" +
+ '>' +
'
" +
+ '' +
'
';
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 label =
- '
";
+ 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 ul = [
- '"
- ];
+ var upclass = placement === 'top' ? 'dropup' : '';
+ var ul = [''];
for (let index = 0; index < items.length; index++) {
let item = items[index];
@@ -171,26 +159,24 @@ function gfDropdown($parse, $compile, $timeout) {
}
var li =
- "";
+ li += '';
ul.splice(index + 1, 0, li);
}
@@ -198,29 +184,27 @@ 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 dropdown = angular.element(
- buildTemplate(items, placement).join("")
- );
+ var placement = iElement.data('placement');
+ var dropdown = angular.element(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 3061b1f1aa0..4385c72f1b0 100644
--- a/public/app/core/directives/ng_model_on_blur.ts
+++ b/public/app/core/directives/ng_model_on_blur.ts
@@ -1,59 +1,59 @@
-import coreModule from "../core_module";
-import * as rangeUtil from "app/core/utils/rangeutil";
+import coreModule from '../core_module';
+import * as rangeUtil from 'app/core/utils/rangeutil';
function ngModelOnBlur() {
return {
- restrict: "A",
+ restrict: 'A',
priority: 1,
- require: "ngModel",
+ require: 'ngModel',
link: function(scope, elm, attr, ngModelCtrl) {
- if (attr.type === "radio" || attr.type === "checkbox") {
+ if (attr.type === 'radio' || attr.type === 'checkbox') {
return;
}
- elm.off("input keydown change");
- elm.bind("blur", function() {
+ elm.off('input keydown change');
+ elm.bind('blur', function() {
scope.$apply(function() {
ngModelCtrl.$setViewValue(elm.val());
});
});
- }
+ },
};
}
function emptyToNull() {
return {
- restrict: "A",
- require: "ngModel",
+ restrict: 'A',
+ require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
ctrl.$parsers.push(function(viewValue) {
- if (viewValue === "") {
+ if (viewValue === '') {
return null;
}
return viewValue;
});
- }
+ },
};
}
function validTimeSpan() {
return {
- require: "ngModel",
+ require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
ctrl.$validators.integer = function(modelValue, viewValue) {
if (ctrl.$isEmpty(modelValue)) {
return true;
}
- if (viewValue.indexOf("$") === 0 || viewValue.indexOf("+$") === 0) {
+ if (viewValue.indexOf('$') === 0 || viewValue.indexOf('+$') === 0) {
return true; // allow template variable
}
var info = rangeUtil.describeTextRange(viewValue);
return info.invalid !== true;
};
- }
+ },
};
}
-coreModule.directive("ngModelOnblur", ngModelOnBlur);
-coreModule.directive("emptyToNull", emptyToNull);
-coreModule.directive("validTimeSpan", validTimeSpan);
+coreModule.directive('ngModelOnblur', ngModelOnBlur);
+coreModule.directive('emptyToNull', emptyToNull);
+coreModule.directive('validTimeSpan', validTimeSpan);
diff --git a/public/app/core/directives/rebuild_on_change.ts b/public/app/core/directives/rebuild_on_change.ts
index 7c3f9096f6a..15907dc6c19 100644
--- a/public/app/core/directives/rebuild_on_change.ts
+++ b/public/app/core/directives/rebuild_on_change.ts
@@ -1,5 +1,5 @@
-import $ from "jquery";
-import coreModule from "../core_module";
+import $ from 'jquery';
+import coreModule from '../core_module';
function getBlockNodes(nodes) {
var node = nodes[0];
@@ -25,7 +25,7 @@ function rebuildOnChange($animate) {
terminal: true,
transclude: true,
priority: 600,
- restrict: "E",
+ restrict: 'E',
link: function(scope, elem, attrs, ctrl, transclude) {
var block, childScope, previousElements;
@@ -47,10 +47,7 @@ function rebuildOnChange($animate) {
}
}
- scope.$watch(attrs.property, function rebuildOnChangeAction(
- value,
- oldValue
- ) {
+ scope.$watch(attrs.property, function rebuildOnChangeAction(value, oldValue) {
if (childScope && value !== oldValue) {
cleanUp();
}
@@ -58,9 +55,7 @@ function rebuildOnChange($animate) {
if (!childScope && (value || attrs.showNull)) {
transclude(function(clone, newScope) {
childScope = newScope;
- clone[clone.length++] = document.createComment(
- " end rebuild on change "
- );
+ clone[clone.length++] = document.createComment(' end rebuild on change ');
block = { clone: clone };
$animate.enter(clone, elem.parent(), elem);
});
@@ -68,8 +63,8 @@ function rebuildOnChange($animate) {
cleanUp();
}
});
- }
+ },
};
}
-coreModule.directive("rebuildOnChange", rebuildOnChange);
+coreModule.directive('rebuildOnChange', rebuildOnChange);
diff --git a/public/app/core/directives/tags.ts b/public/app/core/directives/tags.ts
index 4cddf3c6027..b5020b71fc7 100644
--- a/public/app/core/directives/tags.ts
+++ b/public/app/core/directives/tags.ts
@@ -1,7 +1,7 @@
-import angular from "angular";
-import $ from "jquery";
-import coreModule from "../core_module";
-import "vendor/tagsinput/bootstrap-tagsinput.js";
+import angular from 'angular';
+import $ from 'jquery';
+import coreModule from '../core_module';
+import 'vendor/tagsinput/bootstrap-tagsinput.js';
function djb2(str) {
var hash = 5381;
@@ -14,79 +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: "=" },
+ scope: { tagColorFromName: '=' },
link: function(scope, element) {
setColor(scope.tagColorFromName, element);
- }
+ },
};
}
@@ -106,29 +106,29 @@ function bootstrapTagsinput() {
}
return {
- restrict: "EA",
+ restrict: 'EA',
scope: {
- model: "=ngModel",
- onTagsUpdated: "&"
+ model: '=ngModel',
+ onTagsUpdated: '&',
},
- template: "
",
+ template: '
',
replace: false,
link: function(scope, element, attrs) {
if (!angular.isArray(scope.model)) {
scope.model = [];
}
- var select = $("select", element);
+ var select = $('select', element);
if (attrs.placeholder) {
- select.attr("placeholder", attrs.placeholder);
+ select.attr('placeholder', attrs.placeholder);
}
select.tagsinput({
typeahead: {
source: angular.isFunction(scope.$parent[attrs.typeaheadSource])
? scope.$parent[attrs.typeaheadSource]
- : null
+ : null,
},
widthClass: attrs.widthClass,
itemValue: getItemProperty(scope, attrs.itemvalue),
@@ -137,10 +137,10 @@ function bootstrapTagsinput() {
? scope.$parent[attrs.tagclass]
: function() {
return attrs.tagclass;
- }
+ },
});
- select.on("itemAdded", function(event) {
+ select.on('itemAdded', function(event) {
if (scope.model.indexOf(event.item) === -1) {
scope.model.push(event.item);
if (scope.onTagsUpdated) {
@@ -149,14 +149,14 @@ function bootstrapTagsinput() {
}
var tagElement = select
.next()
- .children("span")
+ .children('span')
.filter(function() {
return $(this).text() === event.item;
});
setColor(event.item, tagElement);
});
- select.on("itemRemoved", function(event) {
+ select.on('itemRemoved', function(event) {
var idx = scope.model.indexOf(event.item);
if (idx !== -1) {
scope.model.splice(idx, 1);
@@ -167,23 +167,23 @@ function bootstrapTagsinput() {
});
scope.$watch(
- "model",
+ '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]);
+ select.tagsinput('add', scope.model[i]);
}
},
true
);
- }
+ },
};
}
-coreModule.directive("tagColorFromName", tagColorFromName);
-coreModule.directive("bootstrapTagsinput", bootstrapTagsinput);
+coreModule.directive('tagColorFromName', tagColorFromName);
+coreModule.directive('bootstrapTagsinput', bootstrapTagsinput);
diff --git a/public/app/core/filters/filters.ts b/public/app/core/filters/filters.ts
index ca73aea3ace..1556e0a94f5 100644
--- a/public/app/core/filters/filters.ts
+++ b/public/app/core/filters/filters.ts
@@ -1,17 +1,17 @@
///
-import _ from "lodash";
-import angular from "angular";
-import moment from "moment";
-import coreModule from "../core_module";
+import _ from 'lodash';
+import angular from 'angular';
+import moment from 'moment';
+import coreModule from '../core_module';
-coreModule.filter("stringSort", function() {
+coreModule.filter('stringSort', function() {
return function(input) {
return input.sort();
};
});
-coreModule.filter("slice", function() {
+coreModule.filter('slice', function() {
return function(arr, start, end) {
if (!_.isUndefined(arr)) {
return arr.slice(start, end);
@@ -19,7 +19,7 @@ coreModule.filter("slice", function() {
};
});
-coreModule.filter("stringify", function() {
+coreModule.filter('stringify', function() {
return function(arr) {
if (_.isObject(arr) && !_.isArray(arr)) {
return angular.toJson(arr);
@@ -29,25 +29,25 @@ coreModule.filter("stringify", function() {
};
});
-coreModule.filter("moment", function() {
+coreModule.filter('moment', function() {
return function(date, mode) {
switch (mode) {
- case "ago":
+ case 'ago':
return moment(date).fromNow();
}
return moment(date).fromNow();
};
});
-coreModule.filter("noXml", function() {
+coreModule.filter('noXml', function() {
var noXml = function(text) {
return _.isString(text)
? text
- .replace(/&/g, "&")
- .replace(//g, ">")
- .replace(/'/g, "'")
- .replace(/"/g, """)
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/'/g, ''')
+ .replace(/"/g, '"')
: text;
};
return function(text) {
@@ -72,5 +72,5 @@ function interpolateTemplateVars(templateSrv) {
return filterFunc;
}
-coreModule.filter("interpolateTemplateVars", interpolateTemplateVars);
+coreModule.filter('interpolateTemplateVars', interpolateTemplateVars);
export default {};
diff --git a/public/app/core/live/live_srv.ts b/public/app/core/live/live_srv.ts
index 9b937c95e4b..e03e8296794 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 _ from 'lodash';
+import config from 'app/core/config';
-import { Observable } from "rxjs/Observable";
+import { Observable } from 'rxjs/Observable';
export class LiveSrv {
conn: any;
@@ -14,12 +14,7 @@ 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() {
@@ -32,12 +27,12 @@ export class LiveSrv {
}
this.initPromise = new Promise((resolve, reject) => {
- console.log("Live: connecting...");
+ console.log('Live: connecting...');
this.conn = new WebSocket(this.getWebSocketUrl());
this.conn.onclose = evt => {
- console.log("Live: websocket onclose", evt);
- reject({ message: "Connection closed" });
+ console.log('Live: websocket onclose', evt);
+ reject({ message: 'Connection closed' });
this.initPromise = null;
setTimeout(this.reconnect.bind(this), 2000);
@@ -49,12 +44,12 @@ export class LiveSrv {
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 => {
- console.log("opened");
+ console.log('opened');
this.initPromise = null;
resolve(this.conn);
};
@@ -67,7 +62,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;
}
@@ -86,11 +81,11 @@ export class LiveSrv {
return;
}
- console.log("LiveSrv: Reconnecting");
+ console.log('LiveSrv: Reconnecting');
this.getConnection().then(conn => {
_.each(this.observers, (value, key) => {
- this.send({ action: "subscribe", stream: key });
+ this.send({ action: 'subscribe', stream: key });
});
});
}
@@ -103,21 +98,21 @@ export class LiveSrv {
this.observers[stream] = observer;
this.getConnection().then(conn => {
- this.send({ action: "subscribe", stream: stream });
+ this.send({ action: 'subscribe', stream: stream });
});
}
removeObserver(stream, observer) {
- console.log("unsubscribe", stream);
+ console.log('unsubscribe', stream);
delete this.observers[stream];
this.getConnection().then(conn => {
- this.send({ action: "unsubscribe", stream: stream });
+ this.send({ action: 'unsubscribe', stream: stream });
});
}
subscribe(streamName) {
- console.log("LiveSrv.subscribe: " + streamName);
+ console.log('LiveSrv.subscribe: ' + streamName);
return Observable.create(observer => {
this.addObserver(streamName, observer);
diff --git a/public/app/core/mod_defs.d.ts b/public/app/core/mod_defs.d.ts
index 1e845f35454..d5b2e6c2a8a 100644
--- a/public/app/core/mod_defs.d.ts
+++ b/public/app/core/mod_defs.d.ts
@@ -1,14 +1,14 @@
-declare module "app/core/controllers/all" {
+declare module 'app/core/controllers/all' {
let json: any;
export { json };
}
-declare module "app/core/routes/all" {
+declare module 'app/core/routes/all' {
let json: any;
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 b1631775830..a9ebd4e79ed 100644
--- a/public/app/core/nav_model_srv.ts
+++ b/public/app/core/nav_model_srv.ts
@@ -1,6 +1,6 @@
-import coreModule from "app/core/core_module";
-import config from "app/core/config";
-import _ from "lodash";
+import coreModule from 'app/core/core_module';
+import config from 'app/core/config';
+import _ from 'lodash';
export interface NavModelItem {
text: string;
@@ -34,7 +34,7 @@ export class NavModelSrv {
}
getCfgNode() {
- return _.find(this.navItems, { id: "cfg" });
+ return _.find(this.navItems, { id: 'cfg' });
}
getNav(...args) {
@@ -70,17 +70,17 @@ 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,
};
}
}
-coreModule.service("navModelSrv", NavModelSrv);
+coreModule.service('navModelSrv', NavModelSrv);
diff --git a/public/app/core/profiler.ts b/public/app/core/profiler.ts
index 591144e3750..f459c5d4557 100644
--- a/public/app/core/profiler.ts
+++ b/public/app/core/profiler.ts
@@ -1,5 +1,5 @@
-import $ from "jquery";
-import angular from "angular";
+import $ from 'jquery';
+import angular from 'angular';
export class Profiler {
panelsRendered: number;
@@ -11,7 +11,7 @@ export class Profiler {
scopeCount: any;
init(config, $rootScope) {
- this.enabled = config.buildInfo.env === "development";
+ this.enabled = config.buildInfo.env === 'development';
this.timings = {};
this.timings.appStart = { loadStart: new Date().getTime() };
this.$rootScope = $rootScope;
@@ -28,22 +28,10 @@ export class Profiler {
() => {}
);
- $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('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);
}
refresh() {
@@ -51,10 +39,10 @@ export class Profiler {
this.timings.render = 0;
setTimeout(() => {
- console.log("panel count: " + this.panelsInitCount);
- console.log("total query: " + this.timings.query);
- console.log("total render: " + this.timings.render);
- console.log("avg render: " + this.timings.render / this.panelsInitCount);
+ console.log('panel count: ' + this.panelsInitCount);
+ console.log('total query: ' + this.timings.query);
+ console.log('total render: ' + this.timings.render);
+ console.log('avg render: ' + this.timings.render / this.panelsInitCount);
}, 5000);
}
@@ -70,21 +58,12 @@ 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();
@@ -92,20 +71,17 @@ 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);
}
getTotalWatcherCount() {
var count = 0;
var scopes = 0;
- var root = $(document.getElementsByTagName("body"));
+ var root = $(document.getElementsByTagName('body'));
var f = function(element) {
- if (element.data().hasOwnProperty("$scope")) {
+ if (element.data().hasOwnProperty('$scope')) {
scopes++;
angular.forEach(element.data().$scope.$$watchers, function() {
count++;
diff --git a/public/app/core/routes/dashboard_loaders.ts b/public/app/core/routes/dashboard_loaders.ts
deleted file mode 100644
index 271346c0ed1..00000000000
--- a/public/app/core/routes/dashboard_loaders.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import coreModule from "../core_module";
-
-export class LoadDashboardCtrl {
- /** @ngInject */
- constructor($scope, $routeParams, dashboardLoaderSrv, backendSrv, $location) {
- $scope.appEvent("dashboard-fetch-start");
-
- if (!$routeParams.slug) {
- backendSrv.get("/api/dashboards/home").then(function(homeDash) {
- if (homeDash.redirectUri) {
- $location.path("dashboard/" + homeDash.redirectUri);
- } else {
- var meta = homeDash.meta;
- meta.canSave = meta.canShare = meta.canStar = false;
- $scope.initDashboard(homeDash, $scope);
- }
- });
- return;
- }
-
- 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
- );
- }
-}
-
-coreModule.controller("LoadDashboardCtrl", LoadDashboardCtrl);
-coreModule.controller("NewDashboardCtrl", NewDashboardCtrl);
diff --git a/public/app/core/routes/routes.ts b/public/app/core/routes/routes.ts
deleted file mode 100644
index f2e4fa1ec88..00000000000
--- a/public/app/core/routes/routes.ts
+++ /dev/null
@@ -1,304 +0,0 @@
-import "./dashboard_loaders";
-import coreModule from "app/core/core_module";
-
-/** @ngInject **/
-function setupAngularRoutes($routeProvider, $locationProvider) {
- $locationProvider.html5Mode(true);
-
- var loadOrgBundle = {
- 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");
- }
- ]
- };
-
- var loadAlertingBundle = {
- 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"
- });
-}
-
-coreModule.config(setupAngularRoutes);
diff --git a/public/app/core/services/alert_srv.ts b/public/app/core/services/alert_srv.ts
index 74200bf8e32..ea15077b960 100644
--- a/public/app/core/services/alert_srv.ts
+++ b/public/app/core/services/alert_srv.ts
@@ -1,9 +1,9 @@
///
-import angular from "angular";
-import _ from "lodash";
-import coreModule from "app/core/core_module";
-import appEvents from "app/core/app_events";
+import angular from 'angular';
+import _ from 'lodash';
+import coreModule from 'app/core/core_module';
+import appEvents from 'app/core/app_events';
export class AlertSrv {
list: any[];
@@ -15,65 +15,59 @@ export class AlertSrv {
init() {
this.$rootScope.onAppEvent(
- "alert-error",
+ 'alert-error',
(e, alert) => {
- this.set(alert[0], alert[1], "error", 12000);
+ this.set(alert[0], alert[1], 'error', 12000);
},
this.$rootScope
);
this.$rootScope.onAppEvent(
- "alert-warning",
+ 'alert-warning',
(e, alert) => {
- this.set(alert[0], alert[1], "warning", 5000);
+ this.set(alert[0], alert[1], 'warning', 5000);
},
this.$rootScope
);
this.$rootScope.onAppEvent(
- "alert-success",
+ 'alert-success',
(e, alert) => {
- this.set(alert[0], alert[1], "success", 3000);
+ 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("confirm-modal", this.showConfirmModal.bind(this));
+ 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";
+ case 'success':
+ return 'fa fa-check';
+ case 'error':
+ return 'fa fa-exclamation-triangle';
default:
- return "fa fa-exclamation";
+ return 'fa fa-exclamation';
}
}
set(title, text, severity, timeout) {
if (_.isObject(text)) {
- console.log("alert error", text);
+ console.log('alert error', text);
if (text.statusText) {
text = `HTTP Error (${text.status}) ${text.statusText}`;
}
}
var newAlert = {
- title: title || "",
- text: text || "",
- severity: severity || "info",
- icon: this.getIconForSeverity(severity)
+ title: title || '',
+ text: text || '',
+ severity: severity || 'info',
+ icon: this.getIconForSeverity(severity),
};
var newAlertJson = angular.toJson(newAlert);
@@ -114,8 +108,7 @@ 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;
@@ -126,24 +119,24 @@ 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({
- template: "public/app/partials/confirm_modal.html",
+ template: 'public/app/partials/confirm_modal.html',
persist: false,
- modalClass: "confirm-modal",
+ modalClass: 'confirm-modal',
show: false,
scope: scope,
- keyboard: false
+ keyboard: false,
});
confirmModal.then(function(modalEl) {
- modalEl.modal("show");
+ modalEl.modal('show');
});
}
}
-coreModule.service("alertSrv", AlertSrv);
+coreModule.service('alertSrv', AlertSrv);
diff --git a/public/app/core/services/analytics.ts b/public/app/core/services/analytics.ts
index 9065d81ffb3..370773154e5 100644
--- a/public/app/core/services/analytics.ts
+++ b/public/app/core/services/analytics.ts
@@ -1,29 +1,29 @@
-import $ from "jquery";
-import coreModule from "app/core/core_module";
-import config from "app/core/config";
+import $ from 'jquery';
+import coreModule from 'app/core/core_module';
+import config from 'app/core/config';
export class Analytics {
/** @ngInject */
constructor(private $rootScope, private $location) {}
gaInit() {
- $.getScript("https://www.google-analytics.com/analytics.js"); // jQuery shortcut
+ $.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();
- ga("create", (config).googleAnalyticsId, "auto");
+ ga('create', (config).googleAnalyticsId, 'auto');
return ga;
}
init() {
- this.$rootScope.$on("$viewContentLoaded", () => {
+ this.$rootScope.$on('$viewContentLoaded', () => {
var track = { page: this.$location.url() };
var ga = (window).ga || this.gaInit();
- ga("set", track);
- ga("send", "pageview");
+ ga('set', track);
+ ga('send', 'pageview');
});
}
}
@@ -35,4 +35,4 @@ function startAnalytics(googleAnalyticsSrv) {
}
}
-coreModule.service("googleAnalyticsSrv", Analytics).run(startAnalytics);
+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 5b276a53e4f..5d582116d8e 100644
--- a/public/app/core/services/backend_srv.ts
+++ b/public/app/core/services/backend_srv.ts
@@ -1,9 +1,9 @@
///
-import _ from "lodash";
-import coreModule from "app/core/core_module";
-import appEvents from "app/core/app_events";
-import { DashboardModel } from "app/features/dashboard/dashboard_model";
+import _ from 'lodash';
+import coreModule from 'app/core/core_module';
+import appEvents from 'app/core/app_events';
+import { DashboardModel } from 'app/features/dashboard/dashboard_model';
export class BackendSrv {
private inFlightRequests = {};
@@ -11,32 +11,26 @@ 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 });
+ return this.request({ method: 'GET', url: url, params: params });
}
delete(url) {
- return this.request({ method: "DELETE", url: url });
+ return this.request({ method: 'DELETE', url: url });
}
post(url, data) {
- return this.request({ method: "POST", url: url, data: data });
+ return this.request({ method: 'POST', url: url, data: data });
}
patch(url, data) {
- return this.request({ method: "PATCH", url: url, data: data });
+ return this.request({ method: 'PATCH', url: url, data: data });
}
put(url, data) {
- return this.request({ method: "PUT", url: url, data: data });
+ return this.request({ method: 'PUT', url: url, data: data });
}
withNoBackendCache(callback) {
@@ -51,28 +45,28 @@ export class BackendSrv {
return;
}
- var data = err.data || { message: "Unexpected error" };
+ var data = err.data || { message: 'Unexpected error' };
if (_.isString(data)) {
data = { message: data };
}
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";
+ 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);
}
@@ -88,20 +82,20 @@ export class BackendSrv {
if (requestIsLocal) {
if (this.contextSrv.user && this.contextSrv.user.orgId) {
options.headers = options.headers || {};
- options.headers["X-Grafana-Org-Id"] = this.contextSrv.user.orgId;
+ 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 (options.method !== 'GET') {
if (results && results.data.message) {
if (options.showSuccessAlert !== false) {
- this.alertSrv.set(results.data.message, "", "success", 3000);
+ this.alertSrv.set(results.data.message, '', 'success', 3000);
}
}
}
@@ -109,11 +103,7 @@ export class BackendSrv {
},
err => {
// handle unauthorized
- if (
- err.status === 401 &&
- this.contextSrv.user.isSignedIn &&
- firstAttempt
- ) {
+ if (err.status === 401 && this.contextSrv.user.isSignedIn && firstAttempt) {
return this.loginPing().then(() => {
options.retry = 1;
return this.request(options);
@@ -163,26 +153,26 @@ export class BackendSrv {
if (requestIsLocal) {
if (this.contextSrv.user && this.contextSrv.user.orgId) {
options.headers = options.headers || {};
- options.headers["X-Grafana-Org-Id"] = this.contextSrv.user.orgId;
+ 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);
}
if (options.headers && options.headers.Authorization) {
- options.headers["X-DS-Authorization"] = options.headers.Authorization;
+ options.headers['X-DS-Authorization'] = options.headers.Authorization;
delete options.headers.Authorization;
}
if (this.noBackendCache) {
- options.headers["X-Grafana-NoCache"] = "true";
+ options.headers['X-Grafana-NoCache'] = 'true';
}
}
return this.$http(options)
.then(response => {
- appEvents.emit("ds-request-response", response);
+ appEvents.emit('ds-request-response', response);
return response;
})
.catch(err => {
@@ -205,7 +195,7 @@ export class BackendSrv {
if (_.isString(err.data) && err.status === 500) {
err.data = {
error: err.statusText,
- response: err.data
+ response: err.data,
};
}
@@ -214,7 +204,7 @@ export class BackendSrv {
err.data.message = err.data.error;
}
- appEvents.emit("ds-request-error", err);
+ appEvents.emit('ds-request-error', err);
throw err;
})
.finally(() => {
@@ -226,49 +216,49 @@ export class BackendSrv {
}
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) {
- return this.get("/api/search", query);
+ return this.get('/api/search', query);
}
getDashboard(type, slug) {
- return this.get("/api/dashboards/" + type + "/" + slug);
+ return this.get('/api/dashboards/' + type + '/' + slug);
}
saveDashboard(dash, options) {
options = options || {};
- return this.post("/api/dashboards/db/", {
+ return this.post('/api/dashboards/db/', {
dashboard: dash,
- folderId: dash.folderId,
+ folderId: options.folderId,
overwrite: options.overwrite === true,
- message: options.message || ""
+ message: options.message || '',
});
}
createDashboardFolder(name) {
const dash = {
schemaVersion: 16,
- title: name,
+ title: name.trim(),
editable: true,
- panels: []
+ panels: [],
};
- return this.post("/api/dashboards/db/", {
+ return this.post('/api/dashboards/db/', {
dashboard: dash,
isFolder: true,
- overwrite: false
+ overwrite: false,
}).then(res => {
- return this.getDashboard("db", res.slug);
+ return this.getDashboard('db', res.slug);
});
}
deleteDashboard(slug) {
let deferred = this.$q.defer();
- this.getDashboard("db", slug).then(fullDash => {
+ this.getDashboard('db', slug).then(fullDash => {
this.delete(`/api/dashboards/db/${slug}`)
.then(() => {
deferred.resolve(fullDash);
@@ -295,16 +285,14 @@ 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
+ alreadyInFolderCount: _.filter(result, { alreadyInFolder: true }).length,
};
});
}
@@ -312,31 +300,30 @@ export class BackendSrv {
private moveDashboard(slug, toFolder) {
let deferred = this.$q.defer();
- this.getDashboard("db", slug).then(fullDash => {
+ 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
- ) {
+ if ((!fullDash.meta.folderId && toFolder.id === 0) || fullDash.meta.folderId === toFolder.id) {
deferred.resolve({ alreadyInFolder: true });
return;
}
- model.folderId = toFolder.id;
- model.meta.folderId = toFolder.id;
- model.meta.folderTitle = toFolder.title;
const clone = model.getSaveModelClone();
+ let options = {
+ folderId: toFolder.id,
+ overwrite: false,
+ };
- this.saveDashboard(clone, {})
+ this.saveDashboard(clone, options)
.then(() => {
deferred.resolve({ succeeded: true });
})
.catch(err => {
- if (err.data && err.data.status === "plugin-dashboard") {
+ if (err.data && err.data.status === 'plugin-dashboard') {
err.isHandled = true;
+ options.overwrite = true;
- this.saveDashboard(clone, { overwrite: true })
+ this.saveDashboard(clone, options)
.then(() => {
deferred.resolve({ succeeded: true });
})
@@ -374,4 +361,4 @@ export class BackendSrv {
}
}
-coreModule.service("backendSrv", BackendSrv);
+coreModule.service('backendSrv', BackendSrv);
diff --git a/public/app/core/services/context_srv.ts b/public/app/core/services/context_srv.ts
index 793e7128dd3..5a879895267 100644
--- a/public/app/core/services/context_srv.ts
+++ b/public/app/core/services/context_srv.ts
@@ -1,7 +1,7 @@
-import config from "app/core/config";
-import _ from "lodash";
-import coreModule from "app/core/core_module";
-import store from "app/core/store";
+import config from 'app/core/config';
+import _ from 'lodash';
+import coreModule from 'app/core/core_module';
+import store from 'app/core/store';
export class User {
isGrafanaAdmin: any;
@@ -30,7 +30,7 @@ export class ContextSrv {
sidemenuSmallBreakpoint = false;
constructor() {
- this.sidemenu = store.getBool("grafana.sidemenu", true);
+ this.sidemenu = store.getBool('grafana.sidemenu', true);
if (!config.buildInfo) {
config.buildInfo = {};
@@ -43,7 +43,7 @@ export class ContextSrv {
this.user = new User();
this.isSignedIn = this.user.isSignedIn;
this.isGrafanaAdmin = this.user.isGrafanaAdmin;
- this.isEditor = this.hasRole("Editor") || this.hasRole("Admin");
+ this.isEditor = this.hasRole('Editor') || this.hasRole('Admin');
}
hasRole(role) {
@@ -51,21 +51,18 @@ export class ContextSrv {
}
isGrafanaVisible() {
- return !!(
- document.visibilityState === undefined ||
- document.visibilityState === "visible"
- );
+ return !!(document.visibilityState === undefined || document.visibilityState === 'visible');
}
toggleSideMenu() {
this.sidemenu = !this.sidemenu;
- store.set("grafana.sidemenu", this.sidemenu);
+ store.set('grafana.sidemenu', this.sidemenu);
}
}
var contextSrv = new ContextSrv();
export { contextSrv };
-coreModule.factory("contextSrv", function() {
+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 936e5d0d9d0..cfcc70516b6 100644
--- a/public/app/core/services/dynamic_directive_srv.ts
+++ b/public/app/core/services/dynamic_directive_srv.ts
@@ -1,7 +1,7 @@
///
-import angular from "angular";
-import coreModule from "../core_module";
+import angular from 'angular';
+import coreModule from '../core_module';
class DynamicDirectiveSrv {
/** @ngInject */
@@ -25,27 +25,21 @@ class DynamicDirectiveSrv {
}
if (!directiveInfo.fn.registered) {
- coreModule.directive(
- attrs.$normalize(directiveInfo.name),
- directiveInfo.fn
- );
+ 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()
- ]);
+ console.log('Plugin load:', err);
+ this.$rootScope.appEvent('alert-error', ['Plugin error', err.toString()]);
});
}
create(options) {
let directiveDef = {
- restrict: "E",
+ restrict: 'E',
scope: options.scope,
link: (scope, elem, attrs) => {
if (options.watchPath) {
@@ -60,11 +54,11 @@ class DynamicDirectiveSrv {
} else {
this.link(scope, elem, attrs, options);
}
- }
+ },
};
return directiveDef;
}
}
-coreModule.service("dynamicDirectiveSrv", 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 953c57437c5..0569b9933d8 100644
--- a/public/app/core/services/global_event_srv.ts
+++ b/public/app/core/services/global_event_srv.ts
@@ -1,32 +1,36 @@
-import coreModule from "app/core/core_module";
-import config from "app/core/config";
-import appEvents from "app/core/app_events";
+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 = "") {
+ stripBaseFromUrl(url = '') {
const appSubUrl = this.appSubUrl;
- const stripExtraChars = appSubUrl.endsWith("/") ? 1 : 0;
+ const stripExtraChars = appSubUrl.endsWith('/') ? 1 : 0;
const urlWithoutBase =
- url.length > 0 && url.indexOf(appSubUrl) === 0
- ? url.slice(appSubUrl.length - stripExtraChars)
- : url;
+ url.length > 0 && url.indexOf(appSubUrl) === 0 ? url.slice(appSubUrl.length - stripExtraChars) : url;
return urlWithoutBase;
}
init() {
- appEvents.on("location-change", payload => {
+ appEvents.on('location-change', payload => {
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.
@@ -36,4 +40,4 @@ export class GlobalEventSrv {
}
}
-coreModule.service("globalEventSrv", GlobalEventSrv);
+coreModule.service('globalEventSrv', GlobalEventSrv);
diff --git a/public/app/core/services/impression_srv.ts b/public/app/core/services/impression_srv.ts
index ce9ad82a646..3945c048876 100644
--- a/public/app/core/services/impression_srv.ts
+++ b/public/app/core/services/impression_srv.ts
@@ -1,6 +1,6 @@
-import store from "app/core/store";
-import _ from "lodash";
-import config from "app/core/config";
+import store from 'app/core/store';
+import _ from 'lodash';
+import config from 'app/core/config';
export class ImpressionSrv {
constructor() {}
@@ -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 b0074c8665e..36fe73b62ce 100644
--- a/public/app/core/services/keybindingSrv.ts
+++ b/public/app/core/services/keybindingSrv.ts
@@ -1,10 +1,10 @@
-import $ from "jquery";
-import _ from "lodash";
+import $ from 'jquery';
+import _ from 'lodash';
-import coreModule from "app/core/core_module";
-import appEvents from "app/core/app_events";
+import coreModule from 'app/core/core_module';
+import appEvents from 'app/core/app_events';
-import Mousetrap from "mousetrap";
+import Mousetrap from 'mousetrap';
export class KeybindingSrv {
helpModal: boolean;
@@ -12,7 +12,7 @@ export class KeybindingSrv {
/** @ngInject */
constructor(private $rootScope, private $location) {
// clear out all shortcuts on route change
- $rootScope.$on("$routeChangeSuccess", () => {
+ $rootScope.$on('$routeChangeSuccess', () => {
Mousetrap.reset();
// rebind global shortcuts
this.setupGlobal();
@@ -22,42 +22,42 @@ 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("s o", this.openSearch);
- this.bind("s t", this.openSearchTags);
- this.bind("f", this.openSearch);
+ 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('s o', this.openSearch);
+ this.bind('s t', this.openSearchTags);
+ this.bind('f', this.openSearch);
}
openSearchStarred() {
- appEvents.emit("show-dash-search", { starred: true });
+ appEvents.emit('show-dash-search', { starred: true });
}
openSearchTags() {
- appEvents.emit("show-dash-search", { tagsMode: true });
+ appEvents.emit('show-dash-search', { tagsMode: true });
}
openSearch() {
- appEvents.emit("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) {
@@ -69,68 +69,68 @@ export class KeybindingSrv {
evt.returnValue = false;
return this.$rootScope.$apply(fn.bind(this));
},
- "keydown"
+ 'keydown'
);
}
showDashEditView() {
- var search = _.extend(this.$location.search(), { editview: "settings" });
+ var search = _.extend(this.$location.search(), { editview: 'settings' });
this.$location.search(search);
}
setupDashboardBindings(scope, dashboard) {
- this.bind("mod+o", () => {
+ this.bind('mod+o', () => {
dashboard.graphTooltip = (dashboard.graphTooltip + 1) % 3;
- appEvents.emit("graph-hover-clear");
- this.$rootScope.$broadcast("refresh");
+ appEvents.emit('graph-hover-clear');
+ this.$rootScope.$broadcast('refresh');
});
- this.bind("mod+s", e => {
- scope.appEvent("save-dashboard");
+ this.bind('mod+s', e => {
+ scope.appEvent('save-dashboard');
});
- this.bind("t z", () => {
- scope.appEvent("zoom-out", 2);
+ this.bind('t z', () => {
+ scope.appEvent('zoom-out', 2);
});
- this.bind("ctrl+z", () => {
- scope.appEvent("zoom-out", 2);
+ this.bind('ctrl+z', () => {
+ scope.appEvent('zoom-out', 2);
});
- this.bind("t left", () => {
- scope.appEvent("shift-time-backward");
+ this.bind('t left', () => {
+ scope.appEvent('shift-time-backward');
});
- this.bind("t right", () => {
- scope.appEvent("shift-time-forward");
+ this.bind('t right', () => {
+ scope.appEvent('shift-time-forward');
});
// edit panel
- this.bind("e", () => {
+ this.bind('e', () => {
if (dashboard.meta.focusPanelId && dashboard.meta.canEdit) {
- this.$rootScope.appEvent("panel-change-view", {
+ this.$rootScope.appEvent('panel-change-view', {
fullscreen: true,
edit: true,
panelId: dashboard.meta.focusPanelId,
- toggle: true
+ toggle: true,
});
}
});
// view panel
- this.bind("v", () => {
+ this.bind('v', () => {
if (dashboard.meta.focusPanelId) {
- this.$rootScope.appEvent("panel-change-view", {
+ this.$rootScope.appEvent('panel-change-view', {
fullscreen: true,
edit: null,
panelId: dashboard.meta.focusPanelId,
- toggle: true
+ toggle: true,
});
}
});
// delete panel
- this.bind("p r", () => {
+ this.bind('p r', () => {
if (dashboard.meta.focusPanelId && dashboard.meta.canEdit) {
var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
panelInfo.row.removePanel(panelInfo.panel);
@@ -139,22 +139,22 @@ export class KeybindingSrv {
});
// share panel
- this.bind("p s", () => {
+ this.bind('p s', () => {
if (dashboard.meta.focusPanelId) {
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
+ appEvents.emit('show-modal', {
+ src: 'public/app/features/dashboard/partials/shareModal.html',
+ scope: shareScope,
});
}
});
// delete row
- this.bind("r r", () => {
+ this.bind('r r', () => {
if (dashboard.meta.focusPanelId && dashboard.meta.canEdit) {
var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
dashboard.removeRow(panelInfo.row);
@@ -163,7 +163,7 @@ export class KeybindingSrv {
});
// collapse row
- this.bind("r c", () => {
+ this.bind('r c', () => {
if (dashboard.meta.focusPanelId) {
var panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
panelInfo.row.toggleCollapse();
@@ -172,47 +172,47 @@ export class KeybindingSrv {
});
// collapse all rows
- this.bind("d shift+c", () => {
+ this.bind('d shift+c', () => {
for (let row of dashboard.rows) {
row.collapse = true;
}
});
// expand all rows
- this.bind("d shift+e", () => {
+ this.bind('d shift+e', () => {
for (let row of dashboard.rows) {
row.collapse = false;
}
});
- this.bind("d n", e => {
- this.$location.url("/dashboard/new");
+ this.bind('d n', e => {
+ this.$location.url('/dashboard/new');
});
- this.bind("d r", () => {
- this.$rootScope.$broadcast("refresh");
+ this.bind('d r', () => {
+ this.$rootScope.$broadcast('refresh');
});
- this.bind("d s", () => {
+ this.bind('d s', () => {
this.showDashEditView();
});
- this.bind("d k", () => {
- appEvents.emit("toggle-kiosk-mode");
+ this.bind('d k', () => {
+ appEvents.emit('toggle-kiosk-mode');
});
- this.bind("d v", () => {
- appEvents.emit("toggle-view-mode");
+ this.bind('d v', () => {
+ appEvents.emit('toggle-view-mode');
});
- this.bind("esc", () => {
- var popups = $(".popover.in");
+ this.bind('esc', () => {
+ var popups = $('.popover.in');
if (popups.length > 0) {
return;
}
- scope.appEvent("hide-modal");
- scope.appEvent("panel-change-view", { fullscreen: false, edit: false });
+ scope.appEvent('hide-modal');
+ scope.appEvent('panel-change-view', { fullscreen: false, edit: false });
// close settings view
var search = this.$location.search();
@@ -224,4 +224,4 @@ export class KeybindingSrv {
}
}
-coreModule.service("keybindingSrv", KeybindingSrv);
+coreModule.service('keybindingSrv', KeybindingSrv);
diff --git a/public/app/core/services/ng_react.ts b/public/app/core/services/ng_react.ts
index ce65844f35b..3c61412669e 100644
--- a/public/app/core/services/ng_react.ts
+++ b/public/app/core/services/ng_react.ts
@@ -9,9 +9,9 @@
// - reactComponent (generic directive for delegating off to React Components)
// - reactDirective (factory for creating specific directives that correspond to reactComponent directives)
-import React from "react";
-import ReactDOM from "react-dom";
-import angular from "angular";
+import React from 'react';
+import ReactDOM from 'react-dom';
+import angular from 'angular';
// get a react component from name (components can be an angular injectable e.g. value, factory or
// available on window
@@ -23,7 +23,7 @@ function getReactComponent(name, $injector) {
// a React component name must be specified
if (!name) {
- throw new Error("ReactComponent name attribute must be specified");
+ throw new Error('ReactComponent name attribute must be specified');
}
// ensure the specified React component is accessible, and fail fast if it's not
@@ -34,14 +34,14 @@ function getReactComponent(name, $injector) {
if (!reactComponent) {
try {
- reactComponent = name.split(".").reduce(function(current, namePart) {
+ reactComponent = name.split('.').reduce(function(current, namePart) {
return current[namePart];
}, window);
} catch (e) {}
}
if (!reactComponent) {
- throw Error("Cannot find react component " + name);
+ throw Error('Cannot find react component ' + name);
}
return reactComponent;
@@ -55,7 +55,7 @@ function applied(fn, scope) {
var wrapped: any = function() {
var args = arguments;
var phase = scope.$root.$$phase;
- if (phase === "$apply" || phase === "$digest") {
+ if (phase === '$apply' || phase === '$digest') {
return fn.apply(null, args);
} else {
return scope.$apply(function() {
@@ -88,10 +88,7 @@ function applyFunctions(obj, scope, propsConfig?) {
* 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;
+ prev[key] = angular.isFunction(value) && config.wrapApply !== false ? applied(value, scope) : value;
return prev;
}, {});
@@ -115,18 +112,18 @@ function watchProps(watchDepth, scope, watchExpressions, listener) {
var actualExpr = getPropExpression(expr);
var exprWatchDepth = getPropWatchDepth(watchDepth, expr);
- if (exprWatchDepth === "collection" && supportsWatchCollection) {
+ if (exprWatchDepth === 'collection' && supportsWatchCollection) {
scope.$watchCollection(actualExpr, listener);
- } else if (exprWatchDepth === "reference" && supportsWatchGroup) {
+ } else if (exprWatchDepth === 'reference' && supportsWatchGroup) {
watchGroupExpressions.push(actualExpr);
- } else if (exprWatchDepth === "one-time") {
+ } else if (exprWatchDepth === 'one-time') {
//do nothing because we handle our one time bindings after this
} else {
- scope.$watch(actualExpr, listener, exprWatchDepth !== "reference");
+ scope.$watch(actualExpr, listener, exprWatchDepth !== 'reference');
}
});
- if (watchDepth === "one-time") {
+ if (watchDepth === 'one-time') {
listener();
}
@@ -167,8 +164,7 @@ 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;
}
@@ -192,7 +188,7 @@ function getPropWatchDepth(defaultWatch, prop) {
//
var reactComponent = function($injector) {
return {
- restrict: "E",
+ restrict: 'E',
replace: true,
link: function(scope, elem, attrs) {
var reactComponent = getReactComponent(attrs.name, $injector);
@@ -205,24 +201,19 @@ 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() {
+ scope.$on('$destroy', function() {
if (!attrs.onScopeDestroy) {
ReactDOM.unmountComponentAtNode(elem[0]);
} else {
scope.$eval(attrs.onScopeDestroy, {
- unmountComponent: ReactDOM.unmountComponentAtNode.bind(
- this,
- elem[0]
- )
+ unmountComponent: ReactDOM.unmountComponentAtNode.bind(this, elem[0]),
});
}
});
- }
+ },
};
};
@@ -255,7 +246,7 @@ var reactComponent = function($injector) {
var reactDirective = function($injector) {
return function(reactComponentName, props, conf, injectableProps) {
var directive = {
- restrict: "E",
+ restrict: 'E',
replace: true,
link: function(scope, elem, attrs) {
var reactComponent = getReactComponent(reactComponentName, $injector);
@@ -282,40 +273,28 @@ 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() {
+ scope.$on('$destroy', function() {
if (!attrs.onScopeDestroy) {
ReactDOM.unmountComponentAtNode(elem[0]);
} else {
scope.$eval(attrs.onScopeDestroy, {
- unmountComponent: ReactDOM.unmountComponentAtNode.bind(
- this,
- elem[0]
- )
+ unmountComponent: ReactDOM.unmountComponentAtNode.bind(this, elem[0]),
});
}
});
- }
+ },
};
return angular.extend(directive, conf);
};
};
-let ngModule = angular.module("react", []);
-ngModule.directive("reactComponent", ["$injector", reactComponent]);
-ngModule.factory("reactDirective", ["$injector", reactDirective]);
+let ngModule = angular.module('react', []);
+ngModule.directive('reactComponent', ['$injector', reactComponent]);
+ngModule.factory('reactDirective', ['$injector', reactDirective]);
diff --git a/public/app/core/services/popover_srv.ts b/public/app/core/services/popover_srv.ts
index 07aae95d67c..7c1708b15a7 100644
--- a/public/app/core/services/popover_srv.ts
+++ b/public/app/core/services/popover_srv.ts
@@ -1,8 +1,8 @@
///
-import _ from "lodash";
-import coreModule from "app/core/core_module";
-import Drop from "tether-drop";
+import _ from 'lodash';
+import coreModule from 'app/core/core_module';
+import Drop from 'tether-drop';
/** @ngInject **/
function popoverSrv($compile, $rootScope, $timeout) {
@@ -43,7 +43,7 @@ function popoverSrv($compile, $rootScope, $timeout) {
drop.close();
};
- var contentElement = document.createElement("div");
+ var contentElement = document.createElement('div');
contentElement.innerHTML = options.template;
$compile(contentElement)(scope);
@@ -53,15 +53,15 @@ function popoverSrv($compile, $rootScope, $timeout) {
target: options.element,
content: contentElement,
position: options.position,
- classes: options.classNames || "drop-popover",
+ classes: options.classNames || 'drop-popover',
openOn: options.openOn,
hoverCloseDelay: 200,
tetherOptions: {
- constraints: [{ to: "scrollParent", attachment: "together" }]
- }
+ constraints: [{ to: 'scrollParent', attachment: 'together' }],
+ },
});
- drop.on("close", () => {
+ drop.on('close', () => {
cleanUp();
});
@@ -78,4 +78,4 @@ function popoverSrv($compile, $rootScope, $timeout) {
};
}
-coreModule.service("popoverSrv", popoverSrv);
+coreModule.service('popoverSrv', popoverSrv);
diff --git a/public/app/core/services/search_srv.ts b/public/app/core/services/search_srv.ts
index 7f33f95b024..a909b4af09f 100644
--- a/public/app/core/services/search_srv.ts
+++ b/public/app/core/services/search_srv.ts
@@ -1,8 +1,8 @@
-import _ from "lodash";
-import coreModule from "app/core/core_module";
-import impressionSrv from "app/core/services/impression_srv";
-import store from "app/core/store";
-import { contextSrv } from "app/core/services/context_srv";
+import _ from 'lodash';
+import coreModule from 'app/core/core_module';
+import impressionSrv from 'app/core/services/impression_srv';
+import store from 'app/core/store';
+import { contextSrv } from 'app/core/services/context_srv';
export class SearchSrv {
recentIsOpen: boolean;
@@ -10,21 +10,21 @@ export class SearchSrv {
/** @ngInject */
constructor(private backendSrv, private $q) {
- this.recentIsOpen = store.getBool("search.sections.recent", true);
- this.starredIsOpen = store.getBool("search.sections.starred", true);
+ this.recentIsOpen = store.getBool('search.sections.recent', true);
+ this.starredIsOpen = store.getBool('search.sections.starred', true);
}
private getRecentDashboards(sections) {
return this.queryForRecentDashboards().then(result => {
if (result.length > 0) {
- sections["recent"] = {
- title: "Recent Boards",
- icon: "fa fa-clock-o",
+ sections['recent'] = {
+ title: 'Recent',
+ icon: 'fa fa-clock-o',
score: -1,
removable: true,
expanded: this.recentIsOpen,
toggle: this.toggleRecent.bind(this),
- items: result
+ items: result,
};
}
});
@@ -50,7 +50,7 @@ export class SearchSrv {
private toggleRecent(section) {
this.recentIsOpen = section.expanded = !section.expanded;
- store.set("search.sections.recent", this.recentIsOpen);
+ store.set('search.sections.recent', this.recentIsOpen);
if (!section.expanded || section.items.length) {
return Promise.resolve(section);
@@ -64,7 +64,7 @@ export class SearchSrv {
private toggleStarred(section) {
this.starredIsOpen = section.expanded = !section.expanded;
- store.set("search.sections.starred", this.starredIsOpen);
+ store.set('search.sections.starred', this.starredIsOpen);
return Promise.resolve(section);
}
@@ -75,20 +75,20 @@ export class SearchSrv {
return this.backendSrv.search({ starred: true, limit: 5 }).then(result => {
if (result.length > 0) {
- sections["starred"] = {
- title: "Starred Boards",
- icon: "fa fa-star-o",
+ sections['starred'] = {
+ title: 'Starred',
+ icon: 'fa fa-star-o',
score: -2,
expanded: this.starredIsOpen,
toggle: this.toggleStarred.bind(this),
- items: result.map(this.transformToViewModel)
+ items: result.map(this.transformToViewModel),
};
}
});
}
private transformToViewModel(hit) {
- hit.url = "dashboard/db/" + hit.slug;
+ hit.url = 'dashboard/db/' + hit.slug;
return hit;
}
@@ -122,7 +122,7 @@ export class SearchSrv {
);
return this.$q.all(promises).then(() => {
- return _.sortBy(_.values(sections), "score");
+ return _.sortBy(_.values(sections), 'score');
});
}
@@ -133,7 +133,7 @@ export class SearchSrv {
// create folder index
for (let hit of results) {
- if (hit.type === "dash-folder") {
+ if (hit.type === 'dash-folder') {
sections[hit.id] = {
id: hit.id,
title: hit.title,
@@ -142,14 +142,14 @@ export class SearchSrv {
toggle: this.toggleFolder.bind(this),
url: `dashboards/folder/${hit.id}/${hit.slug}`,
slug: hit.slug,
- icon: "fa fa-folder",
- score: _.keys(sections).length
+ icon: 'fa fa-folder',
+ score: _.keys(sections).length,
};
}
}
for (let hit of results) {
- if (hit.type === "dash-folder") {
+ if (hit.type === 'dash-folder') {
continue;
}
@@ -162,18 +162,18 @@ export class SearchSrv {
url: `dashboards/folder/${hit.folderId}/${hit.folderSlug}`,
slug: hit.slug,
items: [],
- icon: "fa fa-folder-open",
+ icon: 'fa fa-folder-open',
toggle: this.toggleFolder.bind(this),
- score: _.keys(sections).length
+ score: _.keys(sections).length,
};
} else {
section = {
id: 0,
- title: "Root",
+ title: 'Root',
items: [],
- icon: "fa fa-folder-open",
+ icon: 'fa fa-folder-open',
toggle: this.toggleFolder.bind(this),
- score: _.keys(sections).length
+ score: _.keys(sections).length,
};
}
// add section
@@ -187,14 +187,14 @@ export class SearchSrv {
private toggleFolder(section) {
section.expanded = !section.expanded;
- section.icon = section.expanded ? "fa fa-folder-open" : "fa fa-folder";
+ section.icon = section.expanded ? 'fa fa-folder-open' : 'fa fa-folder';
if (section.items.length) {
return Promise.resolve(section);
}
let query = {
- folderIds: [section.id]
+ folderIds: [section.id],
};
return this.backendSrv.search(query).then(results => {
@@ -204,8 +204,8 @@ export class SearchSrv {
}
getDashboardTags() {
- return this.backendSrv.get("/api/dashboards/tags");
+ return this.backendSrv.get('/api/dashboards/tags');
}
}
-coreModule.service("searchSrv", SearchSrv);
+coreModule.service('searchSrv', SearchSrv);
diff --git a/public/app/core/services/timer.ts b/public/app/core/services/timer.ts
index b71fa1a1730..8052b3f2e2c 100644
--- a/public/app/core/services/timer.ts
+++ b/public/app/core/services/timer.ts
@@ -1,5 +1,5 @@
-import _ from "lodash";
-import coreModule from "app/core/core_module";
+import _ from 'lodash';
+import coreModule from 'app/core/core_module';
// This service really just tracks a list of $timeout promises to give us a
// method for cancelling them all when we need to
@@ -27,4 +27,4 @@ export class Timer {
}
}
-coreModule.service("timer", Timer);
+coreModule.service('timer', Timer);
diff --git a/public/app/core/services/util_srv.ts b/public/app/core/services/util_srv.ts
index a7d752b06bd..2a7dbe3a684 100644
--- a/public/app/core/services/util_srv.ts
+++ b/public/app/core/services/util_srv.ts
@@ -1,7 +1,7 @@
///
-import coreModule from "app/core/core_module";
-import appEvents from "app/core/app_events";
+import coreModule from 'app/core/core_module';
+import appEvents from 'app/core/app_events';
export class UtilSrv {
modalScope: any;
@@ -10,8 +10,8 @@ export class UtilSrv {
constructor(private $rootScope, private $modal) {}
init() {
- appEvents.on("show-modal", this.showModal.bind(this), this.$rootScope);
- appEvents.on("hide-modal", this.hideModal.bind(this), this.$rootScope);
+ appEvents.on('show-modal', this.showModal.bind(this), this.$rootScope);
+ appEvents.on('hide-modal', this.hideModal.bind(this), this.$rootScope);
}
hideModal() {
@@ -42,13 +42,13 @@ export class UtilSrv {
show: false,
scope: this.modalScope,
keyboard: false,
- backdrop: options.backdrop
+ backdrop: options.backdrop,
});
Promise.resolve(modal).then(function(modalEl) {
- modalEl.modal("show");
+ modalEl.modal('show');
});
}
}
-coreModule.service("utilSrv", UtilSrv);
+coreModule.service('utilSrv', UtilSrv);
diff --git a/public/app/core/specs/backend_srv_specs.ts b/public/app/core/specs/backend_srv_specs.ts
index 4a7403fb7d1..74b058b98c8 100644
--- a/public/app/core/specs/backend_srv_specs.ts
+++ b/public/app/core/specs/backend_srv_specs.ts
@@ -1,18 +1,12 @@
-import {
- describe,
- beforeEach,
- it,
- expect,
- angularMocks
-} from "test/lib/common";
-import "app/core/services/backend_srv";
+import { describe, beforeEach, it, expect, angularMocks } from 'test/lib/common';
+import 'app/core/services/backend_srv';
-describe("backend_srv", function() {
+describe('backend_srv', function() {
var _backendSrv;
var _httpBackend;
- beforeEach(angularMocks.module("grafana.core"));
- beforeEach(angularMocks.module("grafana.services"));
+ beforeEach(angularMocks.module('grafana.core'));
+ beforeEach(angularMocks.module('grafana.services'));
beforeEach(
angularMocks.inject(function($httpBackend, $http, backendSrv) {
_httpBackend = $httpBackend;
@@ -20,12 +14,12 @@ describe("backend_srv", function() {
})
);
- describe("when handling errors", function() {
- it("should return the http status code", function(done) {
- _httpBackend.whenGET("gateway-error").respond(502);
+ 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"
+ url: 'gateway-error',
})
.catch(function(err) {
expect(err.status).to.be(502);
diff --git a/public/app/core/specs/datemath.jest.ts b/public/app/core/specs/datemath.jest.ts
index 21173c35c4f..820c53486db 100644
--- a/public/app/core/specs/datemath.jest.ts
+++ b/public/app/core/specs/datemath.jest.ts
@@ -1,73 +1,60 @@
-import sinon from "sinon";
+import sinon from 'sinon';
-import * as dateMath from "app/core/utils/datemath";
-import moment from "moment";
-import _ from "lodash";
+import * as dateMath from 'app/core/utils/datemath';
+import moment from 'moment';
+import _ from 'lodash';
-describe("DateMath", () => {
- var spans = ["s", "m", "h", "d", "w", "M", "y"];
- var anchor = "2014-01-01T06:06:06.666Z";
+describe('DateMath', () => {
+ var spans = ['s', 'm', 'h', 'd', 'w', 'M', 'y'];
+ var anchor = '2014-01-01T06:06:06.666Z';
var unix = moment(anchor).valueOf();
- var format = "YYYY-MM-DDTHH:mm:ss.SSSZ";
+ var format = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
var clock;
- describe("errors", () => {
- it("should return undefined if passed something falsy", () => {
+ describe('errors', () => {
+ it('should return undefined if passed something falsy', () => {
expect(dateMath.parse(false)).toBe(undefined);
});
- it("should return undefined if I pass an operator besides [+-/]", () => {
- expect(dateMath.parse("now&1d")).toBe(undefined);
+ it('should return undefined if I pass an operator besides [+-/]', () => {
+ 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 rounding unit is not 1", () => {
- expect(dateMath.parse("now/2y")).toBe(undefined);
- expect(dateMath.parse("now/0.5y")).toBe(undefined);
+ it('should return undefined if I pass a unit besides' + spans.toString(), () => {
+ expect(dateMath.parse('now+5f')).toBe(undefined);
});
- it("should not go into an infinite loop when missing a unit", () => {
- expect(dateMath.parse("now-0")).toBe(undefined);
- expect(dateMath.parse("now-00")).toBe(undefined);
+ it('should return undefined if rounding unit is not 1', () => {
+ expect(dateMath.parse('now/2y')).toBe(undefined);
+ expect(dateMath.parse('now/0.5y')).toBe(undefined);
+ });
+
+ it('should not go into an infinite loop when missing a unit', () => {
+ expect(dateMath.parse('now-0')).toBe(undefined);
+ expect(dateMath.parse('now-00')).toBe(undefined);
});
});
- 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);
expected.setSeconds(0);
expected.setMilliseconds(0);
- var startOfDay = dateMath.parse("now/d", false).valueOf();
+ var startOfDay = dateMath.parse('now/d', false).valueOf();
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();
+ var startOfDay = dateMath.parse('now/d', false, 'utc').valueOf();
expect(startOfDay).toBe(expected.getTime());
});
- describe("subtraction", () => {
+ describe('subtraction', () => {
var now;
var anchored;
@@ -78,19 +65,15 @@ describe("DateMath", () => {
});
_.each(spans, span => {
- var nowEx = "now-5" + span;
- var thenEx = anchor + "||-5" + span;
+ var nowEx = 'now-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)
- );
+ it('should return 5' + span + ' ago', () => {
+ 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)
- );
+ it('should return 5' + span + ' before ' + anchor, () => {
+ expect(dateMath.parse(thenEx).format(format)).toEqual(anchored.subtract(5, span).format(format));
});
});
@@ -99,7 +82,7 @@ describe("DateMath", () => {
});
});
- describe("rounding", () => {
+ describe('rounding', () => {
var now;
beforeEach(() => {
@@ -108,16 +91,12 @@ describe("DateMath", () => {
});
_.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 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));
});
});
@@ -126,28 +105,28 @@ describe("DateMath", () => {
});
});
- describe("isValid", () => {
- it("should return false when invalid date text", () => {
- expect(dateMath.isValid("asd")).toBe(false);
+ describe('isValid', () => {
+ it('should return false when invalid date text', () => {
+ expect(dateMath.isValid('asd')).toBe(false);
});
- it("should return true when valid date text", () => {
- expect(dateMath.isValid("now-1h")).toBe(true);
+ it('should return true when valid date text', () => {
+ expect(dateMath.isValid('now-1h')).toBe(true);
});
});
- describe("relative time to date parsing", function() {
- it("should handle negative time", function() {
- var date = dateMath.parseDateMath("-2d", moment([2014, 1, 5]));
+ describe('relative time to date parsing', function() {
+ it('should handle negative time', function() {
+ var date = dateMath.parseDateMath('-2d', moment([2014, 1, 5]));
expect(date.valueOf()).toEqual(moment([2014, 1, 3]).valueOf());
});
- it("should handle multiple math expressions", function() {
- var date = dateMath.parseDateMath("-2d-6h", moment([2014, 1, 5]));
+ it('should handle multiple math expressions', function() {
+ var date = dateMath.parseDateMath('-2d-6h', moment([2014, 1, 5]));
expect(date.valueOf()).toEqual(moment([2014, 1, 2, 18]).valueOf());
});
- it("should return false when invalid expression", function() {
- var date = dateMath.parseDateMath("2", moment([2014, 1, 5]));
+ it('should return false when invalid expression', function() {
+ var date = dateMath.parseDateMath('2', moment([2014, 1, 5]));
expect(date).toEqual(undefined);
});
});
diff --git a/public/app/core/specs/emitter.jest.ts b/public/app/core/specs/emitter.jest.ts
index 849096d6191..a819cf0ede2 100644
--- a/public/app/core/specs/emitter.jest.ts
+++ b/public/app/core/specs/emitter.jest.ts
@@ -1,26 +1,26 @@
-import { Emitter } from "../utils/emitter";
+import { Emitter } from '../utils/emitter';
-describe("Emitter", () => {
- describe("given 2 subscribers", () => {
- it("should notfiy subscribers", () => {
+describe('Emitter', () => {
+ describe('given 2 subscribers', () => {
+ it('should notfiy subscribers', () => {
var events = new Emitter();
var sub1Called = false;
var sub2Called = false;
- events.on("test", () => {
+ events.on('test', () => {
sub1Called = true;
});
- events.on("test", () => {
+ events.on('test', () => {
sub2Called = true;
});
- events.emit("test", null);
+ events.emit('test', null);
expect(sub1Called).toBe(true);
expect(sub2Called).toBe(true);
});
- it("when subscribing twice", () => {
+ it('when subscribing twice', () => {
var events = new Emitter();
var sub1Called = 0;
@@ -28,33 +28,33 @@ describe("Emitter", () => {
sub1Called += 1;
}
- events.on("test", handler);
- events.on("test", handler);
+ events.on('test', handler);
+ events.on('test', handler);
- events.emit("test", null);
+ events.emit('test', null);
expect(sub1Called).toBe(2);
});
- it("should handle errors", () => {
+ it('should handle errors', () => {
var events = new Emitter();
var sub1Called = 0;
var sub2Called = 0;
- events.on("test", () => {
+ events.on('test', () => {
sub1Called++;
- throw { message: "hello" };
+ throw { message: 'hello' };
});
- events.on("test", () => {
+ events.on('test', () => {
sub2Called++;
});
try {
- events.emit("test", null);
+ events.emit('test', null);
} catch (_) {}
try {
- events.emit("test", null);
+ events.emit('test', null);
} catch (_) {}
expect(sub1Called).toBe(2);
diff --git a/public/app/core/specs/flatten.jest.ts b/public/app/core/specs/flatten.jest.ts
index 7ca98d8a0c7..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";
+import flatten from 'app/core/utils/flatten';
-describe("flatten", () => {
- it("should return flatten object", () => {
+describe('flatten', () => {
+ it('should return flatten object', () => {
var flattened = flatten(
{
- level1: "level1-value",
+ level1: 'level1-value',
deeper: {
- level2: "level2-value",
+ level2: 'level2-value',
deeper: {
- level3: "level3-value"
- }
- }
+ 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");
+ 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
index d444e822ecd..ba318b81cc7 100644
--- a/public/app/core/specs/global_event_srv.jest.ts
+++ b/public/app/core/specs/global_event_srv.jest.ts
@@ -1,23 +1,23 @@
-import { GlobalEventSrv } from "app/core/services/global_event_srv";
-import { beforeEach } from "test/lib/common";
+import { GlobalEventSrv } from 'app/core/services/global_event_srv';
+import { beforeEach } from 'test/lib/common';
-jest.mock("app/core/config", () => {
+jest.mock('app/core/config', () => {
return {
- appSubUrl: "/subUrl"
+ appSubUrl: '/subUrl',
};
});
-describe("GlobalEventSrv", () => {
+describe('GlobalEventSrv', () => {
let searchSrv;
beforeEach(() => {
- searchSrv = new GlobalEventSrv(null, null);
+ 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/");
+ 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 fef652522b9..4ba0e623784 100644
--- a/public/app/core/specs/kbn.jest.ts
+++ b/public/app/core/specs/kbn.jest.ts
@@ -1,29 +1,29 @@
-import kbn from "../utils/kbn";
-import * as dateMath from "../utils/datemath";
-import moment from "moment";
+import kbn from '../utils/kbn';
+import * as dateMath from '../utils/datemath';
+import moment from 'moment';
-describe("unit format menu", function() {
+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");
+ describe('submenu ' + submenu.text, function() {
+ it('should have a title', function() {
+ expect(typeof submenu.text).toBe('string');
});
- it("should have a submenu", function() {
+ it('should have a submenu', function() {
expect(Array.isArray(submenu.submenu)).toBe(true);
});
submenu.submenu.map(function(entry) {
- describe("entry " + entry.text, function() {
- it("should have a title", function() {
- expect(typeof entry.text).toBe("string");
+ 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 format', function() {
+ expect(typeof entry.value).toBe('string');
});
- it("should have a valid format", function() {
- expect(typeof kbn.valueFormats[entry.value]).toBe("function");
+ it('should have a valid format', function() {
+ expect(typeof kbn.valueFormats[entry.value]).toBe('function');
});
});
});
@@ -32,324 +32,319 @@ 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);
+ describe('value format: ' + desc, function() {
+ it('should translate ' + value + ' as ' + result, function() {
+ 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");
-describeValueFormat("ms", 100, 1, 0, "100 ms");
-describeValueFormat("ms", 1250, 10, 0, "1.25 s");
-describeValueFormat("ms", 1250, 300, 0, "1.3 s");
-describeValueFormat("ms", 65150, 10000, 0, "1.1 min");
-describeValueFormat("ms", 6515000, 1500000, 0, "1.8 hour");
-describeValueFormat("ms", 651500000, 150000000, 0, "8 day");
+describeValueFormat('ms', 0.0024, 0.0005, 4, '0.0024 ms');
+describeValueFormat('ms', 100, 1, 0, '100 ms');
+describeValueFormat('ms', 1250, 10, 0, '1.25 s');
+describeValueFormat('ms', 1250, 300, 0, '1.3 s');
+describeValueFormat('ms', 65150, 10000, 0, '1.1 min');
+describeValueFormat('ms', 6515000, 1500000, 0, '1.8 hour');
+describeValueFormat('ms', 651500000, 150000000, 0, '8 day');
-describeValueFormat("none", 2.75e-10, 0, 10, "3e-10");
-describeValueFormat("none", 0, 0, 2, "0");
-describeValueFormat("dB", 10, 1000, 2, "10.00 dB");
+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", 53, 0, 1, "53.0%");
-describeValueFormat("percentunit", 0.0, 0, 0, "0%");
-describeValueFormat("percentunit", 0.278, 0, 1, "27.8%");
-describeValueFormat("percentunit", 1.0, 0, 0, "100%");
+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%');
+describeValueFormat('percentunit', 1.0, 0, 0, '100%');
-describeValueFormat("currencyUSD", 7.42, 10000, 2, "$7.42");
-describeValueFormat("currencyUSD", 1532.82, 1000, 1, "$1.53K");
-describeValueFormat("currencyUSD", 18520408.7, 10000000, 0, "$19M");
+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.57e308, -1.57e308, 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");
+describeValueFormat('ns', 25, 1, 0, '25 ns');
+describeValueFormat('ns', 2558, 50, 0, '2.56 µs');
-describeValueFormat("ops", 123, 1, 0, "123 ops");
-describeValueFormat("rps", 456000, 1000, -1, "456K rps");
-describeValueFormat("rps", 123456789, 1000000, 2, "123.457M rps");
-describeValueFormat("wps", 789000000, 1000000, -1, "789M wps");
-describeValueFormat("iops", 11000000000, 1000000000, -1, "11B iops");
+describeValueFormat('ops', 123, 1, 0, '123 ops');
+describeValueFormat('rps', 456000, 1000, -1, '456K rps');
+describeValueFormat('rps', 123456789, 1000000, 2, '123.457M rps');
+describeValueFormat('wps', 789000000, 1000000, -1, '789M wps');
+describeValueFormat('iops', 11000000000, 1000000000, -1, '11B iops');
-describeValueFormat("s", 1.23456789e-7, 1e-10, 8, "123.5 ns");
-describeValueFormat("s", 1.23456789e-4, 1e-7, 5, "123.5 µs");
-describeValueFormat("s", 1.23456789e-3, 1e-6, 4, "1.235 ms");
-describeValueFormat("s", 1.23456789e-2, 1e-5, 3, "12.35 ms");
-describeValueFormat("s", 1.23456789e-1, 1e-4, 2, "123.5 ms");
-describeValueFormat("s", 24, 1, 0, "24 s");
-describeValueFormat("s", 246, 1, 0, "4.1 min");
-describeValueFormat("s", 24567, 100, 0, "6.82 hour");
-describeValueFormat("s", 24567890, 10000, 0, "40.62 week");
-describeValueFormat("s", 24567890000, 1000000, 0, "778.53 year");
+describeValueFormat('s', 1.23456789e-7, 1e-10, 8, '123.5 ns');
+describeValueFormat('s', 1.23456789e-4, 1e-7, 5, '123.5 µs');
+describeValueFormat('s', 1.23456789e-3, 1e-6, 4, '1.235 ms');
+describeValueFormat('s', 1.23456789e-2, 1e-5, 3, '12.35 ms');
+describeValueFormat('s', 1.23456789e-1, 1e-4, 2, '123.5 ms');
+describeValueFormat('s', 24, 1, 0, '24 s');
+describeValueFormat('s', 246, 1, 0, '4.1 min');
+describeValueFormat('s', 24567, 100, 0, '6.82 hour');
+describeValueFormat('s', 24567890, 10000, 0, '40.62 week');
+describeValueFormat('s', 24567890000, 1000000, 0, '778.53 year');
-describeValueFormat("m", 24, 1, 0, "24 min");
-describeValueFormat("m", 246, 10, 0, "4.1 hour");
-describeValueFormat("m", 6545, 10, 0, "4.55 day");
-describeValueFormat("m", 24567, 100, 0, "2.44 week");
-describeValueFormat("m", 24567892, 10000, 0, "46.7 year");
+describeValueFormat('m', 24, 1, 0, '24 min');
+describeValueFormat('m', 246, 10, 0, '4.1 hour');
+describeValueFormat('m', 6545, 10, 0, '4.55 day');
+describeValueFormat('m', 24567, 100, 0, '2.44 week');
+describeValueFormat('m', 24567892, 10000, 0, '46.7 year');
-describeValueFormat("h", 21, 1, 0, "21 hour");
-describeValueFormat("h", 145, 1, 0, "6.04 day");
-describeValueFormat("h", 1234, 100, 0, "7.3 week");
-describeValueFormat("h", 9458, 1000, 0, "1.08 year");
+describeValueFormat('h', 21, 1, 0, '21 hour');
+describeValueFormat('h', 145, 1, 0, '6.04 day');
+describeValueFormat('h', 1234, 100, 0, '7.3 week');
+describeValueFormat('h', 9458, 1000, 0, '1.08 year');
-describeValueFormat("d", 3, 1, 0, "3 day");
-describeValueFormat("d", 245, 100, 0, "35 week");
-describeValueFormat("d", 2456, 10, 0, "6.73 year");
+describeValueFormat('d', 3, 1, 0, '3 day');
+describeValueFormat('d', 245, 100, 0, '35 week');
+describeValueFormat('d', 2456, 10, 0, '6.73 year');
-describe("date time formats", function() {
- it("should format as iso date", function() {
+describe('date time formats', function() {
+ it('should format as iso date', function() {
var str = kbn.valueFormats.dateTimeAsIso(1505634997920, 1);
- expect(str).toBe(moment(1505634997920).format("YYYY-MM-DD HH:mm:ss"));
+ expect(str).toBe(moment(1505634997920).format('YYYY-MM-DD HH:mm:ss'));
});
- it("should format as iso date and skip date when today", 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() {
+ it('should format as US date', function() {
var str = kbn.valueFormats.dateTimeAsUS(1505634997920, 1);
- expect(str).toBe(moment(1505634997920).format("MM/DD/YYYY h:mm:ss a"));
+ expect(str).toBe(moment(1505634997920).format('MM/DD/YYYY h:mm:ss a'));
});
- it("should format as US date and skip date when today", 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() {
- var daysAgo = moment().add(-7, "d");
+ it('should format as from now with days', function() {
+ var daysAgo = moment().add(-7, 'd');
var str = kbn.valueFormats.dateTimeFromNow(daysAgo.valueOf(), 1);
- expect(str).toBe("7 days ago");
+ expect(str).toBe('7 days ago');
});
- it("should format as from now with minutes", function() {
- var daysAgo = moment().add(-2, "m");
+ it('should format as from now with minutes', function() {
+ var daysAgo = moment().add(-2, 'm');
var str = kbn.valueFormats.dateTimeFromNow(daysAgo.valueOf(), 1);
- expect(str).toBe("2 minutes ago");
+ expect(str).toBe('2 minutes ago');
});
});
-describe("kbn.toFixed and negative decimals", function() {
- it("should treat as zero decimals", function() {
+describe('kbn.toFixed and negative decimals', function() {
+ it('should treat as zero decimals', function() {
var str = kbn.toFixed(186.123, -2);
- expect(str).toBe("186");
+ expect(str).toBe('186');
});
});
-describe("kbn ms format when scaled decimals is null do not use it", function() {
- it("should use specified decimals", function() {
- var str = kbn.valueFormats["ms"](10000086.123, 1, null);
- expect(str).toBe("2.8 hour");
+describe('kbn ms format when scaled decimals is null do not use it', function() {
+ it('should use specified decimals', function() {
+ var str = kbn.valueFormats['ms'](10000086.123, 1, null);
+ expect(str).toBe('2.8 hour');
});
});
-describe("kbn kbytes format when scaled decimals is null do not use it", function() {
- it("should use specified decimals", function() {
- var str = kbn.valueFormats["kbytes"](10000000, 3, null);
- expect(str).toBe("9.537 GiB");
+describe('kbn kbytes format when scaled decimals is null do not use it', function() {
+ it('should use specified decimals', function() {
+ var str = kbn.valueFormats['kbytes'](10000000, 3, null);
+ expect(str).toBe('9.537 GiB');
});
});
-describe("kbn deckbytes format when scaled decimals is null do not use it", function() {
- it("should use specified decimals", function() {
- var str = kbn.valueFormats["deckbytes"](10000000, 3, null);
- expect(str).toBe("10.000 GB");
+describe('kbn deckbytes format when scaled decimals is null do not use it', function() {
+ it('should use specified decimals', function() {
+ var str = kbn.valueFormats['deckbytes'](10000000, 3, null);
+ expect(str).toBe('10.000 GB');
});
});
-describe("kbn roundValue", function() {
- it("should should handle null value", function() {
+describe('kbn roundValue', function() {
+ it('should should handle null value', function() {
var str = kbn.roundValue(null, 2);
expect(str).toBe(null);
});
- it("should round value", function() {
+ it('should round value', function() {
var str = kbn.roundValue(200.877, 2);
expect(str).toBe(200.88);
});
});
-describe("calculateInterval", function() {
- it("1h 100 resultion", function() {
- var range = { from: dateMath.parse("now-1h"), to: dateMath.parse("now") };
+describe('calculateInterval', function() {
+ it('1h 100 resultion', function() {
+ var range = { from: dateMath.parse('now-1h'), to: dateMath.parse('now') };
var res = kbn.calculateInterval(range, 100, null);
- expect(res.interval).toBe("30s");
+ expect(res.interval).toBe('30s');
});
- it("10m 1600 resolution", function() {
- var range = { from: dateMath.parse("now-10m"), to: dateMath.parse("now") };
+ it('10m 1600 resolution', function() {
+ var range = { from: dateMath.parse('now-10m'), to: dateMath.parse('now') };
var res = kbn.calculateInterval(range, 1600, null);
- expect(res.interval).toBe("500ms");
+ expect(res.interval).toBe('500ms');
expect(res.intervalMs).toBe(500);
});
- it("fixed user min interval", function() {
- var range = { from: dateMath.parse("now-10m"), to: dateMath.parse("now") };
- var res = kbn.calculateInterval(range, 1600, "10s");
- expect(res.interval).toBe("10s");
+ it('fixed user min interval', function() {
+ 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);
});
- it("short time range and user low limit", function() {
- var range = { from: dateMath.parse("now-10m"), to: dateMath.parse("now") };
- var res = kbn.calculateInterval(range, 1600, ">10s");
- expect(res.interval).toBe("10s");
+ it('short time range and user low limit', function() {
+ var range = { from: dateMath.parse('now-10m'), to: dateMath.parse('now') };
+ var res = kbn.calculateInterval(range, 1600, '>10s');
+ expect(res.interval).toBe('10s');
});
- it("large time range and user low limit", function() {
- var range = { from: dateMath.parse("now-14d"), to: dateMath.parse("now") };
- var res = kbn.calculateInterval(range, 1000, ">10s");
- expect(res.interval).toBe("20m");
+ it('large time range and user low limit', function() {
+ var range = { from: dateMath.parse('now-14d'), to: dateMath.parse('now') };
+ var res = kbn.calculateInterval(range, 1000, '>10s');
+ expect(res.interval).toBe('20m');
});
- it("10s 900 resolution and user low limit in ms", function() {
- var range = { from: dateMath.parse("now-10s"), to: dateMath.parse("now") };
- var res = kbn.calculateInterval(range, 900, ">15ms");
- expect(res.interval).toBe("15ms");
+ it('10s 900 resolution and user low limit in ms', function() {
+ var range = { from: dateMath.parse('now-10s'), to: dateMath.parse('now') };
+ var res = kbn.calculateInterval(range, 900, '>15ms');
+ expect(res.interval).toBe('15ms');
});
- it("1d 1 resolution", function() {
- var range = { from: dateMath.parse("now-1d"), to: dateMath.parse("now") };
+ it('1d 1 resolution', function() {
+ var range = { from: dateMath.parse('now-1d'), to: dateMath.parse('now') };
var res = kbn.calculateInterval(range, 1, null);
- expect(res.interval).toBe("1d");
+ expect(res.interval).toBe('1d');
expect(res.intervalMs).toBe(86400000);
});
- it("86399s 1 resolution", function() {
+ it('86399s 1 resolution', function() {
var range = {
- from: dateMath.parse("now-86390s"),
- to: dateMath.parse("now")
+ from: dateMath.parse('now-86390s'),
+ to: dateMath.parse('now'),
};
var res = kbn.calculateInterval(range, 1, null);
- expect(res.interval).toBe("12h");
+ expect(res.interval).toBe('12h');
expect(res.intervalMs).toBe(43200000);
});
});
-describe("hex", function() {
- it("positive integer", function() {
+describe('hex', function() {
+ it('positive integer', function() {
var str = kbn.valueFormats.hex(100, 0);
- expect(str).toBe("64");
+ expect(str).toBe('64');
});
- it("negative integer", function() {
+ it('negative integer', function() {
var str = kbn.valueFormats.hex(-100, 0);
- expect(str).toBe("-64");
+ expect(str).toBe('-64');
});
- it("null", function() {
+ it('null', function() {
var str = kbn.valueFormats.hex(null, 0);
- expect(str).toBe("");
+ expect(str).toBe('');
});
- it("positive float", function() {
+ it('positive float', function() {
var str = kbn.valueFormats.hex(50.52, 1);
- expect(str).toBe("32.8");
+ expect(str).toBe('32.8');
});
- it("negative float", function() {
+ it('negative float', function() {
var str = kbn.valueFormats.hex(-50.333, 2);
- expect(str).toBe("-32.547AE147AE14");
+ expect(str).toBe('-32.547AE147AE14');
});
});
-describe("hex 0x", function() {
- it("positive integeter", function() {
+describe('hex 0x', function() {
+ it('positive integeter', function() {
var str = kbn.valueFormats.hex0x(7999, 0);
- expect(str).toBe("0x1F3F");
+ expect(str).toBe('0x1F3F');
});
- it("negative integer", function() {
+ it('negative integer', function() {
var str = kbn.valueFormats.hex0x(-584, 0);
- expect(str).toBe("-0x248");
+ expect(str).toBe('-0x248');
});
- it("null", function() {
+ it('null', function() {
var str = kbn.valueFormats.hex0x(null, 0);
- expect(str).toBe("");
+ expect(str).toBe('');
});
- it("positive float", function() {
+ it('positive float', function() {
var str = kbn.valueFormats.hex0x(74.443, 3);
- expect(str).toBe("0x4A.716872B020C4");
+ expect(str).toBe('0x4A.716872B020C4');
});
- it("negative float", function() {
+ it('negative float', function() {
var str = kbn.valueFormats.hex0x(-65.458, 1);
- expect(str).toBe("-0x41.8");
+ expect(str).toBe('-0x41.8');
});
});
-describe("duration", function() {
- it("null", function() {
- var str = kbn.toDuration(null, 0, "millisecond");
- expect(str).toBe("");
+describe('duration', function() {
+ it('null', function() {
+ var str = kbn.toDuration(null, 0, 'millisecond');
+ expect(str).toBe('');
});
- it("0 milliseconds", function() {
- var str = kbn.toDuration(0, 0, "millisecond");
- expect(str).toBe("0 milliseconds");
+ it('0 milliseconds', function() {
+ var str = kbn.toDuration(0, 0, 'millisecond');
+ expect(str).toBe('0 milliseconds');
});
- it("1 millisecond", function() {
- var str = kbn.toDuration(1, 0, "millisecond");
- expect(str).toBe("1 millisecond");
+ it('1 millisecond', function() {
+ var str = kbn.toDuration(1, 0, 'millisecond');
+ expect(str).toBe('1 millisecond');
});
- it("-1 millisecond", function() {
- var str = kbn.toDuration(-1, 0, "millisecond");
- expect(str).toBe("1 millisecond ago");
+ it('-1 millisecond', function() {
+ var str = kbn.toDuration(-1, 0, 'millisecond');
+ expect(str).toBe('1 millisecond ago');
});
- it("seconds", function() {
- var str = kbn.toDuration(1, 0, "second");
- expect(str).toBe("1 second");
+ it('seconds', function() {
+ var str = kbn.toDuration(1, 0, 'second');
+ expect(str).toBe('1 second');
});
- it("minutes", function() {
- var str = kbn.toDuration(1, 0, "minute");
- expect(str).toBe("1 minute");
+ it('minutes', function() {
+ var str = kbn.toDuration(1, 0, 'minute');
+ expect(str).toBe('1 minute');
});
- it("hours", function() {
- var str = kbn.toDuration(1, 0, "hour");
- expect(str).toBe("1 hour");
+ it('hours', function() {
+ var str = kbn.toDuration(1, 0, 'hour');
+ expect(str).toBe('1 hour');
});
- it("days", function() {
- var str = kbn.toDuration(1, 0, "day");
- expect(str).toBe("1 day");
+ it('days', function() {
+ var str = kbn.toDuration(1, 0, 'day');
+ expect(str).toBe('1 day');
});
- it("weeks", function() {
- var str = kbn.toDuration(1, 0, "week");
- expect(str).toBe("1 week");
+ it('weeks', function() {
+ var str = kbn.toDuration(1, 0, 'week');
+ expect(str).toBe('1 week');
});
- it("months", function() {
- var str = kbn.toDuration(1, 0, "month");
- expect(str).toBe("1 month");
+ it('months', function() {
+ var str = kbn.toDuration(1, 0, 'month');
+ expect(str).toBe('1 month');
});
- it("years", function() {
- var str = kbn.toDuration(1, 0, "year");
- expect(str).toBe("1 year");
+ it('years', function() {
+ var str = kbn.toDuration(1, 0, 'year');
+ expect(str).toBe('1 year');
});
- it("decimal days", function() {
- var str = kbn.toDuration(1.5, 2, "day");
- expect(str).toBe("1 day, 12 hours, 0 minutes");
+ it('decimal days', function() {
+ 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");
- expect(str).toBe("1 month, 2 weeks, 1 day, 0 hours");
+ it('decimal months', function() {
+ 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");
- expect(str).toBe("1 year");
+ it('no decimals', function() {
+ var str = kbn.toDuration(38898367008, 0, 'millisecond');
+ expect(str).toBe('1 year');
});
- it("1 decimal", function() {
- var str = kbn.toDuration(38898367008, 1, "millisecond");
- expect(str).toBe("1 year, 2 months");
+ it('1 decimal', function() {
+ 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"
- );
+ 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');
});
- 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"
- );
+ 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');
});
});
diff --git a/public/app/core/specs/manage_dashboards.jest.ts b/public/app/core/specs/manage_dashboards.jest.ts
index 3534050d553..bd257c32f9b 100644
--- a/public/app/core/specs/manage_dashboards.jest.ts
+++ b/public/app/core/specs/manage_dashboards.jest.ts
@@ -1,58 +1,58 @@
-import { ManageDashboardsCtrl } from "app/core/components/manage_dashboards/manage_dashboards";
-import { SearchSrv } from "app/core/services/search_srv";
-import q from "q";
+import { ManageDashboardsCtrl } from 'app/core/components/manage_dashboards/manage_dashboards';
+import { SearchSrv } from 'app/core/services/search_srv';
+import q from 'q';
-describe("ManageDashboards", () => {
+describe('ManageDashboards', () => {
let ctrl;
- describe("when browsing dashboards", () => {
+ describe('when browsing dashboards', () => {
beforeEach(() => {
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",
- icon: "fa fa-folder",
+ 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,
},
{
id: 0,
- title: "Root",
- icon: "fa fa-folder-open",
- uri: "db/something-else",
- type: "dash-db",
+ 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",
+ title: 'Dashboard Test',
+ url: 'dashboard/db/dashboard-test',
+ icon: 'fa fa-folder',
tags: [],
- isStarred: false
- }
+ isStarred: false,
+ },
],
tags: [],
- isStarred: false
- }
+ isStarred: false,
+ },
];
ctrl = createCtrlWithStubs(response);
return ctrl.getDashboards();
});
- it("should set checked to false on all sections and children", () => {
+ it('should set checked to false on all sections and children', () => {
expect(ctrl.sections.length).toEqual(2);
expect(ctrl.sections[0].checked).toEqual(false);
expect(ctrl.sections[0].items[0].checked).toEqual(false);
@@ -62,41 +62,41 @@ describe("ManageDashboards", () => {
});
});
- describe("when browsing dashboards for a folder", () => {
+ describe('when browsing dashboards for a folder', () => {
beforeEach(() => {
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",
- icon: "fa fa-folder",
+ 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;
return ctrl.getDashboards();
});
- it("should set hide header to true on section", () => {
+ it('should set hide header to true on section', () => {
expect(ctrl.sections[0].hideHeader).toBeTruthy();
});
});
- describe("when searching dashboards", () => {
+ describe('when searching dashboards', () => {
beforeEach(() => {
const response = [
{
@@ -106,121 +106,121 @@ describe("ManageDashboards", () => {
items: [
{
id: 399,
- title: "Dashboard Test",
- url: "dashboard/db/dashboard-test",
- icon: "fa fa-folder",
+ 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",
- icon: "fa fa-folder",
+ title: 'Dashboard Test',
+ url: 'dashboard/db/dashboard-test',
+ icon: 'fa fa-folder',
tags: [],
folderId: 499,
- isStarred: false
- }
- ]
- }
+ isStarred: false,
+ },
+ ],
+ },
];
ctrl = createCtrlWithStubs(response);
});
- describe("with query filter", () => {
+ describe('with query filter', () => {
beforeEach(() => {
- ctrl.query.query = "d";
+ ctrl.query.query = 'd';
ctrl.canMove = true;
ctrl.canDelete = true;
ctrl.selectAllChecked = true;
return ctrl.getDashboards();
});
- it("should set checked to false on all sections and children", () => {
+ it('should set checked to false on all sections and children', () => {
expect(ctrl.sections.length).toEqual(1);
expect(ctrl.sections[0].checked).toEqual(false);
expect(ctrl.sections[0].items[0].checked).toEqual(false);
expect(ctrl.sections[0].items[1].checked).toEqual(false);
});
- it("should uncheck select all", () => {
+ it('should uncheck select all', () => {
expect(ctrl.selectAllChecked).toBeFalsy();
});
- it("should disable Move To button", () => {
+ it('should disable Move To button', () => {
expect(ctrl.canMove).toBeFalsy();
});
- it("should disable delete button", () => {
+ it('should disable delete button', () => {
expect(ctrl.canDelete).toBeFalsy();
});
- it("should have active filters", () => {
+ it('should have active filters', () => {
expect(ctrl.hasFilters).toBeTruthy();
});
- describe("when select all is checked", () => {
+ describe('when select all is checked', () => {
beforeEach(() => {
ctrl.selectAllChecked = true;
ctrl.onSelectAllChanged();
});
- it("should select all dashboards", () => {
+ it('should select all dashboards', () => {
expect(ctrl.sections[0].checked).toBeFalsy();
expect(ctrl.sections[0].items[0].checked).toBeTruthy();
expect(ctrl.sections[0].items[1].checked).toBeTruthy();
});
- it("should enable Move To button", () => {
+ it('should enable Move To button', () => {
expect(ctrl.canMove).toBeTruthy();
});
- it("should enable delete button", () => {
+ it('should enable delete button', () => {
expect(ctrl.canDelete).toBeTruthy();
});
- describe("when clearing filters", () => {
+ describe('when clearing filters', () => {
beforeEach(() => {
return ctrl.clearFilters();
});
- it("should reset query filter", () => {
- expect(ctrl.query.query).toEqual("");
+ it('should reset query filter', () => {
+ expect(ctrl.query.query).toEqual('');
});
});
});
});
- describe("with tag filter", () => {
+ describe('with tag filter', () => {
beforeEach(() => {
- return ctrl.filterByTag("test");
+ return ctrl.filterByTag('test');
});
- it("should set tag filter", () => {
+ it('should set tag filter', () => {
expect(ctrl.sections.length).toEqual(1);
- expect(ctrl.query.tag[0]).toEqual("test");
+ expect(ctrl.query.tag[0]).toEqual('test');
});
- it("should have active filters", () => {
+ it('should have active filters', () => {
expect(ctrl.hasFilters).toBeTruthy();
});
- describe("when clearing filters", () => {
+ describe('when clearing filters', () => {
beforeEach(() => {
return ctrl.clearFilters();
});
- it("should reset tag filter", () => {
+ it('should reset tag filter', () => {
expect(ctrl.query.tag.length).toEqual(0);
});
});
});
- describe("with starred filter", () => {
+ describe('with starred filter', () => {
beforeEach(() => {
const yesOption: any = ctrl.starredFilterOptions[1];
@@ -228,253 +228,253 @@ describe("ManageDashboards", () => {
return ctrl.onStarredFilterChange();
});
- it("should set starred filter", () => {
+ it('should set starred filter', () => {
expect(ctrl.sections.length).toEqual(1);
expect(ctrl.query.starred).toEqual(true);
});
- it("should have active filters", () => {
+ it('should have active filters', () => {
expect(ctrl.hasFilters).toBeTruthy();
});
- describe("when clearing filters", () => {
+ describe('when clearing filters', () => {
beforeEach(() => {
return ctrl.clearFilters();
});
- it("should reset starred filter", () => {
+ it('should reset starred filter', () => {
expect(ctrl.query.starred).toEqual(false);
});
});
});
});
- describe("when selecting dashboards", () => {
+ describe('when selecting dashboards', () => {
let ctrl;
beforeEach(() => {
ctrl = createCtrlWithStubs([]);
});
- describe("and no dashboards are selected", () => {
+ describe('and no dashboards are selected', () => {
beforeEach(() => {
ctrl.sections = [
{
id: 1,
items: [{ id: 2, checked: false }],
- checked: false
+ checked: false,
},
{
id: 0,
items: [{ id: 3, checked: false }],
- checked: false
- }
+ checked: false,
+ },
];
ctrl.selectionChanged();
});
- it("should disable Move To button", () => {
+ it('should disable Move To button', () => {
expect(ctrl.canMove).toBeFalsy();
});
- it("should disable delete button", () => {
+ it('should disable delete button', () => {
expect(ctrl.canDelete).toBeFalsy();
});
- describe("when select all is checked", () => {
+ describe('when select all is checked', () => {
beforeEach(() => {
ctrl.selectAllChecked = true;
ctrl.onSelectAllChanged();
});
- it("should select all folders and dashboards", () => {
+ it('should select all folders and dashboards', () => {
expect(ctrl.sections[0].checked).toBeTruthy();
expect(ctrl.sections[0].items[0].checked).toBeTruthy();
expect(ctrl.sections[1].checked).toBeTruthy();
expect(ctrl.sections[1].items[0].checked).toBeTruthy();
});
- it("should enable Move To button", () => {
+ it('should enable Move To button', () => {
expect(ctrl.canMove).toBeTruthy();
});
- it("should enable delete button", () => {
+ it('should enable delete button', () => {
expect(ctrl.canDelete).toBeTruthy();
});
});
});
- describe("and all folders and dashboards are selected", () => {
+ describe('and all folders and dashboards are selected', () => {
beforeEach(() => {
ctrl.sections = [
{
id: 1,
items: [{ id: 2, checked: true }],
- checked: true
+ checked: true,
},
{
id: 0,
items: [{ id: 3, checked: true }],
- checked: true
- }
+ checked: true,
+ },
];
ctrl.selectionChanged();
});
- it("should enable Move To button", () => {
+ it('should enable Move To button', () => {
expect(ctrl.canMove).toBeTruthy();
});
- it("should enable delete button", () => {
+ it('should enable delete button', () => {
expect(ctrl.canDelete).toBeTruthy();
});
- describe("when select all is unchecked", () => {
+ describe('when select all is unchecked', () => {
beforeEach(() => {
ctrl.selectAllChecked = false;
ctrl.onSelectAllChanged();
});
- it("should uncheck all checked folders and dashboards", () => {
+ it('should uncheck all checked folders and dashboards', () => {
expect(ctrl.sections[0].checked).toBeFalsy();
expect(ctrl.sections[0].items[0].checked).toBeFalsy();
expect(ctrl.sections[1].checked).toBeFalsy();
expect(ctrl.sections[1].items[0].checked).toBeFalsy();
});
- it("should disable Move To button", () => {
+ it('should disable Move To button', () => {
expect(ctrl.canMove).toBeFalsy();
});
- it("should disable delete button", () => {
+ it('should disable delete button', () => {
expect(ctrl.canDelete).toBeFalsy();
});
});
});
- describe("and one dashboard in root is selected", () => {
+ describe('and one dashboard in root is selected', () => {
beforeEach(() => {
ctrl.sections = [
{
id: 1,
- title: "folder",
+ title: 'folder',
items: [{ id: 2, checked: false }],
- checked: false
+ checked: false,
},
{
id: 0,
- title: "Root",
+ title: 'Root',
items: [{ id: 3, checked: true }],
- checked: false
- }
+ checked: false,
+ },
];
ctrl.selectionChanged();
});
- it("should enable Move To button", () => {
+ it('should enable Move To button', () => {
expect(ctrl.canMove).toBeTruthy();
});
- it("should enable delete button", () => {
+ it('should enable delete button', () => {
expect(ctrl.canDelete).toBeTruthy();
});
});
- describe("and one child dashboard is selected", () => {
+ describe('and one child dashboard is selected', () => {
beforeEach(() => {
ctrl.sections = [
{
id: 1,
- title: "folder",
+ title: 'folder',
items: [{ id: 2, checked: true }],
- checked: false
+ checked: false,
},
{
id: 0,
- title: "Root",
+ title: 'Root',
items: [{ id: 3, checked: false }],
- checked: false
- }
+ checked: false,
+ },
];
ctrl.selectionChanged();
});
- it("should enable Move To button", () => {
+ it('should enable Move To button', () => {
expect(ctrl.canMove).toBeTruthy();
});
- it("should enable delete button", () => {
+ it('should enable delete button', () => {
expect(ctrl.canDelete).toBeTruthy();
});
});
- describe("and one child dashboard and one dashboard is selected", () => {
+ describe('and one child dashboard and one dashboard is selected', () => {
beforeEach(() => {
ctrl.sections = [
{
id: 1,
- title: "folder",
+ title: 'folder',
items: [{ id: 2, checked: true }],
- checked: false
+ checked: false,
},
{
id: 0,
- title: "Root",
+ title: 'Root',
items: [{ id: 3, checked: true }],
- checked: false
- }
+ checked: false,
+ },
];
ctrl.selectionChanged();
});
- it("should enable Move To button", () => {
+ it('should enable Move To button', () => {
expect(ctrl.canMove).toBeTruthy();
});
- it("should enable delete button", () => {
+ it('should enable delete button', () => {
expect(ctrl.canDelete).toBeTruthy();
});
});
- describe("and one child dashboard and one folder is selected", () => {
+ describe('and one child dashboard and one folder is selected', () => {
beforeEach(() => {
ctrl.sections = [
{
id: 1,
- title: "folder",
+ title: 'folder',
items: [{ id: 2, checked: false }],
- checked: true
+ checked: true,
},
{
id: 3,
- title: "folder",
+ title: 'folder',
items: [{ id: 4, checked: true }],
- checked: false
+ checked: false,
},
{
id: 0,
- title: "Root",
+ title: 'Root',
items: [{ id: 3, checked: false }],
- checked: false
- }
+ checked: false,
+ },
];
ctrl.selectionChanged();
});
- it("should enable Move To button", () => {
+ it('should enable Move To button', () => {
expect(ctrl.canMove).toBeTruthy();
});
- it("should enable delete button", () => {
+ it('should enable delete button', () => {
expect(ctrl.canDelete).toBeTruthy();
});
});
});
- describe("when deleting dashboards", () => {
+ describe('when deleting dashboards', () => {
let toBeDeleted: any;
beforeEach(() => {
@@ -483,76 +483,76 @@ describe("ManageDashboards", () => {
ctrl.sections = [
{
id: 1,
- title: "folder",
- items: [{ id: 2, checked: true, slug: "folder-dash" }],
+ title: 'folder',
+ 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" }],
+ title: 'folder-2',
+ 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
- }
+ title: 'Root',
+ items: [{ id: 3, checked: true, slug: 'root-dash' }],
+ checked: true,
+ },
];
toBeDeleted = ctrl.getFoldersAndDashboardsToDelete();
});
- it("should return 1 folder", () => {
+ it('should return 1 folder', () => {
expect(toBeDeleted.folders.length).toEqual(1);
});
- it("should return 2 dashboards", () => {
+ it('should return 2 dashboards', () => {
expect(toBeDeleted.dashboards.length).toEqual(2);
});
- it("should filter out children if parent is checked", () => {
- expect(toBeDeleted.folders[0]).toEqual("folder");
+ it('should filter out children if parent is checked', () => {
+ expect(toBeDeleted.folders[0]).toEqual('folder');
});
- it("should not filter out children if parent not is checked", () => {
- expect(toBeDeleted.dashboards[0]).toEqual("folder-2-dash");
+ it('should not filter out children if parent not is checked', () => {
+ expect(toBeDeleted.dashboards[0]).toEqual('folder-2-dash');
});
- it("should not filter out children if parent is checked and root", () => {
- expect(toBeDeleted.dashboards[1]).toEqual("root-dash");
+ it('should not filter out children if parent is checked and root', () => {
+ expect(toBeDeleted.dashboards[1]).toEqual('root-dash');
});
});
- describe("when moving dashboards", () => {
+ describe('when moving dashboards', () => {
beforeEach(() => {
ctrl = createCtrlWithStubs([]);
ctrl.sections = [
{
id: 1,
- title: "folder",
- items: [{ id: 2, checked: true, slug: "dash" }],
+ title: 'folder',
+ 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
- }
+ title: 'Root',
+ items: [{ id: 3, checked: true, slug: 'dash-2' }],
+ checked: false,
+ },
];
});
- it("should get selected dashboards", () => {
+ it('should get selected dashboards', () => {
const toBeMove = ctrl.getDashboardsToMove();
expect(toBeMove.length).toEqual(2);
- expect(toBeMove[0]).toEqual("dash");
- expect(toBeMove[1]).toEqual("dash-2");
+ expect(toBeMove[0]).toEqual('dash');
+ expect(toBeMove[1]).toEqual('dash-2');
});
});
});
@@ -564,12 +564,8 @@ 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 d1da0948f48..06172604069 100644
--- a/public/app/core/specs/org_switcher.jest.ts
+++ b/public/app/core/specs/org_switcher.jest.ts
@@ -1,14 +1,14 @@
-import { OrgSwitchCtrl } from "../components/org_switcher";
-import q from "q";
+import { OrgSwitchCtrl } from '../components/org_switcher';
+import q from 'q';
-jest.mock("app/core/services/context_srv", () => ({
+jest.mock('app/core/services/context_srv', () => ({
contextSrv: {
- user: { orgId: 1 }
- }
+ user: { orgId: 1 },
+ },
}));
-describe("OrgSwitcher", () => {
- describe("when switching org", () => {
+describe('OrgSwitcher', () => {
+ describe('when switching org', () => {
let expectedHref;
let expectedUsingUrl;
@@ -20,26 +20,23 @@ describe("OrgSwitcher", () => {
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.getWindowLocationHref = () => 'http://localhost:3000?orgId=1&from=now-3h&to=now';
orgSwitcherCtrl.setWindowLocationHref = href => (expectedHref = href);
return orgSwitcherCtrl.setUsingOrg({ orgId: 2 });
});
- it("should switch orgId in call to backend", () => {
- expect(expectedUsingUrl).toBe("/api/user/using/2");
+ it('should switch orgId in call to backend', () => {
+ expect(expectedUsingUrl).toBe('/api/user/using/2');
});
- it("should switch orgId in url", () => {
- expect(expectedHref).toBe(
- "http://localhost:3000?orgId=2&from=now-3h&to=now"
- );
+ it('should switch orgId in url', () => {
+ 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 aa1d2ac414a..6bfc0503900 100644
--- a/public/app/core/specs/rangeutil.jest.ts
+++ b/public/app/core/specs/rangeutil.jest.ts
@@ -1,120 +1,117 @@
-import * as rangeUtil from "app/core/utils/rangeutil";
-import _ from "lodash";
-import moment from "moment";
+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", () => {
- it("when custom settings should return default range list", () => {
- var groups = rangeUtil.getRelativeTimesList(
- { time_options: [] },
- "Last 5 minutes"
- );
+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');
expect(_.keys(groups).length).toBe(4);
expect(groups[3][0].active).toBe(true);
});
});
- 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");
+ 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');
});
- it("should have singular when amount is 1", () => {
- var info = rangeUtil.describeTextRange("1h");
- expect(info.display).toBe("Last 1 hour");
+ it('should have singular when amount is 1', () => {
+ var info = rangeUtil.describeTextRange('1h');
+ expect(info.display).toBe('Last 1 hour');
});
- it("should handle non default amount", () => {
- var info = rangeUtil.describeTextRange("13h");
- expect(info.display).toBe("Last 13 hours");
- expect(info.from).toBe("now-13h");
+ it('should handle non default amount', () => {
+ var info = rangeUtil.describeTextRange('13h');
+ expect(info.display).toBe('Last 13 hours');
+ expect(info.from).toBe('now-13h');
});
- it("should handle non default future amount", () => {
- var info = rangeUtil.describeTextRange("+3h");
- expect(info.display).toBe("Next 3 hours");
- expect(info.from).toBe("now");
- expect(info.to).toBe("now+3h");
+ it('should handle non default future amount', () => {
+ var info = rangeUtil.describeTextRange('+3h');
+ expect(info.display).toBe('Next 3 hours');
+ expect(info.from).toBe('now');
+ expect(info.to).toBe('now+3h');
});
- it("should handle now/d", () => {
- var info = rangeUtil.describeTextRange("now/d");
- expect(info.display).toBe("Today so far");
+ it('should handle now/d', () => {
+ var info = rangeUtil.describeTextRange('now/d');
+ expect(info.display).toBe('Today so far');
});
- it("should handle now/w", () => {
- var info = rangeUtil.describeTextRange("now/w");
- expect(info.display).toBe("This week so far");
+ it('should handle now/w', () => {
+ var info = rangeUtil.describeTextRange('now/w');
+ expect(info.display).toBe('This week so far');
});
- it("should handle now/M", () => {
- var info = rangeUtil.describeTextRange("now/M");
- expect(info.display).toBe("This month so far");
+ it('should handle now/M', () => {
+ var info = rangeUtil.describeTextRange('now/M');
+ expect(info.display).toBe('This month so far');
});
- it("should handle now/y", () => {
- var info = rangeUtil.describeTextRange("now/y");
- expect(info.display).toBe("This year so far");
+ it('should handle now/y', () => {
+ var info = rangeUtil.describeTextRange('now/y');
+ expect(info.display).toBe('This year so far');
});
});
- describe("Can get date range described", () => {
- it("Date range with simple ranges", () => {
- var text = rangeUtil.describeTimeRange({ from: "now-1h", to: "now" });
- expect(text).toBe("Last 1 hour");
+ describe('Can get date range described', () => {
+ it('Date range with simple ranges', () => {
+ 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" });
- expect(text).toBe("now/d+6h to now");
+ it('Date range with rounding ranges', () => {
+ 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", () => {
+ it('Date range with absolute to now', () => {
var text = rangeUtil.describeTimeRange({
from: moment([2014, 10, 10, 2, 3, 4]),
- to: "now"
+ to: 'now',
});
- expect(text).toBe("Nov 10, 2014 02:03:04 to a few seconds ago");
+ expect(text).toBe('Nov 10, 2014 02:03:04 to a few seconds ago');
});
- it("Date range with absolute to relative", () => {
+ it('Date range with absolute to relative', () => {
var text = rangeUtil.describeTimeRange({
from: moment([2014, 10, 10, 2, 3, 4]),
- to: "now-1d"
+ to: 'now-1d',
});
- expect(text).toBe("Nov 10, 2014 02:03:04 to a day ago");
+ expect(text).toBe('Nov 10, 2014 02:03:04 to a day ago');
});
- it("Date range with relative to absolute", () => {
+ it('Date range with relative to absolute', () => {
var text = rangeUtil.describeTimeRange({
- from: "now-7d",
- to: moment([2014, 10, 10, 2, 3, 4])
+ from: 'now-7d',
+ to: moment([2014, 10, 10, 2, 3, 4]),
});
- expect(text).toBe("7 days ago to Nov 10, 2014 02:03:04");
+ 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" });
- expect(text).toBe("Last 13 hours");
+ it('Date range with non matching default ranges', () => {
+ 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" });
- expect(text).toBe("now-6h to now-3h");
+ it('Date range with from and to both are in now-* format', () => {
+ 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", () => {
+ 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"
+ from: 'now/d+6h',
+ to: 'now-3h',
});
- expect(text).toBe("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" });
- expect(text).toBe("now-6h to now+1h");
+ 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' });
+ 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 94c3319284e..2457d71a48d 100644
--- a/public/app/core/specs/search.jest.ts
+++ b/public/app/core/specs/search.jest.ts
@@ -1,75 +1,70 @@
-import { SearchCtrl } from "../components/search/search";
-import { SearchSrv } from "../services/search_srv";
+import { SearchCtrl } from '../components/search/search';
+import { SearchSrv } from '../services/search_srv';
-describe("SearchCtrl", () => {
+describe('SearchCtrl', () => {
const searchSrvStub = {
search: (options: any) => {},
- getDashboardTags: () => {}
+ getDashboardTags: () => {},
};
- let ctrl = new SearchCtrl(
- { $on: () => {} },
- {},
- {},
- searchSrvStub
- );
+ let ctrl = new SearchCtrl({ $on: () => {} }, {}, {}, searchSrvStub);
- describe("Given an empty result", () => {
+ describe('Given an empty result', () => {
beforeEach(() => {
ctrl.results = [];
});
- describe("When navigating down one step", () => {
+ describe('When navigating down one step', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(1);
});
- it("should not navigate", () => {
+ it('should not navigate', () => {
expect(ctrl.selectedIndex).toBe(0);
});
});
- describe("When navigating up one step", () => {
+ describe('When navigating up one step', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(-1);
});
- it("should not navigate", () => {
+ it('should not navigate', () => {
expect(ctrl.selectedIndex).toBe(0);
});
});
});
- describe("Given a result of one selected collapsed folder with no dashboards and a root folder with 2 dashboards", () => {
+ describe('Given a result of one selected collapsed folder with no dashboards and a root folder with 2 dashboards', () => {
beforeEach(() => {
ctrl.results = [
{
id: 1,
- title: "folder",
+ title: 'folder',
items: [],
selected: true,
expanded: false,
- toggle: i => (i.expanded = !i.expanded)
+ toggle: i => (i.expanded = !i.expanded),
},
{
id: 0,
- title: "Root",
+ title: 'Root',
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),
+ },
];
});
- describe("When navigating down one step", () => {
+ describe('When navigating down one step', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(1);
});
- it("should select first dashboard in root folder", () => {
+ it('should select first dashboard in root folder', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[1].items[0].selected).toBeTruthy();
@@ -77,14 +72,14 @@ describe("SearchCtrl", () => {
});
});
- describe("When navigating down two steps", () => {
+ describe('When navigating down two steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(1);
ctrl.moveSelection(1);
});
- it("should select last dashboard in root folder", () => {
+ it('should select last dashboard in root folder', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[1].items[0].selected).toBeFalsy();
@@ -92,7 +87,7 @@ describe("SearchCtrl", () => {
});
});
- describe("When navigating down three steps", () => {
+ describe('When navigating down three steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(1);
@@ -100,7 +95,7 @@ describe("SearchCtrl", () => {
ctrl.moveSelection(1);
});
- it("should select first folder", () => {
+ it('should select first folder', () => {
expect(ctrl.results[0].selected).toBeTruthy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[1].items[0].selected).toBeFalsy();
@@ -108,13 +103,13 @@ describe("SearchCtrl", () => {
});
});
- describe("When navigating up one step", () => {
+ describe('When navigating up one step', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(-1);
});
- it("should select last dashboard in root folder", () => {
+ it('should select last dashboard in root folder', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[1].items[0].selected).toBeFalsy();
@@ -122,14 +117,14 @@ describe("SearchCtrl", () => {
});
});
- describe("When navigating up two steps", () => {
+ describe('When navigating up two steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(-1);
ctrl.moveSelection(-1);
});
- it("should select first dashboard in root folder", () => {
+ it('should select first dashboard in root folder', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[1].items[0].selected).toBeTruthy();
@@ -138,35 +133,35 @@ describe("SearchCtrl", () => {
});
});
- describe("Given a result of one selected collapsed folder with 2 dashboards and a root folder with 2 dashboards", () => {
+ describe('Given a result of one selected collapsed folder with 2 dashboards and a root folder with 2 dashboards', () => {
beforeEach(() => {
ctrl.results = [
{
id: 1,
- title: "folder",
+ title: 'folder',
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",
+ title: 'Root',
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),
+ },
];
});
- describe("When navigating down one step", () => {
+ describe('When navigating down one step', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(1);
});
- it("should select first dashboard in root folder", () => {
+ it('should select first dashboard in root folder', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeFalsy();
@@ -176,14 +171,14 @@ describe("SearchCtrl", () => {
});
});
- describe("When navigating down two steps", () => {
+ describe('When navigating down two steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(1);
ctrl.moveSelection(1);
});
- it("should select last dashboard in root folder", () => {
+ it('should select last dashboard in root folder', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeFalsy();
@@ -193,7 +188,7 @@ describe("SearchCtrl", () => {
});
});
- describe("When navigating down three steps", () => {
+ describe('When navigating down three steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(1);
@@ -201,7 +196,7 @@ describe("SearchCtrl", () => {
ctrl.moveSelection(1);
});
- it("should select first folder", () => {
+ it('should select first folder', () => {
expect(ctrl.results[0].selected).toBeTruthy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeFalsy();
@@ -211,13 +206,13 @@ describe("SearchCtrl", () => {
});
});
- describe("When navigating up one step", () => {
+ describe('When navigating up one step', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(-1);
});
- it("should select last dashboard in root folder", () => {
+ it('should select last dashboard in root folder', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeFalsy();
@@ -227,14 +222,14 @@ describe("SearchCtrl", () => {
});
});
- describe("When navigating up two steps", () => {
+ describe('When navigating up two steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 0;
ctrl.moveSelection(-1);
ctrl.moveSelection(-1);
});
- it("should select first dashboard in root folder", () => {
+ it('should select first dashboard in root folder', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[1].selected).toBeFalsy();
expect(ctrl.results[1].items[0].selected).toBeTruthy();
@@ -243,7 +238,7 @@ describe("SearchCtrl", () => {
});
});
- describe("Given a result of a search with 2 dashboards where the first is selected", () => {
+ describe('Given a result of a search with 2 dashboards where the first is selected', () => {
beforeEach(() => {
ctrl.results = [
{
@@ -251,39 +246,39 @@ describe("SearchCtrl", () => {
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),
+ },
];
});
- describe("When navigating down one step", () => {
+ describe('When navigating down one step', () => {
beforeEach(() => {
ctrl.selectedIndex = 1;
ctrl.moveSelection(1);
});
- it("should select last dashboard", () => {
+ it('should select last dashboard', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeFalsy();
expect(ctrl.results[0].items[1].selected).toBeTruthy();
});
});
- describe("When navigating down two steps", () => {
+ describe('When navigating down two steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 1;
ctrl.moveSelection(1);
ctrl.moveSelection(1);
});
- it("should select first dashboard", () => {
+ it('should select first dashboard', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeTruthy();
expect(ctrl.results[0].items[1].selected).toBeFalsy();
});
});
- describe("When navigating down three steps", () => {
+ describe('When navigating down three steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 1;
ctrl.moveSelection(1);
@@ -291,34 +286,34 @@ describe("SearchCtrl", () => {
ctrl.moveSelection(1);
});
- it("should select last dashboard", () => {
+ it('should select last dashboard', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeFalsy();
expect(ctrl.results[0].items[1].selected).toBeTruthy();
});
});
- describe("When navigating up one step", () => {
+ describe('When navigating up one step', () => {
beforeEach(() => {
ctrl.selectedIndex = 1;
ctrl.moveSelection(-1);
});
- it("should select last dashboard", () => {
+ it('should select last dashboard', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeFalsy();
expect(ctrl.results[0].items[1].selected).toBeTruthy();
});
});
- describe("When navigating up two steps", () => {
+ describe('When navigating up two steps', () => {
beforeEach(() => {
ctrl.selectedIndex = 1;
ctrl.moveSelection(-1);
ctrl.moveSelection(-1);
});
- it("should select first dashboard", () => {
+ it('should select first dashboard', () => {
expect(ctrl.results[0].selected).toBeFalsy();
expect(ctrl.results[0].items[0].selected).toBeTruthy();
expect(ctrl.results[0].items[1].selected).toBeFalsy();
diff --git a/public/app/core/specs/search_results.jest.ts b/public/app/core/specs/search_results.jest.ts
index ce948e95f43..830496be3a8 100644
--- a/public/app/core/specs/search_results.jest.ts
+++ b/public/app/core/specs/search_results.jest.ts
@@ -1,17 +1,17 @@
-import { SearchResultsCtrl } from "../components/search/search_results";
-import { beforeEach, afterEach } from "test/lib/common";
-import appEvents from "app/core/app_events";
+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", () => {
+jest.mock('app/core/app_events', () => {
return {
- emit: jest.fn()
+ emit: jest.fn(),
};
});
-describe("SearchResultsCtrl", () => {
+describe('SearchResultsCtrl', () => {
let ctrl;
- describe("when checking an item that is not checked", () => {
+ describe('when checking an item that is not checked', () => {
let item = { checked: false };
let selectionChanged = false;
@@ -21,16 +21,16 @@ describe("SearchResultsCtrl", () => {
ctrl.toggleSelection(item);
});
- it("should set checked to true", () => {
+ it('should set checked to true', () => {
expect(item.checked).toBeTruthy();
});
- it("should trigger selection changed callback", () => {
+ it('should trigger selection changed callback', () => {
expect(selectionChanged).toBeTruthy();
});
});
- describe("when checking an item that is checked", () => {
+ describe('when checking an item that is checked', () => {
let item = { checked: true };
let selectionChanged = false;
@@ -40,30 +40,30 @@ describe("SearchResultsCtrl", () => {
ctrl.toggleSelection(item);
});
- it("should set checked to false", () => {
+ it('should set checked to false', () => {
expect(item.checked).toBeFalsy();
});
- it("should trigger selection changed callback", () => {
+ it('should trigger selection changed callback', () => {
expect(selectionChanged).toBeTruthy();
});
});
- describe("when selecting a tag", () => {
+ describe('when selecting a tag', () => {
let selectedTag = null;
beforeEach(() => {
ctrl = new SearchResultsCtrl({});
ctrl.onTagSelected = tag => (selectedTag = tag);
- ctrl.selectTag("tag-test");
+ ctrl.selectTag('tag-test');
});
- it("should trigger tag selected callback", () => {
- expect(selectedTag["$tag"]).toBe("tag-test");
+ it('should trigger tag selected callback', () => {
+ expect(selectedTag['$tag']).toBe('tag-test');
});
});
- describe("when toggle a collapsed folder", () => {
+ describe('when toggle a collapsed folder', () => {
let folderExpanded = false;
beforeEach(() => {
@@ -74,18 +74,18 @@ describe("SearchResultsCtrl", () => {
let folder = {
expanded: false,
- toggle: () => Promise.resolve(folder)
+ toggle: () => Promise.resolve(folder),
};
ctrl.toggleFolderExpand(folder);
});
- it("should trigger folder expanding callback", () => {
+ it('should trigger folder expanding callback', () => {
expect(folderExpanded).toBeTruthy();
});
});
- describe("when toggle an expanded folder", () => {
+ describe('when toggle an expanded folder', () => {
let folderExpanded = false;
beforeEach(() => {
@@ -96,43 +96,43 @@ describe("SearchResultsCtrl", () => {
let folder = {
expanded: true,
- toggle: () => Promise.resolve(folder)
+ toggle: () => Promise.resolve(folder),
};
ctrl.toggleFolderExpand(folder);
});
- it("should not trigger folder expanding callback", () => {
+ it('should not trigger folder expanding callback', () => {
expect(folderExpanded).toBeFalsy();
});
});
- describe("when clicking on a link in search result", () => {
- const dashPath = "dashboard/path";
+ 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", () => {
+ 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", () => {
+ it('should close the search', () => {
expect(appEventsMock.emit.mock.calls.length).toBe(1);
- expect(appEventsMock.emit.mock.calls[0][0]).toBe("hide-dash-search");
+ expect(appEventsMock.emit.mock.calls[0][0]).toBe('hide-dash-search');
});
});
- describe("with a different url than current path", () => {
+ describe('with a different url than current path', () => {
beforeEach(() => {
ctrl = new SearchResultsCtrl($location);
- const item = { url: "another/path" };
+ const item = { url: 'another/path' };
ctrl.onItemClick(item);
});
- it("should do nothing", () => {
+ it('should do nothing', () => {
expect(appEventsMock.emit.mock.calls.length).toBe(0);
});
});
diff --git a/public/app/core/specs/search_srv.jest.ts b/public/app/core/specs/search_srv.jest.ts
index e9bbe0d9d61..444939d1f4a 100644
--- a/public/app/core/specs/search_srv.jest.ts
+++ b/public/app/core/specs/search_srv.jest.ts
@@ -1,23 +1,23 @@
-import { SearchSrv } from "app/core/services/search_srv";
-import { BackendSrvMock } from "test/mocks/backend_srv";
-import impressionSrv from "app/core/services/impression_srv";
-import { contextSrv } from "app/core/services/context_srv";
-import { beforeEach } from "test/lib/common";
+import { SearchSrv } from 'app/core/services/search_srv';
+import { BackendSrvMock } from 'test/mocks/backend_srv';
+import impressionSrv from 'app/core/services/impression_srv';
+import { contextSrv } from 'app/core/services/context_srv';
+import { beforeEach } from 'test/lib/common';
-jest.mock("app/core/store", () => {
+jest.mock('app/core/store', () => {
return {
getBool: jest.fn(),
- set: jest.fn()
+ set: jest.fn(),
};
});
-jest.mock("app/core/services/impression_srv", () => {
+jest.mock('app/core/services/impression_srv', () => {
return {
- getDashboardOpened: jest.fn
+ getDashboardOpened: jest.fn,
};
});
-describe("SearchSrv", () => {
+describe('SearchSrv', () => {
let searchSrv, backendSrvMock;
beforeEach(() => {
@@ -28,57 +28,50 @@ describe("SearchSrv", () => {
impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([]);
});
- describe("With recent dashboards", () => {
+ describe('With recent dashboards', () => {
let results;
beforeEach(() => {
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([]));
impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([1, 2]);
- return searchSrv.search({ query: "" }).then(res => {
+ return searchSrv.search({ query: '' }).then(res => {
results = res;
});
});
- it("should include recent dashboards section", () => {
- expect(results[0].title).toBe("Recent Boards");
+ it('should include recent dashboards section', () => {
+ expect(results[0].title).toBe('Recent');
});
- it("should return order decided by impressions store not api", () => {
- expect(results[0].items[0].title).toBe("first but second");
- expect(results[0].items[1].title).toBe("second but first");
+ it('should return order decided by impressions store not api', () => {
+ expect(results[0].items[0].title).toBe('first but second');
+ expect(results[0].items[1].title).toBe('second but first');
});
- describe("and 3 recent dashboards removed in backend", () => {
+ describe('and 3 recent dashboards removed in backend', () => {
let results;
beforeEach(() => {
backendSrvMock.search = jest
.fn()
- .mockReturnValueOnce(
- Promise.resolve([{ id: 2, title: "two" }, { id: 1, title: "one" }])
- )
+ .mockReturnValueOnce(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 => {
+ return searchSrv.search({ query: '' }).then(res => {
results = res;
});
});
- it("should return 2 dashboards", () => {
+ it('should return 2 dashboards', () => {
expect(results[0].items.length).toBe(2);
expect(results[0].items[0].id).toBe(1);
expect(results[0].items[1].id).toBe(2);
@@ -86,59 +79,52 @@ describe("SearchSrv", () => {
});
});
- describe("With starred dashboards", () => {
+ describe('With starred dashboards', () => {
let results;
beforeEach(() => {
- backendSrvMock.search = jest
- .fn()
- .mockReturnValue(Promise.resolve([{ id: 1, title: "starred" }]));
+ backendSrvMock.search = jest.fn().mockReturnValue(Promise.resolve([{ id: 1, title: 'starred' }]));
- return searchSrv.search({ query: "" }).then(res => {
+ return searchSrv.search({ query: '' }).then(res => {
results = res;
});
});
- it("should include starred dashboards section", () => {
- expect(results[0].title).toBe("Starred Boards");
+ it('should include starred dashboards section', () => {
+ expect(results[0].title).toBe('Starred');
expect(results[0].items.length).toBe(1);
});
});
- describe("With starred dashboards and recent", () => {
+ describe('With starred dashboards and recent', () => {
let results;
beforeEach(() => {
backendSrvMock.search = jest
.fn()
.mockReturnValueOnce(
- Promise.resolve([
- { id: 1, title: "starred and recent", isStarred: true },
- { id: 2, title: "recent" }
- ])
+ Promise.resolve([{ id: 1, title: 'starred and recent', isStarred: true }, { id: 2, title: 'recent' }])
)
- .mockReturnValue(
- Promise.resolve([{ id: 1, title: "starred and recent" }])
- );
+ .mockReturnValue(Promise.resolve([{ id: 1, title: 'starred and recent' }]));
impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([1, 2]);
- return searchSrv.search({ query: "" }).then(res => {
+ 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].items[0].title).toBe("recent");
+ it('should not show starred in recent', () => {
+ 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].items[0].title).toBe("starred and recent");
+ it('should show starred', () => {
+ 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", () => {
+ describe('with no query string and dashboards with folders returned', () => {
let results;
beforeEach(() => {
@@ -148,45 +134,45 @@ describe("SearchSrv", () => {
.mockReturnValue(
Promise.resolve([
{
- title: "folder1",
- type: "dash-folder",
- id: 1
+ title: 'folder1',
+ type: 'dash-folder',
+ id: 1,
},
{
- title: "dash with no folder",
- type: "dash-db",
- id: 2
+ title: 'dash with no folder',
+ type: 'dash-db',
+ id: 2,
},
{
- title: "dash in folder1 1",
- type: "dash-db",
+ title: 'dash in folder1 1',
+ type: 'dash-db',
id: 3,
- folderId: 1
+ folderId: 1,
},
{
- title: "dash in folder1 2",
- type: "dash-db",
+ title: 'dash in folder1 2',
+ type: 'dash-db',
id: 4,
- folderId: 1
- }
+ folderId: 1,
+ },
])
);
- return searchSrv.search({ query: "" }).then(res => {
+ return searchSrv.search({ query: '' }).then(res => {
results = res;
});
});
- it("should create sections for each folder and root", () => {
+ it('should create sections for each folder and root', () => {
expect(results).toHaveLength(2);
});
- it("should place folders first", () => {
- expect(results[0].title).toBe("folder1");
+ it('should place folders first', () => {
+ expect(results[0].title).toBe('folder1');
});
});
- describe("with query string and dashboards with folders returned", () => {
+ describe('with query string and dashboards with folders returned', () => {
let results;
beforeEach(() => {
@@ -196,47 +182,47 @@ describe("SearchSrv", () => {
Promise.resolve([
{
id: 2,
- title: "dash with no folder",
- type: "dash-db"
+ title: 'dash with no folder',
+ type: 'dash-db',
},
{
id: 3,
- title: "dash in folder1 1",
- type: "dash-db",
+ title: 'dash in folder1 1',
+ type: 'dash-db',
folderId: 1,
- folderTitle: "folder1"
- }
+ folderTitle: 'folder1',
+ },
])
);
- return searchSrv.search({ query: "search" }).then(res => {
+ return searchSrv.search({ query: 'search' }).then(res => {
results = res;
});
});
- it("should not specify folder ids", () => {
+ it('should not specify folder ids', () => {
expect(backendSrvMock.search.mock.calls[0][0].folderIds).toHaveLength(0);
});
- it("should group results by folder", () => {
+ it('should group results by folder', () => {
expect(results).toHaveLength(2);
});
});
- describe("with tags", () => {
+ describe('with tags', () => {
beforeEach(() => {
backendSrvMock.search = jest.fn();
backendSrvMock.search.mockReturnValue(Promise.resolve([]));
- return searchSrv.search({ tag: ["atag"] }).then(() => {});
+ return searchSrv.search({ tag: ['atag'] }).then(() => {});
});
- it("should send tags query to backend search", () => {
+ it('should send tags query to backend search', () => {
expect(backendSrvMock.search.mock.calls[0][0].tag).toHaveLength(1);
});
});
- describe("with starred", () => {
+ describe('with starred', () => {
beforeEach(() => {
backendSrvMock.search = jest.fn();
backendSrvMock.search.mockReturnValue(Promise.resolve([]));
@@ -244,12 +230,12 @@ describe("SearchSrv", () => {
return searchSrv.search({ starred: true }).then(() => {});
});
- it("should send starred query to backend search", () => {
+ it('should send starred query to backend search', () => {
expect(backendSrvMock.search.mock.calls[0][0].starred).toEqual(true);
});
});
- describe("when skipping recent dashboards", () => {
+ describe('when skipping recent dashboards', () => {
let getRecentDashboardsCalled = false;
beforeEach(() => {
@@ -263,12 +249,12 @@ describe("SearchSrv", () => {
return searchSrv.search({ skipRecent: true }).then(() => {});
});
- it("should not fetch recent dashboards", () => {
+ it('should not fetch recent dashboards', () => {
expect(getRecentDashboardsCalled).toBeFalsy();
});
});
- describe("when skipping starred dashboards", () => {
+ describe('when skipping starred dashboards', () => {
let getStarredCalled = false;
beforeEach(() => {
@@ -283,7 +269,7 @@ describe("SearchSrv", () => {
return searchSrv.search({ skipStarred: true }).then(() => {});
});
- it("should not fetch starred dashboards", () => {
+ it('should not fetch starred dashboards', () => {
expect(getStarredCalled).toBeFalsy();
});
});
diff --git a/public/app/core/specs/store.jest.ts b/public/app/core/specs/store.jest.ts
index e8d6fea2124..0162960621d 100644
--- a/public/app/core/specs/store.jest.ts
+++ b/public/app/core/specs/store.jest.ts
@@ -1,40 +1,40 @@
-import store from "../store";
+import store from '../store';
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");
+describe('store', () => {
+ 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 4085e20f72f..a2c1eb5e1af 100644
--- a/public/app/core/specs/table_model.jest.ts
+++ b/public/app/core/specs/table_model.jest.ts
@@ -1,9 +1,9 @@
-import TableModel from "app/core/table_model";
+import TableModel from 'app/core/table_model';
-describe("when sorting table desc", () => {
+describe('when sorting table desc', () => {
var table;
var panel = {
- sort: { col: 0, desc: true }
+ sort: { col: 0, desc: true },
};
beforeEach(() => {
@@ -13,22 +13,22 @@ describe("when sorting table desc", () => {
table.sort(panel.sort);
});
- it("should sort by time", () => {
+ it('should sort by time', () => {
expect(table.rows[0][0]).toBe(105);
expect(table.rows[1][0]).toBe(103);
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", () => {
+describe('when sorting table asc', () => {
var table;
var panel = {
- sort: { col: 1, desc: false }
+ sort: { col: 1, desc: false },
};
beforeEach(() => {
@@ -38,7 +38,7 @@ describe("when sorting table asc", () => {
table.sort(panel.sort);
});
- it("should sort by time", () => {
+ it('should sort by time', () => {
expect(table.rows[0][1]).toBe(10);
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 1855eac0a89..5043953071a 100644
--- a/public/app/core/specs/time_series.jest.ts
+++ b/public/app/core/specs/time_series.jest.ts
@@ -1,308 +1,300 @@
-import TimeSeries from "app/core/time_series2";
+import TimeSeries from 'app/core/time_series2';
-describe("TimeSeries", function() {
+describe('TimeSeries', function() {
var points, series;
- var yAxisFormats = ["short", "ms"];
+ var yAxisFormats = ['short', 'ms'];
var testData;
beforeEach(function() {
testData = {
- alias: "test",
- datapoints: [[1, 2], [null, 3], [10, 4], [8, 5]]
+ alias: 'test',
+ datapoints: [[1, 2], [null, 3], [10, 4], [8, 5]],
};
});
- describe("when getting flot pairs", function() {
- it("with connected style, should ignore nulls", function() {
+ describe('when getting flot pairs', function() {
+ it('with connected style, should ignore nulls', function() {
series = new TimeSeries(testData);
- points = series.getFlotPairs("connected", yAxisFormats);
+ points = series.getFlotPairs('connected', yAxisFormats);
expect(points.length).toBe(3);
});
- it("with null as zero style, should replace nulls with zero", function() {
+ it('with null as zero style, should replace nulls with zero', function() {
series = new TimeSeries(testData);
- points = series.getFlotPairs("null as zero", yAxisFormats);
+ points = series.getFlotPairs('null as zero', yAxisFormats);
expect(points.length).toBe(4);
expect(points[1][1]).toBe(0);
});
- it("if last is null current should pick next to last", 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);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.current).toBe(10);
});
- it("max value should work for negative values", 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);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.max).toBe(-4);
});
- it("average value should ignore nulls", function() {
+ it('average value should ignore nulls', function() {
series = new TimeSeries(testData);
- series.getFlotPairs("null", yAxisFormats);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.avg).toBe(6.333333333333333);
});
- it("the delta value should account for nulls", 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);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(14);
});
- it("the delta value should account for nulls on first", 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);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(14);
});
- it("the delta value should account for nulls on last", 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);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(9);
});
- it("the delta value should account for resets", 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);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(19);
});
- it("the delta value should account for resets on last", 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);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(17);
});
- it("the range value should be max - min", function() {
+ it('the range value should be max - min', function() {
series = new TimeSeries(testData);
- series.getFlotPairs("null", yAxisFormats);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.range).toBe(9);
});
- it("first value should ingone nulls", function() {
+ it('first value should ingone nulls', function() {
series = new TimeSeries(testData);
- series.getFlotPairs("null", yAxisFormats);
+ 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);
+ series.getFlotPairs('null', yAxisFormats);
expect(series.stats.first).toBe(1);
});
- it("with null as zero style, average value should treat nulls as 0", function() {
+ it('with null as zero style, average value should treat nulls as 0', function() {
series = new TimeSeries(testData);
- series.getFlotPairs("null as zero", yAxisFormats);
+ series.getFlotPairs('null as zero', yAxisFormats);
expect(series.stats.avg).toBe(4.75);
});
- it("average value should be null if all values is null", 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");
+ series.getFlotPairs('null');
expect(series.stats.avg).toBe(null);
});
});
- describe("When checking if ms resolution is needed", function() {
- describe("msResolution with second resolution timestamps", 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]]
+ datapoints: [[45, 1234567890], [60, 1234567899]],
});
});
- it("should set hasMsResolution to false", function() {
+ it('should set hasMsResolution to false', function() {
expect(series.hasMsResolution).toBe(false);
});
});
- describe("msResolution with millisecond resolution timestamps", function() {
+ describe('msResolution with millisecond resolution timestamps', function() {
beforeEach(function() {
series = new TimeSeries({
- datapoints: [[55, 1236547890001], [90, 1234456709000]]
+ datapoints: [[55, 1236547890001], [90, 1234456709000]],
});
});
- it("should show millisecond resolution tooltip", function() {
+ it('should show millisecond resolution tooltip', function() {
expect(series.hasMsResolution).toBe(true);
});
});
- describe("msResolution with millisecond resolution timestamps but with trailing zeroes", function() {
+ describe('msResolution with millisecond resolution timestamps but with trailing zeroes', function() {
beforeEach(function() {
series = new TimeSeries({
- datapoints: [[45, 1234567890000], [60, 1234567899000]]
+ datapoints: [[45, 1234567890000], [60, 1234567899000]],
});
});
- it("should not show millisecond resolution tooltip", function() {
+ it('should not show millisecond resolution tooltip', function() {
expect(series.hasMsResolution).toBe(false);
});
});
});
- describe("can detect if series contains ms precision", function() {
+ describe('can detect if series contains ms precision', function() {
var fakedata;
beforeEach(function() {
fakedata = testData;
});
- it("missing datapoint with ms precision", function() {
+ it('missing datapoint with ms precision', function() {
fakedata.datapoints[0] = [1337, 1234567890000];
series = new TimeSeries(fakedata);
expect(series.isMsResolutionNeeded()).toBe(false);
});
- it("contains datapoint with ms precision", function() {
+ it('contains datapoint with ms precision', function() {
fakedata.datapoints[0] = [1337, 1236547890001];
series = new TimeSeries(fakedata);
expect(series.isMsResolutionNeeded()).toBe(true);
});
});
- describe("series overrides", function() {
+ describe('series overrides', function() {
var series;
beforeEach(function() {
series = new TimeSeries(testData);
});
- describe("fill & points", function() {
+ describe('fill & points', function() {
beforeEach(function() {
- series.alias = "test";
- series.applySeriesOverrides([{ alias: "test", fill: 0, points: true }]);
+ series.alias = 'test';
+ series.applySeriesOverrides([{ alias: 'test', fill: 0, points: true }]);
});
- it("should set fill zero, and enable points", function() {
+ it('should set fill zero, and enable points', function() {
expect(series.lines.fill).toBe(0.001);
expect(series.points.show).toBe(true);
});
});
- describe("series option overrides, bars, true & lines false", function() {
+ describe('series option overrides, bars, true & lines false', function() {
beforeEach(function() {
- series.alias = "test";
- series.applySeriesOverrides([
- { alias: "test", bars: true, lines: false }
- ]);
+ series.alias = 'test';
+ series.applySeriesOverrides([{ alias: 'test', bars: true, lines: false }]);
});
- it("should disable lines, and enable bars", function() {
+ it('should disable lines, and enable bars', function() {
expect(series.lines.show).toBe(false);
expect(series.bars.show).toBe(true);
});
});
- describe("series option overrides, linewidth, stack", function() {
+ describe('series option overrides, linewidth, stack', function() {
beforeEach(function() {
- series.alias = "test";
- series.applySeriesOverrides([
- { alias: "test", linewidth: 5, stack: false }
- ]);
+ series.alias = 'test';
+ series.applySeriesOverrides([{ alias: 'test', linewidth: 5, stack: false }]);
});
- it("should disable stack, and set lineWidth", function() {
+ it('should disable stack, and set lineWidth', function() {
expect(series.stack).toBe(false);
expect(series.lines.lineWidth).toBe(5);
});
});
- describe("series option overrides, dashes and lineWidth", function() {
+ describe('series option overrides, dashes and lineWidth', function() {
beforeEach(function() {
- series.alias = "test";
- series.applySeriesOverrides([
- { alias: "test", linewidth: 5, dashes: true }
- ]);
+ series.alias = 'test';
+ series.applySeriesOverrides([{ alias: 'test', linewidth: 5, dashes: true }]);
});
- it("should enable dashes, set dashes lineWidth to 5 and lines lineWidth to 0", function() {
+ it('should enable dashes, set dashes lineWidth to 5 and lines lineWidth to 0', function() {
expect(series.dashes.show).toBe(true);
expect(series.dashes.lineWidth).toBe(5);
expect(series.lines.lineWidth).toBe(0);
});
});
- describe("series option overrides, fill below to", function() {
+ describe('series option overrides, fill below to', function() {
beforeEach(function() {
- series.alias = "test";
- series.applySeriesOverrides([{ alias: "test", fillBelowTo: "min" }]);
+ series.alias = 'test';
+ series.applySeriesOverrides([{ alias: 'test', fillBelowTo: 'min' }]);
});
- it("should disable line fill and add fillBelowTo", function() {
- expect(series.fillBelowTo).toBe("min");
+ it('should disable line fill and add fillBelowTo', function() {
+ expect(series.fillBelowTo).toBe('min');
});
});
- describe("series option overrides, pointradius, steppedLine", function() {
+ describe('series option overrides, pointradius, steppedLine', function() {
beforeEach(function() {
- series.alias = "test";
- series.applySeriesOverrides([
- { alias: "test", pointradius: 5, steppedLine: true }
- ]);
+ series.alias = 'test';
+ series.applySeriesOverrides([{ alias: 'test', pointradius: 5, steppedLine: true }]);
});
- it("should set pointradius, and set steppedLine", function() {
+ it('should set pointradius, and set steppedLine', function() {
expect(series.points.radius).toBe(5);
expect(series.lines.steps).toBe(true);
});
});
- describe("override match on regex", function() {
+ describe('override match on regex', function() {
beforeEach(function() {
- series.alias = "test_01";
- series.applySeriesOverrides([{ alias: "/.*01/", lines: false }]);
+ series.alias = 'test_01';
+ series.applySeriesOverrides([{ alias: '/.*01/', lines: false }]);
});
- it("should match second series", function() {
+ it('should match second series', function() {
expect(series.lines.show).toBe(false);
});
});
- describe("override series y-axis, and z-index", function() {
+ describe('override series y-axis, and z-index', function() {
beforeEach(function() {
- series.alias = "test";
- series.applySeriesOverrides([{ alias: "test", yaxis: 2, zindex: 2 }]);
+ series.alias = 'test';
+ series.applySeriesOverrides([{ alias: 'test', yaxis: 2, zindex: 2 }]);
});
- it("should set yaxis", function() {
+ it('should set yaxis', function() {
expect(series.yaxis).toBe(2);
});
- it("should set zindex", function() {
+ it('should set zindex', function() {
expect(series.zindex).toBe(2);
});
});
});
- describe("value formatter", function() {
+ describe('value formatter', function() {
var series;
beforeEach(function() {
series = new TimeSeries(testData);
});
- 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("");
+ 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('');
});
});
});
diff --git a/public/app/core/specs/value_select_dropdown_specs.ts b/public/app/core/specs/value_select_dropdown_specs.ts
index d0dca0e109b..8f6408fb389 100644
--- a/public/app/core/specs/value_select_dropdown_specs.ts
+++ b/public/app/core/specs/value_select_dropdown_specs.ts
@@ -1,177 +1,170 @@
-import {
- describe,
- beforeEach,
- it,
- expect,
- angularMocks,
- sinon
-} from "test/lib/common";
-import "app/core/directives/value_select_dropdown";
+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 = {};
var rootScope;
var q;
- beforeEach(angularMocks.module("grafana.core"));
+ 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 = $controller('ValueSelectDropdownCtrl', { $scope: scope });
ctrl.onUpdated = sinon.spy();
- $httpBackend.when("GET", /\.html$/).respond("");
+ $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]);
- }
+ },
};
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"];
- tagValuesMap.key3 = ["server-1", "server-2", "server-3"];
+ tagValuesMap.key1 = ['server-1', 'server-3'];
+ tagValuesMap.key2 = ['server-2', 'server-3'];
+ tagValuesMap.key3 = ['server-1', 'server-2', 'server-3'];
ctrl.init();
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() {
- expect(ctrl.linkText).to.be("server-1");
+ it('should set linkText', function() {
+ expect(ctrl.linkText).to.be('server-1');
});
- describe("after adititional value is selected", function() {
+ describe('after adititional value is selected', function() {
beforeEach(function() {
ctrl.selectValue(ctrl.options[2], {});
ctrl.commitChanges();
});
- it("should update link text", function() {
- expect(ctrl.linkText).to.be("server-1 + server-3");
+ it('should update link text', function() {
+ expect(ctrl.linkText).to.be('server-1 + server-3');
});
});
- describe("When tag is selected", function() {
+ describe('When tag is selected', function() {
beforeEach(function() {
ctrl.selectTag(ctrl.tags[0]);
rootScope.$digest();
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() {
- expect(ctrl.linkText).to.be("");
+ it('link text should not include tag values', function() {
+ expect(ctrl.linkText).to.be('');
});
- describe("and then dropdown is opened and closed without changes", function() {
+ describe('and then dropdown is opened and closed without changes', function() {
beforeEach(function() {
ctrl.show();
ctrl.commitChanges();
rootScope.$digest();
});
- it("should still have selected tag", function() {
+ it('should still have selected tag', function() {
expect(ctrl.selectedTags.length).to.be(1);
});
});
- describe("and then unselected", function() {
+ describe('and then unselected', function() {
beforeEach(function() {
ctrl.selectTag(ctrl.tags[0]);
rootScope.$digest();
});
- it("should deselect tag", function() {
+ it('should deselect tag', function() {
expect(ctrl.selectedTags.length).to.be(0);
});
});
- describe("and then value is unselected", function() {
+ describe('and then value is unselected', function() {
beforeEach(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 }]
+ 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 f6b8dd8fd12..b0714f49256 100644
--- a/public/app/core/store.ts
+++ b/public/app/core/store.ts
@@ -11,7 +11,7 @@ export class Store {
if (def !== void 0 && !this.exists(key)) {
return def;
}
- return window.localStorage[key] === "true";
+ return window.localStorage[key] === 'true';
}
exists(key) {
diff --git a/public/app/core/table_model.ts b/public/app/core/table_model.ts
index 1cefc8c0c0d..57800b3e48d 100644
--- a/public/app/core/table_model.ts
+++ b/public/app/core/table_model.ts
@@ -8,7 +8,7 @@ export default class TableModel {
this.columns = [];
this.columnMap = {};
this.rows = [];
- this.type = "table";
+ this.type = 'table';
}
sort(options) {
diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts
index a6506a3d87e..5d9963977de 100644
--- a/public/app/core/time_series2.ts
+++ b/public/app/core/time_series2.ts
@@ -1,13 +1,13 @@
-import kbn from "app/core/utils/kbn";
-import { getFlotTickDecimals } from "app/core/utils/ticks";
-import _ from "lodash";
+import kbn from 'app/core/utils/kbn';
+import { getFlotTickDecimals } from 'app/core/utils/ticks';
+import _ from 'lodash';
function matchSeriesOverride(aliasOrRegex, seriesAlias) {
if (!aliasOrRegex) {
return false;
}
- if (aliasOrRegex[0] === "/") {
+ if (aliasOrRegex[0] === '/') {
var regex = kbn.stringToJsRegex(aliasOrRegex);
return seriesAlias.match(regex) != null;
}
@@ -108,7 +108,7 @@ export default class TimeSeries {
applySeriesOverrides(overrides) {
this.lines = {};
this.dashes = {
- dashLength: []
+ dashLength: [],
};
this.points = {};
this.bars = {};
@@ -199,8 +199,8 @@ export default class TimeSeries {
this.allIsNull = true;
this.allIsZero = true;
- var ignoreNulls = fillStyle === "connected";
- var nullAsZero = fillStyle === "null as zero";
+ var ignoreNulls = fillStyle === 'connected';
+ var nullAsZero = fillStyle === 'null as zero';
var currentTime;
var currentValue;
var nonNulls = 0;
diff --git a/public/app/core/utils/colors.ts b/public/app/core/utils/colors.ts
index b078dd2a64e..8a70e093ea2 100644
--- a/public/app/core/utils/colors.ts
+++ b/public/app/core/utils/colors.ts
@@ -1,80 +1,80 @@
-import _ from "lodash";
-import tinycolor from "tinycolor2";
+import _ from 'lodash';
+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 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 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) {
let hslColors = _.map(hexColors, hexToHsl);
- let sortedHSLColors = _.sortBy(hslColors, ["h"]);
+ let sortedHSLColors = _.sortBy(hslColors, ['h']);
sortedHSLColors = _.chunk(sortedHSLColors, PALETTE_ROWS);
sortedHSLColors = _.map(sortedHSLColors, chunk => {
- return _.sortBy(chunk, "l");
+ return _.sortBy(chunk, 'l');
});
sortedHSLColors = _.flattenDeep(_.zip(...sortedHSLColors));
diff --git a/public/app/core/utils/css_loader.ts b/public/app/core/utils/css_loader.ts
index a253f4d906c..4ff03ec3c97 100644
--- a/public/app/core/utils/css_loader.ts
+++ b/public/app/core/utils/css_loader.ts
@@ -1,10 +1,10 @@
///
var waitSeconds = 100;
-var head = document.getElementsByTagName("head")[0];
+var head = document.getElementsByTagName('head')[0];
// get all link tags in the page
-var links = document.getElementsByTagName("link");
+var links = document.getElementsByTagName('link');
var linkHrefs = [];
for (var i = 0; i < links.length; i++) {
linkHrefs.push(links[i].href);
@@ -27,9 +27,9 @@ var noop = function() {};
var loadCSS = function(url) {
return new Promise(function(resolve, reject) {
- var link = document.createElement("link");
+ var link = document.createElement('link');
var timeout = setTimeout(function() {
- reject("Unable to load CSS");
+ reject('Unable to load CSS');
}, waitSeconds * 1000);
var _callback = function(error) {
@@ -39,13 +39,13 @@ var loadCSS = function(url) {
if (error) {
reject(error);
} else {
- resolve("");
+ resolve('');
}
}, 7);
};
- link.type = "text/css";
- link.rel = "stylesheet";
+ link.type = 'text/css';
+ link.rel = 'stylesheet';
link.href = url;
if (!isWebkit) {
@@ -57,7 +57,7 @@ var loadCSS = function(url) {
}
link.onerror = function(evt: any) {
- _callback(evt.error || new Error("Error loading CSS file."));
+ _callback(evt.error || new Error('Error loading CSS file.'));
};
head.appendChild(link);
@@ -65,14 +65,14 @@ var loadCSS = function(url) {
};
export function fetch(load): any {
- if (typeof window === "undefined") {
- return "";
+ if (typeof window === 'undefined') {
+ return '';
}
// dont reload styles loaded in the head
for (var i = 0; i < linkHrefs.length; i++) {
if (load.address === linkHrefs[i]) {
- return "";
+ return '';
}
}
return loadCSS(load.address);
diff --git a/public/app/core/utils/datemath.ts b/public/app/core/utils/datemath.ts
index 4d132864062..b892d49f2d8 100644
--- a/public/app/core/utils/datemath.ts
+++ b/public/app/core/utils/datemath.ts
@@ -1,9 +1,9 @@
///
-import _ from "lodash";
-import moment from "moment";
+import _ from 'lodash';
+import moment from 'moment';
-var units = ["y", "M", "w", "d", "h", "m", "s"];
+var units = ['y', 'M', 'w', 'd', 'h', 'm', 's'];
export function parse(text, roundUp?, timezone?) {
if (!text) {
@@ -17,22 +17,22 @@ export function parse(text, roundUp?, timezone?) {
}
var time;
- var mathString = "";
+ var mathString = '';
var index;
var parseString;
- if (text.substring(0, 3) === "now") {
- if (timezone === "utc") {
+ if (text.substring(0, 3) === 'now') {
+ if (timezone === 'utc') {
time = moment.utc();
} else {
time = moment();
}
- mathString = text.substring("now".length);
+ mathString = text.substring('now'.length);
} else {
- index = text.indexOf("||");
+ index = text.indexOf('||');
if (index === -1) {
parseString = text;
- mathString = ""; // nothing else
+ mathString = ''; // nothing else
} else {
parseString = text.substring(0, index);
mathString = text.substring(index + 2);
@@ -72,11 +72,11 @@ export function parseDateMath(mathString, time, roundUp?) {
var num;
var unit;
- if (c === "/") {
+ if (c === '/') {
type = 0;
- } else if (c === "+") {
+ } else if (c === '+') {
type = 1;
- } else if (c === "-") {
+ } else if (c === '-') {
type = 2;
} else {
return undefined;
diff --git a/public/app/core/utils/emitter.ts b/public/app/core/utils/emitter.ts
index 280ccbdc14b..3ac19e57a6a 100644
--- a/public/app/core/utils/emitter.ts
+++ b/public/app/core/utils/emitter.ts
@@ -1,5 +1,3 @@
-///
-
import EventEmitter from 'eventemitter3';
export class Emitter {
diff --git a/public/app/core/utils/file_export.ts b/public/app/core/utils/file_export.ts
index b60b2e9386d..1ebd5b90a86 100644
--- a/public/app/core/utils/file_export.ts
+++ b/public/app/core/utils/file_export.ts
@@ -1,41 +1,27 @@
-import _ from "lodash";
-import moment from "moment";
-import { saveAs } from "file-saver";
+import _ from 'lodash';
+import moment from 'moment';
+import { saveAs } from 'file-saver';
-const DEFAULT_DATETIME_FORMAT = "YYYY-MM-DDTHH:mm:ssZ";
+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";
+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";
+ 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;";
+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 += series.alias + ';';
});
text = text.substring(0, text.length - 1);
- text += "\n";
+ text += '\n';
// process data
var dataArr = [[]];
@@ -53,34 +39,34 @@ export function exportSeriesListToCsvColumns(
// make text
for (var i = 0; i < dataArr[0].length; i++) {
- text += dataArr[0][i] + ";";
+ text += dataArr[0][i] + ';';
for (var j = 1; j < dataArr.length; j++) {
- text += dataArr[j][i] + ";";
+ text += dataArr[j][i] + ';';
}
text = text.substring(0, text.length - 1);
- text += "\n";
+ text += '\n';
}
- saveSaveBlob(text, "grafana_data_export.csv");
+ saveSaveBlob(text, 'grafana_data_export.csv');
}
export function exportTableDataToCsv(table, excel = false) {
- var text = excel ? "sep=;\n" : "";
+ var text = excel ? 'sep=;\n' : '';
// add header
_.each(table.columns, function(column) {
- text += (column.title || column.text) + ";";
+ text += (column.title || column.text) + ';';
});
- text += "\n";
+ text += '\n';
// process data
_.each(table.rows, function(row) {
_.each(row, function(value) {
- text += value + ";";
+ text += value + ';';
});
- text += "\n";
+ 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" });
+ 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 beac593db17..150017e34f8 100644
--- a/public/app/core/utils/flatten.ts
+++ b/public/app/core/utils/flatten.ts
@@ -4,7 +4,7 @@
export default function flatten(target, opts): any {
opts = opts || {};
- var delimiter = opts.delimiter || ".";
+ var delimiter = opts.delimiter || '.';
var maxDepth = opts.maxDepth || 3;
var currentDepth = 1;
var output = {};
@@ -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,12 +22,7 @@ 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 e207348511b..ec4837fe31d 100644
--- a/public/app/core/utils/kbn.ts
+++ b/public/app/core/utils/kbn.ts
@@ -1,12 +1,12 @@
-import _ from "lodash";
-import moment from "moment";
+import _ from 'lodash';
+import moment from 'moment';
var kbn: any = {};
kbn.valueFormats = {};
kbn.regexEscape = function(value) {
- return value.replace(/[\\^$*+?.()|[\]{}\/]/g, "\\$&");
+ return value.replace(/[\\^$*+?.()|[\]{}\/]/g, '\\$&');
};
///// HELPER FUNCTIONS /////
@@ -105,41 +105,41 @@ kbn.round_interval = function(interval) {
kbn.secondsToHms = function(seconds) {
var numyears = Math.floor(seconds / 31536000);
if (numyears) {
- return numyears + "y";
+ return numyears + 'y';
}
var numdays = Math.floor((seconds % 31536000) / 86400);
if (numdays) {
- return numdays + "d";
+ return numdays + 'd';
}
var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600);
if (numhours) {
- return numhours + "h";
+ return numhours + 'h';
}
var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60);
if (numminutes) {
- return numminutes + "m";
+ return numminutes + 'm';
}
var numseconds = Math.floor((((seconds % 31536000) % 86400) % 3600) % 60);
if (numseconds) {
- return numseconds + "s";
+ return numseconds + 's';
}
var nummilliseconds = Math.floor(seconds * 1000.0);
if (nummilliseconds) {
- return nummilliseconds + "ms";
+ return nummilliseconds + 'ms';
}
- return "less than a millisecond"; //'just now' //or other string you like;
+ return 'less than a millisecond'; //'just now' //or other string you like;
};
kbn.to_percent = function(nr, outof) {
- return Math.floor(nr / outof * 10000) / 100 + "%";
+ return Math.floor(nr / outof * 10000) / 100 + '%';
};
kbn.addslashes = function(str) {
- str = str.replace(/\\/g, "\\\\");
+ str = str.replace(/\\/g, '\\\\');
str = str.replace(/\'/g, "\\'");
str = str.replace(/\"/g, '\\"');
- str = str.replace(/\0/g, "\\0");
+ str = str.replace(/\0/g, '\\0');
return str;
};
@@ -154,7 +154,7 @@ kbn.intervals_in_seconds = {
h: 3600,
m: 60,
s: 1,
- ms: 0.001
+ ms: 0.001,
};
kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
@@ -162,36 +162,32 @@ kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
var intervalMs;
if (lowLimitInterval) {
- if (lowLimitInterval[0] === ">") {
+ if (lowLimitInterval[0] === '>') {
lowLimitInterval = lowLimitInterval.slice(1);
}
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;
}
return {
intervalMs: intervalMs,
- interval: kbn.secondsToHms(intervalMs / 1000)
+ interval: kbn.secondsToHms(intervalMs / 1000),
};
};
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]],
type: matches[2],
- count: parseInt(matches[1], 10)
+ count: parseInt(matches[1], 10),
};
}
};
@@ -209,11 +205,7 @@ kbn.interval_to_seconds = function(str) {
kbn.query_color_dot = function(color, diameter) {
return (
''
);
};
@@ -221,55 +213,46 @@ kbn.query_color_dot = function(color, diameter) {
kbn.slugifyForUrl = function(str) {
return str
.toLowerCase()
- .replace(/[^\w ]+/g, "")
- .replace(/ +/g, "-");
+ .replace(/[^\w ]+/g, '')
+ .replace(/ +/g, '-');
};
kbn.stringToJsRegex = function(str) {
- if (str[0] !== "/") {
- return new RegExp("^" + str + "$");
+ if (str[0] !== '/') {
+ return new RegExp('^' + str + '$');
}
- var match = str.match(new RegExp("^/(.*?)/(g?i?m?y?)$"));
+ var match = str.match(new RegExp('^/(.*?)/(g?i?m?y?)$'));
return new RegExp(match[1], match[2]);
};
kbn.toFixed = function(value, decimals) {
if (value === null) {
- return "";
+ return '';
}
var factor = decimals ? Math.pow(10, Math.max(0, decimals)) : 1;
var formatted = String(Math.round(value * factor) / factor);
// if exponent return directly
- if (formatted.indexOf("e") !== -1 || value === 0) {
+ if (formatted.indexOf('e') !== -1 || value === 0) {
return formatted;
}
// If tickDecimals was specified, ensure that we have exactly that
// much precision; otherwise default to the value's own precision.
if (decimals != null) {
- var decimalPos = formatted.indexOf(".");
+ 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 {
@@ -295,9 +278,9 @@ kbn.formatBuilders = {};
kbn.formatBuilders.fixedUnit = function(unit) {
return function(size, decimals) {
if (size === null) {
- return "";
+ return '';
}
- return kbn.toFixed(size, decimals) + " " + unit;
+ return kbn.toFixed(size, decimals) + ' ' + unit;
};
};
@@ -307,7 +290,7 @@ kbn.formatBuilders.fixedUnit = function(unit) {
kbn.formatBuilders.scaledUnits = function(factor, extArray) {
return function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
var steps = 0;
@@ -318,7 +301,7 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
size /= factor;
if (steps >= limit) {
- return "NA";
+ return 'NA';
}
}
@@ -334,10 +317,10 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
// offset is given, it adjusts the starting units at the given prefix; a value
// of 0 starts at no scale; -3 drops to nano, +2 starts at mega, etc.
kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
- var prefixes = ["n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
+ var prefixes = ['n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
prefixes = prefixes.slice(3 + (offset || 0));
var units = prefixes.map(function(p) {
- return " " + p + unit;
+ return ' ' + p + unit;
});
return kbn.formatBuilders.scaledUnits(1000, units);
};
@@ -346,11 +329,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;
+ return ' ' + p + unit;
});
return kbn.formatBuilders.scaledUnits(1024, units);
};
@@ -358,11 +339,11 @@ kbn.formatBuilders.binarySIPrefix = function(unit, offset) {
// Currency formatter for prefixing a symbol onto a number. Supports scaling
// up to the trillions.
kbn.formatBuilders.currency = function(symbol) {
- var units = ["", "K", "M", "B", "T"];
+ var units = ['', 'K', 'M', 'B', 'T'];
var scaler = kbn.formatBuilders.scaledUnits(1000, units);
return function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
var scaled = scaler(size, decimals, scaledDecimals);
return symbol + scaled;
@@ -370,14 +351,14 @@ kbn.formatBuilders.currency = function(symbol) {
};
kbn.formatBuilders.simpleCountUnit = function(symbol) {
- var units = ["", "K", "M", "B", "T"];
+ var units = ['', 'K', 'M', 'B', 'T'];
var scaler = kbn.formatBuilders.scaledUnits(1000, units);
return function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
var scaled = scaler(size, decimals, scaledDecimals);
- return scaled + " " + symbol;
+ return scaled + ' ' + symbol;
};
};
@@ -386,31 +367,31 @@ kbn.formatBuilders.simpleCountUnit = function(symbol) {
// Dimensionless Units
kbn.valueFormats.none = kbn.toFixed;
kbn.valueFormats.short = kbn.formatBuilders.scaledUnits(1000, [
- "",
- " K",
- " Mil",
- " Bil",
- " Tri",
- " Quadr",
- " Quint",
- " Sext",
- " Sept"
+ '',
+ ' K',
+ ' Mil',
+ ' Bil',
+ ' Tri',
+ ' Quadr',
+ ' Quint',
+ ' Sext',
+ ' Sept',
]);
-kbn.valueFormats.dB = kbn.formatBuilders.fixedUnit("dB");
-kbn.valueFormats.ppm = kbn.formatBuilders.fixedUnit("ppm");
+kbn.valueFormats.dB = kbn.formatBuilders.fixedUnit('dB');
+kbn.valueFormats.ppm = kbn.formatBuilders.fixedUnit('ppm');
kbn.valueFormats.percent = function(size, decimals) {
if (size === null) {
- return "";
+ return '';
}
- return kbn.toFixed(size, decimals) + "%";
+ return kbn.toFixed(size, decimals) + '%';
};
kbn.valueFormats.percentunit = function(size, decimals) {
if (size === null) {
- return "";
+ return '';
}
- return kbn.toFixed(100 * size, decimals) + "%";
+ return kbn.toFixed(100 * size, decimals) + '%';
};
/* Formats the value to hex. Uses float if specified decimals are not 0.
@@ -418,7 +399,7 @@ kbn.valueFormats.percentunit = function(size, decimals) {
kbn.valueFormats.hex = function(value, decimals) {
if (value == null) {
- return "";
+ return '';
}
return parseFloat(kbn.toFixed(value, decimals))
.toString(16)
@@ -427,13 +408,13 @@ kbn.valueFormats.hex = function(value, decimals) {
kbn.valueFormats.hex0x = function(value, decimals) {
if (value == null) {
- return "";
+ return '';
}
var hexString = kbn.valueFormats.hex(value, decimals);
- if (hexString.substring(0, 1) === "-") {
- return "-0x" + hexString.substring(1);
+ if (hexString.substring(0, 1) === '-') {
+ return '-0x' + hexString.substring(1);
}
- return "0x" + hexString;
+ return '0x' + hexString;
};
kbn.valueFormats.sci = function(value, decimals) {
@@ -445,387 +426,305 @@ kbn.valueFormats.locale = function(value, decimals) {
};
// Currencies
-kbn.valueFormats.currencyUSD = kbn.formatBuilders.currency("$");
-kbn.valueFormats.currencyGBP = kbn.formatBuilders.currency("£");
-kbn.valueFormats.currencyEUR = kbn.formatBuilders.currency("€");
-kbn.valueFormats.currencyJPY = kbn.formatBuilders.currency("¥");
-kbn.valueFormats.currencyRUB = kbn.formatBuilders.currency("₽");
-kbn.valueFormats.currencyUAH = kbn.formatBuilders.currency("₴");
-kbn.valueFormats.currencyBRL = kbn.formatBuilders.currency("R$");
-kbn.valueFormats.currencyDKK = kbn.formatBuilders.currency("kr");
-kbn.valueFormats.currencyISK = kbn.formatBuilders.currency("kr");
-kbn.valueFormats.currencyNOK = kbn.formatBuilders.currency("kr");
-kbn.valueFormats.currencySEK = kbn.formatBuilders.currency("kr");
+kbn.valueFormats.currencyUSD = kbn.formatBuilders.currency('$');
+kbn.valueFormats.currencyGBP = kbn.formatBuilders.currency('£');
+kbn.valueFormats.currencyEUR = kbn.formatBuilders.currency('€');
+kbn.valueFormats.currencyJPY = kbn.formatBuilders.currency('¥');
+kbn.valueFormats.currencyRUB = kbn.formatBuilders.currency('₽');
+kbn.valueFormats.currencyUAH = kbn.formatBuilders.currency('₴');
+kbn.valueFormats.currencyBRL = kbn.formatBuilders.currency('R$');
+kbn.valueFormats.currencyDKK = kbn.formatBuilders.currency('kr');
+kbn.valueFormats.currencyISK = kbn.formatBuilders.currency('kr');
+kbn.valueFormats.currencyNOK = kbn.formatBuilders.currency('kr');
+kbn.valueFormats.currencySEK = kbn.formatBuilders.currency('kr');
// Data (Binary)
-kbn.valueFormats.bits = kbn.formatBuilders.binarySIPrefix("b");
-kbn.valueFormats.bytes = kbn.formatBuilders.binarySIPrefix("B");
-kbn.valueFormats.kbytes = kbn.formatBuilders.binarySIPrefix("B", 1);
-kbn.valueFormats.mbytes = kbn.formatBuilders.binarySIPrefix("B", 2);
-kbn.valueFormats.gbytes = kbn.formatBuilders.binarySIPrefix("B", 3);
+kbn.valueFormats.bits = kbn.formatBuilders.binarySIPrefix('b');
+kbn.valueFormats.bytes = kbn.formatBuilders.binarySIPrefix('B');
+kbn.valueFormats.kbytes = kbn.formatBuilders.binarySIPrefix('B', 1);
+kbn.valueFormats.mbytes = kbn.formatBuilders.binarySIPrefix('B', 2);
+kbn.valueFormats.gbytes = kbn.formatBuilders.binarySIPrefix('B', 3);
// Data (Decimal)
-kbn.valueFormats.decbits = kbn.formatBuilders.decimalSIPrefix("b");
-kbn.valueFormats.decbytes = kbn.formatBuilders.decimalSIPrefix("B");
-kbn.valueFormats.deckbytes = kbn.formatBuilders.decimalSIPrefix("B", 1);
-kbn.valueFormats.decmbytes = kbn.formatBuilders.decimalSIPrefix("B", 2);
-kbn.valueFormats.decgbytes = kbn.formatBuilders.decimalSIPrefix("B", 3);
+kbn.valueFormats.decbits = kbn.formatBuilders.decimalSIPrefix('b');
+kbn.valueFormats.decbytes = kbn.formatBuilders.decimalSIPrefix('B');
+kbn.valueFormats.deckbytes = kbn.formatBuilders.decimalSIPrefix('B', 1);
+kbn.valueFormats.decmbytes = kbn.formatBuilders.decimalSIPrefix('B', 2);
+kbn.valueFormats.decgbytes = kbn.formatBuilders.decimalSIPrefix('B', 3);
// Data Rate
-kbn.valueFormats.pps = kbn.formatBuilders.decimalSIPrefix("pps");
-kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix("bps");
-kbn.valueFormats.Bps = kbn.formatBuilders.decimalSIPrefix("Bps");
-kbn.valueFormats.KBs = kbn.formatBuilders.decimalSIPrefix("Bs", 1);
-kbn.valueFormats.Kbits = kbn.formatBuilders.decimalSIPrefix("bps", 1);
-kbn.valueFormats.MBs = kbn.formatBuilders.decimalSIPrefix("Bs", 2);
-kbn.valueFormats.Mbits = kbn.formatBuilders.decimalSIPrefix("bps", 2);
-kbn.valueFormats.GBs = kbn.formatBuilders.decimalSIPrefix("Bs", 3);
-kbn.valueFormats.Gbits = kbn.formatBuilders.decimalSIPrefix("bps", 3);
+kbn.valueFormats.pps = kbn.formatBuilders.decimalSIPrefix('pps');
+kbn.valueFormats.bps = kbn.formatBuilders.decimalSIPrefix('bps');
+kbn.valueFormats.Bps = kbn.formatBuilders.decimalSIPrefix('Bps');
+kbn.valueFormats.KBs = kbn.formatBuilders.decimalSIPrefix('Bs', 1);
+kbn.valueFormats.Kbits = kbn.formatBuilders.decimalSIPrefix('bps', 1);
+kbn.valueFormats.MBs = kbn.formatBuilders.decimalSIPrefix('Bs', 2);
+kbn.valueFormats.Mbits = kbn.formatBuilders.decimalSIPrefix('bps', 2);
+kbn.valueFormats.GBs = kbn.formatBuilders.decimalSIPrefix('Bs', 3);
+kbn.valueFormats.Gbits = kbn.formatBuilders.decimalSIPrefix('bps', 3);
// Throughput
-kbn.valueFormats.ops = kbn.formatBuilders.simpleCountUnit("ops");
-kbn.valueFormats.rps = kbn.formatBuilders.simpleCountUnit("rps");
-kbn.valueFormats.wps = kbn.formatBuilders.simpleCountUnit("wps");
-kbn.valueFormats.iops = kbn.formatBuilders.simpleCountUnit("iops");
-kbn.valueFormats.opm = kbn.formatBuilders.simpleCountUnit("opm");
-kbn.valueFormats.rpm = kbn.formatBuilders.simpleCountUnit("rpm");
-kbn.valueFormats.wpm = kbn.formatBuilders.simpleCountUnit("wpm");
+kbn.valueFormats.ops = kbn.formatBuilders.simpleCountUnit('ops');
+kbn.valueFormats.rps = kbn.formatBuilders.simpleCountUnit('rps');
+kbn.valueFormats.wps = kbn.formatBuilders.simpleCountUnit('wps');
+kbn.valueFormats.iops = kbn.formatBuilders.simpleCountUnit('iops');
+kbn.valueFormats.opm = kbn.formatBuilders.simpleCountUnit('opm');
+kbn.valueFormats.rpm = kbn.formatBuilders.simpleCountUnit('rpm');
+kbn.valueFormats.wpm = kbn.formatBuilders.simpleCountUnit('wpm');
// Energy
-kbn.valueFormats.watt = kbn.formatBuilders.decimalSIPrefix("W");
-kbn.valueFormats.kwatt = kbn.formatBuilders.decimalSIPrefix("W", 1);
-kbn.valueFormats.mwatt = kbn.formatBuilders.decimalSIPrefix("W", -1);
-kbn.valueFormats.kwattm = kbn.formatBuilders.decimalSIPrefix("W/Min", 1);
-kbn.valueFormats.voltamp = kbn.formatBuilders.decimalSIPrefix("VA");
-kbn.valueFormats.kvoltamp = kbn.formatBuilders.decimalSIPrefix("VA", 1);
-kbn.valueFormats.voltampreact = kbn.formatBuilders.decimalSIPrefix("var");
-kbn.valueFormats.kvoltampreact = kbn.formatBuilders.decimalSIPrefix("var", 1);
-kbn.valueFormats.watth = kbn.formatBuilders.decimalSIPrefix("Wh");
-kbn.valueFormats.kwatth = kbn.formatBuilders.decimalSIPrefix("Wh", 1);
-kbn.valueFormats.joule = kbn.formatBuilders.decimalSIPrefix("J");
-kbn.valueFormats.ev = kbn.formatBuilders.decimalSIPrefix("eV");
-kbn.valueFormats.amp = kbn.formatBuilders.decimalSIPrefix("A");
-kbn.valueFormats.kamp = kbn.formatBuilders.decimalSIPrefix("A", 1);
-kbn.valueFormats.mamp = kbn.formatBuilders.decimalSIPrefix("A", -1);
-kbn.valueFormats.volt = kbn.formatBuilders.decimalSIPrefix("V");
-kbn.valueFormats.kvolt = kbn.formatBuilders.decimalSIPrefix("V", 1);
-kbn.valueFormats.mvolt = kbn.formatBuilders.decimalSIPrefix("V", -1);
-kbn.valueFormats.dBm = kbn.formatBuilders.decimalSIPrefix("dBm");
-kbn.valueFormats.ohm = kbn.formatBuilders.decimalSIPrefix("Ω");
+kbn.valueFormats.watt = kbn.formatBuilders.decimalSIPrefix('W');
+kbn.valueFormats.kwatt = kbn.formatBuilders.decimalSIPrefix('W', 1);
+kbn.valueFormats.mwatt = kbn.formatBuilders.decimalSIPrefix('W', -1);
+kbn.valueFormats.kwattm = kbn.formatBuilders.decimalSIPrefix('W/Min', 1);
+kbn.valueFormats.voltamp = kbn.formatBuilders.decimalSIPrefix('VA');
+kbn.valueFormats.kvoltamp = kbn.formatBuilders.decimalSIPrefix('VA', 1);
+kbn.valueFormats.voltampreact = kbn.formatBuilders.decimalSIPrefix('var');
+kbn.valueFormats.kvoltampreact = kbn.formatBuilders.decimalSIPrefix('var', 1);
+kbn.valueFormats.watth = kbn.formatBuilders.decimalSIPrefix('Wh');
+kbn.valueFormats.kwatth = kbn.formatBuilders.decimalSIPrefix('Wh', 1);
+kbn.valueFormats.joule = kbn.formatBuilders.decimalSIPrefix('J');
+kbn.valueFormats.ev = kbn.formatBuilders.decimalSIPrefix('eV');
+kbn.valueFormats.amp = kbn.formatBuilders.decimalSIPrefix('A');
+kbn.valueFormats.kamp = kbn.formatBuilders.decimalSIPrefix('A', 1);
+kbn.valueFormats.mamp = kbn.formatBuilders.decimalSIPrefix('A', -1);
+kbn.valueFormats.volt = kbn.formatBuilders.decimalSIPrefix('V');
+kbn.valueFormats.kvolt = kbn.formatBuilders.decimalSIPrefix('V', 1);
+kbn.valueFormats.mvolt = kbn.formatBuilders.decimalSIPrefix('V', -1);
+kbn.valueFormats.dBm = kbn.formatBuilders.decimalSIPrefix('dBm');
+kbn.valueFormats.ohm = kbn.formatBuilders.decimalSIPrefix('Ω');
// Temperature
-kbn.valueFormats.celsius = kbn.formatBuilders.fixedUnit("°C");
-kbn.valueFormats.farenheit = kbn.formatBuilders.fixedUnit("°F");
-kbn.valueFormats.kelvin = kbn.formatBuilders.fixedUnit("K");
-kbn.valueFormats.humidity = kbn.formatBuilders.fixedUnit("%H");
+kbn.valueFormats.celsius = kbn.formatBuilders.fixedUnit('°C');
+kbn.valueFormats.farenheit = kbn.formatBuilders.fixedUnit('°F');
+kbn.valueFormats.kelvin = kbn.formatBuilders.fixedUnit('K');
+kbn.valueFormats.humidity = kbn.formatBuilders.fixedUnit('%H');
// Pressure
-kbn.valueFormats.pressurebar = kbn.formatBuilders.decimalSIPrefix("bar");
-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.pressurebar = kbn.formatBuilders.decimalSIPrefix('bar');
+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");
-kbn.valueFormats.forcekNm = kbn.formatBuilders.decimalSIPrefix("Nm", 1);
-kbn.valueFormats.forceN = kbn.formatBuilders.decimalSIPrefix("N");
-kbn.valueFormats.forcekN = kbn.formatBuilders.decimalSIPrefix("N", 1);
+kbn.valueFormats.forceNm = kbn.formatBuilders.decimalSIPrefix('Nm');
+kbn.valueFormats.forcekNm = kbn.formatBuilders.decimalSIPrefix('Nm', 1);
+kbn.valueFormats.forceN = kbn.formatBuilders.decimalSIPrefix('N');
+kbn.valueFormats.forcekN = kbn.formatBuilders.decimalSIPrefix('N', 1);
// Length
-kbn.valueFormats.lengthm = kbn.formatBuilders.decimalSIPrefix("m");
-kbn.valueFormats.lengthmm = kbn.formatBuilders.decimalSIPrefix("m", -1);
-kbn.valueFormats.lengthkm = kbn.formatBuilders.decimalSIPrefix("m", 1);
-kbn.valueFormats.lengthmi = kbn.formatBuilders.fixedUnit("mi");
-kbn.valueFormats.lengthft = kbn.formatBuilders.fixedUnit("ft");
+kbn.valueFormats.lengthm = kbn.formatBuilders.decimalSIPrefix('m');
+kbn.valueFormats.lengthmm = kbn.formatBuilders.decimalSIPrefix('m', -1);
+kbn.valueFormats.lengthkm = kbn.formatBuilders.decimalSIPrefix('m', 1);
+kbn.valueFormats.lengthmi = kbn.formatBuilders.fixedUnit('mi');
+kbn.valueFormats.lengthft = kbn.formatBuilders.fixedUnit('ft');
// Area
-kbn.valueFormats.areaM2 = kbn.formatBuilders.fixedUnit("m²");
-kbn.valueFormats.areaF2 = kbn.formatBuilders.fixedUnit("ft²");
-kbn.valueFormats.areaMI2 = kbn.formatBuilders.fixedUnit("mi²");
+kbn.valueFormats.areaM2 = kbn.formatBuilders.fixedUnit('m²');
+kbn.valueFormats.areaF2 = kbn.formatBuilders.fixedUnit('ft²');
+kbn.valueFormats.areaMI2 = kbn.formatBuilders.fixedUnit('mi²');
// Mass
-kbn.valueFormats.massmg = kbn.formatBuilders.decimalSIPrefix("g", -1);
-kbn.valueFormats.massg = kbn.formatBuilders.decimalSIPrefix("g");
-kbn.valueFormats.masskg = kbn.formatBuilders.decimalSIPrefix("g", 1);
-kbn.valueFormats.masst = kbn.formatBuilders.fixedUnit("t");
+kbn.valueFormats.massmg = kbn.formatBuilders.decimalSIPrefix('g', -1);
+kbn.valueFormats.massg = kbn.formatBuilders.decimalSIPrefix('g');
+kbn.valueFormats.masskg = kbn.formatBuilders.decimalSIPrefix('g', 1);
+kbn.valueFormats.masst = kbn.formatBuilders.fixedUnit('t');
// Velocity
-kbn.valueFormats.velocityms = kbn.formatBuilders.fixedUnit("m/s");
-kbn.valueFormats.velocitykmh = kbn.formatBuilders.fixedUnit("km/h");
-kbn.valueFormats.velocitymph = kbn.formatBuilders.fixedUnit("mph");
-kbn.valueFormats.velocityknot = kbn.formatBuilders.fixedUnit("kn");
+kbn.valueFormats.velocityms = kbn.formatBuilders.fixedUnit('m/s');
+kbn.valueFormats.velocitykmh = kbn.formatBuilders.fixedUnit('km/h');
+kbn.valueFormats.velocitymph = kbn.formatBuilders.fixedUnit('mph');
+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.accMS2 = kbn.formatBuilders.fixedUnit('m/sec²');
+kbn.valueFormats.accFS2 = kbn.formatBuilders.fixedUnit('f/sec²');
+kbn.valueFormats.accG = kbn.formatBuilders.fixedUnit('g');
// Volume
-kbn.valueFormats.litre = kbn.formatBuilders.decimalSIPrefix("L");
-kbn.valueFormats.mlitre = kbn.formatBuilders.decimalSIPrefix("L", -1);
-kbn.valueFormats.m3 = kbn.formatBuilders.decimalSIPrefix("m3");
-kbn.valueFormats.dm3 = kbn.formatBuilders.decimalSIPrefix("dm3");
-kbn.valueFormats.gallons = kbn.formatBuilders.fixedUnit("gal");
+kbn.valueFormats.litre = kbn.formatBuilders.decimalSIPrefix('L');
+kbn.valueFormats.mlitre = kbn.formatBuilders.decimalSIPrefix('L', -1);
+kbn.valueFormats.m3 = kbn.formatBuilders.decimalSIPrefix('m3');
+kbn.valueFormats.dm3 = kbn.formatBuilders.decimalSIPrefix('dm3');
+kbn.valueFormats.gallons = kbn.formatBuilders.fixedUnit('gal');
// Flow
-kbn.valueFormats.flowgpm = kbn.formatBuilders.fixedUnit("gpm");
-kbn.valueFormats.flowcms = kbn.formatBuilders.fixedUnit("cms");
-kbn.valueFormats.flowcfs = kbn.formatBuilders.fixedUnit("cfs");
-kbn.valueFormats.flowcfm = kbn.formatBuilders.fixedUnit("cfm");
+kbn.valueFormats.flowgpm = kbn.formatBuilders.fixedUnit('gpm');
+kbn.valueFormats.flowcms = kbn.formatBuilders.fixedUnit('cms');
+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");
+kbn.valueFormats.hertz = kbn.formatBuilders.decimalSIPrefix('Hz');
kbn.valueFormats.ms = function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
if (Math.abs(size) < 1000) {
- return kbn.toFixed(size, decimals) + " ms";
+ return kbn.toFixed(size, decimals) + ' ms';
} else if (Math.abs(size) < 60000) {
// Less than 1 min
- return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, " s");
+ return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, ' s');
} else if (Math.abs(size) < 3600000) {
// Less than 1 hour, devide in minutes
- return kbn.toFixedScaled(size / 60000, decimals, scaledDecimals, 5, " min");
+ 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) {
if (size === null) {
- return "";
+ return '';
}
// 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) {
- return kbn.toFixed(size, decimals) + " s";
+ return kbn.toFixed(size, decimals) + ' s';
} else if (Math.abs(size) < 3600) {
// Less than 1 hour, devide in minutes
- return kbn.toFixedScaled(size / 60, decimals, scaledDecimals, 1, " min");
+ return kbn.toFixedScaled(size / 60, decimals, scaledDecimals, 1, ' min');
} else if (Math.abs(size) < 86400) {
// Less than one day, devide in hours
- return kbn.toFixedScaled(size / 3600, decimals, scaledDecimals, 4, " hour");
+ return kbn.toFixedScaled(size / 3600, decimals, scaledDecimals, 4, ' hour');
} else if (Math.abs(size) < 604800) {
// Less than one week, devide in days
- return kbn.toFixedScaled(size / 86400, decimals, scaledDecimals, 5, " day");
+ 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) {
+kbn.valueFormats['µs'] = function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
if (Math.abs(size) < 1000) {
- return kbn.toFixed(size, decimals) + " µs";
+ return kbn.toFixed(size, decimals) + ' µs';
} else if (Math.abs(size) < 1000000) {
- return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, " ms");
+ return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, ' ms');
} else {
- return kbn.toFixedScaled(size / 1000000, decimals, scaledDecimals, 6, " s");
+ return kbn.toFixedScaled(size / 1000000, decimals, scaledDecimals, 6, ' s');
}
};
kbn.valueFormats.ns = function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
if (Math.abs(size) < 1000) {
- return kbn.toFixed(size, decimals) + " ns";
+ return kbn.toFixed(size, decimals) + ' ns';
} else if (Math.abs(size) < 1000000) {
- return kbn.toFixedScaled(size / 1000, decimals, scaledDecimals, 3, " µs");
+ 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');
}
};
kbn.valueFormats.m = function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
if (Math.abs(size) < 60) {
- return kbn.toFixed(size, decimals) + " min";
+ return kbn.toFixed(size, decimals) + ' min';
} else if (Math.abs(size) < 1440) {
- return kbn.toFixedScaled(size / 60, decimals, scaledDecimals, 2, " hour");
+ return kbn.toFixedScaled(size / 60, decimals, scaledDecimals, 2, ' hour');
} else if (Math.abs(size) < 10080) {
- return kbn.toFixedScaled(size / 1440, decimals, scaledDecimals, 3, " day");
+ 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');
}
};
kbn.valueFormats.h = function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
if (Math.abs(size) < 24) {
- return kbn.toFixed(size, decimals) + " hour";
+ return kbn.toFixed(size, decimals) + ' hour';
} else if (Math.abs(size) < 168) {
- return kbn.toFixedScaled(size / 24, decimals, scaledDecimals, 2, " day");
+ return kbn.toFixedScaled(size / 24, decimals, scaledDecimals, 2, ' day');
} else if (Math.abs(size) < 8760) {
- return kbn.toFixedScaled(size / 168, decimals, scaledDecimals, 3, " week");
+ return kbn.toFixedScaled(size / 168, decimals, scaledDecimals, 3, ' week');
} else {
- return kbn.toFixedScaled(size / 8760, decimals, scaledDecimals, 4, " year");
+ return kbn.toFixedScaled(size / 8760, decimals, scaledDecimals, 4, ' year');
}
};
kbn.valueFormats.d = function(size, decimals, scaledDecimals) {
if (size === null) {
- return "";
+ return '';
}
if (Math.abs(size) < 7) {
- return kbn.toFixed(size, decimals) + " day";
+ return kbn.toFixed(size, decimals) + ' day';
} else if (Math.abs(size) < 365) {
- return kbn.toFixedScaled(size / 7, decimals, scaledDecimals, 2, " week");
+ return kbn.toFixedScaled(size / 7, decimals, scaledDecimals, 2, ' week');
} else {
- return kbn.toFixedScaled(size / 365, decimals, scaledDecimals, 3, " year");
+ return kbn.toFixedScaled(size / 365, decimals, scaledDecimals, 3, ' year');
}
};
kbn.toDuration = function(size, decimals, timeScale) {
if (size === null) {
- return "";
+ return '';
}
if (size === 0) {
- return "0 " + timeScale + "s";
+ return '0 ' + timeScale + 's';
}
if (size < 0) {
- return kbn.toDuration(-size, decimals, timeScale) + " ago";
+ return kbn.toDuration(-size, decimals, timeScale) + ' ago';
}
var units = [
- { short: "y", long: "year" },
- { short: "M", long: "month" },
- { short: "w", long: "week" },
- { short: "d", long: "day" },
- { short: "h", long: "hour" },
- { short: "m", long: "minute" },
- { short: "s", long: "second" },
- { short: "ms", long: "millisecond" }
+ { short: 'y', long: 'year' },
+ { short: 'M', long: 'month' },
+ { short: 'w', long: 'week' },
+ { short: 'd', long: 'day' },
+ { short: 'h', long: 'hour' },
+ { short: 'm', long: 'minute' },
+ { short: 's', long: 'second' },
+ { short: 'ms', long: 'millisecond' },
];
// convert $size to milliseconds
// intervals_in_seconds uses seconds (duh), convert them to milliseconds here to minimize floating point errors
@@ -845,40 +744,40 @@ kbn.toDuration = function(size, decimals, timeScale) {
if (value >= 1 || decrementDecimals) {
decrementDecimals = true;
var floor = Math.floor(value);
- var unit = units[i].long + (floor !== 1 ? "s" : "");
- strings.push(floor + " " + unit);
+ var unit = units[i].long + (floor !== 1 ? 's' : '');
+ strings.push(floor + ' ' + unit);
size = size % interval;
decimals--;
}
}
- return strings.join(", ");
+ return strings.join(', ');
};
kbn.valueFormats.dtdurationms = function(size, decimals) {
- return kbn.toDuration(size, decimals, "millisecond");
+ return kbn.toDuration(size, decimals, 'millisecond');
};
kbn.valueFormats.dtdurations = function(size, decimals) {
- return kbn.toDuration(size, decimals, "second");
+ return kbn.toDuration(size, decimals, 'second');
};
kbn.valueFormats.dateTimeAsIso = function(epoch) {
var time = moment(epoch);
- if (moment().isSame(epoch, "day")) {
- return time.format("HH:mm:ss");
+ if (moment().isSame(epoch, 'day')) {
+ return time.format('HH:mm:ss');
}
- return time.format("YYYY-MM-DD HH:mm:ss");
+ return time.format('YYYY-MM-DD HH:mm:ss');
};
kbn.valueFormats.dateTimeAsUS = function(epoch) {
var time = moment(epoch);
- if (moment().isSame(epoch, "day")) {
- return time.format("h:mm:ss a");
+ if (moment().isSame(epoch, 'day')) {
+ return time.format('h:mm:ss a');
}
- return time.format("MM/DD/YYYY h:mm:ss a");
+ return time.format('MM/DD/YYYY h:mm:ss a');
};
kbn.valueFormats.dateTimeFromNow = function(epoch) {
@@ -890,230 +789,230 @@ kbn.valueFormats.dateTimeFromNow = function(epoch) {
kbn.getUnitFormats = function() {
return [
{
- text: "none",
+ text: 'none',
submenu: [
- { text: "none", value: "none" },
- { text: "short", value: "short" },
- { text: "percent (0-100)", value: "percent" },
- { text: "percent (0.0-1.0)", value: "percentunit" },
- { text: "Humidity (%H)", value: "humidity" },
- { text: "ppm", value: "ppm" },
- { text: "decibel", value: "dB" },
- { text: "hexadecimal (0x)", value: "hex0x" },
- { text: "hexadecimal", value: "hex" },
- { text: "scientific notation", value: "sci" },
- { text: "locale format", value: "locale" }
- ]
+ { text: 'none', value: 'none' },
+ { text: 'short', value: 'short' },
+ { text: 'percent (0-100)', value: 'percent' },
+ { text: 'percent (0.0-1.0)', value: 'percentunit' },
+ { text: 'Humidity (%H)', value: 'humidity' },
+ { text: 'ppm', value: 'ppm' },
+ { text: 'decibel', value: 'dB' },
+ { text: 'hexadecimal (0x)', value: 'hex0x' },
+ { text: 'hexadecimal', value: 'hex' },
+ { text: 'scientific notation', value: 'sci' },
+ { text: 'locale format', value: 'locale' },
+ ],
},
{
- text: "currency",
+ text: 'currency',
submenu: [
- { text: "Dollars ($)", value: "currencyUSD" },
- { text: "Pounds (£)", value: "currencyGBP" },
- { text: "Euro (€)", value: "currencyEUR" },
- { text: "Yen (¥)", value: "currencyJPY" },
- { text: "Rubles (₽)", value: "currencyRUB" },
- { text: "Hryvnias (₴)", value: "currencyUAH" },
- { text: "Real (R$)", value: "currencyBRL" },
- { text: "Danish Krone (kr)", value: "currencyDKK" },
- { text: "Icelandic Krone (kr)", value: "currencyISK" },
- { text: "Norwegian Krone (kr)", value: "currencyNOK" },
- { text: "Swedish Krone (kr)", value: "currencySEK" }
- ]
+ { text: 'Dollars ($)', value: 'currencyUSD' },
+ { text: 'Pounds (£)', value: 'currencyGBP' },
+ { text: 'Euro (€)', value: 'currencyEUR' },
+ { text: 'Yen (¥)', value: 'currencyJPY' },
+ { text: 'Rubles (₽)', value: 'currencyRUB' },
+ { text: 'Hryvnias (₴)', value: 'currencyUAH' },
+ { text: 'Real (R$)', value: 'currencyBRL' },
+ { text: 'Danish Krone (kr)', value: 'currencyDKK' },
+ { text: 'Icelandic Krone (kr)', value: 'currencyISK' },
+ { text: 'Norwegian Krone (kr)', value: 'currencyNOK' },
+ { text: 'Swedish Krone (kr)', value: 'currencySEK' },
+ ],
},
{
- text: "time",
+ text: 'time',
submenu: [
- { text: "Hertz (1/s)", value: "hertz" },
- { text: "nanoseconds (ns)", value: "ns" },
- { text: "microseconds (µs)", value: "µs" },
- { text: "milliseconds (ms)", value: "ms" },
- { text: "seconds (s)", value: "s" },
- { text: "minutes (m)", value: "m" },
- { text: "hours (h)", value: "h" },
- { text: "days (d)", value: "d" },
- { text: "duration (ms)", value: "dtdurationms" },
- { text: "duration (s)", value: "dtdurations" }
- ]
+ { text: 'Hertz (1/s)', value: 'hertz' },
+ { text: 'nanoseconds (ns)', value: 'ns' },
+ { text: 'microseconds (µs)', value: 'µs' },
+ { text: 'milliseconds (ms)', value: 'ms' },
+ { text: 'seconds (s)', value: 's' },
+ { text: 'minutes (m)', value: 'm' },
+ { text: 'hours (h)', value: 'h' },
+ { text: 'days (d)', value: 'd' },
+ { text: 'duration (ms)', value: 'dtdurationms' },
+ { text: 'duration (s)', value: 'dtdurations' },
+ ],
},
{
- text: "date & time",
+ text: 'date & time',
submenu: [
- { text: "YYYY-MM-DD HH:mm:ss", value: "dateTimeAsIso" },
- { text: "DD/MM/YYYY h:mm:ss a", value: "dateTimeAsUS" },
- { text: "From Now", value: "dateTimeFromNow" }
- ]
+ { text: 'YYYY-MM-DD HH:mm:ss', value: 'dateTimeAsIso' },
+ { text: 'DD/MM/YYYY h:mm:ss a', value: 'dateTimeAsUS' },
+ { text: 'From Now', value: 'dateTimeFromNow' },
+ ],
},
{
- text: "data (IEC)",
+ text: 'data (IEC)',
submenu: [
- { text: "bits", value: "bits" },
- { text: "bytes", value: "bytes" },
- { text: "kibibytes", value: "kbytes" },
- { text: "mebibytes", value: "mbytes" },
- { text: "gibibytes", value: "gbytes" }
- ]
+ { text: 'bits', value: 'bits' },
+ { text: 'bytes', value: 'bytes' },
+ { text: 'kibibytes', value: 'kbytes' },
+ { text: 'mebibytes', value: 'mbytes' },
+ { text: 'gibibytes', value: 'gbytes' },
+ ],
},
{
- text: "data (Metric)",
+ text: 'data (Metric)',
submenu: [
- { text: "bits", value: "decbits" },
- { text: "bytes", value: "decbytes" },
- { text: "kilobytes", value: "deckbytes" },
- { text: "megabytes", value: "decmbytes" },
- { text: "gigabytes", value: "decgbytes" }
- ]
+ { text: 'bits', value: 'decbits' },
+ { text: 'bytes', value: 'decbytes' },
+ { text: 'kilobytes', value: 'deckbytes' },
+ { text: 'megabytes', value: 'decmbytes' },
+ { text: 'gigabytes', value: 'decgbytes' },
+ ],
},
{
- text: "data rate",
+ text: 'data rate',
submenu: [
- { text: "packets/sec", value: "pps" },
- { text: "bits/sec", value: "bps" },
- { text: "bytes/sec", value: "Bps" },
- { text: "kilobits/sec", value: "Kbits" },
- { text: "kilobytes/sec", value: "KBs" },
- { text: "megabits/sec", value: "Mbits" },
- { text: "megabytes/sec", value: "MBs" },
- { text: "gigabytes/sec", value: "GBs" },
- { text: "gigabits/sec", value: "Gbits" }
- ]
+ { text: 'packets/sec', value: 'pps' },
+ { text: 'bits/sec', value: 'bps' },
+ { text: 'bytes/sec', value: 'Bps' },
+ { text: 'kilobits/sec', value: 'Kbits' },
+ { text: 'kilobytes/sec', value: 'KBs' },
+ { text: 'megabits/sec', value: 'Mbits' },
+ { text: 'megabytes/sec', value: 'MBs' },
+ { text: 'gigabytes/sec', value: 'GBs' },
+ { text: 'gigabits/sec', value: 'Gbits' },
+ ],
},
{
- text: "throughput",
+ text: 'throughput',
submenu: [
- { text: "ops/sec (ops)", value: "ops" },
- { text: "reads/sec (rps)", value: "rps" },
- { text: "writes/sec (wps)", value: "wps" },
- { text: "I/O ops/sec (iops)", value: "iops" },
- { text: "ops/min (opm)", value: "opm" },
- { text: "reads/min (rpm)", value: "rpm" },
- { text: "writes/min (wpm)", value: "wpm" }
- ]
+ { text: 'ops/sec (ops)', value: 'ops' },
+ { text: 'reads/sec (rps)', value: 'rps' },
+ { text: 'writes/sec (wps)', value: 'wps' },
+ { text: 'I/O ops/sec (iops)', value: 'iops' },
+ { text: 'ops/min (opm)', value: 'opm' },
+ { text: 'reads/min (rpm)', value: 'rpm' },
+ { text: 'writes/min (wpm)', value: 'wpm' },
+ ],
},
{
- text: "length",
+ text: 'length',
submenu: [
- { text: "millimetre (mm)", value: "lengthmm" },
- { text: "meter (m)", value: "lengthm" },
- { text: "feet (ft)", value: "lengthft" },
- { text: "kilometer (km)", value: "lengthkm" },
- { text: "mile (mi)", value: "lengthmi" }
- ]
+ { text: 'millimetre (mm)', value: 'lengthmm' },
+ { text: 'meter (m)', value: 'lengthm' },
+ { text: 'feet (ft)', value: 'lengthft' },
+ { text: 'kilometer (km)', value: 'lengthkm' },
+ { text: 'mile (mi)', value: 'lengthmi' },
+ ],
},
{
- text: "area",
+ 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",
+ text: 'mass',
submenu: [
- { text: "milligram (mg)", value: "massmg" },
- { text: "gram (g)", value: "massg" },
- { text: "kilogram (kg)", value: "masskg" },
- { text: "metric ton (t)", value: "masst" }
- ]
+ { text: 'milligram (mg)', value: 'massmg' },
+ { text: 'gram (g)', value: 'massg' },
+ { text: 'kilogram (kg)', value: 'masskg' },
+ { text: 'metric ton (t)', value: 'masst' },
+ ],
},
{
- text: "velocity",
+ text: 'velocity',
submenu: [
- { text: "m/s", value: "velocityms" },
- { text: "km/h", value: "velocitykmh" },
- { text: "mph", value: "velocitymph" },
- { text: "knot (kn)", value: "velocityknot" }
- ]
+ { text: 'm/s', value: 'velocityms' },
+ { text: 'km/h', value: 'velocitykmh' },
+ { text: 'mph', value: 'velocitymph' },
+ { text: 'knot (kn)', value: 'velocityknot' },
+ ],
},
{
- text: "volume",
+ text: 'volume',
submenu: [
- { text: "millilitre", value: "mlitre" },
- { text: "litre", value: "litre" },
- { text: "cubic metre", value: "m3" },
- { text: "cubic decimetre", value: "dm3" },
- { text: "gallons", value: "gallons" }
- ]
+ { text: 'millilitre', value: 'mlitre' },
+ { text: 'litre', value: 'litre' },
+ { text: 'cubic metre', value: 'm3' },
+ { text: 'cubic decimetre', value: 'dm3' },
+ { text: 'gallons', value: 'gallons' },
+ ],
},
{
- text: "energy",
+ text: 'energy',
submenu: [
- { text: "Watt (W)", value: "watt" },
- { text: "Kilowatt (kW)", value: "kwatt" },
- { text: "Milliwatt (mW)", value: "mwatt" },
- { text: "Volt-ampere (VA)", value: "voltamp" },
- { text: "Kilovolt-ampere (kVA)", value: "kvoltamp" },
- { text: "Volt-ampere reactive (var)", value: "voltampreact" },
- { text: "Kilovolt-ampere reactive (kvar)", value: "kvoltampreact" },
- { text: "Watt-hour (Wh)", value: "watth" },
- { text: "Kilowatt-hour (kWh)", value: "kwatth" },
- { text: "Kilowatt-min (kWm)", value: "kwattm" },
- { text: "Joule (J)", value: "joule" },
- { text: "Electron volt (eV)", value: "ev" },
- { text: "Ampere (A)", value: "amp" },
- { text: "Kiloampere (kA)", value: "kamp" },
- { text: "Milliampere (mA)", value: "mamp" },
- { text: "Volt (V)", value: "volt" },
- { text: "Kilovolt (kV)", value: "kvolt" },
- { text: "Millivolt (mV)", value: "mvolt" },
- { text: "Decibel-milliwatt (dBm)", value: "dBm" },
- { text: "Ohm (Ω)", value: "ohm" }
- ]
+ { text: 'Watt (W)', value: 'watt' },
+ { text: 'Kilowatt (kW)', value: 'kwatt' },
+ { text: 'Milliwatt (mW)', value: 'mwatt' },
+ { text: 'Volt-ampere (VA)', value: 'voltamp' },
+ { text: 'Kilovolt-ampere (kVA)', value: 'kvoltamp' },
+ { text: 'Volt-ampere reactive (var)', value: 'voltampreact' },
+ { text: 'Kilovolt-ampere reactive (kvar)', value: 'kvoltampreact' },
+ { text: 'Watt-hour (Wh)', value: 'watth' },
+ { text: 'Kilowatt-hour (kWh)', value: 'kwatth' },
+ { text: 'Kilowatt-min (kWm)', value: 'kwattm' },
+ { text: 'Joule (J)', value: 'joule' },
+ { text: 'Electron volt (eV)', value: 'ev' },
+ { text: 'Ampere (A)', value: 'amp' },
+ { text: 'Kiloampere (kA)', value: 'kamp' },
+ { text: 'Milliampere (mA)', value: 'mamp' },
+ { text: 'Volt (V)', value: 'volt' },
+ { text: 'Kilovolt (kV)', value: 'kvolt' },
+ { text: 'Millivolt (mV)', value: 'mvolt' },
+ { text: 'Decibel-milliwatt (dBm)', value: 'dBm' },
+ { text: 'Ohm (Ω)', value: 'ohm' },
+ ],
},
{
- text: "temperature",
+ text: 'temperature',
submenu: [
- { text: "Celsius (°C)", value: "celsius" },
- { text: "Farenheit (°F)", value: "farenheit" },
- { text: "Kelvin (K)", value: "kelvin" }
- ]
+ { text: 'Celsius (°C)', value: 'celsius' },
+ { text: 'Farenheit (°F)', value: 'farenheit' },
+ { text: 'Kelvin (K)', value: 'kelvin' },
+ ],
},
{
- text: "pressure",
+ text: 'pressure',
submenu: [
- { text: "Millibars", value: "pressurembar" },
- { text: "Bars", value: "pressurebar" },
- { text: "Kilobars", value: "pressurekbar" },
- { text: "Hectopascals", value: "pressurehpa" },
- { text: "Inches of mercury", value: "pressurehg" },
- { text: "PSI", value: "pressurepsi" }
- ]
+ { text: 'Millibars', value: 'pressurembar' },
+ { text: 'Bars', value: 'pressurebar' },
+ { text: 'Kilobars', value: 'pressurekbar' },
+ { text: 'Hectopascals', value: 'pressurehpa' },
+ { text: 'Inches of mercury', value: 'pressurehg' },
+ { text: 'PSI', value: 'pressurepsi' },
+ ],
},
{
- text: "force",
+ text: 'force',
submenu: [
- { text: "Newton-meters (Nm)", value: "forceNm" },
- { text: "Kilonewton-meters (kNm)", value: "forcekNm" },
- { text: "Newtons (N)", value: "forceN" },
- { text: "Kilonewtons (kN)", value: "forcekN" }
- ]
+ { text: 'Newton-meters (Nm)', value: 'forceNm' },
+ { text: 'Kilonewton-meters (kNm)', value: 'forcekNm' },
+ { text: 'Newtons (N)', value: 'forceN' },
+ { text: 'Kilonewtons (kN)', value: 'forcekN' },
+ ],
},
{
- text: "flow",
+ text: 'flow',
submenu: [
- { text: "Gallons/min (gpm)", value: "flowgpm" },
- { text: "Cubic meters/sec (cms)", value: "flowcms" },
- { text: "Cubic feet/sec (cfs)", value: "flowcfs" },
- { text: "Cubic feet/min (cfm)", value: "flowcfm" }
- ]
+ { text: 'Gallons/min (gpm)', value: 'flowgpm' },
+ { text: 'Cubic meters/sec (cms)', value: 'flowcms' },
+ { text: 'Cubic feet/sec (cfs)', value: 'flowcfs' },
+ { text: 'Cubic feet/min (cfm)', value: 'flowcfm' },
+ ],
},
{
- text: "angle",
+ text: 'angle',
submenu: [
- { text: "Degrees (°)", value: "degree" },
- { text: "Radians", value: "radian" },
- { text: "Gradian", value: "grad" }
- ]
+ { text: 'Degrees (°)', value: 'degree' },
+ { text: 'Radians', value: 'radian' },
+ { text: 'Gradian', value: 'grad' },
+ ],
},
{
- text: "acceleration",
+ text: 'acceleration',
submenu: [
- { text: "Meters/sec²", value: "accMS2" },
- { text: "Feet/sec²", value: "accFS2" },
- { text: "G unit", value: "accG" }
- ]
- }
+ { text: 'Meters/sec²', value: 'accMS2' },
+ { 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 e2984aa7484..e595ada6e13 100644
--- a/public/app/core/utils/model_utils.ts
+++ b/public/app/core/utils/model_utils.ts
@@ -1,9 +1,4 @@
-export function assignModelProperties(
- target,
- source,
- defaults,
- removeDefaults?
-) {
+export function assignModelProperties(target, source, defaults, removeDefaults?) {
for (var key in defaults) {
if (!defaults.hasOwnProperty(key)) {
continue;
diff --git a/public/app/core/utils/outline.ts b/public/app/core/utils/outline.ts
index 52ed607cb28..94393e781e9 100644
--- a/public/app/core/utils/outline.ts
+++ b/public/app/core/utils/outline.ts
@@ -2,34 +2,32 @@
function outlineFixer() {
let d: any = document;
- var style_element = d.createElement("STYLE");
- var dom_events = "addEventListener" in d;
+ var style_element = d.createElement('STYLE');
+ var dom_events = 'addEventListener' in d;
var add_event_listener = function(type, callback) {
// Basic cross-browser event handling
if (dom_events) {
d.addEventListener(type, callback);
} else {
- d.attachEvent("on" + type, callback);
+ d.attachEvent('on' + type, callback);
}
};
var set_css = function(css_text) {
// Handle setting of