diff --git a/starsky/starsky.foundation.platform/Models/AppSettingsTransferObject.cs b/starsky/starsky.foundation.platform/Models/AppSettingsTransferObject.cs index 970419ffd3..cc2fcc061d 100644 --- a/starsky/starsky.foundation.platform/Models/AppSettingsTransferObject.cs +++ b/starsky/starsky.foundation.platform/Models/AppSettingsTransferObject.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using starsky.foundation.platform.Enums; + namespace starsky.foundation.platform.Models { /// @@ -11,5 +14,11 @@ public sealed class AppSettingsTransferObject public bool? UseSystemTrash { get; set; } public bool? UseLocalDesktop { get; set; } + + public List DefaultDesktopEditor { get; set; } = []; + + public CollectionsOpenType.RawJpegMode DesktopCollectionsOpen { get; set; } = + CollectionsOpenType.RawJpegMode.Default; + } } diff --git a/starsky/starsky/Controllers/AppSettingsController.cs b/starsky/starsky/Controllers/AppSettingsController.cs index 783f8c4b03..ad18e0b25b 100644 --- a/starsky/starsky/Controllers/AppSettingsController.cs +++ b/starsky/starsky/Controllers/AppSettingsController.cs @@ -38,6 +38,8 @@ public AppSettingsController(AppSettings appSettings, public IActionResult Env() { var appSettings = _appSettings.CloneToDisplay(); + + // For end-to-end testing if ( Request != null! && Request.Headers.Any(p => p.Key == "x-force-html") ) { Response.Headers.ContentType = "text/html; charset=utf-8"; diff --git a/starsky/starsky/clientapp/src/components/organisms/preference-app-settings-desktop/preference-app-settings-desktop.tsx b/starsky/starsky/clientapp/src/components/organisms/preference-app-settings-desktop/preference-app-settings-desktop.tsx index f9f9e913be..c08358091a 100644 --- a/starsky/starsky/clientapp/src/components/organisms/preference-app-settings-desktop/preference-app-settings-desktop.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/preference-app-settings-desktop/preference-app-settings-desktop.tsx @@ -1,10 +1,72 @@ -import React from "react"; +import React, { useState } from "react"; +import useFetch from "../../../hooks/use-fetch"; +import useGlobalSettings from "../../../hooks/use-global-settings"; +import { IAppSettings } from "../../../interfaces/IAppSettings"; +import { RawJpegMode } from "../../../interfaces/ICollectionsOpenType"; +import localization from "../../../localization/localization.json"; +import FetchPost from "../../../shared/fetch/fetch-post"; +import { Language } from "../../../shared/language"; +import { UrlQuery } from "../../../shared/url-query"; +import FormControl from "../../atoms/form-control/form-control"; +import SwitchButton from "../../atoms/switch-button/switch-button"; const PreferencesAppSettingsDesktop: React.FunctionComponent = () => { + const appSettings = useFetch(new UrlQuery().UrlApiAppSettings(), "get") + ?.data as IAppSettings | null; + + const settings = useGlobalSettings(); + + const language = new Language(settings.language); + const MessageSwitchButtonDesktopCollectionsRawOn = language.key( + localization.MessageSwitchButtonDesktopCollectionsRawOn + ); + const MessageSwitchButtonDesktopCollectionsJpegDefaultOff = language.key( + localization.MessageSwitchButtonDesktopCollectionsJpegDefaultOff + ); + + // appSettings?.desktopCollectionsOpen + // List DefaultDesktopEditor + // CollectionsOpenType.RawJpegMode DesktopCollectionsOpen + + async function toggleCollections(value: boolean) { + const desktopCollectionsOpen = value ? RawJpegMode.Raw : RawJpegMode.Jpeg; + + const bodyParams = new URLSearchParams(); + bodyParams.set("desktopCollectionsOpen", desktopCollectionsOpen.toString()); + + const result = await FetchPost(new UrlQuery().UrlApiAppSettings(), bodyParams.toString()); + if (result.statusCode != 200) { + setIsMessage("FAIL"); + return; + } + setIsMessage("OK"); + } + + // for showing a notification + const [isMessage, setIsMessage] = useState(""); + return ( <>

Desktop

Only used when using Starsky as desktop + {isMessage !== "" ? ( +
{isMessage}
+ ) : null} + +

Tags:

+ ); }; diff --git a/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings-storage-folder/preferences-app-settings-storage-folder.tsx b/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings-storage-folder/preferences-app-settings-storage-folder.tsx index 0130677f12..17d8702a5f 100644 --- a/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings-storage-folder/preferences-app-settings-storage-folder.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings-storage-folder/preferences-app-settings-storage-folder.tsx @@ -7,6 +7,13 @@ import FetchPost from "../../../shared/fetch/fetch-post"; import { Language } from "../../../shared/language"; import { UrlQuery } from "../../../shared/url-query"; import FormControl from "../../atoms/form-control/form-control"; + +/** + * Update Change Settings + * @param value - content + * @param name - key name + * @returns void + */ export async function ChangeSetting(value: string, name?: string): Promise { const bodyParams = new URLSearchParams(); bodyParams.set(name ?? "", value); @@ -53,10 +60,6 @@ const PreferencesAppSettingsStorageFolder: React.FunctionComponent = () => { const [storageFolder, setStorageFolder] = useState(appSettings?.storageFolder); - // const [defaultDesktopEditor, setDefaultDesktopEditor] = useState( - // appSettings?.defaultDesktopEditor - // ); - useEffect(() => { setStorageFolder(appSettings?.storageFolder); }, [appSettings]); diff --git a/starsky/starsky/clientapp/src/localization/localization.json b/starsky/starsky/clientapp/src/localization/localization.json index 10f33cf345..d7a2728441 100644 --- a/starsky/starsky/clientapp/src/localization/localization.json +++ b/starsky/starsky/clientapp/src/localization/localization.json @@ -283,6 +283,15 @@ "en": "Please update the 'app__storageFolder' environment variable to change the location", "nl": "Update alsjeblieft de 'app__storageFolder' environment variable om de opslag locatie te veranderen" }, + "MessageSwitchButtonDesktopCollectionsRawOn": { + "en": "Raw first", + "nl": "Raw eerst" + }, + "MessageSwitchButtonDesktopCollectionsJpegDefaultOff": { + "en": "Jpeg first", + "nl": "Jpeg eerst" + }, + "temp1": { "en": "", "nl": "" diff --git a/starsky/starskytest/starsky.feature.settings/Services/UpdateAppSettingsByPathTest.cs b/starsky/starskytest/starsky.feature.settings/Services/UpdateAppSettingsByPathTest.cs index 10ca323d82..41f0ccecbf 100644 --- a/starsky/starskytest/starsky.feature.settings/Services/UpdateAppSettingsByPathTest.cs +++ b/starsky/starskytest/starsky.feature.settings/Services/UpdateAppSettingsByPathTest.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using starsky.feature.settings.Services; +using starsky.foundation.platform.Enums; using starsky.foundation.platform.JsonConverter; using starsky.foundation.platform.Models; using starsky.foundation.storage.Helpers; @@ -31,7 +32,8 @@ public async Task UpdateAppSettingsAsync_ValidInput_Success() new UpdateAppSettingsByPath(new AppSettings(), selectorStorage); var appSettingTransferObject = new AppSettingsTransferObject { - StorageFolder = testFolderPath, Verbose = true + StorageFolder = testFolderPath, + Verbose = true }; // Act @@ -62,7 +64,9 @@ public async Task UpdateAppSettingsAsync_ValidInput_Success_CompareJson() var updateAppSettingsByPath = new UpdateAppSettingsByPath(appSettings, selectorStorage); var appSettingTransferObject = new AppSettingsTransferObject { - StorageFolder = testFolderPath, Verbose = true, UseLocalDesktop = null + StorageFolder = testFolderPath, + Verbose = true, + UseLocalDesktop = null }; // Act @@ -191,5 +195,28 @@ await StreamToStringHelper.StreamToStringAsync( Assert.AreEqual(testFolderPath, fileResult2.App.StorageFolder); Assert.IsTrue(fileResult2.App.Verbose); } + + [TestMethod] + public async Task UpdateAppSettingsAsync_ValidInput_Success1() + { + var storage = new FakeIStorage(); + var selectorStorage = new FakeSelectorStorage(storage); + var updateAppSettingsByPath = + new UpdateAppSettingsByPath(new AppSettings(), selectorStorage); + var appSettingTransferObject = new AppSettingsTransferObject + { + DesktopCollectionsOpen = CollectionsOpenType.RawJpegMode.Raw, + Verbose = true + }; + + // Act + var result = + await updateAppSettingsByPath.UpdateAppSettingsAsync(appSettingTransferObject); + + + // Assert + Assert.AreEqual(200, result.StatusCode); + Assert.AreEqual("Updated", result.Message); + } } }