diff --git a/public/app/features/dashboard/folder_picker/folder_picker.html b/public/app/features/dashboard/folder_picker/folder_picker.html
index b830e65b7e6..8722a19a5f8 100644
--- a/public/app/features/dashboard/folder_picker/folder_picker.html
+++ b/public/app/features/dashboard/folder_picker/folder_picker.html
@@ -43,4 +43,4 @@
{{ctrl.validationError}}
-
\ No newline at end of file
+
diff --git a/public/app/features/dashboard/folder_picker/folder_picker.ts b/public/app/features/dashboard/folder_picker/folder_picker.ts
index 72d1984634c..150f29a0dac 100644
--- a/public/app/features/dashboard/folder_picker/folder_picker.ts
+++ b/public/app/features/dashboard/folder_picker/folder_picker.ts
@@ -1,8 +1,6 @@
-///
-
-import _ from 'lodash';
-import coreModule from 'app/core/core_module';
-import appEvents from 'app/core/app_events';
+import _ from "lodash";
+import coreModule from "app/core/core_module";
+import appEvents from "app/core/app_events";
export class FolderPickerCtrl {
initialTitle: string;
@@ -14,7 +12,7 @@ export class FolderPickerCtrl {
enterFolderCreation: any;
exitFolderCreation: any;
enableCreateNew: boolean;
- rootName = 'Root';
+ rootName = "Root";
folder: any;
createNewFolder: boolean;
newFolderName: string;
@@ -34,24 +32,26 @@ export class FolderPickerCtrl {
getOptions(query) {
var params = {
query: query,
- type: 'dash-folder',
+ type: "dash-folder"
};
return this.backendSrv.search(params).then(result => {
- if (query === '' ||
- query.toLowerCase() === "r" ||
- query.toLowerCase() === "ro" ||
- query.toLowerCase() === "roo" ||
- query.toLowerCase() === "root") {
- result.unshift({title: this.rootName, id: 0});
+ if (
+ query === "" ||
+ query.toLowerCase() === "r" ||
+ query.toLowerCase() === "ro" ||
+ query.toLowerCase() === "roo" ||
+ query.toLowerCase() === "root"
+ ) {
+ result.unshift({ title: this.rootName, id: 0 });
}
- if (this.enableCreateNew && query === '') {
- result.unshift({title: '-- New Folder --', id: -1});
+ if (this.enableCreateNew && query === "") {
+ result.unshift({ title: "-- New Folder --", id: -1 });
}
return _.map(result, item => {
- return {text: item.title, value: item.id};
+ return { text: item.title, value: item.id };
});
});
}
@@ -62,13 +62,14 @@ export class FolderPickerCtrl {
this.enterFolderCreation();
return;
}
- this.onChange({$folder: {id: option.value, title: option.text}});
+ this.onChange({ $folder: { id: option.value, title: option.text } });
}
newFolderNameChanged() {
this.newFolderNameTouched = true;
- this.validationSrv.validateNewDashboardOrFolderName(this.newFolderName)
+ this.validationSrv
+ .validateNewDashboardOrFolderName(this.newFolderName)
.then(() => {
this.hasValidationError = false;
})
@@ -84,13 +85,18 @@ export class FolderPickerCtrl {
evt.preventDefault();
}
- return this.backendSrv.createDashboardFolder(this.newFolderName).then(result => {
- appEvents.emit('alert-success', ['Folder Created', 'OK']);
+ return this.backendSrv
+ .createDashboardFolder(this.newFolderName)
+ .then(result => {
+ appEvents.emit("alert-success", ["Folder Created", "OK"]);
- this.closeCreateFolder();
- this.folder = {text: result.dashboard.title, value: result.dashboard.id};
- this.onFolderChange(this.folder);
- });
+ this.closeCreateFolder();
+ this.folder = {
+ text: result.dashboard.title,
+ value: result.dashboard.id
+ };
+ this.onFolderChange(this.folder);
+ });
}
cancelCreateFolder(evt) {
@@ -108,21 +114,21 @@ export class FolderPickerCtrl {
this.createNewFolder = false;
this.hasValidationError = false;
this.validationError = null;
- this.newFolderName = '';
+ this.newFolderName = "";
this.newFolderNameTouched = false;
}
private loadInitialValue() {
if (this.initialFolderId && this.initialFolderId > 0) {
- this.getOptions('').then(result => {
- this.folder = _.find(result, {value: this.initialFolderId});
+ this.getOptions("").then(result => {
+ this.folder = _.find(result, { value: this.initialFolderId });
this.onFolderLoad();
});
} else {
if (this.initialTitle) {
- this.folder = {text: this.initialTitle, value: null};
+ this.folder = { text: this.initialTitle, value: null };
} else {
- this.folder = {text: this.rootName, value: 0};
+ this.folder = { text: this.rootName, value: 0 };
}
this.onFolderLoad();
@@ -131,31 +137,34 @@ export class FolderPickerCtrl {
private onFolderLoad() {
if (this.onLoad) {
- this.onLoad({$folder: {id: this.folder.value, title: this.folder.text}});
+ this.onLoad({
+ $folder: { id: this.folder.value, title: this.folder.text }
+ });
}
}
}
export function folderPicker() {
return {
- restrict: 'E',
- templateUrl: 'public/app/features/dashboard/folder_picker/folder_picker.html',
+ restrict: "E",
+ templateUrl:
+ "public/app/features/dashboard/folder_picker/folder_picker.html",
controller: FolderPickerCtrl,
bindToController: true,
- controllerAs: 'ctrl',
+ controllerAs: "ctrl",
scope: {
- initialTitle: '<',
- initialFolderId: '<',
- labelClass: '@',
- rootName: '@',
- onChange: '&',
- onLoad: '&',
- onCreateFolder: '&',
- enterFolderCreation: '&',
- exitFolderCreation: '&',
- enableCreateNew: '@'
+ initialTitle: "<",
+ initialFolderId: "<",
+ labelClass: "@",
+ rootName: "@",
+ onChange: "&",
+ onLoad: "&",
+ onCreateFolder: "&",
+ enterFolderCreation: "&",
+ exitFolderCreation: "&",
+ enableCreateNew: "@"
}
};
}
-coreModule.directive('folderPicker', folderPicker);
+coreModule.directive("folderPicker", folderPicker);
diff --git a/public/app/features/dashboard/validation_srv.ts b/public/app/features/dashboard/validation_srv.ts
index 4e02b8a678f..4200cf1b6ba 100644
--- a/public/app/features/dashboard/validation_srv.ts
+++ b/public/app/features/dashboard/validation_srv.ts
@@ -1,27 +1,25 @@
-///
-
-import coreModule from 'app/core/core_module';
+import coreModule from "app/core/core_module";
export class ValidationSrv {
- rootName = 'root';
+ rootName = "root";
/** @ngInject */
constructor(private $q, private backendSrv) {}
validateNewDashboardOrFolderName(name) {
- name = (name || '').trim();
+ name = (name || "").trim();
if (name.length === 0) {
return this.$q.reject({
- type: 'REQUIRED',
- message: 'Name is required'
+ type: "REQUIRED",
+ message: "Name is required"
});
}
if (name.toLowerCase() === this.rootName) {
return this.$q.reject({
- type: 'EXISTING',
- message: 'A folder or dashboard with the same name already exists'
+ type: "EXISTING",
+ message: "A folder or dashboard with the same name already exists"
});
}
@@ -31,8 +29,8 @@ export class ValidationSrv {
for (let hit of res) {
if (name.toLowerCase() === hit.title.toLowerCase()) {
deferred.reject({
- type: 'EXISTING',
- message: 'A folder or dashboard with the same name already exists'
+ type: "EXISTING",
+ message: "A folder or dashboard with the same name already exists"
});
break;
}
@@ -45,4 +43,4 @@ export class ValidationSrv {
}
}
-coreModule.service('validationSrv', ValidationSrv);
+coreModule.service("validationSrv", ValidationSrv);