add configuration: top nav order and settings
This commit is contained in:
1 parent
d300354725
commit
12decb7862
9 files changed
+386
-71
No files matched your search
@@ -0,0 +1,57 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type NavItem struct {
|
||||
Label string `json:"label"`
|
||||
Href string `json:"href"`
|
||||
}
|
||||
|
||||
func defaultNavItems() []NavItem {
|
||||
|
||||
return []NavItem{
|
||||
{
|
||||
Label: "Home",
|
||||
Href: "/",
|
||||
},
|
||||
{
|
||||
Label: "Tree",
|
||||
Href: "/v/tree",
|
||||
},
|
||||
{
|
||||
Label: "Config",
|
||||
Href: "/-/sys/config",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) getNavItems() []NavItem {
|
||||
|
||||
raw, err :=
|
||||
s.store.GetConfig(
|
||||
"nav_items",
|
||||
)
|
||||
|
||||
if err != nil ||
|
||||
raw == "" {
|
||||
|
||||
return defaultNavItems()
|
||||
}
|
||||
|
||||
var items []NavItem
|
||||
|
||||
err = json.Unmarshal(
|
||||
[]byte(raw),
|
||||
&items,
|
||||
)
|
||||
|
||||
if err != nil ||
|
||||
len(items) == 0 {
|
||||
|
||||
return defaultNavItems()
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
Reference in new issue
Block a user