mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 10:50:37 -06:00
remove DashboardRowCtrl (#12187)
This commit is contained in:
parent
f93d83befe
commit
415ad8fbf3
@ -6,7 +6,6 @@ import coreModule from 'app/core/core_module';
|
||||
import { importPluginModule } from './plugin_loader';
|
||||
|
||||
import { UnknownPanelCtrl } from 'app/plugins/panel/unknown/module';
|
||||
import { DashboardRowCtrl } from './row_ctrl';
|
||||
|
||||
/** @ngInject **/
|
||||
function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $templateCache) {
|
||||
@ -59,15 +58,6 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
|
||||
}
|
||||
|
||||
function loadPanelComponentInfo(scope, attrs) {
|
||||
if (scope.panel.type === 'row') {
|
||||
return $q.when({
|
||||
name: 'dashboard-row',
|
||||
bindings: { dashboard: '=', panel: '=' },
|
||||
attrs: { dashboard: 'ctrl.dashboard', panel: 'panel' },
|
||||
Component: DashboardRowCtrl,
|
||||
});
|
||||
}
|
||||
|
||||
var componentInfo: any = {
|
||||
name: 'panel-plugin-' + scope.panel.type,
|
||||
bindings: { dashboard: '=', panel: '=', row: '=' },
|
||||
|
@ -1,100 +0,0 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
export class DashboardRowCtrl {
|
||||
static template = `
|
||||
<div class="dashboard-row__center">
|
||||
<div class="dashboard-row__actions-left">
|
||||
<i class="fa fa-chevron-down" ng-hide="ctrl.panel.collapse"></i>
|
||||
<i class="fa fa-chevron-right" ng-show="ctrl.panel.collapse"></i>
|
||||
</div>
|
||||
<a class="dashboard-row__title pointer" ng-click="ctrl.toggle()">
|
||||
<span class="dashboard-row__title-text">
|
||||
{{ctrl.panel.title | interpolateTemplateVars:this}}
|
||||
</span>
|
||||
</a>
|
||||
<div class="dashboard-row__actions-right">
|
||||
<a class="pointer" ng-click="ctrl.openSettings()"><span class="fa fa-cog"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-row__panel_count">
|
||||
({{ctrl.panel.hiddenPanels.length}} hidden panels)
|
||||
</div>
|
||||
<div class="dashboard-row__drag grid-drag-handle">
|
||||
</div>
|
||||
`;
|
||||
|
||||
dashboard: any;
|
||||
panel: any;
|
||||
|
||||
constructor() {
|
||||
this.panel.hiddenPanels = this.panel.hiddenPanels || [];
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if (this.panel.collapse) {
|
||||
let panelIndex = _.indexOf(this.dashboard.panels, this.panel);
|
||||
|
||||
for (let child of this.panel.hiddenPanels) {
|
||||
this.dashboard.panels.splice(panelIndex + 1, 0, child);
|
||||
child.y = this.panel.y + 1;
|
||||
console.log('restoring child', child);
|
||||
}
|
||||
|
||||
this.panel.hiddenPanels = [];
|
||||
this.panel.collapse = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.panel.collapse = true;
|
||||
let foundRow = false;
|
||||
|
||||
for (let i = 0; i < this.dashboard.panels.length; i++) {
|
||||
let panel = this.dashboard.panels[i];
|
||||
|
||||
if (panel === this.panel) {
|
||||
console.log('found row');
|
||||
foundRow = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!foundRow) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (panel.type === 'row') {
|
||||
break;
|
||||
}
|
||||
|
||||
this.panel.hiddenPanels.push(panel);
|
||||
console.log('hiding child', panel.id);
|
||||
}
|
||||
|
||||
for (let hiddenPanel of this.panel.hiddenPanels) {
|
||||
this.dashboard.removePanel(hiddenPanel, false);
|
||||
}
|
||||
}
|
||||
|
||||
moveUp() {
|
||||
// let panelIndex = _.indexOf(this.dashboard.panels, this.panel);
|
||||
// let rowAbove = null;
|
||||
// for (let index = panelIndex-1; index > 0; index--) {
|
||||
// panel = this.dashboard.panels[index];
|
||||
// if (panel.type === 'row') {
|
||||
// rowAbove = panel;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (rowAbove) {
|
||||
// this.panel.y = rowAbove.y;
|
||||
// }
|
||||
}
|
||||
|
||||
link(scope, elem) {
|
||||
elem.addClass('dashboard-row');
|
||||
|
||||
scope.$watch('ctrl.panel.collapse', () => {
|
||||
elem.toggleClass('dashboard-row--collapse', this.panel.collapse === true);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user