Commit e081a5c5 by Torkel Ödegaard

feat(apps): worked on pinning apps

parent 4da31291
...@@ -21,5 +21,6 @@ type PluginCss struct { ...@@ -21,5 +21,6 @@ type PluginCss struct {
type NavLink struct { type NavLink struct {
Text string `json:"text"` Text string `json:"text"`
Icon string `json:"icon"` Icon string `json:"icon"`
Img string `json:"img"`
Url string `json:"url"` Url string `json:"url"`
} }
...@@ -82,16 +82,14 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { ...@@ -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}) data.PluginCss = append(data.PluginCss, &dtos.PluginCss{Light: plugin.Css.Light, Dark: plugin.Css.Dark})
} }
if plugin.Pinned && plugin.Page != nil { if plugin.Pinned {
if c.HasUserRole(plugin.Page.ReqRole) {
data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
Text: plugin.Page.Text, Text: plugin.Name,
Url: plugin.Page.Url, Url: setting.AppSubUrl + "/apps/edit/" + plugin.Id,
Icon: plugin.Page.Icon, Img: plugin.Info.Logos.Small,
}) })
} }
} }
}
return &data, nil return &data, nil
} }
......
...@@ -8,7 +8,6 @@ import ( ...@@ -8,7 +8,6 @@ import (
type AppPluginPage struct { type AppPluginPage struct {
Text string `json:"text"` Text string `json:"text"`
Icon string `json:"icon"`
Url string `json:"url"` Url string `json:"url"`
ReqRole models.RoleType `json:"reqRole"` ReqRole models.RoleType `json:"reqRole"`
} }
...@@ -21,7 +20,7 @@ type AppPluginCss struct { ...@@ -21,7 +20,7 @@ type AppPluginCss struct {
type AppPlugin struct { type AppPlugin struct {
FrontendPluginBase FrontendPluginBase
Css *AppPluginCss `json:"css"` Css *AppPluginCss `json:"css"`
Page *AppPluginPage `json:"page"` Page []*AppPluginPage `json:"page"`
Pinned bool `json:"-"` Pinned bool `json:"-"`
Enabled bool `json:"-"` Enabled bool `json:"-"`
......
...@@ -30,41 +30,20 @@ func GetEnabledPlugins(orgId int64) (*EnabledPlugins, error) { ...@@ -30,41 +30,20 @@ func GetEnabledPlugins(orgId int64) (*EnabledPlugins, error) {
seenPanels := make(map[string]bool) seenPanels := make(map[string]bool)
seenApi := make(map[string]bool) seenApi := make(map[string]bool)
for appType, installedApp := range Apps { for appId, installedApp := range Apps {
var app AppPlugin var app AppPlugin
app = *installedApp app = *installedApp
// check if the app is stored in the DB for this org and if so, use the // check if the app is stored in the DB for this org and if so, use the
// state stored there. // state stored there.
if b, ok := orgApps[appType]; ok { if b, ok := orgApps[appId]; ok {
app.Enabled = b.Enabled app.Enabled = b.Enabled
app.Pinned = b.Pinned app.Pinned = b.Pinned
} }
// if app.Enabled { if app.Enabled {
// for _, d := range app.DatasourcePlugins { enabledPlugins.Apps = append(enabledPlugins.Apps, &app)
// 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)
// }
} }
// add all plugins that are not part of an App. // add all plugins that are not part of an App.
......
...@@ -19,6 +19,7 @@ function (angular, _, $, coreModule, config) { ...@@ -19,6 +19,7 @@ function (angular, _, $, coreModule, config) {
$scope.mainLinks.push({ $scope.mainLinks.push({
text: item.text, text: item.text,
icon: item.icon, icon: item.icon,
img: item.img,
url: $scope.getUrl(item.url) url: $scope.getUrl(item.url)
}); });
}); });
......
...@@ -32,8 +32,13 @@ ...@@ -32,8 +32,13 @@
</a> </a>
&nbsp; &nbsp; &nbsp; &nbsp;
<span class="label label-info" ng-if="app.enabled"> <span class="label label-info" ng-if="app.enabled">
enabled Enabled
</span> </span>
&nbsp;
<span class="label label-info" ng-if="app.pinned">
Pinned
</span>
</span> </span>
<span class="filter-list-card-status"> <span class="filter-list-card-status">
<span class="filter-list-card-state">Dashboards: 1</span> <span class="filter-list-card-state">Dashboards: 1</span>
......
...@@ -46,7 +46,10 @@ ...@@ -46,7 +46,10 @@
<li ng-repeat="item in mainLinks"> <li ng-repeat="item in mainLinks">
<a href="{{item.url}}" class="sidemenu-item sidemenu-main-link" target="{{item.target}}"> <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> <span class="sidemenu-item-text">{{item.text}}</span>
</a> </a>
</li> </li>
......
...@@ -92,6 +92,10 @@ ...@@ -92,6 +92,10 @@
top: 5px; top: 5px;
font-size: 150%; font-size: 150%;
} }
img {
left: 7px;
position: relative;
}
} }
.sidemenu-item { .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