feat(plugins): more work on plugin dashboard install, #4298
This commit is contained in:
1 parent
2de439bd1e
commit
fc54c01f01
23 files changed
+70
-55
No files matched your search
@@ -27,7 +27,8 @@ type PluginListItem struct {
|
||||
}
|
||||
|
||||
type InstallPluginDashboardCmd struct {
|
||||
PluginId string `json:"pluginId"`
|
||||
Path string `json:"path"`
|
||||
Inputs map[string]interface{} `json:"inputs"`
|
||||
PluginId string `json:"pluginId"`
|
||||
Path string `json:"path"`
|
||||
Reinstall bool `json:"reinstall"`
|
||||
Inputs map[string]interface{} `json:"inputs"`
|
||||
}
|
||||
@@ -48,8 +48,9 @@ func InstallPluginDashboard(cmd *InstallPluginDashboardCommand) error {
|
||||
Title: dashboard.Title,
|
||||
Path: cmd.Path,
|
||||
Revision: dashboard.GetString("revision", "1.0"),
|
||||
InstalledURI: "db/" + saveCmd.Result.Slug,
|
||||
InstalledUri: "db/" + saveCmd.Result.Slug,
|
||||
InstalledRevision: dashboard.GetString("revision", "1.0"),
|
||||
Installed: true,
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
type PluginDashboardInfoDTO struct {
|
||||
PluginId string `json:"pluginId"`
|
||||
Title string `json:"title"`
|
||||
InstalledURI string `json:"installedURI"`
|
||||
Installed bool `json:"installed"`
|
||||
InstalledUri string `json:"installedUri"`
|
||||
InstalledRevision string `json:"installedRevision"`
|
||||
Revision string `json:"revision"`
|
||||
Description string `json:"description"`
|
||||
@@ -83,7 +84,8 @@ func getDashboardImportStatus(orgId int64, plugin *PluginBase, path string) (*Pl
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
res.InstalledURI = "db/" + query.Result.Slug
|
||||
res.Installed = true
|
||||
res.InstalledUri = "db/" + query.Result.Slug
|
||||
res.InstalledRevision = query.Result.GetString("revision", "1.0")
|
||||
}
|
||||
|
||||
|
||||
@@ -52,19 +52,19 @@ function setupAngularRoutes($routeProvider, $locationProvider) {
|
||||
templateUrl: 'public/app/features/datasources/partials/list.html',
|
||||
controller : 'DataSourcesCtrl',
|
||||
controllerAs: 'ctrl',
|
||||
resolve: loadOrgBundle,
|
||||
resolve: loadPluginsBundle,
|
||||
})
|
||||
.when('/datasources/edit/:id', {
|
||||
templateUrl: 'public/app/features/datasources/partials/edit.html',
|
||||
controller : 'DataSourceEditCtrl',
|
||||
controllerAs: 'ctrl',
|
||||
resolve: loadOrgBundle,
|
||||
resolve: loadPluginsBundle,
|
||||
})
|
||||
.when('/datasources/new', {
|
||||
templateUrl: 'public/app/features/datasources/partials/edit.html',
|
||||
controller : 'DataSourceEditCtrl',
|
||||
controllerAs: 'ctrl',
|
||||
resolve: loadOrgBundle,
|
||||
resolve: loadPluginsBundle,
|
||||
})
|
||||
.when('/org', {
|
||||
templateUrl: 'public/app/features/org/partials/orgDetails.html',
|
||||
|
||||
@@ -13,7 +13,6 @@ define([
|
||||
'./timeSrv',
|
||||
'./unsavedChangesSrv',
|
||||
'./timepicker/timepicker',
|
||||
'./import_list/import_list',
|
||||
'./graphiteImportCtrl',
|
||||
'./dynamicDashboardSrv',
|
||||
'./importCtrl',
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
define([
|
||||
'./list_ctrl',
|
||||
'./edit_ctrl',
|
||||
], function () {});
|
||||
@@ -4,5 +4,4 @@ define([
|
||||
'./userInviteCtrl',
|
||||
'./orgApiKeysCtrl',
|
||||
'./orgDetailsCtrl',
|
||||
'../datasources/all',
|
||||
], function () {});
|
||||
@@ -1,3 +1,6 @@
|
||||
import './edit_ctrl';
|
||||
import './page_ctrl';
|
||||
import './list_ctrl';
|
||||
import './plugin_edit_ctrl';
|
||||
import './plugin_page_ctrl';
|
||||
import './plugin_list_ctrl';
|
||||
import './import_list/import_list';
|
||||
import './ds_edit_ctrl';
|
||||
import './ds_list_ctrl';
|
||||
+1
-1
@@ -140,6 +140,6 @@ coreModule.controller('DataSourceEditCtrl', DataSourceEditCtrl);
|
||||
coreModule.directive('datasourceHttpSettings', function() {
|
||||
return {
|
||||
scope: {current: "="},
|
||||
templateUrl: 'public/app/features/datasources/partials/http_settings.html'
|
||||
templateUrl: 'public/app/features/plugins/partials/ds_http_settings.html'
|
||||
};
|
||||
});
|
||||
File renamed without changes.
@@ -0,0 +1,37 @@
|
||||
<div class="gf-form-group" ng-if="ctrl.dashboards.length">
|
||||
<table class="filter-table">
|
||||
<tbody>
|
||||
<tr ng-repeat="dash in ctrl.dashboards">
|
||||
<td class="width-1">
|
||||
<i class="icon-gf icon-gf-dashboard"></i>
|
||||
</td>
|
||||
<td>
|
||||
<a href="dashboard/{{dash.installedUri}}" ng-show="dash.installed">
|
||||
{{dash.title}}
|
||||
</a>
|
||||
<span ng-show="!dash.installed">
|
||||
{{dash.title}}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
v{{dash.revision}}
|
||||
</td>
|
||||
<td ng-if="dash.installed">
|
||||
Installed v{{dash.installedRevision}}
|
||||
</td>
|
||||
<td style="text-align: right">
|
||||
<button class="btn btn-secondary" ng-click="ctrl.import(dash, false)" ng-show="!dash.installed">
|
||||
Install
|
||||
</button>
|
||||
<button class="btn btn-secondary" ng-click="ctrl.import(dash, true)" ng-show="dash.installed">
|
||||
Re-Install
|
||||
</button>
|
||||
<button class="btn btn-danger" ng-click="ctrl.remove(dash)" ng-show="dash.installed">
|
||||
Un-install
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
+11
-33
@@ -4,9 +4,6 @@ import angular from 'angular';
|
||||
import _ from 'lodash';
|
||||
import coreModule from 'app/core/core_module';
|
||||
|
||||
class DashboardScriptLoader {
|
||||
}
|
||||
|
||||
export class DashImportListCtrl {
|
||||
dashboards: any[];
|
||||
plugin: any;
|
||||
@@ -19,50 +16,32 @@ export class DashImportListCtrl {
|
||||
});
|
||||
}
|
||||
|
||||
import(dash) {
|
||||
import(dash, reinstall) {
|
||||
var installCmd = {
|
||||
pluginId: this.plugin.id,
|
||||
path: dash.path,
|
||||
reinstall: reinstall,
|
||||
inputs: {}
|
||||
};
|
||||
|
||||
this.backendSrv.post(`/api/plugins/dashboards/install`, installCmd).then(res => {
|
||||
console.log(res);
|
||||
this.$rootScope.appEvent('alert-success', ['Dashboard Installed', dash.title]);
|
||||
_.extend(dash, res);
|
||||
});
|
||||
}
|
||||
|
||||
remove(dash) {
|
||||
this.backendSrv.delete('/api/dashboards/' + dash.installedUri).then(() => {
|
||||
this.$rootScope.appEvent('alert-success', ['Dashboard Deleted', dash.title]);
|
||||
dash.installed = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var template = `
|
||||
<div class="gf-form-group" ng-if="ctrl.dashboards.length">
|
||||
<table class="filter-table">
|
||||
<tbody>
|
||||
<tr ng-repeat="dash in ctrl.dashboards">
|
||||
<td class="width-1">
|
||||
<i class="icon-gf icon-gf-dashboard"></i>
|
||||
</td>
|
||||
<td>
|
||||
{{dash.title}}
|
||||
</td>
|
||||
<td>
|
||||
{{dash.revision}}
|
||||
</td>
|
||||
<td>
|
||||
{{dash.installedRevision}}
|
||||
</td>
|
||||
<td class="width-2">
|
||||
<button class="btn btn-secondary" ng-click="ctrl.import(dash)">Install</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export function dashboardImportList() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: template,
|
||||
templateUrl: 'public/app/features/plugins/import_list/import_list.html',
|
||||
controller: DashImportListCtrl,
|
||||
bindToController: true,
|
||||
controllerAs: 'ctrl',
|
||||
@@ -72,7 +51,6 @@ export function dashboardImportList() {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
coreModule.directive('dashboardImportList', dashboardImportList);
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -6,7 +6,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
"title": "Carbon stats",
|
||||
"title": "Carbon Cache Stats",
|
||||
"version": 1,
|
||||
"rows": [
|
||||
{
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"id": "graphite",
|
||||
|
||||
"includes": [
|
||||
{"type": "dashboard", "name": "Carbon Overview", "path": "dashboards/carbon_stats.json"},
|
||||
{"type": "dashboard", "name": "Carbon Agent Details", "path": "dashboards/carbon_stats.json"}
|
||||
{"type": "dashboard", "name": "Carbon Cache Stats", "path": "dashboards/carbon_stats.json"}
|
||||
],
|
||||
|
||||
"metrics": true,
|
||||
|
||||
Reference in new issue
Block a user