File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 11package system
22
33import (
4+ "cmp"
45 "encoding/json"
56 "github.com/gofiber/fiber/v2"
67 "github.com/typomedia/patchouli/app/store/boltdb"
78 "github.com/typomedia/patchouli/app/structs"
9+ "slices"
810)
911
1012func List (c * fiber.Ctx ) error {
@@ -24,9 +26,16 @@ func List(c *fiber.Ctx) error {
2426 if err != nil {
2527 return err
2628 }
29+ machinesOfSystem , err := db .GetMachinesBySystem (system .Id )
30+ if err != nil {
31+ return err
32+ }
33+ system .MachineCount = len (machinesOfSystem )
2734 Systems = append (Systems , system )
2835 }
29-
36+ slices .SortFunc (Systems , func (a , b structs.System ) int {
37+ return cmp .Compare (b .MachineCount , a .MachineCount )
38+ })
3039 defer db .Close ()
3140
3241 return c .Render ("app/views/system/list" , fiber.Map {
Original file line number Diff line number Diff line change 11{{ template "header" . }}
2- < table >
2+ < table id =" sort " >
33 < thead >
44 < tr >
55 < th > < a href ="/system/new "> < i class ="ri-edit-box-fill "> </ i > New</ a > </ th >
6+ < th > Machines</ th >
67 < th > LTS</ th >
78 < th > EOL</ th >
89 </ tr >
1112 {{range .Systems}}
1213 < tr >
1314 < td > < i class ="ri-edit-line "> </ i > < a href ="/system/edit/{{.Id}} "> {{.Name}}</ a > </ td >
15+ < td > < a href ="/machine/filter/system/{{.Id}} "> < i class ="ri-menu-search-line "> </ i > {{ .MachineCount }}</ a > </ td >
1416 < td >
1517 {{ if .LTS }}
1618 < span role ="button " class ="primary "> True</ span >
2325 {{end}}
2426 </ tbody >
2527</ table >
28+ < script >
29+ new Tablesort ( document . getElementById ( 'sort' ) ) ;
30+ </ script >
2631{{ template "footer" . }}
You can’t perform that action at this time.
0 commit comments