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

79 lines
1.5 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';
}
2017-12-12 07:05:24 -06:00
addLink() {
this.dashboard.links.push({ type: 'dashboard', icon: 'external link' });
this.dashboard.updateSubmenuVisibility();
this.updated();
2017-12-12 04:21:32 -06:00
this.mode = 'new';
}
2017-12-12 07:05:24 -06:00
editLink(index) {
2017-12-12 04:21:32 -06:00
}
2017-12-12 07:05:24 -06:00
saveLink() {
this.updated();
this.backToList();
2017-12-12 04:21:32 -06:00
}
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);