remove additional linting errors
This commit is contained in:
Родитель
679257dd2d
Коммит
c9127c72bc
|
@ -8,5 +8,5 @@
|
|||
"editor.detectIndentation": false,
|
||||
"editor.rulers": [
|
||||
120
|
||||
],
|
||||
]
|
||||
}
|
|
@ -36,8 +36,7 @@ export class DataSourceConnector {
|
|||
}
|
||||
|
||||
// Dynamically load the plugin from the plugins directory
|
||||
var pluginPath = './plugins/' + config.type;
|
||||
var PluginClass = require(pluginPath);
|
||||
var PluginClass = require('./plugins/' + config.type);
|
||||
var plugin: any = new PluginClass.default(config, connections);
|
||||
|
||||
// Creating actions class
|
||||
|
|
|
@ -98,56 +98,59 @@ export default class ApplicationInsightsQuery extends DataSourcePlugin<IQueryPar
|
|||
var url = `${appInsightsUri}/${appId}/query?timespan=${queryTimespan}`;
|
||||
|
||||
return (dispatch) => {
|
||||
request(url, {
|
||||
method: 'POST',
|
||||
json: true,
|
||||
headers: {
|
||||
'x-api-key': apiKey
|
||||
},
|
||||
body: {
|
||||
query
|
||||
}
|
||||
},
|
||||
(error, json) => {
|
||||
if (error) return this.failure(error);
|
||||
if (json.error) {
|
||||
return json.error.code === 'PathNotFoundError' ?
|
||||
this.failure(new Error(
|
||||
`There was a problem getting results from Application Insights. Make sure the connection string is food.
|
||||
${JSON.stringify(json)}`)) :
|
||||
this.failure(json.error);
|
||||
}
|
||||
|
||||
// Check if result is valid
|
||||
let tables = this.mapAllTables(json, mappings);
|
||||
let resultStatus: IQueryStatus[] = tables[tables.length - 1];
|
||||
if (!resultStatus || !resultStatus.length) {
|
||||
return dispatch(json);
|
||||
}
|
||||
|
||||
// Map tables to appropriate results
|
||||
var resultTables = tables.filter((aTable, idx) => {
|
||||
return idx < resultStatus.length && resultStatus[idx].Kind === 'QueryResult';
|
||||
});
|
||||
|
||||
let returnedResults = {
|
||||
values: (resultTables.length && resultTables[0]) || null
|
||||
};
|
||||
|
||||
tableNames.forEach((aTable: string, idx: number) => {
|
||||
returnedResults[aTable] = resultTables.length > idx ? resultTables[idx] : null;
|
||||
// Get state for filter selection
|
||||
const prevState = DataSourceConnector.getDataSource(this._props.id).store.getState();
|
||||
// Extracting calculated values
|
||||
let calc = queries[aTable].calculated;
|
||||
if (typeof calc === 'function') {
|
||||
var additionalValues = calc(returnedResults[aTable], dependencies, prevState) || {};
|
||||
Object.assign(returnedResults, additionalValues);
|
||||
request(
|
||||
url,
|
||||
{
|
||||
method: 'POST',
|
||||
json: true,
|
||||
headers: {
|
||||
'x-api-key': apiKey
|
||||
},
|
||||
body: {
|
||||
query
|
||||
}
|
||||
},
|
||||
(error, json) => {
|
||||
if (error) { return this.failure(error); }
|
||||
if (json.error) {
|
||||
return json.error.code === 'PathNotFoundError' ?
|
||||
this.failure(new Error(
|
||||
`There was a problem getting results from Application Insights. Make sure the connection string is food.
|
||||
${JSON.stringify(json)}`)) :
|
||||
this.failure(json.error);
|
||||
}
|
||||
});
|
||||
|
||||
return dispatch(returnedResults);
|
||||
});
|
||||
// Check if result is valid
|
||||
let tables = this.mapAllTables(json, mappings);
|
||||
let resultStatus: IQueryStatus[] = tables[tables.length - 1];
|
||||
if (!resultStatus || !resultStatus.length) {
|
||||
return dispatch(json);
|
||||
}
|
||||
|
||||
// Map tables to appropriate results
|
||||
var resultTables = tables.filter((aTable, idx) => {
|
||||
return idx < resultStatus.length && resultStatus[idx].Kind === 'QueryResult';
|
||||
});
|
||||
|
||||
let returnedResults = {
|
||||
values: (resultTables.length && resultTables[0]) || null
|
||||
};
|
||||
|
||||
tableNames.forEach((aTable: string, idx: number) => {
|
||||
returnedResults[aTable] = resultTables.length > idx ? resultTables[idx] : null;
|
||||
// Get state for filter selection
|
||||
const prevState = DataSourceConnector.getDataSource(this._props.id).store.getState();
|
||||
// Extracting calculated values
|
||||
let calc = queries[aTable].calculated;
|
||||
if (typeof calc === 'function') {
|
||||
var additionalValues = calc(returnedResults[aTable], dependencies, prevState) || {};
|
||||
Object.assign(returnedResults, additionalValues);
|
||||
}
|
||||
});
|
||||
|
||||
return dispatch(returnedResults);
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ export abstract class DataSourcePlugin<T> implements IDataSourcePlugin {
|
|||
private errorToMessage(error: any): string {
|
||||
if (!(error instanceof Error)) {
|
||||
|
||||
if (typeof error === 'object') return JSON.stringify(error);
|
||||
if (typeof error === 'object') { return JSON.stringify(error); }
|
||||
|
||||
return error;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче