Commit 8ea43517 by Nikolay Bryskin

import from non-default dashboard support

parent 34a18514
......@@ -12,12 +12,25 @@ function (angular, app, _) {
$scope.init = function() {
console.log('hej!');
$scope.datasources = datasourceSrv.listOptions();
$scope.setDatasource(datasourceSrv.default.value);
};
$scope.setDatasource = function(datasource) {
$scope.datasource = datasourceSrv.get(datasource);
if (!$scope.datasource) {
$scope.error = "Cannot find datasource " + datasource;
return;
}
};
$scope.listAll = function(query) {
delete $scope.error;
datasourceSrv.default.listDashboards(query)
$scope.datasource.listDashboards(query)
.then(function(results) {
$scope.dashboards = results;
})
......@@ -29,7 +42,7 @@ function (angular, app, _) {
$scope.import = function(dashName) {
delete $scope.error;
datasourceSrv.default.loadDashboard(dashName)
$scope.datasource.loadDashboard(dashName)
.then(function(results) {
if (!results.data || !results.data.state) {
throw { message: 'no dashboard state received from graphite' };
......
<div ng-controller="GraphiteImportCtrl" ng-init="init()">
<div ng-controller="GraphiteImportCtrl" ng-init="init()" style="height: 400px">
<h5>Import dashboards from graphite web</h5>
<div class="editor-row">
<div class="section">
<div class="btn-group">
<button class="btn btn-info dropdown-toggle" data-toggle="dropdown" bs-tooltip="'Datasource'">{{datasource.name}} <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li ng-repeat="datasource in datasources" role="menuitem">
<a ng-click="setDatasource(datasource.value);">{{datasource.name}}</a>
</li>
</ul>
</div>
<button ng-click="listAll()" class="btn btn-primary">List all dashboards</button>
</div>
</div>
......
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