Commit e081a5c5 by Torkel Ödegaard

feat(apps): worked on pinning apps

parent 4da31291
......@@ -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"`
}
......@@ -82,16 +82,14 @@ 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) {
if plugin.Pinned {
data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
Text: plugin.Page.Text,
Url: plugin.Page.Url,
Icon: plugin.Page.Icon,
Text: plugin.Name,
Url: setting.AppSubUrl + "/apps/edit/" + plugin.Id,
Img: plugin.Info.Logos.Small,
})
}
}
}
return &data, nil
}
......
......@@ -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"`
}
......@@ -21,7 +20,7 @@ type AppPluginCss struct {
type AppPlugin struct {
FrontendPluginBase
Css *AppPluginCss `json:"css"`
Page *AppPluginPage `json:"page"`
Page []*AppPluginPage `json:"page"`
Pinned bool `json:"-"`
Enabled bool `json:"-"`
......
......@@ -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.
......
......@@ -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)
});
});
......
......@@ -32,8 +32,13 @@
</a>
&nbsp; &nbsp;
<span class="label label-info" ng-if="app.enabled">
enabled
Enabled
</span>
&nbsp;
<span class="label label-info" ng-if="app.pinned">
Pinned
</span>
</span>
<span class="filter-list-card-status">
<span class="filter-list-card-state">Dashboards: 1</span>
......
......@@ -46,7 +46,10 @@
<li ng-repeat="item in mainLinks">
<a href="{{item.url}}" class="sidemenu-item sidemenu-main-link" target="{{item.target}}">
<span class="icon-circle sidemenu-icon"><i class="{{item.icon}}"></i></span>
<span class="icon-circle sidemenu-icon">
<i class="{{item.icon}}" ng-show="item.icon"></i>
<img src="{{item.img}}" ng-show="item.img">
</span>
<span class="sidemenu-item-text">{{item.text}}</span>
</a>
</li>
......
......@@ -92,6 +92,10 @@
top: 5px;
font-size: 150%;
}
img {
left: 7px;
position: relative;
}
}
.sidemenu-item {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment