add uptime to display
This commit is contained in:
parent
dee71085ab
commit
36544d813a
6
flake.lock
generated
6
flake.lock
generated
@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1711333969,
|
"lastModified": 1713714899,
|
||||||
"narHash": "sha256-5PiWGn10DQjMZee5NXzeA6ccsv60iLu+Xtw+mfvkUAs=",
|
"narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "57e6b3a9e4ebec5aa121188301f04a6b8c354c9b",
|
"rev": "6143fc5eeb9c4f00163267708e26191d1e918932",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
go
|
go
|
||||||
gopls
|
gopls
|
||||||
go-tools
|
go-tools
|
||||||
|
nilaway
|
||||||
|
|
||||||
glfw
|
glfw
|
||||||
pkg-config
|
pkg-config
|
||||||
|
22
main.go
22
main.go
@ -60,6 +60,7 @@ type Status struct {
|
|||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Port int32 `json:"port"`
|
Port int32 `json:"port"`
|
||||||
Uname string `json:"uname_a"`
|
Uname string `json:"uname_a"`
|
||||||
|
Uptime string `json:"uptime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -307,7 +308,7 @@ func (s *Status) ToTable() *widget.Table {
|
|||||||
t := widget.NewTable(
|
t := widget.NewTable(
|
||||||
// Length
|
// Length
|
||||||
func() (int, int) {
|
func() (int, int) {
|
||||||
return 6, 2
|
return 7, 2
|
||||||
},
|
},
|
||||||
// CreateCell
|
// CreateCell
|
||||||
func() fyne.CanvasObject {
|
func() fyne.CanvasObject {
|
||||||
@ -329,10 +330,12 @@ func (s *Status) ToTable() *widget.Table {
|
|||||||
case 2:
|
case 2:
|
||||||
content.SetText("Uname")
|
content.SetText("Uname")
|
||||||
case 3:
|
case 3:
|
||||||
content.SetText("Configuration Revision")
|
content.SetText("Uptime")
|
||||||
case 4:
|
case 4:
|
||||||
content.SetText("Restart?")
|
content.SetText("Configuration Revision")
|
||||||
case 5:
|
case 5:
|
||||||
|
content.SetText("Restart?")
|
||||||
|
case 6:
|
||||||
content.SetText("System Diff")
|
content.SetText("System Diff")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,14 +348,16 @@ func (s *Status) ToTable() *widget.Table {
|
|||||||
case 2:
|
case 2:
|
||||||
content.SetText(s.Uname)
|
content.SetText(s.Uname)
|
||||||
case 3:
|
case 3:
|
||||||
content.SetText(s.ConfigurationRevision)
|
content.SetText(s.Uptime)
|
||||||
case 4:
|
case 4:
|
||||||
|
content.SetText(s.ConfigurationRevision)
|
||||||
|
case 5:
|
||||||
str := "No"
|
str := "No"
|
||||||
if s.NeedsRestart {
|
if s.NeedsRestart {
|
||||||
str = "Yes"
|
str = "Yes"
|
||||||
}
|
}
|
||||||
content.SetText(str)
|
content.SetText(str)
|
||||||
case 5:
|
case 6:
|
||||||
text, err := base64.StdEncoding.DecodeString(s.SystemDiff)
|
text, err := base64.StdEncoding.DecodeString(s.SystemDiff)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("decode error:", err)
|
fmt.Println("decode error:", err)
|
||||||
@ -373,7 +378,7 @@ func (s *Status) ToTable() *widget.Table {
|
|||||||
|
|
||||||
t.SetColumnWidth(0, 300.0)
|
t.SetColumnWidth(0, 300.0)
|
||||||
t.SetColumnWidth(1, 600.0)
|
t.SetColumnWidth(1, 600.0)
|
||||||
t.SetRowHeight(5, 600.0)
|
t.SetRowHeight(6, 600.0)
|
||||||
|
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
@ -390,17 +395,22 @@ func buildCards(stat *xinStatus) fyne.CanvasObject {
|
|||||||
verBStr := binding.BindString(&s.NixosVersion)
|
verBStr := binding.BindString(&s.NixosVersion)
|
||||||
bvl := widget.NewLabelWithData(verBStr)
|
bvl := widget.NewLabelWithData(verBStr)
|
||||||
|
|
||||||
|
uptimeBStr := binding.BindString(&s.Uptime)
|
||||||
|
uvl := widget.NewLabelWithData(uptimeBStr)
|
||||||
|
|
||||||
restartBBool := binding.BindBool(&s.NeedsRestart)
|
restartBBool := binding.BindBool(&s.NeedsRestart)
|
||||||
bbl := widget.NewCheckWithData("Reboot", restartBBool)
|
bbl := widget.NewCheckWithData("Reboot", restartBBool)
|
||||||
bbl.Disable()
|
bbl.Disable()
|
||||||
|
|
||||||
stat.boundStrings = append(stat.boundStrings, commitBStr)
|
stat.boundStrings = append(stat.boundStrings, commitBStr)
|
||||||
stat.boundStrings = append(stat.boundStrings, verBStr)
|
stat.boundStrings = append(stat.boundStrings, verBStr)
|
||||||
|
stat.boundStrings = append(stat.boundStrings, uptimeBStr)
|
||||||
stat.boundBools = append(stat.boundBools, restartBBool)
|
stat.boundBools = append(stat.boundBools, restartBBool)
|
||||||
|
|
||||||
card := widget.NewCard(s.Host, "",
|
card := widget.NewCard(s.Host, "",
|
||||||
container.NewVBox(
|
container.NewVBox(
|
||||||
container.NewHBox(bvl),
|
container.NewHBox(bvl),
|
||||||
|
container.NewHBox(uvl),
|
||||||
container.NewHBox(bbl),
|
container.NewHBox(bbl),
|
||||||
container.NewHBox(bsl),
|
container.NewHBox(bsl),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user