mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Adds typings to lodash (#16590)
This commit is contained in:
@@ -33,7 +33,7 @@ export class ElasticConfigCtrl {
|
||||
this.current.database.length === 0 ||
|
||||
this.current.database.startsWith('[logstash-]')
|
||||
) {
|
||||
const def = _.find(this.indexPatternTypes, {
|
||||
const def: any = _.find(this.indexPatternTypes, {
|
||||
value: this.current.jsonData.interval,
|
||||
});
|
||||
this.current.database = def.example || 'es-index-name';
|
||||
|
||||
@@ -204,7 +204,7 @@ export class ElasticDatasource {
|
||||
// validate that the index exist and has date field
|
||||
return this.getFields({ type: 'date' }).then(
|
||||
dateFields => {
|
||||
const timeField = _.find(dateFields, { text: this.timeField });
|
||||
const timeField: any = _.find(dateFields, { text: this.timeField });
|
||||
if (!timeField) {
|
||||
return {
|
||||
status: 'error',
|
||||
|
||||
@@ -222,7 +222,7 @@ export class ElasticResponse {
|
||||
}
|
||||
|
||||
private getMetricName(metric) {
|
||||
let metricDef = _.find(queryDef.metricAggTypes, { value: metric });
|
||||
let metricDef: any = _.find(queryDef.metricAggTypes, { value: metric });
|
||||
if (!metricDef) {
|
||||
metricDef = _.find(queryDef.extendedStats, { value: metric });
|
||||
}
|
||||
@@ -258,12 +258,12 @@ export class ElasticResponse {
|
||||
|
||||
if (series.field && queryDef.isPipelineAgg(series.metric)) {
|
||||
if (series.metric && queryDef.isPipelineAggWithMultipleBucketPaths(series.metric)) {
|
||||
const agg = _.find(target.metrics, { id: series.metricId });
|
||||
const agg: any = _.find(target.metrics, { id: series.metricId });
|
||||
if (agg && agg.settings.script) {
|
||||
metricName = agg.settings.script;
|
||||
|
||||
for (const pv of agg.pipelineVariables) {
|
||||
const appliedAgg = _.find(target.metrics, { id: pv.pipelineAgg });
|
||||
const appliedAgg: any = _.find(target.metrics, { id: pv.pipelineAgg });
|
||||
if (appliedAgg) {
|
||||
metricName = metricName.replace('params.' + pv.name, queryDef.describeMetric(appliedAgg));
|
||||
}
|
||||
@@ -272,7 +272,7 @@ export class ElasticResponse {
|
||||
metricName = 'Unset';
|
||||
}
|
||||
} else {
|
||||
const appliedAgg = _.find(target.metrics, { id: series.field });
|
||||
const appliedAgg: any = _.find(target.metrics, { id: series.field });
|
||||
if (appliedAgg) {
|
||||
metricName += ' ' + queryDef.describeMetric(appliedAgg);
|
||||
} else {
|
||||
@@ -343,7 +343,7 @@ export class ElasticResponse {
|
||||
}
|
||||
|
||||
trimDatapoints(aggregations, target) {
|
||||
const histogram = _.find(target.bucketAggs, { type: 'date_histogram' });
|
||||
const histogram: any = _.find(target.bucketAggs, { type: 'date_histogram' });
|
||||
|
||||
const shouldDropFirstAndLast = histogram && histogram.settings && histogram.settings.trimEdges;
|
||||
if (shouldDropFirstAndLast) {
|
||||
|
||||
@@ -81,7 +81,7 @@ export class ElasticMetricAggCtrl {
|
||||
$scope.agg.meta,
|
||||
(memo, val, key) => {
|
||||
if (val) {
|
||||
const def = _.find($scope.extendedStats, { value: key });
|
||||
const def: any = _.find($scope.extendedStats, { value: key });
|
||||
memo.push(def.text);
|
||||
}
|
||||
return memo;
|
||||
|
||||
@@ -66,7 +66,7 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
||||
text += 'Metrics: ';
|
||||
|
||||
_.each(metricAggs, (metric, index) => {
|
||||
const aggDef = _.find(metricAggTypes, { value: metric.type });
|
||||
const aggDef: any = _.find(metricAggTypes, { value: metric.type });
|
||||
text += aggDef.text + '(';
|
||||
if (aggDef.requiresField) {
|
||||
text += metric.field;
|
||||
@@ -77,12 +77,12 @@ export class ElasticQueryCtrl extends QueryCtrl {
|
||||
text += '), ';
|
||||
});
|
||||
|
||||
_.each(bucketAggs, (bucketAgg, index) => {
|
||||
_.each(bucketAggs, (bucketAgg: any, index: number) => {
|
||||
if (index === 0) {
|
||||
text += ' Group by: ';
|
||||
}
|
||||
|
||||
const aggDef = _.find(bucketAggTypes, { value: bucketAgg.type });
|
||||
const aggDef: any = _.find(bucketAggTypes, { value: bucketAgg.type });
|
||||
text += aggDef.text + '(';
|
||||
if (aggDef.requiresField) {
|
||||
text += bucketAgg.field;
|
||||
|
||||
@@ -224,12 +224,12 @@ export function getOrderByOptions(target) {
|
||||
}
|
||||
|
||||
export function describeOrder(order) {
|
||||
const def = _.find(orderOptions, { value: order });
|
||||
const def: any = _.find(orderOptions, { value: order });
|
||||
return def.text;
|
||||
}
|
||||
|
||||
export function describeMetric(metric) {
|
||||
const def = _.find(metricAggTypes, { value: metric.type });
|
||||
const def: any = _.find(metricAggTypes, { value: metric.type });
|
||||
if (!def.requiresField && !isPipelineAgg(metric.type)) {
|
||||
return def.text;
|
||||
}
|
||||
@@ -237,11 +237,11 @@ export function describeMetric(metric) {
|
||||
}
|
||||
|
||||
export function describeOrderBy(orderBy, target) {
|
||||
const def = _.find(orderByOptions, { value: orderBy });
|
||||
const def: any = _.find(orderByOptions, { value: orderBy });
|
||||
if (def) {
|
||||
return def.text;
|
||||
}
|
||||
const metric = _.find(target.metrics, { id: orderBy });
|
||||
const metric: any = _.find(target.metrics, { id: orderBy });
|
||||
if (metric) {
|
||||
return describeMetric(metric);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user