diff --git a/src/app/[locale]/settings/_components/id-settings/IdSettingsCard.tsx b/src/app/[locale]/settings/_components/id-settings/IdSettingsCard.tsx index e1a2898..d606dee 100644 --- a/src/app/[locale]/settings/_components/id-settings/IdSettingsCard.tsx +++ b/src/app/[locale]/settings/_components/id-settings/IdSettingsCard.tsx @@ -129,7 +129,7 @@ export function IdSettingsCard() { setIsLoading(true); for (const setting of data.idSettings) { if (setting.prefix.value && setting.dynamicPart.value) { - await putSingleIdGenerationSetting(setting.name, bearerToken, { + await putSingleIdGenerationSetting(setting.name, { prefix: setting.prefix.value, dynamicPart: setting.dynamicPart.value, }); diff --git a/src/app/[locale]/templates/[id]/page.tsx b/src/app/[locale]/templates/[id]/page.tsx index 2b14d27..90e12a7 100644 --- a/src/app/[locale]/templates/[id]/page.tsx +++ b/src/app/[locale]/templates/[id]/page.tsx @@ -62,12 +62,12 @@ export default function Page() { const env = useEnv(); const fetchCustom = async () => { if (!id) return; - const custom = await getCustomTemplateById(bearerToken, id); + const custom = await getCustomTemplateById(id); setLocalFrontendTemplate(generateSubmodelViewObject(custom)); }; const fetchDefaultTemplates = async () => { - const defaultTemplates = await getDefaultTemplates(bearerToken); + const defaultTemplates = await getDefaultTemplates(); setDefaultTemplates(defaultTemplates); }; @@ -134,7 +134,7 @@ export default function Page() { const deleteTemplate = async () => { if (!id) return; try { - await deleteCustomTemplateById(bearerToken, id); + await deleteCustomTemplateById(id); notificationSpawner.spawn({ message: intl.formatMessage(messages.mnestix.templateDeletedSuccessfully), severity: 'success', diff --git a/src/app/[locale]/templates/page.tsx b/src/app/[locale]/templates/page.tsx index e188e2a..11460df 100644 --- a/src/app/[locale]/templates/page.tsx +++ b/src/app/[locale]/templates/page.tsx @@ -49,7 +49,7 @@ export default function Page() { const bearerToken = auth.getBearerToken(); const fetchAll = async () => { // fetching defaults first - const _defaults = await getDefaultTemplates(bearerToken); + const _defaults = await getDefaultTemplates(); _defaults.sort((a: Submodel, b: Submodel) => sortWithNullableValues(a.idShort, b.idShort)); setDefaults(_defaults); const _defaultItems: TabSelectorItem[] = [ @@ -80,7 +80,7 @@ export default function Page() { const fetchCustoms = async (_defaultItems: Array) => { const _customTemplateItems: CustomTemplateItemType[] = []; - const customs = (await getCustomTemplates(bearerToken)) as Submodel[]; + const customs = (await getCustomTemplates()) as Submodel[]; customs?.forEach((customSubmodel: Submodel) => { // get displayName out of Qualifiers or use idShort of Submodel const displayName = @@ -185,7 +185,7 @@ export default function Page() { const deleteTemplate = async (item: CustomTemplateItemType) => { if (!item.id) return; try { - await deleteCustomTemplateById(bearerToken, item.id); + await deleteCustomTemplateById(item.id); notificationSpawner.spawn({ message: intl.formatMessage(messages.mnestix.templateDeletedSuccessfully), severity: 'success', diff --git a/src/lib/api/configuration-shell-api/configurationShellApi.ts b/src/lib/api/configuration-shell-api/configurationShellApi.ts index cdc596f..b24ad37 100644 --- a/src/lib/api/configuration-shell-api/configurationShellApi.ts +++ b/src/lib/api/configuration-shell-api/configurationShellApi.ts @@ -60,19 +60,17 @@ export class ConfigurationShellApi implements IConfigurationShellApi { async putSingleIdGenerationSetting( idShort: string, - bearerToken: string, values: { prefix: string; dynamicPart: string; }, ) { - await this.putSingleSettingValue(`${idShort}.Prefix`, bearerToken, values.prefix, 'idGeneration'); - await this.putSingleSettingValue(`${idShort}.DynamicPart`, bearerToken, values.dynamicPart, 'idGeneration'); + await this.putSingleSettingValue(`${idShort}.Prefix`, values.prefix, 'idGeneration'); + await this.putSingleSettingValue(`${idShort}.DynamicPart`, values.dynamicPart, 'idGeneration'); } async putSingleSettingValue( path: string, - bearerToken: string, value: string, settingsType: string, ): Promise { diff --git a/src/lib/api/configuration-shell-api/configurationShellApiInterface.ts b/src/lib/api/configuration-shell-api/configurationShellApiInterface.ts index 5d1c94a..1b8cffb 100644 --- a/src/lib/api/configuration-shell-api/configurationShellApiInterface.ts +++ b/src/lib/api/configuration-shell-api/configurationShellApiInterface.ts @@ -7,14 +7,13 @@ export interface IConfigurationShellApi { putSingleIdGenerationSetting( idShort: string, - bearerToken: string, values: { prefix: string; dynamicPart: string; }, ): Promise; - putSingleSettingValue(path: string, bearerToken: string, value: string, settingsType: string): Promise; + putSingleSettingValue(path: string, value: string, settingsType: string): Promise; processPutSingleSettingValue(response: Response): Promise; } diff --git a/src/lib/api/template-shell-api/templateShellApi.ts b/src/lib/api/template-shell-api/templateShellApi.ts index eee9700..3275790 100644 --- a/src/lib/api/template-shell-api/templateShellApi.ts +++ b/src/lib/api/template-shell-api/templateShellApi.ts @@ -26,12 +26,13 @@ export class TemplateShellApi { return new TemplateShellApi(backendApiUrl, enable_authentication, http); } - public async getDefaults(token: string): Promise { - const headers = this.prepareHeader(token); + public async getDefaults(): Promise { const response = await this.http.fetch(`${this.basePathOwnApi}/allDefaultSubmodels`, { method: 'GET', - headers, + headers: { + 'Accept': 'application/json', + }, }); if (response.status >= 200 && response.status < 300) { @@ -41,12 +42,13 @@ export class TemplateShellApi { } } - public async getCustoms(token: string): Promise { - const headers = this.prepareHeader(token); + public async getCustoms(): Promise { const response = await this.http.fetch(`${this.basePathOwnApi}/allCustomSubmodels`, { method: 'GET', - headers, + headers: { + 'Accept': 'application/json', + }, }); if (response.status >= 200 && response.status < 300) { @@ -56,14 +58,15 @@ export class TemplateShellApi { } } - public async getCustom(token: string, submodelIdShort: string): Promise { - const headers = this.prepareHeader(token); + public async getCustom(submodelIdShort: string): Promise { const response = await this.http.fetch( `${this.basePathOwnApi}/CustomSubmodel/${encodeBase64(submodelIdShort)}`, { method: 'GET', - headers, + headers: { + 'Accept': 'application/json', + }, }, ); @@ -74,14 +77,15 @@ export class TemplateShellApi { } } - public async deleteCustomById(token: string, id: string): Promise { - const headers = this.prepareHeader(token); + public async deleteCustomById(id: string): Promise { // We use the regular delete endpoint, which expects an idShort, but because of our backend interception, we saved the actual id in the idShort field earlier. // That's why this works. const response = await this.http.fetch(`${this.basePathCustoms}/${encodeBase64(id)}`, { method: 'DELETE', - headers, + headers: { + 'Accept': 'application/json', + }, }); if (response.status >= 200 && response.status < 300) { @@ -90,14 +94,4 @@ export class TemplateShellApi { throw response; } } - - private prepareHeader(token: string) { - const headers = { - Accept: 'application/json', - }; - if (this.enable_authentication) { - headers['Authorization'] = token; - } - return headers; - } } diff --git a/src/lib/services/configurationApiActions.ts b/src/lib/services/configurationApiActions.ts index 23b71d1..13bed19 100644 --- a/src/lib/services/configurationApiActions.ts +++ b/src/lib/services/configurationApiActions.ts @@ -16,11 +16,10 @@ export async function getIdGenerationSettings(): Promise { export async function putSingleIdGenerationSetting( idShort: string, - bearerToken: string, values: { prefix: string; dynamicPart: string; }, ): Promise { - return configurationShellApi.putSingleIdGenerationSetting(idShort, bearerToken, values); + return configurationShellApi.putSingleIdGenerationSetting(idShort, values); } diff --git a/src/lib/services/templatesApiActions.ts b/src/lib/services/templatesApiActions.ts index dc5ea31..5032964 100644 --- a/src/lib/services/templatesApiActions.ts +++ b/src/lib/services/templatesApiActions.ts @@ -10,18 +10,18 @@ const templateApiClient = TemplateShellApi.create( mnestixFetchLegacy(), ); -export async function getDefaultTemplates(bearerToken: string): Promise { - return templateApiClient.getDefaults(bearerToken); +export async function getDefaultTemplates(): Promise { + return templateApiClient.getDefaults(); } -export async function getCustomTemplates(bearerToken: string): Promise { - return templateApiClient.getCustoms(bearerToken); +export async function getCustomTemplates(): Promise { + return templateApiClient.getCustoms(); } -export async function getCustomTemplateById(bearerToken: string, id: string): Promise { - return templateApiClient.getCustom(bearerToken, id); +export async function getCustomTemplateById(id: string): Promise { + return templateApiClient.getCustom(id); } -export async function deleteCustomTemplateById(bearerToken: string, id: string): Promise { - return templateApiClient.deleteCustomById(bearerToken, id); +export async function deleteCustomTemplateById(id: string): Promise { + return templateApiClient.deleteCustomById(id); }