本文整理汇总了TypeScript中app/core/core.coreModule.directive方法的典型用法代码示例。如果您正苦于以下问题:TypeScript coreModule.directive方法的具体用法?TypeScript coreModule.directive怎么用?TypeScript coreModule.directive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app/core/core.coreModule
的用法示例。
在下文中一共展示了coreModule.directive方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
appEvents.emit('confirm-modal', {
title: 'Delete',
text: 'Are you sure you want to delete this datasource?',
yesText: "Delete",
icon: "fa-trash",
onConfirm: () => {
this.confirmDelete();
}
});
}
}
coreModule.controller('DataSourceEditCtrl', DataSourceEditCtrl);
coreModule.directive('datasourceHttpSettings', function() {
return {
scope: {
current: "=",
suggestUrl: "@",
},
templateUrl: 'public/app/features/plugins/partials/ds_http_settings.html',
link: {
pre: function($scope, elem, attrs) {
$scope.getSuggestUrls = function() {
return [$scope.suggestUrl];
};
}
}
};
});
示例2: function
coreModule.directive('grafanaGraph', function($rootScope, timeSrv) {
return {
restrict: 'A',
template: '',
link: function(scope, elem) {
var ctrl = scope.ctrl;
var dashboard = ctrl.dashboard;
var panel = ctrl.panel;
var data;
var annotations;
var plot;
var sortedSeries;
var legendSideLastValue = null;
var rootScope = scope.$root;
var panelWidth = 0;
var thresholdManager = new ThresholdManager(ctrl);
var tooltip = new GraphTooltip(elem, dashboard, scope, function() {
return sortedSeries;
});
// panel events
ctrl.events.on('panel-teardown', () => {
thresholdManager = null;
if (plot) {
plot.destroy();
plot = null;
}
});
ctrl.events.on('render', function(renderData) {
data = renderData || data;
if (!data) {
return;
}
annotations = ctrl.annotations;
render_panel();
});
// global events
appEvents.on('graph-hover', function(evt) {
// ignore other graph hover events if shared tooltip is disabled
if (!dashboard.sharedTooltipModeEnabled()) {
return;
}
// ignore if we are the emitter
if (!plot || evt.panel.id === panel.id || ctrl.otherPanelInFullscreenMode()) {
return;
}
tooltip.show(evt.pos);
}, scope);
appEvents.on('graph-hover-clear', function(event, info) {
if (plot) {
tooltip.clear(plot);
}
}, scope);
function getLegendHeight(panelHeight) {
if (!panel.legend.show || panel.legend.rightSide) {
return 0;
}
if (panel.legend.alignAsTable) {
var legendSeries = _.filter(data, function(series) {
return series.hideFromLegend(panel.legend) === false;
});
var total = 23 + (21 * legendSeries.length);
return Math.min(total, Math.floor(panelHeight/2));
} else {
return 26;
}
}
function setElementHeight() {
try {
var height = ctrl.height - getLegendHeight(ctrl.height);
elem.css('height', height + 'px');
return true;
} catch (e) { // IE throws errors sometimes
console.log(e);
return false;
}
}
function shouldAbortRender() {
if (!data) {
return true;
}
if (!setElementHeight()) { return true; }
if (panelWidth === 0) {
return true;
}
}
//.........这里部分代码省略.........
示例3: queryTroubleshooter
}
export function queryTroubleshooter() {
return {
restrict: 'E',
template: template,
controller: QueryTroubleshooterCtrl,
bindToController: true,
controllerAs: 'ctrl',
scope: {
panelCtrl: "=",
isOpen: "=",
},
link: function(scope, elem, attrs, ctrl) {
ctrl.renderJsonExplorer = function(data) {
var jsonElem = elem.find('.query-troubleshooter-json');
ctrl.jsonExplorer = new JsonExplorer(data, 3, {
animateOpen: true,
});
const html = ctrl.jsonExplorer.render(true);
jsonElem.html(html);
};
}
};
}
coreModule.directive('queryTroubleshooter', queryTroubleshooter);
示例4: createResetHandler
import { coreModule } from 'app/core/core';
import { createChangeHandler, createResetHandler, PasswordFieldEnum } from '../utils/passwordHandlers';
coreModule.directive('datasourceHttpSettings', () => {
return {
scope: {
current: '=',
suggestUrl: '@',
noDirectAccess: '@',
},
templateUrl: 'public/app/features/datasources/partials/http_settings.html',
link: {
pre: ($scope: any, elem, attrs) => {
// do not show access option if direct access is disabled
$scope.showAccessOption = $scope.noDirectAccess !== 'true';
$scope.showAccessHelp = false;
$scope.toggleAccessHelp = () => {
$scope.showAccessHelp = !$scope.showAccessHelp;
};
$scope.getSuggestUrls = () => {
return [$scope.suggestUrl];
};
$scope.onBasicAuthPasswordReset = createResetHandler($scope, PasswordFieldEnum.BasicAuthPassword);
$scope.onBasicAuthPasswordChange = createChangeHandler($scope, PasswordFieldEnum.BasicAuthPassword);
},
},
};
});
示例5: addPanelDirective
editable: true,
type: panelPluginInfo.id,
isNew: true,
};
this.rowCtrl.closeDropView();
this.dashboard.addPanel(panel, this.row);
this.$timeout(() => {
this.$rootScope.$broadcast('render');
//this.$rootScope.appEvent('panel-change-view', {
// fullscreen: true, edit: true, panelId: panel.id
//});
});
}
}
export function addPanelDirective() {
return {
restrict: 'E',
templateUrl: 'public/app/features/dashboard/row/add_panel.html',
controller: AddPanelCtrl,
bindToController: true,
controllerAs: 'ctrl',
scope: {
rowCtrl: "=",
},
};
}
coreModule.directive('dashRowAddPanel', addPanelDirective);
示例6: function
coreModule.directive('grafanaGraph', function($rootScope, timeSrv, popoverSrv) {
return {
restrict: 'A',
template: '',
link: function(scope, elem) {
var ctrl = scope.ctrl;
var dashboard = ctrl.dashboard;
var panel = ctrl.panel;
var annotations = [];
var data;
var plot;
var sortedSeries;
var legendSideLastValue = null;
var rootScope = scope.$root;
var panelWidth = 0;
var eventManager = new EventManager(ctrl, elem, popoverSrv);
var thresholdManager = new ThresholdManager(ctrl);
var tooltip = new GraphTooltip(elem, dashboard, scope, function() {
return sortedSeries;
});
// panel events
ctrl.events.on('panel-teardown', () => {
thresholdManager = null;
if (plot) {
plot.destroy();
plot = null;
}
});
ctrl.events.on('render', function(renderData) {
data = renderData || data;
if (!data) {
return;
}
annotations = ctrl.annotations || [];
render_panel();
});
// global events
appEvents.on('graph-hover', function(evt) {
// ignore other graph hover events if shared tooltip is disabled
if (!dashboard.sharedTooltipModeEnabled()) {
return;
}
// ignore if we are the emitter
if (!plot || evt.panel.id === panel.id || ctrl.otherPanelInFullscreenMode()) {
return;
}
tooltip.show(evt.pos);
}, scope);
appEvents.on('graph-hover-clear', function(event, info) {
if (plot) {
tooltip.clear(plot);
}
}, scope);
function getLegendHeight(panelHeight) {
if (!panel.legend.show || panel.legend.rightSide) {
return 0;
}
if (panel.legend.alignAsTable) {
var legendSeries = _.filter(data, function(series) {
return series.hideFromLegend(panel.legend) === false;
});
var total = 23 + (21 * legendSeries.length);
return Math.min(total, Math.floor(panelHeight/2));
} else {
return 26;
}
}
function setElementHeight() {
try {
var height = ctrl.height - getLegendHeight(ctrl.height);
elem.css('height', height + 'px');
return true;
} catch (e) { // IE throws errors sometimes
console.log(e);
return false;
}
}
function shouldAbortRender() {
if (!data) {
return true;
}
if (!setElementHeight()) { return true; }
if (panelWidth === 0) {
return true;
}
}
//.........这里部分代码省略.........
示例7: function
}
});
elem.bind('plotclick', function(event, pos, item) {
if (panel.xaxis.mode !== 'time') {
// Skip if panel in histogram or series mode
return;
}
if ((pos.ctrlKey || pos.metaKey) && dashboard.meta.canEdit) {
// Skip if range selected (added in "plotselected" event handler)
let isRangeSelection = pos.x !== pos.x1;
if (!isRangeSelection) {
setTimeout(() => {
eventManager.updateTime({ from: pos.x, to: null });
}, 100);
}
}
});
scope.$on('$destroy', function() {
tooltip.destroy();
elem.off();
elem.remove();
});
},
};
}
coreModule.directive('grafanaGraph', graphDirective);
示例8: function
coreModule.directive('dashRow', function($rootScope) {
return {
restrict: 'E',
templateUrl: 'public/app/features/dashboard/row/row.html',
controller: DashRowCtrl,
bindToController: true,
controllerAs: 'ctrl',
scope: {
dashboard: "=",
row: "=",
},
link: function(scope, element) {
scope.$watchGroup(['ctrl.row.collapse', 'ctrl.row.height'], function() {
element.toggleClass('dash-row--collapse', scope.ctrl.row.collapse);
element.find('.panels-wrapper').css({minHeight: scope.ctrl.row.collapse ? '5px' : scope.ctrl.row.height});
});
$rootScope.onAppEvent('panel-fullscreen-enter', function(evt, info) {
var hasPanel = _.find(scope.ctrl.row.panels, {id: info.panelId});
if (!hasPanel) {
element.hide();
}
}, scope);
$rootScope.onAppEvent('panel-fullscreen-exit', function() {
element.show();
}, scope);
}
};
});
示例9: confirmDelete
}
};
confirmDelete() {
this.backendSrv.delete('/api/datasources/' + this.current.id).then(() => {
this.$location.path('datasources');
});
}
delete(s) {
appEvents.emit('confirm-modal', {
title: 'Delete',
text: 'Are you sure you want to delete this datasource?',
yesText: "Delete",
icon: "fa-trash",
onConfirm: () => {
this.confirmDelete();
}
});
}
}
coreModule.controller('DataSourceEditCtrl', DataSourceEditCtrl);
coreModule.directive('datasourceHttpSettings', function() {
return {
scope: {current: "="},
templateUrl: 'public/app/features/plugins/partials/ds_http_settings.html'
};
});
示例10: function
});
}
}
coreModule.controller('DataSourceEditCtrl', DataSourceEditCtrl);
coreModule.directive('datasourceHttpSettings', function() {
return {
scope: {
current: '=',
suggestUrl: '@',
noDirectAccess: '@',
},
templateUrl: 'public/app/features/plugins/partials/ds_http_settings.html',
link: {
pre: function($scope, elem, attrs) {
// do not show access option if direct access is disabled
$scope.showAccessOption = $scope.noDirectAccess !== 'true';
$scope.showAccessHelp = false;
$scope.toggleAccessHelp = function() {
$scope.showAccessHelp = !$scope.showAccessHelp;
};
$scope.getSuggestUrls = function() {
return [$scope.suggestUrl];
};
},
},
};
});