2015-02-04 11:35:19 +01:00
|
|
|
define([
|
|
|
|
|
'angular',
|
|
|
|
|
'app',
|
|
|
|
|
'lodash',
|
|
|
|
|
'config',
|
|
|
|
|
'components/panelmeta',
|
|
|
|
|
],
|
|
|
|
|
function (angular, app, _, config, PanelMeta) {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
var module = angular.module('grafana.panels.dashlist', []);
|
|
|
|
|
app.useModule(module);
|
|
|
|
|
|
|
|
|
|
module.directive('grafanaPanelDashlist', function() {
|
|
|
|
|
return {
|
|
|
|
|
controller: 'DashListPanelCtrl',
|
|
|
|
|
templateUrl: 'app/panels/dashlist/module.html',
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.controller('DashListPanelCtrl', function($scope, panelSrv, backendSrv) {
|
|
|
|
|
|
|
|
|
|
$scope.panelMeta = new PanelMeta({
|
2015-07-06 12:24:11 +02:00
|
|
|
panelName: 'Dashboard list',
|
2015-02-04 11:35:19 +01:00
|
|
|
editIcon: "fa fa-star",
|
|
|
|
|
fullscreen: true,
|
|
|
|
|
});
|
|
|
|
|
|
2015-02-05 09:48:14 +01:00
|
|
|
$scope.panelMeta.addEditorTab('Options', 'app/panels/dashlist/editor.html');
|
|
|
|
|
|
2015-02-04 11:35:19 +01:00
|
|
|
var defaults = {
|
2015-02-05 09:48:14 +01:00
|
|
|
mode: 'starred',
|
|
|
|
|
query: '',
|
2015-02-05 11:10:56 +01:00
|
|
|
limit: 10,
|
2015-06-02 11:04:06 +02:00
|
|
|
tags: []
|
2015-02-04 11:35:19 +01:00
|
|
|
};
|
|
|
|
|
|
2015-02-05 09:48:14 +01:00
|
|
|
$scope.modes = ['starred', 'search'];
|
|
|
|
|
|
2015-02-04 11:35:19 +01:00
|
|
|
_.defaults($scope.panel, defaults);
|
|
|
|
|
|
|
|
|
|
$scope.dashList = [];
|
|
|
|
|
|
|
|
|
|
$scope.init = function() {
|
|
|
|
|
panelSrv.init($scope);
|
2015-06-02 11:04:06 +02:00
|
|
|
if ($scope.panel.tag) {
|
|
|
|
|
$scope.panel.tags = [$scope.panel.tag];
|
|
|
|
|
}
|
2015-02-04 11:35:19 +01:00
|
|
|
|
|
|
|
|
if ($scope.isNewPanel()) {
|
|
|
|
|
$scope.panel.title = "Starred Dashboards";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-27 22:29:00 +01:00
|
|
|
$scope.refreshData = function() {
|
2015-02-05 11:10:56 +01:00
|
|
|
var params = {
|
|
|
|
|
limit: $scope.panel.limit
|
|
|
|
|
};
|
2015-02-08 11:24:03 +01:00
|
|
|
|
2015-02-05 09:48:14 +01:00
|
|
|
if ($scope.panel.mode === 'starred') {
|
2015-02-08 11:24:03 +01:00
|
|
|
params.starred = "true";
|
2015-02-05 09:48:14 +01:00
|
|
|
} else {
|
2015-02-08 11:24:03 +01:00
|
|
|
params.query = $scope.panel.query;
|
2015-06-02 11:04:06 +02:00
|
|
|
params.tag = $scope.panel.tags;
|
2015-02-05 09:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-02 08:33:06 +01:00
|
|
|
return backendSrv.search(params).then(function(result) {
|
2015-05-13 13:36:13 +02:00
|
|
|
$scope.dashList = result;
|
2015-06-19 14:13:25 -04:00
|
|
|
$scope.panelRenderingComplete();
|
2015-02-04 11:35:19 +01:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.init();
|
|
|
|
|
});
|
|
|
|
|
});
|