-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from ssciwr/svelte5
Svelte 5
- Loading branch information
Showing
22 changed files
with
336 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { milestoneGroups, userQuestions } from '$lib/stores/adminStore'; | ||
import { | ||
authCookieLogin, | ||
getMilestoneGroupsAdmin, | ||
getUserQuestionsAdmin, | ||
usersCurrentUser | ||
} from '$lib/client/services.gen'; | ||
import type { | ||
GetLanguagesResponse, | ||
MilestoneGroupAdmin, | ||
UserQuestionAdmin, | ||
UserRead, | ||
Body_auth_cookie_login_auth_login_post | ||
} from '$lib/client/types.gen'; | ||
|
||
function AdminUser() { | ||
let user = $state(null as UserRead | null); | ||
return { | ||
get value(): UserRead | null { | ||
return user; | ||
}, | ||
login: async function (loginData: Body_auth_cookie_login_auth_login_post) { | ||
console.log(loginData); | ||
const { data, error } = await authCookieLogin({ body: loginData }); | ||
if (error) { | ||
return error?.detail as string; | ||
} else { | ||
await this.refresh(); | ||
if (!user || !user.is_superuser) { | ||
return 'Admin account required'; | ||
} | ||
return ''; | ||
} | ||
}, | ||
refresh: async function () { | ||
const { data, error } = await usersCurrentUser(); | ||
if (error || data === undefined) { | ||
console.log('Failed to get current User'); | ||
user = null; | ||
} else { | ||
user = data; | ||
} | ||
} | ||
}; | ||
} | ||
|
||
export const adminUser = AdminUser(); | ||
|
||
export async function refreshMilestoneGroups() { | ||
console.log('refreshMilestoneGroups...'); | ||
const { data, error } = await getMilestoneGroupsAdmin(); | ||
if (error || data == undefined) { | ||
console.log('Failed to get MilestoneGroups'); | ||
milestoneGroups.set([]); | ||
} else { | ||
milestoneGroups.set(data); | ||
} | ||
} | ||
|
||
export function milestoneGroupImageUrl(id: number) { | ||
return `${import.meta.env.VITE_MONDEY_API_URL}/static/mg${id}.jpg`; | ||
} | ||
|
||
export async function refreshUserQuestions() { | ||
console.log('refreshQuestions...'); | ||
const { data, error } = await getUserQuestionsAdmin(); | ||
if (error || data === undefined) { | ||
console.log('Failed to get UserQuestions'); | ||
userQuestions.set([]); | ||
} else { | ||
userQuestions.set(data); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
<svelte:options runes={true} /> | ||
|
||
<script lang="ts"> | ||
import { Button } from 'flowbite-svelte'; | ||
import Button from 'flowbite-svelte/Button.svelte'; | ||
import PlusOutline from 'flowbite-svelte-icons/PlusOutline.svelte'; | ||
import { _ } from 'svelte-i18n'; | ||
export let onClick: () => void; | ||
export let disabled: boolean = false; | ||
let { onclick, disabled = false }: { onclick: () => void; disabled?: boolean } = $props(); | ||
</script> | ||
|
||
<Button color="blue" {disabled} on:click={onClick} | ||
<Button color="blue" {onclick} {disabled} | ||
><PlusOutline class="me-2 h-5 w-5" /> {$_('admin.add')}</Button | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<svelte:options runes={true} /> | ||
|
||
<script lang="ts"> | ||
import Button from 'flowbite-svelte/Button.svelte'; | ||
import CloseOutline from 'flowbite-svelte-icons/CloseOutline.svelte'; | ||
import { _ } from 'svelte-i18n'; | ||
let { onclick = () => {} }: { onclick?: () => void } = $props(); | ||
</script> | ||
|
||
<Button color="alternative" {onclick} | ||
><CloseOutline class="me-2 h-5 w-5" /> {$_('admin.cancel')}</Button | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<svelte:options runes={true} /> | ||
|
||
<script lang="ts"> | ||
import { Button } from 'flowbite-svelte'; | ||
import Button from 'flowbite-svelte/Button.svelte'; | ||
import TrashBinOutline from 'flowbite-svelte-icons/TrashBinOutline.svelte'; | ||
import { _ } from 'svelte-i18n'; | ||
export let onClick: () => void; | ||
let { onclick }: { onclick: (event: Event) => void } = $props(); | ||
</script> | ||
|
||
<Button color="red" on:click={onClick} | ||
><TrashBinOutline class="me-2 h-5 w-5" /> {$_('admin.delete')}</Button | ||
> | ||
<Button color="red" {onclick}><TrashBinOutline class="me-2 h-5 w-5" /> {$_('admin.delete')}</Button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<svelte:options runes={true} /> | ||
|
||
<script lang="ts"> | ||
import { Button } from 'flowbite-svelte'; | ||
import Button from 'flowbite-svelte/Button.svelte'; | ||
import EditOutline from 'flowbite-svelte-icons/EditOutline.svelte'; | ||
import { _ } from 'svelte-i18n'; | ||
export let onClick: () => void; | ||
let { onclick }: { onclick: (event: Event) => void } = $props(); | ||
</script> | ||
|
||
<Button color="yellow" on:click={onClick} | ||
><EditOutline class="me-2 h-5 w-5" /> {$_('admin.edit')}</Button | ||
> | ||
<Button color="yellow" {onclick}><EditOutline class="me-2 h-5 w-5" /> {$_('admin.edit')}</Button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.