mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
Refactor web to use OpenAPI SDK (#326)
* Refactor main index page * Refactor admin page * Refactor Auth endpoint * Refactor directory to prep for monorepo * Fixed refactoring path * Resolved file path in vite * Refactor photo index page * Refactor thumbnail * Fixed test * Refactor Video Viewer component * Refactor download file * Refactor navigation bar * Refactor upload file check * Simplify Upload Asset signature * PR feedback
This commit is contained in:
@@ -1,39 +1,28 @@
|
||||
<script context="module" lang="ts">
|
||||
export const prerender = false;
|
||||
import type { Load } from '@sveltejs/kit';
|
||||
import { api } from '@api';
|
||||
|
||||
export const load: Load = async ({ session, fetch }) => {
|
||||
const res = await fetch(`${serverEndpoint}/user/count`);
|
||||
const { userCount } = await res.json();
|
||||
export const load: Load = async ({ session }) => {
|
||||
const { data } = await api.userApi.getUserCount();
|
||||
|
||||
if (!session.user) {
|
||||
// Check if admin exist to wherether navigating to login or registration
|
||||
if (userCount != 0) {
|
||||
return {
|
||||
status: 200,
|
||||
props: {
|
||||
isAdminUserExist: true,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: 200,
|
||||
props: {
|
||||
isAdminUserExist: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
} else {
|
||||
if (session.user) {
|
||||
return {
|
||||
status: 302,
|
||||
redirect: '/photos',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
props: {
|
||||
isAdminUserExist: data.userCount == 0 ? false : true,
|
||||
},
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { serverEndpoint } from '$lib/constants';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
export let isAdminUserExist: boolean;
|
||||
|
||||
Reference in New Issue
Block a user