mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
import from non-default dashboard support
This commit is contained in:
parent
34a18514b6
commit
8ea4351797
@ -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' };
|
||||
|
@ -1,8 +1,17 @@
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user