mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[internal] Replace var with let in ui/public P-T
This change was applied to any .js files under directories beginning with `p` through `t` in src/ui/public. There are no `o` directories. This was an automatic replacement from var to let for any variable declaration that doubles as the initial assignment. Ultimately we want most of these to be converted to const, but this commit is so large that it warrants breaking each step of automation up into its own commit. For example: `var foo = 'bar';` becomes `let foo = 'var';` This was accomplished by replacing: find: `var ([a-zA-Z_$][0-9a-zA-Z_$]*)(\s+)=` replace: `let $1$2=`
This commit is contained in:
parent
68d46d430d
commit
1cddaab2c4
50 changed files with 291 additions and 291 deletions
|
@ -4,7 +4,7 @@ import paginatedTableTemplate from 'ui/paginated_table/paginated_table.html';
|
||||||
uiModules
|
uiModules
|
||||||
.get('kibana')
|
.get('kibana')
|
||||||
.directive('paginatedTable', function ($filter) {
|
.directive('paginatedTable', function ($filter) {
|
||||||
var orderBy = $filter('orderBy');
|
let orderBy = $filter('orderBy');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
|
@ -19,14 +19,14 @@ uiModules
|
||||||
},
|
},
|
||||||
controllerAs: 'paginatedTable',
|
controllerAs: 'paginatedTable',
|
||||||
controller: function ($scope) {
|
controller: function ($scope) {
|
||||||
var self = this;
|
let self = this;
|
||||||
self.sort = {
|
self.sort = {
|
||||||
columnIndex: null,
|
columnIndex: null,
|
||||||
direction: null
|
direction: null
|
||||||
};
|
};
|
||||||
|
|
||||||
self.sortColumn = function (colIndex) {
|
self.sortColumn = function (colIndex) {
|
||||||
var col = $scope.columns[colIndex];
|
let col = $scope.columns[colIndex];
|
||||||
|
|
||||||
if (!col) return;
|
if (!col) return;
|
||||||
if (col.sortable === false) return;
|
if (col.sortable === false) return;
|
||||||
|
@ -36,7 +36,7 @@ uiModules
|
||||||
if (self.sort.columnIndex !== colIndex) {
|
if (self.sort.columnIndex !== colIndex) {
|
||||||
sortDirection = 'asc';
|
sortDirection = 'asc';
|
||||||
} else {
|
} else {
|
||||||
var directions = {
|
let directions = {
|
||||||
null: 'asc',
|
null: 'asc',
|
||||||
'asc': 'desc',
|
'asc': 'desc',
|
||||||
'desc': null
|
'desc': null
|
||||||
|
@ -56,7 +56,7 @@ uiModules
|
||||||
} else {
|
} else {
|
||||||
// use generic sort handler
|
// use generic sort handler
|
||||||
self.sort.getter = function (row) {
|
self.sort.getter = function (row) {
|
||||||
var value = row[index];
|
let value = row[index];
|
||||||
if (value && value.value != null) value = value.value;
|
if (value && value.value != null) value = value.value;
|
||||||
if (typeof value === 'boolean') value = value ? 0 : 1;
|
if (typeof value === 'boolean') value = value ? 0 : 1;
|
||||||
return value;
|
return value;
|
||||||
|
@ -75,7 +75,7 @@ uiModules
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sort = self.sort;
|
let sort = self.sort;
|
||||||
if (sort.direction == null) {
|
if (sort.direction == null) {
|
||||||
$scope.sortedRows = $scope.rows.slice(0);
|
$scope.sortedRows = $scope.rows.slice(0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import DecorateQueryProvider from 'ui/courier/data_source/_decorate_query';
|
import DecorateQueryProvider from 'ui/courier/data_source/_decorate_query';
|
||||||
export default function GetQueryFromUser(es, Private) {
|
export default function GetQueryFromUser(es, Private) {
|
||||||
var decorateQuery = Private(DecorateQueryProvider);
|
let decorateQuery = Private(DecorateQueryProvider);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take text from the user and make it into a query object
|
* Take text from the user and make it into a query object
|
||||||
|
@ -13,7 +13,7 @@ export default function GetQueryFromUser(es, Private) {
|
||||||
return decorateQuery({query_string: {query: text}});
|
return decorateQuery({query_string: {query: text}});
|
||||||
}
|
}
|
||||||
|
|
||||||
var matchAll = getQueryStringQuery('*');
|
let matchAll = getQueryStringQuery('*');
|
||||||
|
|
||||||
// If we get an empty object, treat it as a *
|
// If we get an empty object, treat it as a *
|
||||||
if (_.isObject(text)) {
|
if (_.isObject(text)) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import uiModules from 'ui/modules';
|
||||||
uiModules
|
uiModules
|
||||||
.get('kibana')
|
.get('kibana')
|
||||||
.directive('parseQuery', function (Private) {
|
.directive('parseQuery', function (Private) {
|
||||||
var fromUser = Private(ParseQueryLibFromUserProvider);
|
let fromUser = Private(ParseQueryLibFromUserProvider);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
|
@ -13,7 +13,7 @@ uiModules
|
||||||
'ngModel': '='
|
'ngModel': '='
|
||||||
},
|
},
|
||||||
link: function ($scope, elem, attr, ngModel) {
|
link: function ($scope, elem, attr, ngModel) {
|
||||||
var init = function () {
|
let init = function () {
|
||||||
$scope.ngModel = fromUser($scope.ngModel);
|
$scope.ngModel = fromUser($scope.ngModel);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import SimpleEmitter from 'ui/utils/simple_emitter';
|
||||||
import EventsProvider from 'ui/events';
|
import EventsProvider from 'ui/events';
|
||||||
|
|
||||||
export default function (Private) {
|
export default function (Private) {
|
||||||
var Events = Private(EventsProvider);
|
let Events = Private(EventsProvider);
|
||||||
|
|
||||||
function validateParent(parent, path) {
|
function validateParent(parent, path) {
|
||||||
if (path.length <= 0) {
|
if (path.length <= 0) {
|
||||||
|
@ -17,7 +17,7 @@ export default function (Private) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateValue(value) {
|
function validateValue(value) {
|
||||||
var msg = 'State value must be a plain object';
|
let msg = 'State value must be a plain object';
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
if (!_.isPlainObject(value)) throw new errors.PersistedStateError(msg);
|
if (!_.isPlainObject(value)) throw new errors.PersistedStateError(msg);
|
||||||
}
|
}
|
||||||
|
@ -73,21 +73,21 @@ export default function (Private) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype.set = function (key, value) {
|
PersistedState.prototype.set = function (key, value) {
|
||||||
var params = prepSetParams(key, value, this._path);
|
let params = prepSetParams(key, value, this._path);
|
||||||
var val = this._set(params.key, params.value);
|
let val = this._set(params.key, params.value);
|
||||||
this.emit('set');
|
this.emit('set');
|
||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype.setSilent = function (key, value) {
|
PersistedState.prototype.setSilent = function (key, value) {
|
||||||
var params = prepSetParams(key, value, this._path);
|
let params = prepSetParams(key, value, this._path);
|
||||||
return this._set(params.key, params.value, true);
|
return this._set(params.key, params.value, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype.reset = function (path) {
|
PersistedState.prototype.reset = function (path) {
|
||||||
var keyPath = this._getIndex(path);
|
let keyPath = this._getIndex(path);
|
||||||
var origValue = _.get(this._defaultState, keyPath);
|
let origValue = _.get(this._defaultState, keyPath);
|
||||||
var currentValue = _.get(this._mergedState, keyPath);
|
let currentValue = _.get(this._mergedState, keyPath);
|
||||||
|
|
||||||
if (_.isUndefined(origValue)) {
|
if (_.isUndefined(origValue)) {
|
||||||
this._cleanPath(path, this._mergedState);
|
this._cleanPath(path, this._mergedState);
|
||||||
|
@ -108,7 +108,7 @@ export default function (Private) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype.removeChild = function (path) {
|
PersistedState.prototype.removeChild = function (path) {
|
||||||
var origValue = _.get(this._defaultState, this._getIndex(path));
|
let origValue = _.get(this._defaultState, this._getIndex(path));
|
||||||
|
|
||||||
if (_.isUndefined(origValue)) {
|
if (_.isUndefined(origValue)) {
|
||||||
this.reset(path);
|
this.reset(path);
|
||||||
|
@ -139,19 +139,19 @@ export default function (Private) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype._getPartialIndex = function (key) {
|
PersistedState.prototype._getPartialIndex = function (key) {
|
||||||
var keyPath = this._getIndex(key);
|
let keyPath = this._getIndex(key);
|
||||||
return keyPath.slice(this._path.length);
|
return keyPath.slice(this._path.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype._cleanPath = function (path, stateTree) {
|
PersistedState.prototype._cleanPath = function (path, stateTree) {
|
||||||
var partialPath = this._getPartialIndex(path);
|
let partialPath = this._getPartialIndex(path);
|
||||||
var remove = true;
|
let remove = true;
|
||||||
|
|
||||||
// recursively delete value tree, when no other keys exist
|
// recursively delete value tree, when no other keys exist
|
||||||
while (partialPath.length > 0) {
|
while (partialPath.length > 0) {
|
||||||
var lastKey = partialPath.splice(partialPath.length - 1, 1)[0];
|
let lastKey = partialPath.splice(partialPath.length - 1, 1)[0];
|
||||||
var statePath = this._path.concat(partialPath);
|
let statePath = this._path.concat(partialPath);
|
||||||
var stateVal = statePath.length > 0 ? _.get(stateTree, statePath) : stateTree;
|
let stateVal = statePath.length > 0 ? _.get(stateTree, statePath) : stateTree;
|
||||||
|
|
||||||
// if stateVal isn't an object, do nothing
|
// if stateVal isn't an object, do nothing
|
||||||
if (!_.isPlainObject(stateVal)) return;
|
if (!_.isPlainObject(stateVal)) return;
|
||||||
|
@ -162,13 +162,13 @@ export default function (Private) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype._getDefault = function () {
|
PersistedState.prototype._getDefault = function () {
|
||||||
var def = (this._hasPath()) ? undefined : {};
|
let def = (this._hasPath()) ? undefined : {};
|
||||||
return (this._parent ? this.get() : def);
|
return (this._parent ? this.get() : def);
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype._setPath = function (path) {
|
PersistedState.prototype._setPath = function (path) {
|
||||||
var isString = _.isString(path);
|
let isString = _.isString(path);
|
||||||
var isArray = _.isArray(path);
|
let isArray = _.isArray(path);
|
||||||
|
|
||||||
if (!isString && !isArray) return [];
|
if (!isString && !isArray) return [];
|
||||||
return (isString) ? [this._getIndex(path)] : path;
|
return (isString) ? [this._getIndex(path)] : path;
|
||||||
|
@ -196,11 +196,11 @@ export default function (Private) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PersistedState.prototype._set = function (key, value, silent, initialChildState) {
|
PersistedState.prototype._set = function (key, value, silent, initialChildState) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var stateChanged = false;
|
let stateChanged = false;
|
||||||
var initialState = !this._initialized;
|
let initialState = !this._initialized;
|
||||||
var keyPath = this._getIndex(key);
|
let keyPath = this._getIndex(key);
|
||||||
var hasKeyPath = keyPath.length > 0;
|
let hasKeyPath = keyPath.length > 0;
|
||||||
|
|
||||||
// if this is the initial state value, save value as the default
|
// if this is the initial state value, save value as the default
|
||||||
if (initialState) {
|
if (initialState) {
|
||||||
|
@ -226,7 +226,7 @@ export default function (Private) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// check for changes at path, emit an event when different
|
// check for changes at path, emit an event when different
|
||||||
var curVal = hasKeyPath ? this.get(keyPath) : this._mergedState;
|
let curVal = hasKeyPath ? this.get(keyPath) : this._mergedState;
|
||||||
stateChanged = !_.isEqual(curVal, value);
|
stateChanged = !_.isEqual(curVal, value);
|
||||||
|
|
||||||
if (!initialChildState) {
|
if (!initialChildState) {
|
||||||
|
@ -243,11 +243,11 @@ export default function (Private) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the merged state value
|
// update the merged state value
|
||||||
var targetObj = this._mergedState || _.cloneDeep(this._defaultState);
|
let targetObj = this._mergedState || _.cloneDeep(this._defaultState);
|
||||||
var sourceObj = _.merge({}, this._defaultChildState, this._changedState);
|
let sourceObj = _.merge({}, this._defaultChildState, this._changedState);
|
||||||
|
|
||||||
// handler arguments are (targetValue, sourceValue, key, target, source)
|
// handler arguments are (targetValue, sourceValue, key, target, source)
|
||||||
var mergeMethod = function (targetValue, sourceValue, mergeKey) {
|
let mergeMethod = function (targetValue, sourceValue, mergeKey) {
|
||||||
// if not initial state, skip default merge method (ie. return value, see note below)
|
// if not initial state, skip default merge method (ie. return value, see note below)
|
||||||
if (!initialState && !initialChildState && _.isEqual(keyPath, self._getIndex(mergeKey))) {
|
if (!initialState && !initialChildState && _.isEqual(keyPath, self._getIndex(mergeKey))) {
|
||||||
// use the sourceValue or fall back to targetValue
|
// use the sourceValue or fall back to targetValue
|
||||||
|
|
|
@ -23,10 +23,10 @@ import uiModules from 'ui/modules';
|
||||||
* ```js
|
* ```js
|
||||||
* define(function (require) {
|
* define(function (require) {
|
||||||
* return function ServerHealthProvider(Private, Promise) {
|
* return function ServerHealthProvider(Private, Promise) {
|
||||||
* var ping = Private(require('ui/ping'));
|
* let ping = Private(require('ui/ping'));
|
||||||
* return {
|
* return {
|
||||||
* check: Promise.method(function () {
|
* check: Promise.method(function () {
|
||||||
* var attempts = 0;
|
* let attempts = 0;
|
||||||
* return (function attempt() {
|
* return (function attempt() {
|
||||||
* attempts += 1;
|
* attempts += 1;
|
||||||
* return ping.ping()
|
* return ping.ping()
|
||||||
|
@ -87,7 +87,7 @@ import uiModules from 'ui/modules';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
var nextId = _.partial(_.uniqueId, 'privateProvider#');
|
let nextId = _.partial(_.uniqueId, 'privateProvider#');
|
||||||
|
|
||||||
function name(fn) {
|
function name(fn) {
|
||||||
return fn.name || fn.toString().split('\n').shift();
|
return fn.name || fn.toString().split('\n').shift();
|
||||||
|
@ -95,11 +95,11 @@ function name(fn) {
|
||||||
|
|
||||||
uiModules.get('kibana')
|
uiModules.get('kibana')
|
||||||
.provider('Private', function () {
|
.provider('Private', function () {
|
||||||
var provider = this;
|
let provider = this;
|
||||||
|
|
||||||
// one cache/swaps per Provider
|
// one cache/swaps per Provider
|
||||||
var cache = {};
|
let cache = {};
|
||||||
var swaps = {};
|
let swaps = {};
|
||||||
|
|
||||||
// return the uniq id for this function
|
// return the uniq id for this function
|
||||||
function identify(fn) {
|
function identify(fn) {
|
||||||
|
@ -117,15 +117,15 @@ uiModules.get('kibana')
|
||||||
};
|
};
|
||||||
|
|
||||||
provider.swap = function (fn, prov) {
|
provider.swap = function (fn, prov) {
|
||||||
var id = identify(fn);
|
let id = identify(fn);
|
||||||
swaps[id] = prov;
|
swaps[id] = prov;
|
||||||
};
|
};
|
||||||
|
|
||||||
provider.$get = ['$injector', function PrivateFactory($injector) {
|
provider.$get = ['$injector', function PrivateFactory($injector) {
|
||||||
|
|
||||||
// prevent circular deps by tracking where we came from
|
// prevent circular deps by tracking where we came from
|
||||||
var privPath = [];
|
let privPath = [];
|
||||||
var pathToString = function () {
|
let pathToString = function () {
|
||||||
return privPath.map(name).join(' -> ');
|
return privPath.map(name).join(' -> ');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ uiModules.get('kibana')
|
||||||
|
|
||||||
privPath.push(prov);
|
privPath.push(prov);
|
||||||
|
|
||||||
var context = {};
|
let context = {};
|
||||||
var instance = $injector.invoke(prov, context, locals);
|
let instance = $injector.invoke(prov, context, locals);
|
||||||
if (!_.isObject(instance)) instance = context;
|
if (!_.isObject(instance)) instance = context;
|
||||||
|
|
||||||
privPath.pop();
|
privPath.pop();
|
||||||
|
@ -167,7 +167,7 @@ uiModules.get('kibana')
|
||||||
|
|
||||||
// main api, get the appropriate instance for a provider
|
// main api, get the appropriate instance for a provider
|
||||||
function Private(prov) {
|
function Private(prov) {
|
||||||
var id = identify(prov);
|
let id = identify(prov);
|
||||||
let $delegateId;
|
let $delegateId;
|
||||||
let $delegateProv;
|
let $delegateProv;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
|
|
||||||
var module = uiModules.get('kibana');
|
let module = uiModules.get('kibana');
|
||||||
|
|
||||||
// Provides a tiny subset of the excelent API from
|
// Provides a tiny subset of the excelent API from
|
||||||
// bluebird, reimplemented using the $q service
|
// bluebird, reimplemented using the $q service
|
||||||
|
@ -9,7 +9,7 @@ module.service('Promise', function ($q, $timeout) {
|
||||||
function Promise(fn) {
|
function Promise(fn) {
|
||||||
if (typeof this === 'undefined') throw new Error('Promise constructor must be called with "new"');
|
if (typeof this === 'undefined') throw new Error('Promise constructor must be called with "new"');
|
||||||
|
|
||||||
var defer = $q.defer();
|
let defer = $q.defer();
|
||||||
try {
|
try {
|
||||||
fn(defer.resolve, defer.reject);
|
fn(defer.resolve, defer.reject);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -20,12 +20,12 @@ module.service('Promise', function ($q, $timeout) {
|
||||||
|
|
||||||
Promise.all = Promise.props = $q.all;
|
Promise.all = Promise.props = $q.all;
|
||||||
Promise.resolve = function (val) {
|
Promise.resolve = function (val) {
|
||||||
var defer = $q.defer();
|
let defer = $q.defer();
|
||||||
defer.resolve(val);
|
defer.resolve(val);
|
||||||
return defer.promise;
|
return defer.promise;
|
||||||
};
|
};
|
||||||
Promise.reject = function (reason) {
|
Promise.reject = function (reason) {
|
||||||
var defer = $q.defer();
|
let defer = $q.defer();
|
||||||
defer.reject(reason);
|
defer.reject(reason);
|
||||||
return defer.promise;
|
return defer.promise;
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ module.service('Promise', function ($q, $timeout) {
|
||||||
};
|
};
|
||||||
Promise.method = function (fn) {
|
Promise.method = function (fn) {
|
||||||
return function () {
|
return function () {
|
||||||
var args = Array.prototype.slice.call(arguments);
|
let args = Array.prototype.slice.call(arguments);
|
||||||
return Promise.try(fn, args, this);
|
return Promise.try(fn, args, this);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -64,7 +64,7 @@ module.service('Promise', function ($q, $timeout) {
|
||||||
return obj && typeof obj.then === 'function';
|
return obj && typeof obj.then === 'function';
|
||||||
};
|
};
|
||||||
Promise.halt = _.once(function () {
|
Promise.halt = _.once(function () {
|
||||||
var promise = new Promise();
|
let promise = new Promise();
|
||||||
promise.then = _.constant(promise);
|
promise.then = _.constant(promise);
|
||||||
promise.catch = _.constant(promise);
|
promise.catch = _.constant(promise);
|
||||||
return promise;
|
return promise;
|
||||||
|
@ -155,7 +155,7 @@ module.factory('PromiseEmitter', function (Promise) {
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
function PromiseEmitter(fn, handler) {
|
function PromiseEmitter(fn, handler) {
|
||||||
var prom = new Promise(fn);
|
let prom = new Promise(fn);
|
||||||
|
|
||||||
if (!handler) return prom;
|
if (!handler) return prom;
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@ import _ from 'lodash';
|
||||||
import EventsProvider from 'ui/events';
|
import EventsProvider from 'ui/events';
|
||||||
export default function ReflowWatcherService(Private, $rootScope, $http) {
|
export default function ReflowWatcherService(Private, $rootScope, $http) {
|
||||||
|
|
||||||
var EventEmitter = Private(EventsProvider);
|
let EventEmitter = Private(EventsProvider);
|
||||||
var $body = $(document.body);
|
let $body = $(document.body);
|
||||||
var $window = $(window);
|
let $window = $(window);
|
||||||
|
|
||||||
var MOUSE_EVENTS = 'mouseup';
|
let MOUSE_EVENTS = 'mouseup';
|
||||||
var WINDOW_EVENTS = 'resize';
|
let WINDOW_EVENTS = 'resize';
|
||||||
|
|
||||||
_.class(ReflowWatcher).inherits(EventEmitter);
|
_.class(ReflowWatcher).inherits(EventEmitter);
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import IndexedArray from 'ui/indexed_array';
|
import IndexedArray from 'ui/indexed_array';
|
||||||
import RegistryVisTypesProvider from 'ui/registry/vis_types';
|
import RegistryVisTypesProvider from 'ui/registry/vis_types';
|
||||||
var notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor');
|
let notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a registry, which is just a Private module provider.
|
* Create a registry, which is just a Private module provider.
|
||||||
|
@ -16,7 +16,7 @@ var notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor');
|
||||||
*
|
*
|
||||||
* + register a module
|
* + register a module
|
||||||
* ```js
|
* ```js
|
||||||
* var registry = require('ui/registry/vis_types');
|
* let registry = require('ui/registry/vis_types');
|
||||||
* registry.add(function InjectablePrivateModule($http, Promise) {
|
* registry.add(function InjectablePrivateModule($http, Promise) {
|
||||||
* ...
|
* ...
|
||||||
* })
|
* })
|
||||||
|
@ -24,7 +24,7 @@ var notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor');
|
||||||
*
|
*
|
||||||
* + get all registered modules
|
* + get all registered modules
|
||||||
* ```js
|
* ```js
|
||||||
* var visTypes = Private(RegistryVisTypesProvider);
|
* let visTypes = Private(RegistryVisTypesProvider);
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -49,10 +49,10 @@ var notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor');
|
||||||
export default function createRegistry(spec) {
|
export default function createRegistry(spec) {
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
var constructor = _.has(spec, 'constructor') && spec.constructor;
|
let constructor = _.has(spec, 'constructor') && spec.constructor;
|
||||||
var iaOpts = _.defaults(_.pick(spec, IndexedArray.OPT_NAMES), { index: ['name'] });
|
let iaOpts = _.defaults(_.pick(spec, IndexedArray.OPT_NAMES), { index: ['name'] });
|
||||||
var props = _.omit(spec, notPropsOptNames);
|
let props = _.omit(spec, notPropsOptNames);
|
||||||
var providers = [];
|
let providers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the Private module that will be instanciated by
|
* This is the Private module that will be instanciated by
|
||||||
|
@ -62,10 +62,10 @@ export default function createRegistry(spec) {
|
||||||
* that were registered, the registry spec
|
* that were registered, the registry spec
|
||||||
* defines how things will be indexed.
|
* defines how things will be indexed.
|
||||||
*/
|
*/
|
||||||
var registry = function (Private, $injector) {
|
let registry = function (Private, $injector) {
|
||||||
// index all of the modules
|
// index all of the modules
|
||||||
iaOpts.initialSet = providers.map(Private);
|
iaOpts.initialSet = providers.map(Private);
|
||||||
var modules = new IndexedArray(iaOpts);
|
let modules = new IndexedArray(iaOpts);
|
||||||
|
|
||||||
// mixin other props
|
// mixin other props
|
||||||
_.assign(modules, props);
|
_.assign(modules, props);
|
||||||
|
|
|
@ -7,7 +7,7 @@ export default uiRegistry({
|
||||||
group: ['fieldType'],
|
group: ['fieldType'],
|
||||||
|
|
||||||
constructor: function (config, $rootScope) {
|
constructor: function (config, $rootScope) {
|
||||||
var self = this;
|
let self = this;
|
||||||
let defaultMap;
|
let defaultMap;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -56,7 +56,7 @@ export default uiRegistry({
|
||||||
* @return {FieldFormat}
|
* @return {FieldFormat}
|
||||||
*/
|
*/
|
||||||
self.getInstance = _.memoize(function (formatId) {
|
self.getInstance = _.memoize(function (formatId) {
|
||||||
var FieldFormat = self.byId[formatId];
|
let FieldFormat = self.byId[formatId];
|
||||||
return new FieldFormat();
|
return new FieldFormat();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ export default uiRegistry({
|
||||||
* @return {FieldFormat}
|
* @return {FieldFormat}
|
||||||
*/
|
*/
|
||||||
self.getDefaultInstance = _.memoize(function (fieldType) {
|
self.getDefaultInstance = _.memoize(function (fieldType) {
|
||||||
var conf = self.getDefaultConfig(fieldType);
|
let conf = self.getDefaultConfig(fieldType);
|
||||||
var FieldFormat = self.byId[conf.id];
|
let FieldFormat = self.byId[conf.id];
|
||||||
return new FieldFormat(conf.params);
|
return new FieldFormat(conf.params);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,16 @@ import wrapRouteWithPrep from './wrap_route_with_prep';
|
||||||
import RouteSetupManager from './route_setup_manager';
|
import RouteSetupManager from './route_setup_manager';
|
||||||
|
|
||||||
function RouteManager() {
|
function RouteManager() {
|
||||||
var self = this;
|
let self = this;
|
||||||
var setup = new RouteSetupManager();
|
let setup = new RouteSetupManager();
|
||||||
var when = [];
|
let when = [];
|
||||||
var defaults = [];
|
let defaults = [];
|
||||||
let otherwise;
|
let otherwise;
|
||||||
|
|
||||||
self.config = function ($routeProvider) {
|
self.config = function ($routeProvider) {
|
||||||
when.forEach(function (args) {
|
when.forEach(function (args) {
|
||||||
var path = args[0];
|
let path = args[0];
|
||||||
var route = args[1] || {};
|
let route = args[1] || {};
|
||||||
|
|
||||||
// merge in any defaults
|
// merge in any defaults
|
||||||
defaults.forEach(function (args) {
|
defaults.forEach(function (args) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ module.exports = class RouteSetupManager {
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// wait for the queue to fill up, then do all the work
|
// wait for the queue to fill up, then do all the work
|
||||||
var defer = Promise.defer();
|
let defer = Promise.defer();
|
||||||
userWork.resolveWhenFull(defer);
|
userWork.resolveWhenFull(defer);
|
||||||
|
|
||||||
return defer.promise.then(() => Promise.all(userWork.doWork()));
|
return defer.promise.then(() => Promise.all(userWork.doWork()));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import RouteManager from './route_manager';
|
import RouteManager from './route_manager';
|
||||||
import 'angular-route/angular-route';
|
import 'angular-route/angular-route';
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var defaultRouteManager = new RouteManager();
|
let defaultRouteManager = new RouteManager();
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...defaultRouteManager,
|
...defaultRouteManager,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
function WorkQueue() {
|
function WorkQueue() {
|
||||||
var q = this;
|
let q = this;
|
||||||
|
|
||||||
var work = [];
|
let work = [];
|
||||||
var fullDefers = [];
|
let fullDefers = [];
|
||||||
|
|
||||||
q.limit = 0;
|
q.limit = 0;
|
||||||
Object.defineProperty(q, 'length', {
|
Object.defineProperty(q, 'length', {
|
||||||
|
@ -13,13 +13,13 @@ function WorkQueue() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var resolve = function (defers) {
|
let resolve = function (defers) {
|
||||||
return defers.splice(0).map(function (defer) {
|
return defers.splice(0).map(function (defer) {
|
||||||
return defer.resolve();
|
return defer.resolve();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var checkIfFull = function () {
|
let checkIfFull = function () {
|
||||||
if (work.length >= q.limit && fullDefers.length) {
|
if (work.length >= q.limit && fullDefers.length) {
|
||||||
resolve(fullDefers);
|
resolve(fullDefers);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ function WorkQueue() {
|
||||||
};
|
};
|
||||||
|
|
||||||
q.doWork = function () {
|
q.doWork = function () {
|
||||||
var resps = resolve(work);
|
let resps = resolve(work);
|
||||||
checkIfFull();
|
checkIfFull();
|
||||||
return resps;
|
return resps;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,11 +7,11 @@ import errors from 'ui/errors';
|
||||||
function wrapRouteWithPrep(route, setup) {
|
function wrapRouteWithPrep(route, setup) {
|
||||||
if (!route.resolve && route.redirectTo) return;
|
if (!route.resolve && route.redirectTo) return;
|
||||||
|
|
||||||
var userWork = new WorkQueue();
|
let userWork = new WorkQueue();
|
||||||
// the point at which we will consider the queue "full"
|
// the point at which we will consider the queue "full"
|
||||||
userWork.limit = _.keys(route.resolve).length;
|
userWork.limit = _.keys(route.resolve).length;
|
||||||
|
|
||||||
var resolve = {
|
let resolve = {
|
||||||
__prep__: function ($injector) {
|
__prep__: function ($injector) {
|
||||||
return $injector.invoke(setup.doWork, setup, { userWork });
|
return $injector.invoke(setup.doWork, setup, { userWork });
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ function wrapRouteWithPrep(route, setup) {
|
||||||
// prep is complete
|
// prep is complete
|
||||||
_.forOwn(route.resolve || {}, function (expr, name) {
|
_.forOwn(route.resolve || {}, function (expr, name) {
|
||||||
resolve[name] = function ($injector, Promise) {
|
resolve[name] = function ($injector, Promise) {
|
||||||
var defer = Promise.defer();
|
let defer = Promise.defer();
|
||||||
userWork.push(defer);
|
userWork.push(defer);
|
||||||
return defer.promise.then(function () {
|
return defer.promise.then(function () {
|
||||||
return $injector[angular.isString(expr) ? 'get' : 'invoke'](expr);
|
return $injector[angular.isString(expr) ? 'get' : 'invoke'](expr);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
var err = new Error();
|
let err = new Error();
|
||||||
try { setByAssignment(err, 'john'); } catch (e) {} // eslint-disable-line
|
try { setByAssignment(err, 'john'); } catch (e) {} // eslint-disable-line
|
||||||
|
|
||||||
// err.stack is not always writeable, so we
|
// err.stack is not always writeable, so we
|
||||||
|
@ -13,7 +13,7 @@ if (err.stack === 'john') module.exports = setByAssignment;
|
||||||
else module.exports = setByShadowing;
|
else module.exports = setByShadowing;
|
||||||
|
|
||||||
function setByShadowing(err, stack) {
|
function setByShadowing(err, stack) {
|
||||||
var props = _.mapValues(err, function (val) {
|
let props = _.mapValues(err, function (val) {
|
||||||
return {
|
return {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
value: val
|
value: val
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
var opts = [
|
let opts = [
|
||||||
/@((?:[!#$&-;=?-\[\]_a-z~]|%[0-9a-f]{2})+\.js)\:(\d+)(?:\:(\d+)|())/ig,
|
/@((?:[!#$&-;=?-\[\]_a-z~]|%[0-9a-f]{2})+\.js)\:(\d+)(?:\:(\d+)|())/ig,
|
||||||
/(?: \(|at )((?:[!#$&-;=?-\[\]_a-z~]|%[0-9a-f]{2})+\.js)\:(\d+)(?:\:(\d+)|())/ig
|
/(?: \(|at )((?:[!#$&-;=?-\[\]_a-z~]|%[0-9a-f]{2})+\.js)\:(\d+)(?:\:(\d+)|())/ig
|
||||||
];
|
];
|
||||||
|
@ -8,7 +8,7 @@ var opts = [
|
||||||
let sample;
|
let sample;
|
||||||
try { throw new Error('msg'); } catch (e) { sample = e.stack; }
|
try { throw new Error('msg'); } catch (e) { sample = e.stack; }
|
||||||
|
|
||||||
var format = _.find(opts, function (format) {
|
let format = _.find(opts, function (format) {
|
||||||
return format.test(sample);
|
return format.test(sample);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ StackTraceMapper.prototype.init = function (mapUrls) {
|
||||||
StackTraceMapper.prototype.mapError = function (err) {
|
StackTraceMapper.prototype.mapError = function (err) {
|
||||||
if (!stackLineFormat || !err.stack) return err;
|
if (!stackLineFormat || !err.stack) return err;
|
||||||
|
|
||||||
var stack = err.stack.replace(stackLineFormat, this.mapLine);
|
let stack = err.stack.replace(stackLineFormat, this.mapLine);
|
||||||
return setErrorStack(err, stack);
|
return setErrorStack(err, stack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,10 +39,10 @@ StackTraceMapper.prototype.getMapFor = function (url) {
|
||||||
StackTraceMapper.prototype.loadMaps = function (mapUrls) {
|
StackTraceMapper.prototype.loadMaps = function (mapUrls) {
|
||||||
mapUrls = _.clone(mapUrls || {});
|
mapUrls = _.clone(mapUrls || {});
|
||||||
|
|
||||||
var maps = this.maps;
|
let maps = this.maps;
|
||||||
|
|
||||||
$('script[src][src-map]').each(function () {
|
$('script[src][src-map]').each(function () {
|
||||||
var $el = $(this);
|
let $el = $(this);
|
||||||
mapUrls[$el.attr('src')] = $el.attr('src-map');
|
mapUrls[$el.attr('src')] = $el.attr('src-map');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,17 @@ import _ from 'lodash';
|
||||||
module.exports = function (map, match, filename, line, col) {
|
module.exports = function (map, match, filename, line, col) {
|
||||||
if (!map) return match;
|
if (!map) return match;
|
||||||
|
|
||||||
var position = {
|
let position = {
|
||||||
line: parseFloat(line) || 0,
|
line: parseFloat(line) || 0,
|
||||||
column: parseFloat(col) || 0
|
column: parseFloat(col) || 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var srcPosition = map.smc.originalPositionFor(position);
|
let srcPosition = map.smc.originalPositionFor(position);
|
||||||
if (!srcPosition || !srcPosition.source) return match;
|
if (!srcPosition || !srcPosition.source) return match;
|
||||||
|
|
||||||
var srcFilename = srcPosition.source;
|
let srcFilename = srcPosition.source;
|
||||||
var srcLine = srcPosition.line;
|
let srcLine = srcPosition.line;
|
||||||
var srcCol = srcPosition.column;
|
let srcCol = srcPosition.column;
|
||||||
|
|
||||||
if (srcCol === 0 && position.column) {
|
if (srcCol === 0 && position.column) {
|
||||||
// TODO: teach sourcemaps correct column
|
// TODO: teach sourcemaps correct column
|
||||||
|
@ -26,10 +26,10 @@ module.exports = function (map, match, filename, line, col) {
|
||||||
// fold the components into the original match, so that supporting
|
// fold the components into the original match, so that supporting
|
||||||
// characters (parens, periods, etc) from the format are kept, and so
|
// characters (parens, periods, etc) from the format are kept, and so
|
||||||
// we don't accidentally replace the wrong part we use splitting and consumption
|
// we don't accidentally replace the wrong part we use splitting and consumption
|
||||||
var resp = '';
|
let resp = '';
|
||||||
var remainingResp = match;
|
let remainingResp = match;
|
||||||
var fold = function (replace, replacement) {
|
let fold = function (replace, replacement) {
|
||||||
var wrappingContent = remainingResp.split(replace);
|
let wrappingContent = remainingResp.split(replace);
|
||||||
resp += wrappingContent.shift() + replacement;
|
resp += wrappingContent.shift() + replacement;
|
||||||
remainingResp = wrappingContent.join(replace);
|
remainingResp = wrappingContent.join(replace);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ import rison from 'ui/utils/rison';
|
||||||
export default function ($location) {
|
export default function ($location) {
|
||||||
// feed in some of the private state from globalState
|
// feed in some of the private state from globalState
|
||||||
return function (globalState, updateListeners, app) {
|
return function (globalState, updateListeners, app) {
|
||||||
var getAppStash = function (search) {
|
let getAppStash = function (search) {
|
||||||
var appStash = search._a && rison.decode(search._a);
|
let appStash = search._a && rison.decode(search._a);
|
||||||
if (app.current) {
|
if (app.current) {
|
||||||
// Apply the defaults to appStash
|
// Apply the defaults to appStash
|
||||||
appStash = _.defaults(appStash || {}, app.defaults);
|
appStash = _.defaults(appStash || {}, app.defaults);
|
||||||
|
@ -16,20 +16,20 @@ export default function ($location) {
|
||||||
return appStash;
|
return appStash;
|
||||||
};
|
};
|
||||||
|
|
||||||
var diffTrans = function (trans) {
|
let diffTrans = function (trans) {
|
||||||
var obj = trans[0];
|
let obj = trans[0];
|
||||||
var update = trans[1];
|
let update = trans[1];
|
||||||
|
|
||||||
var diff = {};
|
let diff = {};
|
||||||
|
|
||||||
// the keys that are currently set on obj, excluding methods
|
// the keys that are currently set on obj, excluding methods
|
||||||
var objKeys = Object.keys(obj).filter(function (key) {
|
let objKeys = Object.keys(obj).filter(function (key) {
|
||||||
return typeof obj[key] !== 'function';
|
return typeof obj[key] !== 'function';
|
||||||
});
|
});
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
// the keys obj should have after applying the update
|
// the keys obj should have after applying the update
|
||||||
var updateKeys = diff.keys = Object.keys(update).filter(function (key) {
|
let updateKeys = diff.keys = Object.keys(update).filter(function (key) {
|
||||||
return typeof update[key] !== 'function';
|
return typeof update[key] !== 'function';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ export default function ($location) {
|
||||||
return diff;
|
return diff;
|
||||||
};
|
};
|
||||||
|
|
||||||
var notify = function (trans, diff) {
|
let notify = function (trans, diff) {
|
||||||
var listeners = null;
|
let listeners = null;
|
||||||
|
|
||||||
if (trans[0] === app.current) {
|
if (trans[0] === app.current) {
|
||||||
listeners = app.listeners;
|
listeners = app.listeners;
|
||||||
|
@ -66,11 +66,11 @@ export default function ($location) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var applyDiff = function (trans, diff) {
|
let applyDiff = function (trans, diff) {
|
||||||
if (!diff.all.length) return;
|
if (!diff.all.length) return;
|
||||||
|
|
||||||
var obj = trans[0];
|
let obj = trans[0];
|
||||||
var update = trans[1];
|
let update = trans[1];
|
||||||
|
|
||||||
diff.remove.forEach(function (key) {
|
diff.remove.forEach(function (key) {
|
||||||
delete obj[key];
|
delete obj[key];
|
||||||
|
@ -81,13 +81,13 @@ export default function ($location) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var syncTrans = function (trans, forceNotify) {
|
let syncTrans = function (trans, forceNotify) {
|
||||||
// obj that will be modified by update(trans[1])
|
// obj that will be modified by update(trans[1])
|
||||||
// if it is empty, we can skip it all
|
// if it is empty, we can skip it all
|
||||||
var skipWrite = !trans[0];
|
let skipWrite = !trans[0];
|
||||||
trans[0] = trans[0] || {};
|
trans[0] = trans[0] || {};
|
||||||
|
|
||||||
var diff = diffTrans(trans);
|
let diff = diffTrans(trans);
|
||||||
if (!skipWrite && (forceNotify || diff.all.length)) {
|
if (!skipWrite && (forceNotify || diff.all.length)) {
|
||||||
applyDiff(trans, diff);
|
applyDiff(trans, diff);
|
||||||
notify(trans, diff);
|
notify(trans, diff);
|
||||||
|
@ -98,17 +98,17 @@ export default function ($location) {
|
||||||
return {
|
return {
|
||||||
// sync by pushing to the url
|
// sync by pushing to the url
|
||||||
push: function (forceNotify) {
|
push: function (forceNotify) {
|
||||||
var search = $location.search();
|
let search = $location.search();
|
||||||
|
|
||||||
var appStash = getAppStash(search) || {};
|
let appStash = getAppStash(search) || {};
|
||||||
var globalStash = search._g ? rison.decode(search._g) : {};
|
let globalStash = search._g ? rison.decode(search._g) : {};
|
||||||
|
|
||||||
var res = _.mapValues({
|
let res = _.mapValues({
|
||||||
app: [appStash, app.current],
|
app: [appStash, app.current],
|
||||||
global: [globalStash, globalState]
|
global: [globalStash, globalState]
|
||||||
}, function (trans, key) {
|
}, function (trans, key) {
|
||||||
var diff = syncTrans(trans, forceNotify);
|
let diff = syncTrans(trans, forceNotify);
|
||||||
var urlKey = '_' + key.charAt(0);
|
let urlKey = '_' + key.charAt(0);
|
||||||
if (diff.keys.length === 0) {
|
if (diff.keys.length === 0) {
|
||||||
delete search[urlKey];
|
delete search[urlKey];
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,10 +122,10 @@ export default function ($location) {
|
||||||
},
|
},
|
||||||
// sync by pulling from the url
|
// sync by pulling from the url
|
||||||
pull: function (forceNotify) {
|
pull: function (forceNotify) {
|
||||||
var search = $location.search();
|
let search = $location.search();
|
||||||
|
|
||||||
var appStash = getAppStash(search);
|
let appStash = getAppStash(search);
|
||||||
var globalStash = search._g && rison.decode(search._g);
|
let globalStash = search._g && rison.decode(search._g);
|
||||||
|
|
||||||
return _.mapValues({
|
return _.mapValues({
|
||||||
app: [app.current, appStash],
|
app: [app.current, appStash],
|
||||||
|
|
|
@ -2,11 +2,11 @@ import _ from 'lodash';
|
||||||
import modules from 'ui/modules';
|
import modules from 'ui/modules';
|
||||||
import StateManagementStateProvider from 'ui/state_management/state';
|
import StateManagementStateProvider from 'ui/state_management/state';
|
||||||
import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state';
|
import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state';
|
||||||
var urlParam = '_a';
|
let urlParam = '_a';
|
||||||
|
|
||||||
function AppStateProvider(Private, $rootScope, getAppState) {
|
function AppStateProvider(Private, $rootScope, getAppState) {
|
||||||
var State = Private(StateManagementStateProvider);
|
let State = Private(StateManagementStateProvider);
|
||||||
var PersistedState = Private(PersistedStatePersistedStateProvider);
|
let PersistedState = Private(PersistedStatePersistedStateProvider);
|
||||||
let persistedStates;
|
let persistedStates;
|
||||||
let eventUnsubscribers;
|
let eventUnsubscribers;
|
||||||
|
|
||||||
|
@ -30,31 +30,31 @@ function AppStateProvider(Private, $rootScope, getAppState) {
|
||||||
|
|
||||||
AppState.prototype.makeStateful = function (prop) {
|
AppState.prototype.makeStateful = function (prop) {
|
||||||
if (persistedStates[prop]) return persistedStates[prop];
|
if (persistedStates[prop]) return persistedStates[prop];
|
||||||
var self = this;
|
let self = this;
|
||||||
|
|
||||||
// set up the ui state
|
// set up the ui state
|
||||||
persistedStates[prop] = new PersistedState();
|
persistedStates[prop] = new PersistedState();
|
||||||
|
|
||||||
// update the app state when the stateful instance changes
|
// update the app state when the stateful instance changes
|
||||||
var updateOnChange = function () {
|
let updateOnChange = function () {
|
||||||
var replaceState = false; // TODO: debouncing logic
|
let replaceState = false; // TODO: debouncing logic
|
||||||
|
|
||||||
self[prop] = persistedStates[prop].getChanges();
|
self[prop] = persistedStates[prop].getChanges();
|
||||||
self.save(replaceState);
|
self.save(replaceState);
|
||||||
};
|
};
|
||||||
var handlerOnChange = (method) => persistedStates[prop][method]('change', updateOnChange);
|
let handlerOnChange = (method) => persistedStates[prop][method]('change', updateOnChange);
|
||||||
handlerOnChange('on');
|
handlerOnChange('on');
|
||||||
eventUnsubscribers.push(() => handlerOnChange('off'));
|
eventUnsubscribers.push(() => handlerOnChange('off'));
|
||||||
|
|
||||||
// update the stateful object when the app state changes
|
// update the stateful object when the app state changes
|
||||||
var persistOnChange = function (changes) {
|
let persistOnChange = function (changes) {
|
||||||
if (!changes) return;
|
if (!changes) return;
|
||||||
|
|
||||||
if (changes.indexOf(prop) !== -1) {
|
if (changes.indexOf(prop) !== -1) {
|
||||||
persistedStates[prop].set(self[prop]);
|
persistedStates[prop].set(self[prop]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var handlePersist = (method) => this[method]('fetch_with_changes', persistOnChange);
|
let handlePersist = (method) => this[method]('fetch_with_changes', persistOnChange);
|
||||||
handlePersist('on');
|
handlePersist('on');
|
||||||
eventUnsubscribers.push(() => handlePersist('off'));
|
eventUnsubscribers.push(() => handlePersist('off'));
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ modules.get('kibana/global_state')
|
||||||
|
|
||||||
// Checks to see if the appState might already exist, even if it hasn't been newed up
|
// Checks to see if the appState might already exist, even if it hasn't been newed up
|
||||||
get.previouslyStored = function () {
|
get.previouslyStored = function () {
|
||||||
var search = $location.search();
|
let search = $location.search();
|
||||||
return search[urlParam] ? true : false;
|
return search[urlParam] ? true : false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ import rison from 'ui/utils/rison';
|
||||||
import StateManagementStateProvider from 'ui/state_management/state';
|
import StateManagementStateProvider from 'ui/state_management/state';
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
|
|
||||||
var module = uiModules.get('kibana/global_state');
|
let module = uiModules.get('kibana/global_state');
|
||||||
|
|
||||||
module.service('globalState', function (Private, $rootScope, $location) {
|
module.service('globalState', function (Private, $rootScope, $location) {
|
||||||
var State = Private(StateManagementStateProvider);
|
let State = Private(StateManagementStateProvider);
|
||||||
|
|
||||||
_.class(GlobalState).inherits(State);
|
_.class(GlobalState).inherits(State);
|
||||||
function GlobalState(defaults) {
|
function GlobalState(defaults) {
|
||||||
|
|
|
@ -7,13 +7,13 @@ import Notifier from 'ui/notify/notifier';
|
||||||
|
|
||||||
|
|
||||||
export default function StateProvider(Private, $rootScope, $location) {
|
export default function StateProvider(Private, $rootScope, $location) {
|
||||||
var Events = Private(EventsProvider);
|
let Events = Private(EventsProvider);
|
||||||
|
|
||||||
_.class(State).inherits(Events);
|
_.class(State).inherits(Events);
|
||||||
function State(urlParam, defaults) {
|
function State(urlParam, defaults) {
|
||||||
State.Super.call(this);
|
State.Super.call(this);
|
||||||
|
|
||||||
var self = this;
|
let self = this;
|
||||||
self.setDefaults(defaults);
|
self.setDefaults(defaults);
|
||||||
self._urlParam = urlParam || '_s';
|
self._urlParam = urlParam || '_s';
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ export default function StateProvider(Private, $rootScope, $location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
State.prototype._readFromURL = function () {
|
State.prototype._readFromURL = function () {
|
||||||
var search = $location.search();
|
let search = $location.search();
|
||||||
try {
|
try {
|
||||||
return search[this._urlParam] ? rison.decode(search[this._urlParam]) : null;
|
return search[this._urlParam] ? rison.decode(search[this._urlParam]) : null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var notify = new Notifier();
|
let notify = new Notifier();
|
||||||
notify.error('Unable to parse URL');
|
notify.error('Unable to parse URL');
|
||||||
search[this._urlParam] = rison.encode(this._defaults);
|
search[this._urlParam] = rison.encode(this._defaults);
|
||||||
$location.search(search).replace();
|
$location.search(search).replace();
|
||||||
|
@ -57,7 +57,7 @@ export default function StateProvider(Private, $rootScope, $location) {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
State.prototype.fetch = function () {
|
State.prototype.fetch = function () {
|
||||||
var stash = this._readFromURL();
|
let stash = this._readFromURL();
|
||||||
|
|
||||||
// nothing to read from the url? save if ordered to persist
|
// nothing to read from the url? save if ordered to persist
|
||||||
if (stash === null) {
|
if (stash === null) {
|
||||||
|
@ -70,7 +70,7 @@ export default function StateProvider(Private, $rootScope, $location) {
|
||||||
|
|
||||||
_.defaults(stash, this._defaults);
|
_.defaults(stash, this._defaults);
|
||||||
// apply diff to state from stash, will change state in place via side effect
|
// apply diff to state from stash, will change state in place via side effect
|
||||||
var diffResults = applyDiff(this, stash);
|
let diffResults = applyDiff(this, stash);
|
||||||
|
|
||||||
if (diffResults.keys.length) {
|
if (diffResults.keys.length) {
|
||||||
this.emit('fetch_with_changes', diffResults.keys);
|
this.emit('fetch_with_changes', diffResults.keys);
|
||||||
|
@ -82,8 +82,8 @@ export default function StateProvider(Private, $rootScope, $location) {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
State.prototype.save = function (replace) {
|
State.prototype.save = function (replace) {
|
||||||
var stash = this._readFromURL();
|
let stash = this._readFromURL();
|
||||||
var state = this.toObject();
|
let state = this.toObject();
|
||||||
replace = replace || false;
|
replace = replace || false;
|
||||||
|
|
||||||
if (!stash) {
|
if (!stash) {
|
||||||
|
@ -93,14 +93,14 @@ export default function StateProvider(Private, $rootScope, $location) {
|
||||||
|
|
||||||
_.defaults(state, this._defaults);
|
_.defaults(state, this._defaults);
|
||||||
// apply diff to state from stash, will change state in place via side effect
|
// apply diff to state from stash, will change state in place via side effect
|
||||||
var diffResults = applyDiff(stash, state);
|
let diffResults = applyDiff(stash, state);
|
||||||
|
|
||||||
if (diffResults.keys.length) {
|
if (diffResults.keys.length) {
|
||||||
this.emit('save_with_changes', diffResults.keys);
|
this.emit('save_with_changes', diffResults.keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
// persist the state in the URL
|
// persist the state in the URL
|
||||||
var search = $location.search();
|
let search = $location.search();
|
||||||
search[this._urlParam] = this.toRISON();
|
search[this._urlParam] = this.toRISON();
|
||||||
if (replace) {
|
if (replace) {
|
||||||
$location.search(search).replace();
|
$location.search(search).replace();
|
||||||
|
@ -125,7 +125,7 @@ export default function StateProvider(Private, $rootScope, $location) {
|
||||||
State.prototype.reset = function () {
|
State.prototype.reset = function () {
|
||||||
// apply diff to _attributes from defaults, this is side effecting so
|
// apply diff to _attributes from defaults, this is side effecting so
|
||||||
// it will change the state in place.
|
// it will change the state in place.
|
||||||
var diffResults = applyDiff(this, this._defaults);
|
let diffResults = applyDiff(this, this._defaults);
|
||||||
if (diffResults.keys.length) {
|
if (diffResults.keys.length) {
|
||||||
this.emit('reset_with_changes', diffResults.keys);
|
this.emit('reset_with_changes', diffResults.keys);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import modules from 'ui/modules';
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
|
|
||||||
function Storage(store) {
|
function Storage(store) {
|
||||||
var self = this;
|
let self = this;
|
||||||
self.store = store;
|
self.store = store;
|
||||||
|
|
||||||
self.get = function (key) {
|
self.get = function (key) {
|
||||||
|
@ -30,7 +30,7 @@ function Storage(store) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var createService = function (type) {
|
let createService = function (type) {
|
||||||
return function ($window) {
|
return function ($window) {
|
||||||
return new Storage($window[type]);
|
return new Storage($window[type]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,9 +3,9 @@ import 'ui/field_format_editor/numeral/numeral';
|
||||||
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
||||||
import BoundToConfigObjProvider from 'ui/bound_to_config_obj';
|
import BoundToConfigObjProvider from 'ui/bound_to_config_obj';
|
||||||
export default function AbstractNumeralFormatProvider(Private) {
|
export default function AbstractNumeralFormatProvider(Private) {
|
||||||
var FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
let FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
||||||
var BoundToConfigObj = Private(BoundToConfigObjProvider);
|
let BoundToConfigObj = Private(BoundToConfigObjProvider);
|
||||||
var numeral = require('numeral')();
|
let numeral = require('numeral')();
|
||||||
|
|
||||||
_.class(Numeral).inherits(FieldFormat);
|
_.class(Numeral).inherits(FieldFormat);
|
||||||
function Numeral(params) {
|
function Numeral(params) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral';
|
import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral';
|
||||||
|
|
||||||
export default function BytesFormatProvider(Private) {
|
export default function BytesFormatProvider(Private) {
|
||||||
var Numeral = Private(StringifyTypesNumeralProvider);
|
let Numeral = Private(StringifyTypesNumeralProvider);
|
||||||
return Numeral.factory({
|
return Numeral.factory({
|
||||||
id: 'bytes',
|
id: 'bytes',
|
||||||
title: 'Bytes',
|
title: 'Bytes',
|
||||||
|
|
|
@ -5,8 +5,8 @@ import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/fi
|
||||||
import BoundToConfigObjProvider from 'ui/bound_to_config_obj';
|
import BoundToConfigObjProvider from 'ui/bound_to_config_obj';
|
||||||
import dateTemplate from 'ui/stringify/editors/date.html';
|
import dateTemplate from 'ui/stringify/editors/date.html';
|
||||||
export default function DateTimeFormatProvider(Private) {
|
export default function DateTimeFormatProvider(Private) {
|
||||||
var FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
let FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
||||||
var BoundToConfigObj = Private(BoundToConfigObjProvider);
|
let BoundToConfigObj = Private(BoundToConfigObjProvider);
|
||||||
|
|
||||||
|
|
||||||
_.class(DateTime).inherits(FieldFormat);
|
_.class(DateTime).inherits(FieldFormat);
|
||||||
|
@ -27,7 +27,7 @@ export default function DateTimeFormatProvider(Private) {
|
||||||
template: dateTemplate,
|
template: dateTemplate,
|
||||||
controllerAs: 'cntrl',
|
controllerAs: 'cntrl',
|
||||||
controller: function ($interval, $scope) {
|
controller: function ($interval, $scope) {
|
||||||
var self = this;
|
let self = this;
|
||||||
self.sampleInputs = [
|
self.sampleInputs = [
|
||||||
Date.now(),
|
Date.now(),
|
||||||
+moment().startOf('year'),
|
+moment().startOf('year'),
|
||||||
|
@ -43,11 +43,11 @@ export default function DateTimeFormatProvider(Private) {
|
||||||
DateTime.prototype._convert = function (val) {
|
DateTime.prototype._convert = function (val) {
|
||||||
// don't give away our ref to converter so
|
// don't give away our ref to converter so
|
||||||
// we can hot-swap when config changes
|
// we can hot-swap when config changes
|
||||||
var pattern = this.param('pattern');
|
let pattern = this.param('pattern');
|
||||||
var timezone = this.param('timezone');
|
let timezone = this.param('timezone');
|
||||||
|
|
||||||
var timezoneChanged = this._timeZone !== timezone;
|
let timezoneChanged = this._timeZone !== timezone;
|
||||||
var datePatternChanged = this._memoizedPattern !== pattern;
|
let datePatternChanged = this._memoizedPattern !== pattern;
|
||||||
if (timezoneChanged || datePatternChanged) {
|
if (timezoneChanged || datePatternChanged) {
|
||||||
this._timeZone = timezone;
|
this._timeZone = timezone;
|
||||||
this._memoizedPattern = pattern;
|
this._memoizedPattern = pattern;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
||||||
export default function IpFormatProvider(Private) {
|
export default function IpFormatProvider(Private) {
|
||||||
var FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
let FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
||||||
|
|
||||||
_.class(Ip).inherits(FieldFormat);
|
_.class(Ip).inherits(FieldFormat);
|
||||||
function Ip(params) {
|
function Ip(params) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral';
|
import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral';
|
||||||
|
|
||||||
export default function NumberFormatProvider(Private) {
|
export default function NumberFormatProvider(Private) {
|
||||||
var Numeral = Private(StringifyTypesNumeralProvider);
|
let Numeral = Private(StringifyTypesNumeralProvider);
|
||||||
return Numeral.factory({
|
return Numeral.factory({
|
||||||
id: 'number',
|
id: 'number',
|
||||||
title: 'Number',
|
title: 'Number',
|
||||||
|
|
|
@ -2,8 +2,8 @@ import _ from 'lodash';
|
||||||
import BoundToConfigObjProvider from 'ui/bound_to_config_obj';
|
import BoundToConfigObjProvider from 'ui/bound_to_config_obj';
|
||||||
import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral';
|
import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral';
|
||||||
export default function PercentFormatProvider(Private) {
|
export default function PercentFormatProvider(Private) {
|
||||||
var BoundToConfigObj = Private(BoundToConfigObjProvider);
|
let BoundToConfigObj = Private(BoundToConfigObjProvider);
|
||||||
var Numeral = Private(StringifyTypesNumeralProvider);
|
let Numeral = Private(StringifyTypesNumeralProvider);
|
||||||
|
|
||||||
return Numeral.factory({
|
return Numeral.factory({
|
||||||
id: 'percent',
|
id: 'percent',
|
||||||
|
|
|
@ -3,8 +3,8 @@ import noWhiteSpace from 'ui/utils/no_white_space';
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
||||||
export default function _SourceFormatProvider(Private, shortDotsFilter) {
|
export default function _SourceFormatProvider(Private, shortDotsFilter) {
|
||||||
var FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
let FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
||||||
var template = _.template(noWhiteSpace(require('ui/stringify/types/_source.html')));
|
let template = _.template(noWhiteSpace(require('ui/stringify/types/_source.html')));
|
||||||
|
|
||||||
_.class(Source).inherits(FieldFormat);
|
_.class(Source).inherits(FieldFormat);
|
||||||
function Source(params) {
|
function Source(params) {
|
||||||
|
@ -20,15 +20,15 @@ export default function _SourceFormatProvider(Private, shortDotsFilter) {
|
||||||
html: function sourceToHtml(source, field, hit) {
|
html: function sourceToHtml(source, field, hit) {
|
||||||
if (!field) return this.getConverter('text')(source, field, hit);
|
if (!field) return this.getConverter('text')(source, field, hit);
|
||||||
|
|
||||||
var highlights = (hit && hit.highlight) || {};
|
let highlights = (hit && hit.highlight) || {};
|
||||||
var formatted = field.indexPattern.formatHit(hit);
|
let formatted = field.indexPattern.formatHit(hit);
|
||||||
var highlightPairs = [];
|
let highlightPairs = [];
|
||||||
var sourcePairs = [];
|
let sourcePairs = [];
|
||||||
|
|
||||||
_.keys(formatted).forEach(function (key) {
|
_.keys(formatted).forEach(function (key) {
|
||||||
var pairs = highlights[key] ? highlightPairs : sourcePairs;
|
let pairs = highlights[key] ? highlightPairs : sourcePairs;
|
||||||
var field = shortDotsFilter(key);
|
let field = shortDotsFilter(key);
|
||||||
var val = formatted[key];
|
let val = formatted[key];
|
||||||
pairs.push([field, val]);
|
pairs.push([field, val]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import _ from 'lodash';
|
||||||
import 'ui/field_format_editor/samples/samples';
|
import 'ui/field_format_editor/samples/samples';
|
||||||
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
||||||
export default function StringFormatProvider(Private) {
|
export default function StringFormatProvider(Private) {
|
||||||
var FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
let FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
||||||
|
|
||||||
|
|
||||||
_.class(_String).inherits(FieldFormat);
|
_.class(_String).inherits(FieldFormat);
|
||||||
|
|
|
@ -2,8 +2,8 @@ import _ from 'lodash';
|
||||||
|
|
||||||
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format';
|
||||||
export default function TruncateFormatProvider(Private) {
|
export default function TruncateFormatProvider(Private) {
|
||||||
var FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
let FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
||||||
var omission = '...';
|
let omission = '...';
|
||||||
|
|
||||||
_.class(Truncate).inherits(FieldFormat);
|
_.class(Truncate).inherits(FieldFormat);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ export default function TruncateFormatProvider(Private) {
|
||||||
Truncate.fieldType = ['string'];
|
Truncate.fieldType = ['string'];
|
||||||
|
|
||||||
Truncate.prototype._convert = function (val) {
|
Truncate.prototype._convert = function (val) {
|
||||||
var length = this.param('fieldLength');
|
let length = this.param('fieldLength');
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
return _.trunc(val, {
|
return _.trunc(val, {
|
||||||
'length': length + omission.length,
|
'length': length + omission.length,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/fi
|
||||||
import urlTemplate from 'ui/stringify/editors/url.html';
|
import urlTemplate from 'ui/stringify/editors/url.html';
|
||||||
export default function UrlFormatProvider(Private, highlightFilter) {
|
export default function UrlFormatProvider(Private, highlightFilter) {
|
||||||
|
|
||||||
var FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
let FieldFormat = Private(IndexPatternsFieldFormatProvider);
|
||||||
|
|
||||||
|
|
||||||
_.class(Url).inherits(FieldFormat);
|
_.class(Url).inherits(FieldFormat);
|
||||||
|
@ -31,7 +31,7 @@ export default function UrlFormatProvider(Private, highlightFilter) {
|
||||||
template: urlTemplate,
|
template: urlTemplate,
|
||||||
controllerAs: 'url',
|
controllerAs: 'url',
|
||||||
controller: function ($scope) {
|
controller: function ($scope) {
|
||||||
var iconPattern = '/bundles/src/ui/public/stringify/icons/{{value}}.png';
|
let iconPattern = '/bundles/src/ui/public/stringify/icons/{{value}}.png';
|
||||||
|
|
||||||
this.samples = {
|
this.samples = {
|
||||||
a: [ 'john', '/some/pathname/asset.png', 1234 ],
|
a: [ 'john', '/some/pathname/asset.png', 1234 ],
|
||||||
|
@ -39,7 +39,7 @@ export default function UrlFormatProvider(Private, highlightFilter) {
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$watch('editor.formatParams.type', function (type, prev) {
|
$scope.$watch('editor.formatParams.type', function (type, prev) {
|
||||||
var params = $scope.editor.formatParams;
|
let params = $scope.editor.formatParams;
|
||||||
if (type === 'img' && type !== prev && !params.urlTemplate) {
|
if (type === 'img' && type !== prev && !params.urlTemplate) {
|
||||||
params.urlTemplate = iconPattern;
|
params.urlTemplate = iconPattern;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ export default function UrlFormatProvider(Private, highlightFilter) {
|
||||||
];
|
];
|
||||||
|
|
||||||
Url.prototype._formatUrl = function (value) {
|
Url.prototype._formatUrl = function (value) {
|
||||||
var template = this.param('urlTemplate');
|
let template = this.param('urlTemplate');
|
||||||
if (!template) return value;
|
if (!template) return value;
|
||||||
|
|
||||||
return this._compileTemplate(template)({
|
return this._compileTemplate(template)({
|
||||||
|
@ -70,7 +70,7 @@ export default function UrlFormatProvider(Private, highlightFilter) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Url.prototype._formatLabel = function (value, url) {
|
Url.prototype._formatLabel = function (value, url) {
|
||||||
var template = this.param('labelTemplate');
|
let template = this.param('labelTemplate');
|
||||||
if (url == null) url = this._formatUrl(value);
|
if (url == null) url = this._formatUrl(value);
|
||||||
if (!template) return url;
|
if (!template) return url;
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ export default function UrlFormatProvider(Private, highlightFilter) {
|
||||||
},
|
},
|
||||||
|
|
||||||
html: function (rawValue, field, hit) {
|
html: function (rawValue, field, hit) {
|
||||||
var url = _.escape(this._formatUrl(rawValue));
|
let url = _.escape(this._formatUrl(rawValue));
|
||||||
var label = _.escape(this._formatLabel(rawValue, url));
|
let label = _.escape(this._formatLabel(rawValue, url));
|
||||||
|
|
||||||
switch (this.param('type')) {
|
switch (this.param('type')) {
|
||||||
case 'img':
|
case 'img':
|
||||||
|
@ -103,19 +103,19 @@ export default function UrlFormatProvider(Private, highlightFilter) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Url.prototype._compileTemplate = function (template) {
|
Url.prototype._compileTemplate = function (template) {
|
||||||
var parts = template.split(Url.templateMatchRE).map(function (part, i) {
|
let parts = template.split(Url.templateMatchRE).map(function (part, i) {
|
||||||
// trim all the odd bits, the variable names
|
// trim all the odd bits, the variable names
|
||||||
return (i % 2) ? part.trim() : part;
|
return (i % 2) ? part.trim() : part;
|
||||||
});
|
});
|
||||||
|
|
||||||
return function (locals) {
|
return function (locals) {
|
||||||
// replace all the odd bits with their local var
|
// replace all the odd bits with their local var
|
||||||
var output = '';
|
let output = '';
|
||||||
var i = -1;
|
let i = -1;
|
||||||
while (++i < parts.length) {
|
while (++i < parts.length) {
|
||||||
if (i % 2) {
|
if (i % 2) {
|
||||||
if (locals.hasOwnProperty(parts[i])) {
|
if (locals.hasOwnProperty(parts[i])) {
|
||||||
var local = locals[parts[i]];
|
let local = locals[parts[i]];
|
||||||
output += local == null ? '' : local;
|
output += local == null ? '' : local;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,15 +2,15 @@ import _ from 'lodash';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import 'ui/config';
|
import 'ui/config';
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var $style = $('<style>').appendTo('head').attr('id', 'style-compile');
|
let $style = $('<style>').appendTo('head').attr('id', 'style-compile');
|
||||||
|
|
||||||
|
|
||||||
uiModules
|
uiModules
|
||||||
.get('kibana')
|
.get('kibana')
|
||||||
.run(function ($rootScope, $compile, config) {
|
.run(function ($rootScope, $compile, config) {
|
||||||
var truncateGradientHeight = 15;
|
let truncateGradientHeight = 15;
|
||||||
var template = _.template(require('./style_compile.css.tmpl'));
|
let template = _.template(require('./style_compile.css.tmpl'));
|
||||||
var locals = {};
|
let locals = {};
|
||||||
|
|
||||||
// watch the value of the truncate:maxHeight config param
|
// watch the value of the truncate:maxHeight config param
|
||||||
$rootScope.$watch(function () {
|
$rootScope.$watch(function () {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import VisRenderbotProvider from 'ui/vis/renderbot';
|
import VisRenderbotProvider from 'ui/vis/renderbot';
|
||||||
export default function TemplateRenderbotFactory(Private, $compile, $rootScope) {
|
export default function TemplateRenderbotFactory(Private, $compile, $rootScope) {
|
||||||
var Renderbot = Private(VisRenderbotProvider);
|
let Renderbot = Private(VisRenderbotProvider);
|
||||||
|
|
||||||
_.class(TemplateRenderbot).inherits(Renderbot);
|
_.class(TemplateRenderbot).inherits(Renderbot);
|
||||||
function TemplateRenderbot(vis, $el, uiState) {
|
function TemplateRenderbot(vis, $el, uiState) {
|
||||||
|
|
|
@ -2,8 +2,8 @@ import _ from 'lodash';
|
||||||
import VisVisTypeProvider from 'ui/vis/vis_type';
|
import VisVisTypeProvider from 'ui/vis/vis_type';
|
||||||
import TemplateVisTypeTemplateRenderbotProvider from 'ui/template_vis_type/template_renderbot';
|
import TemplateVisTypeTemplateRenderbotProvider from 'ui/template_vis_type/template_renderbot';
|
||||||
export default function TemplateVisTypeFactory(Private) {
|
export default function TemplateVisTypeFactory(Private) {
|
||||||
var VisType = Private(VisVisTypeProvider);
|
let VisType = Private(VisVisTypeProvider);
|
||||||
var TemplateRenderbot = Private(TemplateVisTypeTemplateRenderbotProvider);
|
let TemplateRenderbot = Private(TemplateVisTypeTemplateRenderbotProvider);
|
||||||
|
|
||||||
_.class(TemplateVisType).inherits(VisType);
|
_.class(TemplateVisType).inherits(VisType);
|
||||||
function TemplateVisType(opts) {
|
function TemplateVisType(opts) {
|
||||||
|
|
|
@ -18,8 +18,8 @@ $('body').attr('id', 'test-harness-body'); // so we can make high priority selec
|
||||||
|
|
||||||
|
|
||||||
/*** Setup seeded random ***/
|
/*** Setup seeded random ***/
|
||||||
var seedInput = parse(window.location.href, true).query.seed;
|
let seedInput = parse(window.location.href, true).query.seed;
|
||||||
var seed = _.add(seedInput, 0) || Date.now();
|
let seed = _.add(seedInput, 0) || Date.now();
|
||||||
Math.random = _.bindKey(new Nonsense(seed), 'frac');
|
Math.random = _.bindKey(new Nonsense(seed), 'frac');
|
||||||
Math.random.nonsense = new Nonsense(seed);
|
Math.random.nonsense = new Nonsense(seed);
|
||||||
console.log('Random-ness seed: ' + seed);
|
console.log('Random-ness seed: ' + seed);
|
||||||
|
@ -38,7 +38,7 @@ before(function () {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
|
|
||||||
let mapper;
|
let mapper;
|
||||||
var Runner = window.Mocha.Runner;
|
let Runner = window.Mocha.Runner;
|
||||||
|
|
||||||
Runner.prototype.emit = _.wrap(Runner.prototype.emit, function (emit, event, test, err) {
|
Runner.prototype.emit = _.wrap(Runner.prototype.emit, function (emit, event, test, err) {
|
||||||
if (err && mapper) err = mapper.mapError(err);
|
if (err && mapper) err = mapper.mapError(err);
|
||||||
|
|
|
@ -3,7 +3,7 @@ import moment from 'moment';
|
||||||
export default function DateIntervalRoundingRulesProvider() {
|
export default function DateIntervalRoundingRulesProvider() {
|
||||||
// these are the rounding rules used by roundInterval()
|
// these are the rounding rules used by roundInterval()
|
||||||
|
|
||||||
var roundingRules = [
|
let roundingRules = [
|
||||||
[ d(500, 'ms'), d(100, 'ms') ],
|
[ d(500, 'ms'), d(100, 'ms') ],
|
||||||
[ d(5, 'second'), d(1, 'second') ],
|
[ d(5, 'second'), d(1, 'second') ],
|
||||||
[ d(7.5, 'second'), d(5, 'second') ],
|
[ d(7.5, 'second'), d(5, 'second') ],
|
||||||
|
@ -22,16 +22,16 @@ export default function DateIntervalRoundingRulesProvider() {
|
||||||
[ Infinity, d(1, 'year') ]
|
[ Infinity, d(1, 'year') ]
|
||||||
];
|
];
|
||||||
|
|
||||||
var revRoundingRules = roundingRules.slice(0).reverse();
|
let revRoundingRules = roundingRules.slice(0).reverse();
|
||||||
|
|
||||||
function find(rules, check, last) {
|
function find(rules, check, last) {
|
||||||
function pick(buckets, duration) {
|
function pick(buckets, duration) {
|
||||||
var target = duration / buckets;
|
let target = duration / buckets;
|
||||||
let lastResp;
|
let lastResp;
|
||||||
|
|
||||||
for (var i = 0; i < rules.length; i++) {
|
for (let i = 0; i < rules.length; i++) {
|
||||||
var rule = rules[i];
|
let rule = rules[i];
|
||||||
var resp = check(rule[0], rule[1], target);
|
let resp = check(rule[0], rule[1], target);
|
||||||
|
|
||||||
if (resp == null) {
|
if (resp == null) {
|
||||||
if (!last) continue;
|
if (!last) continue;
|
||||||
|
@ -44,12 +44,12 @@ export default function DateIntervalRoundingRulesProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback to just a number of milliseconds, ensure ms is >= 1
|
// fallback to just a number of milliseconds, ensure ms is >= 1
|
||||||
var ms = Math.max(Math.floor(target), 1);
|
let ms = Math.max(Math.floor(target), 1);
|
||||||
return moment.duration(ms, 'ms');
|
return moment.duration(ms, 'ms');
|
||||||
}
|
}
|
||||||
|
|
||||||
return function (buckets, duration) {
|
return function (buckets, duration) {
|
||||||
var interval = pick(buckets, duration);
|
let interval = pick(buckets, duration);
|
||||||
if (interval) return moment.duration(interval._data);
|
if (interval) return moment.duration(interval._data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ import moment from 'moment';
|
||||||
import dateMath from 'ui/utils/date_math';
|
import dateMath from 'ui/utils/date_math';
|
||||||
export default function () {
|
export default function () {
|
||||||
|
|
||||||
var unitsDesc = dateMath.unitsDesc;
|
let unitsDesc = dateMath.unitsDesc;
|
||||||
var largeMax = unitsDesc.indexOf('M');
|
let largeMax = unitsDesc.indexOf('M');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a moment.duration into an es
|
* Convert a moment.duration into an es
|
||||||
|
@ -14,9 +14,9 @@ export default function () {
|
||||||
* @return {object}
|
* @return {object}
|
||||||
*/
|
*/
|
||||||
function esDuration(duration) {
|
function esDuration(duration) {
|
||||||
for (var i = 0; i < unitsDesc.length; i++) {
|
for (let i = 0; i < unitsDesc.length; i++) {
|
||||||
var unit = unitsDesc[i];
|
let unit = unitsDesc[i];
|
||||||
var val = duration.as(unit);
|
let val = duration.as(unit);
|
||||||
// find a unit that rounds neatly
|
// find a unit that rounds neatly
|
||||||
if (val >= 1 && Math.floor(val) === val) {
|
if (val >= 1 && Math.floor(val) === val) {
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ export default function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ms = duration.as('ms');
|
let ms = duration.as('ms');
|
||||||
return {
|
return {
|
||||||
value: ms,
|
value: ms,
|
||||||
unit: 'ms',
|
unit: 'ms',
|
||||||
|
|
|
@ -6,9 +6,9 @@ import TimeBucketsCalcAutoIntervalProvider from 'ui/time_buckets/calc_auto_inter
|
||||||
import TimeBucketsCalcEsIntervalProvider from 'ui/time_buckets/calc_es_interval';
|
import TimeBucketsCalcEsIntervalProvider from 'ui/time_buckets/calc_es_interval';
|
||||||
export default function IntervalHelperProvider(Private, timefilter, config) {
|
export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
|
|
||||||
var calcAuto = Private(TimeBucketsCalcAutoIntervalProvider);
|
let calcAuto = Private(TimeBucketsCalcAutoIntervalProvider);
|
||||||
var calcEsInterval = Private(TimeBucketsCalcEsIntervalProvider);
|
let calcEsInterval = Private(TimeBucketsCalcEsIntervalProvider);
|
||||||
var tzOffset = moment().format('Z');
|
let tzOffset = moment().format('Z');
|
||||||
|
|
||||||
function isValidMoment(m) {
|
function isValidMoment(m) {
|
||||||
return m && ('isValid' in m) && m.isValid();
|
return m && ('isValid' in m) && m.isValid();
|
||||||
|
@ -51,11 +51,11 @@ export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
bounds = _.isArray(input) ? input : [];
|
bounds = _.isArray(input) ? input : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var moments = _(bounds)
|
let moments = _(bounds)
|
||||||
.map(_.ary(moment, 1))
|
.map(_.ary(moment, 1))
|
||||||
.sortBy(Number);
|
.sortBy(Number);
|
||||||
|
|
||||||
var valid = moments.size() === 2 && moments.every(isValidMoment);
|
let valid = moments.size() === 2 && moments.every(isValidMoment);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
this.clearBounds();
|
this.clearBounds();
|
||||||
throw new Error('invalid bounds set: ' + input);
|
throw new Error('invalid bounds set: ' + input);
|
||||||
|
@ -133,7 +133,7 @@ export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
* @param {object|string|moment.duration} input - see desc
|
* @param {object|string|moment.duration} input - see desc
|
||||||
*/
|
*/
|
||||||
TimeBuckets.prototype.setInterval = function (input) {
|
TimeBuckets.prototype.setInterval = function (input) {
|
||||||
var interval = input;
|
let interval = input;
|
||||||
|
|
||||||
// selection object -> val
|
// selection object -> val
|
||||||
if (_.isObject(input)) {
|
if (_.isObject(input)) {
|
||||||
|
@ -197,13 +197,13 @@ export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
* @return {[type]} [description]
|
* @return {[type]} [description]
|
||||||
*/
|
*/
|
||||||
TimeBuckets.prototype.getInterval = function () {
|
TimeBuckets.prototype.getInterval = function () {
|
||||||
var self = this;
|
let self = this;
|
||||||
var duration = self.getDuration();
|
let duration = self.getDuration();
|
||||||
return decorateInterval(maybeScaleInterval(readInterval()));
|
return decorateInterval(maybeScaleInterval(readInterval()));
|
||||||
|
|
||||||
// either pull the interval from state or calculate the auto-interval
|
// either pull the interval from state or calculate the auto-interval
|
||||||
function readInterval() {
|
function readInterval() {
|
||||||
var interval = self._i;
|
let interval = self._i;
|
||||||
if (moment.isDuration(interval)) return interval;
|
if (moment.isDuration(interval)) return interval;
|
||||||
return calcAuto.near(config.get('histogram:barTarget'), duration);
|
return calcAuto.near(config.get('histogram:barTarget'), duration);
|
||||||
}
|
}
|
||||||
|
@ -212,8 +212,8 @@ export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
function maybeScaleInterval(interval) {
|
function maybeScaleInterval(interval) {
|
||||||
if (!self.hasBounds()) return interval;
|
if (!self.hasBounds()) return interval;
|
||||||
|
|
||||||
var maxLength = config.get('histogram:maxBars');
|
let maxLength = config.get('histogram:maxBars');
|
||||||
var approxLen = duration / interval;
|
let approxLen = duration / interval;
|
||||||
let scaled;
|
let scaled;
|
||||||
|
|
||||||
if (approxLen > maxLength) {
|
if (approxLen > maxLength) {
|
||||||
|
@ -234,13 +234,13 @@ export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
|
|
||||||
// append some TimeBuckets specific props to the interval
|
// append some TimeBuckets specific props to the interval
|
||||||
function decorateInterval(interval) {
|
function decorateInterval(interval) {
|
||||||
var esInterval = calcEsInterval(interval);
|
let esInterval = calcEsInterval(interval);
|
||||||
interval.esValue = esInterval.value;
|
interval.esValue = esInterval.value;
|
||||||
interval.esUnit = esInterval.unit;
|
interval.esUnit = esInterval.unit;
|
||||||
interval.expression = esInterval.expression;
|
interval.expression = esInterval.expression;
|
||||||
interval.overflow = duration > interval ? moment.duration(interval - duration) : false;
|
interval.overflow = duration > interval ? moment.duration(interval - duration) : false;
|
||||||
|
|
||||||
var prettyUnits = moment.normalizeUnits(esInterval.unit);
|
let prettyUnits = moment.normalizeUnits(esInterval.unit);
|
||||||
if (esInterval.value === 1) {
|
if (esInterval.value === 1) {
|
||||||
interval.description = prettyUnits;
|
interval.description = prettyUnits;
|
||||||
} else {
|
} else {
|
||||||
|
@ -263,11 +263,11 @@ export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
TimeBuckets.prototype.getScaledDateFormat = function () {
|
TimeBuckets.prototype.getScaledDateFormat = function () {
|
||||||
var interval = this.getInterval();
|
let interval = this.getInterval();
|
||||||
var rules = config.get('dateFormat:scaled');
|
let rules = config.get('dateFormat:scaled');
|
||||||
|
|
||||||
for (var i = rules.length - 1; i >= 0; i--) {
|
for (let i = rules.length - 1; i >= 0; i--) {
|
||||||
var rule = rules[i];
|
let rule = rules[i];
|
||||||
if (!rule[0] || interval >= moment.duration(rule[0])) {
|
if (!rule[0] || interval >= moment.duration(rule[0])) {
|
||||||
return rule[1];
|
return rule[1];
|
||||||
}
|
}
|
||||||
|
@ -278,23 +278,23 @@ export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
|
|
||||||
|
|
||||||
TimeBuckets.__cached__ = function (self) {
|
TimeBuckets.__cached__ = function (self) {
|
||||||
var cache = {};
|
let cache = {};
|
||||||
var sameMoment = same(moment.isMoment);
|
let sameMoment = same(moment.isMoment);
|
||||||
var sameDuration = same(moment.isDuration);
|
let sameDuration = same(moment.isDuration);
|
||||||
|
|
||||||
var desc = {
|
let desc = {
|
||||||
__cached__: {
|
__cached__: {
|
||||||
value: self
|
value: self
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var breakers = {
|
let breakers = {
|
||||||
setBounds: 'bounds',
|
setBounds: 'bounds',
|
||||||
clearBounds: 'bounds',
|
clearBounds: 'bounds',
|
||||||
setInterval: 'interval'
|
setInterval: 'interval'
|
||||||
};
|
};
|
||||||
|
|
||||||
var resources = {
|
let resources = {
|
||||||
bounds: {
|
bounds: {
|
||||||
setup: function () {
|
setup: function () {
|
||||||
return [self._lb, self._ub];
|
return [self._lb, self._ub];
|
||||||
|
@ -326,16 +326,16 @@ export default function IntervalHelperProvider(Private, timefilter, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cacheBreaker(prop) {
|
function cacheBreaker(prop) {
|
||||||
var resource = resources[breakers[prop]];
|
let resource = resources[breakers[prop]];
|
||||||
var setup = resource.setup;
|
let setup = resource.setup;
|
||||||
var changes = resource.changes;
|
let changes = resource.changes;
|
||||||
var deps = resource.deps;
|
let deps = resource.deps;
|
||||||
var fn = self[prop];
|
let fn = self[prop];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
value: function cacheBreaker(input) {
|
value: function cacheBreaker(input) {
|
||||||
var prev = setup.call(self);
|
let prev = setup.call(self);
|
||||||
var ret = fn.apply(self, arguments);
|
let ret = fn.apply(self, arguments);
|
||||||
|
|
||||||
if (changes.call(self, prev)) {
|
if (changes.call(self, prev)) {
|
||||||
cache = {};
|
cache = {};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import UtilsDiffTimePickerValsProvider from 'ui/utils/diff_time_picker_vals';
|
import UtilsDiffTimePickerValsProvider from 'ui/utils/diff_time_picker_vals';
|
||||||
export default function diffTimeProvider(Private) {
|
export default function diffTimeProvider(Private) {
|
||||||
var diff = Private(UtilsDiffTimePickerValsProvider);
|
let diff = Private(UtilsDiffTimePickerValsProvider);
|
||||||
|
|
||||||
return function (self) {
|
return function (self) {
|
||||||
var oldRefreshInterval = _.clone(self.refreshInterval);
|
let oldRefreshInterval = _.clone(self.refreshInterval);
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
if (diff(self.refreshInterval, oldRefreshInterval)) {
|
if (diff(self.refreshInterval, oldRefreshInterval)) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import UtilsDiffTimePickerValsProvider from 'ui/utils/diff_time_picker_vals';
|
import UtilsDiffTimePickerValsProvider from 'ui/utils/diff_time_picker_vals';
|
||||||
export default function diffTimeProvider(Private) {
|
export default function diffTimeProvider(Private) {
|
||||||
var diff = Private(UtilsDiffTimePickerValsProvider);
|
let diff = Private(UtilsDiffTimePickerValsProvider);
|
||||||
|
|
||||||
return function (self) {
|
return function (self) {
|
||||||
var oldTime = _.clone(self.time);
|
let oldTime = _.clone(self.time);
|
||||||
return function () {
|
return function () {
|
||||||
if (diff(self.time, oldTime)) {
|
if (diff(self.time, oldTime)) {
|
||||||
self.emit('update');
|
self.emit('update');
|
||||||
|
|
|
@ -20,12 +20,12 @@ uiModules
|
||||||
.get('kibana')
|
.get('kibana')
|
||||||
.service('timefilter', function (Private, globalState, $rootScope, config) {
|
.service('timefilter', function (Private, globalState, $rootScope, config) {
|
||||||
|
|
||||||
var Events = Private(EventsProvider);
|
let Events = Private(EventsProvider);
|
||||||
var diff = Private(UtilsDiffTimePickerValsProvider);
|
let diff = Private(UtilsDiffTimePickerValsProvider);
|
||||||
|
|
||||||
|
|
||||||
function convertISO8601(stringTime) {
|
function convertISO8601(stringTime) {
|
||||||
var obj = moment(stringTime, 'YYYY-MM-DDTHH:mm:ss.SSSZ', true);
|
let obj = moment(stringTime, 'YYYY-MM-DDTHH:mm:ss.SSSZ', true);
|
||||||
return obj.isValid() ? obj : stringTime;
|
return obj.isValid() ? obj : stringTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ uiModules
|
||||||
function Timefilter() {
|
function Timefilter() {
|
||||||
Timefilter.Super.call(this);
|
Timefilter.Super.call(this);
|
||||||
|
|
||||||
var self = this;
|
let self = this;
|
||||||
var diffTime = Private(TimefilterLibDiffTimeProvider)(self);
|
let diffTime = Private(TimefilterLibDiffTimeProvider)(self);
|
||||||
var diffInterval = Private(TimefilterLibDiffIntervalProvider)(self);
|
let diffInterval = Private(TimefilterLibDiffIntervalProvider)(self);
|
||||||
|
|
||||||
self.enabled = false;
|
self.enabled = false;
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ uiModules
|
||||||
});
|
});
|
||||||
|
|
||||||
self.consumeDefaults = _.once(function () {
|
self.consumeDefaults = _.once(function () {
|
||||||
var timeDefaults = config.get('timepicker:timeDefaults');
|
let timeDefaults = config.get('timepicker:timeDefaults');
|
||||||
var refreshIntervalDefaults = config.get('timepicker:refreshIntervalDefaults');
|
let refreshIntervalDefaults = config.get('timepicker:refreshIntervalDefaults');
|
||||||
|
|
||||||
// These can be date math strings or moments.
|
// These can be date math strings or moments.
|
||||||
self.time = _.defaults(globalState.time || {}, timeDefaults);
|
self.time = _.defaults(globalState.time || {}, timeDefaults);
|
||||||
|
@ -54,8 +54,8 @@ uiModules
|
||||||
|
|
||||||
globalState.on('fetch_with_changes', function () {
|
globalState.on('fetch_with_changes', function () {
|
||||||
// clone and default to {} in one
|
// clone and default to {} in one
|
||||||
var newTime = _.defaults({}, globalState.time, timeDefaults);
|
let newTime = _.defaults({}, globalState.time, timeDefaults);
|
||||||
var newRefreshInterval = _.defaults({}, globalState.refreshInterval, refreshIntervalDefaults);
|
let newRefreshInterval = _.defaults({}, globalState.refreshInterval, refreshIntervalDefaults);
|
||||||
|
|
||||||
if (newTime) {
|
if (newTime) {
|
||||||
if (newTime.to) newTime.to = convertISO8601(newTime.to);
|
if (newTime.to) newTime.to = convertISO8601(newTime.to);
|
||||||
|
@ -85,10 +85,10 @@ uiModules
|
||||||
|
|
||||||
Timefilter.prototype.get = function (indexPattern) {
|
Timefilter.prototype.get = function (indexPattern) {
|
||||||
let filter;
|
let filter;
|
||||||
var timefield = indexPattern.timeFieldName && _.find(indexPattern.fields, {name: indexPattern.timeFieldName});
|
let timefield = indexPattern.timeFieldName && _.find(indexPattern.fields, {name: indexPattern.timeFieldName});
|
||||||
|
|
||||||
if (timefield) {
|
if (timefield) {
|
||||||
var bounds = this.getBounds();
|
let bounds = this.getBounds();
|
||||||
filter = {range : {}};
|
filter = {range : {}};
|
||||||
filter.range[timefield.name] = {
|
filter.range[timefield.name] = {
|
||||||
gte: bounds.min.valueOf(),
|
gte: bounds.min.valueOf(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var module = uiModules.get('kibana');
|
let module = uiModules.get('kibana');
|
||||||
|
|
||||||
module.constant('quickRanges', [
|
module.constant('quickRanges', [
|
||||||
{ from: 'now/d', to: 'now/d', display: 'Today', section: 0 },
|
{ from: 'now/d', to: 'now/d', display: 'Today', section: 0 },
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var module = uiModules.get('kibana');
|
let module = uiModules.get('kibana');
|
||||||
|
|
||||||
module.constant('refreshIntervals', [
|
module.constant('refreshIntervals', [
|
||||||
{ value : 0, display: 'Off', section: 0},
|
{ value : 0, display: 'Off', section: 0},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var module = uiModules.get('kibana');
|
let module = uiModules.get('kibana');
|
||||||
|
|
||||||
module.constant('timeUnits', {
|
module.constant('timeUnits', {
|
||||||
s: 'second',
|
s: 'second',
|
||||||
|
|
|
@ -10,8 +10,8 @@ import 'ui/timepicker/refresh_intervals';
|
||||||
import 'ui/timepicker/time_units';
|
import 'ui/timepicker/time_units';
|
||||||
import 'ui/timepicker/kbn_global_timepicker';
|
import 'ui/timepicker/kbn_global_timepicker';
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var module = uiModules.get('ui/timepicker');
|
let module = uiModules.get('ui/timepicker');
|
||||||
var notify = new Notifier({
|
let notify = new Notifier({
|
||||||
location: 'timepicker',
|
location: 'timepicker',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ module.directive('kbnTimepicker', function (quickRanges, timeUnits, refreshInter
|
||||||
},
|
},
|
||||||
template: html,
|
template: html,
|
||||||
controller: function ($scope) {
|
controller: function ($scope) {
|
||||||
var init = function () {
|
let init = function () {
|
||||||
$scope.setMode($scope.mode);
|
$scope.setMode($scope.mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ module.directive('kbnTimepicker', function (quickRanges, timeUnits, refreshInter
|
||||||
case 'quick':
|
case 'quick':
|
||||||
break;
|
break;
|
||||||
case 'relative':
|
case 'relative':
|
||||||
var fromParts = $scope.from.toString().split('-');
|
let fromParts = $scope.from.toString().split('-');
|
||||||
var relativeParts = [];
|
let relativeParts = [];
|
||||||
|
|
||||||
// Try to parse the relative time, if we can't use moment duration to guestimate
|
// Try to parse the relative time, if we can't use moment duration to guestimate
|
||||||
if ($scope.to.toString() === 'now' && fromParts[0] === 'now' && fromParts[1]) {
|
if ($scope.to.toString() === 'now' && fromParts[0] === 'now' && fromParts[1]) {
|
||||||
|
@ -89,11 +89,11 @@ module.directive('kbnTimepicker', function (quickRanges, timeUnits, refreshInter
|
||||||
$scope.relative.count = parseInt(relativeParts[1], 10);
|
$scope.relative.count = parseInt(relativeParts[1], 10);
|
||||||
$scope.relative.unit = relativeParts[2];
|
$scope.relative.unit = relativeParts[2];
|
||||||
} else {
|
} else {
|
||||||
var duration = moment.duration(moment().diff(dateMath.parse($scope.from)));
|
let duration = moment.duration(moment().diff(dateMath.parse($scope.from)));
|
||||||
var units = _.pluck(_.clone($scope.relativeOptions).reverse(), 'value');
|
let units = _.pluck(_.clone($scope.relativeOptions).reverse(), 'value');
|
||||||
if ($scope.from.toString().split('/')[1]) $scope.relative.round = true;
|
if ($scope.from.toString().split('/')[1]) $scope.relative.round = true;
|
||||||
for (var i = 0; i < units.length; i++) {
|
for (let i = 0; i < units.length; i++) {
|
||||||
var as = duration.as(units[i]);
|
let as = duration.as(units[i]);
|
||||||
if (as > 1) {
|
if (as > 1) {
|
||||||
$scope.relative.count = Math.round(as);
|
$scope.relative.count = Math.round(as);
|
||||||
$scope.relative.unit = units[i];
|
$scope.relative.unit = units[i];
|
||||||
|
@ -125,7 +125,7 @@ module.directive('kbnTimepicker', function (quickRanges, timeUnits, refreshInter
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.formatRelative = function () {
|
$scope.formatRelative = function () {
|
||||||
var parsed = dateMath.parse(getRelativeString());
|
let parsed = dateMath.parse(getRelativeString());
|
||||||
$scope.relative.preview = parsed ? parsed.format($scope.format) : undefined;
|
$scope.relative.preview = parsed ? parsed.format($scope.format) : undefined;
|
||||||
return parsed;
|
return parsed;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import 'ui/notify/directives';
|
import 'ui/notify/directives';
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var typeahead = uiModules.get('kibana/typeahead');
|
let typeahead = uiModules.get('kibana/typeahead');
|
||||||
|
|
||||||
|
|
||||||
typeahead.directive('kbnTypeaheadInput', function ($rootScope) {
|
typeahead.directive('kbnTypeaheadInput', function ($rootScope) {
|
||||||
|
@ -11,8 +11,8 @@ typeahead.directive('kbnTypeaheadInput', function ($rootScope) {
|
||||||
require: ['^ngModel', '^kbnTypeahead'],
|
require: ['^ngModel', '^kbnTypeahead'],
|
||||||
|
|
||||||
link: function ($scope, $el, $attr, deps) {
|
link: function ($scope, $el, $attr, deps) {
|
||||||
var model = deps[0];
|
let model = deps[0];
|
||||||
var typeaheadCtrl = deps[1];
|
let typeaheadCtrl = deps[1];
|
||||||
|
|
||||||
typeaheadCtrl.setInputModel(model);
|
typeaheadCtrl.setInputModel(model);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import _ from 'lodash';
|
||||||
import listTemplate from 'ui/typeahead/partials/typeahead-items.html';
|
import listTemplate from 'ui/typeahead/partials/typeahead-items.html';
|
||||||
import 'ui/notify/directives';
|
import 'ui/notify/directives';
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var typeahead = uiModules.get('kibana/typeahead');
|
let typeahead = uiModules.get('kibana/typeahead');
|
||||||
|
|
||||||
|
|
||||||
typeahead.directive('kbnTypeaheadItems', function () {
|
typeahead.directive('kbnTypeaheadItems', function () {
|
||||||
|
|
|
@ -3,11 +3,11 @@ import 'ui/typeahead/typeahead.less';
|
||||||
import 'ui/typeahead/_input';
|
import 'ui/typeahead/_input';
|
||||||
import 'ui/typeahead/_items';
|
import 'ui/typeahead/_items';
|
||||||
import uiModules from 'ui/modules';
|
import uiModules from 'ui/modules';
|
||||||
var typeahead = uiModules.get('kibana/typeahead');
|
let typeahead = uiModules.get('kibana/typeahead');
|
||||||
|
|
||||||
|
|
||||||
typeahead.directive('kbnTypeahead', function () {
|
typeahead.directive('kbnTypeahead', function () {
|
||||||
var keyMap = {
|
let keyMap = {
|
||||||
ESC: 27,
|
ESC: 27,
|
||||||
UP: 38,
|
UP: 38,
|
||||||
DOWN: 40,
|
DOWN: 40,
|
||||||
|
@ -23,7 +23,7 @@ typeahead.directive('kbnTypeahead', function () {
|
||||||
controllerAs: 'typeahead',
|
controllerAs: 'typeahead',
|
||||||
|
|
||||||
controller: function ($scope, $element, $timeout, PersistedLog, config) {
|
controller: function ($scope, $element, $timeout, PersistedLog, config) {
|
||||||
var self = this;
|
let self = this;
|
||||||
self.form = $element.closest('form');
|
self.form = $element.closest('form');
|
||||||
self.query = '';
|
self.query = '';
|
||||||
self.hidden = true;
|
self.hidden = true;
|
||||||
|
@ -76,7 +76,7 @@ typeahead.directive('kbnTypeahead', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.activateNext = function () {
|
self.activateNext = function () {
|
||||||
var index = self.getActiveIndex();
|
let index = self.getActiveIndex();
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
index = 0;
|
index = 0;
|
||||||
} else if (index < $scope.filteredItems.length - 1) {
|
} else if (index < $scope.filteredItems.length - 1) {
|
||||||
|
@ -87,7 +87,7 @@ typeahead.directive('kbnTypeahead', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.activatePrev = function () {
|
self.activatePrev = function () {
|
||||||
var index = self.getActiveIndex();
|
let index = self.getActiveIndex();
|
||||||
|
|
||||||
if (index > 0 && index != null) {
|
if (index > 0 && index != null) {
|
||||||
--index;
|
--index;
|
||||||
|
@ -138,7 +138,7 @@ typeahead.directive('kbnTypeahead', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.keypressHandler = function (ev) {
|
self.keypressHandler = function (ev) {
|
||||||
var keyCode = ev.which || ev.keyCode;
|
let keyCode = ev.which || ev.keyCode;
|
||||||
|
|
||||||
if (self.focused) {
|
if (self.focused) {
|
||||||
self.hidden = false;
|
self.hidden = false;
|
||||||
|
@ -194,11 +194,11 @@ typeahead.directive('kbnTypeahead', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the filteredItems using the query
|
// update the filteredItems using the query
|
||||||
var beginningMatches = $scope.items.filter(function (item) {
|
let beginningMatches = $scope.items.filter(function (item) {
|
||||||
return item.indexOf(query) === 0;
|
return item.indexOf(query) === 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
var otherMatches = $scope.items.filter(function (item) {
|
let otherMatches = $scope.items.filter(function (item) {
|
||||||
return item.indexOf(query) > 0;
|
return item.indexOf(query) > 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue