" +
+ '>' +
'
" +
+ '' +
'
';
elem.replaceWith($compile(angular.element(template))(scope));
- }
+ },
};
}
/** @ngInject */
function editorCheckbox($compile, $interpolate) {
return {
- restrict: "E",
+ restrict: 'E',
link: function(scope, elem, attrs) {
var text = $interpolate(attrs.text)(scope);
var model = $interpolate(attrs.model)(scope);
- var ngchange = attrs.change ? ' ng-change="' + attrs.change + '"' : "";
- var tip = attrs.tip ? "
" + attrs.tip + "" : "";
+ var ngchange = attrs.change ? ' ng-change="' + attrs.change + '"' : '';
+ var tip = attrs.tip ? '
' + attrs.tip + '' : '';
var label =
'
";
+ '';
var template =
'
';
template = template + label;
- elem.addClass("gf-form-checkbox");
+ elem.addClass('gf-form-checkbox');
elem.html($compile(angular.element(template))(scope));
- }
+ },
};
}
/** @ngInject */
function gfDropdown($parse, $compile, $timeout) {
function buildTemplate(items, placement?) {
- var upclass = placement === "top" ? "dropup" : "";
+ var upclass = placement === 'top' ? 'dropup' : '';
var ul = [
'"
+ '',
];
for (let index = 0; index < items.length; index++) {
@@ -171,26 +171,26 @@ function gfDropdown($parse, $compile, $timeout) {
}
var li =
- "";
+ li += '';
ul.splice(index + 1, 0, li);
}
@@ -198,29 +198,29 @@ function gfDropdown($parse, $compile, $timeout) {
}
return {
- restrict: "EA",
+ restrict: 'EA',
scope: true,
link: function postLink(scope, iElement, iAttrs) {
var getter = $parse(iAttrs.gfDropdown),
items = getter(scope);
$timeout(function() {
- var placement = iElement.data("placement");
+ var placement = iElement.data('placement');
var dropdown = angular.element(
- buildTemplate(items, placement).join("")
+ buildTemplate(items, placement).join('')
);
dropdown.insertAfter(iElement);
- $compile(iElement.next("ul.dropdown-menu"))(scope);
+ $compile(iElement.next('ul.dropdown-menu'))(scope);
});
- iElement.addClass("dropdown-toggle").attr("data-toggle", "dropdown");
- }
+ iElement.addClass('dropdown-toggle').attr('data-toggle', 'dropdown');
+ },
};
}
-coreModule.directive("tip", tip);
-coreModule.directive("clipboardButton", clipboardButton);
-coreModule.directive("compile", compile);
-coreModule.directive("watchChange", watchChange);
-coreModule.directive("editorOptBool", editorOptBool);
-coreModule.directive("editorCheckbox", editorCheckbox);
-coreModule.directive("gfDropdown", gfDropdown);
+coreModule.directive('tip', tip);
+coreModule.directive('clipboardButton', clipboardButton);
+coreModule.directive('compile', compile);
+coreModule.directive('watchChange', watchChange);
+coreModule.directive('editorOptBool', editorOptBool);
+coreModule.directive('editorCheckbox', editorCheckbox);
+coreModule.directive('gfDropdown', gfDropdown);
diff --git a/public/app/core/directives/ng_model_on_blur.ts b/public/app/core/directives/ng_model_on_blur.ts
index 2f7de3bf20c..4385c72f1b0 100644
--- a/public/app/core/directives/ng_model_on_blur.ts
+++ b/public/app/core/directives/ng_model_on_blur.ts
@@ -17,7 +17,7 @@ function ngModelOnBlur() {
ngModelCtrl.$setViewValue(elm.val());
});
});
- }
+ },
};
}
@@ -25,12 +25,14 @@ function emptyToNull() {
return {
restrict: 'A',
require: 'ngModel',
- link: function (scope, elm, attrs, ctrl) {
- ctrl.$parsers.push(function (viewValue) {
- if (viewValue === "") { return null; }
+ link: function(scope, elm, attrs, ctrl) {
+ ctrl.$parsers.push(function(viewValue) {
+ if (viewValue === '') {
+ return null;
+ }
return viewValue;
});
- }
+ },
};
}
@@ -48,7 +50,7 @@ function validTimeSpan() {
var info = rangeUtil.describeTextRange(viewValue);
return info.invalid !== true;
};
- }
+ },
};
}
diff --git a/public/app/core/directives/rebuild_on_change.ts b/public/app/core/directives/rebuild_on_change.ts
index db2634869c0..a9d39d635f6 100644
--- a/public/app/core/directives/rebuild_on_change.ts
+++ b/public/app/core/directives/rebuild_on_change.ts
@@ -20,7 +20,6 @@ function getBlockNodes(nodes) {
/** @ngInject **/
function rebuildOnChange($animate) {
-
return {
multiElement: true,
terminal: true,
@@ -48,7 +47,10 @@ function rebuildOnChange($animate) {
}
}
- scope.$watch(attrs.property, function rebuildOnChangeAction(value, oldValue) {
+ scope.$watch(attrs.property, function rebuildOnChangeAction(
+ value,
+ oldValue
+ ) {
if (childScope && value !== oldValue) {
cleanUp();
}
@@ -56,15 +58,17 @@ function rebuildOnChange($animate) {
if (!childScope && (value || attrs.showNull)) {
transclude(function(clone, newScope) {
childScope = newScope;
- clone[clone.length++] = document.createComment(' end rebuild on change ');
- block = {clone: clone};
+ clone[clone.length++] = document.createComment(
+ ' end rebuild on change '
+ );
+ block = { clone: clone };
$animate.enter(clone, elem.parent(), elem);
});
} else {
cleanUp();
}
});
- }
+ },
};
}
diff --git a/public/app/core/directives/tags.ts b/public/app/core/directives/tags.ts
index 0f4d0990d47..b5020b71fc7 100644
--- a/public/app/core/directives/tags.ts
+++ b/public/app/core/directives/tags.ts
@@ -6,7 +6,7 @@ import 'vendor/tagsinput/bootstrap-tagsinput.js';
function djb2(str) {
var hash = 5381;
for (var i = 0; i < str.length; i++) {
- hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */
+ hash = (hash << 5) + hash + str.charCodeAt(i); /* hash * 33 + c */
}
return hash;
}
@@ -14,33 +14,79 @@ function djb2(str) {
function setColor(name, element) {
var hash = djb2(name.toLowerCase());
var colors = [
- "#E24D42","#1F78C1","#BA43A9","#705DA0","#466803",
- "#508642","#447EBC","#C15C17","#890F02","#757575",
- "#0A437C","#6D1F62","#584477","#629E51","#2F4F4F",
- "#BF1B00","#806EB7","#8a2eb8", "#699e00","#000000",
- "#3F6833","#2F575E","#99440A","#E0752D","#0E4AB4",
- "#58140C","#052B51","#511749","#3F2B5B",
+ '#E24D42',
+ '#1F78C1',
+ '#BA43A9',
+ '#705DA0',
+ '#466803',
+ '#508642',
+ '#447EBC',
+ '#C15C17',
+ '#890F02',
+ '#757575',
+ '#0A437C',
+ '#6D1F62',
+ '#584477',
+ '#629E51',
+ '#2F4F4F',
+ '#BF1B00',
+ '#806EB7',
+ '#8a2eb8',
+ '#699e00',
+ '#000000',
+ '#3F6833',
+ '#2F575E',
+ '#99440A',
+ '#E0752D',
+ '#0E4AB4',
+ '#58140C',
+ '#052B51',
+ '#511749',
+ '#3F2B5B',
];
var borderColors = [
- "#FF7368","#459EE7","#E069CF","#9683C6","#6C8E29",
- "#76AC68","#6AA4E2","#E7823D","#AF3528","#9B9B9B",
- "#3069A2","#934588","#7E6A9D","#88C477","#557575",
- "#E54126","#A694DD","#B054DE", "#8FC426","#262626",
- "#658E59","#557D84","#BF6A30","#FF9B53","#3470DA",
- "#7E3A32","#2B5177","#773D6F","#655181",
+ '#FF7368',
+ '#459EE7',
+ '#E069CF',
+ '#9683C6',
+ '#6C8E29',
+ '#76AC68',
+ '#6AA4E2',
+ '#E7823D',
+ '#AF3528',
+ '#9B9B9B',
+ '#3069A2',
+ '#934588',
+ '#7E6A9D',
+ '#88C477',
+ '#557575',
+ '#E54126',
+ '#A694DD',
+ '#B054DE',
+ '#8FC426',
+ '#262626',
+ '#658E59',
+ '#557D84',
+ '#BF6A30',
+ '#FF9B53',
+ '#3470DA',
+ '#7E3A32',
+ '#2B5177',
+ '#773D6F',
+ '#655181',
];
var color = colors[Math.abs(hash % colors.length)];
var borderColor = borderColors[Math.abs(hash % borderColors.length)];
- element.css("background-color", color);
- element.css("border-color", borderColor);
+ element.css('background-color', color);
+ element.css('border-color', borderColor);
}
function tagColorFromName() {
return {
- scope: { tagColorFromName: "=" },
- link: function (scope, element) {
+ scope: { tagColorFromName: '=' },
+ link: function(scope, element) {
setColor(scope.tagColorFromName, element);
- }
+ },
};
}
@@ -63,12 +109,11 @@ function bootstrapTagsinput() {
restrict: 'EA',
scope: {
model: '=ngModel',
- onTagsUpdated: "&",
+ onTagsUpdated: '&',
},
template: '
',
replace: false,
link: function(scope, element, attrs) {
-
if (!angular.isArray(scope.model)) {
scope.model = [];
}
@@ -81,13 +126,18 @@ function bootstrapTagsinput() {
select.tagsinput({
typeahead: {
- source: angular.isFunction(scope.$parent[attrs.typeaheadSource]) ? scope.$parent[attrs.typeaheadSource] : null
+ source: angular.isFunction(scope.$parent[attrs.typeaheadSource])
+ ? scope.$parent[attrs.typeaheadSource]
+ : null,
},
widthClass: attrs.widthClass,
itemValue: getItemProperty(scope, attrs.itemvalue),
- itemText : getItemProperty(scope, attrs.itemtext),
- tagClass : angular.isFunction(scope.$parent[attrs.tagclass]) ?
- scope.$parent[attrs.tagclass] : function() { return attrs.tagclass; }
+ itemText: getItemProperty(scope, attrs.itemtext),
+ tagClass: angular.isFunction(scope.$parent[attrs.tagclass])
+ ? scope.$parent[attrs.tagclass]
+ : function() {
+ return attrs.tagclass;
+ },
});
select.on('itemAdded', function(event) {
@@ -97,7 +147,12 @@ function bootstrapTagsinput() {
scope.onTagsUpdated();
}
}
- var tagElement = select.next().children("span").filter(function() { return $(this).text() === event.item; });
+ var tagElement = select
+ .next()
+ .children('span')
+ .filter(function() {
+ return $(this).text() === event.item;
+ });
setColor(event.item, tagElement);
});
@@ -111,19 +166,22 @@ function bootstrapTagsinput() {
}
});
- scope.$watch("model", function() {
- if (!angular.isArray(scope.model)) {
- scope.model = [];
- }
+ scope.$watch(
+ 'model',
+ function() {
+ if (!angular.isArray(scope.model)) {
+ scope.model = [];
+ }
- select.tagsinput('removeAll');
+ select.tagsinput('removeAll');
- for (var i = 0; i < scope.model.length; i++) {
- select.tagsinput('add', scope.model[i]);
- }
-
- }, true);
- }
+ for (var i = 0; i < scope.model.length; i++) {
+ select.tagsinput('add', scope.model[i]);
+ }
+ },
+ true
+ );
+ },
};
}
diff --git a/public/app/core/filters/filters.ts b/public/app/core/filters/filters.ts
index 0f53df8b4fb..1556e0a94f5 100644
--- a/public/app/core/filters/filters.ts
+++ b/public/app/core/filters/filters.ts
@@ -41,19 +41,17 @@ coreModule.filter('moment', function() {
coreModule.filter('noXml', function() {
var noXml = function(text) {
- return _.isString(text)
- ? text
- .replace(/&/g, '&')
- .replace(//g, '>')
- .replace(/'/g, ''')
- .replace(/"/g, '"')
- : text;
+ return _.isString(text)
+ ? text
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/'/g, ''')
+ .replace(/"/g, '"')
+ : text;
};
return function(text) {
- return _.isArray(text)
- ? _.map(text, noXml)
- : noXml(text);
+ return _.isArray(text) ? _.map(text, noXml) : noXml(text);
};
});
diff --git a/public/app/core/live/live_srv.ts b/public/app/core/live/live_srv.ts
index 8e808e60e1a..46e278aa749 100644
--- a/public/app/core/live/live_srv.ts
+++ b/public/app/core/live/live_srv.ts
@@ -1,7 +1,7 @@
import _ from 'lodash';
import config from 'app/core/config';
-import {Observable} from 'rxjs/Observable';
+import { Observable } from 'rxjs/Observable';
export class LiveSrv {
conn: any;
@@ -14,7 +14,12 @@ export class LiveSrv {
getWebSocketUrl() {
var l = window.location;
- return ((l.protocol === "https:") ? "wss://" : "ws://") + l.host + config.appSubUrl + '/ws';
+ return (
+ (l.protocol === 'https:' ? 'wss://' : 'ws://') +
+ l.host +
+ config.appSubUrl +
+ '/ws'
+ );
}
getConnection() {
@@ -30,25 +35,25 @@ export class LiveSrv {
console.log('Live: connecting...');
this.conn = new WebSocket(this.getWebSocketUrl());
- this.conn.onclose = (evt) => {
- console.log("Live: websocket onclose", evt);
- reject({message: 'Connection closed'});
+ this.conn.onclose = evt => {
+ console.log('Live: websocket onclose', evt);
+ reject({ message: 'Connection closed' });
this.initPromise = null;
setTimeout(this.reconnect.bind(this), 2000);
};
- this.conn.onmessage = (evt) => {
+ this.conn.onmessage = evt => {
this.handleMessage(evt.data);
};
- this.conn.onerror = (evt) => {
+ this.conn.onerror = evt => {
this.initPromise = null;
- reject({message: 'Connection error'});
- console.log("Live: websocket error", evt);
+ reject({ message: 'Connection error' });
+ console.log('Live: websocket error', evt);
};
- this.conn.onopen = (evt) => {
+ this.conn.onopen = evt => {
console.log('opened');
this.initPromise = null;
resolve(this.conn);
@@ -62,7 +67,7 @@ export class LiveSrv {
message = JSON.parse(message);
if (!message.stream) {
- console.log("Error: stream message without stream!", message);
+ console.log('Error: stream message without stream!', message);
return;
}
@@ -85,7 +90,7 @@ export class LiveSrv {
this.getConnection().then(conn => {
_.each(this.observers, (value, key) => {
- this.send({action: 'subscribe', stream: key});
+ this.send({ action: 'subscribe', stream: key });
});
});
}
@@ -98,7 +103,7 @@ export class LiveSrv {
this.observers[stream] = observer;
this.getConnection().then(conn => {
- this.send({action: 'subscribe', stream: stream});
+ this.send({ action: 'subscribe', stream: stream });
});
}
@@ -107,7 +112,7 @@ export class LiveSrv {
delete this.observers[stream];
this.getConnection().then(conn => {
- this.send({action: 'unsubscribe', stream: stream});
+ this.send({ action: 'unsubscribe', stream: stream });
});
}
@@ -126,8 +131,7 @@ export class LiveSrv {
// this.send({action: 'subscribe', stream: name});
// });
}
-
}
var instance = new LiveSrv();
-export {instance as liveSrv};
+export { instance as liveSrv };
diff --git a/public/app/core/mod_defs.d.ts b/public/app/core/mod_defs.d.ts
index e42bac80310..d5b2e6c2a8a 100644
--- a/public/app/core/mod_defs.d.ts
+++ b/public/app/core/mod_defs.d.ts
@@ -1,18 +1,14 @@
-declare module "app/core/controllers/all" {
+declare module 'app/core/controllers/all' {
let json: any;
- export {json};
+ export { json };
}
-declare module "app/core/routes/all" {
+declare module 'app/core/routes/all' {
let json: any;
- export {json};
+ export { json };
}
-declare module "app/core/services/all" {
+declare module 'app/core/services/all' {
let json: any;
export default json;
}
-
-
-
-
diff --git a/public/app/core/nav_model_srv.ts b/public/app/core/nav_model_srv.ts
index 85d4ccfb7e1..a9ebd4e79ed 100644
--- a/public/app/core/nav_model_srv.ts
+++ b/public/app/core/nav_model_srv.ts
@@ -34,7 +34,7 @@ export class NavModelSrv {
}
getCfgNode() {
- return _.find(this.navItems, {id: 'cfg'});
+ return _.find(this.navItems, { id: 'cfg' });
}
getNav(...args) {
@@ -48,7 +48,7 @@ export class NavModelSrv {
break;
}
- let node = _.find(children, {id: id});
+ let node = _.find(children, { id: id });
nav.breadcrumbs.push(node);
nav.node = node;
nav.main = node;
@@ -70,15 +70,15 @@ export class NavModelSrv {
getNotFoundNav() {
var node = {
- text: "Page not found",
- icon: "fa fa-fw fa-warning",
- subTitle: "404 Error"
+ text: 'Page not found',
+ icon: 'fa fa-fw fa-warning',
+ subTitle: '404 Error',
};
return {
breadcrumbs: [node],
node: node,
- main: node
+ main: node,
};
}
}
diff --git a/public/app/core/profiler.ts b/public/app/core/profiler.ts
index e762b3fc4b3..634a627899c 100644
--- a/public/app/core/profiler.ts
+++ b/public/app/core/profiler.ts
@@ -20,15 +20,30 @@ export class Profiler {
return;
}
- $rootScope.$watch(() => {
- this.digestCounter++;
- return false;
- }, () => {});
+ $rootScope.$watch(
+ () => {
+ this.digestCounter++;
+ return false;
+ },
+ () => {}
+ );
$rootScope.onAppEvent('refresh', this.refresh.bind(this), $rootScope);
- $rootScope.onAppEvent('dashboard-fetch-end', this.dashboardFetched.bind(this), $rootScope);
- $rootScope.onAppEvent('dashboard-initialized', this.dashboardInitialized.bind(this), $rootScope);
- $rootScope.onAppEvent('panel-initialized', this.panelInitialized.bind(this), $rootScope);
+ $rootScope.onAppEvent(
+ 'dashboard-fetch-end',
+ this.dashboardFetched.bind(this),
+ $rootScope
+ );
+ $rootScope.onAppEvent(
+ 'dashboard-initialized',
+ this.dashboardInitialized.bind(this),
+ $rootScope
+ );
+ $rootScope.onAppEvent(
+ 'panel-initialized',
+ this.panelInitialized.bind(this),
+ $rootScope
+ );
}
refresh() {
@@ -55,12 +70,21 @@ export class Profiler {
dashboardInitialized() {
setTimeout(() => {
- console.log("Dashboard::Performance Total Digests: " + this.digestCounter);
- console.log("Dashboard::Performance Total Watchers: " + this.getTotalWatcherCount());
- console.log("Dashboard::Performance Total ScopeCount: " + this.scopeCount);
+ console.log(
+ 'Dashboard::Performance Total Digests: ' + this.digestCounter
+ );
+ console.log(
+ 'Dashboard::Performance Total Watchers: ' + this.getTotalWatcherCount()
+ );
+ console.log(
+ 'Dashboard::Performance Total ScopeCount: ' + this.scopeCount
+ );
- var timeTaken = this.timings.lastPanelInitializedAt - this.timings.dashboardLoadStart;
- console.log("Dashboard::Performance All panels initialized in " + timeTaken + " ms");
+ var timeTaken =
+ this.timings.lastPanelInitializedAt - this.timings.dashboardLoadStart;
+ console.log(
+ 'Dashboard::Performance All panels initialized in ' + timeTaken + ' ms'
+ );
// measure digest performance
var rootDigestStart = window.performance.now();
@@ -68,7 +92,10 @@ export class Profiler {
this.$rootScope.$apply();
}
- console.log("Dashboard::Performance Root Digest " + ((window.performance.now() - rootDigestStart) / 30));
+ console.log(
+ 'Dashboard::Performance Root Digest ' +
+ (window.performance.now() - rootDigestStart) / 30
+ );
}, 3000);
}
@@ -77,15 +104,15 @@ export class Profiler {
var scopes = 0;
var root = $(document.getElementsByTagName('body'));
- var f = function (element) {
+ var f = function(element) {
if (element.data().hasOwnProperty('$scope')) {
scopes++;
- angular.forEach(element.data().$scope.$$watchers, function () {
+ angular.forEach(element.data().$scope.$$watchers, function() {
count++;
});
}
- angular.forEach(element.children(), function (childElement) {
+ angular.forEach(element.children(), function(childElement) {
f($(childElement));
});
};
@@ -116,8 +143,7 @@ export class Profiler {
this.panelsInitCount++;
this.timings.lastPanelInitializedAt = new Date().getTime();
}
-
}
var profiler = new Profiler();
-export {profiler};
+export { profiler };
diff --git a/public/app/core/routes/bundle_loader.ts b/public/app/core/routes/bundle_loader.ts
index b86f9fb1495..e4e345b49fc 100644
--- a/public/app/core/routes/bundle_loader.ts
+++ b/public/app/core/routes/bundle_loader.ts
@@ -4,19 +4,23 @@ export class BundleLoader {
constructor(bundleName) {
var defer = null;
- this.lazy = ["$q", "$route", "$rootScope", ($q, $route, $rootScope) => {
- if (defer) {
+ this.lazy = [
+ '$q',
+ '$route',
+ '$rootScope',
+ ($q, $route, $rootScope) => {
+ if (defer) {
+ return defer.promise;
+ }
+
+ defer = $q.defer();
+
+ System.import(bundleName).then(() => {
+ defer.resolve();
+ });
+
return defer.promise;
- }
-
- defer = $q.defer();
-
- System.import(bundleName).then(() => {
- defer.resolve();
- });
-
- return defer.promise;
- }];
-
+ },
+ ];
}
}
diff --git a/public/app/core/routes/dashboard_loaders.ts b/public/app/core/routes/dashboard_loaders.ts
index 4e32a378a3b..7b6ed068b30 100644
--- a/public/app/core/routes/dashboard_loaders.ts
+++ b/public/app/core/routes/dashboard_loaders.ts
@@ -1,10 +1,9 @@
import coreModule from '../core_module';
export class LoadDashboardCtrl {
-
/** @ngInject */
constructor($scope, $routeParams, dashboardLoaderSrv, backendSrv, $location) {
- $scope.appEvent("dashboard-fetch-start");
+ $scope.appEvent('dashboard-fetch-start');
if (!$routeParams.slug) {
backendSrv.get('/api/dashboards/home').then(function(homeDash) {
@@ -19,33 +18,37 @@ export class LoadDashboardCtrl {
return;
}
- dashboardLoaderSrv.loadDashboard($routeParams.type, $routeParams.slug).then(function(result) {
- if ($routeParams.keepRows) {
- result.meta.keepRows = true;
- }
- $scope.initDashboard(result, $scope);
- });
+ dashboardLoaderSrv
+ .loadDashboard($routeParams.type, $routeParams.slug)
+ .then(function(result) {
+ if ($routeParams.keepRows) {
+ result.meta.keepRows = true;
+ }
+ $scope.initDashboard(result, $scope);
+ });
}
}
export class NewDashboardCtrl {
-
/** @ngInject */
constructor($scope, $routeParams) {
- $scope.initDashboard({
- meta: { canStar: false, canShare: false, isNew: true },
- dashboard: {
- title: "New dashboard",
- panels: [
- {
- type: 'add-panel',
- gridPos: {x: 0, y: 0, w: 12, h: 9},
- title: 'Panel Title',
- }
- ],
- folderId: Number($routeParams.folderId)
+ $scope.initDashboard(
+ {
+ meta: { canStar: false, canShare: false, isNew: true },
+ dashboard: {
+ title: 'New dashboard',
+ panels: [
+ {
+ type: 'add-panel',
+ gridPos: { x: 0, y: 0, w: 12, h: 9 },
+ title: 'Panel Title',
+ },
+ ],
+ folderId: Number($routeParams.folderId),
+ },
},
- }, $scope);
+ $scope
+ );
}
}
diff --git a/public/app/core/routes/routes.ts b/public/app/core/routes/routes.ts
index cd1ae8682b4..2e4950cac6f 100644
--- a/public/app/core/routes/routes.ts
+++ b/public/app/core/routes/routes.ts
@@ -6,277 +6,299 @@ function setupAngularRoutes($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
var loadOrgBundle = {
- lazy: ["$q", "$route", "$rootScope", ($q, $route, $rootScope) => {
- return System.import('app/features/org/all');
- }]
+ lazy: [
+ '$q',
+ '$route',
+ '$rootScope',
+ ($q, $route, $rootScope) => {
+ return System.import('app/features/org/all');
+ },
+ ],
};
var loadAdminBundle = {
- lazy: ["$q", "$route", "$rootScope", ($q, $route, $rootScope) => {
- return System.import('app/features/admin/admin');
- }]
+ lazy: [
+ '$q',
+ '$route',
+ '$rootScope',
+ ($q, $route, $rootScope) => {
+ return System.import('app/features/admin/admin');
+ },
+ ],
};
var loadAlertingBundle = {
- lazy: ["$q", "$route", "$rootScope", ($q, $route, $rootScope) => {
- return System.import('app/features/alerting/all');
- }]
+ lazy: [
+ '$q',
+ '$route',
+ '$rootScope',
+ ($q, $route, $rootScope) => {
+ return System.import('app/features/alerting/all');
+ },
+ ],
};
$routeProvider
- .when('/', {
- templateUrl: 'public/app/partials/dashboard.html',
- controller : 'LoadDashboardCtrl',
- reloadOnSearch: false,
- pageClass: 'page-dashboard',
- })
- .when('/dashboard/:type/:slug', {
- templateUrl: 'public/app/partials/dashboard.html',
- controller : 'LoadDashboardCtrl',
- reloadOnSearch: false,
- pageClass: 'page-dashboard',
- })
- .when('/dashboard-solo/:type/:slug', {
- templateUrl: 'public/app/features/panel/partials/soloPanel.html',
- controller : 'SoloPanelCtrl',
- reloadOnSearch: false,
- pageClass: 'page-dashboard',
- })
- .when('/dashboard/new', {
- templateUrl: 'public/app/partials/dashboard.html',
- controller : 'NewDashboardCtrl',
- reloadOnSearch: false,
- pageClass: 'page-dashboard',
- })
- .when('/dashboard/import', {
- templateUrl: 'public/app/features/dashboard/partials/dashboardImport.html',
- controller : 'DashboardImportCtrl',
- controllerAs: 'ctrl',
- })
- .when('/datasources', {
- templateUrl: 'public/app/features/plugins/partials/ds_list.html',
- controller : 'DataSourcesCtrl',
- controllerAs: 'ctrl',
- })
- .when('/datasources/edit/:id', {
- templateUrl: 'public/app/features/plugins/partials/ds_edit.html',
- controller : 'DataSourceEditCtrl',
- controllerAs: 'ctrl',
- })
- .when('/datasources/new', {
- templateUrl: 'public/app/features/plugins/partials/ds_edit.html',
- controller : 'DataSourceEditCtrl',
- controllerAs: 'ctrl',
- })
- .when('/dashboards', {
- templateUrl: 'public/app/features/dashboard/partials/dashboard_list.html',
- controller : 'DashboardListCtrl',
- controllerAs: 'ctrl',
- })
- .when('/dashboards/folder/new', {
- templateUrl: 'public/app/features/dashboard/partials/create_folder.html',
- controller : 'CreateFolderCtrl',
- controllerAs: 'ctrl',
- })
- .when('/dashboards/folder/:folderId/:slug/permissions', {
- templateUrl: 'public/app/features/dashboard/partials/folder_permissions.html',
- controller : 'FolderPermissionsCtrl',
- controllerAs: 'ctrl',
- })
- .when('/dashboards/folder/:folderId/:slug/settings', {
- templateUrl: 'public/app/features/dashboard/partials/folder_settings.html',
- controller : 'FolderSettingsCtrl',
- controllerAs: 'ctrl',
- })
- .when('/dashboards/folder/:folderId/:slug', {
- templateUrl: 'public/app/features/dashboard/partials/folder_dashboards.html',
- controller : 'FolderDashboardsCtrl',
- controllerAs: 'ctrl',
- })
- .when('/org', {
- templateUrl: 'public/app/features/org/partials/orgDetails.html',
- controller : 'OrgDetailsCtrl',
- resolve: loadOrgBundle,
- })
- .when('/org/new', {
- templateUrl: 'public/app/features/org/partials/newOrg.html',
- controller : 'NewOrgCtrl',
- resolve: loadOrgBundle,
- })
- .when('/org/users', {
- templateUrl: 'public/app/features/org/partials/orgUsers.html',
- controller : 'OrgUsersCtrl',
- controllerAs: 'ctrl',
- resolve: loadOrgBundle,
- })
- .when('/org/users/invite', {
- templateUrl: 'public/app/features/org/partials/invite.html',
- controller : 'UserInviteCtrl',
- controllerAs: 'ctrl',
- resolve: loadOrgBundle,
- })
- .when('/org/apikeys', {
- templateUrl: 'public/app/features/org/partials/orgApiKeys.html',
- controller : 'OrgApiKeysCtrl',
- resolve: loadOrgBundle,
- })
- .when('/org/teams', {
- templateUrl: 'public/app/features/org/partials/teams.html',
- controller : 'TeamsCtrl',
- controllerAs: 'ctrl',
- resolve: loadOrgBundle,
- })
- .when('/org/teams/edit/:id', {
- templateUrl: 'public/app/features/org/partials/team_details.html',
- controller : 'TeamDetailsCtrl',
- controllerAs: 'ctrl',
- resolve: loadOrgBundle,
- })
- .when('/profile', {
- templateUrl: 'public/app/features/org/partials/profile.html',
- controller : 'ProfileCtrl',
- controllerAs: 'ctrl',
- resolve: loadOrgBundle,
- })
- .when('/profile/password', {
- templateUrl: 'public/app/features/org/partials/change_password.html',
- controller : 'ChangePasswordCtrl',
- resolve: loadOrgBundle,
- })
- .when('/profile/select-org', {
- templateUrl: 'public/app/features/org/partials/select_org.html',
- controller : 'SelectOrgCtrl',
- resolve: loadOrgBundle,
- })
- // ADMIN
- .when('/admin', {
- templateUrl: 'public/app/features/admin/partials/admin_home.html',
- controller : 'AdminHomeCtrl',
- controllerAs: 'ctrl',
- resolve: loadAdminBundle,
- })
- .when('/admin/settings', {
- templateUrl: 'public/app/features/admin/partials/settings.html',
- controller : 'AdminSettingsCtrl',
- controllerAs: 'ctrl',
- resolve: loadAdminBundle,
- })
- .when('/admin/users', {
- templateUrl: 'public/app/features/admin/partials/users.html',
- controller : 'AdminListUsersCtrl',
- controllerAs: 'ctrl',
- resolve: loadAdminBundle,
- })
- .when('/admin/users/create', {
- templateUrl: 'public/app/features/admin/partials/new_user.html',
- controller : 'AdminEditUserCtrl',
- resolve: loadAdminBundle,
- })
- .when('/admin/users/edit/:id', {
- templateUrl: 'public/app/features/admin/partials/edit_user.html',
- controller : 'AdminEditUserCtrl',
- resolve: loadAdminBundle,
- })
- .when('/admin/orgs', {
- templateUrl: 'public/app/features/admin/partials/orgs.html',
- controller : 'AdminListOrgsCtrl',
- controllerAs: 'ctrl',
- resolve: loadAdminBundle,
- })
- .when('/admin/orgs/edit/:id', {
- templateUrl: 'public/app/features/admin/partials/edit_org.html',
- controller : 'AdminEditOrgCtrl',
- controllerAs: 'ctrl',
- resolve: loadAdminBundle,
- })
- .when('/admin/stats', {
- templateUrl: 'public/app/features/admin/partials/stats.html',
- controller : 'AdminStatsCtrl',
- controllerAs: 'ctrl',
- resolve: loadAdminBundle,
- })
- // LOGIN / SIGNUP
- .when('/login', {
- templateUrl: 'public/app/partials/login.html',
- controller : 'LoginCtrl',
- pageClass: 'login-page sidemenu-hidden',
- })
- .when('/invite/:code', {
- templateUrl: 'public/app/partials/signup_invited.html',
- controller : 'InvitedCtrl',
- pageClass: 'sidemenu-hidden',
- })
- .when('/signup', {
- templateUrl: 'public/app/partials/signup_step2.html',
- controller : 'SignUpCtrl',
- pageClass: 'sidemenu-hidden',
- })
- .when('/user/password/send-reset-email', {
- templateUrl: 'public/app/partials/reset_password.html',
- controller : 'ResetPasswordCtrl',
- pageClass: 'sidemenu-hidden',
- })
- .when('/user/password/reset', {
- templateUrl: 'public/app/partials/reset_password.html',
- controller : 'ResetPasswordCtrl',
- pageClass: 'sidemenu-hidden',
- })
- .when('/dashboard/snapshots', {
- templateUrl: 'public/app/features/snapshot/partials/snapshots.html',
- controller : 'SnapshotsCtrl',
- controllerAs: 'ctrl',
- })
- .when('/plugins', {
- templateUrl: 'public/app/features/plugins/partials/plugin_list.html',
- controller: 'PluginListCtrl',
- controllerAs: 'ctrl',
- })
- .when('/plugins/:pluginId/edit', {
- templateUrl: 'public/app/features/plugins/partials/plugin_edit.html',
- controller: 'PluginEditCtrl',
- controllerAs: 'ctrl',
- })
- .when('/plugins/:pluginId/page/:slug', {
- templateUrl: 'public/app/features/plugins/partials/plugin_page.html',
- controller: 'AppPageCtrl',
- controllerAs: 'ctrl',
- })
- .when('/styleguide/:page?', {
- controller: 'StyleGuideCtrl',
- controllerAs: 'ctrl',
- templateUrl: 'public/app/features/styleguide/styleguide.html',
- })
- .when('/alerting', {
- redirectTo: '/alerting/list'
- })
- .when('/alerting/list', {
- templateUrl: 'public/app/features/alerting/partials/alert_list.html',
- controller: 'AlertListCtrl',
- controllerAs: 'ctrl',
- resolve: loadAlertingBundle,
- })
- .when('/alerting/notifications', {
- templateUrl: 'public/app/features/alerting/partials/notifications_list.html',
- controller: 'AlertNotificationsListCtrl',
- controllerAs: 'ctrl',
- resolve: loadAlertingBundle,
- })
- .when('/alerting/notification/new', {
- templateUrl: 'public/app/features/alerting/partials/notification_edit.html',
- controller: 'AlertNotificationEditCtrl',
- controllerAs: 'ctrl',
- resolve: loadAlertingBundle,
- })
- .when('/alerting/notification/:id/edit', {
- templateUrl: 'public/app/features/alerting/partials/notification_edit.html',
- controller: 'AlertNotificationEditCtrl',
- controllerAs: 'ctrl',
- resolve: loadAlertingBundle,
- })
- .otherwise({
- templateUrl: 'public/app/partials/error.html',
- controller: 'ErrorCtrl'
- });
+ .when('/', {
+ templateUrl: 'public/app/partials/dashboard.html',
+ controller: 'LoadDashboardCtrl',
+ reloadOnSearch: false,
+ pageClass: 'page-dashboard',
+ })
+ .when('/dashboard/:type/:slug', {
+ templateUrl: 'public/app/partials/dashboard.html',
+ controller: 'LoadDashboardCtrl',
+ reloadOnSearch: false,
+ pageClass: 'page-dashboard',
+ })
+ .when('/dashboard-solo/:type/:slug', {
+ templateUrl: 'public/app/features/panel/partials/soloPanel.html',
+ controller: 'SoloPanelCtrl',
+ reloadOnSearch: false,
+ pageClass: 'page-dashboard',
+ })
+ .when('/dashboard/new', {
+ templateUrl: 'public/app/partials/dashboard.html',
+ controller: 'NewDashboardCtrl',
+ reloadOnSearch: false,
+ pageClass: 'page-dashboard',
+ })
+ .when('/dashboard/import', {
+ templateUrl:
+ 'public/app/features/dashboard/partials/dashboard_import.html',
+ controller: 'DashboardImportCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/datasources', {
+ templateUrl: 'public/app/features/plugins/partials/ds_list.html',
+ controller: 'DataSourcesCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/datasources/edit/:id', {
+ templateUrl: 'public/app/features/plugins/partials/ds_edit.html',
+ controller: 'DataSourceEditCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/datasources/new', {
+ templateUrl: 'public/app/features/plugins/partials/ds_edit.html',
+ controller: 'DataSourceEditCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/dashboards', {
+ templateUrl: 'public/app/features/dashboard/partials/dashboard_list.html',
+ controller: 'DashboardListCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/dashboards/folder/new', {
+ templateUrl: 'public/app/features/dashboard/partials/create_folder.html',
+ controller: 'CreateFolderCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/dashboards/folder/:folderId/:slug/permissions', {
+ templateUrl:
+ 'public/app/features/dashboard/partials/folder_permissions.html',
+ controller: 'FolderPermissionsCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/dashboards/folder/:folderId/:slug/settings', {
+ templateUrl:
+ 'public/app/features/dashboard/partials/folder_settings.html',
+ controller: 'FolderSettingsCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/dashboards/folder/:folderId/:slug', {
+ templateUrl:
+ 'public/app/features/dashboard/partials/folder_dashboards.html',
+ controller: 'FolderDashboardsCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/org', {
+ templateUrl: 'public/app/features/org/partials/orgDetails.html',
+ controller: 'OrgDetailsCtrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/org/new', {
+ templateUrl: 'public/app/features/org/partials/newOrg.html',
+ controller: 'NewOrgCtrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/org/users', {
+ templateUrl: 'public/app/features/org/partials/orgUsers.html',
+ controller: 'OrgUsersCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/org/users/invite', {
+ templateUrl: 'public/app/features/org/partials/invite.html',
+ controller: 'UserInviteCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/org/apikeys', {
+ templateUrl: 'public/app/features/org/partials/orgApiKeys.html',
+ controller: 'OrgApiKeysCtrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/org/teams', {
+ templateUrl: 'public/app/features/org/partials/teams.html',
+ controller: 'TeamsCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/org/teams/edit/:id', {
+ templateUrl: 'public/app/features/org/partials/team_details.html',
+ controller: 'TeamDetailsCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/profile', {
+ templateUrl: 'public/app/features/org/partials/profile.html',
+ controller: 'ProfileCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/profile/password', {
+ templateUrl: 'public/app/features/org/partials/change_password.html',
+ controller: 'ChangePasswordCtrl',
+ resolve: loadOrgBundle,
+ })
+ .when('/profile/select-org', {
+ templateUrl: 'public/app/features/org/partials/select_org.html',
+ controller: 'SelectOrgCtrl',
+ resolve: loadOrgBundle,
+ })
+ // ADMIN
+ .when('/admin', {
+ templateUrl: 'public/app/features/admin/partials/admin_home.html',
+ controller: 'AdminHomeCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAdminBundle,
+ })
+ .when('/admin/settings', {
+ templateUrl: 'public/app/features/admin/partials/settings.html',
+ controller: 'AdminSettingsCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAdminBundle,
+ })
+ .when('/admin/users', {
+ templateUrl: 'public/app/features/admin/partials/users.html',
+ controller: 'AdminListUsersCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAdminBundle,
+ })
+ .when('/admin/users/create', {
+ templateUrl: 'public/app/features/admin/partials/new_user.html',
+ controller: 'AdminEditUserCtrl',
+ resolve: loadAdminBundle,
+ })
+ .when('/admin/users/edit/:id', {
+ templateUrl: 'public/app/features/admin/partials/edit_user.html',
+ controller: 'AdminEditUserCtrl',
+ resolve: loadAdminBundle,
+ })
+ .when('/admin/orgs', {
+ templateUrl: 'public/app/features/admin/partials/orgs.html',
+ controller: 'AdminListOrgsCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAdminBundle,
+ })
+ .when('/admin/orgs/edit/:id', {
+ templateUrl: 'public/app/features/admin/partials/edit_org.html',
+ controller: 'AdminEditOrgCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAdminBundle,
+ })
+ .when('/admin/stats', {
+ templateUrl: 'public/app/features/admin/partials/stats.html',
+ controller: 'AdminStatsCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAdminBundle,
+ })
+ // LOGIN / SIGNUP
+ .when('/login', {
+ templateUrl: 'public/app/partials/login.html',
+ controller: 'LoginCtrl',
+ pageClass: 'login-page sidemenu-hidden',
+ })
+ .when('/invite/:code', {
+ templateUrl: 'public/app/partials/signup_invited.html',
+ controller: 'InvitedCtrl',
+ pageClass: 'sidemenu-hidden',
+ })
+ .when('/signup', {
+ templateUrl: 'public/app/partials/signup_step2.html',
+ controller: 'SignUpCtrl',
+ pageClass: 'sidemenu-hidden',
+ })
+ .when('/user/password/send-reset-email', {
+ templateUrl: 'public/app/partials/reset_password.html',
+ controller: 'ResetPasswordCtrl',
+ pageClass: 'sidemenu-hidden',
+ })
+ .when('/user/password/reset', {
+ templateUrl: 'public/app/partials/reset_password.html',
+ controller: 'ResetPasswordCtrl',
+ pageClass: 'sidemenu-hidden',
+ })
+ .when('/dashboard/snapshots', {
+ templateUrl: 'public/app/features/snapshot/partials/snapshots.html',
+ controller: 'SnapshotsCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/plugins', {
+ templateUrl: 'public/app/features/plugins/partials/plugin_list.html',
+ controller: 'PluginListCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/plugins/:pluginId/edit', {
+ templateUrl: 'public/app/features/plugins/partials/plugin_edit.html',
+ controller: 'PluginEditCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/plugins/:pluginId/page/:slug', {
+ templateUrl: 'public/app/features/plugins/partials/plugin_page.html',
+ controller: 'AppPageCtrl',
+ controllerAs: 'ctrl',
+ })
+ .when('/styleguide/:page?', {
+ controller: 'StyleGuideCtrl',
+ controllerAs: 'ctrl',
+ templateUrl: 'public/app/features/styleguide/styleguide.html',
+ })
+ .when('/alerting', {
+ redirectTo: '/alerting/list',
+ })
+ .when('/alerting/list', {
+ templateUrl: 'public/app/features/alerting/partials/alert_list.html',
+ controller: 'AlertListCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAlertingBundle,
+ })
+ .when('/alerting/notifications', {
+ templateUrl:
+ 'public/app/features/alerting/partials/notifications_list.html',
+ controller: 'AlertNotificationsListCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAlertingBundle,
+ })
+ .when('/alerting/notification/new', {
+ templateUrl:
+ 'public/app/features/alerting/partials/notification_edit.html',
+ controller: 'AlertNotificationEditCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAlertingBundle,
+ })
+ .when('/alerting/notification/:id/edit', {
+ templateUrl:
+ 'public/app/features/alerting/partials/notification_edit.html',
+ controller: 'AlertNotificationEditCtrl',
+ controllerAs: 'ctrl',
+ resolve: loadAlertingBundle,
+ })
+ .otherwise({
+ templateUrl: 'public/app/partials/error.html',
+ controller: 'ErrorCtrl',
+ });
}
coreModule.config(setupAngularRoutes);
diff --git a/public/app/core/services/alert_srv.ts b/public/app/core/services/alert_srv.ts
index 1a87ed6096c..82c824a2b75 100644
--- a/public/app/core/services/alert_srv.ts
+++ b/public/app/core/services/alert_srv.ts
@@ -14,29 +14,50 @@ export class AlertSrv {
}
init() {
- this.$rootScope.onAppEvent('alert-error', (e, alert) => {
- this.set(alert[0], alert[1], 'error', 12000);
- }, this.$rootScope);
+ this.$rootScope.onAppEvent(
+ 'alert-error',
+ (e, alert) => {
+ this.set(alert[0], alert[1], 'error', 12000);
+ },
+ this.$rootScope
+ );
- this.$rootScope.onAppEvent('alert-warning', (e, alert) => {
- this.set(alert[0], alert[1], 'warning', 5000);
- }, this.$rootScope);
+ this.$rootScope.onAppEvent(
+ 'alert-warning',
+ (e, alert) => {
+ this.set(alert[0], alert[1], 'warning', 5000);
+ },
+ this.$rootScope
+ );
- this.$rootScope.onAppEvent('alert-success', (e, alert) => {
- this.set(alert[0], alert[1], 'success', 3000);
- }, this.$rootScope);
+ this.$rootScope.onAppEvent(
+ 'alert-success',
+ (e, alert) => {
+ this.set(alert[0], alert[1], 'success', 3000);
+ },
+ this.$rootScope
+ );
- appEvents.on('alert-warning', options => this.set(options[0], options[1], 'warning', 5000));
- appEvents.on('alert-success', options => this.set(options[0], options[1], 'success', 3000));
- appEvents.on('alert-error', options => this.set(options[0], options[1], 'error', 7000));
+ appEvents.on('alert-warning', options =>
+ this.set(options[0], options[1], 'warning', 5000)
+ );
+ appEvents.on('alert-success', options =>
+ this.set(options[0], options[1], 'success', 3000)
+ );
+ appEvents.on('alert-error', options =>
+ this.set(options[0], options[1], 'error', 7000)
+ );
appEvents.on('confirm-modal', this.showConfirmModal.bind(this));
}
getIconForSeverity(severity) {
switch (severity) {
- case 'success': return 'fa fa-check';
- case 'error': return 'fa fa-exclamation-triangle';
- default: return 'fa fa-exclamation';
+ case 'success':
+ return 'fa fa-check';
+ case 'error':
+ return 'fa fa-exclamation-triangle';
+ default:
+ return 'fa fa-exclamation';
}
}
@@ -52,7 +73,7 @@ export class AlertSrv {
title: title || '',
text: text || '',
severity: severity || 'info',
- icon: this.getIconForSeverity(severity)
+ icon: this.getIconForSeverity(severity),
};
var newAlertJson = angular.toJson(newAlert);
@@ -73,7 +94,7 @@ export class AlertSrv {
this.$rootScope.$digest();
}
- return(newAlert);
+ return newAlert;
}
clear(alert) {
@@ -93,7 +114,8 @@ export class AlertSrv {
};
scope.updateConfirmText = function(value) {
- scope.confirmTextValid = payload.confirmText.toLowerCase() === value.toLowerCase();
+ scope.confirmTextValid =
+ payload.confirmText.toLowerCase() === value.toLowerCase();
};
scope.title = payload.title;
@@ -104,9 +126,9 @@ export class AlertSrv {
scope.onConfirm = payload.onConfirm;
scope.onAltAction = payload.onAltAction;
scope.altActionText = payload.altActionText;
- scope.icon = payload.icon || "fa-check";
- scope.yesText = payload.yesText || "Yes";
- scope.noText = payload.noText || "Cancel";
+ scope.icon = payload.icon || 'fa-check';
+ scope.yesText = payload.yesText || 'Yes';
+ scope.noText = payload.noText || 'Cancel';
scope.confirmTextValid = scope.confirmText ? false : true;
var confirmModal = this.$modal({
@@ -115,7 +137,7 @@ export class AlertSrv {
modalClass: 'confirm-modal',
show: false,
scope: scope,
- keyboard: false
+ keyboard: false,
});
confirmModal.then(function(modalEl) {
diff --git a/public/app/core/services/analytics.ts b/public/app/core/services/analytics.ts
index 87e84efa706..370773154e5 100644
--- a/public/app/core/services/analytics.ts
+++ b/public/app/core/services/analytics.ts
@@ -3,14 +3,17 @@ import coreModule from 'app/core/core_module';
import config from 'app/core/config';
export class Analytics {
-
/** @ngInject */
- constructor(private $rootScope, private $location) {
- }
+ constructor(private $rootScope, private $location) {}
gaInit() {
$.getScript('https://www.google-analytics.com/analytics.js'); // jQuery shortcut
- var ga = (
window).ga = (window).ga || function () { (ga.q = ga.q || []).push(arguments); }; ga.l = +new Date;
+ var ga = ((window).ga =
+ (window).ga ||
+ function() {
+ (ga.q = ga.q || []).push(arguments);
+ });
+ ga.l = +new Date();
ga('create', (config).googleAnalyticsId, 'auto');
return ga;
}
@@ -33,4 +36,3 @@ function startAnalytics(googleAnalyticsSrv) {
}
coreModule.service('googleAnalyticsSrv', Analytics).run(startAnalytics);
-
diff --git a/public/app/core/services/backend_srv.ts b/public/app/core/services/backend_srv.ts
index f9cc0ae124f..01ca5a70d70 100644
--- a/public/app/core/services/backend_srv.ts
+++ b/public/app/core/services/backend_srv.ts
@@ -11,8 +11,13 @@ export class BackendSrv {
private noBackendCache: boolean;
/** @ngInject */
- constructor(private $http, private alertSrv, private $q, private $timeout, private contextSrv) {
- }
+ constructor(
+ private $http,
+ private alertSrv,
+ private $q,
+ private $timeout,
+ private contextSrv
+ ) {}
get(url, params?) {
return this.request({ method: 'GET', url: url, params: params });
@@ -52,22 +57,22 @@ export class BackendSrv {
}
if (err.status === 422) {
- this.alertSrv.set("Validation failed", data.message, "warning", 4000);
+ this.alertSrv.set('Validation failed', data.message, 'warning', 4000);
throw data;
}
data.severity = 'error';
if (err.status < 500) {
- data.severity = "warning";
+ data.severity = 'warning';
}
if (data.message) {
- let description = "";
+ let description = '';
let message = data.message;
if (message.length > 80) {
description = message;
- message = "Error";
+ message = 'Error';
}
this.alertSrv.set(message, description, data.severity, 10000);
}
@@ -86,32 +91,39 @@ export class BackendSrv {
options.headers['X-Grafana-Org-Id'] = this.contextSrv.user.orgId;
}
- if (options.url.indexOf("/") === 0) {
+ if (options.url.indexOf('/') === 0) {
options.url = options.url.substring(1);
}
}
- return this.$http(options).then(results => {
- if (options.method !== 'GET') {
- if (results && results.data.message) {
- if (options.showSuccessAlert !== false) {
- this.alertSrv.set(results.data.message, '', 'success', 3000);
+ return this.$http(options).then(
+ results => {
+ if (options.method !== 'GET') {
+ if (results && results.data.message) {
+ if (options.showSuccessAlert !== false) {
+ this.alertSrv.set(results.data.message, '', 'success', 3000);
+ }
}
}
- }
- return results.data;
- }, err => {
- // handle unauthorized
- if (err.status === 401 && this.contextSrv.user.isSignedIn && firstAttempt) {
- return this.loginPing().then(() => {
- options.retry = 1;
- return this.request(options);
- });
- }
+ return results.data;
+ },
+ err => {
+ // handle unauthorized
+ if (
+ err.status === 401 &&
+ this.contextSrv.user.isSignedIn &&
+ firstAttempt
+ ) {
+ return this.loginPing().then(() => {
+ options.retry = 1;
+ return this.request(options);
+ });
+ }
- this.$timeout(this.requestErrorHandler.bind(this, err), 50);
- throw err;
- });
+ this.$timeout(this.requestErrorHandler.bind(this, err), 50);
+ throw err;
+ }
+ );
}
addCanceler(requestId, canceler) {
@@ -154,7 +166,7 @@ export class BackendSrv {
options.headers['X-Grafana-Org-Id'] = this.contextSrv.user.orgId;
}
- if (options.url.indexOf("/") === 0) {
+ if (options.url.indexOf('/') === 0) {
options.url = options.url.substring(1);
}
@@ -168,51 +180,53 @@ export class BackendSrv {
}
}
- return this.$http(options).then(response => {
- appEvents.emit('ds-request-response', response);
- return response;
- }).catch(err => {
- if (err.status === this.HTTP_REQUEST_CANCELLED) {
- throw {err, cancelled: true};
- }
+ return this.$http(options)
+ .then(response => {
+ appEvents.emit('ds-request-response', response);
+ return response;
+ })
+ .catch(err => {
+ if (err.status === this.HTTP_REQUEST_CANCELLED) {
+ throw { err, cancelled: true };
+ }
- // handle unauthorized for backend requests
- if (requestIsLocal && firstAttempt && err.status === 401) {
- return this.loginPing().then(() => {
- options.retry = 1;
- if (canceler) {
- canceler.resolve();
- }
- return this.datasourceRequest(options);
- });
- }
+ // handle unauthorized for backend requests
+ if (requestIsLocal && firstAttempt && err.status === 401) {
+ return this.loginPing().then(() => {
+ options.retry = 1;
+ if (canceler) {
+ canceler.resolve();
+ }
+ return this.datasourceRequest(options);
+ });
+ }
- // populate error obj on Internal Error
- if (_.isString(err.data) && err.status === 500) {
- err.data = {
- error: err.statusText,
- response: err.data,
- };
- }
+ // populate error obj on Internal Error
+ if (_.isString(err.data) && err.status === 500) {
+ err.data = {
+ error: err.statusText,
+ response: err.data,
+ };
+ }
- // for Prometheus
- if (err.data && !err.data.message && _.isString(err.data.error)) {
- err.data.message = err.data.error;
- }
+ // for Prometheus
+ if (err.data && !err.data.message && _.isString(err.data.error)) {
+ err.data.message = err.data.error;
+ }
- appEvents.emit('ds-request-error', err);
- throw err;
-
- }).finally(() => {
- // clean up
- if (options.requestId) {
- this.inFlightRequests[options.requestId].shift();
- }
- });
+ appEvents.emit('ds-request-error', err);
+ throw err;
+ })
+ .finally(() => {
+ // clean up
+ if (options.requestId) {
+ this.inFlightRequests[options.requestId].shift();
+ }
+ });
}
loginPing() {
- return this.request({url: '/api/login/ping', method: 'GET', retry: 1 });
+ return this.request({ url: '/api/login/ping', method: 'GET', retry: 1 });
}
search(query) {
@@ -224,7 +238,7 @@ export class BackendSrv {
}
saveDashboard(dash, options) {
- options = (options || {});
+ options = options || {};
return this.post('/api/dashboards/db/', {
dashboard: dash,
@@ -237,13 +251,16 @@ export class BackendSrv {
createDashboardFolder(name) {
const dash = {
schemaVersion: 16,
- title: name,
+ title: name.trim(),
editable: true,
- panels: []
+ panels: [],
};
- return this.post('/api/dashboards/db/', {dashboard: dash, isFolder: true, overwrite: false})
- .then(res => {
+ return this.post('/api/dashboards/db/', {
+ dashboard: dash,
+ isFolder: true,
+ overwrite: false,
+ }).then(res => {
return this.getDashboard('db', res.slug);
});
}
@@ -251,15 +268,15 @@ export class BackendSrv {
deleteDashboard(slug) {
let deferred = this.$q.defer();
- this.getDashboard('db', slug)
- .then(fullDash => {
- this.delete(`/api/dashboards/db/${slug}`)
- .then(() => {
- deferred.resolve(fullDash);
- }).catch(err => {
- deferred.reject(err);
- });
- });
+ this.getDashboard('db', slug).then(fullDash => {
+ this.delete(`/api/dashboards/db/${slug}`)
+ .then(() => {
+ deferred.resolve(fullDash);
+ })
+ .catch(err => {
+ deferred.reject(err);
+ });
+ });
return deferred.promise;
}
@@ -278,17 +295,19 @@ export class BackendSrv {
const tasks = [];
for (let slug of dashboardSlugs) {
- tasks.push(this.createTask(this.moveDashboard.bind(this), true, slug, toFolder));
+ tasks.push(
+ this.createTask(this.moveDashboard.bind(this), true, slug, toFolder)
+ );
}
- return this.executeInOrder(tasks, [])
- .then(result => {
- return {
- totalCount: result.length,
- successCount: _.filter(result, { succeeded: true }).length,
- alreadyInFolderCount: _.filter(result, { alreadyInFolder: true }).length
- };
- });
+ return this.executeInOrder(tasks, []).then(result => {
+ return {
+ totalCount: result.length,
+ successCount: _.filter(result, { succeeded: true }).length,
+ alreadyInFolderCount: _.filter(result, { alreadyInFolder: true })
+ .length,
+ };
+ });
}
private moveDashboard(slug, toFolder) {
@@ -297,9 +316,11 @@ export class BackendSrv {
this.getDashboard('db', slug).then(fullDash => {
const model = new DashboardModel(fullDash.dashboard, fullDash.meta);
- if ((!fullDash.meta.folderId && toFolder.id === 0) ||
- fullDash.meta.folderId === toFolder.id) {
- deferred.resolve({alreadyInFolder: true});
+ if (
+ (!fullDash.meta.folderId && toFolder.id === 0) ||
+ fullDash.meta.folderId === toFolder.id
+ ) {
+ deferred.resolve({ alreadyInFolder: true });
return;
}
@@ -310,19 +331,21 @@ export class BackendSrv {
this.saveDashboard(clone, {})
.then(() => {
- deferred.resolve({succeeded: true});
- }).catch(err => {
- if (err.data && err.data.status === "plugin-dashboard") {
+ deferred.resolve({ succeeded: true });
+ })
+ .catch(err => {
+ if (err.data && err.data.status === 'plugin-dashboard') {
err.isHandled = true;
- this.saveDashboard(clone, {overwrite: true})
+ this.saveDashboard(clone, { overwrite: true })
.then(() => {
- deferred.resolve({succeeded: true});
- }).catch(err => {
- deferred.resolve({succeeded: false});
+ deferred.resolve({ succeeded: true });
+ })
+ .catch(err => {
+ deferred.resolve({ succeeded: false });
});
} else {
- deferred.resolve({succeeded: false});
+ deferred.resolve({ succeeded: false });
}
});
});
@@ -331,11 +354,13 @@ export class BackendSrv {
}
private createTask(fn, ignoreRejections, ...args: any[]) {
- return (result) => {
- return fn.apply(null, args)
+ return result => {
+ return fn
+ .apply(null, args)
.then(res => {
return Array.prototype.concat(result, [res]);
- }).catch(err => {
+ })
+ .catch(err => {
if (ignoreRejections) {
return result;
}
@@ -350,5 +375,4 @@ export class BackendSrv {
}
}
-
coreModule.service('backendSrv', BackendSrv);
diff --git a/public/app/core/services/context_srv.ts b/public/app/core/services/context_srv.ts
index d707afc283d..96c671ea4bc 100644
--- a/public/app/core/services/context_srv.ts
+++ b/public/app/core/services/context_srv.ts
@@ -36,7 +36,7 @@ export class ContextSrv {
config.buildInfo = {};
}
if (!config.bootData) {
- config.bootData = {user: {}, settings: {}};
+ config.bootData = { user: {}, settings: {} };
}
this.version = config.buildInfo.version;
@@ -51,7 +51,10 @@ export class ContextSrv {
}
isGrafanaVisible() {
- return !!(document.visibilityState === undefined || document.visibilityState === 'visible');
+ return !!(
+ document.visibilityState === undefined ||
+ document.visibilityState === 'visible'
+ );
}
toggleSideMenu() {
@@ -61,7 +64,7 @@ export class ContextSrv {
}
var contextSrv = new ContextSrv();
-export {contextSrv};
+export { contextSrv };
coreModule.factory('contextSrv', function() {
return contextSrv;
diff --git a/public/app/core/services/dynamic_directive_srv.ts b/public/app/core/services/dynamic_directive_srv.ts
index 5565e19a3f6..86c2cbb40b4 100644
--- a/public/app/core/services/dynamic_directive_srv.ts
+++ b/public/app/core/services/dynamic_directive_srv.ts
@@ -4,7 +4,6 @@ import angular from 'angular';
import coreModule from '../core_module';
class DynamicDirectiveSrv {
-
/** @ngInject */
constructor(private $compile, private $rootScope) {}
@@ -17,22 +16,31 @@ class DynamicDirectiveSrv {
}
link(scope, elem, attrs, options) {
- options.directive(scope).then(directiveInfo => {
- if (!directiveInfo || !directiveInfo.fn) {
- elem.empty();
- return;
- }
+ options
+ .directive(scope)
+ .then(directiveInfo => {
+ if (!directiveInfo || !directiveInfo.fn) {
+ elem.empty();
+ return;
+ }
- if (!directiveInfo.fn.registered) {
- coreModule.directive(attrs.$normalize(directiveInfo.name), directiveInfo.fn);
- directiveInfo.fn.registered = true;
- }
+ if (!directiveInfo.fn.registered) {
+ coreModule.directive(
+ attrs.$normalize(directiveInfo.name),
+ directiveInfo.fn
+ );
+ directiveInfo.fn.registered = true;
+ }
- this.addDirective(elem, directiveInfo.name, scope);
- }).catch(err => {
- console.log('Plugin load:', err);
- this.$rootScope.appEvent('alert-error', ['Plugin error', err.toString()]);
- });
+ this.addDirective(elem, directiveInfo.name, scope);
+ })
+ .catch(err => {
+ console.log('Plugin load:', err);
+ this.$rootScope.appEvent('alert-error', [
+ 'Plugin error',
+ err.toString(),
+ ]);
+ });
}
create(options) {
@@ -52,7 +60,7 @@ class DynamicDirectiveSrv {
} else {
this.link(scope, elem, attrs, options);
}
- }
+ },
};
return directiveDef;
@@ -60,5 +68,3 @@ class DynamicDirectiveSrv {
}
coreModule.service('dynamicDirectiveSrv', DynamicDirectiveSrv);
-
-
diff --git a/public/app/core/services/global_event_srv.ts b/public/app/core/services/global_event_srv.ts
index a4d5865eb63..ee78a7802ab 100644
--- a/public/app/core/services/global_event_srv.ts
+++ b/public/app/core/services/global_event_srv.ts
@@ -1,19 +1,43 @@
import coreModule from 'app/core/core_module';
+import config from 'app/core/config';
import appEvents from 'app/core/app_events';
// This service is for registering global events.
// Good for communication react > angular and vice verse
export class GlobalEventSrv {
+ private appSubUrl;
+ private fullPageReloadRoutes;
/** @ngInject */
- constructor(private $location, private $timeout) {
+ constructor(private $location, private $timeout, private $window) {
+ this.appSubUrl = config.appSubUrl;
+ this.fullPageReloadRoutes = ['/logout'];
+ }
+
+ // Angular's $location does not like and absolute urls
+ stripBaseFromUrl(url = '') {
+ const appSubUrl = this.appSubUrl;
+ const stripExtraChars = appSubUrl.endsWith('/') ? 1 : 0;
+ const urlWithoutBase =
+ url.length > 0 && url.indexOf(appSubUrl) === 0
+ ? url.slice(appSubUrl.length - stripExtraChars)
+ : url;
+
+ return urlWithoutBase;
}
init() {
appEvents.on('location-change', payload => {
- this.$timeout(() => { // A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
- this.$location.path(payload.href);
- });
+ const urlWithoutBase = this.stripBaseFromUrl(payload.href);
+ if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) {
+ this.$window.location.href = payload.href;
+ return;
+ }
+
+ this.$timeout(() => {
+ // A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
+ this.$location.url(urlWithoutBase);
+ });
});
}
}
diff --git a/public/app/core/services/impression_srv.ts b/public/app/core/services/impression_srv.ts
index 9d2613d7372..3945c048876 100644
--- a/public/app/core/services/impression_srv.ts
+++ b/public/app/core/services/impression_srv.ts
@@ -15,7 +15,7 @@ export class ImpressionSrv {
}
}
- impressions = impressions.filter((imp) => {
+ impressions = impressions.filter(imp => {
return dashboardId !== imp;
});
@@ -28,7 +28,7 @@ export class ImpressionSrv {
}
getDashboardOpened() {
- var impressions = store.get(this.impressionKey(config)) || "[]";
+ var impressions = store.get(this.impressionKey(config)) || '[]';
impressions = JSON.parse(impressions);
@@ -40,7 +40,7 @@ export class ImpressionSrv {
}
impressionKey(config) {
- return "dashboard_impressions-" + config.bootData.user.orgId;
+ return 'dashboard_impressions-' + config.bootData.user.orgId;
}
}
diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts
index 4e819abd1bc..36fe73b62ce 100644
--- a/public/app/core/services/keybindingSrv.ts
+++ b/public/app/core/services/keybindingSrv.ts
@@ -10,10 +10,7 @@ export class KeybindingSrv {
helpModal: boolean;
/** @ngInject */
- constructor(
- private $rootScope,
- private $location) {
-
+ constructor(private $rootScope, private $location) {
// clear out all shortcuts on route change
$rootScope.$on('$routeChangeSuccess', () => {
Mousetrap.reset();
@@ -26,54 +23,58 @@ export class KeybindingSrv {
setupGlobal() {
this.bind(['?', 'h'], this.showHelpModal);
- this.bind("g h", this.goToHome);
- this.bind("g a", this.openAlerting);
- this.bind("g p", this.goToProfile);
- this.bind("s s", this.openSearchStarred);
+ this.bind('g h', this.goToHome);
+ this.bind('g a', this.openAlerting);
+ this.bind('g p', this.goToProfile);
+ this.bind('s s', this.openSearchStarred);
this.bind('s o', this.openSearch);
this.bind('s t', this.openSearchTags);
this.bind('f', this.openSearch);
}
openSearchStarred() {
- this.$rootScope.appEvent('show-dash-search', {starred: true});
+ appEvents.emit('show-dash-search', { starred: true });
}
openSearchTags() {
- this.$rootScope.appEvent('show-dash-search', {tagsMode: true});
+ appEvents.emit('show-dash-search', { tagsMode: true });
}
openSearch() {
- this.$rootScope.appEvent('show-dash-search');
+ appEvents.emit('show-dash-search');
}
openAlerting() {
- this.$location.url("/alerting");
+ this.$location.url('/alerting');
}
goToHome() {
- this.$location.url("/");
+ this.$location.url('/');
}
goToProfile() {
- this.$location.url("/profile");
+ this.$location.url('/profile');
}
showHelpModal() {
- appEvents.emit('show-modal', {templateHtml: ''});
+ appEvents.emit('show-modal', { templateHtml: '' });
}
bind(keyArg, fn) {
- Mousetrap.bind(keyArg, evt => {
- evt.preventDefault();
- evt.stopPropagation();
- evt.returnValue = false;
- return this.$rootScope.$apply(fn.bind(this));
- }, 'keydown');
+ Mousetrap.bind(
+ keyArg,
+ evt => {
+ evt.preventDefault();
+ evt.stopPropagation();
+ evt.returnValue = false;
+ return this.$rootScope.$apply(fn.bind(this));
+ },
+ 'keydown'
+ );
}
showDashEditView() {
- var search = _.extend(this.$location.search(), {editview: 'settings'});
+ var search = _.extend(this.$location.search(), { editview: 'settings' });
this.$location.search(search);
}
@@ -111,7 +112,7 @@ export class KeybindingSrv {
fullscreen: true,
edit: true,
panelId: dashboard.meta.focusPanelId,
- toggle: true
+ toggle: true,
});
}
});
@@ -140,14 +141,14 @@ export class KeybindingSrv {
// share panel
this.bind('p s', () => {
if (dashboard.meta.focusPanelId) {
- var shareScope = scope.$new();
+ var shareScope = scope.$new();
var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
shareScope.panel = panelInfo.panel;
shareScope.dashboard = dashboard;
appEvents.emit('show-modal', {
src: 'public/app/features/dashboard/partials/shareModal.html',
- scope: shareScope
+ scope: shareScope,
});
}
});
@@ -185,7 +186,7 @@ export class KeybindingSrv {
});
this.bind('d n', e => {
- this.$location.url("/dashboard/new");
+ this.$location.url('/dashboard/new');
});
this.bind('d r', () => {
@@ -211,7 +212,7 @@ export class KeybindingSrv {
}
scope.appEvent('hide-modal');
- scope.appEvent('panel-change-view', {fullscreen: false, edit: false});
+ scope.appEvent('panel-change-view', { fullscreen: false, edit: false });
// close settings view
var search = this.$location.search();
diff --git a/public/app/core/services/ng_react.ts b/public/app/core/services/ng_react.ts
index 9922772c730..55c1e19a52d 100644
--- a/public/app/core/services/ng_react.ts
+++ b/public/app/core/services/ng_react.ts
@@ -2,7 +2,6 @@
// This is using ng-react with this PR applied https://github.com/ngReact/ngReact/pull/199
//
-
// # ngReact
// ### Use React Components inside of your Angular applications
//
@@ -85,24 +84,27 @@ function applyFunctions(obj, scope, propsConfig?) {
var value = obj[key];
var config = (propsConfig || {})[key] || {};
/**
- * wrap functions in a function that ensures they are scope.$applied
- * ensures that when function is called from a React component
- * the Angular digest cycle is run
- */
- prev[key] = angular.isFunction(value) && config.wrapApply !== false ? applied(value, scope) : value;
+ * wrap functions in a function that ensures they are scope.$applied
+ * ensures that when function is called from a React component
+ * the Angular digest cycle is run
+ */
+ prev[key] =
+ angular.isFunction(value) && config.wrapApply !== false
+ ? applied(value, scope)
+ : value;
return prev;
}, {});
}
/**
- *
- * @param watchDepth (value of HTML watch-depth attribute)
- * @param scope (angular scope)
- *
- * Uses the watchDepth attribute to determine how to watch props on scope.
- * If watchDepth attribute is NOT reference or collection, watchDepth defaults to deep watching by value
- */
+ *
+ * @param watchDepth (value of HTML watch-depth attribute)
+ * @param scope (angular scope)
+ *
+ * Uses the watchDepth attribute to determine how to watch props on scope.
+ * If watchDepth attribute is NOT reference or collection, watchDepth defaults to deep watching by value
+ */
function watchProps(watchDepth, scope, watchExpressions, listener) {
var supportsWatchCollection = angular.isFunction(scope.$watchCollection);
var supportsWatchGroup = angular.isFunction(scope.$watchGroup);
@@ -165,7 +167,8 @@ function findAttribute(attrs, propName) {
// get watch depth of prop (string or array)
function getPropWatchDepth(defaultWatch, prop) {
- var customWatchDepth = Array.isArray(prop) && angular.isObject(prop[1]) && prop[1].watchDepth;
+ var customWatchDepth =
+ Array.isArray(prop) && angular.isObject(prop[1]) && prop[1].watchDepth;
return customWatchDepth || defaultWatch;
}
@@ -202,7 +205,9 @@ var reactComponent = function($injector) {
};
// If there are props, re-render when they change
- attrs.props ? watchProps(attrs.watchDepth, scope, [attrs.props], renderMyComponent) : renderMyComponent();
+ attrs.props
+ ? watchProps(attrs.watchDepth, scope, [attrs.props], renderMyComponent)
+ : renderMyComponent();
// cleanup when scope is destroyed
scope.$on('$destroy', function() {
@@ -210,7 +215,10 @@ var reactComponent = function($injector) {
ReactDOM.unmountComponentAtNode(elem[0]);
} else {
scope.$eval(attrs.onScopeDestroy, {
- unmountComponent: ReactDOM.unmountComponentAtNode.bind(this, elem[0]),
+ unmountComponent: ReactDOM.unmountComponentAtNode.bind(
+ this,
+ elem[0]
+ ),
});
}
});
@@ -274,11 +282,20 @@ var reactDirective = function($injector) {
// watch each property name and trigger an update whenever something changes,
// to update scope.props with new values
var propExpressions = props.map(function(prop) {
- return Array.isArray(prop) ? [attrs[getPropName(prop)], getPropConfig(prop)] : attrs[prop];
+ return Array.isArray(prop)
+ ? [attrs[getPropName(prop)], getPropConfig(prop)]
+ : attrs[prop];
});
// If we don't have any props, then our watch statement won't fire.
- props.length ? watchProps(attrs.watchDepth, scope, propExpressions, renderMyComponent) : renderMyComponent();
+ props.length
+ ? watchProps(
+ attrs.watchDepth,
+ scope,
+ propExpressions,
+ renderMyComponent
+ )
+ : renderMyComponent();
// cleanup when scope is destroyed
scope.$on('$destroy', function() {
@@ -286,7 +303,10 @@ var reactDirective = function($injector) {
ReactDOM.unmountComponentAtNode(elem[0]);
} else {
scope.$eval(attrs.onScopeDestroy, {
- unmountComponent: ReactDOM.unmountComponentAtNode.bind(this, elem[0]),
+ unmountComponent: ReactDOM.unmountComponentAtNode.bind(
+ this,
+ elem[0]
+ ),
});
}
});
diff --git a/public/app/core/services/popover_srv.ts b/public/app/core/services/popover_srv.ts
index bf0dae2c631..7c1708b15a7 100644
--- a/public/app/core/services/popover_srv.ts
+++ b/public/app/core/services/popover_srv.ts
@@ -57,8 +57,8 @@ function popoverSrv($compile, $rootScope, $timeout) {
openOn: options.openOn,
hoverCloseDelay: 200,
tetherOptions: {
- constraints: [{to: 'scrollParent', attachment: "none both"}]
- }
+ constraints: [{ to: 'scrollParent', attachment: 'together' }],
+ },
});
drop.on('close', () => {
diff --git a/public/app/core/services/search_srv.ts b/public/app/core/services/search_srv.ts
index a930868852f..a909b4af09f 100644
--- a/public/app/core/services/search_srv.ts
+++ b/public/app/core/services/search_srv.ts
@@ -18,7 +18,7 @@ export class SearchSrv {
return this.queryForRecentDashboards().then(result => {
if (result.length > 0) {
sections['recent'] = {
- title: 'Recent Boards',
+ title: 'Recent',
icon: 'fa fa-clock-o',
score: -1,
removable: true,
@@ -37,9 +37,11 @@ export class SearchSrv {
}
return this.backendSrv.search({ dashboardIds: dashIds }).then(result => {
- return dashIds.map(orderId => {
- return _.find(result, { id: orderId });
- }).filter(hit => hit && !hit.isStarred)
+ return dashIds
+ .map(orderId => {
+ return _.find(result, { id: orderId });
+ })
+ .filter(hit => hit && !hit.isStarred)
.map(hit => {
return this.transformToViewModel(hit);
});
@@ -71,10 +73,10 @@ export class SearchSrv {
return Promise.resolve();
}
- return this.backendSrv.search({starred: true, limit: 5}).then(result => {
+ return this.backendSrv.search({ starred: true, limit: 5 }).then(result => {
if (result.length > 0) {
sections['starred'] = {
- title: 'Starred Boards',
+ title: 'Starred',
icon: 'fa fa-star-o',
score: -2,
expanded: this.starredIsOpen,
@@ -94,8 +96,10 @@ export class SearchSrv {
let sections: any = {};
let promises = [];
let query = _.clone(options);
- let hasFilters = options.query ||
- (options.tag && options.tag.length > 0) || options.starred ||
+ let hasFilters =
+ options.query ||
+ (options.tag && options.tag.length > 0) ||
+ options.starred ||
(options.folderIds && options.folderIds.length > 0);
if (!options.skipRecent && !hasFilters) {
@@ -111,9 +115,11 @@ export class SearchSrv {
query.folderIds = [0];
}
- promises.push(this.backendSrv.search(query).then(results => {
- return this.handleSearchResult(sections, results);
- }));
+ promises.push(
+ this.backendSrv.search(query).then(results => {
+ return this.handleSearchResult(sections, results);
+ })
+ );
return this.$q.all(promises).then(() => {
return _.sortBy(_.values(sections), 'score');
diff --git a/public/app/core/services/timer.ts b/public/app/core/services/timer.ts
index 6355105ee0e..8052b3f2e2c 100644
--- a/public/app/core/services/timer.ts
+++ b/public/app/core/services/timer.ts
@@ -7,8 +7,7 @@ export class Timer {
timers = [];
/** @ngInject */
- constructor(private $timeout) {
- }
+ constructor(private $timeout) {}
register(promise) {
this.timers.push(promise);
diff --git a/public/app/core/services/util_srv.ts b/public/app/core/services/util_srv.ts
index dca016e1391..2a7dbe3a684 100644
--- a/public/app/core/services/util_srv.ts
+++ b/public/app/core/services/util_srv.ts
@@ -7,8 +7,7 @@ export class UtilSrv {
modalScope: any;
/** @ngInject */
- constructor(private $rootScope, private $modal) {
- }
+ constructor(private $rootScope, private $modal) {}
init() {
appEvents.on('show-modal', this.showModal.bind(this), this.$rootScope);
@@ -43,7 +42,7 @@ export class UtilSrv {
show: false,
scope: this.modalScope,
keyboard: false,
- backdrop: options.backdrop
+ backdrop: options.backdrop,
});
Promise.resolve(modal).then(function(modalEl) {
diff --git a/public/app/core/specs/backend_srv_specs.ts b/public/app/core/specs/backend_srv_specs.ts
index 5e8cfa7b761..eb228e01a72 100644
--- a/public/app/core/specs/backend_srv_specs.ts
+++ b/public/app/core/specs/backend_srv_specs.ts
@@ -1,4 +1,10 @@
-import {describe, beforeEach, it, expect, angularMocks} from 'test/lib/common';
+import {
+ describe,
+ beforeEach,
+ it,
+ expect,
+ angularMocks,
+} from 'test/lib/common';
import 'app/core/services/backend_srv';
describe('backend_srv', function() {
@@ -7,20 +13,24 @@ describe('backend_srv', function() {
beforeEach(angularMocks.module('grafana.core'));
beforeEach(angularMocks.module('grafana.services'));
- beforeEach(angularMocks.inject(function ($httpBackend, $http, backendSrv) {
- _httpBackend = $httpBackend;
- _backendSrv = backendSrv;
- }));
+ beforeEach(
+ angularMocks.inject(function($httpBackend, $http, backendSrv) {
+ _httpBackend = $httpBackend;
+ _backendSrv = backendSrv;
+ })
+ );
describe('when handling errors', function() {
it('should return the http status code', function(done) {
_httpBackend.whenGET('gateway-error').respond(502);
- _backendSrv.datasourceRequest({
- url: 'gateway-error'
- }).catch(function(err) {
- expect(err.status).to.be(502);
- done();
- });
+ _backendSrv
+ .datasourceRequest({
+ url: 'gateway-error',
+ })
+ .catch(function(err) {
+ expect(err.status).to.be(502);
+ done();
+ });
_httpBackend.flush();
});
});
diff --git a/public/app/core/specs/datemath.jest.ts b/public/app/core/specs/datemath.jest.ts
index 54ef711bdcf..5bf79b1ca42 100644
--- a/public/app/core/specs/datemath.jest.ts
+++ b/public/app/core/specs/datemath.jest.ts
@@ -4,9 +4,9 @@ import * as dateMath from 'app/core/utils/datemath';
import moment from 'moment';
import _ from 'lodash';
-describe("DateMath", () => {
+describe('DateMath', () => {
var spans = ['s', 'm', 'h', 'd', 'w', 'M', 'y'];
- var anchor = '2014-01-01T06:06:06.666Z';
+ var anchor = '2014-01-01T06:06:06.666Z';
var unix = moment(anchor).valueOf();
var format = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
var clock;
@@ -20,9 +20,12 @@ describe("DateMath", () => {
expect(dateMath.parse('now&1d')).toBe(undefined);
});
- it('should return undefined if I pass a unit besides' + spans.toString(), () => {
- expect(dateMath.parse('now+5f')).toBe(undefined);
- });
+ it(
+ 'should return undefined if I pass a unit besides' + spans.toString(),
+ () => {
+ expect(dateMath.parse('now+5f')).toBe(undefined);
+ }
+ );
it('should return undefined if rounding unit is not 1', () => {
expect(dateMath.parse('now/2y')).toBe(undefined);
@@ -35,7 +38,7 @@ describe("DateMath", () => {
});
});
- it("now/d should set to start of current day", () => {
+ it('now/d should set to start of current day', () => {
var expected = new Date();
expected.setHours(0);
expected.setMinutes(0);
@@ -46,9 +49,19 @@ describe("DateMath", () => {
expect(startOfDay).toBe(expected.getTime());
});
- it("now/d on a utc dashboard should be start of the current day in UTC time", () => {
+ it('now/d on a utc dashboard should be start of the current day in UTC time', () => {
var today = new Date();
- var expected = new Date(Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate(), 0, 0, 0, 0));
+ var expected = new Date(
+ Date.UTC(
+ today.getUTCFullYear(),
+ today.getUTCMonth(),
+ today.getUTCDate(),
+ 0,
+ 0,
+ 0,
+ 0
+ )
+ );
var startOfDay = dateMath.parse('now/d', false, 'utc').valueOf();
expect(startOfDay).toBe(expected.getTime());
@@ -64,16 +77,20 @@ describe("DateMath", () => {
anchored = moment(anchor);
});
- _.each(spans, (span) => {
+ _.each(spans, span => {
var nowEx = 'now-5' + span;
- var thenEx = anchor + '||-5' + span;
+ var thenEx = anchor + '||-5' + span;
it('should return 5' + span + ' ago', () => {
- expect(dateMath.parse(nowEx).format(format)).toEqual(now.subtract(5, span).format(format));
+ expect(dateMath.parse(nowEx).format(format)).toEqual(
+ now.subtract(5, span).format(format)
+ );
});
it('should return 5' + span + ' before ' + anchor, () => {
- expect(dateMath.parse(thenEx).format(format)).toEqual(anchored.subtract(5, span).format(format));
+ expect(dateMath.parse(thenEx).format(format)).toEqual(
+ anchored.subtract(5, span).format(format)
+ );
});
});
@@ -90,13 +107,17 @@ describe("DateMath", () => {
now = moment();
});
- _.each(spans, (span) => {
- it('should round now to the beginning of the ' + span, function () {
- expect(dateMath.parse('now/' + span).format(format)).toEqual(now.startOf(span).format(format));
+ _.each(spans, span => {
+ it('should round now to the beginning of the ' + span, function() {
+ expect(dateMath.parse('now/' + span).format(format)).toEqual(
+ now.startOf(span).format(format)
+ );
});
- it('should round now to the end of the ' + span, function () {
- expect(dateMath.parse('now/' + span, true).format(format)).toEqual(now.endOf(span).format(format));
+ it('should round now to the end of the ' + span, function() {
+ expect(dateMath.parse('now/' + span, true).format(format)).toEqual(
+ now.endOf(span).format(format)
+ );
});
});
@@ -130,7 +151,4 @@ describe("DateMath", () => {
expect(date).toEqual(undefined);
});
});
-
});
-
-
diff --git a/public/app/core/specs/emitter.jest.ts b/public/app/core/specs/emitter.jest.ts
index 1de59852fcc..a819cf0ede2 100644
--- a/public/app/core/specs/emitter.jest.ts
+++ b/public/app/core/specs/emitter.jest.ts
@@ -1,9 +1,7 @@
-import {Emitter} from '../utils/emitter';
-
-describe("Emitter", () => {
+import { Emitter } from '../utils/emitter';
+describe('Emitter', () => {
describe('given 2 subscribers', () => {
-
it('should notfiy subscribers', () => {
var events = new Emitter();
var sub1Called = false;
@@ -45,20 +43,22 @@ describe("Emitter", () => {
events.on('test', () => {
sub1Called++;
- throw {message: "hello"};
+ throw { message: 'hello' };
});
events.on('test', () => {
sub2Called++;
});
- try { events.emit('test', null); } catch (_) { }
- try { events.emit('test', null); } catch (_) {}
+ try {
+ events.emit('test', null);
+ } catch (_) {}
+ try {
+ events.emit('test', null);
+ } catch (_) {}
expect(sub1Called).toBe(2);
expect(sub2Called).toBe(0);
});
});
});
-
-
diff --git a/public/app/core/specs/flatten.jest.ts b/public/app/core/specs/flatten.jest.ts
index 7fe07128d1e..7c7f4816d94 100644
--- a/public/app/core/specs/flatten.jest.ts
+++ b/public/app/core/specs/flatten.jest.ts
@@ -1,22 +1,22 @@
import flatten from 'app/core/utils/flatten';
-describe("flatten", () => {
-
+describe('flatten', () => {
it('should return flatten object', () => {
- var flattened = flatten({
- level1: 'level1-value',
- deeper: {
- level2: 'level2-value',
+ var flattened = flatten(
+ {
+ level1: 'level1-value',
deeper: {
- level3: 'level3-value'
- }
- }
- }, null);
+ level2: 'level2-value',
+ deeper: {
+ level3: 'level3-value',
+ },
+ },
+ },
+ null
+ );
expect(flattened['level1']).toBe('level1-value');
expect(flattened['deeper.level2']).toBe('level2-value');
expect(flattened['deeper.deeper.level3']).toBe('level3-value');
});
-
});
-
diff --git a/public/app/core/specs/global_event_srv.jest.ts b/public/app/core/specs/global_event_srv.jest.ts
new file mode 100644
index 00000000000..ba318b81cc7
--- /dev/null
+++ b/public/app/core/specs/global_event_srv.jest.ts
@@ -0,0 +1,23 @@
+import { GlobalEventSrv } from 'app/core/services/global_event_srv';
+import { beforeEach } from 'test/lib/common';
+
+jest.mock('app/core/config', () => {
+ return {
+ appSubUrl: '/subUrl',
+ };
+});
+
+describe('GlobalEventSrv', () => {
+ let searchSrv;
+
+ beforeEach(() => {
+ searchSrv = new GlobalEventSrv(null, null, null);
+ });
+
+ describe('With /subUrl as appSubUrl', () => {
+ it('/subUrl should be stripped', () => {
+ const urlWithoutMaster = searchSrv.stripBaseFromUrl('/subUrl/grafana/');
+ expect(urlWithoutMaster).toBe('/grafana/');
+ });
+ });
+});
diff --git a/public/app/core/specs/kbn.jest.ts b/public/app/core/specs/kbn.jest.ts
index 9f50a05d5ad..490c66a90af 100644
--- a/public/app/core/specs/kbn.jest.ts
+++ b/public/app/core/specs/kbn.jest.ts
@@ -5,9 +5,7 @@ import moment from 'moment';
describe('unit format menu', function() {
var menu = kbn.getUnitFormats();
menu.map(function(submenu) {
-
describe('submenu ' + submenu.text, function() {
-
it('should have a title', function() {
expect(typeof submenu.text).toBe('string');
});
@@ -18,8 +16,12 @@ describe('unit format menu', function() {
submenu.submenu.map(function(entry) {
describe('entry ' + entry.text, function() {
- it('should have a title', function() { expect(typeof entry.text).toBe('string'); });
- it('should have a format', function() { expect(typeof entry.value).toBe('string'); });
+ it('should have a title', function() {
+ expect(typeof entry.text).toBe('string');
+ });
+ it('should have a format', function() {
+ expect(typeof entry.value).toBe('string');
+ });
it('should have a valid format', function() {
expect(typeof kbn.valueFormats[entry.value]).toBe('function');
});
@@ -30,15 +32,14 @@ describe('unit format menu', function() {
});
function describeValueFormat(desc, value, tickSize, tickDecimals, result) {
-
describe('value format: ' + desc, function() {
it('should translate ' + value + ' as ' + result, function() {
- var scaledDecimals = tickDecimals - Math.floor(Math.log(tickSize) / Math.LN10);
+ var scaledDecimals =
+ tickDecimals - Math.floor(Math.log(tickSize) / Math.LN10);
var str = kbn.valueFormats[desc](value, tickDecimals, scaledDecimals);
expect(str).toBe(result);
});
});
-
}
describeValueFormat('ms', 0.0024, 0.0005, 4, '0.0024 ms');
@@ -53,7 +54,7 @@ describeValueFormat('none', 2.75e-10, 0, 10, '3e-10');
describeValueFormat('none', 0, 0, 2, '0');
describeValueFormat('dB', 10, 1000, 2, '10.00 dB');
-describeValueFormat('percent', 0, 0, 0, '0%');
+describeValueFormat('percent', 0, 0, 0, '0%');
describeValueFormat('percent', 53, 0, 1, '53.0%');
describeValueFormat('percentunit', 0.0, 0, 0, '0%');
describeValueFormat('percentunit', 0.278, 0, 1, '27.8%');
@@ -63,7 +64,7 @@ describeValueFormat('currencyUSD', 7.42, 10000, 2, '$7.42');
describeValueFormat('currencyUSD', 1532.82, 1000, 1, '$1.53K');
describeValueFormat('currencyUSD', 18520408.7, 10000000, 0, '$19M');
-describeValueFormat('bytes', -1.57e+308, -1.57e+308, 2, 'NA');
+describeValueFormat('bytes', -1.57e308, -1.57e308, 2, 'NA');
describeValueFormat('ns', 25, 1, 0, '25 ns');
describeValueFormat('ns', 2558, 50, 0, '2.56 µs');
@@ -109,7 +110,7 @@ describe('date time formats', function() {
it('should format as iso date and skip date when today', function() {
var now = moment();
var str = kbn.valueFormats.dateTimeAsIso(now.valueOf(), 1);
- expect(str).toBe(now.format("HH:mm:ss"));
+ expect(str).toBe(now.format('HH:mm:ss'));
});
it('should format as US date', function() {
@@ -120,7 +121,7 @@ describe('date time formats', function() {
it('should format as US date and skip date when today', function() {
var now = moment();
var str = kbn.valueFormats.dateTimeAsUS(now.valueOf(), 1);
- expect(str).toBe(now.format("h:mm:ss a"));
+ expect(str).toBe(now.format('h:mm:ss a'));
});
it('should format as from now with days', function() {
@@ -190,7 +191,7 @@ describe('calculateInterval', function() {
});
it('fixed user min interval', function() {
- var range = {from: dateMath.parse('now-10m'), to: dateMath.parse('now')};
+ var range = { from: dateMath.parse('now-10m'), to: dateMath.parse('now') };
var res = kbn.calculateInterval(range, 1600, '10s');
expect(res.interval).toBe('10s');
expect(res.intervalMs).toBe(10000);
@@ -203,7 +204,7 @@ describe('calculateInterval', function() {
});
it('large time range and user low limit', function() {
- var range = {from: dateMath.parse('now-14d'), to: dateMath.parse('now')};
+ var range = { from: dateMath.parse('now-14d'), to: dateMath.parse('now') };
var res = kbn.calculateInterval(range, 1000, '>10s');
expect(res.interval).toBe('20m');
});
@@ -222,7 +223,10 @@ describe('calculateInterval', function() {
});
it('86399s 1 resolution', function() {
- var range = { from: dateMath.parse('now-86390s'), to: dateMath.parse('now') };
+ var range = {
+ from: dateMath.parse('now-86390s'),
+ to: dateMath.parse('now'),
+ };
var res = kbn.calculateInterval(range, 1, null);
expect(res.interval).toBe('12h');
expect(res.intervalMs).toBe(43200000);
@@ -254,11 +258,11 @@ describe('hex', function() {
describe('hex 0x', function() {
it('positive integeter', function() {
- var str = kbn.valueFormats.hex0x(7999,0);
+ var str = kbn.valueFormats.hex0x(7999, 0);
expect(str).toBe('0x1F3F');
});
it('negative integer', function() {
- var str = kbn.valueFormats.hex0x(-584,0);
+ var str = kbn.valueFormats.hex0x(-584, 0);
expect(str).toBe('-0x248');
});
it('null', function() {
@@ -277,71 +281,75 @@ describe('hex 0x', function() {
describe('duration', function() {
it('null', function() {
- var str = kbn.toDuration(null, 0, "millisecond");
+ var str = kbn.toDuration(null, 0, 'millisecond');
expect(str).toBe('');
});
it('0 milliseconds', function() {
- var str = kbn.toDuration(0, 0, "millisecond");
+ var str = kbn.toDuration(0, 0, 'millisecond');
expect(str).toBe('0 milliseconds');
});
it('1 millisecond', function() {
- var str = kbn.toDuration(1, 0, "millisecond");
+ var str = kbn.toDuration(1, 0, 'millisecond');
expect(str).toBe('1 millisecond');
});
it('-1 millisecond', function() {
- var str = kbn.toDuration(-1, 0, "millisecond");
+ var str = kbn.toDuration(-1, 0, 'millisecond');
expect(str).toBe('1 millisecond ago');
});
it('seconds', function() {
- var str = kbn.toDuration(1, 0, "second");
+ var str = kbn.toDuration(1, 0, 'second');
expect(str).toBe('1 second');
});
it('minutes', function() {
- var str = kbn.toDuration(1, 0, "minute");
+ var str = kbn.toDuration(1, 0, 'minute');
expect(str).toBe('1 minute');
});
it('hours', function() {
- var str = kbn.toDuration(1, 0, "hour");
+ var str = kbn.toDuration(1, 0, 'hour');
expect(str).toBe('1 hour');
});
it('days', function() {
- var str = kbn.toDuration(1, 0, "day");
+ var str = kbn.toDuration(1, 0, 'day');
expect(str).toBe('1 day');
});
it('weeks', function() {
- var str = kbn.toDuration(1, 0, "week");
+ var str = kbn.toDuration(1, 0, 'week');
expect(str).toBe('1 week');
});
it('months', function() {
- var str = kbn.toDuration(1, 0, "month");
+ var str = kbn.toDuration(1, 0, 'month');
expect(str).toBe('1 month');
});
it('years', function() {
- var str = kbn.toDuration(1, 0, "year");
+ var str = kbn.toDuration(1, 0, 'year');
expect(str).toBe('1 year');
});
it('decimal days', function() {
- var str = kbn.toDuration(1.5, 2, "day");
+ var str = kbn.toDuration(1.5, 2, 'day');
expect(str).toBe('1 day, 12 hours, 0 minutes');
});
it('decimal months', function() {
- var str = kbn.toDuration(1.5, 3, "month");
+ var str = kbn.toDuration(1.5, 3, 'month');
expect(str).toBe('1 month, 2 weeks, 1 day, 0 hours');
});
it('no decimals', function() {
- var str = kbn.toDuration(38898367008, 0, "millisecond");
+ var str = kbn.toDuration(38898367008, 0, 'millisecond');
expect(str).toBe('1 year');
});
it('1 decimal', function() {
- var str = kbn.toDuration(38898367008, 1, "millisecond");
+ var str = kbn.toDuration(38898367008, 1, 'millisecond');
expect(str).toBe('1 year, 2 months');
});
it('too many decimals', function() {
- var str = kbn.toDuration(38898367008, 20, "millisecond");
- expect(str).toBe('1 year, 2 months, 3 weeks, 4 days, 5 hours, 6 minutes, 7 seconds, 8 milliseconds');
+ var str = kbn.toDuration(38898367008, 20, 'millisecond');
+ expect(str).toBe(
+ '1 year, 2 months, 3 weeks, 4 days, 5 hours, 6 minutes, 7 seconds, 8 milliseconds'
+ );
});
it('floating point error', function() {
- var str = kbn.toDuration(36993906007, 8, "millisecond");
- expect(str).toBe('1 year, 2 months, 0 weeks, 3 days, 4 hours, 5 minutes, 6 seconds, 7 milliseconds');
+ var str = kbn.toDuration(36993906007, 8, 'millisecond');
+ expect(str).toBe(
+ '1 year, 2 months, 0 weeks, 3 days, 4 hours, 5 minutes, 6 seconds, 7 milliseconds'
+ );
});
});
diff --git a/public/app/core/specs/manage_dashboards.jest.ts b/public/app/core/specs/manage_dashboards.jest.ts
index 00e1d0b11bd..86b4a223a80 100644
--- a/public/app/core/specs/manage_dashboards.jest.ts
+++ b/public/app/core/specs/manage_dashboards.jest.ts
@@ -10,43 +10,43 @@ describe('ManageDashboards', () => {
const response = [
{
id: 410,
- title: "afolder",
- type: "dash-folder",
+ title: 'afolder',
+ type: 'dash-folder',
items: [
{
id: 399,
- title: "Dashboard Test",
- url: "dashboard/db/dashboard-test",
+ title: 'Dashboard Test',
+ url: 'dashboard/db/dashboard-test',
icon: 'fa fa-folder',
tags: [],
isStarred: false,
folderId: 410,
- folderTitle: "afolder",
- folderSlug: "afolder"
- }
- ],
- tags: [],
- isStarred: false
- },
- {
- id: 0,
- title: "Root",
- icon: 'fa fa-folder-open',
- uri: "db/something-else",
- type: "dash-db",
- items: [
- {
- id: 500,
- title: "Dashboard Test",
- url: "dashboard/db/dashboard-test",
- icon: 'fa fa-folder',
- tags: [],
- isStarred: false
- }
+ folderTitle: 'afolder',
+ folderSlug: 'afolder',
+ },
],
tags: [],
isStarred: false,
- }
+ },
+ {
+ id: 0,
+ title: 'Root',
+ icon: 'fa fa-folder-open',
+ uri: 'db/something-else',
+ type: 'dash-db',
+ items: [
+ {
+ id: 500,
+ title: 'Dashboard Test',
+ url: 'dashboard/db/dashboard-test',
+ icon: 'fa fa-folder',
+ tags: [],
+ isStarred: false,
+ },
+ ],
+ tags: [],
+ isStarred: false,
+ },
];
ctrl = createCtrlWithStubs(response);
return ctrl.getDashboards();
@@ -67,24 +67,24 @@ describe('ManageDashboards', () => {
const response = [
{
id: 410,
- title: "afolder",
- type: "dash-folder",
+ title: 'afolder',
+ type: 'dash-folder',
items: [
{
id: 399,
- title: "Dashboard Test",
- url: "dashboard/db/dashboard-test",
+ title: 'Dashboard Test',
+ url: 'dashboard/db/dashboard-test',
icon: 'fa fa-folder',
tags: [],
isStarred: false,
folderId: 410,
- folderTitle: "afolder",
- folderSlug: "afolder"
- }
+ folderTitle: 'afolder',
+ folderSlug: 'afolder',
+ },
],
tags: [],
- isStarred: false
- }
+ isStarred: false,
+ },
];
ctrl = createCtrlWithStubs(response);
ctrl.folderId = 410;
@@ -106,26 +106,26 @@ describe('ManageDashboards', () => {
items: [
{
id: 399,
- title: "Dashboard Test",
- url: "dashboard/db/dashboard-test",
+ title: 'Dashboard Test',
+ url: 'dashboard/db/dashboard-test',
icon: 'fa fa-folder',
tags: [],
isStarred: false,
folderId: 410,
- folderTitle: "afolder",
- folderSlug: "afolder"
+ folderTitle: 'afolder',
+ folderSlug: 'afolder',
},
{
id: 500,
- title: "Dashboard Test",
- url: "dashboard/db/dashboard-test",
+ title: 'Dashboard Test',
+ url: 'dashboard/db/dashboard-test',
icon: 'fa fa-folder',
tags: [],
folderId: 499,
- isStarred: false
- }
- ]
- }
+ isStarred: false,
+ },
+ ],
+ },
];
ctrl = createCtrlWithStubs(response);
@@ -261,18 +261,14 @@ describe('ManageDashboards', () => {
ctrl.sections = [
{
id: 1,
- items: [
- { id: 2, checked: false }
- ],
- checked: false
+ items: [{ id: 2, checked: false }],
+ checked: false,
},
{
id: 0,
- items: [
- { id: 3, checked: false }
- ],
- checked: false
- }
+ items: [{ id: 3, checked: false }],
+ checked: false,
+ },
];
ctrl.selectionChanged();
});
@@ -313,18 +309,14 @@ describe('ManageDashboards', () => {
ctrl.sections = [
{
id: 1,
- items: [
- { id: 2, checked: true }
- ],
- checked: true
+ items: [{ id: 2, checked: true }],
+ checked: true,
},
{
id: 0,
- items: [
- { id: 3, checked: true }
- ],
- checked: true
- }
+ items: [{ id: 3, checked: true }],
+ checked: true,
+ },
];
ctrl.selectionChanged();
});
@@ -366,19 +358,15 @@ describe('ManageDashboards', () => {
{
id: 1,
title: 'folder',
- items: [
- { id: 2, checked: false }
- ],
- checked: false
+ items: [{ id: 2, checked: false }],
+ checked: false,
},
{
id: 0,
title: 'Root',
- items: [
- { id: 3, checked: true }
- ],
- checked: false
- }
+ items: [{ id: 3, checked: true }],
+ checked: false,
+ },
];
ctrl.selectionChanged();
});
@@ -398,19 +386,15 @@ describe('ManageDashboards', () => {
{
id: 1,
title: 'folder',
- items: [
- { id: 2, checked: true }
- ],
- checked: false
+ items: [{ id: 2, checked: true }],
+ checked: false,
},
{
id: 0,
title: 'Root',
- items: [
- { id: 3, checked: false }
- ],
- checked: false
- }
+ items: [{ id: 3, checked: false }],
+ checked: false,
+ },
];
ctrl.selectionChanged();
@@ -431,19 +415,15 @@ describe('ManageDashboards', () => {
{
id: 1,
title: 'folder',
- items: [
- { id: 2, checked: true }
- ],
- checked: false
+ items: [{ id: 2, checked: true }],
+ checked: false,
},
{
id: 0,
title: 'Root',
- items: [
- { id: 3, checked: true }
- ],
- checked: false
- }
+ items: [{ id: 3, checked: true }],
+ checked: false,
+ },
];
ctrl.selectionChanged();
@@ -464,27 +444,21 @@ describe('ManageDashboards', () => {
{
id: 1,
title: 'folder',
- items: [
- { id: 2, checked: false }
- ],
- checked: true
+ items: [{ id: 2, checked: false }],
+ checked: true,
},
{
id: 3,
title: 'folder',
- items: [
- { id: 4, checked: true }
- ],
- checked: false
+ items: [{ id: 4, checked: true }],
+ checked: false,
},
{
id: 0,
title: 'Root',
- items: [
- { id: 3, checked: false }
- ],
- checked: false
- }
+ items: [{ id: 3, checked: false }],
+ checked: false,
+ },
];
ctrl.selectionChanged();
@@ -510,29 +484,23 @@ describe('ManageDashboards', () => {
{
id: 1,
title: 'folder',
- items: [
- { id: 2, checked: true, slug: 'folder-dash' }
- ],
+ items: [{ id: 2, checked: true, slug: 'folder-dash' }],
checked: true,
- slug: 'folder'
+ slug: 'folder',
},
{
id: 3,
title: 'folder-2',
- items: [
- { id: 3, checked: true, slug: 'folder-2-dash' }
- ],
+ items: [{ id: 3, checked: true, slug: 'folder-2-dash' }],
checked: false,
- slug: 'folder-2'
+ slug: 'folder-2',
},
{
id: 0,
title: 'Root',
- items: [
- { id: 3, checked: true, slug: 'root-dash' }
- ],
- checked: true
- }
+ items: [{ id: 3, checked: true, slug: 'root-dash' }],
+ checked: true,
+ },
];
toBeDeleted = ctrl.getFoldersAndDashboardsToDelete();
@@ -567,20 +535,16 @@ describe('ManageDashboards', () => {
{
id: 1,
title: 'folder',
- items: [
- { id: 2, checked: true, slug: 'dash' }
- ],
+ items: [{ id: 2, checked: true, slug: 'dash' }],
checked: false,
- slug: 'folder'
+ slug: 'folder',
},
{
id: 0,
title: 'Root',
- items: [
- { id: 3, checked: true, slug: 'dash-2' }
- ],
- checked: false
- }
+ items: [{ id: 3, checked: true, slug: 'dash-2' }],
+ checked: false,
+ },
];
});
@@ -600,8 +564,12 @@ function createCtrlWithStubs(searchResponse: any, tags?: any) {
},
getDashboardTags: () => {
return q.resolve(tags || []);
- }
+ },
};
- return new ManageDashboardsCtrl({}, { getNav: () => { } }, searchSrvStub);
+ return new ManageDashboardsCtrl(
+ {},
+ { getNav: () => {} },
+ searchSrvStub
+ );
}
diff --git a/public/app/core/specs/org_switcher.jest.ts b/public/app/core/specs/org_switcher.jest.ts
index 9597d78f586..3d9c40a4318 100644
--- a/public/app/core/specs/org_switcher.jest.ts
+++ b/public/app/core/specs/org_switcher.jest.ts
@@ -1,10 +1,10 @@
-import {OrgSwitchCtrl} from '../components/org_switcher';
+import { OrgSwitchCtrl } from '../components/org_switcher';
import q from 'q';
jest.mock('app/core/services/context_srv', () => ({
contextSrv: {
- user: {orgId: 1}
- }
+ user: { orgId: 1 },
+ },
}));
describe('OrgSwitcher', () => {
@@ -13,18 +13,23 @@ describe('OrgSwitcher', () => {
let expectedUsingUrl;
beforeEach(() => {
-
const backendSrvStub: any = {
- get: (url) => { return q.resolve([]); },
- post: (url) => { expectedUsingUrl = url; return q.resolve({}); }
+ get: url => {
+ return q.resolve([]);
+ },
+ post: url => {
+ expectedUsingUrl = url;
+ return q.resolve({});
+ },
};
const orgSwitcherCtrl = new OrgSwitchCtrl(backendSrvStub);
- orgSwitcherCtrl.getWindowLocationHref = () => 'http://localhost:3000?orgId=1&from=now-3h&to=now';
- orgSwitcherCtrl.setWindowLocationHref = (href) => expectedHref = href;
+ orgSwitcherCtrl.getWindowLocationHref = () =>
+ 'http://localhost:3000?orgId=1&from=now-3h&to=now';
+ orgSwitcherCtrl.setWindowLocationHref = href => (expectedHref = href);
- return orgSwitcherCtrl.setUsingOrg({orgId: 2});
+ return orgSwitcherCtrl.setUsingOrg({ orgId: 2 });
});
it('should switch orgId in call to backend', () => {
@@ -32,7 +37,9 @@ describe('OrgSwitcher', () => {
});
it('should switch orgId in url', () => {
- expect(expectedHref).toBe('http://localhost:3000?orgId=2&from=now-3h&to=now');
+ expect(expectedHref).toBe(
+ 'http://localhost:3000?orgId=2&from=now-3h&to=now'
+ );
});
});
});
diff --git a/public/app/core/specs/rangeutil.jest.ts b/public/app/core/specs/rangeutil.jest.ts
index eb9dcfc3ace..535022b4493 100644
--- a/public/app/core/specs/rangeutil.jest.ts
+++ b/public/app/core/specs/rangeutil.jest.ts
@@ -2,17 +2,19 @@ import * as rangeUtil from 'app/core/utils/rangeutil';
import _ from 'lodash';
import moment from 'moment';
-describe("rangeUtil", () => {
-
- describe("Can get range grouped list of ranges", () => {
+describe('rangeUtil', () => {
+ describe('Can get range grouped list of ranges', () => {
it('when custom settings should return default range list', () => {
- var groups = rangeUtil.getRelativeTimesList({time_options: []}, 'Last 5 minutes');
+ var groups = rangeUtil.getRelativeTimesList(
+ { time_options: [] },
+ 'Last 5 minutes'
+ );
expect(_.keys(groups).length).toBe(4);
expect(groups[3][0].active).toBe(true);
});
});
- describe("Can get range text described", () => {
+ describe('Can get range text described', () => {
it('should handle simple old expression with only amount and unit', () => {
var info = rangeUtil.describeTextRange('5m');
expect(info.display).toBe('Last 5 minutes');
@@ -57,52 +59,62 @@ describe("rangeUtil", () => {
});
});
- describe("Can get date range described", () => {
+ describe('Can get date range described', () => {
it('Date range with simple ranges', () => {
- var text = rangeUtil.describeTimeRange({from: 'now-1h', to: 'now'});
+ var text = rangeUtil.describeTimeRange({ from: 'now-1h', to: 'now' });
expect(text).toBe('Last 1 hour');
});
it('Date range with rounding ranges', () => {
- var text = rangeUtil.describeTimeRange({from: 'now/d+6h', to: 'now'});
+ var text = rangeUtil.describeTimeRange({ from: 'now/d+6h', to: 'now' });
expect(text).toBe('now/d+6h to now');
});
it('Date range with absolute to now', () => {
- var text = rangeUtil.describeTimeRange({from: moment([2014,10,10,2,3,4]), to: 'now'});
+ var text = rangeUtil.describeTimeRange({
+ from: moment([2014, 10, 10, 2, 3, 4]),
+ to: 'now',
+ });
expect(text).toBe('Nov 10, 2014 02:03:04 to a few seconds ago');
});
it('Date range with absolute to relative', () => {
- var text = rangeUtil.describeTimeRange({from: moment([2014,10,10,2,3,4]), to: 'now-1d'});
+ var text = rangeUtil.describeTimeRange({
+ from: moment([2014, 10, 10, 2, 3, 4]),
+ to: 'now-1d',
+ });
expect(text).toBe('Nov 10, 2014 02:03:04 to a day ago');
});
it('Date range with relative to absolute', () => {
- var text = rangeUtil.describeTimeRange({from: 'now-7d', to: moment([2014,10,10,2,3,4])});
+ var text = rangeUtil.describeTimeRange({
+ from: 'now-7d',
+ to: moment([2014, 10, 10, 2, 3, 4]),
+ });
expect(text).toBe('7 days ago to Nov 10, 2014 02:03:04');
});
it('Date range with non matching default ranges', () => {
- var text = rangeUtil.describeTimeRange({from: 'now-13h', to: 'now'});
+ var text = rangeUtil.describeTimeRange({ from: 'now-13h', to: 'now' });
expect(text).toBe('Last 13 hours');
});
it('Date range with from and to both are in now-* format', () => {
- var text = rangeUtil.describeTimeRange({from: 'now-6h', to: 'now-3h'});
+ var text = rangeUtil.describeTimeRange({ from: 'now-6h', to: 'now-3h' });
expect(text).toBe('now-6h to now-3h');
});
it('Date range with from and to both are either in now-* or now/* format', () => {
- var text = rangeUtil.describeTimeRange({from: 'now/d+6h', to: 'now-3h'});
+ var text = rangeUtil.describeTimeRange({
+ from: 'now/d+6h',
+ to: 'now-3h',
+ });
expect(text).toBe('now/d+6h to now-3h');
});
it('Date range with from and to both are either in now-* or now+* format', () => {
- var text = rangeUtil.describeTimeRange({from: 'now-6h', to: 'now+1h'});
+ var text = rangeUtil.describeTimeRange({ from: 'now-6h', to: 'now+1h' });
expect(text).toBe('now-6h to now+1h');
});
-
});
-
});
diff --git a/public/app/core/specs/search.jest.ts b/public/app/core/specs/search.jest.ts
index d3058e7550e..d0b1bbd78d3 100644
--- a/public/app/core/specs/search.jest.ts
+++ b/public/app/core/specs/search.jest.ts
@@ -4,9 +4,14 @@ import { SearchSrv } from '../services/search_srv';
describe('SearchCtrl', () => {
const searchSrvStub = {
search: (options: any) => {},
- getDashboardTags: () => {}
+ getDashboardTags: () => {},
};
- let ctrl = new SearchCtrl({}, {}, {}, searchSrvStub, { onAppEvent: () => { } });
+ let ctrl = new SearchCtrl(
+ { $on: () => {} },
+ {},
+ {},
+ searchSrvStub
+ );
describe('Given an empty result', () => {
beforeEach(() => {
@@ -45,19 +50,16 @@ describe('SearchCtrl', () => {
items: [],
selected: true,
expanded: false,
- toggle: (i) => i.expanded = !i.expanded
+ toggle: i => (i.expanded = !i.expanded),
},
{
id: 0,
title: 'Root',
- items: [
- { id: 3, selected: false },
- { id: 5, selected: false }
- ],
+ items: [{ id: 3, selected: false }, { id: 5, selected: false }],
selected: false,
expanded: true,
- toggle: (i) => i.expanded = !i.expanded
- }
+ toggle: i => (i.expanded = !i.expanded),
+ },
];
});
@@ -142,25 +144,19 @@ describe('SearchCtrl', () => {
{
id: 1,
title: 'folder',
- items: [
- { id: 2, selected: false },
- { id: 4, selected: false }
- ],
+ items: [{ id: 2, selected: false }, { id: 4, selected: false }],
selected: true,
expanded: false,
- toggle: (i) => i.expanded = !i.expanded
+ toggle: i => (i.expanded = !i.expanded),
},
{
id: 0,
title: 'Root',
- items: [
- { id: 3, selected: false },
- { id: 5, selected: false }
- ],
+ items: [{ id: 3, selected: false }, { id: 5, selected: false }],
selected: false,
expanded: true,
- toggle: (i) => i.expanded = !i.expanded
- }
+ toggle: i => (i.expanded = !i.expanded),
+ },
];
});
@@ -252,14 +248,11 @@ describe('SearchCtrl', () => {
ctrl.results = [
{
hideHeader: true,
- items: [
- { id: 3, selected: true },
- { id: 5, selected: false }
- ],
+ items: [{ id: 3, selected: true }, { id: 5, selected: false }],
selected: false,
expanded: true,
- toggle: (i) => i.expanded = !i.expanded
- }
+ toggle: i => (i.expanded = !i.expanded),
+ },
];
});
diff --git a/public/app/core/specs/search_results.jest.ts b/public/app/core/specs/search_results.jest.ts
index 7084f5e7d8f..830496be3a8 100644
--- a/public/app/core/specs/search_results.jest.ts
+++ b/public/app/core/specs/search_results.jest.ts
@@ -1,15 +1,23 @@
import { SearchResultsCtrl } from '../components/search/search_results';
+import { beforeEach, afterEach } from 'test/lib/common';
+import appEvents from 'app/core/app_events';
+
+jest.mock('app/core/app_events', () => {
+ return {
+ emit: jest.fn(),
+ };
+});
describe('SearchResultsCtrl', () => {
let ctrl;
describe('when checking an item that is not checked', () => {
- let item = {checked: false};
+ let item = { checked: false };
let selectionChanged = false;
beforeEach(() => {
ctrl = new SearchResultsCtrl({});
- ctrl.onSelectionChanged = () => selectionChanged = true;
+ ctrl.onSelectionChanged = () => (selectionChanged = true);
ctrl.toggleSelection(item);
});
@@ -23,12 +31,12 @@ describe('SearchResultsCtrl', () => {
});
describe('when checking an item that is checked', () => {
- let item = {checked: true};
+ let item = { checked: true };
let selectionChanged = false;
beforeEach(() => {
ctrl = new SearchResultsCtrl({});
- ctrl.onSelectionChanged = () => selectionChanged = true;
+ ctrl.onSelectionChanged = () => (selectionChanged = true);
ctrl.toggleSelection(item);
});
@@ -46,12 +54,12 @@ describe('SearchResultsCtrl', () => {
beforeEach(() => {
ctrl = new SearchResultsCtrl({});
- ctrl.onTagSelected = (tag) => selectedTag = tag;
+ ctrl.onTagSelected = tag => (selectedTag = tag);
ctrl.selectTag('tag-test');
});
it('should trigger tag selected callback', () => {
- expect(selectedTag["$tag"]).toBe('tag-test');
+ expect(selectedTag['$tag']).toBe('tag-test');
});
});
@@ -60,11 +68,13 @@ describe('SearchResultsCtrl', () => {
beforeEach(() => {
ctrl = new SearchResultsCtrl({});
- ctrl.onFolderExpanding = () => { folderExpanded = true; };
+ ctrl.onFolderExpanding = () => {
+ folderExpanded = true;
+ };
let folder = {
expanded: false,
- toggle: () => Promise.resolve(folder)
+ toggle: () => Promise.resolve(folder),
};
ctrl.toggleFolderExpand(folder);
@@ -80,11 +90,13 @@ describe('SearchResultsCtrl', () => {
beforeEach(() => {
ctrl = new SearchResultsCtrl({});
- ctrl.onFolderExpanding = () => { folderExpanded = true; };
+ ctrl.onFolderExpanding = () => {
+ folderExpanded = true;
+ };
let folder = {
expanded: true,
- toggle: () => Promise.resolve(folder)
+ toggle: () => Promise.resolve(folder),
};
ctrl.toggleFolderExpand(folder);
@@ -94,4 +106,39 @@ describe('SearchResultsCtrl', () => {
expect(folderExpanded).toBeFalsy();
});
});
+
+ describe('when clicking on a link in search result', () => {
+ const dashPath = 'dashboard/path';
+ const $location = { path: () => dashPath };
+ const appEventsMock = appEvents as any;
+
+ describe('with the same url as current path', () => {
+ beforeEach(() => {
+ ctrl = new SearchResultsCtrl($location);
+ const item = { url: dashPath };
+ ctrl.onItemClick(item);
+ });
+
+ it('should close the search', () => {
+ expect(appEventsMock.emit.mock.calls.length).toBe(1);
+ expect(appEventsMock.emit.mock.calls[0][0]).toBe('hide-dash-search');
+ });
+ });
+
+ describe('with a different url than current path', () => {
+ beforeEach(() => {
+ ctrl = new SearchResultsCtrl($location);
+ const item = { url: 'another/path' };
+ ctrl.onItemClick(item);
+ });
+
+ it('should do nothing', () => {
+ expect(appEventsMock.emit.mock.calls.length).toBe(0);
+ });
+ });
+
+ afterEach(() => {
+ appEventsMock.emit.mockClear();
+ });
+ });
});
diff --git a/public/app/core/specs/search_srv.jest.ts b/public/app/core/specs/search_srv.jest.ts
index f3135aa5f58..a1470578331 100644
--- a/public/app/core/specs/search_srv.jest.ts
+++ b/public/app/core/specs/search_srv.jest.ts
@@ -35,7 +35,10 @@ describe('SearchSrv', () => {
backendSrvMock.search = jest
.fn()
.mockReturnValueOnce(
- Promise.resolve([{ id: 2, title: 'second but first' }, { id: 1, title: 'first but second' }]),
+ Promise.resolve([
+ { id: 2, title: 'second but first' },
+ { id: 1, title: 'first but second' },
+ ])
)
.mockReturnValue(Promise.resolve([]));
@@ -47,7 +50,7 @@ describe('SearchSrv', () => {
});
it('should include recent dashboards section', () => {
- expect(results[0].title).toBe('Recent Boards');
+ expect(results[0].title).toBe('Recent');
});
it('should return order decided by impressions store not api', () => {
@@ -62,11 +65,13 @@ describe('SearchSrv', () => {
backendSrvMock.search = jest
.fn()
.mockReturnValueOnce(
- Promise.resolve([{ id: 2, title: 'two' }, { id: 1, title: 'one' }]),
+ Promise.resolve([{ id: 2, title: 'two' }, { id: 1, title: 'one' }])
)
.mockReturnValue(Promise.resolve([]));
- impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([4, 5, 1, 2, 3]);
+ impressionSrv.getDashboardOpened = jest
+ .fn()
+ .mockReturnValue([4, 5, 1, 2, 3]);
return searchSrv.search({ query: '' }).then(res => {
results = res;
@@ -87,9 +92,7 @@ describe('SearchSrv', () => {
beforeEach(() => {
backendSrvMock.search = jest
.fn()
- .mockReturnValue(Promise.resolve([
- {id: 1, title: 'starred'}
- ]));
+ .mockReturnValue(Promise.resolve([{ id: 1, title: 'starred' }]));
return searchSrv.search({ query: '' }).then(res => {
results = res;
@@ -97,7 +100,7 @@ describe('SearchSrv', () => {
});
it('should include starred dashboards section', () => {
- expect(results[0].title).toBe('Starred Boards');
+ expect(results[0].title).toBe('Starred');
expect(results[0].items.length).toBe(1);
});
});
@@ -108,30 +111,31 @@ describe('SearchSrv', () => {
beforeEach(() => {
backendSrvMock.search = jest
.fn()
- .mockReturnValueOnce(Promise.resolve([
- {id: 1, title: 'starred and recent', isStarred: true},
- {id: 2, title: 'recent'}
- ]))
- .mockReturnValue(Promise.resolve([
- {id: 1, title: 'starred and recent'}
- ]));
+ .mockReturnValueOnce(
+ Promise.resolve([
+ { id: 1, title: 'starred and recent', isStarred: true },
+ { id: 2, title: 'recent' },
+ ])
+ )
+ .mockReturnValue(
+ Promise.resolve([{ id: 1, title: 'starred and recent' }])
+ );
- impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([1,2]);
+ impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([1, 2]);
return searchSrv.search({ query: '' }).then(res => {
results = res;
});
});
it('should not show starred in recent', () => {
- expect(results[1].title).toBe('Recent Boards');
+ expect(results[1].title).toBe('Recent');
expect(results[1].items[0].title).toBe('recent');
});
it('should show starred', () => {
- expect(results[0].title).toBe('Starred Boards');
+ expect(results[0].title).toBe('Starred');
expect(results[0].items[0].title).toBe('starred and recent');
});
-
});
describe('with no query string and dashboards with folders returned', () => {
@@ -165,7 +169,7 @@ describe('SearchSrv', () => {
id: 4,
folderId: 1,
},
- ]),
+ ])
);
return searchSrv.search({ query: '' }).then(res => {
@@ -202,7 +206,7 @@ describe('SearchSrv', () => {
folderId: 1,
folderTitle: 'folder1',
},
- ]),
+ ])
);
return searchSrv.search({ query: 'search' }).then(res => {
diff --git a/public/app/core/specs/store.jest.ts b/public/app/core/specs/store.jest.ts
index 44cb2a84959..0162960621d 100644
--- a/public/app/core/specs/store.jest.ts
+++ b/public/app/core/specs/store.jest.ts
@@ -4,41 +4,37 @@ Object.assign(window, {
localStorage: {
removeItem(key) {
delete window.localStorage[key];
- }
- }
+ },
+ },
});
describe('store', () => {
-
- it("should store", ()=> {
- store.set("key1", "123");
- expect(store.get("key1")).toBe("123");
+ it('should store', () => {
+ store.set('key1', '123');
+ expect(store.get('key1')).toBe('123');
});
- it("get key when undefined", ()=> {
- expect(store.get("key2")).toBe(undefined);
+ it('get key when undefined', () => {
+ expect(store.get('key2')).toBe(undefined);
});
- it("check if key exixts", ()=> {
- store.set("key3", "123");
- expect(store.exists("key3")).toBe(true);
+ it('check if key exixts', () => {
+ store.set('key3', '123');
+ expect(store.exists('key3')).toBe(true);
});
- it("get boolean when no key", ()=> {
- expect(store.getBool("key4", false)).toBe(false);
+ it('get boolean when no key', () => {
+ expect(store.getBool('key4', false)).toBe(false);
});
- it("get boolean", ()=> {
- store.set("key5", "true");
- expect(store.getBool("key5", false)).toBe(true);
+ it('get boolean', () => {
+ store.set('key5', 'true');
+ expect(store.getBool('key5', false)).toBe(true);
});
- it("key should be deleted", ()=> {
- store.set("key6", "123");
- store.delete("key6");
- expect(store.exists("key6")).toBe(false);
+ it('key should be deleted', () => {
+ store.set('key6', '123');
+ store.delete('key6');
+ expect(store.exists('key6')).toBe(false);
});
-
});
-
-
diff --git a/public/app/core/specs/table_model.jest.ts b/public/app/core/specs/table_model.jest.ts
index 05c9fbda039..a2c1eb5e1af 100644
--- a/public/app/core/specs/table_model.jest.ts
+++ b/public/app/core/specs/table_model.jest.ts
@@ -3,7 +3,7 @@ import TableModel from 'app/core/table_model';
describe('when sorting table desc', () => {
var table;
var panel = {
- sort: {col: 0, desc: true},
+ sort: { col: 0, desc: true },
};
beforeEach(() => {
@@ -19,17 +19,16 @@ describe('when sorting table desc', () => {
expect(table.rows[2][0]).toBe(100);
});
- it ('should mark column being sorted', () => {
+ it('should mark column being sorted', () => {
expect(table.columns[0].sort).toBe(true);
expect(table.columns[0].desc).toBe(true);
});
-
});
describe('when sorting table asc', () => {
var table;
var panel = {
- sort: {col: 1, desc: false},
+ sort: { col: 1, desc: false },
};
beforeEach(() => {
@@ -44,6 +43,4 @@ describe('when sorting table asc', () => {
expect(table.rows[1][1]).toBe(11);
expect(table.rows[2][1]).toBe(15);
});
-
});
-
diff --git a/public/app/core/specs/time_series.jest.ts b/public/app/core/specs/time_series.jest.ts
index 1a199daa59f..bbbfae90990 100644
--- a/public/app/core/specs/time_series.jest.ts
+++ b/public/app/core/specs/time_series.jest.ts
@@ -1,6 +1,6 @@
import TimeSeries from 'app/core/time_series2';
-describe("TimeSeries", function() {
+describe('TimeSeries', function() {
var points, series;
var yAxisFormats = ['short', 'ms'];
var testData;
@@ -8,9 +8,7 @@ describe("TimeSeries", function() {
beforeEach(function() {
testData = {
alias: 'test',
- datapoints: [
- [1,2],[null,3],[10,4],[8,5]
- ]
+ datapoints: [[1, 2], [null, 3], [10, 4], [8, 5]],
};
});
@@ -30,7 +28,7 @@ describe("TimeSeries", function() {
it('if last is null current should pick next to last', function() {
series = new TimeSeries({
- datapoints: [[10,1], [null, 2]]
+ datapoints: [[10, 1], [null, 2]],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.current).toBe(10);
@@ -38,7 +36,7 @@ describe("TimeSeries", function() {
it('max value should work for negative values', function() {
series = new TimeSeries({
- datapoints: [[-10,1], [-4, 2]]
+ datapoints: [[-10, 1], [-4, 2]],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.max).toBe(-4);
@@ -52,7 +50,7 @@ describe("TimeSeries", function() {
it('the delta value should account for nulls', function() {
series = new TimeSeries({
- datapoints: [[1,2],[3,3],[null,4],[10,5],[15,6]]
+ datapoints: [[1, 2], [3, 3], [null, 4], [10, 5], [15, 6]],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(14);
@@ -60,7 +58,7 @@ describe("TimeSeries", function() {
it('the delta value should account for nulls on first', function() {
series = new TimeSeries({
- datapoints: [[null,2],[1,3],[10,4],[15,5]]
+ datapoints: [[null, 2], [1, 3], [10, 4], [15, 5]],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(14);
@@ -68,7 +66,7 @@ describe("TimeSeries", function() {
it('the delta value should account for nulls on last', function() {
series = new TimeSeries({
- datapoints: [[1,2],[5,3],[10,4],[null,5]]
+ datapoints: [[1, 2], [5, 3], [10, 4], [null, 5]],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(9);
@@ -76,7 +74,7 @@ describe("TimeSeries", function() {
it('the delta value should account for resets', function() {
series = new TimeSeries({
- datapoints: [[1,2],[5,3],[10,4],[0,5],[10,6]]
+ datapoints: [[1, 2], [5, 3], [10, 4], [0, 5], [10, 6]],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(19);
@@ -84,7 +82,7 @@ describe("TimeSeries", function() {
it('the delta value should account for resets on last', function() {
series = new TimeSeries({
- datapoints: [[1,2],[2,3],[10,4],[8,5]]
+ datapoints: [[1, 2], [2, 3], [10, 4], [8, 5]],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(17);
@@ -101,7 +99,7 @@ describe("TimeSeries", function() {
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.first).toBe(1);
series = new TimeSeries({
- datapoints: [[null,2],[1,3],[10,4],[8,5]]
+ datapoints: [[null, 2], [1, 3], [10, 4], [8, 5]],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.first).toBe(1);
@@ -115,7 +113,7 @@ describe("TimeSeries", function() {
it('average value should be null if all values is null', function() {
series = new TimeSeries({
- datapoints: [[null,2],[null,3],[null,4],[null,5]]
+ datapoints: [[null, 2], [null, 3], [null, 4], [null, 5]],
});
series.getFlotPairs('null');
expect(series.stats.avg).toBe(null);
@@ -125,7 +123,9 @@ describe("TimeSeries", function() {
describe('When checking if ms resolution is needed', function() {
describe('msResolution with second resolution timestamps', function() {
beforeEach(function() {
- series = new TimeSeries({datapoints: [[45, 1234567890], [60, 1234567899]]});
+ series = new TimeSeries({
+ datapoints: [[45, 1234567890], [60, 1234567899]],
+ });
});
it('should set hasMsResolution to false', function() {
@@ -135,7 +135,9 @@ describe("TimeSeries", function() {
describe('msResolution with millisecond resolution timestamps', function() {
beforeEach(function() {
- series = new TimeSeries({datapoints: [[55, 1236547890001], [90, 1234456709000]]});
+ series = new TimeSeries({
+ datapoints: [[55, 1236547890001], [90, 1234456709000]],
+ });
});
it('should show millisecond resolution tooltip', function() {
@@ -145,7 +147,9 @@ describe("TimeSeries", function() {
describe('msResolution with millisecond resolution timestamps but with trailing zeroes', function() {
beforeEach(function() {
- series = new TimeSeries({datapoints: [[45, 1234567890000], [60, 1234567899000]]});
+ series = new TimeSeries({
+ datapoints: [[45, 1234567890000], [60, 1234567899000]],
+ });
});
it('should not show millisecond resolution tooltip', function() {
@@ -195,7 +199,9 @@ describe("TimeSeries", function() {
describe('series option overrides, bars, true & lines false', function() {
beforeEach(function() {
series.alias = 'test';
- series.applySeriesOverrides([{ alias: 'test', bars: true, lines: false }]);
+ series.applySeriesOverrides([
+ { alias: 'test', bars: true, lines: false },
+ ]);
});
it('should disable lines, and enable bars', function() {
@@ -207,7 +213,9 @@ describe("TimeSeries", function() {
describe('series option overrides, linewidth, stack', function() {
beforeEach(function() {
series.alias = 'test';
- series.applySeriesOverrides([{ alias: 'test', linewidth: 5, stack: false }]);
+ series.applySeriesOverrides([
+ { alias: 'test', linewidth: 5, stack: false },
+ ]);
});
it('should disable stack, and set lineWidth', function() {
@@ -219,7 +227,9 @@ describe("TimeSeries", function() {
describe('series option overrides, dashes and lineWidth', function() {
beforeEach(function() {
series.alias = 'test';
- series.applySeriesOverrides([{ alias: 'test', linewidth: 5, dashes: true }]);
+ series.applySeriesOverrides([
+ { alias: 'test', linewidth: 5, dashes: true },
+ ]);
});
it('should enable dashes, set dashes lineWidth to 5 and lines lineWidth to 0', function() {
@@ -243,7 +253,9 @@ describe("TimeSeries", function() {
describe('series option overrides, pointradius, steppedLine', function() {
beforeEach(function() {
series.alias = 'test';
- series.applySeriesOverrides([{ alias: 'test', pointradius: 5, steppedLine: true }]);
+ series.applySeriesOverrides([
+ { alias: 'test', pointradius: 5, steppedLine: true },
+ ]);
});
it('should set pointradius, and set steppedLine', function() {
@@ -277,7 +289,6 @@ describe("TimeSeries", function() {
expect(series.zindex).toBe(2);
});
});
-
});
describe('value formatter', function() {
@@ -287,12 +298,11 @@ describe("TimeSeries", function() {
});
it('should format non-numeric values as empty string', function() {
- expect(series.formatValue(null)).toBe("");
- expect(series.formatValue(undefined)).toBe("");
- expect(series.formatValue(NaN)).toBe("");
- expect(series.formatValue(Infinity)).toBe("");
- expect(series.formatValue(-Infinity)).toBe("");
+ expect(series.formatValue(null)).toBe('');
+ expect(series.formatValue(undefined)).toBe('');
+ expect(series.formatValue(NaN)).toBe('');
+ expect(series.formatValue(Infinity)).toBe('');
+ expect(series.formatValue(-Infinity)).toBe('');
});
});
-
});
diff --git a/public/app/core/specs/value_select_dropdown_specs.ts b/public/app/core/specs/value_select_dropdown_specs.ts
index 644320e7e0d..d51a5a374b2 100644
--- a/public/app/core/specs/value_select_dropdown_specs.ts
+++ b/public/app/core/specs/value_select_dropdown_specs.ts
@@ -1,7 +1,14 @@
-import {describe, beforeEach, it, expect, angularMocks, sinon} from 'test/lib/common';
+import {
+ describe,
+ beforeEach,
+ it,
+ expect,
+ angularMocks,
+ sinon,
+} from 'test/lib/common';
import 'app/core/directives/value_select_dropdown';
-describe("SelectDropdownCtrl", function() {
+describe('SelectDropdownCtrl', function() {
var scope;
var ctrl;
var tagValuesMap: any = {};
@@ -9,19 +16,21 @@ describe("SelectDropdownCtrl", function() {
var q;
beforeEach(angularMocks.module('grafana.core'));
- beforeEach(angularMocks.inject(function($controller, $rootScope, $q, $httpBackend) {
- rootScope = $rootScope;
- q = $q;
- scope = $rootScope.$new();
- ctrl = $controller('ValueSelectDropdownCtrl', {$scope: scope});
- ctrl.onUpdated = sinon.spy();
- $httpBackend.when('GET', /\.html$/).respond('');
- }));
+ beforeEach(
+ angularMocks.inject(function($controller, $rootScope, $q, $httpBackend) {
+ rootScope = $rootScope;
+ q = $q;
+ scope = $rootScope.$new();
+ ctrl = $controller('ValueSelectDropdownCtrl', { $scope: scope });
+ ctrl.onUpdated = sinon.spy();
+ $httpBackend.when('GET', /\.html$/).respond('');
+ })
+ );
- describe("Given simple variable", function() {
+ describe('Given simple variable', function() {
beforeEach(function() {
ctrl.variable = {
- current: {text: 'hej', value: 'hej' },
+ current: { text: 'hej', value: 'hej' },
getValuesForTag: function(key) {
return q.when(tagValuesMap[key]);
},
@@ -29,25 +38,25 @@ describe("SelectDropdownCtrl", function() {
ctrl.init();
});
- it("Should init labelText and linkText", function() {
- expect(ctrl.linkText).to.be("hej");
+ it('Should init labelText and linkText', function() {
+ expect(ctrl.linkText).to.be('hej');
});
});
- describe("Given variable with tags and dropdown is opened", function() {
+ describe('Given variable with tags and dropdown is opened', function() {
beforeEach(function() {
ctrl.variable = {
- current: {text: 'server-1', value: 'server-1'},
+ current: { text: 'server-1', value: 'server-1' },
options: [
- {text: 'server-1', value: 'server-1', selected: true},
- {text: 'server-2', value: 'server-2'},
- {text: 'server-3', value: 'server-3'},
+ { text: 'server-1', value: 'server-1', selected: true },
+ { text: 'server-2', value: 'server-2' },
+ { text: 'server-3', value: 'server-3' },
],
- tags: ["key1", "key2", "key3"],
+ tags: ['key1', 'key2', 'key3'],
getValuesForTag: function(key) {
return q.when(tagValuesMap[key]);
},
- multi: true
+ multi: true,
};
tagValuesMap.key1 = ['server-1', 'server-3'];
tagValuesMap.key2 = ['server-2', 'server-3'];
@@ -56,20 +65,20 @@ describe("SelectDropdownCtrl", function() {
ctrl.show();
});
- it("should init tags model", function() {
+ it('should init tags model', function() {
expect(ctrl.tags.length).to.be(3);
- expect(ctrl.tags[0].text).to.be("key1");
+ expect(ctrl.tags[0].text).to.be('key1');
});
- it("should init options model", function() {
+ it('should init options model', function() {
expect(ctrl.options.length).to.be(3);
});
- it("should init selected values array", function() {
+ it('should init selected values array', function() {
expect(ctrl.selectedValues.length).to.be(1);
});
- it("should set linkText", function() {
+ it('should set linkText', function() {
expect(ctrl.linkText).to.be('server-1');
});
@@ -91,16 +100,16 @@ describe("SelectDropdownCtrl", function() {
ctrl.commitChanges();
});
- it("should select tag", function() {
+ it('should select tag', function() {
expect(ctrl.selectedTags.length).to.be(1);
});
- it("should select values", function() {
+ it('should select values', function() {
expect(ctrl.options[0].selected).to.be(true);
expect(ctrl.options[2].selected).to.be(true);
});
- it("link text should not include tag values", function() {
+ it('link text should not include tag values', function() {
expect(ctrl.linkText).to.be('');
});
@@ -111,7 +120,7 @@ describe("SelectDropdownCtrl", function() {
rootScope.$digest();
});
- it("should still have selected tag", function() {
+ it('should still have selected tag', function() {
expect(ctrl.selectedTags.length).to.be(1);
});
});
@@ -122,7 +131,7 @@ describe("SelectDropdownCtrl", function() {
rootScope.$digest();
});
- it("should deselect tag", function() {
+ it('should deselect tag', function() {
expect(ctrl.selectedTags.length).to.be(0);
});
});
@@ -132,36 +141,38 @@ describe("SelectDropdownCtrl", function() {
ctrl.selectValue(ctrl.options[0], {});
});
- it("should deselect tag", function() {
+ it('should deselect tag', function() {
expect(ctrl.selectedTags.length).to.be(0);
});
});
});
});
- describe("Given variable with selected tags", function() {
+ describe('Given variable with selected tags', function() {
beforeEach(function() {
ctrl.variable = {
- current: {text: 'server-1', value: 'server-1', tags: [{text: 'key1', selected: true}] },
+ current: {
+ text: 'server-1',
+ value: 'server-1',
+ tags: [{ text: 'key1', selected: true }],
+ },
options: [
- {text: 'server-1', value: 'server-1'},
- {text: 'server-2', value: 'server-2'},
- {text: 'server-3', value: 'server-3'},
+ { text: 'server-1', value: 'server-1' },
+ { text: 'server-2', value: 'server-2' },
+ { text: 'server-3', value: 'server-3' },
],
- tags: ["key1", "key2", "key3"],
+ tags: ['key1', 'key2', 'key3'],
getValuesForTag: function(key) {
return q.when(tagValuesMap[key]);
},
- multi: true
+ multi: true,
};
ctrl.init();
ctrl.show();
});
- it("should set tag as selected", function() {
+ it('should set tag as selected', function() {
expect(ctrl.tags[0].selected).to.be(true);
});
-
});
});
-
diff --git a/public/app/core/store.ts b/public/app/core/store.ts
index cbed16510ab..b0714f49256 100644
--- a/public/app/core/store.ts
+++ b/public/app/core/store.ts
@@ -1,5 +1,4 @@
export class Store {
-
get(key) {
return window.localStorage[key];
}
@@ -22,7 +21,6 @@ export class Store {
delete(key) {
window.localStorage.removeItem(key);
}
-
}
const store = new Store();
diff --git a/public/app/core/table_model.ts b/public/app/core/table_model.ts
index 6b02e906583..57800b3e48d 100644
--- a/public/app/core/table_model.ts
+++ b/public/app/core/table_model.ts
@@ -1,4 +1,3 @@
-
export default class TableModel {
columns: any[];
rows: any[];
diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts
index 5a242a5abc1..5d9963977de 100644
--- a/public/app/core/time_series2.ts
+++ b/public/app/core/time_series2.ts
@@ -1,9 +1,11 @@
import kbn from 'app/core/utils/kbn';
-import {getFlotTickDecimals} from 'app/core/utils/ticks';
+import { getFlotTickDecimals } from 'app/core/utils/ticks';
import _ from 'lodash';
function matchSeriesOverride(aliasOrRegex, seriesAlias) {
- if (!aliasOrRegex) { return false; }
+ if (!aliasOrRegex) {
+ return false;
+ }
if (aliasOrRegex[0] === '/') {
var regex = kbn.stringToJsRegex(aliasOrRegex);
@@ -14,7 +16,7 @@ function matchSeriesOverride(aliasOrRegex, seriesAlias) {
}
function translateFillOption(fill) {
- return fill === 0 ? 0.001 : fill/10;
+ return fill === 0 ? 0.001 : fill / 10;
}
/**
@@ -27,7 +29,7 @@ export function updateLegendValues(data: TimeSeries[], panel) {
let series = data[i];
let yaxes = panel.yaxes;
let axis = yaxes[series.yaxis - 1];
- let {tickDecimals, scaledDecimals} = getFlotTickDecimals(data, axis);
+ let { tickDecimals, scaledDecimals } = getFlotTickDecimals(data, axis);
let formater = kbn.valueFormats[panel.yaxes[series.yaxis - 1].format];
// decimal override
@@ -56,7 +58,7 @@ export function getDataMinMax(data: TimeSeries[]) {
}
}
- return {datamin, datamax};
+ return { datamin, datamax };
}
export default class TimeSeries {
@@ -106,7 +108,7 @@ export default class TimeSeries {
applySeriesOverrides(overrides) {
this.lines = {};
this.dashes = {
- dashLength: []
+ dashLength: [],
};
this.points = {};
this.bars = {};
@@ -120,29 +122,59 @@ export default class TimeSeries {
if (!matchSeriesOverride(override.alias, this.alias)) {
continue;
}
- if (override.lines !== void 0) { this.lines.show = override.lines; }
+ if (override.lines !== void 0) {
+ this.lines.show = override.lines;
+ }
if (override.dashes !== void 0) {
- this.dashes.show = override.dashes;
- this.lines.lineWidth = 0;
+ this.dashes.show = override.dashes;
+ this.lines.lineWidth = 0;
+ }
+ if (override.points !== void 0) {
+ this.points.show = override.points;
+ }
+ if (override.bars !== void 0) {
+ this.bars.show = override.bars;
+ }
+ if (override.fill !== void 0) {
+ this.lines.fill = translateFillOption(override.fill);
+ }
+ if (override.stack !== void 0) {
+ this.stack = override.stack;
}
- if (override.points !== void 0) { this.points.show = override.points; }
- if (override.bars !== void 0) { this.bars.show = override.bars; }
- if (override.fill !== void 0) { this.lines.fill = translateFillOption(override.fill); }
- if (override.stack !== void 0) { this.stack = override.stack; }
if (override.linewidth !== void 0) {
- this.lines.lineWidth = this.dashes.show ? 0: override.linewidth;
- this.dashes.lineWidth = override.linewidth;
+ this.lines.lineWidth = this.dashes.show ? 0 : override.linewidth;
+ this.dashes.lineWidth = override.linewidth;
+ }
+ if (override.dashLength !== void 0) {
+ this.dashes.dashLength[0] = override.dashLength;
+ }
+ if (override.spaceLength !== void 0) {
+ this.dashes.dashLength[1] = override.spaceLength;
+ }
+ if (override.nullPointMode !== void 0) {
+ this.nullPointMode = override.nullPointMode;
+ }
+ if (override.pointradius !== void 0) {
+ this.points.radius = override.pointradius;
+ }
+ if (override.steppedLine !== void 0) {
+ this.lines.steps = override.steppedLine;
+ }
+ if (override.zindex !== void 0) {
+ this.zindex = override.zindex;
+ }
+ if (override.fillBelowTo !== void 0) {
+ this.fillBelowTo = override.fillBelowTo;
+ }
+ if (override.color !== void 0) {
+ this.color = override.color;
+ }
+ if (override.transform !== void 0) {
+ this.transform = override.transform;
+ }
+ if (override.legend !== void 0) {
+ this.legend = override.legend;
}
- if (override.dashLength !== void 0) { this.dashes.dashLength[0] = override.dashLength; }
- if (override.spaceLength !== void 0) { this.dashes.dashLength[1] = override.spaceLength; }
- if (override.nullPointMode !== void 0) { this.nullPointMode = override.nullPointMode; }
- if (override.pointradius !== void 0) { this.points.radius = override.pointradius; }
- if (override.steppedLine !== void 0) { this.lines.steps = override.steppedLine; }
- if (override.zindex !== void 0) { this.zindex = override.zindex; }
- if (override.fillBelowTo !== void 0) { this.fillBelowTo = override.fillBelowTo; }
- if (override.color !== void 0) { this.color = override.color; }
- if (override.transform !== void 0) { this.transform = override.transform; }
- if (override.legend !== void 0) { this.legend = override.legend; }
if (override.yaxis !== void 0) {
this.yaxis = override.yaxis;
@@ -191,7 +223,9 @@ export default class TimeSeries {
previousTime = currentTime;
if (currentValue === null) {
- if (ignoreNulls) { continue; }
+ if (ignoreNulls) {
+ continue;
+ }
if (nullAsZero) {
currentValue = 0;
}
@@ -215,16 +249,18 @@ export default class TimeSeries {
if (this.stats.first === null) {
this.stats.first = currentValue;
} else {
- if (previousValue > currentValue) { // counter reset
+ if (previousValue > currentValue) {
+ // counter reset
previousDeltaUp = false;
- if (i === this.datapoints.length-1) { // reset on last
- this.stats.delta += currentValue;
+ if (i === this.datapoints.length - 1) {
+ // reset on last
+ this.stats.delta += currentValue;
}
} else {
if (previousDeltaUp) {
- this.stats.delta += currentValue - previousValue; // normal increment
+ this.stats.delta += currentValue - previousValue; // normal increment
} else {
- this.stats.delta += currentValue; // account for counter reset
+ this.stats.delta += currentValue; // account for counter reset
}
previousDeltaUp = true;
}
@@ -243,14 +279,18 @@ export default class TimeSeries {
result.push([currentTime, currentValue]);
}
- if (this.stats.max === -Number.MAX_VALUE) { this.stats.max = null; }
- if (this.stats.min === Number.MAX_VALUE) { this.stats.min = null; }
+ if (this.stats.max === -Number.MAX_VALUE) {
+ this.stats.max = null;
+ }
+ if (this.stats.min === Number.MAX_VALUE) {
+ this.stats.min = null;
+ }
if (result.length && !this.allIsNull) {
- this.stats.avg = (this.stats.total / nonNulls);
- this.stats.current = result[result.length-1][1];
+ this.stats.avg = this.stats.total / nonNulls;
+ this.stats.current = result[result.length - 1][1];
if (this.stats.current === null && result.length > 1) {
- this.stats.current = result[result.length-2][1];
+ this.stats.current = result[result.length - 2][1];
}
}
if (this.stats.max !== null && this.stats.min !== null) {
@@ -281,7 +321,7 @@ export default class TimeSeries {
for (var i = 0; i < this.datapoints.length; i++) {
if (this.datapoints[i][1] !== null) {
var timestamp = this.datapoints[i][1].toString();
- if (timestamp.length === 13 && (timestamp % 1000) !== 0) {
+ if (timestamp.length === 13 && timestamp % 1000 !== 0) {
return true;
}
}
diff --git a/public/app/core/utils/colors.ts b/public/app/core/utils/colors.ts
index a38c92a6476..8a70e093ea2 100644
--- a/public/app/core/utils/colors.ts
+++ b/public/app/core/utils/colors.ts
@@ -4,19 +4,68 @@ import tinycolor from 'tinycolor2';
export const PALETTE_ROWS = 4;
export const PALETTE_COLUMNS = 14;
export const DEFAULT_ANNOTATION_COLOR = 'rgba(0, 211, 255, 1)';
-export const OK_COLOR = "rgba(11, 237, 50, 1)";
-export const ALERTING_COLOR = "rgba(237, 46, 24, 1)";
-export const NO_DATA_COLOR = "rgba(150, 150, 150, 1)";
+export const OK_COLOR = 'rgba(11, 237, 50, 1)';
+export const ALERTING_COLOR = 'rgba(237, 46, 24, 1)';
+export const NO_DATA_COLOR = 'rgba(150, 150, 150, 1)';
export const REGION_FILL_ALPHA = 0.09;
let colors = [
- "#7EB26D","#EAB839","#6ED0E0","#EF843C","#E24D42","#1F78C1","#BA43A9","#705DA0",
- "#508642","#CCA300","#447EBC","#C15C17","#890F02","#0A437C","#6D1F62","#584477",
- "#B7DBAB","#F4D598","#70DBED","#F9BA8F","#F29191","#82B5D8","#E5A8E2","#AEA2E0",
- "#629E51","#E5AC0E","#64B0C8","#E0752D","#BF1B00","#0A50A1","#962D82","#614D93",
- "#9AC48A","#F2C96D","#65C5DB","#F9934E","#EA6460","#5195CE","#D683CE","#806EB7",
- "#3F6833","#967302","#2F575E","#99440A","#58140C","#052B51","#511749","#3F2B5B",
- "#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7"
+ '#7EB26D',
+ '#EAB839',
+ '#6ED0E0',
+ '#EF843C',
+ '#E24D42',
+ '#1F78C1',
+ '#BA43A9',
+ '#705DA0',
+ '#508642',
+ '#CCA300',
+ '#447EBC',
+ '#C15C17',
+ '#890F02',
+ '#0A437C',
+ '#6D1F62',
+ '#584477',
+ '#B7DBAB',
+ '#F4D598',
+ '#70DBED',
+ '#F9BA8F',
+ '#F29191',
+ '#82B5D8',
+ '#E5A8E2',
+ '#AEA2E0',
+ '#629E51',
+ '#E5AC0E',
+ '#64B0C8',
+ '#E0752D',
+ '#BF1B00',
+ '#0A50A1',
+ '#962D82',
+ '#614D93',
+ '#9AC48A',
+ '#F2C96D',
+ '#65C5DB',
+ '#F9934E',
+ '#EA6460',
+ '#5195CE',
+ '#D683CE',
+ '#806EB7',
+ '#3F6833',
+ '#967302',
+ '#2F575E',
+ '#99440A',
+ '#58140C',
+ '#052B51',
+ '#511749',
+ '#3F2B5B',
+ '#E0F9D7',
+ '#FCEACA',
+ '#CFFAFF',
+ '#F9E2D2',
+ '#FCE2DE',
+ '#BADFF4',
+ '#F9D9F9',
+ '#DEDAF7',
];
export function sortColorsByHue(hexColors) {
diff --git a/public/app/core/utils/css_loader.ts b/public/app/core/utils/css_loader.ts
index e81e659032d..4ff03ec3c97 100644
--- a/public/app/core/utils/css_loader.ts
+++ b/public/app/core/utils/css_loader.ts
@@ -49,7 +49,9 @@ var loadCSS = function(url) {
link.href = url;
if (!isWebkit) {
- link.onload = function() { _callback(undefined); };
+ link.onload = function() {
+ _callback(undefined);
+ };
} else {
webkitLoadCheck(link, _callback);
}
@@ -75,4 +77,3 @@ export function fetch(load): any {
}
return loadCSS(load.address);
}
-
diff --git a/public/app/core/utils/datemath.ts b/public/app/core/utils/datemath.ts
index f5608443f49..b892d49f2d8 100644
--- a/public/app/core/utils/datemath.ts
+++ b/public/app/core/utils/datemath.ts
@@ -6,9 +6,15 @@ import moment from 'moment';
var units = ['y', 'M', 'w', 'd', 'h', 'm', 's'];
export function parse(text, roundUp?, timezone?) {
- if (!text) { return undefined; }
- if (moment.isMoment(text)) { return text; }
- if (_.isDate(text)) { return moment(text); }
+ if (!text) {
+ return undefined;
+ }
+ if (moment.isMoment(text)) {
+ return text;
+ }
+ if (_.isDate(text)) {
+ return moment(text);
+ }
var time;
var mathString = '';
@@ -84,7 +90,9 @@ export function parseDateMath(mathString, time, roundUp?) {
var numFrom = i;
while (!isNaN(mathString.charAt(i))) {
i++;
- if (i > 10) { return undefined; }
+ if (i > 10) {
+ return undefined;
+ }
}
num = parseInt(mathString.substring(numFrom, i), 10);
}
@@ -115,4 +123,3 @@ export function parseDateMath(mathString, time, roundUp?) {
}
return dateTime;
}
-
diff --git a/public/app/core/utils/file_export.ts b/public/app/core/utils/file_export.ts
index 03fcd147a3e..adbda50d829 100644
--- a/public/app/core/utils/file_export.ts
+++ b/public/app/core/utils/file_export.ts
@@ -1,72 +1,86 @@
import _ from 'lodash';
import moment from 'moment';
-import {saveAs} from 'file-saver';
+import { saveAs } from 'file-saver';
const DEFAULT_DATETIME_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ';
-export function exportSeriesListToCsv(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT, excel = false) {
- var text = (excel ? 'sep=;\n' : '') + 'Series;Time;Value\n';
- _.each(seriesList, function(series) {
- _.each(series.datapoints, function(dp) {
- text += series.alias + ';' + moment(dp[1]).format(dateTimeFormat) + ';' + dp[0] + '\n';
- });
+export function exportSeriesListToCsv(
+ seriesList,
+ dateTimeFormat = DEFAULT_DATETIME_FORMAT,
+ excel = false
+) {
+ var text = (excel ? 'sep=;\n' : '') + 'Series;Time;Value\n';
+ _.each(seriesList, function(series) {
+ _.each(series.datapoints, function(dp) {
+ text +=
+ series.alias +
+ ';' +
+ moment(dp[1]).format(dateTimeFormat) +
+ ';' +
+ dp[0] +
+ '\n';
});
- saveSaveBlob(text, 'grafana_data_export.csv');
+ });
+ saveSaveBlob(text, 'grafana_data_export.csv');
}
-export function exportSeriesListToCsvColumns(seriesList, dateTimeFormat = DEFAULT_DATETIME_FORMAT, excel = false) {
- var text = (excel ? 'sep=;\n' : '') + 'Time;';
- // add header
- _.each(seriesList, function(series) {
- text += series.alias + ';';
- });
- text = text.substring(0,text.length-1);
- text += '\n';
+export function exportSeriesListToCsvColumns(
+ seriesList,
+ dateTimeFormat = DEFAULT_DATETIME_FORMAT,
+ excel = false
+) {
+ var text = (excel ? 'sep=;\n' : '') + 'Time;';
+ // add header
+ _.each(seriesList, function(series) {
+ text += series.alias + ';';
+ });
+ text = text.substring(0, text.length - 1);
+ text += '\n';
- // process data
- var dataArr = [[]];
- var sIndex = 1;
- _.each(seriesList, function(series) {
- var cIndex = 0;
- dataArr.push([]);
- _.each(series.datapoints, function(dp) {
- dataArr[0][cIndex] = moment(dp[1]).format(dateTimeFormat);
- dataArr[sIndex][cIndex] = dp[0];
- cIndex++;
- });
- sIndex++;
+ // process data
+ var dataArr = [[]];
+ var sIndex = 1;
+ _.each(seriesList, function(series) {
+ var cIndex = 0;
+ dataArr.push([]);
+ _.each(series.datapoints, function(dp) {
+ dataArr[0][cIndex] = moment(dp[1]).format(dateTimeFormat);
+ dataArr[sIndex][cIndex] = dp[0];
+ cIndex++;
});
+ sIndex++;
+ });
- // make text
- for (var i = 0; i < dataArr[0].length; i++) {
- text += dataArr[0][i] + ';';
- for (var j = 1; j < dataArr.length; j++) {
- text += dataArr[j][i] + ';';
- }
- text = text.substring(0,text.length-1);
- text += '\n';
+ // make text
+ for (var i = 0; i < dataArr[0].length; i++) {
+ text += dataArr[0][i] + ';';
+ for (var j = 1; j < dataArr.length; j++) {
+ text += dataArr[j][i] + ';';
}
- saveSaveBlob(text, 'grafana_data_export.csv');
+ text = text.substring(0, text.length - 1);
+ text += '\n';
+ }
+ saveSaveBlob(text, 'grafana_data_export.csv');
}
export function exportTableDataToCsv(table, excel = false) {
var text = excel ? 'sep=;\n' : '';
- // add header
- _.each(table.columns, function(column) {
- text += (column.title || column.text) + ';';
+ // add header
+ _.each(table.columns, function(column) {
+ text += (column.title || column.text) + ';';
+ });
+ text += '\n';
+ // process data
+ _.each(table.rows, function(row) {
+ _.each(row, function(value) {
+ text += value + ';';
});
text += '\n';
- // process data
- _.each(table.rows, function(row) {
- _.each(row, function(value) {
- text += value + ';';
- });
- text += '\n';
- });
- saveSaveBlob(text, 'grafana_data_export.csv');
+ });
+ saveSaveBlob(text, 'grafana_data_export.csv');
}
export function saveSaveBlob(payload, fname) {
- var blob = new Blob([payload], { type: "text/csv;charset=utf-8" });
- saveAs(blob, fname);
+ var blob = new Blob([payload], { type: 'text/csv;charset=utf-8' });
+ saveAs(blob, fname);
}
diff --git a/public/app/core/utils/flatten.ts b/public/app/core/utils/flatten.ts
index 927fbf34b78..66455cd0871 100644
--- a/public/app/core/utils/flatten.ts
+++ b/public/app/core/utils/flatten.ts
@@ -14,7 +14,7 @@ export default function flatten(target, opts): any {
var value = object[key];
var isarray = opts.safe && Array.isArray(value);
var type = Object.prototype.toString.call(value);
- var isobject = type === "[object Object]";
+ var isobject = type === '[object Object]';
var newKey = prev ? prev + delimiter + key : key;
@@ -22,7 +22,12 @@ export default function flatten(target, opts): any {
maxDepth = currentDepth + 1;
}
- if (!isarray && isobject && Object.keys(value).length && currentDepth < maxDepth) {
+ if (
+ !isarray &&
+ isobject &&
+ Object.keys(value).length &&
+ currentDepth < maxDepth
+ ) {
++currentDepth;
return step(value, newKey);
}
diff --git a/public/app/core/utils/kbn.ts b/public/app/core/utils/kbn.ts
index b0715502114..d4111139a30 100644
--- a/public/app/core/utils/kbn.ts
+++ b/public/app/core/utils/kbn.ts
@@ -168,7 +168,9 @@ kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
lowLimitMs = kbn.interval_to_ms(lowLimitInterval);
}
- intervalMs = kbn.round_interval((range.to.valueOf() - range.from.valueOf()) / resolution);
+ intervalMs = kbn.round_interval(
+ (range.to.valueOf() - range.from.valueOf()) / resolution
+ );
if (lowLimitMs > intervalMs) {
intervalMs = lowLimitMs;
}
@@ -182,7 +184,9 @@ kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
kbn.describe_interval = function(str) {
var matches = str.match(kbn.interval_regex);
if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
- throw new Error('Invalid interval string, expecting a number followed by one of "Mwdhmsy"');
+ throw new Error(
+ 'Invalid interval string, expecting a number followed by one of "Mwdhmsy"'
+ );
} else {
return {
sec: kbn.intervals_in_seconds[matches[2]],
@@ -205,7 +209,11 @@ kbn.interval_to_seconds = function(str) {
kbn.query_color_dot = function(color, diameter) {
return (
''
);
};
@@ -245,14 +253,23 @@ kbn.toFixed = function(value, decimals) {
var decimalPos = formatted.indexOf('.');
var precision = decimalPos === -1 ? 0 : formatted.length - decimalPos - 1;
if (precision < decimals) {
- return (precision ? formatted : formatted + '.') + String(factor).substr(1, decimals - precision);
+ return (
+ (precision ? formatted : formatted + '.') +
+ String(factor).substr(1, decimals - precision)
+ );
}
}
return formatted;
};
-kbn.toFixedScaled = function(value, decimals, scaledDecimals, additionalDecimals, ext) {
+kbn.toFixedScaled = function(
+ value,
+ decimals,
+ scaledDecimals,
+ additionalDecimals,
+ ext
+) {
if (scaledDecimals === null) {
return kbn.toFixed(value, decimals) + ext;
} else {
@@ -329,7 +346,9 @@ kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
// offset is given, it starts the units at the given prefix; otherwise, the
// offset defaults to zero and the initial unit is not prefixed.
kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
- var prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'].slice(offset);
+ var prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'].slice(
+ offset
+ );
var units = prefixes.map(function(p) {
return ' ' + p + unit;
});
@@ -506,7 +525,11 @@ kbn.valueFormats.pressurembar = kbn.formatBuilders.decimalSIPrefix('bar', -1);
kbn.valueFormats.pressurekbar = kbn.formatBuilders.decimalSIPrefix('bar', 1);
kbn.valueFormats.pressurehpa = kbn.formatBuilders.fixedUnit('hPa');
kbn.valueFormats.pressurehg = kbn.formatBuilders.fixedUnit('"Hg');
-kbn.valueFormats.pressurepsi = kbn.formatBuilders.scaledUnits(1000, [' psi', ' ksi', ' Mpsi']);
+kbn.valueFormats.pressurepsi = kbn.formatBuilders.scaledUnits(1000, [
+ ' psi',
+ ' ksi',
+ ' Mpsi',
+]);
// Force
kbn.valueFormats.forceNm = kbn.formatBuilders.decimalSIPrefix('Nm');
@@ -541,7 +564,7 @@ kbn.valueFormats.velocityknot = kbn.formatBuilders.fixedUnit('kn');
// Acceleration
kbn.valueFormats.accMS2 = kbn.formatBuilders.fixedUnit('m/sec²');
kbn.valueFormats.accFS2 = kbn.formatBuilders.fixedUnit('f/sec²');
-kbn.valueFormats.accG = kbn.formatBuilders.fixedUnit('g');
+kbn.valueFormats.accG = kbn.formatBuilders.fixedUnit('g');
// Volume
kbn.valueFormats.litre = kbn.formatBuilders.decimalSIPrefix('L');
@@ -557,9 +580,9 @@ kbn.valueFormats.flowcfs = kbn.formatBuilders.fixedUnit('cfs');
kbn.valueFormats.flowcfm = kbn.formatBuilders.fixedUnit('cfm');
// Angle
-kbn.valueFormats.degree = kbn.formatBuilders.fixedUnit('°');
-kbn.valueFormats.radian = kbn.formatBuilders.fixedUnit('rad');
-kbn.valueFormats.grad = kbn.formatBuilders.fixedUnit('grad');
+kbn.valueFormats.degree = kbn.formatBuilders.fixedUnit('°');
+kbn.valueFormats.radian = kbn.formatBuilders.fixedUnit('rad');
+kbn.valueFormats.grad = kbn.formatBuilders.fixedUnit('grad');
// Time
kbn.valueFormats.hertz = kbn.formatBuilders.decimalSIPrefix('Hz');
@@ -579,13 +602,31 @@ kbn.valueFormats.ms = function(size, decimals, scaledDecimals) {
return kbn.toFixedScaled(size / 60000, decimals, scaledDecimals, 5, ' min');
} else if (Math.abs(size) < 86400000) {
// Less than one day, devide in hours
- return kbn.toFixedScaled(size / 3600000, decimals, scaledDecimals, 7, ' hour');
+ return kbn.toFixedScaled(
+ size / 3600000,
+ decimals,
+ scaledDecimals,
+ 7,
+ ' hour'
+ );
} else if (Math.abs(size) < 31536000000) {
// Less than one year, devide in days
- return kbn.toFixedScaled(size / 86400000, decimals, scaledDecimals, 8, ' day');
+ return kbn.toFixedScaled(
+ size / 86400000,
+ decimals,
+ scaledDecimals,
+ 8,
+ ' day'
+ );
}
- return kbn.toFixedScaled(size / 31536000000, decimals, scaledDecimals, 10, ' year');
+ return kbn.toFixedScaled(
+ size / 31536000000,
+ decimals,
+ scaledDecimals,
+ 10,
+ ' year'
+ );
};
kbn.valueFormats.s = function(size, decimals, scaledDecimals) {
@@ -595,15 +636,33 @@ kbn.valueFormats.s = function(size, decimals, scaledDecimals) {
// Less than 1 µs, devide in ns
if (Math.abs(size) < 0.000001) {
- return kbn.toFixedScaled(size * 1e9, decimals, scaledDecimals - decimals, -9, ' ns');
+ return kbn.toFixedScaled(
+ size * 1e9,
+ decimals,
+ scaledDecimals - decimals,
+ -9,
+ ' ns'
+ );
}
// Less than 1 ms, devide in µs
if (Math.abs(size) < 0.001) {
- return kbn.toFixedScaled(size * 1e6, decimals, scaledDecimals - decimals, -6, ' µs');
+ return kbn.toFixedScaled(
+ size * 1e6,
+ decimals,
+ scaledDecimals - decimals,
+ -6,
+ ' µs'
+ );
}
// Less than 1 second, devide in ms
if (Math.abs(size) < 1) {
- return kbn.toFixedScaled(size * 1e3, decimals, scaledDecimals - decimals, -3, ' ms');
+ return kbn.toFixedScaled(
+ size * 1e3,
+ decimals,
+ scaledDecimals - decimals,
+ -3,
+ ' ms'
+ );
}
if (Math.abs(size) < 60) {
@@ -619,10 +678,22 @@ kbn.valueFormats.s = function(size, decimals, scaledDecimals) {
return kbn.toFixedScaled(size / 86400, decimals, scaledDecimals, 5, ' day');
} else if (Math.abs(size) < 31536000) {
// Less than one year, devide in week
- return kbn.toFixedScaled(size / 604800, decimals, scaledDecimals, 6, ' week');
+ return kbn.toFixedScaled(
+ size / 604800,
+ decimals,
+ scaledDecimals,
+ 6,
+ ' week'
+ );
}
- return kbn.toFixedScaled(size / 3.15569e7, decimals, scaledDecimals, 7, ' year');
+ return kbn.toFixedScaled(
+ size / 3.15569e7,
+ decimals,
+ scaledDecimals,
+ 7,
+ ' year'
+ );
};
kbn.valueFormats['µs'] = function(size, decimals, scaledDecimals) {
@@ -649,11 +720,29 @@ kbn.valueFormats.ns = function(size, decimals, scaledDecimals) {
} else if (Math.abs(size) < 1000000) {
return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, ' µs');
} else if (Math.abs(size) < 1000000000) {
- return kbn.toFixedScaled(size / 1000000, decimals, scaledDecimals, 6, ' ms');
+ return kbn.toFixedScaled(
+ size / 1000000,
+ decimals,
+ scaledDecimals,
+ 6,
+ ' ms'
+ );
} else if (Math.abs(size) < 60000000000) {
- return kbn.toFixedScaled(size / 1000000000, decimals, scaledDecimals, 9, ' s');
+ return kbn.toFixedScaled(
+ size / 1000000000,
+ decimals,
+ scaledDecimals,
+ 9,
+ ' s'
+ );
} else {
- return kbn.toFixedScaled(size / 60000000000, decimals, scaledDecimals, 12, ' min');
+ return kbn.toFixedScaled(
+ size / 60000000000,
+ decimals,
+ scaledDecimals,
+ 12,
+ ' min'
+ );
}
};
@@ -669,9 +758,21 @@ kbn.valueFormats.m = function(size, decimals, scaledDecimals) {
} else if (Math.abs(size) < 10080) {
return kbn.toFixedScaled(size / 1440, decimals, scaledDecimals, 3, ' day');
} else if (Math.abs(size) < 604800) {
- return kbn.toFixedScaled(size / 10080, decimals, scaledDecimals, 4, ' week');
+ return kbn.toFixedScaled(
+ size / 10080,
+ decimals,
+ scaledDecimals,
+ 4,
+ ' week'
+ );
} else {
- return kbn.toFixedScaled(size / 5.25948e5, decimals, scaledDecimals, 5, ' year');
+ return kbn.toFixedScaled(
+ size / 5.25948e5,
+ decimals,
+ scaledDecimals,
+ 5,
+ ' year'
+ );
}
};
@@ -902,10 +1003,10 @@ kbn.getUnitFormats = function() {
{
text: 'area',
submenu: [
- {text: 'Square Meters (m²)', value: 'areaM2' },
- {text: 'Square Feet (ft²)', value: 'areaF2' },
- {text: 'Square Miles (mi²)', value: 'areaMI2'},
- ]
+ { text: 'Square Meters (m²)', value: 'areaM2' },
+ { text: 'Square Feet (ft²)', value: 'areaF2' },
+ { text: 'Square Miles (mi²)', value: 'areaMI2' },
+ ],
},
{
text: 'mass',
@@ -957,7 +1058,7 @@ kbn.getUnitFormats = function() {
{ text: 'Kilovolt (kV)', value: 'kvolt' },
{ text: 'Millivolt (mV)', value: 'mvolt' },
{ text: 'Decibel-milliwatt (dBm)', value: 'dBm' },
- { text: 'Ohm (Ω)', value: 'ohm' }
+ { text: 'Ohm (Ω)', value: 'ohm' },
],
},
{
@@ -1002,17 +1103,17 @@ kbn.getUnitFormats = function() {
submenu: [
{ text: 'Degrees (°)', value: 'degree' },
{ text: 'Radians', value: 'radian' },
- { text: 'Gradian', value: 'grad' }
- ]
+ { text: 'Gradian', value: 'grad' },
+ ],
},
{
text: 'acceleration',
submenu: [
{ text: 'Meters/sec²', value: 'accMS2' },
- { text: 'Feet/sec²', value: 'accFS2' },
- { text: 'G unit', value: 'accG' }
- ]
- }
+ { text: 'Feet/sec²', value: 'accFS2' },
+ { text: 'G unit', value: 'accG' },
+ ],
+ },
];
};
diff --git a/public/app/core/utils/model_utils.ts b/public/app/core/utils/model_utils.ts
index dd620aff53d..e2984aa7484 100644
--- a/public/app/core/utils/model_utils.ts
+++ b/public/app/core/utils/model_utils.ts
@@ -1,4 +1,9 @@
-export function assignModelProperties(target, source, defaults, removeDefaults?) {
+export function assignModelProperties(
+ target,
+ source,
+ defaults,
+ removeDefaults?
+) {
for (var key in defaults) {
if (!defaults.hasOwnProperty(key)) {
continue;
@@ -7,4 +12,3 @@ export function assignModelProperties(target, source, defaults, removeDefaults?)
target[key] = source[key] === undefined ? defaults[key] : source[key];
}
}
-
diff --git a/public/app/core/utils/outline.ts b/public/app/core/utils/outline.ts
index 109d13d9fc9..dafe0b12914 100644
--- a/public/app/core/utils/outline.ts
+++ b/public/app/core/utils/outline.ts
@@ -5,7 +5,7 @@ function outlineFixer() {
var style_element = d.createElement('STYLE');
var dom_events = 'addEventListener' in d;
- var add_event_listener = function (type, callback) {
+ var add_event_listener = function(type, callback) {
// Basic cross-browser event handling
if (dom_events) {
d.addEventListener(type, callback);
@@ -14,19 +14,21 @@ function outlineFixer() {
}
};
- var set_css = function (css_text) {
+ var set_css = function(css_text) {
// Handle setting of