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