Moved windows stuff to own package
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
9d373ae81d
commit
9d7710b376
69
main.go
69
main.go
|
@ -58,13 +58,13 @@ func main() {
|
|||
router.RegisterRoutes(e)
|
||||
// Start server
|
||||
go func() {
|
||||
fmt.Println(config.GetConfig())
|
||||
if err := e.Start(config.GetInterface()); err != nil {
|
||||
e.Logger.Info("shutting down...")
|
||||
}
|
||||
}()
|
||||
|
||||
// TODO: Make sure everything still works
|
||||
// TODO: Move all this window crap in its own package
|
||||
// TODO: Distribute as single binary
|
||||
// TODO: Switch to viper
|
||||
// TODO: SSE
|
||||
|
@ -73,70 +73,5 @@ func main() {
|
|||
// TODO: Tests?
|
||||
|
||||
//Windows
|
||||
// Create astilectron
|
||||
var a *astilectron.Astilectron
|
||||
var err error
|
||||
if a, err = astilectron.New(astilectron.Options{
|
||||
AppName: "Astilectron",
|
||||
AppIconDefaultPath: "gopher.png",
|
||||
AppIconDarwinPath: "gopher.icns",
|
||||
BaseDirectoryPath: "astilectron-deps",
|
||||
}); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "creating new astilectron failed"))
|
||||
}
|
||||
defer a.Close()
|
||||
a.HandleSignals()
|
||||
|
||||
// Start
|
||||
if err = a.Start(); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "starting failed"))
|
||||
}
|
||||
|
||||
// Create Frontend window
|
||||
var wFrontend *astilectron.Window
|
||||
wFrontend, err = a.NewWindow("http://"+config.GetInterface(), &astilectron.WindowOptions{
|
||||
Center: astilectron.PtrBool(true),
|
||||
Height: astilectron.PtrInt(800),
|
||||
Width: astilectron.PtrInt(1200),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "new window failed"))
|
||||
}
|
||||
if err = wFrontend.Create(); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "creating window failed"))
|
||||
}
|
||||
|
||||
// If several displays, move the window to the second display
|
||||
var displays = a.Displays()
|
||||
if len(displays) > 1 {
|
||||
if displays[1].IsPrimary() {
|
||||
wFrontend.MoveInDisplay(displays[0], 50, 50)
|
||||
} else {
|
||||
wFrontend.MoveInDisplay(displays[1], 50, 50)
|
||||
}
|
||||
wFrontend.Maximize()
|
||||
}
|
||||
|
||||
// Create Admin window
|
||||
var wAdmin *astilectron.Window
|
||||
if wAdmin, err = a.NewWindow("http://"+config.GetInterface()+"/admin", &astilectron.WindowOptions{
|
||||
Center: astilectron.PtrBool(true),
|
||||
Height: astilectron.PtrInt(700),
|
||||
Width: astilectron.PtrInt(1200),
|
||||
}); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "new window failed"))
|
||||
}
|
||||
if err = wAdmin.Create(); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "creating window failed"))
|
||||
}
|
||||
|
||||
// Blocking pattern
|
||||
a.Wait()
|
||||
//windows.OpenWindows()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package windows
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.kolaente.de/konrad/Konfi-Castle-Kasino/pkg/config"
|
||||
"github.com/asticode/go-astilectron"
|
||||
"github.com/asticode/go-astilog"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func OpenWindows() {
|
||||
// Create astilectron
|
||||
var a *astilectron.Astilectron
|
||||
var err error
|
||||
if a, err = astilectron.New(astilectron.Options{
|
||||
AppName: "Astilectron",
|
||||
AppIconDefaultPath: "gopher.png",
|
||||
AppIconDarwinPath: "gopher.icns",
|
||||
BaseDirectoryPath: "astilectron-deps",
|
||||
}); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "creating new astilectron failed"))
|
||||
}
|
||||
defer a.Close()
|
||||
a.HandleSignals()
|
||||
|
||||
// Start
|
||||
if err = a.Start(); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "starting failed"))
|
||||
}
|
||||
|
||||
// Create Frontend window
|
||||
var wFrontend *astilectron.Window
|
||||
wFrontend, err = a.NewWindow("http://"+config.GetInterface(), &astilectron.WindowOptions{
|
||||
Center: astilectron.PtrBool(true),
|
||||
Height: astilectron.PtrInt(800),
|
||||
Width: astilectron.PtrInt(1200),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "new window failed"))
|
||||
}
|
||||
if err = wFrontend.Create(); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "creating window failed"))
|
||||
}
|
||||
|
||||
// If several displays, move the window to the second display
|
||||
var displays = a.Displays()
|
||||
if len(displays) > 1 {
|
||||
if displays[1].IsPrimary() {
|
||||
wFrontend.MoveInDisplay(displays[0], 50, 50)
|
||||
} else {
|
||||
wFrontend.MoveInDisplay(displays[1], 50, 50)
|
||||
}
|
||||
wFrontend.Maximize()
|
||||
}
|
||||
|
||||
// Create Admin window
|
||||
var wAdmin *astilectron.Window
|
||||
if wAdmin, err = a.NewWindow("http://"+config.GetInterface()+"/admin", &astilectron.WindowOptions{
|
||||
Center: astilectron.PtrBool(true),
|
||||
Height: astilectron.PtrInt(700),
|
||||
Width: astilectron.PtrInt(1200),
|
||||
}); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "new window failed"))
|
||||
}
|
||||
if err = wAdmin.Create(); err != nil {
|
||||
fmt.Println(err)
|
||||
astilog.Fatal(errors.Wrap(err, "creating window failed"))
|
||||
}
|
||||
|
||||
// Blocking pattern
|
||||
a.Wait()
|
||||
}
|
Loading…
Reference in New Issue