feat(apps): worked on pinning apps

This commit is contained in:
Torkel Ödegaard
2016-01-11 18:03:08 +01:00
parent 4da31291d2
commit e081a5c5a0
8 changed files with 29 additions and 39 deletions
+2 -3
View File
@@ -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:"-"`
+5 -26
View File
@@ -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.