mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(panels): fixing broken stuff
This commit is contained in:
parent
9c1217cd2c
commit
f0f7da9ff0
@ -116,32 +116,7 @@ function (angular, _, config) {
|
||||
$scope.$broadcast('render');
|
||||
};
|
||||
|
||||
$scope.removePanel = function(panel) {
|
||||
$scope.appEvent('confirm-modal', {
|
||||
title: 'Are you sure you want to remove this panel?',
|
||||
icon: 'fa-trash',
|
||||
yesText: 'Delete',
|
||||
onConfirm: function() {
|
||||
$scope.row.panels = _.without($scope.row.panels, panel);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.replacePanel = function(newPanel, oldPanel) {
|
||||
var row = $scope.row;
|
||||
var index = _.indexOf(row.panels, oldPanel);
|
||||
row.panels.splice(index, 1);
|
||||
|
||||
// adding it back needs to be done in next digest
|
||||
$timeout(function() {
|
||||
newPanel.id = oldPanel.id;
|
||||
newPanel.span = oldPanel.span;
|
||||
row.panels.splice(index, 0, newPanel);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.init();
|
||||
|
||||
});
|
||||
|
||||
module.directive('rowHeight', function() {
|
||||
|
@ -21,16 +21,17 @@ export class PanelCtrl {
|
||||
editorHelpIndex: number;
|
||||
|
||||
constructor($scope, $injector) {
|
||||
var plugin = config.panels[this.panel.type];
|
||||
|
||||
this.$injector = $injector;
|
||||
this.$scope = $scope;
|
||||
this.$timeout = $injector.get('$timeout');
|
||||
this.pluginName = plugin.name;
|
||||
this.pluginId = plugin.id;
|
||||
this.icon = plugin.info.icon;
|
||||
this.editorTabIndex = 0;
|
||||
|
||||
var plugin = config.panels[this.panel.type];
|
||||
if (plugin) {
|
||||
this.pluginId = plugin.id;
|
||||
this.pluginName = plugin.name;
|
||||
}
|
||||
|
||||
$scope.$on("refresh", () => this.refresh());
|
||||
}
|
||||
|
||||
@ -97,6 +98,10 @@ export class PanelCtrl {
|
||||
return menu;
|
||||
}
|
||||
|
||||
getExtendedMenu() {
|
||||
return [{text: 'Panel JSON', click: 'ctrl.editPanelJson(); dismiss();'}];
|
||||
}
|
||||
|
||||
otherPanelInFullscreenMode() {
|
||||
return this.dashboard.meta.fullscreen && !this.fullscreen;
|
||||
}
|
||||
@ -135,4 +140,23 @@ export class PanelCtrl {
|
||||
});
|
||||
}
|
||||
|
||||
editPanelJson() {
|
||||
this.publishAppEvent('show-json-editor', {
|
||||
object: this.panel,
|
||||
updateHandler: this.replacePanel.bind(this)
|
||||
});
|
||||
}
|
||||
|
||||
replacePanel(newPanel, oldPanel) {
|
||||
var row = this.row;
|
||||
var index = _.indexOf(this.row.panels, oldPanel);
|
||||
this.row.panels.splice(index, 1);
|
||||
|
||||
// adding it back needs to be done in next digest
|
||||
this.$timeout(() => {
|
||||
newPanel.id = oldPanel.id;
|
||||
newPanel.span = oldPanel.span;
|
||||
this.row.panels.splice(index, 0, newPanel);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ function (angular, $) {
|
||||
var panelContainer = elem.find('.panel-container');
|
||||
var ctrl = scope.ctrl;
|
||||
scope.$watchGroup(['ctrl.fullscreen', 'ctrl.height', 'ctrl.panel.height', 'ctrl.row.height'], function() {
|
||||
console.log('height: ', ctrl.height);
|
||||
panelContainer.css({ minHeight: ctrl.height || ctrl.panel.height || ctrl.row.height, display: 'block' });
|
||||
elem.toggleClass('panel-fullscreen', ctrl.fullscreen ? true : false);
|
||||
});
|
||||
@ -80,7 +79,7 @@ function (angular, $) {
|
||||
|
||||
function dragEndHandler() {
|
||||
// if close to 12
|
||||
var rowSpan = ctrl.dashboard.rowSpan(scope.row);
|
||||
var rowSpan = ctrl.dashboard.rowSpan(ctrl.row);
|
||||
if (rowSpan < 12 && rowSpan > 11) {
|
||||
lastPanel.span += 12 - rowSpan;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ function panelLoader($compile, dynamicDirectiveSrv, $http, $q, $injector) {
|
||||
function addPanel(name, Panel) {
|
||||
if (Panel.registered) {
|
||||
addPanelAndCompile(name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Panel.promise) {
|
||||
@ -62,14 +63,13 @@ function panelLoader($compile, dynamicDirectiveSrv, $http, $q, $injector) {
|
||||
Panel.registered = true;
|
||||
addPanelAndCompile(name);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var panelElemName = 'panel-directive-' + scope.panel.type;
|
||||
let panelInfo = config.panels[scope.panel.type];
|
||||
if (!panelInfo) {
|
||||
addPanel(panelElemName, UnknownPanel);
|
||||
return;
|
||||
}
|
||||
|
||||
System.import(panelInfo.module).then(function(panelModule) {
|
||||
|
@ -64,7 +64,7 @@ function (angular, $, _) {
|
||||
}
|
||||
|
||||
function getExtendedMenu(ctrl) {
|
||||
return angular.copy(ctrl.extendedMenu);
|
||||
return ctrl.getExtendedMenu();
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -59,6 +59,7 @@ export class TextPanelCtrl extends PanelCtrl {
|
||||
this.updateContent(this.converter.makeHtml(text));
|
||||
} else {
|
||||
System.import('vendor/showdown').then(Showdown => {
|
||||
console.log(this);
|
||||
this.converter = new Showdown.converter();
|
||||
this.$scope.$apply(() => {
|
||||
this.updateContent(this.converter.makeHtml(text));
|
||||
|
@ -2,10 +2,15 @@
|
||||
|
||||
import {PanelDirective} from '../../../features/panel/panel';
|
||||
|
||||
export class UnknownPanel extends PanelDirective {
|
||||
class UnknownPanel extends PanelDirective {
|
||||
template = `<div class="text-center" style="padding-top: 2rem">
|
||||
Unknown panel type: <strong>{{ctrl.panel.type}}</strong>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
UnknownPanel,
|
||||
UnknownPanel as Panel
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user