2019-02-01 07:28:17 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "log"
|
2019-05-06 20:57:59 -05:00
|
|
|
import "os"
|
2019-05-06 19:42:59 -05:00
|
|
|
import "time"
|
2019-05-07 06:28:50 -05:00
|
|
|
import "fmt"
|
2019-02-01 07:28:17 -06:00
|
|
|
|
|
|
|
import "github.com/gookit/config"
|
|
|
|
|
2019-05-10 03:21:32 -05:00
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
2019-05-08 15:09:44 -05:00
|
|
|
import "git.wit.com/wit/gui"
|
|
|
|
|
2019-05-07 07:02:39 -05:00
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
2019-02-01 07:28:17 -06:00
|
|
|
|
|
|
|
// reminder to use this for JSON
|
|
|
|
// https://github.com/tidwall/gjson
|
|
|
|
// value := gjson.Get(json, "name.last")
|
|
|
|
// println(value.String())
|
|
|
|
// value := gjson.Get(json, friends.#[last=="Murphy"].first)
|
|
|
|
|
|
|
|
// use mergo to merge structs
|
|
|
|
// import "github.com/imdario/mergo"
|
|
|
|
// mergo.Merge(&dest, src)
|
|
|
|
|
|
|
|
// always sorted slice (new project)
|
|
|
|
// https://github.com/yaa110/sslice
|
|
|
|
|
2019-05-10 03:21:32 -05:00
|
|
|
func add2() {
|
2019-05-08 19:44:14 -05:00
|
|
|
var parts []gui.InputData
|
|
|
|
|
2019-05-09 08:52:51 -05:00
|
|
|
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
2019-05-08 19:44:14 -05:00
|
|
|
log.Println(key, foo)
|
|
|
|
|
|
|
|
var b gui.InputData
|
|
|
|
b.CellType = foo
|
|
|
|
b.Heading = fmt.Sprintf("heading%d", key)
|
|
|
|
parts = append(parts, b)
|
|
|
|
}
|
|
|
|
|
2019-05-08 16:21:05 -05:00
|
|
|
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
|
|
|
time.Sleep(1 * 1000 * 1000 * 1000)
|
2019-05-09 08:52:51 -05:00
|
|
|
gui.AddTableTab("test seven", 7, parts)
|
2019-05-10 03:21:32 -05:00
|
|
|
}
|
2019-05-08 16:21:05 -05:00
|
|
|
|
2019-05-10 03:21:32 -05:00
|
|
|
func main() {
|
|
|
|
parseConfig()
|
2019-05-08 17:29:06 -05:00
|
|
|
|
2019-05-10 03:21:32 -05:00
|
|
|
// only test the socket code if no GUI
|
|
|
|
if (config.String("nogui") == "true") {
|
|
|
|
retrySocket()
|
|
|
|
onExit()
|
|
|
|
}
|
2019-05-08 16:03:10 -05:00
|
|
|
|
2019-05-10 03:21:32 -05:00
|
|
|
go retrySocket()
|
2019-05-07 16:54:08 -05:00
|
|
|
|
2019-05-10 03:21:32 -05:00
|
|
|
// make this the main loop in an attempt to figure out the crashes
|
|
|
|
// do not change this until the GUI is stable
|
|
|
|
ui.Main(setupCloudUI)
|
|
|
|
|
|
|
|
/*
|
2019-05-07 16:54:08 -05:00
|
|
|
for account, _ := range config.StringMap("cloud") {
|
|
|
|
port := config.String("cloud." + account + ".port")
|
|
|
|
proto := config.String("cloud." + account + ".proto")
|
|
|
|
hostname := config.String("cloud." + account + ".hostname")
|
2019-05-09 08:52:51 -05:00
|
|
|
rows := config.Int("cloud." + account + ".rows")
|
|
|
|
fmt.Println(hostname, port, proto, rows)
|
|
|
|
|
2019-05-08 19:44:14 -05:00
|
|
|
gui.AddTableTab(account, rows, parts)
|
2019-05-09 08:52:51 -05:00
|
|
|
|
2019-05-08 03:49:09 -05:00
|
|
|
log.Println("Sleep for 10 seconds, then add next table")
|
|
|
|
time.Sleep(10 * 1000 * 1000 * 1000)
|
2019-05-07 16:54:08 -05:00
|
|
|
}
|
2019-05-10 03:21:32 -05:00
|
|
|
*/
|
2019-05-07 07:02:39 -05:00
|
|
|
}
|
2019-05-06 20:57:59 -05:00
|
|
|
|
2019-05-07 07:02:39 -05:00
|
|
|
// Exit and write out the config
|
|
|
|
// (in yaml and json I guess.)
|
|
|
|
// switch to json once it can be made human readable
|
|
|
|
func onExit() {
|
2019-05-06 20:57:59 -05:00
|
|
|
log.Println("Sleep for 1 second")
|
|
|
|
time.Sleep(1 * 1000 * 1000 * 1000)
|
|
|
|
|
2019-05-07 07:02:39 -05:00
|
|
|
f, err := os.Create("/tmp/cloud-control-panel.yaml")
|
|
|
|
if err == nil {
|
|
|
|
config.DumpTo(f, "yaml")
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err = os.Create("/tmp/cloud-control-panel.json")
|
|
|
|
if err == nil {
|
|
|
|
config.DumpTo(f, "json")
|
|
|
|
}
|
2019-05-06 20:57:59 -05:00
|
|
|
|
2019-05-07 07:02:39 -05:00
|
|
|
os.Exit(0)
|
2019-02-01 07:28:17 -06:00
|
|
|
}
|