2018-11-14 10:57:37 -06:00
|
|
|
import coreModule from 'app/core/core_module';
|
|
|
|
|
2019-07-18 01:03:04 -05:00
|
|
|
const obj2string = (obj: any) => {
|
2018-12-05 07:56:29 -06:00
|
|
|
return Object.keys(obj)
|
|
|
|
.reduce((acc, curr) => acc.concat(curr + '=' + obj[curr]), [])
|
|
|
|
.join();
|
|
|
|
};
|
|
|
|
|
2018-11-14 10:57:37 -06:00
|
|
|
export class GeneralTabCtrl {
|
|
|
|
panelCtrl: any;
|
|
|
|
|
|
|
|
/** @ngInject */
|
2019-07-18 01:03:04 -05:00
|
|
|
constructor($scope: any) {
|
2018-11-14 10:57:37 -06:00
|
|
|
this.panelCtrl = $scope.ctrl;
|
2018-12-05 07:56:29 -06:00
|
|
|
|
|
|
|
const updatePanel = () => {
|
|
|
|
console.log('panel.render()');
|
|
|
|
this.panelCtrl.panel.render();
|
|
|
|
};
|
|
|
|
|
2019-07-18 01:03:04 -05:00
|
|
|
const generateValueFromPanel = (scope: any) => {
|
2018-12-05 07:56:29 -06:00
|
|
|
const { panel } = scope.ctrl;
|
|
|
|
const panelPropsToTrack = ['title', 'description', 'transparent', 'repeat', 'repeatDirection', 'minSpan'];
|
|
|
|
const panelPropsString = panelPropsToTrack
|
2018-12-06 02:39:17 -06:00
|
|
|
.map(prop => prop + '=' + (panel[prop] && panel[prop].toString ? panel[prop].toString() : panel[prop]))
|
2018-12-05 07:56:29 -06:00
|
|
|
.join();
|
2019-01-29 02:47:41 -06:00
|
|
|
const panelLinks = panel.links || [];
|
2018-12-05 07:56:29 -06:00
|
|
|
const panelLinksString = panelLinks.map(obj2string).join();
|
|
|
|
return panelPropsString + panelLinksString;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.$watch(generateValueFromPanel, updatePanel, true);
|
2018-11-14 10:57:37 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @ngInject */
|
|
|
|
export function generalTab() {
|
|
|
|
'use strict';
|
|
|
|
return {
|
|
|
|
restrict: 'E',
|
|
|
|
templateUrl: 'public/app/features/panel/partials/general_tab.html',
|
|
|
|
controller: GeneralTabCtrl,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
coreModule.directive('panelGeneralTab', generalTab);
|