grafana/public/app/features/dashlinks/editor.ts

83 lines
1.6 KiB
TypeScript
Raw Normal View History

2017-12-12 04:21:32 -06:00
import angular from 'angular';
import _ from 'lodash';
import appEvents from 'app/core/app_events';
export var iconMap = {
"external link": "fa-external-link",
"dashboard": "fa-th-large",
"question": "fa-question",
"info": "fa-info",
"bolt": "fa-bolt",
"doc": "fa-file-text-o",
"cloud": "fa-cloud",
};
export class DashLinkEditorCtrl {
dashboard: any;
iconMap: any;
mode: any;
link: any;
currentLink: any;
/** @ngInject */
constructor($scope, $rootScope) {
this.iconMap = iconMap;
this.dashboard.links = this.dashboard.links || [];
this.mode = 'list';
}
backToList() {
this.mode = 'list';
}
addLinkMode() {
this.mode = 'new';
}
editLinkMode(index) {
this.currentLink = index;
this.mode = 'edit';
}
2017-12-12 06:06:32 -06:00
addLink(type) {
this.dashboard.links.push({ type: type, icon: 'external link' });
//this.dashboard.updateSubmenuVisibility();
2017-12-12 04:21:32 -06:00
this.updated();
this.mode = 'list';
}
editLink(index) {
}
moveLink(index, dir) {
_.move(this.dashboard.links, index, index+dir);
this.updated();
}
updated() {
appEvents.emit('dash-links-updated');
}
deleteLink(index) {
this.dashboard.links.splice(index, 1);
2017-12-12 06:06:32 -06:00
//this.dashboard.updateSubmenuVisibility();
2017-12-12 04:21:32 -06:00
this.updated();
}
}
function dashLinksEditor() {
return {
restrict: 'E',
controller: DashLinkEditorCtrl,
templateUrl: 'public/app/features/dashlinks/editor.html',
bindToController: true,
controllerAs: 'ctrl',
scope: {
dashboard: "="
}
};
}
angular.module('grafana.directives').directive('dashLinksEditor', dashLinksEditor);