From 0bc226d76093f347604d12fced5b8cc7550f5c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 15 Aug 2017 20:24:16 +0200 Subject: [PATCH] ux: more nav work --- pkg/api/dtos/index.go | 18 +-- pkg/api/index.go | 23 +++- .../core/components/sidemenu/sidemenu.html | 3 +- .../app/core/components/sidemenu/sidemenu.ts | 16 +-- public/app/core/nav_model_srv.ts | 115 +++--------------- public/app/features/admin/admin.ts | 4 +- .../app/features/alerting/alert_list_ctrl.ts | 2 +- .../alerting/notification_edit_ctrl.ts | 4 +- .../alerting/notifications_list_ctrl.ts | 2 +- .../alerting/partials/alert_list.html | 9 +- .../alerting/partials/notifications_list.html | 6 +- .../app/features/org/change_password_ctrl.js | 2 +- public/app/features/org/orgApiKeysCtrl.js | 2 +- public/app/features/org/org_users_ctrl.ts | 2 +- .../org/partials/change_password.html | 5 +- public/app/features/org/partials/profile.html | 5 +- public/app/features/org/profile_ctrl.ts | 2 +- public/app/features/plugins/ds_edit_ctrl.ts | 2 +- public/app/features/plugins/ds_list_ctrl.ts | 2 +- .../app/features/plugins/plugin_edit_ctrl.ts | 2 +- .../app/features/plugins/plugin_list_ctrl.ts | 2 +- .../app/features/plugins/plugin_page_ctrl.ts | 46 +------ public/sass/components/_gf-form.scss | 2 +- public/sass/components/_query_part.scss | 2 +- public/sass/layout/_page.scss | 4 +- 25 files changed, 95 insertions(+), 187 deletions(-) diff --git a/pkg/api/dtos/index.go b/pkg/api/dtos/index.go index c3a8bbd6ef4..ea910901492 100644 --- a/pkg/api/dtos/index.go +++ b/pkg/api/dtos/index.go @@ -20,12 +20,14 @@ type PluginCss struct { } type NavLink struct { - Id string `json:"id,omitempty"` - Text string `json:"text,omitempty"` - Description string `json:"description,omitempty"` - Icon string `json:"icon,omitempty"` - Img string `json:"img,omitempty"` - Url string `json:"url,omitempty"` - Divider bool `json:"divider,omitempty"` - Children []*NavLink `json:"children,omitempty"` + Id string `json:"id,omitempty"` + Text string `json:"text,omitempty"` + Description string `json:"description,omitempty"` + Icon string `json:"icon,omitempty"` + Img string `json:"img,omitempty"` + Url string `json:"url,omitempty"` + Target string `json:"target,omitempty"` + Divider bool `json:"divider,omitempty"` + HideFromMenu bool `json:"hideFromMenu,omitempty"` + Children []*NavLink `json:"children,omitempty"` } diff --git a/pkg/api/index.go b/pkg/api/index.go index c08dafc263d..3e35cbcd01a 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -105,19 +105,35 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { data.NavTree = append(data.NavTree, &dtos.NavLink{ Text: "Dashboards", + Id: "dashboards", Icon: "icon-gf icon-gf-dashboard", Url: setting.AppSubUrl + "/", Children: dashboardChildNavs, }) + if c.IsSignedIn { + data.NavTree = append(data.NavTree, &dtos.NavLink{ + Text: "Your Profile", + Id: "profile", + Icon: "fa fa-fw fa-user", + Url: setting.AppSubUrl + "/profile", + Children: []*dtos.NavLink{ + {Text: "Signout", Url: setting.AppSubUrl + "/logout", Icon: "fa fa-fw fa-sign-out", Target: "_self"}, + {Text: "Your profile", Url: setting.AppSubUrl + "/profile", Icon: "fa fa-fw fa-sliders"}, + {Text: "Change Password", Id: "change-password", Url: setting.AppSubUrl + "/profile/password", Icon: "fa fa-fw fa-lock", HideFromMenu: true}, + }, + }) + } + if setting.AlertingEnabled && (c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR) { alertChildNavs := []*dtos.NavLink{ - {Text: "Alert List", Url: setting.AppSubUrl + "/alerting/list", Icon: "fa fa-fw fa-list-ul"}, - {Text: "Notification channels", Url: setting.AppSubUrl + "/alerting/notifications", Icon: "fa fa-fw fa-bell-o"}, + {Text: "Alert List", Id: "alert-list", Url: setting.AppSubUrl + "/alerting/list", Icon: "fa fa-fw fa-list-ul"}, + {Text: "Notification channels", Id: "channels", Url: setting.AppSubUrl + "/alerting/notifications", Icon: "fa fa-fw fa-bell-o"}, } data.NavTree = append(data.NavTree, &dtos.NavLink{ Text: "Alerting", + Id: "alerting", Icon: "icon-gf icon-gf-alert", Url: setting.AppSubUrl + "/alerting/list", Children: alertChildNavs, @@ -133,6 +149,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { if plugin.Pinned { appLink := &dtos.NavLink{ Text: plugin.Name, + Id: "plugin-page-" + plugin.Id, Url: plugin.DefaultNavUrl, Img: plugin.Info.Logos.Small, } @@ -216,6 +233,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { }, { Text: "API Keys", + Id: "apikeys", Description: "Create & manage API keys", Icon: "fa fa-fw fa-key", Url: setting.AppSubUrl + "/org/apikeys", @@ -226,6 +244,7 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { if c.IsGrafanaAdmin { cfgNode.Children = append(cfgNode.Children, &dtos.NavLink{ Text: "Server Admin", + Id: "admin", Icon: "fa fa-fw fa-shield", Url: setting.AppSubUrl + "/admin", Children: []*dtos.NavLink{ diff --git a/public/app/core/components/sidemenu/sidemenu.html b/public/app/core/components/sidemenu/sidemenu.html index 7d54ad426aa..44271765f00 100644 --- a/public/app/core/components/sidemenu/sidemenu.html +++ b/public/app/core/components/sidemenu/sidemenu.html @@ -39,7 +39,6 @@ -