فهرست منبع

feat(apps): worked on pinning apps

Torkel Ödegaard 10 سال پیش
والد
کامیت
e081a5c5a0

+ 1 - 0
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"`
 }

+ 6 - 8
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,
+			})
 		}
 	}
 

+ 2 - 3
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:"-"`

+ 5 - 26
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.

+ 1 - 0
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)
         });
       });

+ 6 - 1
public/app/features/apps/partials/list.html

@@ -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>

+ 4 - 1
public/app/partials/sidemenu.html

@@ -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>

+ 4 - 0
public/less/sidemenu.less

@@ -92,6 +92,10 @@
     top: 5px;
     font-size: 150%;
   }
+  img {
+    left: 7px;
+    position: relative;
+  }
 }
 
 .sidemenu-item {