From a464e482871376ade4768d11ac6421ec49be4fa8 Mon Sep 17 00:00:00 2001 From: Patrick Cleavelin Date: Tue, 14 Mar 2023 21:44:10 -0500 Subject: [PATCH] lots of style stuff, can delete guild intros --- src/IntroDownloader.svelte | 4 +- src/IntroSelector.svelte | 44 +++++++++++++++------ src/api.js | 8 +++- src/app.html | 20 +++++++--- src/components/ModDashboard.svelte | 61 ++++++++++++++++++++++++++++++ src/routes/+page.svelte | 12 ++++-- 6 files changed, 124 insertions(+), 25 deletions(-) create mode 100644 src/components/ModDashboard.svelte diff --git a/src/IntroDownloader.svelte b/src/IntroDownloader.svelte index 656f6a2..b380ce1 100644 --- a/src/IntroDownloader.svelte +++ b/src/IntroDownloader.svelte @@ -51,7 +51,7 @@ {#if canDownloadAny}
-
+

Download New Intro

{#if !!downloadPromise} {#await downloadPromise} @@ -76,7 +76,7 @@ {/if}
-
+

Upload New Intro

{#if !!uploadPromise} {#await uploadPromise} diff --git a/src/IntroSelector.svelte b/src/IntroSelector.svelte index da56ff1..8b78b57 100644 --- a/src/IntroSelector.svelte +++ b/src/IntroSelector.svelte @@ -11,6 +11,7 @@ export let exclude = null; export let include = null; export let btnLabel = 'Add'; + export let btnDanger = false; export let emptyMsg = null; let filteredIntroList = []; @@ -82,16 +83,35 @@ let selectedIntros = []; -
- {#if !!filteredIntroList && filteredIntroList.length > 0} - {#each filteredIntroList as intro (intro.index)} - - {/each} - {:else} -

{emptyMsg}

- {/if} - +
+
+ {#if !!filteredIntroList && filteredIntroList.length > 0} + {#each filteredIntroList as intro (intro.index)} + + {/each} + {:else} +

{emptyMsg}

+ {/if} +
+
+ + diff --git a/src/api.js b/src/api.js index fe28c8c..4c4f13d 100644 --- a/src/api.js +++ b/src/api.js @@ -1,6 +1,6 @@ import { env } from '$env/dynamic/public'; -export const apiCall = async (method, endpoint, token, body) => { +export const apiCall = async (method, endpoint, token, body, contentType) => { const headers = (() => { if (!!token) { return { 'token': token }; @@ -12,7 +12,7 @@ export const apiCall = async (method, endpoint, token, body) => { return (await fetch( `${env.PUBLIC_API_URL}/${endpoint}`, - { method: method, headers: headers, body: body }) + { method: method, headers: { 'Content-Type': contentType, ...headers }, body: body }) ); }; @@ -48,3 +48,7 @@ export const removeIntro = async (guild, channel, selectedIntros, token) => { export const uploadIntro = async (guild, name, file, token) => { await apiCall('POST', `intros/${guild}/upload?name=${encodeURIComponent(name)}`, token, file); } + +export const deleteIntro = async (guild, selectedIntros, token) => { + await apiCall('DELETE', `intros/${guild}/delete`, token, JSON.stringify(selectedIntros), 'application/json'); +} diff --git a/src/app.html b/src/app.html index fffa607..4869924 100644 --- a/src/app.html +++ b/src/app.html @@ -23,7 +23,7 @@ div#cardContent { display: grid; grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); - align-items: center; + align-items: stretch; justify-items: center; justify-content: center; background-color: #323259; @@ -33,14 +33,24 @@ gap: 1em; } - div#list { + div#nestedCardContent { display: flex; + position: relative; width: 85%; - border-radius: 4px; + height: fit-content; flex-direction: column; align-items: center; + background-color: #2a2a4a; + padding: 16px; + box-shadow: 1px 3px 4px 1px #1f1f36; + } + + div#nestedCardContent.cardNoShadow{ + box-shadow: none; + } + + div#nestedCardContent.cardLight{ background-color: #323259; - padding: 1em; } button, #list-item { @@ -68,5 +78,5 @@ background-image: linear-gradient(0deg, #40406e, #444475); } - %sveltekit.body% +
%sveltekit.body%
diff --git a/src/components/ModDashboard.svelte b/src/components/ModDashboard.svelte new file mode 100644 index 0000000..a93b651 --- /dev/null +++ b/src/components/ModDashboard.svelte @@ -0,0 +1,61 @@ + + +

Wow you're a moderator, here is a cool dashboard for you to use

+
+
+ {#if dashboardVisible} +
+ + {#if !!deletePromise} + {#await deletePromise} + {:catch err} +

{err}

+ {/await} + {/if} +
+ {#each $member.guilds as guild} +

{guild.name}

+ + {/each} +
+
+ {:else} + + {/if} +
+
+ + + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 0ed531a..d8b520d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -6,6 +6,7 @@ import Login from '../Login.svelte'; import IntroSelector from '../IntroSelector.svelte'; import IntroDownloader from '../IntroDownloader.svelte'; + import ModDashboard from '../components/ModDashboard.svelte'; let addIntroPromise = null; let removeIntroPromise = null; @@ -33,14 +34,16 @@

MemeJoin - A bot for user intros

{$member.username}

+ +

Guild Settings

{#each $member.guilds as guild} -
+

{guild.name}

-
+
{#each guild.channels as channel} -
+

{channel.name}

{#await addIntroPromise then result} {:catch err} @@ -81,7 +84,7 @@ {/if}