mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 17:02:15 +08:00
feat(apps): minor progress on app meta data
This commit is contained in:
@ -15,36 +15,31 @@ func GetAppPlugins(c *middleware.Context) Response {
|
|||||||
return ApiError(500, "Failed to list Plugin Bundles", err)
|
return ApiError(500, "Failed to list Plugin Bundles", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
installedAppsMap := make(map[string]*dtos.AppPlugin)
|
translateToDto := func(app *plugins.AppPlugin) *dtos.AppPlugin {
|
||||||
for t, a := range plugins.Apps {
|
return &dtos.AppPlugin{
|
||||||
installedAppsMap[t] = &dtos.AppPlugin{
|
Name: app.Name,
|
||||||
Type: a.Type,
|
Type: app.Type,
|
||||||
Enabled: a.Enabled,
|
Enabled: app.Enabled,
|
||||||
Pinned: a.Pinned,
|
Pinned: app.Pinned,
|
||||||
Module: a.Module,
|
Module: app.Module,
|
||||||
JsonData: make(map[string]interface{}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seenApps := make(map[string]bool)
|
seenApps := make(map[string]bool)
|
||||||
|
|
||||||
result := make([]*dtos.AppPlugin, 0)
|
result := make([]*dtos.AppPlugin, 0)
|
||||||
for _, b := range query.Result {
|
for _, orgApp := range query.Result {
|
||||||
if def, ok := installedAppsMap[b.Type]; ok {
|
if def, ok := plugins.Apps[orgApp.Type]; ok {
|
||||||
result = append(result, &dtos.AppPlugin{
|
pluginDto := translateToDto(def)
|
||||||
Type: b.Type,
|
pluginDto.Enabled = orgApp.Enabled
|
||||||
Enabled: b.Enabled,
|
pluginDto.JsonData = orgApp.JsonData
|
||||||
Pinned: b.Pinned,
|
result = append(result, pluginDto)
|
||||||
Module: def.Module,
|
seenApps[orgApp.Type] = true
|
||||||
JsonData: b.JsonData,
|
|
||||||
})
|
|
||||||
seenApps[b.Type] = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for t, a := range installedAppsMap {
|
for _, app := range plugins.Apps {
|
||||||
if _, ok := seenApps[t]; !ok {
|
if _, ok := seenApps[app.Type]; !ok {
|
||||||
result = append(result, a)
|
result = append(result, translateToDto(app))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dtos
|
package dtos
|
||||||
|
|
||||||
type AppPlugin struct {
|
type AppPlugin struct {
|
||||||
|
Name string `json:"name"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
Pinned bool `json:"pinned"`
|
Pinned bool `json:"pinned"`
|
||||||
|
@ -4,6 +4,23 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/models"
|
"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 DataSourcePlugin struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@ -61,12 +78,14 @@ type ApiPlugin struct {
|
|||||||
|
|
||||||
type AppPlugin struct {
|
type AppPlugin struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
Name string `json:"name"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
Pinned bool `json:"pinned"`
|
Pinned bool `json:"pinned"`
|
||||||
Module string `json:"module"`
|
Module string `json:"module"`
|
||||||
Css *AppPluginCss `json:"css"`
|
Css *AppPluginCss `json:"css"`
|
||||||
Page *AppPluginPage `json:"page"`
|
Page *AppPluginPage `json:"page"`
|
||||||
PublicContent *PublicContent `json:"public"`
|
PublicContent *PublicContent `json:"public"`
|
||||||
|
Info *PluginInfo `json:"info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EnabledPlugins struct {
|
type EnabledPlugins struct {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
///<reference path="../../headers/common.d.ts" />
|
///<reference path="../../headers/common.d.ts" />
|
||||||
|
|
||||||
import config = require('app/core/config');
|
import config from 'app/core/config';
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
import * as _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
export class AppEditCtrl {
|
export class AppEditCtrl {
|
||||||
appModel: any;
|
appModel: any;
|
||||||
@ -25,3 +25,4 @@ export class AppEditCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
angular.module('grafana.controllers').controller('AppEditCtrl', AppEditCtrl);
|
angular.module('grafana.controllers').controller('AppEditCtrl', AppEditCtrl);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
///<reference path="../../headers/common.d.ts" />
|
///<reference path="../../headers/common.d.ts" />
|
||||||
|
|
||||||
import config = require('app/core/config');
|
import _ from 'lodash';
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
|
|
||||||
export class AppSrv {
|
export class AppSrv {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</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-status">
|
||||||
<span class="filter-list-card-state">Dashboards: 1</span>
|
<span class="filter-list-card-state">Dashboards: 1</span>
|
||||||
</span>
|
</span>
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"pluginType": "datasource",
|
"pluginType": "datasource",
|
||||||
"name": "Graphite",
|
"name": "Graphite",
|
||||||
|
|
||||||
"type": "graphite",
|
"type": "graphite",
|
||||||
"serviceName": "GraphiteDatasource",
|
|
||||||
|
|
||||||
|
"serviceName": "GraphiteDatasource",
|
||||||
"module": "app/plugins/datasource/graphite/datasource",
|
"module": "app/plugins/datasource/graphite/datasource",
|
||||||
|
|
||||||
"partials": {
|
"partials": {
|
||||||
|
Reference in New Issue
Block a user