From e081a5c5a0fdf274433e5c5d40e65575079ea1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 11 Jan 2016 18:03:08 +0100 Subject: [PATCH] feat(apps): worked on pinning apps --- pkg/api/dtos/index.go | 1 + pkg/api/index.go | 14 ++++----- pkg/plugins/app_plugin.go | 5 ++-- pkg/plugins/queries.go | 31 ++++---------------- public/app/core/controllers/sidemenu_ctrl.js | 1 + public/app/features/apps/partials/list.html | 7 ++++- public/app/partials/sidemenu.html | 5 +++- public/less/sidemenu.less | 4 +++ 8 files changed, 29 insertions(+), 39 deletions(-) diff --git a/pkg/api/dtos/index.go b/pkg/api/dtos/index.go index 64abec6f4e5..c5b81ee0e98 100644 --- a/pkg/api/dtos/index.go +++ b/pkg/api/dtos/index.go @@ -21,5 +21,6 @@ type PluginCss struct { type NavLink struct { Text string `json:"text"` Icon string `json:"icon"` + Img string `json:"img"` Url string `json:"url"` } diff --git a/pkg/api/index.go b/pkg/api/index.go index bbe0c6565a8..ddc2429baf5 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -82,14 +82,12 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { data.PluginCss = append(data.PluginCss, &dtos.PluginCss{Light: plugin.Css.Light, Dark: plugin.Css.Dark}) } - if plugin.Pinned && plugin.Page != nil { - if c.HasUserRole(plugin.Page.ReqRole) { - data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ - Text: plugin.Page.Text, - Url: plugin.Page.Url, - Icon: plugin.Page.Icon, - }) - } + if plugin.Pinned { + data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ + Text: plugin.Name, + Url: setting.AppSubUrl + "/apps/edit/" + plugin.Id, + Img: plugin.Info.Logos.Small, + }) } } diff --git a/pkg/plugins/app_plugin.go b/pkg/plugins/app_plugin.go index 7ffc24cfc0b..b8a3eee2bc0 100644 --- a/pkg/plugins/app_plugin.go +++ b/pkg/plugins/app_plugin.go @@ -8,7 +8,6 @@ import ( type AppPluginPage struct { Text string `json:"text"` - Icon string `json:"icon"` Url string `json:"url"` ReqRole models.RoleType `json:"reqRole"` } @@ -20,8 +19,8 @@ type AppPluginCss struct { type AppPlugin struct { FrontendPluginBase - Css *AppPluginCss `json:"css"` - Page *AppPluginPage `json:"page"` + Css *AppPluginCss `json:"css"` + Page []*AppPluginPage `json:"page"` Pinned bool `json:"-"` Enabled bool `json:"-"` diff --git a/pkg/plugins/queries.go b/pkg/plugins/queries.go index 4a7d5294128..889cbe654d5 100644 --- a/pkg/plugins/queries.go +++ b/pkg/plugins/queries.go @@ -30,41 +30,20 @@ func GetEnabledPlugins(orgId int64) (*EnabledPlugins, error) { seenPanels := make(map[string]bool) seenApi := make(map[string]bool) - for appType, installedApp := range Apps { + for appId, installedApp := range Apps { var app AppPlugin app = *installedApp // check if the app is stored in the DB for this org and if so, use the // state stored there. - if b, ok := orgApps[appType]; ok { + if b, ok := orgApps[appId]; ok { app.Enabled = b.Enabled app.Pinned = b.Pinned } - // if app.Enabled { - // for _, d := range app.DatasourcePlugins { - // if ds, ok := DataSources[d]; ok { - // enabledPlugins.DataSourcePlugins[d] = ds - // } - // } - // for _, p := range app.PanelPlugins { - // if panel, ok := Panels[p]; ok { - // if _, ok := seenPanels[p]; !ok { - // seenPanels[p] = true - // enabledPlugins.PanelPlugins = append(enabledPlugins.PanelPlugins, panel) - // } - // } - // } - // for _, a := range app.ApiPlugins { - // if api, ok := ApiPlugins[a]; ok { - // if _, ok := seenApi[a]; !ok { - // seenApi[a] = true - // enabledPlugins.ApiPlugins = append(enabledPlugins.ApiPlugins, api) - // } - // } - // } - // enabledPlugins.AppPlugins = append(enabledPlugins.AppPlugins, &app) - // } + if app.Enabled { + enabledPlugins.Apps = append(enabledPlugins.Apps, &app) + } } // add all plugins that are not part of an App. diff --git a/public/app/core/controllers/sidemenu_ctrl.js b/public/app/core/controllers/sidemenu_ctrl.js index 368d275a3df..5bca63cb1cd 100644 --- a/public/app/core/controllers/sidemenu_ctrl.js +++ b/public/app/core/controllers/sidemenu_ctrl.js @@ -19,6 +19,7 @@ function (angular, _, $, coreModule, config) { $scope.mainLinks.push({ text: item.text, icon: item.icon, + img: item.img, url: $scope.getUrl(item.url) }); }); diff --git a/public/app/features/apps/partials/list.html b/public/app/features/apps/partials/list.html index 0bdaebe3657..f6c915ff4ce 100644 --- a/public/app/features/apps/partials/list.html +++ b/public/app/features/apps/partials/list.html @@ -32,8 +32,13 @@     - enabled + Enabled +   + + Pinned + + Dashboards: 1 diff --git a/public/app/partials/sidemenu.html b/public/app/partials/sidemenu.html index bf75b465be8..5e83b623438 100644 --- a/public/app/partials/sidemenu.html +++ b/public/app/partials/sidemenu.html @@ -46,7 +46,10 @@
  • - + + + + {{item.text}}
  • diff --git a/public/less/sidemenu.less b/public/less/sidemenu.less index ac3470c65ea..6e9691eaa11 100644 --- a/public/less/sidemenu.less +++ b/public/less/sidemenu.less @@ -92,6 +92,10 @@ top: 5px; font-size: 150%; } + img { + left: 7px; + position: relative; + } } .sidemenu-item {