diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index b95535441f2..093eebde694 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -48,7 +48,7 @@ class MetricsPanelCtrl extends PanelCtrl { }, 30);; } - initEditorTabs() { + initEditMode() { this.addEditorTab('Metrics', () => { return { templateUrl: 'public/app/partials/metrics.html' }; }); diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index 311009d303a..c53bfda68bd 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -33,6 +33,7 @@ export class PanelCtrl { init() { this.publishAppEvent('panel-instantiated', {scope: this.$scope}); + this.refresh(); } renderingCompleted() { @@ -61,7 +62,7 @@ export class PanelCtrl { if (!this.editorTabs) { this.editorTabs = []; this.editorTabs.push({title: 'General', directiveFn: generalOptionsTabEditorTab}); - this.initEditorTabs(); + this.initEditMode(); } this.changeView(true, true); @@ -71,7 +72,7 @@ export class PanelCtrl { this.changeView(false, false); } - initEditorTabs() { + initEditMode() { return; } diff --git a/public/app/plugins/panel/dashlist/editor.html b/public/app/plugins/panel/dashlist/editor.html index 1a0ba518c01..7e8f91ab002 100644 --- a/public/app/plugins/panel/dashlist/editor.html +++ b/public/app/plugins/panel/dashlist/editor.html @@ -7,7 +7,7 @@ Mode
  • - +
  • @@ -24,13 +24,13 @@
  • + ng-model="ctrl.panel.query" ng-change="ctrl.refresh()" ng-model-onblur>
  • Tags
  • - +
  • @@ -47,7 +47,7 @@ Limit number to
  • - +
  • diff --git a/public/app/plugins/panel/dashlist/module.html b/public/app/plugins/panel/dashlist/module.html index de0e23a9ea5..455291409d5 100644 --- a/public/app/plugins/panel/dashlist/module.html +++ b/public/app/plugins/panel/dashlist/module.html @@ -1,6 +1,5 @@ - -
    -
    + diff --git a/public/app/plugins/panel/dashlist/module.js b/public/app/plugins/panel/dashlist/module.js deleted file mode 100644 index 8ffee99ab2c..00000000000 --- a/public/app/plugins/panel/dashlist/module.js +++ /dev/null @@ -1,82 +0,0 @@ -define([ - 'angular', - 'app/app', - 'lodash', - 'app/core/config', - 'app/features/panel/panel_meta', -], -function (angular, app, _, config, PanelMeta) { - 'use strict'; - - var module = angular.module('grafana.panels.dashlist', []); - app.useModule(module); - - /** @ngInject */ - function DashListPanelCtrl($scope, panelSrv, backendSrv) { - - $scope.panelMeta = new PanelMeta({ - panelName: 'Dashboard list', - editIcon: "fa fa-star", - fullscreen: true, - }); - - $scope.panelMeta.addEditorTab('Options', 'app/plugins/panel/dashlist/editor.html'); - - var defaults = { - mode: 'starred', - query: '', - limit: 10, - tags: [] - }; - - $scope.modes = ['starred', 'search']; - - _.defaults($scope.panel, defaults); - - $scope.dashList = []; - - $scope.init = function() { - panelSrv.init($scope); - - if ($scope.panel.tag) { - $scope.panel.tags = [$scope.panel.tag]; - delete $scope.panel.tag; - } - - if ($scope.isNewPanel()) { - $scope.panel.title = "Starred Dashboards"; - } - }; - - $scope.refreshData = function() { - var params = { - limit: $scope.panel.limit - }; - - if ($scope.panel.mode === 'starred') { - params.starred = "true"; - } else { - params.query = $scope.panel.query; - params.tag = $scope.panel.tags; - } - - return backendSrv.search(params).then(function(result) { - $scope.dashList = result; - $scope.panelRenderingComplete(); - }); - }; - - $scope.init(); - } - - function dashListPanelDirective() { - return { - controller: DashListPanelCtrl, - templateUrl: 'app/plugins/panel/dashlist/module.html', - }; - } - - return { - panel: dashListPanelDirective - }; -}); diff --git a/public/app/plugins/panel/dashlist/module.ts b/public/app/plugins/panel/dashlist/module.ts new file mode 100644 index 00000000000..d64174d77ff --- /dev/null +++ b/public/app/plugins/panel/dashlist/module.ts @@ -0,0 +1,63 @@ +/// + +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 +} diff --git a/public/app/plugins/panel/text/module.ts b/public/app/plugins/panel/text/module.ts index 351abb7be7c..f546f10c567 100644 --- a/public/app/plugins/panel/text/module.ts +++ b/public/app/plugins/panel/text/module.ts @@ -18,17 +18,19 @@ export class TextPanelCtrl extends PanelCtrl { super($scope, $injector); _.defaults(this.panel, panelDefaults); - this.render(); - } - initEditorTabs() { + initEditMode() { this.icon = 'fa fa-text-width'; this.addEditorTab('Options', () => { return { templateUrl: 'public/app/plugins/panel/text/editor.html' }; }); } + refresh() { + this.render(); + } + render() { if (this.panel.mode === 'markdown') { this.renderMarkdown(this.panel.content); @@ -40,10 +42,6 @@ export class TextPanelCtrl extends PanelCtrl { this.renderingCompleted(); } - refresh() { - this.render(); - } - renderText(content) { content = content .replace(/&/g, '&')