mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* Split query modifications into seperate file * seperate setQueryValue for Logs * wip for centralising api requests * more wip * moved data hooks out into seperate module, added post-request cleanup * metric metadata * , * more cleanup * update tests, fix hasOption to work with grouped variables * update ARG subscriptiopns field * last select stuff * remove todo comment * pr feedback * more pr feedback :) :) * updated comment
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { rangeUtil } from '@grafana/data';
|
|
import TimegrainConverter from '../time_grain_converter';
|
|
import { AzureMonitorOption } from '../types';
|
|
|
|
export const hasOption = (options: AzureMonitorOption[], value: string): boolean =>
|
|
options.some((v) => (v.options ? hasOption(v.options, value) : v.value === value));
|
|
|
|
export const findOptions = (options: AzureMonitorOption[], values: string[] = []) => {
|
|
if (values.length === 0) {
|
|
return [];
|
|
}
|
|
const set = values.reduce((accum, item) => {
|
|
accum.add(item);
|
|
return accum;
|
|
}, new Set());
|
|
return options.filter((option) => set.has(option.value));
|
|
};
|
|
|
|
export const toOption = (v: { text: string; value: string }) => ({ value: v.value, label: v.text });
|
|
|
|
export function convertTimeGrainsToMs<T extends { value: string }>(timeGrains: T[]) {
|
|
const allowedTimeGrainsMs: number[] = [];
|
|
timeGrains.forEach((tg: any) => {
|
|
if (tg.value !== 'auto') {
|
|
allowedTimeGrainsMs.push(rangeUtil.intervalToMs(TimegrainConverter.createKbnUnitFromISO8601Duration(tg.value)));
|
|
}
|
|
});
|
|
return allowedTimeGrainsMs;
|
|
}
|
|
|
|
// Route definitions shared with the backend.
|
|
// Check: /pkg/tsdb/azuremonitor/azuremonitor-resource-handler.go <registerRoutes>
|
|
export const routeNames = {
|
|
azureMonitor: 'azuremonitor',
|
|
logAnalytics: 'loganalytics',
|
|
appInsights: 'appinsights',
|
|
resourceGraph: 'resourcegraph',
|
|
};
|