mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data * Move types from grafana-ui to grafana-data * Move valueFormats to grafana-data * Move utils from grafana-ui to grafana-data * Update imports in grafana-ui * revert data's tsconfig change * Update imports in grafana-runtime * Fix import paths in grafana-ui * Move rxjs to devDeps * Core import updates batch 1 * Import updates batch 2 * Imports fix batch 3 * Imports fixes batch i don't know * Fix imorts in grafana-toolkit * Fix imports after master merge
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import LokiDatasource from './datasource';
|
|
import { DataSourceSettings } from '@grafana/data';
|
|
import { LokiOptions } from './types';
|
|
import { createDatasourceSettings } from '../../../features/datasources/mocks';
|
|
|
|
export function makeMockLokiDatasource(labelsAndValues: { [label: string]: string[] }): LokiDatasource {
|
|
const labels = Object.keys(labelsAndValues);
|
|
return {
|
|
metadataRequest: (url: string) => {
|
|
let responseData;
|
|
if (url === '/api/prom/label') {
|
|
responseData = labels;
|
|
} else {
|
|
const match = url.match(/^\/api\/prom\/label\/(\w*)\/values/);
|
|
if (match) {
|
|
responseData = labelsAndValues[match[1]];
|
|
}
|
|
}
|
|
if (responseData) {
|
|
return {
|
|
data: {
|
|
data: responseData,
|
|
},
|
|
};
|
|
} else {
|
|
throw new Error(`Unexpected url error, ${url}`);
|
|
}
|
|
},
|
|
} as any;
|
|
}
|
|
|
|
export function createDefaultConfigOptions(): DataSourceSettings<LokiOptions> {
|
|
return createDatasourceSettings<LokiOptions>({
|
|
maxLines: '531',
|
|
});
|
|
}
|