From 68d15b98f7225e98c487dfc3c55ad919d5f0c807 Mon Sep 17 00:00:00 2001 From: Jake Fulmine Date: Mon, 22 Aug 2022 10:19:39 +0200 Subject: [PATCH] feat(dashboard): rewrite system privacy and add pronouns --- dashboard/src/api/types.ts | 5 +- dashboard/src/lib/system/Privacy.svelte | 34 ++--- dashboard/src/lib/system/PrivacyEdit.svelte | 138 +++++++++----------- 3 files changed, 79 insertions(+), 98 deletions(-) diff --git a/dashboard/src/api/types.ts b/dashboard/src/api/types.ts index 3aaea446..8ca724b5 100644 --- a/dashboard/src/api/types.ts +++ b/dashboard/src/api/types.ts @@ -1,9 +1,10 @@ -interface SystemPrivacy { +export interface SystemPrivacy { description_privacy?: string, member_list_privacy?: string, front_privacy?: string, front_history_privacy?: string, - group_list_privacy?: string + group_list_privacy?: string, + pronoun_privacy?: string, } export interface System { diff --git a/dashboard/src/lib/system/Privacy.svelte b/dashboard/src/lib/system/Privacy.svelte index 2a5060b7..41417409 100644 --- a/dashboard/src/lib/system/Privacy.svelte +++ b/dashboard/src/lib/system/Privacy.svelte @@ -4,12 +4,22 @@ import FaUserLock from 'svelte-icons/fa/FaUserLock.svelte'; import PrivacyEdit from './PrivacyEdit.svelte'; - import { System } from '../../api/types'; + import { System, SystemPrivacy } from '../../api/types'; export let user: System; let editMode = false; let loading: boolean; + + const privacyNames: { [P in keyof SystemPrivacy]-?: string; } = { + description_privacy: "Description", + member_list_privacy: "Member list", + front_privacy: "Front", + front_history_privacy: "Front history", + group_list_privacy: "Group list", + pronoun_privacy: "Pronouns" + }; + @@ -23,24 +33,14 @@ {#if editMode} - + {:else} - - Description: {user.privacy.description_privacy} - - - Member list: {user.privacy.member_list_privacy} - - - Group list: {user.privacy.group_list_privacy} - - - Current front: {user.privacy.front_privacy} - - - Front history: {user.privacy.front_history_privacy} - + {#each Object.keys(user.privacy) as x} + + {privacyNames[x]}: {user.privacy[x]} + + {/each} diff --git a/dashboard/src/lib/system/PrivacyEdit.svelte b/dashboard/src/lib/system/PrivacyEdit.svelte index 38b2d1ae..bc8ffd3c 100644 --- a/dashboard/src/lib/system/PrivacyEdit.svelte +++ b/dashboard/src/lib/system/PrivacyEdit.svelte @@ -1,96 +1,76 @@ -{#if err} + + {#if err} {err} -{/if} - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + {/if} + {#if success} + System privacy updated! + {/if} + + +
+ + {#each Object.keys(privacy) as x} + + + + + + + + {/each} + + +{#if loading} + +{:else} + +{/if} \ No newline at end of file