Skip to content

Commit f9d4519

Browse files
committed
feat(tx_send): Added maintenance
1 parent 0c4843d commit f9d4519

File tree

4 files changed

+81
-10
lines changed

4 files changed

+81
-10
lines changed

gui/dialog_deploy.go

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func showDeployDialog(g *Gui, doneListener binding.DataListener, shidaiInfra bin
143143
}
144144

145145
// cmdForDeploy := fmt.Sprintf(`echo '%v' | sudo -S sh -c "$(curl -s --show-error --fail %v 2>&1 )"`, sP, types.BOOTSTRAP_SCRIPT)
146+
146147
cmdForDeploy := fmt.Sprintf(`echo '%v' | sudo -S sh -c "$(curl -s --show-error --fail %v 2>&1 --sekai=%v --interx=%v)"`, sP, types.BOOTSTRAP_SCRIPT, sekaiVersion, interxVersion)
147148
showCmdExecDialogAndRunCmdV4(g, "Deploying", cmdForDeploy, true, deployErrorBinding, errorMessageBinding)
148149

gui/dialogs.go

+35
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"regexp"
7+
"strings"
78
"sync"
89

910
"fyne.io/fyne/v2"
@@ -187,3 +188,37 @@ func showWarningMessageWithConfirmation(g *Gui, warningMessage string, confirmAc
187188
wizard.Show(g.Window)
188189
wizard.Resize(fyne.NewSize(500, 400))
189190
}
191+
192+
func showMonikerEntryDialog(g *Gui, monikerBinding binding.String, confirmAction binding.DataListener) {
193+
var wizard *dialogWizard.Wizard
194+
195+
monikerEntry := widget.NewEntry()
196+
monikerEntry.Wrapping = fyne.TextWrap(fyne.TextTruncateClip)
197+
monikerEntry.MultiLine = true
198+
199+
doneButton := widget.NewButton("Claim", func() {
200+
moniker := monikerEntry.Text
201+
trimmed := strings.TrimSpace(moniker)
202+
if trimmed == "" {
203+
monikerEntry.SetValidationError(fmt.Errorf("moniker cannot be empty"))
204+
return
205+
}
206+
monikerBinding.Set(moniker)
207+
confirmAction.DataChanged()
208+
wizard.Hide()
209+
})
210+
doneButton.Importance = widget.HighImportance
211+
212+
cancelButton := widget.NewButton("Cancel", func() { wizard.Hide() })
213+
214+
content := container.NewBorder(
215+
nil,
216+
container.NewVBox(doneButton, cancelButton),
217+
nil, nil,
218+
container.NewVScroll(monikerEntry),
219+
)
220+
221+
wizard = dialogWizard.NewWizard("Enter your Moniker", content)
222+
wizard.Show(g.Window)
223+
wizard.Resize(fyne.NewSize(500, 400))
224+
}

gui/screen_nodeInfo.go

+43-9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
type nodeInfoScreen struct {
2424
ctx context.Context
2525
ctxCancel context.CancelFunc
26+
27+
executingStatus bool
2628
}
2729

2830
func makeNodeInfoScreen(_ fyne.Window, g *Gui) fyne.CanvasObject {
@@ -222,10 +224,37 @@ func makeNodeInfoTab(g *Gui) fyne.CanvasObject {
222224
widget.NewFormItem("Gen.SHA256:", genesisChecksumLabel),
223225
)
224226

225-
execFunc := func(arg types.Cmd) {
227+
loadingData := binding.NewFloat()
228+
229+
loadMessage := binding.NewString()
230+
txExecLoadingWidget := container.NewHBox(
231+
widget.NewProgressBarWithData(loadingData), widget.NewLabelWithData(loadMessage),
232+
)
233+
234+
startTXexec := func(command string) {
235+
txExecLoadingWidget.Show()
236+
g.NodeInfo.executingStatus = true
237+
238+
loadMessage.Set(fmt.Sprintf("Executing <%v> command", command))
239+
validatorControlButton.Disable()
240+
maxRange := 40
241+
for i := range maxRange {
242+
time.Sleep(time.Second * time.Duration(i))
243+
percentage := (i * 100) / maxRange
244+
loadingData.Set(float64(percentage))
245+
246+
}
247+
txExecLoadingWidget.Hide()
248+
g.NodeInfo.executingStatus = false
249+
refreshBinding.DataChanged()
250+
}
251+
252+
execFunc := func(args types.ExecSekaiCmd) {
253+
go startTXexec(string(args.TX))
226254
g.WaitDialog.ShowWaitDialog()
227-
payload, err := json.Marshal(types.ExecSekaiCmd{TX: arg})
228-
log.Printf("Executing: %v", arg)
255+
payload, err := json.Marshal(args)
256+
257+
log.Printf("Executing: %v", args)
229258
if err != nil {
230259
g.showErrorDialog(err, binding.NewDataListener(func() {}))
231260
}
@@ -235,22 +264,27 @@ func makeNodeInfoTab(g *Gui) fyne.CanvasObject {
235264
refreshBinding.DataChanged()
236265
}
237266

267+
monikerEntryData := binding.NewString()
268+
claimDataListener := binding.NewDataListener(func() {
269+
moniker, _ := monikerEntryData.Get()
270+
execFunc(types.ExecSekaiCmd{TX: types.ClaimValidatorSeat, Moniker: moniker})
271+
})
272+
238273
claimSeatButton.OnTapped = func() {
239274
//claim seat
240-
execFunc(types.ClaimValidatorSeat)
275+
showMonikerEntryDialog(g, monikerEntryData, claimDataListener)
241276
}
242277
pauseValidatorFunc := func() {
243278
// pause
244-
execFunc(types.Pause)
279+
execFunc(types.ExecSekaiCmd{TX: types.Pause})
245280
}
246281
unpauseValidatorFunc := func() {
247282
// unpause tx
248-
execFunc(types.Unpause)
283+
execFunc(types.ExecSekaiCmd{TX: types.Unpause})
249284
}
250285
activateValidatorFunc := func() {
251286
// activate
252-
execFunc(types.Activate)
253-
287+
execFunc(types.ExecSekaiCmd{TX: types.Activate})
254288
}
255289

256290
errBinding := binding.NewUntyped()
@@ -271,7 +305,7 @@ func makeNodeInfoTab(g *Gui) fyne.CanvasObject {
271305
claimSeatButton.Hide()
272306
}
273307

274-
if dashboardData.ValidatorStatus != "Unknown" {
308+
if dashboardData.ValidatorStatus != "Unknown" && !g.NodeInfo.executingStatus {
275309
status := strings.ToUpper(dashboardData.ValidatorStatus)
276310
switch status {
277311
case string(shidai.Active):

types/types.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ const (
3838
)
3939

4040
type ExecSekaiCmd struct {
41-
TX Cmd `json:"tx"` //pause, unpause, activate,
41+
TX Cmd `json:"tx"` //pause, unpause, activate,
42+
Moniker string `json:"moniker"`
4243
}

0 commit comments

Comments
 (0)