mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Move convertToWebSocketUrl from Explore to Loki (#78542)
* Move convertToWebSocketUrl to Loki * Add tests * Fix test
This commit is contained in:
@@ -28,8 +28,6 @@ import store from 'app/core/store';
|
||||
import { ExpressionDatasourceUID } from 'app/features/expressions/types';
|
||||
import { QueryOptions, QueryTransaction } from 'app/types/explore';
|
||||
|
||||
import { config } from '../config';
|
||||
|
||||
import { getNextRefIdChar } from './query';
|
||||
|
||||
export const DEFAULT_UI_STATE = {
|
||||
@@ -329,15 +327,6 @@ export const getTimeRange = (timeZone: TimeZone, rawRange: RawTimeRange, fiscalY
|
||||
export const refreshIntervalToSortOrder = (refreshInterval?: string) =>
|
||||
RefreshPicker.isLive(refreshInterval) ? LogsSortOrder.Ascending : LogsSortOrder.Descending;
|
||||
|
||||
export const convertToWebSocketUrl = (url: string) => {
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||
let backend = `${protocol}${window.location.host}${config.appSubUrl}`;
|
||||
if (backend.endsWith('/')) {
|
||||
backend = backend.slice(0, -1);
|
||||
}
|
||||
return `${backend}${url}`;
|
||||
};
|
||||
|
||||
export const stopQueryState = (querySubscription: Unsubscribable | undefined) => {
|
||||
if (querySubscription) {
|
||||
querySubscription.unsubscribe();
|
||||
|
||||
Reference in New Issue
Block a user