mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* - initial work on data source config page * - add links to test status box - add tracking function * - add test for the DataSourceConfigAlert component * - fix flicker of the alert box * - fix the build * - small improvements * - fix failing build * - fix failing unit tests * - prettier and betterer fixes * - fix failing e2e tests * - fix build again * - rewrite solution according to the PR comments * - cleanup * - fix failing e2e * - use absolute path in link * Minor fixes --------- Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
94 lines
2.6 KiB
TypeScript
94 lines
2.6 KiB
TypeScript
import { Observable, of } from 'rxjs';
|
|
|
|
import {
|
|
DataFrame,
|
|
dataFrameToJSON,
|
|
MutableDataFrame,
|
|
DataSourceInstanceSettings,
|
|
DataSourceJsonData,
|
|
DataSourceRef,
|
|
ScopedVars,
|
|
DataSourceApi,
|
|
DataQuery,
|
|
DataQueryRequest,
|
|
DataQueryResponse,
|
|
TestDataSourceResponse,
|
|
} from '@grafana/data';
|
|
import { GetDataSourceListFilters, setDataSourceSrv } from '@grafana/runtime';
|
|
|
|
import { CloudWatchLogsQueryStatus } from '../types';
|
|
|
|
import { meta, setupMockedDataSource } from './CloudWatchDataSource';
|
|
|
|
export function setupForLogs() {
|
|
function envelope(frame: DataFrame) {
|
|
return { data: { results: { a: { refId: 'a', frames: [dataFrameToJSON(frame)] } } } };
|
|
}
|
|
|
|
const { datasource, fetchMock, timeSrv } = setupMockedDataSource();
|
|
|
|
const startQueryFrame = new MutableDataFrame({ fields: [{ name: 'queryId', values: ['queryid'] }] });
|
|
fetchMock.mockReturnValueOnce(of(envelope(startQueryFrame)));
|
|
|
|
const logsFrame = new MutableDataFrame({
|
|
fields: [
|
|
{
|
|
name: '@message',
|
|
values: ['something'],
|
|
},
|
|
{
|
|
name: '@timestamp',
|
|
values: [1],
|
|
},
|
|
{
|
|
name: '@xrayTraceId',
|
|
values: ['1-613f0d6b-3e7cb34375b60662359611bd'],
|
|
},
|
|
],
|
|
meta: { custom: { Status: CloudWatchLogsQueryStatus.Complete } },
|
|
});
|
|
|
|
fetchMock.mockReturnValueOnce(of(envelope(logsFrame)));
|
|
|
|
setDataSourceSrv({
|
|
async get() {
|
|
const ds: DataSourceApi = {
|
|
name: 'Xray',
|
|
id: 0,
|
|
type: '',
|
|
uid: '',
|
|
query: function (
|
|
request: DataQueryRequest<DataQuery>
|
|
): Observable<DataQueryResponse> | Promise<DataQueryResponse> {
|
|
throw new Error('Function not implemented.');
|
|
},
|
|
testDatasource: function (): Promise<TestDataSourceResponse> {
|
|
throw new Error('Function not implemented.');
|
|
},
|
|
meta: meta,
|
|
getRef: function (): DataSourceRef {
|
|
throw new Error('Function not implemented.');
|
|
},
|
|
};
|
|
|
|
return ds;
|
|
},
|
|
getList: function (
|
|
filters?: GetDataSourceListFilters | undefined
|
|
): Array<DataSourceInstanceSettings<DataSourceJsonData>> {
|
|
throw new Error('Function not implemented.');
|
|
},
|
|
getInstanceSettings: function (
|
|
ref?: string | DataSourceRef | null | undefined,
|
|
scopedVars?: ScopedVars | undefined
|
|
): DataSourceInstanceSettings<DataSourceJsonData> | undefined {
|
|
throw new Error('Function not implemented.');
|
|
},
|
|
reload: function (): void {
|
|
throw new Error('Function not implemented.');
|
|
},
|
|
});
|
|
|
|
return { datasource, fetchMock, timeSrv };
|
|
}
|