mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-08-25 08:25:07 +03:00
mesh-ui splash
This commit is contained in:
parent
71b38c4d0b
commit
5fb45014f2
2 changed files with 189 additions and 1 deletions
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/RiV-chain/RiV-mesh/src/defaults"
|
"github.com/RiV-chain/RiV-mesh/src/defaults"
|
||||||
|
|
||||||
|
@ -46,6 +47,191 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Opening: %v", confui.IndexHtml)
|
log.Printf("Opening: %v", confui.IndexHtml)
|
||||||
w.Navigate(confui.IndexHtml)
|
w.SetHtml(strings.Replace(splash, "http://localhost:19019", confui.IndexHtml, 1))
|
||||||
w.Run()
|
w.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var splash = `<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Riv mesh</title>
|
||||||
|
</head>
|
||||||
|
<script>
|
||||||
|
let ep = "http://localhost:19019";
|
||||||
|
|
||||||
|
function redirect() {
|
||||||
|
fetch(ep + '/api')
|
||||||
|
.then(() => {
|
||||||
|
window.location.replace(ep);
|
||||||
|
}).catch((error) => {
|
||||||
|
document.getElementById("error").innerHTML = "Mesh service connection error<br>Waiting for connection....";
|
||||||
|
setTimeout(redirect, 1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
redirect();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
position: absolute;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
.spinner .blob {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
border: 2px solid #fff;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
.spinner .blob.top {
|
||||||
|
top: 0;
|
||||||
|
-webkit-animation: blob-top 1s infinite ease-in;
|
||||||
|
animation: blob-top 1s infinite ease-in;
|
||||||
|
}
|
||||||
|
.spinner .blob.bottom {
|
||||||
|
top: 100%;
|
||||||
|
-webkit-animation: blob-bottom 1s infinite ease-in;
|
||||||
|
animation: blob-bottom 1s infinite ease-in;
|
||||||
|
}
|
||||||
|
.spinner .blob.left {
|
||||||
|
left: 0;
|
||||||
|
-webkit-animation: blob-left 1s infinite ease-in;
|
||||||
|
animation: blob-left 1s infinite ease-in;
|
||||||
|
}
|
||||||
|
.spinner .move-blob {
|
||||||
|
background: #fff;
|
||||||
|
top: 0;
|
||||||
|
-webkit-animation: blob-spinner-mover 1s infinite ease-in;
|
||||||
|
animation: blob-spinner-mover 1s infinite ease-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes blob-bottom {
|
||||||
|
25%, 50%, 75% {
|
||||||
|
top: 50%;
|
||||||
|
left: 100%;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes blob-bottom {
|
||||||
|
25%, 50%, 75% {
|
||||||
|
top: 50%;
|
||||||
|
left: 100%;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@-webkit-keyframes blob-left {
|
||||||
|
25% {
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
50%, 100% {
|
||||||
|
top: 100%;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes blob-left {
|
||||||
|
25% {
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
50%, 100% {
|
||||||
|
top: 100%;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@-webkit-keyframes blob-top {
|
||||||
|
50% {
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
75%, 100% {
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes blob-top {
|
||||||
|
50% {
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
75%, 100% {
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@-webkit-keyframes blob-spinner-mover {
|
||||||
|
0%, 100% {
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
25% {
|
||||||
|
top: 50%;
|
||||||
|
left: 100%;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
top: 100%;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
75% {
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes blob-spinner-mover {
|
||||||
|
0%, 100% {
|
||||||
|
top: 0;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
25% {
|
||||||
|
top: 50%;
|
||||||
|
left: 100%;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
top: 100%;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
75% {
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#error {
|
||||||
|
color: #fff;
|
||||||
|
font-size: 1.5em;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div id="error"></div>
|
||||||
|
<div class="spinner">
|
||||||
|
<div class="blob top"></div>
|
||||||
|
<div class="blob bottom"></div>
|
||||||
|
<div class="blob left"></div>
|
||||||
|
|
||||||
|
<div class="blob move-blob"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`
|
||||||
|
|
|
@ -125,6 +125,8 @@ func addNoCacheHeaders(w http.ResponseWriter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *RestServer) apiHandler(w http.ResponseWriter, r *http.Request) {
|
func (a *RestServer) apiHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
w.Header().Set("Access-Control-Allow-Headers", "*")
|
||||||
fmt.Fprintf(w, "Following methods are allowed: GET /api/self, getpeers. litening")
|
fmt.Fprintf(w, "Following methods are allowed: GET /api/self, getpeers. litening")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue