Browse Source

feat(plugins): work on plugins that include dashboards

Torkel Ödegaard 9 years ago
parent
commit
3191678b14

+ 18 - 8
public/app/features/dashboard/import_list/import_list.ts

@@ -8,8 +8,13 @@ class DashboardScriptLoader {
 }
 
 export class DashImportListCtrl {
+  dashboards: any[];
+  plugin: any;
+
   constructor(private $http) {
-    console.log('importList', this);
+
+    this.dashboards = this.plugin.includes.filter(val => val.type === 'dashboard');
+
   }
 
   load(json) {
@@ -18,17 +23,22 @@ export class DashImportListCtrl {
   }
 
   import() {
-    var url = 'public/app/plugins/datasource/graphite/dashboards/carbon_stats.json';
-    this.$http.get(url).then(res => {
-      this.load(res.data);
-    });
+    // this.$http.get(url).then(res => {
+    //   this.load(res.data);
+    // });
   }
 }
 
 var template = `
-<h3 class="page-heading">Dashboards</h3>
-<div class="gf-form-group">
-  <button class="btn btn-mini btn-inverse" ng-click="ctrl.import(dash)">Import</button>
+<div class="gf-form-group" ng-if="ctrl.dashboards.length">
+  <h3 class="page-heading">Dashboards</h3>
+  <div class="gf-form" ng-repeat="dash in ctrl.dashboards">
+    <label class="gf-form-label">
+        <i class="icon-gf icon-gf-dashboard"></i>
+    </label>
+    <label class="gf-form-label width-20">{{dash.name}}</label>
+    <button class="btn btn-inverse gf-form-btn" ng-click="ctrl.import(dash)">Import</button>
+  </div>
 </div>
 `;
 

+ 7 - 1
public/app/features/datasources/edit_ctrl.js

@@ -18,7 +18,13 @@ function (angular, _, config) {
 
   module.controller('DataSourceEditCtrl', function($scope, $q, backendSrv, $routeParams, $location, datasourceSrv) {
 
-    var defaults = {name: '', type: 'graphite', url: '', access: 'proxy', jsonData: {}};
+    var defaults = {
+      name: '',
+      type: 'graphite',
+      url: '',
+      access: 'proxy',
+      jsonData: {}
+    };
 
     $scope.init = function() {
       $scope.isNew = true;

+ 2 - 2
public/app/features/datasources/partials/edit.html

@@ -36,6 +36,8 @@ icon="icon-gf icon-gf-datasources">
 		<rebuild-on-change property="datasourceMeta.id">
 			<plugin-component type="datasource-config-ctrl">
 			</plugin-component>
+
+			<dashboard-import-list plugin="datasourceMeta"></dashboard-import-list>
 		</rebuild-on-change>
 
 		<div ng-if="testing" style="margin-top: 25px">
@@ -47,8 +49,6 @@ icon="icon-gf icon-gf-datasources">
 			</div>
 		</div>
 
-		<!-- <dashboard&#45;import&#45;list plugin="current"></dashboard&#45;import&#45;list> -->
-
 		<div class="gf-form-button-row">
 			<button type="submit" class="btn btn-success" ng-show="isNew" ng-click="saveChanges()">Add</button>
 			<button type="submit" class="btn btn-success" ng-show="!isNew" ng-click="saveChanges()">Save</button>