Commit 78b9c300 by Torkel Ödegaard

feat(plugins): minor progress on dashboard imports

parent 1951f385
...@@ -63,6 +63,7 @@ function setupAngularRoutes($routeProvider, $locationProvider) { ...@@ -63,6 +63,7 @@ function setupAngularRoutes($routeProvider, $locationProvider) {
.when('/datasources/new', { .when('/datasources/new', {
templateUrl: 'public/app/features/datasources/partials/edit.html', templateUrl: 'public/app/features/datasources/partials/edit.html',
controller : 'DataSourceEditCtrl', controller : 'DataSourceEditCtrl',
controllerAs: 'ctrl',
resolve: loadOrgBundle, resolve: loadOrgBundle,
}) })
.when('/org', { .when('/org', {
......
...@@ -31,14 +31,21 @@ export class DashImportListCtrl { ...@@ -31,14 +31,21 @@ export class DashImportListCtrl {
var template = ` var template = `
<div class="gf-form-group" ng-if="ctrl.dashboards.length"> <div class="gf-form-group" ng-if="ctrl.dashboards.length">
<h3 class="page-heading">Dashboards</h3> <table class="filter-table">
<div class="gf-form" ng-repeat="dash in ctrl.dashboards"> <tbody>
<label class="gf-form-label"> <tr ng-repeat="dash in ctrl.dashboards">
<td class="width-1">
<i class="icon-gf icon-gf-dashboard"></i> <i class="icon-gf icon-gf-dashboard"></i>
</label> </td>
<label class="gf-form-label width-20">{{dash.name}}</label> <td>
<button class="btn btn-inverse gf-form-btn" ng-click="ctrl.import(dash)">Import</button> {{dash.name}}</span>
</div> </td>
<td class="width-2">
<button class="btn btn-primary btn-small">Install</button>
</td
</tr>
</tbody>
</table>
</div> </div>
`; `;
......
...@@ -22,6 +22,8 @@ export class DataSourceEditCtrl { ...@@ -22,6 +22,8 @@ export class DataSourceEditCtrl {
types: any; types: any;
testing: any; testing: any;
datasourceMeta: any; datasourceMeta: any;
tabIndex: number;
hasDashboards: boolean;
/** @ngInject */ /** @ngInject */
constructor( constructor(
...@@ -34,6 +36,7 @@ export class DataSourceEditCtrl { ...@@ -34,6 +36,7 @@ export class DataSourceEditCtrl {
this.isNew = true; this.isNew = true;
this.datasources = []; this.datasources = [];
this.tabIndex = 0;
this.loadDatasourceTypes().then(() => { this.loadDatasourceTypes().then(() => {
if (this.$routeParams.id) { if (this.$routeParams.id) {
...@@ -66,8 +69,10 @@ export class DataSourceEditCtrl { ...@@ -66,8 +69,10 @@ export class DataSourceEditCtrl {
} }
typeChanged() { typeChanged() {
this.hasDashboards = false;
return this.backendSrv.get('/api/org/plugins/' + this.current.type + '/settings').then(pluginInfo => { return this.backendSrv.get('/api/org/plugins/' + this.current.type + '/settings').then(pluginInfo => {
this.datasourceMeta = pluginInfo; this.datasourceMeta = pluginInfo;
this.hasDashboards = _.findWhere(pluginInfo.includes, {type: 'dashboard'});
}); });
} }
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
<ul class="gf-tabs"> <ul class="gf-tabs">
<li class="gf-tabs-item"> <li class="gf-tabs-item">
<a class="gf-tabs-link" ng-click="ctrl.editor.index = 0" ng-class="{active: ctrl.editor.index === 0}"> <a class="gf-tabs-link" ng-click="ctrl.tabIndex = 0" ng-class="{active: ctrl.tabIndex === 0}">
Config Config
</a> </a>
</li> </li>
<li class="gf-tabs-item" ng-show="ctrl.hasDashboards" ng-cloak> <li class="gf-tabs-item" ng-show="ctrl.hasDashboards" ng-cloak>
<a class="gf-tabs-link" ng-click="ctrl.editor.index = 1" ng-class="{active: ctrl.editor.index === 1}"> <a class="gf-tabs-link" ng-click="ctrl.tabIndex = 1" ng-class="{active: ctrl.tabIndex === 1}">
Dashboards Dashboards
</a> </a>
</li> </li>
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
</div> </div>
</div> </div>
<div ng-if="ctrl.tabIndex === 0" class="tab-content">
<form name="editForm"> <form name="editForm">
<div class="gf-form-group"> <div class="gf-form-group">
...@@ -51,8 +52,6 @@ ...@@ -51,8 +52,6 @@
<rebuild-on-change property="ctrl.datasourceMeta.id"> <rebuild-on-change property="ctrl.datasourceMeta.id">
<plugin-component type="datasource-config-ctrl"> <plugin-component type="datasource-config-ctrl">
</plugin-component> </plugin-component>
<dashboard-import-list plugin="ctrl.datasourceMeta"></dashboard-import-list>
</rebuild-on-change> </rebuild-on-change>
<div ng-if="testing" style="margin-top: 25px"> <div ng-if="testing" style="margin-top: 25px">
...@@ -74,5 +73,11 @@ ...@@ -74,5 +73,11 @@
</div> </div>
</form> </form>
</div>
<div ng-if="ctrl.tabIndex === 1" class="tab-content">
<dashboard-import-list plugin="ctrl.datasourceMeta"></dashboard-import-list>
</div>
</div> </div>
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
"id": "graphite", "id": "graphite",
"includes": [ "includes": [
{"type": "dashboard", "name": "Carbon Stats", "path": "dashboards/carbon_stats.json"} {"type": "dashboard", "name": "Carbon Overview", "path": "dashboards/carbon_stats.json"},
{"type": "dashboard", "name": "Carbon Agent Details", "path": "dashboards/carbon_stats.json"}
], ],
"metrics": true, "metrics": true,
......
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