mirror of
https://github.com/aleksilassila/reiverr.git
synced 2026-04-23 17:25:14 +02:00
feat: Creating the first user
This commit is contained in:
@@ -21,6 +21,11 @@ export class ReiverrApi implements Api<paths> {
|
||||
});
|
||||
}
|
||||
|
||||
isSetupDone = async (): Promise<boolean> =>
|
||||
this.getClient()
|
||||
?.GET('/user/isSetupDone')
|
||||
.then((res) => res.data || false) || false;
|
||||
|
||||
async getUser() {
|
||||
const res = await this.getClient()?.GET('/user', {});
|
||||
return res.data;
|
||||
|
||||
13
src/lib/apis/reiverr/reiverr.generated.d.ts
vendored
13
src/lib/apis/reiverr/reiverr.generated.d.ts
vendored
@@ -13,6 +13,9 @@ export interface paths {
|
||||
get: operations["UserController_findById"];
|
||||
put: operations["UserController_updateUser"];
|
||||
};
|
||||
"/user/isSetupDone": {
|
||||
get: operations["UserController_isSetupDone"];
|
||||
};
|
||||
"/auth": {
|
||||
post: operations["AuthController_signIn"];
|
||||
};
|
||||
@@ -175,6 +178,16 @@ export interface operations {
|
||||
};
|
||||
};
|
||||
};
|
||||
UserController_isSetupDone: {
|
||||
responses: {
|
||||
/** @description Setup done */
|
||||
200: {
|
||||
content: {
|
||||
"application/json": boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
AuthController_signIn: {
|
||||
requestBody: {
|
||||
content: {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
import TextField from '../components/TextField.svelte';
|
||||
import Button from '../components/Button.svelte';
|
||||
|
||||
let name: string = 'test';
|
||||
let password: string = 'test';
|
||||
let name: string = '';
|
||||
let password: string = '';
|
||||
let error: string | undefined = undefined;
|
||||
|
||||
let loading = false;
|
||||
@@ -36,26 +36,34 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container
|
||||
class="w-full h-full max-w-xs mx-auto flex flex-col items-center justify-center"
|
||||
focusOnMount
|
||||
>
|
||||
<h1 class="font-semibold tracking-wide text-xl w-full mb-4">Login to Reiverr</h1>
|
||||
<div class="w-full h-full flex items-center justify-center">
|
||||
<Container class="flex flex-col bg-primary-800 rounded-2xl p-10 shadow-xl max-w-lg" focusOnMount>
|
||||
<h1 class="header2 w-full mb-2">Login to Reiverr</h1>
|
||||
<div class="header1 mb-4">
|
||||
If this is your first time logging in, a new account will be created based on your
|
||||
credentials.
|
||||
</div>
|
||||
|
||||
<TextField
|
||||
value={$appState.serverBaseUrl}
|
||||
on:change={(e) => appState.setBaseUrl(e.detail)}
|
||||
class="mb-4 w-full"
|
||||
>
|
||||
Server
|
||||
</TextField>
|
||||
<TextField
|
||||
value={$appState.serverBaseUrl}
|
||||
on:change={(e) => appState.setBaseUrl(e.detail)}
|
||||
class="mb-4 w-full"
|
||||
>
|
||||
Server
|
||||
</TextField>
|
||||
|
||||
<TextField bind:value={name} class="mb-4 w-full">Name</TextField>
|
||||
<TextField bind:value={password} type="password" class="mb-8 w-full">Name</TextField>
|
||||
<TextField bind:value={name} class="mb-4 w-full">Name</TextField>
|
||||
<TextField bind:value={password} type="password" class="mb-8 w-full">Password</TextField>
|
||||
|
||||
<Button disabled={loading} on:clickOrSelect={handleLogin} class="mb-4 w-full">Submit</Button>
|
||||
<Button
|
||||
type="primary-dark"
|
||||
disabled={loading}
|
||||
on:clickOrSelect={handleLogin}
|
||||
class="mb-4 w-full">Submit</Button
|
||||
>
|
||||
|
||||
{#if error}
|
||||
<div class="text-red-300 text-center">{error}</div>
|
||||
{/if}
|
||||
</Container>
|
||||
{#if error}
|
||||
<div class="text-red-300 text-center">{error}</div>
|
||||
{/if}
|
||||
</Container>
|
||||
</div>
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
'text-primary-500': hasFocus
|
||||
})}
|
||||
>
|
||||
Interface
|
||||
General
|
||||
</span>
|
||||
</Container>
|
||||
<Container
|
||||
@@ -198,6 +198,14 @@
|
||||
localSettings.update((p) => ({ ...p, useCssTransitions: detail }))}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex items-center justify-between text-lg font-medium text-secondary-100 py-2">
|
||||
<label class="mr-2">Check for Updates</label>
|
||||
<Toggle
|
||||
checked={$localSettings.checkForUpdates}
|
||||
on:change={({ detail }) =>
|
||||
localSettings.update((p) => ({ ...p, checkForUpdates: detail }))}
|
||||
/>
|
||||
</div>
|
||||
</Tab>
|
||||
|
||||
<Tab {...tab} tab={Tabs.Integrations} class="">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import Button from '../components/Button.svelte';
|
||||
import { appState } from '../stores/app-state.store';
|
||||
import { tmdbApi } from '../apis/tmdb/tmdb-api';
|
||||
import { ArrowRight, ExternalLink } from 'radix-icons-svelte';
|
||||
import { ArrowLeft, ArrowRight, CheckCircled, ExternalLink } from 'radix-icons-svelte';
|
||||
import TextField from '../components/TextField.svelte';
|
||||
import { jellyfinApi, type JellyfinUser } from '../apis/jellyfin/jellyfin-api';
|
||||
import SelectField from '../components/SelectField.svelte';
|
||||
@@ -13,6 +13,7 @@
|
||||
import { radarrApi } from '../apis/radarr/radarr-api';
|
||||
import { get } from 'svelte/store';
|
||||
import { useTabs } from '../components/Tab/Tab';
|
||||
import classNames from 'classnames';
|
||||
|
||||
enum Tabs {
|
||||
Welcome,
|
||||
@@ -20,6 +21,7 @@
|
||||
Jellyfin,
|
||||
Sonarr,
|
||||
Radarr,
|
||||
Complete,
|
||||
|
||||
SelectUser = Jellyfin + 0.1,
|
||||
TmdbConnect = Tmdb + 0.1
|
||||
@@ -123,7 +125,7 @@
|
||||
}
|
||||
}));
|
||||
|
||||
tab.next();
|
||||
tab.set(Tabs.Jellyfin);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -409,8 +411,27 @@
|
||||
{#if radarrBaseUrl && radarrApiKey}
|
||||
<Button type="primary-dark" action={handleConnectRadarr}>Connect</Button>
|
||||
{:else}
|
||||
<Button type="primary-dark" on:clickOrSelect={finalizeSetup}>Skip</Button>
|
||||
<Button type="primary-dark" on:clickOrSelect={() => tab.next()}>Skip</Button>
|
||||
{/if}
|
||||
</Container>
|
||||
</Tab>
|
||||
|
||||
<Tab {...tab} tab={Tabs.Complete} class={classNames(tabContainer, 'w-full')}>
|
||||
<div class="flex items-center justify-center text-secondary-500 mb-4">
|
||||
<CheckCircled size={64} />
|
||||
</div>
|
||||
<h1 class="header2 text-center w-full">All Set!</h1>
|
||||
<div class="header1 mb-8 text-center">Reiverr is now ready to use.</div>
|
||||
|
||||
<Container direction="horizontal" class="inline-flex space-x-4 w-full">
|
||||
<Button type="primary-dark" on:clickOrSelect={() => tab.previous()} icon={ArrowLeft}
|
||||
>Back</Button
|
||||
>
|
||||
<div class="flex-1">
|
||||
<Button type="primary-dark" on:clickOrSelect={finalizeSetup} iconAbsolute={ArrowRight}
|
||||
>Done</Button
|
||||
>
|
||||
</div>
|
||||
</Container>
|
||||
</Tab>
|
||||
</Container>
|
||||
|
||||
@@ -95,7 +95,8 @@ export const appStateUser = derived(appState, ($state) => $state.user);
|
||||
|
||||
authenticationStore.subscribe((auth) => {
|
||||
if (auth.token) {
|
||||
getReiverrApiClient(auth.serverBaseUrl, auth.token)
|
||||
reiverrApi
|
||||
.getClient(auth.serverBaseUrl, auth.token)
|
||||
?.GET('/user', {})
|
||||
.then((res) => res.data)
|
||||
.then((user) => appState.setUser(user || null))
|
||||
|
||||
Reference in New Issue
Block a user