mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(panels): upgraded dashlist panel to new format
This commit is contained in:
63
public/app/plugins/panel/dashlist/module.ts
Normal file
63
public/app/plugins/panel/dashlist/module.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
///<reference path="../../../headers/common.d.ts" />
|
||||
|
||||
import _ from 'lodash';
|
||||
import config from 'app/core/config';
|
||||
import {PanelDirective, PanelCtrl} from '../../../features/panel/panel';
|
||||
|
||||
// Set and populate defaults
|
||||
var panelDefaults = {
|
||||
mode: 'starred',
|
||||
query: '',
|
||||
limit: 10,
|
||||
tags: []
|
||||
};
|
||||
|
||||
class DashListCtrl extends PanelCtrl {
|
||||
dashList: any[];
|
||||
modes: any[];
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, $injector, private backendSrv) {
|
||||
super($scope, $injector);
|
||||
_.defaults(this.panel, panelDefaults);
|
||||
|
||||
if (this.panel.tag) {
|
||||
this.panel.tags = [$scope.panel.tag];
|
||||
delete this.panel.tag;
|
||||
}
|
||||
}
|
||||
|
||||
initEditMode() {
|
||||
this.modes = ['starred', 'search'];
|
||||
this.icon = "fa fa-star";
|
||||
this.addEditorTab('Options', () => {
|
||||
return {templateUrl: 'app/plugins/panel/dashlist/editor.html'};
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
var params: any = {limit: this.panel.limit};
|
||||
|
||||
if (this.panel.mode === 'starred') {
|
||||
params.starred = "true";
|
||||
} else {
|
||||
params.query = this.panel.query;
|
||||
params.tag = this.panel.tags;
|
||||
}
|
||||
|
||||
return this.backendSrv.search(params).then(result => {
|
||||
this.dashList = result;
|
||||
this.renderingCompleted();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class DashListPanel extends PanelDirective {
|
||||
controller = DashListCtrl;
|
||||
templateUrl = 'public/app/plugins/panel/dashlist/module.html';
|
||||
}
|
||||
|
||||
export {
|
||||
DashListCtrl,
|
||||
DashListPanel as Panel
|
||||
}
|
||||
Reference in New Issue
Block a user