mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
@grafana/data: Add serializeParams (#78468)
* Move serializeParams to @grafana/data * Update comment * Update solution in Tempo * Fix type assertions * Use toUrlParams in serializeParams * Update data sources * Update * Update packages/grafana-data/src/utils/url.ts
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
rangeUtil,
|
||||
ScopedVars,
|
||||
TestDataSourceResponse,
|
||||
urlUtil,
|
||||
} from '@grafana/data';
|
||||
import {
|
||||
BackendSrvRequest,
|
||||
@@ -32,7 +33,6 @@ import {
|
||||
import { BarGaugeDisplayMode, TableCellDisplayMode, VariableFormatID } from '@grafana/schema';
|
||||
import { NodeGraphOptions } from 'app/core/components/NodeGraphSettings';
|
||||
import { TraceToLogsOptions } from 'app/core/components/TraceToLogs/TraceToLogsSettings';
|
||||
import { serializeParams } from 'app/core/utils/fetch';
|
||||
import { SpanBarOptions } from 'app/features/explore/TraceView/components';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
|
||||
@@ -691,7 +691,7 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
|
||||
data?: unknown,
|
||||
options?: Partial<BackendSrvRequest>
|
||||
): Observable<Record<string, any>> {
|
||||
const params = data ? serializeParams(data) : '';
|
||||
const params = data ? urlUtil.serializeParams(data) : '';
|
||||
const url = `${this.instanceSettings.url}${apiUrl}${params.length ? `?${params}` : ''}`;
|
||||
const req = { ...options, url };
|
||||
|
||||
@@ -723,7 +723,9 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
|
||||
if (query.queryType === 'nativeSearch') {
|
||||
let result = [];
|
||||
for (const key of ['serviceName', 'spanName', 'search', 'minDuration', 'maxDuration', 'limit']) {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
if (query.hasOwnProperty(key) && query[key as keyof TempoQuery]) {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
result.push(`${startCase(key)}: ${query[key as keyof TempoQuery]}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user