feat(web): update-mode toggle and available-version badge (#8)
This commit is contained in:
@@ -11,12 +11,19 @@ import (
|
||||
|
||||
type serviceGroup struct {
|
||||
Title string
|
||||
Services []model.Service
|
||||
Services []serviceRow
|
||||
}
|
||||
|
||||
// serviceRow is a service as shown in the overview table.
|
||||
type serviceRow struct {
|
||||
model.Service
|
||||
AutoBlocked string // why the service cannot be set to auto; "" when it can
|
||||
}
|
||||
|
||||
// groupServices groups machine-bound services per agent and Swarm services
|
||||
// in one group, keeping the store's order (machines first, Swarm last).
|
||||
func groupServices(services []model.Service) []serviceGroup {
|
||||
// autoBlocked returns the reason a service cannot be set to auto, or "".
|
||||
func groupServices(services []model.Service, autoBlocked func(model.Service) string) []serviceGroup {
|
||||
var groups []serviceGroup
|
||||
index := map[string]int{}
|
||||
for _, s := range services {
|
||||
@@ -32,7 +39,7 @@ func groupServices(services []model.Service) []serviceGroup {
|
||||
index[title] = i
|
||||
groups = append(groups, serviceGroup{Title: title})
|
||||
}
|
||||
groups[i].Services = append(groups[i].Services, s)
|
||||
groups[i].Services = append(groups[i].Services, serviceRow{Service: s, AutoBlocked: autoBlocked(s)})
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user