1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package ui
import (
// "time"
// "github.com/Z-Bolt/OctoScreen/interfaces"
"github.com/Z-Bolt/OctoScreen/uiWidgets"
"github.com/Z-Bolt/OctoScreen/utils"
)
var systemPanelInstance *systemPanel = nil
type systemPanel struct {
CommonPanel
// First row
octoPrintInfoBox *uiWidgets.OctoPrintInfoBox
octoScreenInfoBox *uiWidgets.OctoScreenInfoBox
octoScreenPluginInfoBox *uiWidgets.OctoScreenPluginInfoBox
// Second row
systemInformationInfoBox *uiWidgets.SystemInformationInfoBox
// Third row
shutdownSystemButton *uiWidgets.SystemCommandButton
rebootSystemButton *uiWidgets.SystemCommandButton
restartOctoPrintButton *uiWidgets.SystemCommandButton
}
func SystemPanel(
ui *UI,
) *systemPanel {
if systemPanelInstance == nil {
instance := &systemPanel {
CommonPanel: NewCommonPanel("SystemPanel", ui),
}
instance.initialize()
instance.preShowCallback = instance.refreshSystemInformationInfoBox
systemPanelInstance = instance
}
return systemPanelInstance
}
func (this *systemPanel) initialize() {
defer this.Initialize()
// First row
logoWidth := this.Scaled(52)
this.octoPrintInfoBox = uiWidgets.CreateOctoPrintInfoBox(this.UI.Client, logoWidth)
this.Grid().Attach(this.octoPrintInfoBox, 0, 0, 1, 1)
this.octoScreenInfoBox = uiWidgets.CreateOctoScreenInfoBox(this.UI.Client, utils.OctoScreenVersion)
this.Grid().Attach(this.octoScreenInfoBox, 1, 0, 2, 1)
this.octoScreenPluginInfoBox = uiWidgets.CreateOctoScreenPluginInfoBox(this.UI.Client, this.UI.UIState, this.UI.OctoPrintPluginIsAvailable)
this.Grid().Attach(this.octoScreenPluginInfoBox, 3, 0, 1, 1)
// Second row
this.systemInformationInfoBox = uiWidgets.CreateSystemInformationInfoBox(this.UI.window, this.UI.scaleFactor)
this.Grid().Attach(this.systemInformationInfoBox, 0, 1, 4, 1)
// Third row
this.shutdownSystemButton = uiWidgets.CreateSystemCommandButton(
this.UI.Client,
this.UI.window,
"Shutdown System",
"shutdown",
"color-warning-sign-yellow",
)
this.Grid().Attach(this.shutdownSystemButton, 0, 2, 1, 1)
this.rebootSystemButton = uiWidgets.CreateSystemCommandButton(
this.UI.Client,
this.UI.window,
"Reboot System",
"reboot",
"color-warning-sign-yellow",
)
this.Grid().Attach(this.rebootSystemButton, 1, 2, 1, 1)
this.restartOctoPrintButton = uiWidgets.CreateSystemCommandButton(
this.UI.Client,
this.UI.window,
"Restart OctoPrint",
"restart",
"color-warning-sign-yellow",
)
this.Grid().Attach(this.restartOctoPrintButton, 2, 2, 1, 1)
}
func (this *systemPanel) refreshSystemInformationInfoBox() {
this.systemInformationInfoBox.Refresh()
}
|