UI Tunings

This commit is contained in:
Ivan Danyliuk
2018-11-16 18:42:57 +01:00
parent 62f82b8af1
commit ab7c5a0439
9 changed files with 6371 additions and 1761 deletions
+16 -4
View File
@@ -67,10 +67,10 @@ func (a *App) Render() vecty.ComponentOrHTML {
vecty.Markup(
vecty.Class("column", "is-half"),
),
vecty.If(!a.session.InProgress(), elem.Div(
vecty.If(!a.session.InProgress() && a.session.State() != StateFinished, elem.Div(
a.settings,
)),
vecty.If(a.session.InProgress(), elem.Div(
vecty.If(a.session.InProgress() || a.session.State() == StateFinished, elem.Div(
a.resultsTable,
)),
),
@@ -106,10 +106,20 @@ func (a *App) SetConnected(val bool) {
// ShowNext handles request to show next animated QR.
func (a *App) ShowNext() {
if a.session.State() == StateNew {
a.session.UpdateConfig(a.settings.Config())
}
setup, ok := a.session.StartNext()
if !ok {
vecty.Rerender(a)
return
}
a.generatingQR = true
vecty.Rerender(a)
time.Sleep(100 * time.Millisecond) // wait till JS thread pickup rerender before running heavy computaiton. withoit this delay it'll never rerender
setup, _ := a.session.StartNext()
time.Sleep(100 * time.Millisecond) // wait till JS thread pickup rerender before running heavy computaiton. without this delay it'll never rerender
log.Println("Creating animated gif for", setup)
now := time.Now()
gif, err := AnimatedGif(a.testData, 500, setup)
@@ -117,10 +127,12 @@ func (a *App) ShowNext() {
log.Println("[ERROR] Can't generate gif: %v", err)
// TODO: session abort
a.generatingQR = false
vecty.Rerender(a)
return
}
log.Println("Took time:", time.Since(now))
a.animatingQR = gif
a.session.SetState(StateAnimating)
a.generatingQR = false
vecty.Rerender(a)
+6316 -1742
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+13 -2
View File
@@ -28,8 +28,9 @@ func (a *App) QR() vecty.ComponentOrHTML {
vecty.Markup(
vecty.Class("has-text-weight-bold"),
),
vecty.If(state == StateFinished, vecty.Text("Test completed")),
vecty.If(!a.connected, vecty.Text("Scan QR code to connect")),
vecty.If(a.connected && !a.session.InProgress() && state != StateAnimating, vecty.Text("Scan QR code for next test")),
vecty.If(a.connected && !a.session.InProgress() && state != StateAnimating && state != StateFinished, vecty.Text("Scan QR code for next test")),
vecty.If(a.connected && state == StateAnimating, vecty.Text("Sending data via QR...")),
),
),
@@ -56,7 +57,7 @@ func (a *App) QR() vecty.ComponentOrHTML {
),
),
),
vecty.If(a.connected,
vecty.If(a.connected && state != StateFinished,
elem.Paragraph(
vecty.Markup(
vecty.Class("card-footer-item", "has-background-success", "has-text-white", "has-text-weight-bold"),
@@ -66,6 +67,16 @@ func (a *App) QR() vecty.ComponentOrHTML {
),
),
),
vecty.If(state == StateFinished,
elem.Paragraph(
vecty.Markup(
vecty.Class("card-footer-item", "has-background-primary", "has-text-white", "has-text-weight-bold"),
),
vecty.Text(
fmt.Sprintf("Finished"),
),
),
),
),
)
}
+9 -3
View File
@@ -32,15 +32,21 @@ func NewSession() *Session {
}
}
// CurrentSetup returns the test setup of the currently executing round.
func (s *Session) CurrentSetup() testSetup {
if s.state == StateNew || s.state == StateFinished {
return testSetup{}
}
ts := s.tests[s.idx]
ts := s.tests[s.idx-1]
return *ts
}
// UpdateConfig sets the new config for the session.
func (s *Session) UpdateConfig(config SessionConfig) {
s.config = config
}
// StartNext starts next round of testing. It returns
// next untested parameters for QR code.
func (s *Session) StartNext() (*testSetup, bool) {
@@ -82,8 +88,8 @@ func (s *Session) generateTestsSetup() []*testSetup {
if s.config.Levels[lvl] == false {
continue
}
for fps := s.config.StartFPS; fps < s.config.StopFPS; fps++ {
for sz := s.config.StartSize; sz < s.config.StopSize; sz += s.config.SizeStep {
for fps := s.config.StartFPS; fps <= s.config.StopFPS; fps++ {
for sz := s.config.StartSize; sz <= s.config.StopSize; sz += s.config.SizeStep {
ret = append(ret, newTestSetup(fps, sz, lvl))
}
}
+7 -2
View File
@@ -43,6 +43,11 @@ func (s *Settings) Render() vecty.ComponentOrHTML {
)
}
// Config returns current configuration.
func (s *Settings) Config() SessionConfig {
return s.config
}
func (s *Settings) chunkSizesRow() vecty.ComponentOrHTML {
return elem.Div(
vecty.Markup(
@@ -205,8 +210,8 @@ func (s *Settings) checkboxInput(name string, val bool, check func(bool)) vecty.
}
func (s *Settings) hint() vecty.ComponentOrHTML {
nChunks := (s.config.StopSize - s.config.StartSize) / s.config.SizeStep
nFPS := s.config.StopFPS - s.config.StartFPS
nChunks := (s.config.StopSize-s.config.StartSize)/s.config.SizeStep + 1
nFPS := s.config.StopFPS - s.config.StartFPS + 1
numberOfTests := s.config.Levels.numEnabled() * nFPS * nChunks
text := fmt.Sprintf("This will run %d tests", numberOfTests)
return elem.Div(
+2
View File
@@ -68,12 +68,14 @@ func (w *WSClient) processWSCommand(data []byte) {
case ws.CmdStartNext:
log.Println("Got start_nextx")
w.app.ShowNext()
w.sendMsg(&ws.UIResponse{Type: ws.Ack})
case ws.CmdResult:
log.Println("Got result")
dur := time.Duration(msg.Duration) * time.Millisecond
setup := w.app.session.CurrentSetup()
res := NewResult(setup, dur)
w.app.ProcessResult(res)
w.sendMsg(&ws.UIResponse{Type: ws.Ack})
default:
log.Printf("[ERROR] Invalid message '%s', ignoring", msg.Cmd)
}
File diff suppressed because one or more lines are too long
+4 -4
View File
@@ -50,7 +50,7 @@ func (ws *WSBridge) handleFirstClient() {
for {
mt, message, err := ws.first.ReadMessage()
if err != nil {
log.Println("[ERROR] Read:", err)
log.Println("[ERROR] Read first:", err)
break
}
if ws.second == nil {
@@ -60,7 +60,7 @@ func (ws *WSBridge) handleFirstClient() {
}
err = ws.second.WriteMessage(mt, message)
if err != nil {
log.Println("[ERROR] Write:", err)
log.Println("[ERROR] Write second:", err)
return
}
}
@@ -70,7 +70,7 @@ func (ws *WSBridge) handleSecondClient() {
for {
mt, message, err := ws.second.ReadMessage()
if err != nil {
log.Println("[ERROR] Read:", err)
log.Println("[ERROR] Read second:", err)
break
}
if ws.first == nil {
@@ -80,7 +80,7 @@ func (ws *WSBridge) handleSecondClient() {
}
err = ws.first.WriteMessage(mt, message)
if err != nil {
log.Println("[ERROR] Write:", err)
log.Println("[ERROR] Write first:", err)
return
}
}