mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 12:53:02 +08:00
tech: ran pretttier on all typescript files
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
///<reference path="../../../headers/common.d.ts" />
|
||||
|
||||
import _ from 'lodash';
|
||||
import _ from "lodash";
|
||||
|
||||
export default class ResponseParser {
|
||||
constructor(private $q) {}
|
||||
@ -9,7 +9,7 @@ export default class ResponseParser {
|
||||
var data = [];
|
||||
|
||||
if (!res.data.results) {
|
||||
return {data: data};
|
||||
return { data: data };
|
||||
}
|
||||
|
||||
for (let key in res.data.results) {
|
||||
@ -21,14 +21,14 @@ export default class ResponseParser {
|
||||
target: series.name,
|
||||
datapoints: series.points,
|
||||
refId: queryRes.refId,
|
||||
meta: queryRes.meta,
|
||||
meta: queryRes.meta
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (queryRes.tables) {
|
||||
for (let table of queryRes.tables) {
|
||||
table.type = 'table';
|
||||
table.type = "table";
|
||||
table.refId = queryRes.refId;
|
||||
table.meta = queryRes.meta;
|
||||
data.push(table);
|
||||
@ -36,16 +36,22 @@ export default class ResponseParser {
|
||||
}
|
||||
}
|
||||
|
||||
return {data: data};
|
||||
return { data: data };
|
||||
}
|
||||
|
||||
parseMetricFindQueryResult(refId, results) {
|
||||
if (!results || results.data.length === 0 || results.data.results[refId].meta.rowCount === 0) { return []; }
|
||||
if (
|
||||
!results ||
|
||||
results.data.length === 0 ||
|
||||
results.data.results[refId].meta.rowCount === 0
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const columns = results.data.results[refId].tables[0].columns;
|
||||
const rows = results.data.results[refId].tables[0].rows;
|
||||
const textColIndex = this.findColIndex(columns, '__text');
|
||||
const valueColIndex = this.findColIndex(columns, '__value');
|
||||
const textColIndex = this.findColIndex(columns, "__text");
|
||||
const valueColIndex = this.findColIndex(columns, "__value");
|
||||
|
||||
if (columns.length === 2 && textColIndex !== -1 && valueColIndex !== -1) {
|
||||
return this.transformToKeyValueList(rows, textColIndex, valueColIndex);
|
||||
@ -59,7 +65,10 @@ export default class ResponseParser {
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
if (!this.containsKey(res, rows[i][textColIndex])) {
|
||||
res.push({text: rows[i][textColIndex], value: rows[i][valueColIndex]});
|
||||
res.push({
|
||||
text: rows[i][textColIndex],
|
||||
value: rows[i][valueColIndex]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,14 +81,14 @@ export default class ResponseParser {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
for (let j = 0; j < rows[i].length; j++) {
|
||||
const value = rows[i][j];
|
||||
if ( res.indexOf( value ) === -1 ) {
|
||||
if (res.indexOf(value) === -1) {
|
||||
res.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _.map(res, value => {
|
||||
return { text: value};
|
||||
return { text: value };
|
||||
});
|
||||
}
|
||||
|
||||
@ -111,17 +120,19 @@ export default class ResponseParser {
|
||||
let tagsColumnIndex = -1;
|
||||
|
||||
for (let i = 0; i < table.columns.length; i++) {
|
||||
if (table.columns[i].text === 'time') {
|
||||
if (table.columns[i].text === "time") {
|
||||
timeColumnIndex = i;
|
||||
} else if (table.columns[i].text === 'text') {
|
||||
} else if (table.columns[i].text === "text") {
|
||||
textColumnIndex = i;
|
||||
} else if (table.columns[i].text === 'tags') {
|
||||
} else if (table.columns[i].text === "tags") {
|
||||
tagsColumnIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeColumnIndex === -1) {
|
||||
return this.$q.reject({message: 'Missing mandatory time column in annotation query.'});
|
||||
return this.$q.reject({
|
||||
message: "Missing mandatory time column in annotation query."
|
||||
});
|
||||
}
|
||||
|
||||
const list = [];
|
||||
@ -132,7 +143,9 @@ export default class ResponseParser {
|
||||
time: Math.floor(row[timeColumnIndex]) * 1000,
|
||||
title: row[titleColumnIndex],
|
||||
text: row[textColumnIndex],
|
||||
tags: row[tagsColumnIndex] ? row[tagsColumnIndex].trim().split(/\s*,\s*/) : []
|
||||
tags: row[tagsColumnIndex]
|
||||
? row[tagsColumnIndex].trim().split(/\s*,\s*/)
|
||||
: []
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user