mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
tech(lodash): began migration work
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jquery": "3.1.0",
|
"jquery": "3.1.0",
|
||||||
|
"lodash": "~4.15.0",
|
||||||
"angular": "1.5.3",
|
"angular": "1.5.3",
|
||||||
"angular-route": "1.5.3",
|
"angular-route": "1.5.3",
|
||||||
"angular-mocks": "1.5.3",
|
"angular-mocks": "1.5.3",
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function (_, $, coreModule) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.$apply(function() {
|
$scope.$apply(function() {
|
||||||
var selected = _.findWhere($scope.altSegments, { value: value });
|
var selected = _.find($scope.altSegments, {value: value});
|
||||||
if (selected) {
|
if (selected) {
|
||||||
segment.value = selected.value;
|
segment.value = selected.value;
|
||||||
segment.html = selected.html;
|
segment.html = selected.html;
|
||||||
@@ -174,7 +174,7 @@ function (_, $, coreModule) {
|
|||||||
pre: function postLink($scope, elem, attrs) {
|
pre: function postLink($scope, elem, attrs) {
|
||||||
|
|
||||||
$scope.valueToSegment = function(value) {
|
$scope.valueToSegment = function(value) {
|
||||||
var option = _.findWhere($scope.options, {value: value});
|
var option = _.find($scope.options, {value: value});
|
||||||
var segment = {
|
var segment = {
|
||||||
cssClass: attrs.cssClass,
|
cssClass: attrs.cssClass,
|
||||||
custom: attrs.custom,
|
custom: attrs.custom,
|
||||||
@@ -196,7 +196,7 @@ function (_, $, coreModule) {
|
|||||||
|
|
||||||
$scope.onSegmentChange = function() {
|
$scope.onSegmentChange = function() {
|
||||||
if ($scope.options) {
|
if ($scope.options) {
|
||||||
var option = _.findWhere($scope.options, {text: $scope.segment.value});
|
var option = _.find($scope.options, {text: $scope.segment.value});
|
||||||
if (option && option.value !== $scope.property) {
|
if (option && option.value !== $scope.property) {
|
||||||
$scope.property = option.value;
|
$scope.property = option.value;
|
||||||
} else if (attrs.custom !== 'false') {
|
} else if (attrs.custom !== 'false') {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function (angular, _, coreModule) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// convert values to text
|
// convert values to text
|
||||||
var currentTexts = _.pluck(selectedAndNotInTag, 'text');
|
var currentTexts = _.map(selectedAndNotInTag, 'text');
|
||||||
|
|
||||||
// join texts
|
// join texts
|
||||||
vm.linkText = currentTexts.join(' + ');
|
vm.linkText = currentTexts.join(' + ');
|
||||||
@@ -167,7 +167,7 @@ function (angular, _, coreModule) {
|
|||||||
_.each(vm.tags, function(tag) {
|
_.each(vm.tags, function(tag) {
|
||||||
if (tag.selected) {
|
if (tag.selected) {
|
||||||
_.each(tag.values, function(value) {
|
_.each(tag.values, function(value) {
|
||||||
if (!_.findWhere(vm.selectedValues, {value: value})) {
|
if (!_.find(vm.selectedValues, {value: value})) {
|
||||||
tag.selected = false;
|
tag.selected = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -175,8 +175,8 @@ function (angular, _, coreModule) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
vm.selectedTags = _.filter(vm.tags, {selected: true});
|
vm.selectedTags = _.filter(vm.tags, {selected: true});
|
||||||
vm.variable.current.value = _.pluck(vm.selectedValues, 'value');
|
vm.variable.current.value = _.map(vm.selectedValues, 'value');
|
||||||
vm.variable.current.text = _.pluck(vm.selectedValues, 'text').join(' + ');
|
vm.variable.current.text = _.map(vm.selectedValues, 'text').join(' + ');
|
||||||
vm.variable.current.tags = vm.selectedTags;
|
vm.variable.current.tags = vm.selectedTags;
|
||||||
|
|
||||||
if (!vm.variable.multi) {
|
if (!vm.variable.multi) {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export function parseDateMath(mathString, time, roundUp?) {
|
|||||||
}
|
}
|
||||||
unit = mathString.charAt(i++);
|
unit = mathString.charAt(i++);
|
||||||
|
|
||||||
if (!_.contains(units, unit)) {
|
if (!_.includes(units, unit)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
if (type === 0) {
|
if (type === 0) {
|
||||||
|
|||||||
@@ -81,20 +81,20 @@ function (angular, _) {
|
|||||||
|
|
||||||
$scope.searchOrgs = function(queryStr, callback) {
|
$scope.searchOrgs = function(queryStr, callback) {
|
||||||
if ($scope.orgsSearchCache.length > 0) {
|
if ($scope.orgsSearchCache.length > 0) {
|
||||||
callback(_.pluck($scope.orgsSearchCache, "name"));
|
callback(_.map($scope.orgsSearchCache, "name"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
backendSrv.get('/api/orgs', {query: ''}).then(function(result) {
|
backendSrv.get('/api/orgs', {query: ''}).then(function(result) {
|
||||||
$scope.orgsSearchCache = result;
|
$scope.orgsSearchCache = result;
|
||||||
callback(_.pluck(result, "name"));
|
callback(_.map(result, "name"));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.addOrgUser = function() {
|
$scope.addOrgUser = function() {
|
||||||
if (!$scope.addOrgForm.$valid) { return; }
|
if (!$scope.addOrgForm.$valid) { return; }
|
||||||
|
|
||||||
var orgInfo = _.findWhere($scope.orgsSearchCache, {name: $scope.newOrg.name});
|
var orgInfo = _.find($scope.orgsSearchCache, {name: $scope.newOrg.name});
|
||||||
if (!orgInfo) { return; }
|
if (!orgInfo) { return; }
|
||||||
|
|
||||||
$scope.newOrg.loginOrEmail = $scope.user.login;
|
$scope.newOrg.loginOrEmail = $scope.user.login;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export class AlertTabCtrl {
|
|||||||
this.notifications = res;
|
this.notifications = res;
|
||||||
|
|
||||||
_.each(this.alert.notifications, item => {
|
_.each(this.alert.notifications, item => {
|
||||||
var model = _.findWhere(this.notifications, {id: item.id});
|
var model = _.find(this.notifications, {id: item.id});
|
||||||
if (model) {
|
if (model) {
|
||||||
model.iconClass = this.getNotificationIcon(model.type);
|
model.iconClass = this.getNotificationIcon(model.type);
|
||||||
this.alertNotifications.push(model);
|
this.alertNotifications.push(model);
|
||||||
@@ -123,7 +123,7 @@ export class AlertTabCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
notificationAdded() {
|
notificationAdded() {
|
||||||
var model = _.findWhere(this.notifications, {name: this.addNotificationSegment.value});
|
var model = _.find(this.notifications, {name: this.addNotificationSegment.value});
|
||||||
if (!model) {
|
if (!model) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export class AnnotationsSrv {
|
|||||||
return this.globalAnnotationsPromise;
|
return this.globalAnnotationsPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
var annotations = _.where(dashboard.annotations.list, {enable: true});
|
var annotations = _.filter(dashboard.annotations.list, {enable: true});
|
||||||
var range = this.timeSrv.timeRange();
|
var range = this.timeSrv.timeRange();
|
||||||
|
|
||||||
this.globalAnnotationsPromise = this.$q.all(_.map(annotations, annotation => {
|
this.globalAnnotationsPromise = this.$q.all(_.map(annotations, annotation => {
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ function (angular, $, _, moment) {
|
|||||||
|
|
||||||
if (oldVersion < 6) {
|
if (oldVersion < 6) {
|
||||||
// move pulldowns to new schema
|
// move pulldowns to new schema
|
||||||
var annotations = _.findWhere(old.pulldowns, { type: 'annotations' });
|
var annotations = _.find(old.pulldowns, { type: 'annotations' });
|
||||||
|
|
||||||
if (annotations) {
|
if (annotations) {
|
||||||
this.annotations = {
|
this.annotations = {
|
||||||
@@ -328,7 +328,7 @@ function (angular, $, _, moment) {
|
|||||||
if (!target.refId) {
|
if (!target.refId) {
|
||||||
target.refId = this.getNextQueryLetter(panel);
|
target.refId = this.getNextQueryLetter(panel);
|
||||||
}
|
}
|
||||||
}, this);
|
}.bind(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export class DynamicDashboardSrv {
|
|||||||
// returns a new row clone or reuses a clone from previous iteration
|
// returns a new row clone or reuses a clone from previous iteration
|
||||||
repeatRow(row, rowIndex) {
|
repeatRow(row, rowIndex) {
|
||||||
var variables = this.dashboard.templating.list;
|
var variables = this.dashboard.templating.list;
|
||||||
var variable = _.findWhere(variables, {name: row.repeat});
|
var variable = _.find(variables, {name: row.repeat});
|
||||||
if (!variable) {
|
if (!variable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ export class DynamicDashboardSrv {
|
|||||||
|
|
||||||
repeatPanel(panel, row) {
|
repeatPanel(panel, row) {
|
||||||
var variables = this.dashboard.templating.list;
|
var variables = this.dashboard.templating.list;
|
||||||
var variable = _.findWhere(variables, {name: panel.repeat});
|
var variable = _.find(variables, {name: panel.repeat});
|
||||||
if (!variable) { return; }
|
if (!variable) { return; }
|
||||||
|
|
||||||
var selected;
|
var selected;
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ function (angular, _, config) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
scope.onAppEvent('panel-fullscreen-enter', function(evt, info) {
|
scope.onAppEvent('panel-fullscreen-enter', function(evt, info) {
|
||||||
var hasPanel = _.findWhere(scope.row.panels, {id: info.panelId});
|
var hasPanel = _.find(scope.row.panels, {id: info.panelId});
|
||||||
if (!hasPanel) {
|
if (!hasPanel) {
|
||||||
element.hide();
|
element.hide();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ describe('given dashboard with repeated panels', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should add datasource to required', function() {
|
it('should add datasource to required', function() {
|
||||||
var require = _.findWhere(exported.__requires, {name: 'TestDB'});
|
var require = _.find(exported.__requires, {name: 'TestDB'});
|
||||||
expect(require.name).to.be("TestDB");
|
expect(require.name).to.be("TestDB");
|
||||||
expect(require.id).to.be("testdb");
|
expect(require.id).to.be("testdb");
|
||||||
expect(require.type).to.be("datasource");
|
expect(require.type).to.be("datasource");
|
||||||
@@ -110,28 +110,28 @@ describe('given dashboard with repeated panels', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should add panel to required', function() {
|
it('should add panel to required', function() {
|
||||||
var require = _.findWhere(exported.__requires, {name: 'Graph'});
|
var require = _.find(exported.__requires, {name: 'Graph'});
|
||||||
expect(require.name).to.be("Graph");
|
expect(require.name).to.be("Graph");
|
||||||
expect(require.id).to.be("graph");
|
expect(require.id).to.be("graph");
|
||||||
expect(require.version).to.be("1.1.0");
|
expect(require.version).to.be("1.1.0");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add grafana version', function() {
|
it('should add grafana version', function() {
|
||||||
var require = _.findWhere(exported.__requires, {name: 'Grafana'});
|
var require = _.find(exported.__requires, {name: 'Grafana'});
|
||||||
expect(require.type).to.be("grafana");
|
expect(require.type).to.be("grafana");
|
||||||
expect(require.id).to.be("grafana");
|
expect(require.id).to.be("grafana");
|
||||||
expect(require.version).to.be("3.0.2");
|
expect(require.version).to.be("3.0.2");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add constant template variables as inputs', function() {
|
it('should add constant template variables as inputs', function() {
|
||||||
var input = _.findWhere(exported.__inputs, {name: 'VAR_PREFIX'});
|
var input = _.find(exported.__inputs, {name: 'VAR_PREFIX'});
|
||||||
expect(input.type).to.be("constant");
|
expect(input.type).to.be("constant");
|
||||||
expect(input.label).to.be("prefix");
|
expect(input.label).to.be("prefix");
|
||||||
expect(input.value).to.be("collectd");
|
expect(input.value).to.be("collectd");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should templatize constant variables', function() {
|
it('should templatize constant variables', function() {
|
||||||
var variable = _.findWhere(exported.templating.list, {name: 'prefix'});
|
var variable = _.find(exported.templating.list, {name: 'prefix'});
|
||||||
expect(variable.query).to.be("${VAR_PREFIX}");
|
expect(variable.query).to.be("${VAR_PREFIX}");
|
||||||
expect(variable.current.text).to.be("${VAR_PREFIX}");
|
expect(variable.current.text).to.be("${VAR_PREFIX}");
|
||||||
expect(variable.current.value).to.be("${VAR_PREFIX}");
|
expect(variable.current.value).to.be("${VAR_PREFIX}");
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ function(angular, _) {
|
|||||||
this.cleanDashboardFromIgnoredChanges(current);
|
this.cleanDashboardFromIgnoredChanges(current);
|
||||||
this.cleanDashboardFromIgnoredChanges(original);
|
this.cleanDashboardFromIgnoredChanges(original);
|
||||||
|
|
||||||
var currentTimepicker = _.findWhere(current.nav, { type: 'timepicker' });
|
var currentTimepicker = _.find(current.nav, { type: 'timepicker' });
|
||||||
var originalTimepicker = _.findWhere(original.nav, { type: 'timepicker' });
|
var originalTimepicker = _.find(original.nav, { type: 'timepicker' });
|
||||||
|
|
||||||
if (currentTimepicker && originalTimepicker) {
|
if (currentTimepicker && originalTimepicker) {
|
||||||
currentTimepicker.now = originalTimepicker.now;
|
currentTimepicker.now = originalTimepicker.now;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export class MetricsDsSelectorCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
datasourceChanged() {
|
datasourceChanged() {
|
||||||
var ds = _.findWhere(this.datasources, {name: this.dsSegment.value});
|
var ds = _.find(this.datasources, {name: this.dsSegment.value});
|
||||||
if (ds) {
|
if (ds) {
|
||||||
this.current = ds;
|
this.current = ds;
|
||||||
this.panelCtrl.setDatasource(ds);
|
this.panelCtrl.setDatasource(ds);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function (angular, _) {
|
|||||||
|
|
||||||
$scope.dashboardChanged = function(link) {
|
$scope.dashboardChanged = function(link) {
|
||||||
backendSrv.search({query: link.dashboard}).then(function(hits) {
|
backendSrv.search({query: link.dashboard}).then(function(hits) {
|
||||||
var dashboard = _.findWhere(hits, {title: link.dashboard});
|
var dashboard = _.find(hits, {title: link.dashboard});
|
||||||
if (dashboard) {
|
if (dashboard) {
|
||||||
link.dashUri = dashboard.uri;
|
link.dashUri = dashboard.uri;
|
||||||
link.title = dashboard.title;
|
link.title = dashboard.title;
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ export class PlaylistEditCtrl {
|
|||||||
|
|
||||||
filterFoundPlaylistItems() {
|
filterFoundPlaylistItems() {
|
||||||
this.filteredDashboards = _.reject(this.dashboardresult, (playlistItem) => {
|
this.filteredDashboards = _.reject(this.dashboardresult, (playlistItem) => {
|
||||||
return _.findWhere(this.playlistItems, (listPlaylistItem) => {
|
return _.find(this.playlistItems, (listPlaylistItem) => {
|
||||||
return parseInt(listPlaylistItem.value) === playlistItem.id;
|
return parseInt(listPlaylistItem.value) === playlistItem.id;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.filteredTags = _.reject(this.tagresult, (tag) => {
|
this.filteredTags = _.reject(this.tagresult, (tag) => {
|
||||||
return _.findWhere(this.playlistItems, (listPlaylistItem) => {
|
return _.find(this.playlistItems, (listPlaylistItem) => {
|
||||||
return listPlaylistItem.value === tag.term;
|
return listPlaylistItem.value === tag.term;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export class DataSourceEditCtrl {
|
|||||||
this.hasDashboards = false;
|
this.hasDashboards = false;
|
||||||
return this.backendSrv.get('/api/plugins/' + this.current.type + '/settings').then(pluginInfo => {
|
return this.backendSrv.get('/api/plugins/' + this.current.type + '/settings').then(pluginInfo => {
|
||||||
this.datasourceMeta = pluginInfo;
|
this.datasourceMeta = pluginInfo;
|
||||||
this.hasDashboards = _.findWhere(pluginInfo.includes, {type: 'dashboard'});
|
this.hasDashboards = _.find(pluginInfo.includes, {type: 'dashboard'});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export class PluginEditCtrl {
|
|||||||
this.tabIndex = 1;
|
this.tabIndex = 1;
|
||||||
this.tabs.push('Config');
|
this.tabs.push('Config');
|
||||||
|
|
||||||
this.hasDashboards = _.findWhere(result.includes, {type: 'dashboard'});
|
this.hasDashboards = _.find(result.includes, {type: 'dashboard'});
|
||||||
if (this.hasDashboards) {
|
if (this.hasDashboards) {
|
||||||
this.tabs.push('Dashboards');
|
this.tabs.push('Dashboards');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class AppPageCtrl {
|
|||||||
|
|
||||||
initPage(app) {
|
initPage(app) {
|
||||||
this.appModel = app;
|
this.appModel = app;
|
||||||
this.page = _.findWhere(app.includes, {slug: this.$routeParams.slug});
|
this.page = _.find(app.includes, {slug: this.$routeParams.slug});
|
||||||
this.appLogoUrl = app.info.logos.small;
|
this.appLogoUrl = app.info.logos.small;
|
||||||
|
|
||||||
pluginInfoCache[this.pluginId] = app;
|
pluginInfoCache[this.pluginId] = app;
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ function (angular, _) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sameName = _.findWhere($scope.variables, { name: $scope.current.name });
|
var sameName = _.find($scope.variables, { name: $scope.current.name });
|
||||||
if (sameName && sameName !== $scope.current) {
|
if (sameName && sameName !== $scope.current) {
|
||||||
$scope.appEvent('alert-warning', ['Validation', 'Variable with the same name already exists']);
|
$scope.appEvent('alert-warning', ['Validation', 'Variable with the same name already exists']);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function (angular, _, $, kbn) {
|
|||||||
$rootScope.onAppEvent('refresh', function() {
|
$rootScope.onAppEvent('refresh', function() {
|
||||||
|
|
||||||
// look for interval variables
|
// look for interval variables
|
||||||
var intervalVariable = _.findWhere(self.variables, { type: 'interval' });
|
var intervalVariable = _.find(self.variables, { type: 'interval' });
|
||||||
if (intervalVariable) {
|
if (intervalVariable) {
|
||||||
self.updateAutoInterval(intervalVariable);
|
self.updateAutoInterval(intervalVariable);
|
||||||
}
|
}
|
||||||
@@ -290,7 +290,7 @@ function (angular, _, $, kbn) {
|
|||||||
|
|
||||||
return self.setVariableValue(variable, selected, false);
|
return self.setVariableValue(variable, selected, false);
|
||||||
} else {
|
} else {
|
||||||
var currentOption = _.findWhere(variable.options, {text: variable.current.text});
|
var currentOption = _.find(variable.options, {text: variable.current.text});
|
||||||
if (currentOption) {
|
if (currentOption) {
|
||||||
return self.setVariableValue(variable, currentOption, false);
|
return self.setVariableValue(variable, currentOption, false);
|
||||||
} else {
|
} else {
|
||||||
@@ -372,8 +372,8 @@ function (angular, _, $, kbn) {
|
|||||||
|
|
||||||
options.push({text: text, value: value});
|
options.push({text: text, value: value});
|
||||||
}
|
}
|
||||||
options = _.uniq(options, 'value');
|
|
||||||
|
|
||||||
|
options = _.uniq(options, 'value');
|
||||||
return this.sortVariableValues(options, variable.sort);
|
return this.sortVariableValues(options, variable.sort);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) {
|
|||||||
return this.performEC2DescribeInstances(region, filters, null).then(function(result) {
|
return this.performEC2DescribeInstances(region, filters, null).then(function(result) {
|
||||||
var attributes = _.chain(result.Reservations)
|
var attributes = _.chain(result.Reservations)
|
||||||
.map(function(reservations) {
|
.map(function(reservations) {
|
||||||
return _.pluck(reservations.Instances, targetAttributeName);
|
return _.map(reservations.Instances, targetAttributeName);
|
||||||
})
|
})
|
||||||
.flatten().uniq().sortBy().value();
|
.flatten().uniq().sortBy().value();
|
||||||
return transformSuggestData(attributes);
|
return transformSuggestData(attributes);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export class ElasticConfigCtrl {
|
|||||||
];
|
];
|
||||||
|
|
||||||
indexPatternTypeChanged() {
|
indexPatternTypeChanged() {
|
||||||
var def = _.findWhere(this.indexPatternTypes, {value: this.current.jsonData.interval});
|
var def = _.find(this.indexPatternTypes, {value: this.current.jsonData.interval});
|
||||||
this.current.database = def.example || 'es-index-name';
|
this.current.database = def.example || 'es-index-name';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ function (_, queryDef) {
|
|||||||
var maxDepth = target.bucketAggs.length-1;
|
var maxDepth = target.bucketAggs.length-1;
|
||||||
|
|
||||||
for (aggId in aggs) {
|
for (aggId in aggs) {
|
||||||
aggDef = _.findWhere(target.bucketAggs, {id: aggId});
|
aggDef = _.find(target.bucketAggs, {id: aggId});
|
||||||
esAgg = aggs[aggId];
|
esAgg = aggs[aggId];
|
||||||
|
|
||||||
if (!aggDef) {
|
if (!aggDef) {
|
||||||
@@ -178,9 +178,9 @@ function (_, queryDef) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ElasticResponse.prototype._getMetricName = function(metric) {
|
ElasticResponse.prototype._getMetricName = function(metric) {
|
||||||
var metricDef = _.findWhere(queryDef.metricAggTypes, {value: metric});
|
var metricDef = _.find(queryDef.metricAggTypes, {value: metric});
|
||||||
if (!metricDef) {
|
if (!metricDef) {
|
||||||
metricDef = _.findWhere(queryDef.extendedStats, {value: metric});
|
metricDef = _.find(queryDef.extendedStats, {value: metric});
|
||||||
}
|
}
|
||||||
|
|
||||||
return metricDef ? metricDef.text : metric;
|
return metricDef ? metricDef.text : metric;
|
||||||
@@ -205,7 +205,7 @@ function (_, queryDef) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (series.field && queryDef.isPipelineAgg(series.metric)) {
|
if (series.field && queryDef.isPipelineAgg(series.metric)) {
|
||||||
var appliedAgg = _.findWhere(target.metrics, { id: series.field });
|
var appliedAgg = _.find(target.metrics, { id: series.field });
|
||||||
if (appliedAgg) {
|
if (appliedAgg) {
|
||||||
metricName += ' ' + queryDef.describeMetric(appliedAgg);
|
metricName += ' ' + queryDef.describeMetric(appliedAgg);
|
||||||
} else {
|
} else {
|
||||||
@@ -233,8 +233,8 @@ function (_, queryDef) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ElasticResponse.prototype.nameSeries = function(seriesList, target) {
|
ElasticResponse.prototype.nameSeries = function(seriesList, target) {
|
||||||
var metricTypeCount = _.uniq(_.pluck(seriesList, 'metric')).length;
|
var metricTypeCount = _.uniq(_.map(seriesList, 'metric')).length;
|
||||||
var fieldNameCount = _.uniq(_.pluck(seriesList, 'field')).length;
|
var fieldNameCount = _.uniq(_.map(seriesList, 'field')).length;
|
||||||
|
|
||||||
for (var i = 0; i < seriesList.length; i++) {
|
for (var i = 0; i < seriesList.length; i++) {
|
||||||
var series = seriesList[i];
|
var series = seriesList[i];
|
||||||
@@ -270,7 +270,7 @@ function (_, queryDef) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ElasticResponse.prototype.trimDatapoints = function(aggregations, target) {
|
ElasticResponse.prototype.trimDatapoints = function(aggregations, target) {
|
||||||
var histogram = _.findWhere(target.bucketAggs, { type: 'date_histogram'});
|
var histogram = _.find(target.bucketAggs, { type: 'date_histogram'});
|
||||||
|
|
||||||
var shouldDropFirstAndLast = histogram && histogram.settings && histogram.settings.trimEdges;
|
var shouldDropFirstAndLast = histogram && histogram.settings && histogram.settings.trimEdges;
|
||||||
if (shouldDropFirstAndLast) {
|
if (shouldDropFirstAndLast) {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function (angular, _, queryDef) {
|
|||||||
$scope.isFirst = $scope.index === 0;
|
$scope.isFirst = $scope.index === 0;
|
||||||
$scope.isSingle = metricAggs.length === 1;
|
$scope.isSingle = metricAggs.length === 1;
|
||||||
$scope.settingsLinkText = '';
|
$scope.settingsLinkText = '';
|
||||||
$scope.aggDef = _.findWhere($scope.metricAggTypes, {value: $scope.agg.type});
|
$scope.aggDef = _.find($scope.metricAggTypes, {value: $scope.agg.type});
|
||||||
|
|
||||||
if (queryDef.isPipelineAgg($scope.agg.type)) {
|
if (queryDef.isPipelineAgg($scope.agg.type)) {
|
||||||
$scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric';
|
$scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric';
|
||||||
@@ -86,7 +86,7 @@ function (angular, _, queryDef) {
|
|||||||
|
|
||||||
var stats = _.reduce($scope.agg.meta, function(memo, val, key) {
|
var stats = _.reduce($scope.agg.meta, function(memo, val, key) {
|
||||||
if (val) {
|
if (val) {
|
||||||
var def = _.findWhere($scope.extendedStats, {value: key});
|
var def = _.find($scope.extendedStats, {value: key});
|
||||||
memo.push(def.text);
|
memo.push(def.text);
|
||||||
}
|
}
|
||||||
return memo;
|
return memo;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
|||||||
text += 'Metrics: ';
|
text += 'Metrics: ';
|
||||||
|
|
||||||
_.each(metricAggs, (metric, index) => {
|
_.each(metricAggs, (metric, index) => {
|
||||||
var aggDef = _.findWhere(metricAggTypes, {value: metric.type});
|
var aggDef = _.find(metricAggTypes, {value: metric.type});
|
||||||
text += aggDef.text + '(';
|
text += aggDef.text + '(';
|
||||||
if (aggDef.requiresField) {
|
if (aggDef.requiresField) {
|
||||||
text += metric.field;
|
text += metric.field;
|
||||||
@@ -66,7 +66,7 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
|||||||
text += ' Group by: ';
|
text += ' Group by: ';
|
||||||
}
|
}
|
||||||
|
|
||||||
var aggDef = _.findWhere(bucketAggTypes, {value: bucketAgg.type});
|
var aggDef = _.find(bucketAggTypes, {value: bucketAgg.type});
|
||||||
text += aggDef.text + '(';
|
text += aggDef.text + '(';
|
||||||
if (aggDef.requiresField) {
|
if (aggDef.requiresField) {
|
||||||
text += bucketAgg.field;
|
text += bucketAgg.field;
|
||||||
|
|||||||
@@ -131,21 +131,21 @@ function (_) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
describeOrder: function(order) {
|
describeOrder: function(order) {
|
||||||
var def = _.findWhere(this.orderOptions, {value: order});
|
var def = _.find(this.orderOptions, {value: order});
|
||||||
return def.text;
|
return def.text;
|
||||||
},
|
},
|
||||||
|
|
||||||
describeMetric: function(metric) {
|
describeMetric: function(metric) {
|
||||||
var def = _.findWhere(this.metricAggTypes, {value: metric.type});
|
var def = _.find(this.metricAggTypes, {value: metric.type});
|
||||||
return def.text + ' ' + metric.field;
|
return def.text + ' ' + metric.field;
|
||||||
},
|
},
|
||||||
|
|
||||||
describeOrderBy: function(orderBy, target) {
|
describeOrderBy: function(orderBy, target) {
|
||||||
var def = _.findWhere(this.orderByOptions, {value: orderBy});
|
var def = _.find(this.orderByOptions, {value: orderBy});
|
||||||
if (def) {
|
if (def) {
|
||||||
return def.text;
|
return def.text;
|
||||||
}
|
}
|
||||||
var metric = _.findWhere(target.metrics, {id: orderBy});
|
var metric = _.find(target.metrics, {id: orderBy});
|
||||||
if (metric) {
|
if (metric) {
|
||||||
return this.describeMetric(metric);
|
return this.describeMetric(metric);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class DashListCtrl extends PanelCtrl {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
var dashIds = _.first(impressions.getDashboardOpened(), this.panel.limit);
|
var dashIds = _.take(impressions.getDashboardOpened(), this.panel.limit);
|
||||||
return this.backendSrv.search({dashboardIds: dashIds, limit: this.panel.limit}).then(result => {
|
return this.backendSrv.search({dashboardIds: dashIds, limit: this.panel.limit}).then(result => {
|
||||||
this.groups[1].list = dashIds.map(orderId => {
|
this.groups[1].list = dashIds.map(orderId => {
|
||||||
return _.find(result, dashboard => {
|
return _.find(result, dashboard => {
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ function (angular, $, moment, _, kbn, GraphTooltip, thresholdManExports) {
|
|||||||
|
|
||||||
options.yaxes.push(defaults);
|
options.yaxes.push(defaults);
|
||||||
|
|
||||||
if (_.findWhere(data, {yaxis: 2})) {
|
if (_.find(data, {yaxis: 2})) {
|
||||||
var secondY = _.clone(defaults);
|
var secondY = _.clone(defaults);
|
||||||
secondY.index = 2,
|
secondY.index = 2,
|
||||||
secondY.show = panel.yaxes[1].show;
|
secondY.show = panel.yaxes[1].show;
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ class GraphCtrl extends MetricsPanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleAxis(info) {
|
toggleAxis(info) {
|
||||||
var override = _.findWhere(this.panel.seriesOverrides, {alias: info.alias});
|
var override = _.find(this.panel.seriesOverrides, {alias: info.alias});
|
||||||
if (!override) {
|
if (!override) {
|
||||||
override = { alias: info.alias };
|
override = { alias: info.alias };
|
||||||
this.panel.seriesOverrides.push(override);
|
this.panel.seriesOverrides.push(override);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export class TablePanelEditorCtrl {
|
|||||||
|
|
||||||
addColumn() {
|
addColumn() {
|
||||||
var columns = transformers[this.panel.transform].getColumns(this.panelCtrl.dataRaw);
|
var columns = transformers[this.panel.transform].getColumns(this.panelCtrl.dataRaw);
|
||||||
var column = _.findWhere(columns, {text: this.addColumnSegment.value});
|
var column = _.find(columns, {text: this.addColumnSegment.value});
|
||||||
|
|
||||||
if (column) {
|
if (column) {
|
||||||
this.panel.columns.push(column);
|
this.panel.columns.push(column);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ System.config({
|
|||||||
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
|
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
|
||||||
'moment': 'vendor/moment.js',
|
'moment': 'vendor/moment.js',
|
||||||
"jquery": "vendor/jquery/dist/jquery.js",
|
"jquery": "vendor/jquery/dist/jquery.js",
|
||||||
'lodash-src': 'vendor/lodash.js',
|
'lodash-src': 'vendor/lodash/dist/lodash.js',
|
||||||
"lodash": 'app/core/lodash_extended.js',
|
"lodash": 'app/core/lodash_extended.js',
|
||||||
"angular": "vendor/angular/angular.js",
|
"angular": "vendor/angular/angular.js",
|
||||||
"bootstrap": "vendor/bootstrap/bootstrap.js",
|
"bootstrap": "vendor/bootstrap/bootstrap.js",
|
||||||
|
|||||||
@@ -12,14 +12,6 @@ describe("rangeUtil", () => {
|
|||||||
expect(_.keys(groups).length).to.be(4)
|
expect(_.keys(groups).length).to.be(4)
|
||||||
expect(groups[3][0].active).to.be(true)
|
expect(groups[3][0].active).to.be(true)
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('should add custom options to right section', () => {
|
|
||||||
// var groups = rangeUtil.getRelativeTimesList({
|
|
||||||
// time_options: ['12m', '15d']
|
|
||||||
// }, '');
|
|
||||||
// var value = _.findWhere(groups["3"], {display: 'Last 12 minutes'});
|
|
||||||
// expect(value).to.not.be(undefined)
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Can get range text described", () => {
|
describe("Can get range text described", () => {
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ define([
|
|||||||
this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g };
|
this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g };
|
||||||
this.data = {};
|
this.data = {};
|
||||||
this.replace = function(text) {
|
this.replace = function(text) {
|
||||||
return _.template(text, this.data, this.templateSettings);
|
return _.template(text, this.templateSettings)(this.data);
|
||||||
};
|
};
|
||||||
this.init = function() {};
|
this.init = function() {};
|
||||||
this.fillVariableValuesForUrl = function() {};
|
this.fillVariableValuesForUrl = function() {};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
|
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
|
||||||
'moment': 'vendor/moment.js',
|
'moment': 'vendor/moment.js',
|
||||||
"jquery": "vendor/jquery/dist/jquery.js",
|
"jquery": "vendor/jquery/dist/jquery.js",
|
||||||
'lodash-src': 'vendor/lodash.js',
|
'lodash-src': 'vendor/lodash/dist/lodash.js',
|
||||||
"lodash": 'app/core/lodash_extended.js',
|
"lodash": 'app/core/lodash_extended.js',
|
||||||
"angular": 'vendor/angular/angular.js',
|
"angular": 'vendor/angular/angular.js',
|
||||||
'angular-mocks': 'vendor/angular-mocks/angular-mocks.js',
|
'angular-mocks': 'vendor/angular-mocks/angular-mocks.js',
|
||||||
|
|||||||
Vendored
-6785
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user