mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(imports): work on datasource dashboards
This commit is contained in:
parent
ac5f7ecdea
commit
87fc83678c
@ -13,6 +13,7 @@ define([
|
|||||||
'./timeSrv',
|
'./timeSrv',
|
||||||
'./unsavedChangesSrv',
|
'./unsavedChangesSrv',
|
||||||
'./timepicker/timepicker',
|
'./timepicker/timepicker',
|
||||||
|
'./import_list/import_list',
|
||||||
'./graphiteImportCtrl',
|
'./graphiteImportCtrl',
|
||||||
'./dynamicDashboardSrv',
|
'./dynamicDashboardSrv',
|
||||||
'./importCtrl',
|
'./importCtrl',
|
||||||
|
50
public/app/features/dashboard/import_list/import_list.ts
Normal file
50
public/app/features/dashboard/import_list/import_list.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
///<reference path="../../../headers/common.d.ts" />
|
||||||
|
|
||||||
|
import angular from 'angular';
|
||||||
|
import coreModule from 'app/core/core_module';
|
||||||
|
|
||||||
|
class DashboardScriptLoader {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DashImportListCtrl {
|
||||||
|
constructor(private $http) {
|
||||||
|
console.log('importList', this);
|
||||||
|
}
|
||||||
|
|
||||||
|
load(json) {
|
||||||
|
var model = angular.fromJson(json);
|
||||||
|
console.log(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
import() {
|
||||||
|
var url = 'public/app/plugins/datasource/graphite/dashboards/carbon_stats.json';
|
||||||
|
this.$http.get(url).then(res => {
|
||||||
|
this.load(res.data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var template = `
|
||||||
|
<button class="btn btn-mini btn-inverse" ng-click="ctrl.import(dash)">Import</span>
|
||||||
|
`;
|
||||||
|
|
||||||
|
export function dashboardImportList() {
|
||||||
|
return {
|
||||||
|
restrict: 'E',
|
||||||
|
template: template,
|
||||||
|
controller: DashImportListCtrl,
|
||||||
|
bindToController: true,
|
||||||
|
controllerAs: 'ctrl',
|
||||||
|
scope: {
|
||||||
|
plugin: "="
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
coreModule.directive('dashboardImportList', dashboardImportList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -105,8 +105,6 @@ function (angular, _, config) {
|
|||||||
$scope.updateFrontendSettings().then(function() {
|
$scope.updateFrontendSettings().then(function() {
|
||||||
if (test) {
|
if (test) {
|
||||||
$scope.testDatasource();
|
$scope.testDatasource();
|
||||||
} else {
|
|
||||||
$location.path('datasources');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -55,6 +55,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<dashboard-import-list plugin="current"></dashboard-import-list>
|
||||||
|
|
||||||
<div class="pull-right" style="margin-top: 35px">
|
<div class="pull-right" style="margin-top: 35px">
|
||||||
<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()">Add</button>
|
||||||
<button type="submit" class="btn btn-success" ng-show="!isNew" ng-click="saveChanges()">Save</button>
|
<button type="submit" class="btn btn-success" ng-show="!isNew" ng-click="saveChanges()">Save</button>
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"__inputs": {
|
||||||
|
"graphite": {
|
||||||
|
"type": "datasource",
|
||||||
|
"description": "Graphite datasource"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"title": "Carbon stats",
|
||||||
|
"version": 1,
|
||||||
|
"rows": [
|
||||||
|
{
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"type": "graph",
|
||||||
|
"datasource": "__$graphite"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user