Explorar el Código

feat(apps): minor progress on app meta data

Torkel Ödegaard hace 10 años
padre
commit
41a0995db7

+ 17 - 22
pkg/api/app_plugin.go

@@ -15,36 +15,31 @@ func GetAppPlugins(c *middleware.Context) Response {
 		return ApiError(500, "Failed to list Plugin Bundles", err)
 	}
 
-	installedAppsMap := make(map[string]*dtos.AppPlugin)
-	for t, a := range plugins.Apps {
-		installedAppsMap[t] = &dtos.AppPlugin{
-			Type:     a.Type,
-			Enabled:  a.Enabled,
-			Pinned:   a.Pinned,
-			Module:   a.Module,
-			JsonData: make(map[string]interface{}),
+	translateToDto := func(app *plugins.AppPlugin) *dtos.AppPlugin {
+		return &dtos.AppPlugin{
+			Name:    app.Name,
+			Type:    app.Type,
+			Enabled: app.Enabled,
+			Pinned:  app.Pinned,
+			Module:  app.Module,
 		}
 	}
 
 	seenApps := make(map[string]bool)
-
 	result := make([]*dtos.AppPlugin, 0)
-	for _, b := range query.Result {
-		if def, ok := installedAppsMap[b.Type]; ok {
-			result = append(result, &dtos.AppPlugin{
-				Type:     b.Type,
-				Enabled:  b.Enabled,
-				Pinned:   b.Pinned,
-				Module:   def.Module,
-				JsonData: b.JsonData,
-			})
-			seenApps[b.Type] = true
+	for _, orgApp := range query.Result {
+		if def, ok := plugins.Apps[orgApp.Type]; ok {
+			pluginDto := translateToDto(def)
+			pluginDto.Enabled = orgApp.Enabled
+			pluginDto.JsonData = orgApp.JsonData
+			result = append(result, pluginDto)
+			seenApps[orgApp.Type] = true
 		}
 	}
 
-	for t, a := range installedAppsMap {
-		if _, ok := seenApps[t]; !ok {
-			result = append(result, a)
+	for _, app := range plugins.Apps {
+		if _, ok := seenApps[app.Type]; !ok {
+			result = append(result, translateToDto(app))
 		}
 	}
 

+ 1 - 0
pkg/api/dtos/app_plugin.go

@@ -1,6 +1,7 @@
 package dtos
 
 type AppPlugin struct {
+	Name     string                 `json:"name"`
 	Type     string                 `json:"type"`
 	Enabled  bool                   `json:"enabled"`
 	Pinned   bool                   `json:"pinned"`

+ 19 - 0
pkg/plugins/models.go

@@ -4,6 +4,23 @@ import (
 	"github.com/grafana/grafana/pkg/models"
 )
 
+type PluginInfo struct {
+	Author      PluginAuthor `json:"author"`
+	Description string       `json:"description"`
+	Homepage    string       `json:"homepage"`
+	Logos       PluginLogos  `json:"logos"`
+}
+
+type PluginAuthor struct {
+	Name string `json:"name"`
+	Url  string `json:"url"`
+}
+
+type PluginLogos struct {
+	Small string `json:"small"`
+	Large string `json:"large"`
+}
+
 type DataSourcePlugin struct {
 	Type               string                 `json:"type"`
 	Name               string                 `json:"name"`
@@ -61,12 +78,14 @@ type ApiPlugin struct {
 
 type AppPlugin struct {
 	Type          string         `json:"type"`
+	Name          string         `json:"name"`
 	Enabled       bool           `json:"enabled"`
 	Pinned        bool           `json:"pinned"`
 	Module        string         `json:"module"`
 	Css           *AppPluginCss  `json:"css"`
 	Page          *AppPluginPage `json:"page"`
 	PublicContent *PublicContent `json:"public"`
+	Info          *PluginInfo    `json:"info"`
 }
 
 type EnabledPlugins struct {

+ 3 - 2
public/app/features/org/app_edit_ctrl.ts

@@ -1,8 +1,8 @@
 ///<reference path="../../headers/common.d.ts" />
 
-import config = require('app/core/config');
+import config from 'app/core/config';
 import angular from 'angular';
-import * as _ from 'lodash';
+import _ from 'lodash';
 
 export class AppEditCtrl {
   appModel: any;
@@ -25,3 +25,4 @@ export class AppEditCtrl {
 }
 
 angular.module('grafana.controllers').controller('AppEditCtrl', AppEditCtrl);
+

+ 1 - 1
public/app/features/org/app_srv.ts

@@ -1,6 +1,6 @@
 ///<reference path="../../headers/common.d.ts" />
 
-import config = require('app/core/config');
+import _ from 'lodash';
 import angular from 'angular';
 
 export class AppSrv {

+ 1 - 1
public/app/features/org/partials/app_list.html

@@ -23,7 +23,7 @@
 								</a>
               </div>
             </div>
-						<span class="filter-list-card-title">Litmus{{app.type}}</span>
+						<span class="filter-list-card-title">{{app.name}}</span>
             <span class="filter-list-card-status">
               <span class="filter-list-card-state">Dashboards: 1</span>
             </span>

+ 1 - 2
public/app/plugins/datasource/graphite/plugin.json

@@ -1,10 +1,9 @@
 {
   "pluginType": "datasource",
   "name": "Graphite",
-
   "type": "graphite",
-  "serviceName": "GraphiteDatasource",
 
+  "serviceName": "GraphiteDatasource",
   "module": "app/plugins/datasource/graphite/datasource",
 
   "partials": {