Merge pull request #22 from RiV-chain/offline_ui

load index.html from file resource
This commit is contained in:
Vadym Vikulin 2022-11-26 16:29:44 +02:00 committed by GitHub
commit d834b2515f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 175 additions and 161 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.history

4
contrib/ui/mesh-ui/assets/all.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>RiV-mesh</title> <title>RiV-mesh</title>
<link rel="stylesheet" href="https://maxst.icons8.com/vue-static/landings/line-awesome/font-awesome-line-awesome/css/all.min.css" type="text/css"> <link rel="stylesheet" href="assets/all.min.css" type="text/css">
<link rel="stylesheet" href="https://unpkg.com/bulmaswatch/slate/bulmaswatch.min.css" type="text/css"> <link rel="stylesheet" href="assets/bulmaswatch.min.css" type="text/css">
<script> <script>
function setFieldValue(id, value){ function setFieldValue(id, value){

Binary file not shown.

View file

@ -1,21 +1,22 @@
package main package main
import ( import (
"github.com/webview/webview"
"github.com/hjson/hjson-go"
"encoding/json" "encoding/json"
"path/filepath"
"io/ioutil"
"os/exec"
"net/url"
"runtime"
"strings"
"strconv"
"time"
"net"
"log"
"fmt" "fmt"
"io/ioutil"
"log"
"net"
"net/url"
"os" "os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
"github.com/hjson/hjson-go"
"github.com/webview/webview"
"github.com/RiV-chain/RiV-mesh/src/admin" "github.com/RiV-chain/RiV-mesh/src/admin"
) )
@ -105,9 +106,10 @@ func main() {
w.Bind("ping", func(peer_list string) { w.Bind("ping", func(peer_list string) {
go ping(w, peer_list) go ping(w, peer_list)
}) })
dat, err := ioutil.ReadFile(path+"/index.html") //dat, err := ioutil.ReadFile(path+"/index.html")
w.Navigate("data:text/html,"+url.QueryEscape(string(dat))) //w.Navigate("data:text/html,"+url.QueryEscape(string(dat)))
//w.Navigate("data:text/html,"+"<html>"+path+"</html>") //w.Navigate("data:text/html,"+"<html>"+path+"</html>")
w.Navigate("file://" + path + "/index.html")
w.Run() w.Run()
} }
@ -117,9 +119,9 @@ func ping(w webview.WebView, peer_list string){
log.Printf("Unmarshaled: %v", peers) log.Printf("Unmarshaled: %v", peers)
for _, u := range peers { for _, u := range peers {
log.Printf("Unmarshaled: %v", u) log.Printf("Unmarshaled: %v", u)
ping_time := check(u); ping_time := check(u)
log.Printf("ping: %d", ping_time) log.Printf("ping: %d", ping_time)
setPingValue(w, u, strconv.FormatInt(ping_time, 10)); setPingValue(w, u, strconv.FormatInt(ping_time, 10))
} }
} }