From c1ac145f2c7b3f83e3bf683d28f15d7cd8fbc67d Mon Sep 17 00:00:00 2001 From: Anne Markensteijn Date: Fri, 13 Oct 2023 16:21:59 +0200 Subject: [PATCH] Rename transform request factory Clean-up return in transform request function --- src/components/map/MapComponent.vue | 6 +++--- src/components/ssd/SsdComponent.vue | 4 ++-- src/components/systemmonitor/ImportStatusComponent.vue | 4 ++-- src/components/systemmonitor/RunningTasks.vue | 4 ++-- src/lib/fews-config/index.ts | 6 +++--- src/lib/requests/transformRequest.ts | 2 +- src/services/useSsd/index.ts | 4 ++-- src/services/useSsdPi/index.ts | 4 ++-- src/services/useTimeSeries/index.ts | 4 ++-- src/services/useTopologyNodes/index.ts | 4 ++-- src/services/useWms/index.ts | 6 +++--- src/views/AboutView.vue | 4 ++-- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/components/map/MapComponent.vue b/src/components/map/MapComponent.vue index 8e9a368d..d2f5ee9e 100644 --- a/src/components/map/MapComponent.vue +++ b/src/components/map/MapComponent.vue @@ -31,17 +31,17 @@ onBeforeMount(() => { function transformRequest(url: string, resourceType: ResourceType) { if (!configManager.authenticationIsEnabled) return { - url: url, + url, } if (resourceType === 'Image' && url.indexOf('GetMap') > -1) { const requestAuthHeaders = authenticationManager.getAuthorizationHeaders() return { - url: url, + url, headers: requestAuthHeaders, } } return { - url: url, + url, } } diff --git a/src/components/ssd/SsdComponent.vue b/src/components/ssd/SsdComponent.vue index 11240bbe..5aeb095e 100644 --- a/src/components/ssd/SsdComponent.vue +++ b/src/components/ssd/SsdComponent.vue @@ -26,7 +26,7 @@ @load="onLoad" @action="onAction" style="width: 100%" - :transformRequestFn="transformRequestFn()" + :transformRequestFn="createTransformRequestFn()" > @@ -37,7 +37,7 @@ import { nextTick, onBeforeUnmount } from 'vue' import { ref, onMounted, watch } from 'vue' import { useDisplay } from 'vuetify' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' interface Props { src?: string diff --git a/src/components/systemmonitor/ImportStatusComponent.vue b/src/components/systemmonitor/ImportStatusComponent.vue index e406b86b..92f0ad63 100644 --- a/src/components/systemmonitor/ImportStatusComponent.vue +++ b/src/components/systemmonitor/ImportStatusComponent.vue @@ -27,7 +27,7 @@ import { ImportStatus, PiWebserviceProvider } from '@deltares/fews-pi-requests' import { onMounted, onUnmounted, ref } from 'vue' import { configManager } from '../../services/application-config' import { VDataTable } from 'vuetify/labs/VDataTable' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' type UnwrapReadonlyArrayType = A extends Readonly> ? UnwrapReadonlyArrayType : A @@ -49,7 +49,7 @@ let active: boolean = false const baseUrl = configManager.get('VITE_FEWS_WEBSERVICES_URL') const webServiceProvider = new PiWebserviceProvider(baseUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) onUnmounted(() => { diff --git a/src/components/systemmonitor/RunningTasks.vue b/src/components/systemmonitor/RunningTasks.vue index 7c8bef35..13a5c064 100644 --- a/src/components/systemmonitor/RunningTasks.vue +++ b/src/components/systemmonitor/RunningTasks.vue @@ -27,7 +27,7 @@ import { import { configManager } from '../../services/application-config' import { onMounted, onUnmounted, ref } from 'vue' import { VDataTable } from 'vuetify/labs/VDataTable' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' type UnwrapReadonlyArrayType = A extends Readonly> ? UnwrapReadonlyArrayType : A @@ -39,7 +39,7 @@ const props = defineProps(['timeOut']) let noDataText = ref('Loading data..') const baseUrl = configManager.get('VITE_FEWS_WEBSERVICES_URL') const webServiceProvider = new PiWebserviceProvider(baseUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) onUnmounted(() => { diff --git a/src/lib/fews-config/index.ts b/src/lib/fews-config/index.ts index fe87693f..a9d3b3da 100644 --- a/src/lib/fews-config/index.ts +++ b/src/lib/fews-config/index.ts @@ -1,12 +1,12 @@ import { configManager } from '../../services/application-config/index.ts' import type { WebOcComponent, WebOcConfiguration } from './types.ts' import { PiWebserviceProvider } from '@deltares/fews-pi-requests' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' export async function getFewsConfig(): Promise { const baseUrl = configManager.get('VITE_FEWS_WEBSERVICES_URL') const webServiceProvider = new PiWebserviceProvider(baseUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) const fewsConfig = await webServiceProvider.getWebOcConfiguration() const webOcComponents: WebOcComponent[] = [] @@ -22,7 +22,7 @@ export async function getFewsConfig(): Promise { export function getResourcesStaticUrl(resource: string) { const baseUrl = configManager.get('VITE_FEWS_WEBSERVICES_URL') const webServiceProvider = new PiWebserviceProvider(baseUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) return webServiceProvider.resourcesStaticUrl(resource).toString() } diff --git a/src/lib/requests/transformRequest.ts b/src/lib/requests/transformRequest.ts index 1a40d401..e94de04b 100644 --- a/src/lib/requests/transformRequest.ts +++ b/src/lib/requests/transformRequest.ts @@ -1,6 +1,6 @@ import { authenticationManager } from '@/services/authentication/AuthenticationManager.ts' -export function transformRequestFn(controller?: AbortController) { +export function createTransformRequestFn(controller?: AbortController) { return async (request: Request): Promise => { return Promise.resolve( authenticationManager.transformRequestAuth(request, controller?.signal), diff --git a/src/services/useSsd/index.ts b/src/services/useSsd/index.ts index 10cbdbfd..8eaa75e6 100644 --- a/src/services/useSsd/index.ts +++ b/src/services/useSsd/index.ts @@ -8,7 +8,7 @@ import { import { ref, shallowRef, toValue, watchEffect } from 'vue' import { absoluteUrl } from '../../lib/utils/absoluteUrl.ts' import type { MaybeRefOrGetter, Ref } from 'vue' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' export interface UseSsdReturn { error: Ref capabilities: Ref @@ -45,7 +45,7 @@ export function useSsd( time: MaybeRefOrGetter, ): UseSsdReturn { const ssdProvider = new SsdWebserviceProvider(baseUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) const isReady = ref(false) diff --git a/src/services/useSsdPi/index.ts b/src/services/useSsdPi/index.ts index 7a70bb54..ace55671 100644 --- a/src/services/useSsdPi/index.ts +++ b/src/services/useSsdPi/index.ts @@ -14,7 +14,7 @@ import { toValue, watchEffect, } from 'vue' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' export interface UseSsdPiReturn { displayConfig: Ref @@ -31,7 +31,7 @@ export function useSsdPi( plotId?: MaybeRefOrGetter, ): UseSsdPiReturn { const ssdProvider = new SsdWebserviceProvider(baseUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) const isReady = ref(false) diff --git a/src/services/useTimeSeries/index.ts b/src/services/useTimeSeries/index.ts index a7f4b463..e7118cdb 100644 --- a/src/services/useTimeSeries/index.ts +++ b/src/services/useTimeSeries/index.ts @@ -5,7 +5,7 @@ import { absoluteUrl } from '../../lib/utils/absoluteUrl' import { DateTime, Interval } from 'luxon' import { Series } from '../../lib/timeseries/timeSeries' import { SeriesUrlRequest } from '../../lib/timeseries/timeSeriesResource' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' export interface UseTimeSeriesReturn { error: Ref @@ -58,7 +58,7 @@ export function useTimeSeries( controller.abort() controller = new AbortController() const piProvider = new PiWebserviceProvider(baseUrl, { - transformRequestFn: transformRequestFn(controller), + transformRequestFn: createTransformRequestFn(controller), }) const _requests = toValue(requests) for (const r in _requests) { diff --git a/src/services/useTopologyNodes/index.ts b/src/services/useTopologyNodes/index.ts index 814fdfe2..50221f98 100644 --- a/src/services/useTopologyNodes/index.ts +++ b/src/services/useTopologyNodes/index.ts @@ -8,7 +8,7 @@ import type { MaybeRefOrGetter, Ref } from 'vue' import { DisplayConfig } from '../../lib/display/DisplayConfig.js' import { timeSeriesDisplayToChartConfig } from '../../lib/charts/timeSeriesDisplayToChartConfig' import { ChartConfig } from '../../lib/charts/types/ChartConfig.js' -import { transformRequestFn } from '@/lib/requests/transformRequest.js' +import { createTransformRequestFn } from '@/lib/requests/transformRequest.js' export interface UseTopologyNodesReturn { error: Ref @@ -39,7 +39,7 @@ export function useTopologyNodes( plotId: MaybeRefOrGetter, ): UseTopologyNodesReturn { const piProvider = new PiWebserviceProvider(baseUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) const isReady = ref(false) diff --git a/src/services/useWms/index.ts b/src/services/useWms/index.ts index 52e93ba8..e01c2046 100644 --- a/src/services/useWms/index.ts +++ b/src/services/useWms/index.ts @@ -11,7 +11,7 @@ import { toWgs84 } from '@turf/projection' import { point } from '@turf/helpers' import { LngLatBounds } from 'mapbox-gl' import { GetLegendGraphicResponse } from '@deltares/fews-wms-requests/src/response/getLegendGraphicResponse.ts' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' export interface UseWmsReturn { legendGraphic: Ref @@ -25,7 +25,7 @@ export function useWmsLayer( const legendGraphic = ref() const wmsUrl = `${baseUrl}/wms` const wmsProvider = new WMSProvider(wmsUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) const times = ref() @@ -99,7 +99,7 @@ export function useWmsCapilities( const capabilities = ref() const wmsUrl = `${baseUrl}/wms` const wmsProvider = new WMSProvider(wmsUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) async function loadCapabilities(): Promise { diff --git a/src/views/AboutView.vue b/src/views/AboutView.vue index ef42350d..9becf83d 100644 --- a/src/views/AboutView.vue +++ b/src/views/AboutView.vue @@ -55,7 +55,7 @@ import { PiWebserviceProvider, Version } from '@deltares/fews-pi-requests' import { onMounted } from 'vue' import { useConfigStore } from '../stores/config.ts' import { configManager } from '@/services/application-config' -import { transformRequestFn } from '@/lib/requests/transformRequest' +import { createTransformRequestFn } from '@/lib/requests/transformRequest' const webServiceUrl = configManager.get('VITE_FEWS_WEBSERVICES_URL') const version = ref(packageConfig.version) @@ -69,7 +69,7 @@ const configStore = useConfigStore() onMounted(async () => { const webServiceProvider = new PiWebserviceProvider(webServiceUrl, { - transformRequestFn: transformRequestFn(), + transformRequestFn: createTransformRequestFn(), }) webServiceVersion.value = await ( await webServiceProvider.getVersion()