From a6ddceb643e944bec0ee6342b5d22567f2811438 Mon Sep 17 00:00:00 2001 From: wukko Date: Wed, 10 Jul 2024 23:35:53 +0600 Subject: [PATCH] web/settings: add advanced & debug pages --- web/i18n/en/settings.json | 8 +++- web/src/lib/settings/defaults.ts | 3 ++ web/src/lib/types/settings.ts | 5 ++ web/src/lib/version.ts | 23 +++++++++ web/src/routes/settings/+layout.svelte | 23 +++++++++ web/src/routes/settings/advanced/+page.svelte | 15 ++++++ .../settings/advanced/debug/+page.svelte | 47 +++++++++++++++++++ 7 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 web/src/lib/version.ts create mode 100644 web/src/routes/settings/advanced/+page.svelte create mode 100644 web/src/routes/settings/advanced/debug/+page.svelte diff --git a/web/i18n/en/settings.json b/web/i18n/en/settings.json index df13ed84..9eea91ab 100644 --- a/web/i18n/en/settings.json +++ b/web/i18n/en/settings.json @@ -3,6 +3,8 @@ "page.video": "video", "page.audio": "audio", "page.metadata": "metadata", + "page.advanced": "advanced", + "page.debug": "debug information", "section.general": "general", "section.save": "save", @@ -80,5 +82,9 @@ "language.auto.title": "use default browser language", "language.auto.description": "automatically picks the best language for you. if preferred browser language isn't available, english is used instead. disable this toggle to pick a language manually.", "language.preferred.title": "preferred language", - "language.preferred.description": "language used for interface and content." + "language.preferred.description": "language used for interface and content.", + + "advanced.debug": "debug", + "advanced.debug.title": "enable debug features", + "advanced.debug.description": "gives you access to a page with app & device info useful for debugging." } diff --git a/web/src/lib/settings/defaults.ts b/web/src/lib/settings/defaults.ts index 33d35603..adb698f5 100644 --- a/web/src/lib/settings/defaults.ts +++ b/web/src/lib/settings/defaults.ts @@ -8,6 +8,9 @@ const defaultSettings: CobaltSettings = { reduceAnimations: false, reduceTransparency: false, }, + advanced: { + debug: false, + }, appearance: { theme: "auto", language: defaultLocale, diff --git a/web/src/lib/types/settings.ts b/web/src/lib/types/settings.ts index b8e6e5f8..5426adf3 100644 --- a/web/src/lib/types/settings.ts +++ b/web/src/lib/types/settings.ts @@ -18,6 +18,10 @@ type CobaltSettingsAppearance = { autoLanguage: boolean, }; +type CobaltSettingsAdvanced = { + debug: boolean, +}; + type CobaltSettingsGeneral = { customProcessingEndpoint: string, seenOnboarding: boolean, @@ -45,6 +49,7 @@ type CobaltSettingsPrivacy = { export type CobaltSettings = { schemaVersion: number, accessibility: CobaltSettingsAccessibility, + advanced: CobaltSettingsAdvanced, appearance: CobaltSettingsAppearance, general: CobaltSettingsGeneral, save: CobaltSettingsSave, diff --git a/web/src/lib/version.ts b/web/src/lib/version.ts new file mode 100644 index 00000000..ff9b4a0b --- /dev/null +++ b/web/src/lib/version.ts @@ -0,0 +1,23 @@ +type VersionResponse = { + commit: string; + branch: string; + remote: string; + version: string; +} + +const fetchVersion = async function () { + const response: VersionResponse | undefined = await fetch('/version.json') + .then(r => r.json()) + .catch(() => {}); + + if (!response) return { + commit: "unknown", + branch: "unknown", + remote: "unknown", + version: "unknown" + } + + return response; +} + +export const version = await fetchVersion(); diff --git a/web/src/routes/settings/+layout.svelte b/web/src/routes/settings/+layout.svelte index b59d679d..5d22da80 100644 --- a/web/src/routes/settings/+layout.svelte +++ b/web/src/routes/settings/+layout.svelte @@ -1,6 +1,8 @@ + + + + diff --git a/web/src/routes/settings/advanced/debug/+page.svelte b/web/src/routes/settings/advanced/debug/+page.svelte new file mode 100644 index 00000000..925d5fed --- /dev/null +++ b/web/src/routes/settings/advanced/debug/+page.svelte @@ -0,0 +1,47 @@ + + +
+ device: +
+ is.iPad: {device.is.iPad} + is.iPhone: {device.is.iPhone} + is.iOS: {device.is.iOS} + is.android: {device.is.android} + is.mobile: {device.is.mobile} + preferredLocale: {device.preferredLocale} +
+ + app: +
+ is.installed: {app.is.installed} +
+ + version: +
+ version: {version.version} + commit: {version.commit.slice(0, 7)} + branch: {version.branch} + remote: {version.remote} +
+
+ +