mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 20:26:27 -04:00
refactor(web): use new open api client (#7097)
* refactor(web): use new open api client * refactor: remove activity api * refactor: trash, oauth, and partner apis * refactor: job api * refactor: face, library, system config * refactor: user api * refactor: album api
This commit is contained in:
parent
9b4a770b9d
commit
8fd94211c0
@ -1,26 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
APIKeyApi,
|
|
||||||
ActivityApi,
|
|
||||||
AlbumApi,
|
|
||||||
AssetApi,
|
AssetApi,
|
||||||
AssetApiFp,
|
AssetApiFp,
|
||||||
AssetJobName,
|
AssetJobName,
|
||||||
AuditApi,
|
|
||||||
AuthenticationApi,
|
|
||||||
DownloadApi,
|
DownloadApi,
|
||||||
FaceApi,
|
|
||||||
JobApi,
|
|
||||||
JobName,
|
JobName,
|
||||||
LibraryApi,
|
|
||||||
OAuthApi,
|
|
||||||
PartnerApi,
|
|
||||||
PersonApi,
|
PersonApi,
|
||||||
SearchApi,
|
SearchApi,
|
||||||
ServerInfoApi,
|
|
||||||
SharedLinkApi,
|
SharedLinkApi,
|
||||||
SystemConfigApi,
|
|
||||||
TrashApi,
|
|
||||||
UserApi,
|
|
||||||
UserApiFp,
|
UserApiFp,
|
||||||
base,
|
base,
|
||||||
common,
|
common,
|
||||||
@ -29,25 +15,11 @@ import {
|
|||||||
import type { ApiParams as ApiParameters } from './types';
|
import type { ApiParams as ApiParameters } from './types';
|
||||||
|
|
||||||
class ImmichApi {
|
class ImmichApi {
|
||||||
public activityApi: ActivityApi;
|
|
||||||
public albumApi: AlbumApi;
|
|
||||||
public downloadApi: DownloadApi;
|
public downloadApi: DownloadApi;
|
||||||
public libraryApi: LibraryApi;
|
|
||||||
public assetApi: AssetApi;
|
public assetApi: AssetApi;
|
||||||
public auditApi: AuditApi;
|
|
||||||
public authenticationApi: AuthenticationApi;
|
|
||||||
public faceApi: FaceApi;
|
|
||||||
public jobApi: JobApi;
|
|
||||||
public keyApi: APIKeyApi;
|
|
||||||
public oauthApi: OAuthApi;
|
|
||||||
public partnerApi: PartnerApi;
|
|
||||||
public searchApi: SearchApi;
|
public searchApi: SearchApi;
|
||||||
public serverInfoApi: ServerInfoApi;
|
|
||||||
public sharedLinkApi: SharedLinkApi;
|
public sharedLinkApi: SharedLinkApi;
|
||||||
public personApi: PersonApi;
|
public personApi: PersonApi;
|
||||||
public systemConfigApi: SystemConfigApi;
|
|
||||||
public userApi: UserApi;
|
|
||||||
public trashApi: TrashApi;
|
|
||||||
|
|
||||||
private config: configuration.Configuration;
|
private config: configuration.Configuration;
|
||||||
private key?: string;
|
private key?: string;
|
||||||
@ -59,25 +31,11 @@ class ImmichApi {
|
|||||||
constructor(parameters: configuration.ConfigurationParameters) {
|
constructor(parameters: configuration.ConfigurationParameters) {
|
||||||
this.config = new configuration.Configuration(parameters);
|
this.config = new configuration.Configuration(parameters);
|
||||||
|
|
||||||
this.activityApi = new ActivityApi(this.config);
|
|
||||||
this.albumApi = new AlbumApi(this.config);
|
|
||||||
this.auditApi = new AuditApi(this.config);
|
|
||||||
this.downloadApi = new DownloadApi(this.config);
|
this.downloadApi = new DownloadApi(this.config);
|
||||||
this.libraryApi = new LibraryApi(this.config);
|
|
||||||
this.assetApi = new AssetApi(this.config);
|
this.assetApi = new AssetApi(this.config);
|
||||||
this.authenticationApi = new AuthenticationApi(this.config);
|
|
||||||
this.faceApi = new FaceApi(this.config);
|
|
||||||
this.jobApi = new JobApi(this.config);
|
|
||||||
this.keyApi = new APIKeyApi(this.config);
|
|
||||||
this.oauthApi = new OAuthApi(this.config);
|
|
||||||
this.partnerApi = new PartnerApi(this.config);
|
|
||||||
this.searchApi = new SearchApi(this.config);
|
this.searchApi = new SearchApi(this.config);
|
||||||
this.serverInfoApi = new ServerInfoApi(this.config);
|
|
||||||
this.sharedLinkApi = new SharedLinkApi(this.config);
|
this.sharedLinkApi = new SharedLinkApi(this.config);
|
||||||
this.personApi = new PersonApi(this.config);
|
this.personApi = new PersonApi(this.config);
|
||||||
this.systemConfigApi = new SystemConfigApi(this.config);
|
|
||||||
this.userApi = new UserApi(this.config);
|
|
||||||
this.trashApi = new TrashApi(this.config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private createUrl(path: string, parameters?: Record<string, unknown>) {
|
private createUrl(path: string, parameters?: Record<string, unknown>) {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import type { AxiosError, AxiosPromise } from 'axios';
|
import { finishOAuth, linkOAuthAccount, startOAuth, unlinkOAuthAccount } from '@immich/sdk';
|
||||||
|
import type { UserResponseDto } from '@immich/sdk/axios';
|
||||||
|
import type { AxiosError } from 'axios';
|
||||||
import {
|
import {
|
||||||
notificationController,
|
|
||||||
NotificationType,
|
NotificationType,
|
||||||
|
notificationController,
|
||||||
} from '../lib/components/shared-components/notification/notification';
|
} from '../lib/components/shared-components/notification/notification';
|
||||||
import { handleError } from '../lib/utils/handle-error';
|
import { handleError } from '../lib/utils/handle-error';
|
||||||
import { api } from './api';
|
|
||||||
import type { UserResponseDto } from '@immich/sdk/axios';
|
|
||||||
|
|
||||||
export type ApiError = AxiosError<{ message: string }>;
|
export type ApiError = AxiosError<{ message: string }>;
|
||||||
|
|
||||||
@ -43,8 +43,8 @@ export const oauth = {
|
|||||||
authorize: async (location: Location) => {
|
authorize: async (location: Location) => {
|
||||||
try {
|
try {
|
||||||
const redirectUri = location.href.split('?')[0];
|
const redirectUri = location.href.split('?')[0];
|
||||||
const { data } = await api.oauthApi.startOAuth({ oAuthConfigDto: { redirectUri } });
|
const { url } = await startOAuth({ oAuthConfigDto: { redirectUri } });
|
||||||
window.location.href = data.url;
|
window.location.href = url;
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to login with OAuth');
|
handleError(error, 'Unable to login with OAuth');
|
||||||
@ -52,12 +52,12 @@ export const oauth = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
login: (location: Location) => {
|
login: (location: Location) => {
|
||||||
return api.oauthApi.finishOAuth({ oAuthCallbackDto: { url: location.href } });
|
return finishOAuth({ oAuthCallbackDto: { url: location.href } });
|
||||||
},
|
},
|
||||||
link: (location: Location): AxiosPromise<UserResponseDto> => {
|
link: (location: Location): Promise<UserResponseDto> => {
|
||||||
return api.oauthApi.linkOAuthAccount({ oAuthCallbackDto: { url: location.href } });
|
return linkOAuthAccount({ oAuthCallbackDto: { url: location.href } });
|
||||||
},
|
},
|
||||||
unlink: () => {
|
unlink: () => {
|
||||||
return api.oauthApi.unlinkOAuthAccount();
|
return unlinkOAuthAccount();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type UserResponseDto } from '@api';
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
||||||
import { handleError } from '../../utils/handle-error';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { deleteUser, type UserResponseDto } from '@immich/sdk';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
|
||||||
export let user: UserResponseDto;
|
export let user: UserResponseDto;
|
||||||
|
|
||||||
@ -11,10 +11,10 @@
|
|||||||
fail: void;
|
fail: void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const deleteUser = async () => {
|
const handleDeleteUser = async () => {
|
||||||
try {
|
try {
|
||||||
const deletedUser = await api.userApi.deleteUser({ id: user.id });
|
const { deletedAt } = await deleteUser({ id: user.id });
|
||||||
if (deletedUser.data.deletedAt == undefined) {
|
if (deletedAt == undefined) {
|
||||||
dispatch('fail');
|
dispatch('fail');
|
||||||
} else {
|
} else {
|
||||||
dispatch('success');
|
dispatch('success');
|
||||||
@ -26,7 +26,7 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ConfirmDialogue title="Delete User" confirmText="Delete" on:confirm={deleteUser} on:cancel>
|
<ConfirmDialogue title="Delete User" confirmText="Delete" on:confirm={handleDeleteUser} on:cancel>
|
||||||
<svelte:fragment slot="prompt">
|
<svelte:fragment slot="prompt">
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<p>
|
<p>
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import ConfirmDialogue from '../../shared-components/confirm-dialogue.svelte';
|
import ConfirmDialogue from '../../shared-components/confirm-dialogue.svelte';
|
||||||
import JobTile from './job-tile.svelte';
|
import JobTile from './job-tile.svelte';
|
||||||
import StorageMigrationDescription from './storage-migration-description.svelte';
|
import StorageMigrationDescription from './storage-migration-description.svelte';
|
||||||
|
import { sendJobCommand } from '@immich/sdk';
|
||||||
|
|
||||||
export let jobs: AllJobStatusResponseDto;
|
export let jobs: AllJobStatusResponseDto;
|
||||||
|
|
||||||
@ -127,8 +128,7 @@
|
|||||||
const title = jobDetails[jobId]?.title;
|
const title = jobDetails[jobId]?.title;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await api.jobApi.sendJobCommand({ id: jobId, jobCommandDto: jobCommand });
|
jobs[jobId] = await sendJobCommand({ id: jobId, jobCommandDto: jobCommand });
|
||||||
jobs[jobId] = data;
|
|
||||||
|
|
||||||
switch (jobCommand.command) {
|
switch (jobCommand.command) {
|
||||||
case JobCommand.Empty: {
|
case JobCommand.Empty: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type UserResponseDto } from '@api';
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
||||||
|
import { restoreUser, type UserResponseDto } from '@immich/sdk';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
|
||||||
export let user: UserResponseDto;
|
export let user: UserResponseDto;
|
||||||
|
|
||||||
@ -10,9 +10,9 @@
|
|||||||
fail: void;
|
fail: void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const restoreUser = async () => {
|
const handleRestoreUser = async () => {
|
||||||
const restoredUser = await api.userApi.restoreUser({ id: user.id });
|
const { deletedAt } = await restoreUser({ id: user.id });
|
||||||
if (restoredUser.data.deletedAt == undefined) {
|
if (deletedAt == undefined) {
|
||||||
dispatch('success');
|
dispatch('success');
|
||||||
} else {
|
} else {
|
||||||
dispatch('fail');
|
dispatch('fail');
|
||||||
@ -20,7 +20,13 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ConfirmDialogue title="Restore User" confirmText="Continue" confirmColor="green" on:confirm={restoreUser} on:cancel>
|
<ConfirmDialogue
|
||||||
|
title="Restore User"
|
||||||
|
confirmText="Continue"
|
||||||
|
confirmColor="green"
|
||||||
|
on:confirm={handleRestoreUser}
|
||||||
|
on:cancel
|
||||||
|
>
|
||||||
<svelte:fragment slot="prompt">
|
<svelte:fragment slot="prompt">
|
||||||
<p><b>{user.name}</b>'s account will be restored.</p>
|
<p><b>{user.name}</b>'s account will be restored.</p>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<svelte:options accessors />
|
<svelte:options accessors />
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type SystemConfigDto, api } from '@api';
|
|
||||||
import {
|
import {
|
||||||
notificationController,
|
|
||||||
NotificationType,
|
NotificationType,
|
||||||
|
notificationController,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
import type { SettingsEventType } from './admin-settings';
|
import { getConfig, getConfigDefaults, updateConfig, type SystemConfigDto } from '@immich/sdk';
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
|
import type { SettingsEventType } from './admin-settings';
|
||||||
|
|
||||||
export let config: SystemConfigDto;
|
export let config: SystemConfigDto;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
const handleSave = async (update: Partial<SystemConfigDto>) => {
|
const handleSave = async (update: Partial<SystemConfigDto>) => {
|
||||||
try {
|
try {
|
||||||
const { data: newConfig } = await api.systemConfigApi.updateConfig({
|
const newConfig = await updateConfig({
|
||||||
systemConfigDto: {
|
systemConfigDto: {
|
||||||
...savedConfig,
|
...savedConfig,
|
||||||
...update,
|
...update,
|
||||||
@ -42,7 +42,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const reset = async (configKeys: Array<keyof SystemConfigDto>) => {
|
const reset = async (configKeys: Array<keyof SystemConfigDto>) => {
|
||||||
const { data: resetConfig } = await api.systemConfigApi.getConfig();
|
const resetConfig = await getConfig();
|
||||||
|
|
||||||
for (const key of configKeys) {
|
for (const key of configKeys) {
|
||||||
config = { ...config, [key]: resetConfig[key] };
|
config = { ...config, [key]: resetConfig[key] };
|
||||||
@ -66,10 +66,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
[savedConfig, defaultConfig] = await Promise.all([
|
[savedConfig, defaultConfig] = await Promise.all([getConfig(), getConfigDefaults()]);
|
||||||
api.systemConfigApi.getConfig().then((res) => res.data),
|
|
||||||
api.systemConfigApi.getConfigDefaults().then((res) => res.data),
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
||||||
|
import { AppRoute } from '$lib/constants';
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
import { api, type SystemConfigDto, type SystemConfigTemplateStorageOptionDto } from '@api';
|
import {
|
||||||
|
getStorageTemplateOptions,
|
||||||
|
type SystemConfigDto,
|
||||||
|
type SystemConfigTemplateStorageOptionDto,
|
||||||
|
} from '@immich/sdk';
|
||||||
import handlebar from 'handlebars';
|
import handlebar from 'handlebars';
|
||||||
import { isEqual } from 'lodash-es';
|
import { isEqual } from 'lodash-es';
|
||||||
import * as luxon from 'luxon';
|
import * as luxon from 'luxon';
|
||||||
@ -13,7 +18,6 @@
|
|||||||
import SettingSwitch from '../setting-switch.svelte';
|
import SettingSwitch from '../setting-switch.svelte';
|
||||||
import SupportedDatetimePanel from './supported-datetime-panel.svelte';
|
import SupportedDatetimePanel from './supported-datetime-panel.svelte';
|
||||||
import SupportedVariablesPanel from './supported-variables-panel.svelte';
|
import SupportedVariablesPanel from './supported-variables-panel.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
|
|
||||||
export let savedConfig: SystemConfigDto;
|
export let savedConfig: SystemConfigDto;
|
||||||
export let defaultConfig: SystemConfigDto;
|
export let defaultConfig: SystemConfigDto;
|
||||||
@ -26,14 +30,11 @@
|
|||||||
let selectedPreset = '';
|
let selectedPreset = '';
|
||||||
|
|
||||||
const getTemplateOptions = async () => {
|
const getTemplateOptions = async () => {
|
||||||
templateOptions = await api.systemConfigApi.getStorageTemplateOptions().then((res) => res.data);
|
templateOptions = await getStorageTemplateOptions();
|
||||||
selectedPreset = savedConfig.storageTemplate.template;
|
selectedPreset = savedConfig.storageTemplate.template;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSupportDateTimeFormat = async () => {
|
const getSupportDateTimeFormat = () => getStorageTemplateOptions();
|
||||||
const { data } = await api.systemConfigApi.getStorageTemplateOptions();
|
|
||||||
return data;
|
|
||||||
};
|
|
||||||
|
|
||||||
$: parsedTemplate = () => {
|
$: parsedTemplate = () => {
|
||||||
try {
|
try {
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import noThumbnailUrl from '$lib/assets/no-thumbnail.png';
|
import noThumbnailUrl from '$lib/assets/no-thumbnail.png';
|
||||||
import { locale } from '$lib/stores/preferences.store';
|
|
||||||
import { type AlbumResponseDto, api, ThumbnailFormat, type UserResponseDto } from '@api';
|
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
|
||||||
import IconButton from '../elements/buttons/icon-button.svelte';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import type { OnClick, OnShowContextMenu } from './album-card';
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
import { getContextMenuPosition } from '../../utils/context-menu';
|
|
||||||
import { mdiDotsVertical } from '@mdi/js';
|
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
|
import { ThumbnailFormat, api, type AlbumResponseDto } from '@api';
|
||||||
|
import { getUserById } from '@immich/sdk';
|
||||||
|
import { mdiDotsVertical } from '@mdi/js';
|
||||||
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
|
import { getContextMenuPosition } from '../../utils/context-menu';
|
||||||
|
import IconButton from '../elements/buttons/icon-button.svelte';
|
||||||
|
import type { OnClick, OnShowContextMenu } from './album-card';
|
||||||
|
|
||||||
export let album: AlbumResponseDto;
|
export let album: AlbumResponseDto;
|
||||||
export let isSharingView = false;
|
export let isSharingView = false;
|
||||||
@ -51,11 +52,7 @@
|
|||||||
imageData = (await loadHighQualityThumbnail(album.albumThumbnailAssetId)) || noThumbnailUrl;
|
imageData = (await loadHighQualityThumbnail(album.albumThumbnailAssetId)) || noThumbnailUrl;
|
||||||
});
|
});
|
||||||
|
|
||||||
const getAlbumOwnerInfo = async (): Promise<UserResponseDto> => {
|
const getAlbumOwnerInfo = () => getUserById({ id: album.ownerId });
|
||||||
const { data } = await api.userApi.getUserById({ id: album.ownerId });
|
|
||||||
|
|
||||||
return data;
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { type AlbumResponseDto, type UserResponseDto } from '@api';
|
||||||
|
import { getMyUserInfo, removeUserFromAlbum } from '@immich/sdk';
|
||||||
|
import { mdiDotsVertical } from '@mdi/js';
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
import { type AlbumResponseDto, api, type UserResponseDto } from '@api';
|
import { getContextMenuPosition } from '../../utils/context-menu';
|
||||||
import BaseModal from '../shared-components/base-modal.svelte';
|
import { handleError } from '../../utils/handle-error';
|
||||||
import UserAvatar from '../shared-components/user-avatar.svelte';
|
|
||||||
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
||||||
|
import BaseModal from '../shared-components/base-modal.svelte';
|
||||||
|
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
||||||
import ContextMenu from '../shared-components/context-menu/context-menu.svelte';
|
import ContextMenu from '../shared-components/context-menu/context-menu.svelte';
|
||||||
import MenuOption from '../shared-components/context-menu/menu-option.svelte';
|
import MenuOption from '../shared-components/context-menu/menu-option.svelte';
|
||||||
import { notificationController, NotificationType } from '../shared-components/notification/notification';
|
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
||||||
import { handleError } from '../../utils/handle-error';
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
||||||
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
|
||||||
import { getContextMenuPosition } from '../../utils/context-menu';
|
|
||||||
import { mdiDotsVertical } from '@mdi/js';
|
|
||||||
|
|
||||||
export let album: AlbumResponseDto;
|
export let album: AlbumResponseDto;
|
||||||
|
|
||||||
@ -28,8 +29,7 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.userApi.getMyUserInfo();
|
currentUser = await getMyUserInfo();
|
||||||
currentUser = data;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to refresh user');
|
handleError(error, 'Unable to refresh user');
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@
|
|||||||
const userId = selectedRemoveUser.id === currentUser?.id ? 'me' : selectedRemoveUser.id;
|
const userId = selectedRemoveUser.id === currentUser?.id ? 'me' : selectedRemoveUser.id;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.albumApi.removeUserFromAlbum({ id: album.id, userId });
|
await removeUserFromAlbum({ id: album.id, userId });
|
||||||
dispatch('remove', userId);
|
dispatch('remove', userId);
|
||||||
const message = userId === 'me' ? `Left ${album.albumName}` : `Removed ${selectedRemoveUser.name}`;
|
const message = userId === 'me' ? `Left ${album.albumName}` : `Removed ${selectedRemoveUser.name}`;
|
||||||
notificationController.show({ type: NotificationType.Info, message });
|
notificationController.show({ type: NotificationType.Info, message });
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
|
||||||
import { type AlbumResponseDto, api, type SharedLinkResponseDto, type UserResponseDto } from '@api';
|
|
||||||
import BaseModal from '../shared-components/base-modal.svelte';
|
|
||||||
import UserAvatar from '../shared-components/user-avatar.svelte';
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import ImmichLogo from '../shared-components/immich-logo.svelte';
|
|
||||||
import Button from '../elements/buttons/button.svelte';
|
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
import { mdiCheck, mdiLink, mdiShareCircle } from '@mdi/js';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
|
import { AppRoute } from '$lib/constants';
|
||||||
|
import { api, type AlbumResponseDto, type SharedLinkResponseDto, type UserResponseDto } from '@api';
|
||||||
|
import { getAllUsers } from '@immich/sdk';
|
||||||
|
import { mdiCheck, mdiLink, mdiShareCircle } from '@mdi/js';
|
||||||
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import BaseModal from '../shared-components/base-modal.svelte';
|
||||||
|
import ImmichLogo from '../shared-components/immich-logo.svelte';
|
||||||
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
||||||
|
|
||||||
export let album: AlbumResponseDto;
|
export let album: AlbumResponseDto;
|
||||||
let users: UserResponseDto[] = [];
|
let users: UserResponseDto[] = [];
|
||||||
@ -22,7 +23,7 @@
|
|||||||
let sharedLinks: SharedLinkResponseDto[] = [];
|
let sharedLinks: SharedLinkResponseDto[] = [];
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await getSharedLinks();
|
await getSharedLinks();
|
||||||
const { data } = await api.userApi.getAllUsers({ isAll: false });
|
const data = await getAllUsers({ isAll: false });
|
||||||
|
|
||||||
// remove invalid users
|
// remove invalid users
|
||||||
users = data.filter((user) => !(user.deletedAt || user.id === album.ownerId));
|
users = data.filter((user) => !(user.deletedAt || user.id === album.ownerId));
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
|
||||||
import UserAvatar from '../shared-components/user-avatar.svelte';
|
|
||||||
import { mdiClose, mdiHeart, mdiSend, mdiDotsVertical } from '@mdi/js';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
|
import { timeBeforeShowLoadingSpinner } from '$lib/constants';
|
||||||
|
import { getAssetType } from '$lib/utils/asset-utils';
|
||||||
|
import { autoGrowHeight } from '$lib/utils/autogrow';
|
||||||
|
import { clickOutside } from '$lib/utils/click-outside';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { isTenMinutesApart } from '$lib/utils/timesince';
|
||||||
import {
|
import {
|
||||||
type ActivityResponseDto,
|
|
||||||
api,
|
|
||||||
AssetTypeEnum,
|
AssetTypeEnum,
|
||||||
ReactionType,
|
ReactionType,
|
||||||
ThumbnailFormat,
|
ThumbnailFormat,
|
||||||
|
api,
|
||||||
|
type ActivityResponseDto,
|
||||||
type UserResponseDto,
|
type UserResponseDto,
|
||||||
} from '@api';
|
} from '@api';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { createActivity, deleteActivity, getActivities } from '@immich/sdk';
|
||||||
import { isTenMinutesApart } from '$lib/utils/timesince';
|
import { mdiClose, mdiDotsVertical, mdiHeart, mdiSend } from '@mdi/js';
|
||||||
import { clickOutside } from '$lib/utils/click-outside';
|
import * as luxon from 'luxon';
|
||||||
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
||||||
import LoadingSpinner from '../shared-components/loading-spinner.svelte';
|
import LoadingSpinner from '../shared-components/loading-spinner.svelte';
|
||||||
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
||||||
import { getAssetType } from '$lib/utils/asset-utils';
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
||||||
import * as luxon from 'luxon';
|
|
||||||
import { timeBeforeShowLoadingSpinner } from '$lib/constants';
|
|
||||||
import { autoGrowHeight } from '$lib/utils/autogrow';
|
|
||||||
|
|
||||||
const units: Intl.RelativeTimeFormatUnit[] = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'];
|
const units: Intl.RelativeTimeFormatUnit[] = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'];
|
||||||
|
|
||||||
@ -85,8 +86,7 @@
|
|||||||
|
|
||||||
const getReactions = async () => {
|
const getReactions = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.activityApi.getActivities({ assetId, albumId });
|
reactions = await getActivities({ assetId, albumId });
|
||||||
reactions = data;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Error when fetching reactions');
|
handleError(error, 'Error when fetching reactions');
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@
|
|||||||
|
|
||||||
const handleDeleteReaction = async (reaction: ActivityResponseDto, index: number) => {
|
const handleDeleteReaction = async (reaction: ActivityResponseDto, index: number) => {
|
||||||
try {
|
try {
|
||||||
await api.activityApi.deleteActivity({ id: reaction.id });
|
await deleteActivity({ id: reaction.id });
|
||||||
reactions.splice(index, 1);
|
reactions.splice(index, 1);
|
||||||
showDeleteReaction.splice(index, 1);
|
showDeleteReaction.splice(index, 1);
|
||||||
reactions = reactions;
|
reactions = reactions;
|
||||||
@ -135,7 +135,7 @@
|
|||||||
}
|
}
|
||||||
const timeout = setTimeout(() => (isSendingMessage = true), timeBeforeShowLoadingSpinner);
|
const timeout = setTimeout(() => (isSendingMessage = true), timeBeforeShowLoadingSpinner);
|
||||||
try {
|
try {
|
||||||
const { data } = await api.activityApi.createActivity({
|
const data = await createActivity({
|
||||||
activityCreateDto: { albumId, assetId, type: ReactionType.Comment, comment: message },
|
activityCreateDto: { albumId, assetId, type: ReactionType.Comment, comment: message },
|
||||||
});
|
});
|
||||||
reactions.push(data);
|
reactions.push(data);
|
||||||
|
@ -1,47 +1,55 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { browser } from '$app/environment';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
|
import { AppRoute, AssetAction, ProjectionType } from '$lib/constants';
|
||||||
|
import { updateNumberOfComments } from '$lib/stores/activity.store';
|
||||||
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
|
import type { AssetStore } from '$lib/stores/assets.store';
|
||||||
|
import { isShowDetail, showDeleteModal } from '$lib/stores/preferences.store';
|
||||||
|
import { featureFlags } from '$lib/stores/server-config.store';
|
||||||
|
import { SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
||||||
|
import { stackAssetsStore } from '$lib/stores/stacked-asset.store';
|
||||||
|
import { user } from '$lib/stores/user.store';
|
||||||
|
import { addAssetsToAlbum, downloadFile } from '$lib/utils/asset-utils';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { shouldIgnoreShortcut } from '$lib/utils/shortcut';
|
||||||
|
import { SlideshowHistory } from '$lib/utils/slideshow-history';
|
||||||
import {
|
import {
|
||||||
type ActivityResponseDto,
|
|
||||||
type AlbumResponseDto,
|
|
||||||
api,
|
|
||||||
AssetJobName,
|
AssetJobName,
|
||||||
type AssetResponseDto,
|
|
||||||
AssetTypeEnum,
|
AssetTypeEnum,
|
||||||
ReactionType,
|
ReactionType,
|
||||||
|
api,
|
||||||
|
type ActivityResponseDto,
|
||||||
|
type AlbumResponseDto,
|
||||||
|
type AssetResponseDto,
|
||||||
type SharedLinkResponseDto,
|
type SharedLinkResponseDto,
|
||||||
} from '@api';
|
} from '@api';
|
||||||
|
import {
|
||||||
|
createActivity,
|
||||||
|
createAlbum,
|
||||||
|
deleteActivity,
|
||||||
|
getActivities,
|
||||||
|
getActivityStatistics,
|
||||||
|
getAllAlbums,
|
||||||
|
} from '@immich/sdk';
|
||||||
|
import { mdiChevronLeft, mdiChevronRight, mdiImageBrokenVariant } from '@mdi/js';
|
||||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
||||||
import { fly } from 'svelte/transition';
|
import { fly } from 'svelte/transition';
|
||||||
|
import Thumbnail from '../assets/thumbnail/thumbnail.svelte';
|
||||||
|
import DeleteAssetDialog from '../photos-page/delete-asset-dialog.svelte';
|
||||||
import AlbumSelectionModal from '../shared-components/album-selection-modal.svelte';
|
import AlbumSelectionModal from '../shared-components/album-selection-modal.svelte';
|
||||||
import { notificationController, NotificationType } from '../shared-components/notification/notification';
|
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
||||||
|
import ProfileImageCropper from '../shared-components/profile-image-cropper.svelte';
|
||||||
|
import ActivityStatus from './activity-status.svelte';
|
||||||
|
import ActivityViewer from './activity-viewer.svelte';
|
||||||
import AssetViewerNavBar from './asset-viewer-nav-bar.svelte';
|
import AssetViewerNavBar from './asset-viewer-nav-bar.svelte';
|
||||||
import DetailPanel from './detail-panel.svelte';
|
import DetailPanel from './detail-panel.svelte';
|
||||||
import PhotoViewer from './photo-viewer.svelte';
|
|
||||||
import VideoViewer from './video-viewer.svelte';
|
|
||||||
import PanoramaViewer from './panorama-viewer.svelte';
|
|
||||||
import { AppRoute, AssetAction, ProjectionType } from '$lib/constants';
|
|
||||||
import ProfileImageCropper from '../shared-components/profile-image-cropper.svelte';
|
|
||||||
import { isShowDetail, showDeleteModal } from '$lib/stores/preferences.store';
|
|
||||||
import { addAssetsToAlbum, downloadFile } from '$lib/utils/asset-utils';
|
|
||||||
import NavigationArea from './navigation-area.svelte';
|
import NavigationArea from './navigation-area.svelte';
|
||||||
import { browser } from '$app/environment';
|
import PanoramaViewer from './panorama-viewer.svelte';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import PhotoViewer from './photo-viewer.svelte';
|
||||||
import type { AssetStore } from '$lib/stores/assets.store';
|
|
||||||
import { shouldIgnoreShortcut } from '$lib/utils/shortcut';
|
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
|
||||||
import { SlideshowHistory } from '$lib/utils/slideshow-history';
|
|
||||||
import { featureFlags } from '$lib/stores/server-config.store';
|
|
||||||
import { mdiChevronLeft, mdiChevronRight, mdiImageBrokenVariant } from '@mdi/js';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
|
||||||
import Thumbnail from '../assets/thumbnail/thumbnail.svelte';
|
|
||||||
import { stackAssetsStore } from '$lib/stores/stacked-asset.store';
|
|
||||||
import ActivityViewer from './activity-viewer.svelte';
|
|
||||||
import ActivityStatus from './activity-status.svelte';
|
|
||||||
import { updateNumberOfComments } from '$lib/stores/activity.store';
|
|
||||||
import { SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
|
||||||
import SlideshowBar from './slideshow-bar.svelte';
|
import SlideshowBar from './slideshow-bar.svelte';
|
||||||
import { user } from '$lib/stores/user.store';
|
import VideoViewer from './video-viewer.svelte';
|
||||||
import DeleteAssetDialog from '../photos-page/delete-asset-dialog.svelte';
|
|
||||||
|
|
||||||
export let assetStore: AssetStore | null = null;
|
export let assetStore: AssetStore | null = null;
|
||||||
export let asset: AssetResponseDto;
|
export let asset: AssetResponseDto;
|
||||||
@ -119,11 +127,11 @@
|
|||||||
try {
|
try {
|
||||||
if (isLiked) {
|
if (isLiked) {
|
||||||
const activityId = isLiked.id;
|
const activityId = isLiked.id;
|
||||||
await api.activityApi.deleteActivity({ id: activityId });
|
await deleteActivity({ id: activityId });
|
||||||
reactions = reactions.filter((reaction) => reaction.id !== activityId);
|
reactions = reactions.filter((reaction) => reaction.id !== activityId);
|
||||||
isLiked = null;
|
isLiked = null;
|
||||||
} else {
|
} else {
|
||||||
const { data } = await api.activityApi.createActivity({
|
const data = await createActivity({
|
||||||
activityCreateDto: { albumId: album.id, assetId: asset.id, type: ReactionType.Like },
|
activityCreateDto: { albumId: album.id, assetId: asset.id, type: ReactionType.Like },
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -139,11 +147,11 @@
|
|||||||
const getFavorite = async () => {
|
const getFavorite = async () => {
|
||||||
if (album && $user) {
|
if (album && $user) {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.activityApi.getActivities({
|
const data = await getActivities({
|
||||||
userId: $user.id,
|
userId: $user.id,
|
||||||
assetId: asset.id,
|
assetId: asset.id,
|
||||||
albumId: album.id,
|
albumId: album.id,
|
||||||
type: ReactionType.Like,
|
$type: ReactionType.Like,
|
||||||
});
|
});
|
||||||
isLiked = data.length > 0 ? data[0] : null;
|
isLiked = data.length > 0 ? data[0] : null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -155,8 +163,8 @@
|
|||||||
const getNumberOfComments = async () => {
|
const getNumberOfComments = async () => {
|
||||||
if (album) {
|
if (album) {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.activityApi.getActivityStatistics({ assetId: asset.id, albumId: album.id });
|
const { comments } = await getActivityStatistics({ assetId: asset.id, albumId: album.id });
|
||||||
numberOfComments = data.comments;
|
numberOfComments = comments;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, "Can't get number of comments");
|
handleError(error, "Can't get number of comments");
|
||||||
}
|
}
|
||||||
@ -192,7 +200,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!sharedLink) {
|
if (!sharedLink) {
|
||||||
await getAllAlbums();
|
await handleGetAllAlbums();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import hack :( see https://github.com/vadimkorr/svelte-carousel/issues/27#issuecomment-851022295
|
// Import hack :( see https://github.com/vadimkorr/svelte-carousel/issues/27#issuecomment-851022295
|
||||||
@ -224,16 +232,15 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$: asset.id && !sharedLink && getAllAlbums(); // Update the album information when the asset ID changes
|
$: asset.id && !sharedLink && handleGetAllAlbums(); // Update the album information when the asset ID changes
|
||||||
|
|
||||||
const getAllAlbums = async () => {
|
const handleGetAllAlbums = async () => {
|
||||||
if (api.isSharedLink) {
|
if (api.isSharedLink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await api.albumApi.getAllAlbums({ assetId: asset.id });
|
appearsInAlbums = await getAllAlbums({ assetId: asset.id });
|
||||||
appearsInAlbums = data;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error getting album that asset belong to', error);
|
console.error('Error getting album that asset belong to', error);
|
||||||
}
|
}
|
||||||
@ -435,20 +442,18 @@
|
|||||||
addToSharedAlbum = shared;
|
addToSharedAlbum = shared;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddToNewAlbum = (albumName: string) => {
|
const handleAddToNewAlbum = async (albumName: string) => {
|
||||||
isShowAlbumPicker = false;
|
isShowAlbumPicker = false;
|
||||||
|
|
||||||
api.albumApi.createAlbum({ createAlbumDto: { albumName, assetIds: [asset.id] } }).then((response) => {
|
const album = await createAlbum({ createAlbumDto: { albumName, assetIds: [asset.id] } });
|
||||||
const album = response.data;
|
await goto(`${AppRoute.ALBUMS}/${album.id}`);
|
||||||
goto(`${AppRoute.ALBUMS}/${album.id}`);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddToAlbum = async (album: AlbumResponseDto) => {
|
const handleAddToAlbum = async (album: AlbumResponseDto) => {
|
||||||
isShowAlbumPicker = false;
|
isShowAlbumPicker = false;
|
||||||
|
|
||||||
await addAssetsToAlbum(album.id, [asset.id]);
|
await addAssetsToAlbum(album.id, [asset.id]);
|
||||||
await getAllAlbums();
|
await handleGetAllAlbums();
|
||||||
};
|
};
|
||||||
|
|
||||||
const disableKeyDownEvent = () => {
|
const disableKeyDownEvent = () => {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
import AssignFaceSidePanel from './assign-face-side-panel.svelte';
|
import AssignFaceSidePanel from './assign-face-side-panel.svelte';
|
||||||
import { getPersonNameWithHiddenValue } from '$lib/utils/person';
|
import { getPersonNameWithHiddenValue } from '$lib/utils/person';
|
||||||
import { timeBeforeShowLoadingSpinner } from '$lib/constants';
|
import { timeBeforeShowLoadingSpinner } from '$lib/constants';
|
||||||
|
import { getFaces, reassignFacesById } from '@immich/sdk';
|
||||||
|
|
||||||
export let assetId: string;
|
export let assetId: string;
|
||||||
export let assetType: AssetTypeEnum;
|
export let assetType: AssetTypeEnum;
|
||||||
@ -70,8 +71,7 @@
|
|||||||
try {
|
try {
|
||||||
const { data } = await api.personApi.getAllPeople({ withHidden: true });
|
const { data } = await api.personApi.getAllPeople({ withHidden: true });
|
||||||
allPeople = data.people;
|
allPeople = data.people;
|
||||||
const result = await api.faceApi.getFaces({ id: assetId });
|
peopleWithFaces = await getFaces({ id: assetId });
|
||||||
peopleWithFaces = result.data;
|
|
||||||
selectedPersonToCreate = Array.from({ length: peopleWithFaces.length });
|
selectedPersonToCreate = Array.from({ length: peopleWithFaces.length });
|
||||||
selectedPersonToReassign = Array.from({ length: peopleWithFaces.length });
|
selectedPersonToReassign = Array.from({ length: peopleWithFaces.length });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -110,14 +110,14 @@
|
|||||||
const personId = selectedPersonToReassign[index]?.id;
|
const personId = selectedPersonToReassign[index]?.id;
|
||||||
|
|
||||||
if (personId) {
|
if (personId) {
|
||||||
await api.faceApi.reassignFacesById({
|
await reassignFacesById({
|
||||||
id: personId,
|
id: personId,
|
||||||
faceDto: { id: peopleWithFace.id },
|
faceDto: { id: peopleWithFace.id },
|
||||||
});
|
});
|
||||||
} else if (selectedPersonToCreate[index]) {
|
} else if (selectedPersonToCreate[index]) {
|
||||||
const { data } = await api.personApi.createPerson();
|
const { data } = await api.personApi.createPerson();
|
||||||
numberOfPersonToCreate.push(data.id);
|
numberOfPersonToCreate.push(data.id);
|
||||||
await api.faceApi.reassignFacesById({
|
await reassignFacesById({
|
||||||
id: data.id,
|
id: data.id,
|
||||||
faceDto: { id: peopleWithFace.id },
|
faceDto: { id: peopleWithFace.id },
|
||||||
});
|
});
|
||||||
|
@ -1,27 +1,28 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import { api } from '@api';
|
import { signUpAdmin } from '@immich/sdk';
|
||||||
|
import { handleError } from '../../utils/handle-error';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
|
||||||
let error: string;
|
let errorMessage: string;
|
||||||
let password = '';
|
let password = '';
|
||||||
let confirmPassowrd = '';
|
let confirmPassowrd = '';
|
||||||
let canRegister = false;
|
let canRegister = false;
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (password !== confirmPassowrd && confirmPassowrd.length > 0) {
|
if (password !== confirmPassowrd && confirmPassowrd.length > 0) {
|
||||||
error = 'Password does not match';
|
errorMessage = 'Password does not match';
|
||||||
canRegister = false;
|
canRegister = false;
|
||||||
} else {
|
} else {
|
||||||
error = '';
|
errorMessage = '';
|
||||||
canRegister = true;
|
canRegister = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function registerAdmin(event: SubmitEvent & { currentTarget: HTMLFormElement }) {
|
async function registerAdmin(event: SubmitEvent & { currentTarget: HTMLFormElement }) {
|
||||||
if (canRegister) {
|
if (canRegister) {
|
||||||
error = '';
|
errorMessage = '';
|
||||||
|
|
||||||
const form = new FormData(event.currentTarget);
|
const form = new FormData(event.currentTarget);
|
||||||
|
|
||||||
@ -29,20 +30,19 @@
|
|||||||
const password = form.get('password');
|
const password = form.get('password');
|
||||||
const name = form.get('name');
|
const name = form.get('name');
|
||||||
|
|
||||||
const { status } = await api.authenticationApi.signUpAdmin({
|
try {
|
||||||
signUpDto: {
|
await signUpAdmin({
|
||||||
email: String(email),
|
signUpDto: {
|
||||||
password: String(password),
|
email: String(email),
|
||||||
name: String(name),
|
password: String(password),
|
||||||
},
|
name: String(name),
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
if (status === 201) {
|
|
||||||
await goto(AppRoute.AUTH_LOGIN);
|
await goto(AppRoute.AUTH_LOGIN);
|
||||||
return;
|
} catch (error) {
|
||||||
} else {
|
handleError(error, 'Unable to create admin account');
|
||||||
error = 'Error create admin account';
|
errorMessage = 'Error create admin account';
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,8 +85,8 @@
|
|||||||
<input class="immich-form-input" id="name" name="name" type="text" autocomplete="name" required />
|
<input class="immich-form-input" id="name" name="name" type="text" autocomplete="name" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if error}
|
{#if errorMessage}
|
||||||
<p class="text-red-400">{error}</p>
|
<p class="text-red-400">{errorMessage}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="my-5 flex w-full">
|
<div class="my-5 flex w-full">
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type UserResponseDto } from '@api';
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import { updateUser, type UserResponseDto } from '@immich/sdk';
|
||||||
|
|
||||||
export let user: UserResponseDto;
|
export let user: UserResponseDto;
|
||||||
let error: string;
|
let errorMessage: string;
|
||||||
let success: string;
|
let success: string;
|
||||||
|
|
||||||
let password = '';
|
let password = '';
|
||||||
let confirmPassowrd = '';
|
let passwordConfirm = '';
|
||||||
|
|
||||||
let changeChagePassword = false;
|
let valid = false;
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (password !== confirmPassowrd && confirmPassowrd.length > 0) {
|
if (password !== passwordConfirm && passwordConfirm.length > 0) {
|
||||||
error = 'Password does not match';
|
errorMessage = 'Password does not match';
|
||||||
changeChagePassword = false;
|
valid = false;
|
||||||
} else {
|
} else {
|
||||||
error = '';
|
errorMessage = '';
|
||||||
changeChagePassword = true;
|
valid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,10 +27,10 @@
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
async function changePassword() {
|
async function changePassword() {
|
||||||
if (changeChagePassword) {
|
if (valid) {
|
||||||
error = '';
|
errorMessage = '';
|
||||||
|
|
||||||
const { status } = await api.userApi.updateUser({
|
await updateUser({
|
||||||
updateUserDto: {
|
updateUserDto: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
password: String(password),
|
password: String(password),
|
||||||
@ -38,12 +38,7 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === 200) {
|
dispatch('success');
|
||||||
dispatch('success');
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
console.error('Error changing password');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -71,12 +66,12 @@
|
|||||||
type="password"
|
type="password"
|
||||||
autocomplete="current-password"
|
autocomplete="current-password"
|
||||||
required
|
required
|
||||||
bind:value={confirmPassowrd}
|
bind:value={passwordConfirm}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if error}
|
{#if errorMessage}
|
||||||
<p class="text-sm text-red-400">{error}</p>
|
<p class="text-sm text-red-400">{errorMessage}</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if success}
|
{#if success}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api } from '@api';
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import ImmichLogo from '../shared-components/immich-logo.svelte';
|
|
||||||
import { notificationController, NotificationType } from '../shared-components/notification/notification';
|
|
||||||
import Button from '../elements/buttons/button.svelte';
|
|
||||||
import { convertToBytes } from '$lib/utils/byte-converter';
|
|
||||||
import { serverInfo } from '$lib/stores/server-info.store';
|
import { serverInfo } from '$lib/stores/server-info.store';
|
||||||
|
import { convertToBytes } from '$lib/utils/byte-converter';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { createUser } from '@immich/sdk';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import ImmichLogo from '../shared-components/immich-logo.svelte';
|
||||||
|
|
||||||
let error: string;
|
let error: string;
|
||||||
let success: string;
|
let success: string;
|
||||||
@ -49,7 +49,7 @@
|
|||||||
const quotaSize = form.get('quotaSize');
|
const quotaSize = form.get('quotaSize');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { status } = await api.userApi.createUser({
|
await createUser({
|
||||||
createUserDto: {
|
createUserDto: {
|
||||||
email: String(email),
|
email: String(email),
|
||||||
password: String(password),
|
password: String(password),
|
||||||
@ -58,26 +58,15 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === 201) {
|
success = 'New user created';
|
||||||
success = 'New user created';
|
|
||||||
|
|
||||||
dispatch('submit');
|
dispatch('submit');
|
||||||
|
|
||||||
isCreatingUser = false;
|
return;
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
error = 'Error create user account';
|
|
||||||
isCreatingUser = false;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
handleError(error, 'Unable to create user');
|
||||||
|
} finally {
|
||||||
isCreatingUser = false;
|
isCreatingUser = false;
|
||||||
|
|
||||||
console.log('[ERROR] registerUser', error);
|
|
||||||
|
|
||||||
notificationController.show({
|
|
||||||
message: `Error create new user, check console for more detail`,
|
|
||||||
type: NotificationType.Error,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type AlbumResponseDto, api } from '@api';
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import { updateAlbumInfo, type AlbumResponseDto } from '@immich/sdk';
|
||||||
import { handleError } from '../../utils/handle-error';
|
|
||||||
import { mdiImageAlbum } from '@mdi/js';
|
import { mdiImageAlbum } from '@mdi/js';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
import { handleError } from '../../utils/handle-error';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
|
||||||
export let album: AlbumResponseDto;
|
export let album: AlbumResponseDto;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
const editUser = async () => {
|
const editUser = async () => {
|
||||||
try {
|
try {
|
||||||
const { status } = await api.albumApi.updateAlbumInfo({
|
await updateAlbumInfo({
|
||||||
id: album.id,
|
id: album.id,
|
||||||
updateAlbumDto: {
|
updateAlbumDto: {
|
||||||
albumName: album.albumName,
|
albumName: album.albumName,
|
||||||
@ -23,9 +23,7 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === 200) {
|
dispatch('editSuccess');
|
||||||
dispatch('editSuccess');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to update user');
|
handleError(error, 'Unable to update user');
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type UserResponseDto } from '@api';
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import { notificationController, NotificationType } from '../shared-components/notification/notification';
|
|
||||||
import Button from '../elements/buttons/button.svelte';
|
|
||||||
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import { mdiAccountEditOutline, mdiClose } from '@mdi/js';
|
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
|
||||||
import { convertFromBytes, convertToBytes } from '$lib/utils/byte-converter';
|
|
||||||
import { serverInfo } from '$lib/stores/server-info.store';
|
import { serverInfo } from '$lib/stores/server-info.store';
|
||||||
|
import { convertFromBytes, convertToBytes } from '$lib/utils/byte-converter';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { updateUser, type UserResponseDto } from '@immich/sdk';
|
||||||
|
import { mdiAccountEditOutline, mdiClose } from '@mdi/js';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
||||||
|
|
||||||
export let user: UserResponseDto;
|
export let user: UserResponseDto;
|
||||||
export let canResetPassword = true;
|
export let canResetPassword = true;
|
||||||
@ -36,7 +35,7 @@
|
|||||||
const editUser = async () => {
|
const editUser = async () => {
|
||||||
try {
|
try {
|
||||||
const { id, email, name, storageLabel, externalPath } = user;
|
const { id, email, name, storageLabel, externalPath } = user;
|
||||||
const { status } = await api.userApi.updateUser({
|
await updateUser({
|
||||||
updateUserDto: {
|
updateUserDto: {
|
||||||
id,
|
id,
|
||||||
email,
|
email,
|
||||||
@ -47,9 +46,7 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === 200) {
|
dispatch('editSuccess');
|
||||||
dispatch('editSuccess');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to update user');
|
handleError(error, 'Unable to update user');
|
||||||
}
|
}
|
||||||
@ -59,7 +56,7 @@
|
|||||||
try {
|
try {
|
||||||
const defaultPassword = 'password';
|
const defaultPassword = 'password';
|
||||||
|
|
||||||
const { status } = await api.userApi.updateUser({
|
await updateUser({
|
||||||
updateUserDto: {
|
updateUserDto: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
password: defaultPassword,
|
password: defaultPassword,
|
||||||
@ -67,15 +64,9 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status == 200) {
|
dispatch('resetPasswordSuccess');
|
||||||
dispatch('resetPasswordSuccess');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error reseting user password', error);
|
handleError(error, 'Unable to reset password');
|
||||||
notificationController.show({
|
|
||||||
message: 'Error reseting user password, check console for more details',
|
|
||||||
type: NotificationType.Error,
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
isShowResetPasswordConfirmation = false;
|
isShowResetPasswordConfirmation = false;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import { featureFlags, serverConfig } from '$lib/stores/server-config.store';
|
import { featureFlags, serverConfig } from '$lib/stores/server-config.store';
|
||||||
import { getServerErrorMessage, handleError } from '$lib/utils/handle-error';
|
import { getServerErrorMessage, handleError } from '$lib/utils/handle-error';
|
||||||
import { api, oauth } from '@api';
|
import { oauth } from '@api';
|
||||||
|
import { getServerConfig, login } from '@immich/sdk';
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
@ -53,19 +54,13 @@
|
|||||||
oauthLoading = false;
|
oauthLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const login = async () => {
|
const handleLogin = async () => {
|
||||||
try {
|
try {
|
||||||
errorMessage = '';
|
errorMessage = '';
|
||||||
loading = true;
|
loading = true;
|
||||||
|
|
||||||
const { data: user } = await api.authenticationApi.login({
|
const user = await login({ loginCredentialDto: { email, password } });
|
||||||
loginCredentialDto: {
|
const serverConfig = await getServerConfig();
|
||||||
email,
|
|
||||||
password,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: serverConfig } = await api.serverInfoApi.getServerConfig();
|
|
||||||
|
|
||||||
if (user.isAdmin && !serverConfig.isOnboarded) {
|
if (user.isAdmin && !serverConfig.isOnboarded) {
|
||||||
dispatch('onboarding');
|
dispatch('onboarding');
|
||||||
@ -97,7 +92,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !oauthLoading && $featureFlags.passwordLogin}
|
{#if !oauthLoading && $featureFlags.passwordLogin}
|
||||||
<form on:submit|preventDefault={login} class="mt-5 flex flex-col gap-5">
|
<form on:submit|preventDefault={handleLogin} class="mt-5 flex flex-col gap-5">
|
||||||
{#if errorMessage}
|
{#if errorMessage}
|
||||||
<p class="text-red-400" transition:fade>
|
<p class="text-red-400" transition:fade>
|
||||||
{errorMessage}
|
{errorMessage}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import OnboardingCard from './onboarding-card.svelte';
|
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
|
||||||
import { featureFlags } from '$lib/stores/server-config.store';
|
import { featureFlags } from '$lib/stores/server-config.store';
|
||||||
import StorageTemplateSettings from '../admin-page/settings/storage-template/storage-template-settings.svelte';
|
|
||||||
import { type SystemConfigDto, api } from '@api';
|
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
import AdminSettings from '../admin-page/settings/admin-settings.svelte';
|
import { type SystemConfigDto } from '@api';
|
||||||
|
import { getConfig } from '@immich/sdk';
|
||||||
import { mdiArrowLeft, mdiCheck } from '@mdi/js';
|
import { mdiArrowLeft, mdiCheck } from '@mdi/js';
|
||||||
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
|
import AdminSettings from '../admin-page/settings/admin-settings.svelte';
|
||||||
|
import StorageTemplateSettings from '../admin-page/settings/storage-template/storage-template-settings.svelte';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
import Icon from '../elements/icon.svelte';
|
import Icon from '../elements/icon.svelte';
|
||||||
|
import OnboardingCard from './onboarding-card.svelte';
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{
|
const dispatch = createEventDispatcher<{
|
||||||
done: void;
|
done: void;
|
||||||
@ -18,8 +19,7 @@
|
|||||||
let config: SystemConfigDto | null = null;
|
let config: SystemConfigDto | null = null;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const { data } = await api.systemConfigApi.getConfig();
|
config = await getConfig();
|
||||||
config = data;
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
NotificationType,
|
NotificationType,
|
||||||
notificationController,
|
notificationController,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
|
import { AppRoute } from '$lib/constants';
|
||||||
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
|
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
|
||||||
import { type AlbumResponseDto, api } from '@api';
|
import { type AlbumResponseDto } from '@api';
|
||||||
|
import { createAlbum } from '@immich/sdk';
|
||||||
import { getMenuContext } from '../asset-select-context-menu.svelte';
|
import { getMenuContext } from '../asset-select-context-menu.svelte';
|
||||||
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
|
|
||||||
export let shared = false;
|
export let shared = false;
|
||||||
let showAlbumPicker = false;
|
let showAlbumPicker = false;
|
||||||
@ -27,8 +28,8 @@
|
|||||||
showAlbumPicker = false;
|
showAlbumPicker = false;
|
||||||
|
|
||||||
const assetIds = [...getAssets()].map((asset) => asset.id);
|
const assetIds = [...getAssets()].map((asset) => asset.id);
|
||||||
api.albumApi.createAlbum({ createAlbumDto: { albumName, assetIds } }).then((response) => {
|
createAlbum({ createAlbumDto: { albumName, assetIds } }).then((response) => {
|
||||||
const { id, albumName } = response.data;
|
const { id, albumName } = response;
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Added ${assetIds.length} to ${albumName}`,
|
message: `Added ${assetIds.length} to ${albumName}`,
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
NotificationType,
|
NotificationType,
|
||||||
notificationController,
|
notificationController,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { type AlbumResponseDto, api } from '@api';
|
import { getAlbumInfo, removeAssetFromAlbum, type AlbumResponseDto } from '@immich/sdk';
|
||||||
|
import { mdiDeleteOutline } from '@mdi/js';
|
||||||
import MenuOption from '../../shared-components/context-menu/menu-option.svelte';
|
import MenuOption from '../../shared-components/context-menu/menu-option.svelte';
|
||||||
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
||||||
import { mdiDeleteOutline } from '@mdi/js';
|
|
||||||
|
|
||||||
export let album: AlbumResponseDto;
|
export let album: AlbumResponseDto;
|
||||||
export let onRemove: ((assetIds: string[]) => void) | undefined;
|
export let onRemove: ((assetIds: string[]) => void) | undefined;
|
||||||
@ -21,13 +21,12 @@
|
|||||||
const removeFromAlbum = async () => {
|
const removeFromAlbum = async () => {
|
||||||
try {
|
try {
|
||||||
const ids = [...getAssets()].map((a) => a.id);
|
const ids = [...getAssets()].map((a) => a.id);
|
||||||
const { data: results } = await api.albumApi.removeAssetFromAlbum({
|
const results = await removeAssetFromAlbum({
|
||||||
id: album.id,
|
id: album.id,
|
||||||
bulkIdsDto: { ids },
|
bulkIdsDto: { ids },
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data } = await api.albumApi.getAlbumInfo({ id: album.id });
|
album = await getAlbumInfo({ id: album.id });
|
||||||
album = data;
|
|
||||||
|
|
||||||
onRemove?.(ids);
|
onRemove?.(ids);
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import {
|
import {
|
||||||
NotificationType,
|
NotificationType,
|
||||||
notificationController,
|
notificationController,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
|
import type { OnRestore } from '$lib/utils/actions';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
import { api } from '@api';
|
import { restoreAssets } from '@immich/sdk';
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import { mdiHistory } from '@mdi/js';
|
||||||
import Button from '../../elements/buttons/button.svelte';
|
import Button from '../../elements/buttons/button.svelte';
|
||||||
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
||||||
import { mdiHistory } from '@mdi/js';
|
|
||||||
import type { OnRestore } from '$lib/utils/actions';
|
|
||||||
|
|
||||||
export let onRestore: OnRestore | undefined;
|
export let onRestore: OnRestore | undefined;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const ids = [...getAssets()].map((a) => a.id);
|
const ids = [...getAssets()].map((a) => a.id);
|
||||||
await api.trashApi.restoreAssets({ bulkIdsDto: { ids } });
|
await restoreAssets({ bulkIdsDto: { ids } });
|
||||||
onRestore?.(ids);
|
onRestore?.(ids);
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type AlbumResponseDto, api } from '@api';
|
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import BaseModal from './base-modal.svelte';
|
import { type AlbumResponseDto } from '@api';
|
||||||
import AlbumListItem from '../asset-viewer/album-list-item.svelte';
|
import { getAllAlbums } from '@immich/sdk';
|
||||||
import { mdiPlus } from '@mdi/js';
|
import { mdiPlus } from '@mdi/js';
|
||||||
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
|
import AlbumListItem from '../asset-viewer/album-list-item.svelte';
|
||||||
|
import BaseModal from './base-modal.svelte';
|
||||||
|
|
||||||
let albums: AlbumResponseDto[] = [];
|
let albums: AlbumResponseDto[] = [];
|
||||||
let recentAlbums: AlbumResponseDto[] = [];
|
let recentAlbums: AlbumResponseDto[] = [];
|
||||||
@ -21,11 +22,8 @@
|
|||||||
export let shared: boolean;
|
export let shared: boolean;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const { data } = await api.albumApi.getAllAlbums({ shared: shared || undefined });
|
albums = await getAllAlbums({ shared: shared || undefined });
|
||||||
albums = data;
|
|
||||||
|
|
||||||
recentAlbums = albums.sort((a, b) => (new Date(a.createdAt) > new Date(b.createdAt) ? -1 : 1)).slice(0, 3);
|
recentAlbums = albums.sort((a, b) => (new Date(a.createdAt) > new Date(b.createdAt) ? -1 : 1)).slice(0, 3);
|
||||||
|
|
||||||
loading = false;
|
loading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,28 +1,29 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
|
||||||
MapLibre,
|
|
||||||
GeoJSON,
|
|
||||||
MarkerLayer,
|
|
||||||
AttributionControl,
|
|
||||||
ControlButton,
|
|
||||||
Control,
|
|
||||||
ControlGroup,
|
|
||||||
type Map,
|
|
||||||
FullscreenControl,
|
|
||||||
GeolocateControl,
|
|
||||||
NavigationControl,
|
|
||||||
ScaleControl,
|
|
||||||
Popup,
|
|
||||||
} from 'svelte-maplibre';
|
|
||||||
import { colorTheme, mapSettings } from '$lib/stores/preferences.store';
|
|
||||||
import { type MapMarkerResponseDto, api } from '@api';
|
|
||||||
import maplibregl from 'maplibre-gl';
|
|
||||||
import type { GeoJSONSource, LngLatLike, StyleSpecification } from 'maplibre-gl';
|
|
||||||
import type { Feature, Geometry, GeoJsonProperties, Point } from 'geojson';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import { mdiCog, mdiMapMarker } from '@mdi/js';
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import { Theme } from '$lib/constants';
|
import { Theme } from '$lib/constants';
|
||||||
|
import { colorTheme, mapSettings } from '$lib/stores/preferences.store';
|
||||||
|
import { api, type MapMarkerResponseDto } from '@api';
|
||||||
|
import { getMapStyle } from '@immich/sdk';
|
||||||
|
import { mdiCog, mdiMapMarker } from '@mdi/js';
|
||||||
|
import type { Feature, GeoJsonProperties, Geometry, Point } from 'geojson';
|
||||||
|
import type { GeoJSONSource, LngLatLike, StyleSpecification } from 'maplibre-gl';
|
||||||
|
import maplibregl from 'maplibre-gl';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
import {
|
||||||
|
AttributionControl,
|
||||||
|
Control,
|
||||||
|
ControlButton,
|
||||||
|
ControlGroup,
|
||||||
|
FullscreenControl,
|
||||||
|
GeoJSON,
|
||||||
|
GeolocateControl,
|
||||||
|
MapLibre,
|
||||||
|
MarkerLayer,
|
||||||
|
NavigationControl,
|
||||||
|
Popup,
|
||||||
|
ScaleControl,
|
||||||
|
type Map,
|
||||||
|
} from 'svelte-maplibre';
|
||||||
|
|
||||||
export let mapMarkers: MapMarkerResponseDto[];
|
export let mapMarkers: MapMarkerResponseDto[];
|
||||||
export let showSettingsModal: boolean | undefined = undefined;
|
export let showSettingsModal: boolean | undefined = undefined;
|
||||||
@ -35,13 +36,10 @@
|
|||||||
let map: maplibregl.Map;
|
let map: maplibregl.Map;
|
||||||
let marker: maplibregl.Marker | null = null;
|
let marker: maplibregl.Marker | null = null;
|
||||||
|
|
||||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
$: style = (() =>
|
||||||
$: style = (async () => {
|
getMapStyle({
|
||||||
const { data } = await api.systemConfigApi.getMapStyle({
|
|
||||||
theme: $mapSettings.allowDarkMode ? $colorTheme.value : Theme.LIGHT,
|
theme: $mapSettings.allowDarkMode ? $colorTheme.value : Theme.LIGHT,
|
||||||
});
|
}) as Promise<StyleSpecification>)();
|
||||||
return data as StyleSpecification;
|
|
||||||
})();
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{
|
const dispatch = createEventDispatcher<{
|
||||||
selected: string[];
|
selected: string[];
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
import { api, UserAvatarColor } from '@api';
|
|
||||||
import { createEventDispatcher } from 'svelte';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import { fade } from 'svelte/transition';
|
import { AppRoute } from '$lib/constants';
|
||||||
import UserAvatar from '../user-avatar.svelte';
|
|
||||||
import { mdiCog, mdiLogout, mdiPencil } from '@mdi/js';
|
|
||||||
import { notificationController, NotificationType } from '../notification/notification';
|
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
|
||||||
import AvatarSelector from './avatar-selector.svelte';
|
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { UserAvatarColor } from '@api';
|
||||||
|
import { deleteProfileImage, updateUser } from '@immich/sdk';
|
||||||
|
import { mdiCog, mdiLogout, mdiPencil } from '@mdi/js';
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
import { fade } from 'svelte/transition';
|
||||||
|
import { notificationController, NotificationType } from '../notification/notification';
|
||||||
|
import UserAvatar from '../user-avatar.svelte';
|
||||||
|
import AvatarSelector from './avatar-selector.svelte';
|
||||||
|
|
||||||
let isShowSelectAvatar = false;
|
let isShowSelectAvatar = false;
|
||||||
|
|
||||||
@ -22,10 +23,10 @@
|
|||||||
const handleSaveProfile = async (color: UserAvatarColor) => {
|
const handleSaveProfile = async (color: UserAvatarColor) => {
|
||||||
try {
|
try {
|
||||||
if ($user.profileImagePath !== '') {
|
if ($user.profileImagePath !== '') {
|
||||||
await api.userApi.deleteProfileImage();
|
await deleteProfileImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await api.userApi.updateUser({
|
$user = await updateUser({
|
||||||
updateUserDto: {
|
updateUserDto: {
|
||||||
id: $user.id,
|
id: $user.id,
|
||||||
email: $user.email,
|
email: $user.email,
|
||||||
@ -34,7 +35,6 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
$user = data;
|
|
||||||
isShowSelectAvatar = false;
|
isShowSelectAvatar = false;
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
import IconButton from '$lib/components/elements/buttons/icon-button.svelte';
|
||||||
|
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
||||||
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
|
import { featureFlags } from '$lib/stores/server-config.store';
|
||||||
|
import { resetSavedUser, user } from '$lib/stores/user.store';
|
||||||
import { clickOutside } from '$lib/utils/click-outside';
|
import { clickOutside } from '$lib/utils/click-outside';
|
||||||
|
import { logout } from '@immich/sdk';
|
||||||
|
import { mdiCog, mdiMagnify, mdiTrayArrowUp } from '@mdi/js';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import { fade, fly } from 'svelte/transition';
|
import { fade, fly } from 'svelte/transition';
|
||||||
import { api } from '@api';
|
|
||||||
import ThemeButton from '../theme-button.svelte';
|
|
||||||
import { AppRoute } from '../../../constants';
|
import { AppRoute } from '../../../constants';
|
||||||
import AccountInfoPanel from './account-info-panel.svelte';
|
|
||||||
import ImmichLogo from '../immich-logo.svelte';
|
import ImmichLogo from '../immich-logo.svelte';
|
||||||
import SearchBar from '../search-bar/search-bar.svelte';
|
import SearchBar from '../search-bar/search-bar.svelte';
|
||||||
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
import ThemeButton from '../theme-button.svelte';
|
||||||
import IconButton from '$lib/components/elements/buttons/icon-button.svelte';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
|
||||||
import UserAvatar from '../user-avatar.svelte';
|
import UserAvatar from '../user-avatar.svelte';
|
||||||
import { featureFlags } from '$lib/stores/server-config.store';
|
import AccountInfoPanel from './account-info-panel.svelte';
|
||||||
import { mdiMagnify, mdiTrayArrowUp, mdiCog } from '@mdi/js';
|
|
||||||
import { resetSavedUser, user } from '$lib/stores/user.store';
|
|
||||||
|
|
||||||
export let showUploadButton = true;
|
export let showUploadButton = true;
|
||||||
|
|
||||||
@ -29,11 +29,11 @@
|
|||||||
|
|
||||||
const logOut = async () => {
|
const logOut = async () => {
|
||||||
resetSavedUser();
|
resetSavedUser();
|
||||||
const { data } = await api.authenticationApi.logout();
|
const { redirectUri } = await logout();
|
||||||
if (data.redirectUri.startsWith('/')) {
|
if (redirectUri.startsWith('/')) {
|
||||||
goto(data.redirectUri);
|
goto(redirectUri);
|
||||||
} else {
|
} else {
|
||||||
window.location.href = data.redirectUri;
|
window.location.href = redirectUri;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type AssetResponseDto, api } from '@api';
|
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
|
||||||
import { notificationController, NotificationType } from './notification/notification';
|
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
|
||||||
import domtoimage from 'dom-to-image';
|
|
||||||
import PhotoViewer from '../asset-viewer/photo-viewer.svelte';
|
|
||||||
import BaseModal from './base-modal.svelte';
|
|
||||||
import Button from '../elements/buttons/button.svelte';
|
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { type AssetResponseDto } from '@api';
|
||||||
|
import { createProfileImage } from '@immich/sdk';
|
||||||
|
import domtoimage from 'dom-to-image';
|
||||||
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
|
import PhotoViewer from '../asset-viewer/photo-viewer.svelte';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import BaseModal from './base-modal.svelte';
|
||||||
|
import { NotificationType, notificationController } from './notification/notification';
|
||||||
|
|
||||||
export let asset: AssetResponseDto;
|
export let asset: AssetResponseDto;
|
||||||
|
|
||||||
@ -57,13 +58,13 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const file = new File([blob], 'profile-picture.png', { type: 'image/png' });
|
const file = new File([blob], 'profile-picture.png', { type: 'image/png' });
|
||||||
const { data } = await api.userApi.createProfileImage({ file });
|
const { profileImagePath } = await createProfileImage({ createProfileImageDto: { file } });
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
message: 'Profile picture set.',
|
message: 'Profile picture set.',
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
});
|
});
|
||||||
$user.profileImagePath = data.profileImagePath;
|
$user.profileImagePath = profileImagePath;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Error setting profile picture.');
|
handleError(error, 'Error setting profile picture.');
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { locale, sidebarSettings } from '$lib/stores/preferences.store';
|
import { locale, sidebarSettings } from '$lib/stores/preferences.store';
|
||||||
import { featureFlags } from '$lib/stores/server-config.store';
|
import { featureFlags } from '$lib/stores/server-config.store';
|
||||||
import { type AssetApiGetAssetStatisticsRequest, api } from '@api';
|
import { api, type AssetApiGetAssetStatisticsRequest } from '@api';
|
||||||
|
import { getAlbumCount } from '@immich/sdk';
|
||||||
import {
|
import {
|
||||||
mdiAccount,
|
mdiAccount,
|
||||||
mdiAccountMultiple,
|
mdiAccountMultiple,
|
||||||
@ -28,10 +29,9 @@
|
|||||||
return stats;
|
return stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAlbumCount = async () => {
|
const handleAlbumCount = async () => {
|
||||||
try {
|
try {
|
||||||
const { data: albumCount } = await api.albumApi.getAlbumCount();
|
return await getAlbumCount();
|
||||||
return albumCount;
|
|
||||||
} catch {
|
} catch {
|
||||||
return { owned: 0, shared: 0, notShared: 0 };
|
return { owned: 0, shared: 0, notShared: 0 };
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@
|
|||||||
isSelected={isSharingSelected}
|
isSelected={isSharingSelected}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="moreInformation">
|
<svelte:fragment slot="moreInformation">
|
||||||
{#await getAlbumCount()}
|
{#await handleAlbumCount()}
|
||||||
<LoadingSpinner />
|
<LoadingSpinner />
|
||||||
{:then data}
|
{:then data}
|
||||||
<div>
|
<div>
|
||||||
@ -127,7 +127,7 @@
|
|||||||
isSelected={$page.route.id === '/(user)/albums'}
|
isSelected={$page.route.id === '/(user)/albums'}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="moreInformation">
|
<svelte:fragment slot="moreInformation">
|
||||||
{#await getAlbumCount()}
|
{#await handleAlbumCount()}
|
||||||
<LoadingSpinner />
|
<LoadingSpinner />
|
||||||
{:then data}
|
{:then data}
|
||||||
<div>
|
<div>
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
notificationController,
|
notificationController,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { api, type ApiError } from '@api';
|
import { type ApiError } from '@api';
|
||||||
|
import { changePassword } from '@immich/sdk';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import SettingInputField, { SettingInputFieldType } from '../admin-page/settings/setting-input-field.svelte';
|
import SettingInputField, { SettingInputFieldType } from '../admin-page/settings/setting-input-field.svelte';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
@ -14,12 +15,7 @@
|
|||||||
|
|
||||||
const handleChangePassword = async () => {
|
const handleChangePassword = async () => {
|
||||||
try {
|
try {
|
||||||
await api.authenticationApi.changePassword({
|
await changePassword({ changePasswordDto: { password, newPassword } });
|
||||||
changePasswordDto: {
|
|
||||||
password,
|
|
||||||
newPassword,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: 'Updated password',
|
message: 'Updated password',
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type AuthDeviceResponseDto } from '@api';
|
import { type AuthDeviceResponseDto } from '@api';
|
||||||
|
import { getAuthDevices, logoutAuthDevice, logoutAuthDevices } from '@immich/sdk';
|
||||||
import { handleError } from '../../utils/handle-error';
|
import { handleError } from '../../utils/handle-error';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
||||||
@ -10,7 +11,7 @@
|
|||||||
let deleteDevice: AuthDeviceResponseDto | null = null;
|
let deleteDevice: AuthDeviceResponseDto | null = null;
|
||||||
let deleteAll = false;
|
let deleteAll = false;
|
||||||
|
|
||||||
const refresh = () => api.authenticationApi.getAuthDevices().then(({ data }) => (devices = data));
|
const refresh = () => getAuthDevices().then((_devices) => (devices = _devices));
|
||||||
|
|
||||||
$: currentDevice = devices.find((device) => device.current);
|
$: currentDevice = devices.find((device) => device.current);
|
||||||
$: otherDevices = devices.filter((device) => !device.current);
|
$: otherDevices = devices.filter((device) => !device.current);
|
||||||
@ -21,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.authenticationApi.logoutAuthDevice({ id: deleteDevice.id });
|
await logoutAuthDevice({ id: deleteDevice.id });
|
||||||
notificationController.show({ message: `Logged out device`, type: NotificationType.Info });
|
notificationController.show({ message: `Logged out device`, type: NotificationType.Info });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to log out device');
|
handleError(error, 'Unable to log out device');
|
||||||
@ -33,7 +34,7 @@
|
|||||||
|
|
||||||
const handleDeleteAll = async () => {
|
const handleDeleteAll = async () => {
|
||||||
try {
|
try {
|
||||||
await api.authenticationApi.logoutAuthDevices();
|
await logoutAuthDevices();
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Logged out all devices`,
|
message: `Logged out all devices`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
|
@ -1,23 +1,31 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type LibraryResponseDto, LibraryType, type LibraryStatsResponseDto } from '@api';
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import Button from '../elements/buttons/button.svelte';
|
|
||||||
import { notificationController, NotificationType } from '../shared-components/notification/notification';
|
|
||||||
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
|
||||||
import { fade } from 'svelte/transition';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import { slide } from 'svelte/transition';
|
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
||||||
import LibraryImportPathsForm from '../forms/library-import-paths-form.svelte';
|
|
||||||
import LibraryScanSettingsForm from '../forms/library-scan-settings-form.svelte';
|
|
||||||
import LibraryRenameForm from '../forms/library-rename-form.svelte';
|
|
||||||
import { getBytesWithUnit } from '$lib/utils/byte-units';
|
import { getBytesWithUnit } from '$lib/utils/byte-units';
|
||||||
import Portal from '../shared-components/portal/portal.svelte';
|
import { getContextMenuPosition } from '$lib/utils/context-menu';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { LibraryType, type LibraryResponseDto, type LibraryStatsResponseDto } from '@api';
|
||||||
|
import {
|
||||||
|
createLibrary,
|
||||||
|
deleteLibrary,
|
||||||
|
getLibraries,
|
||||||
|
getLibraryStatistics,
|
||||||
|
removeOfflineFiles,
|
||||||
|
scanLibrary,
|
||||||
|
updateLibrary,
|
||||||
|
} from '@immich/sdk';
|
||||||
|
import { mdiDatabase, mdiDotsVertical, mdiUpload } from '@mdi/js';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { fade, slide } from 'svelte/transition';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import LibraryImportPathsForm from '../forms/library-import-paths-form.svelte';
|
||||||
|
import LibraryRenameForm from '../forms/library-rename-form.svelte';
|
||||||
|
import LibraryScanSettingsForm from '../forms/library-scan-settings-form.svelte';
|
||||||
|
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
||||||
import ContextMenu from '../shared-components/context-menu/context-menu.svelte';
|
import ContextMenu from '../shared-components/context-menu/context-menu.svelte';
|
||||||
import MenuOption from '../shared-components/context-menu/menu-option.svelte';
|
import MenuOption from '../shared-components/context-menu/menu-option.svelte';
|
||||||
import { getContextMenuPosition } from '$lib/utils/context-menu';
|
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
||||||
import { mdiDatabase, mdiDotsVertical, mdiUpload } from '@mdi/js';
|
import Portal from '../shared-components/portal/portal.svelte';
|
||||||
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
|
|
||||||
|
|
||||||
let libraries: LibraryResponseDto[] = [];
|
let libraries: LibraryResponseDto[] = [];
|
||||||
|
|
||||||
@ -29,7 +37,7 @@
|
|||||||
let diskUsageUnit: string[] = [];
|
let diskUsageUnit: string[] = [];
|
||||||
|
|
||||||
let confirmDeleteLibrary: LibraryResponseDto | null = null;
|
let confirmDeleteLibrary: LibraryResponseDto | null = null;
|
||||||
let deleteLibrary: LibraryResponseDto | null = null;
|
let deletedLibrary: LibraryResponseDto | null = null;
|
||||||
|
|
||||||
let editImportPaths: number | null;
|
let editImportPaths: number | null;
|
||||||
let editScanSettings: number | null;
|
let editScanSettings: number | null;
|
||||||
@ -73,8 +81,7 @@
|
|||||||
showContextMenu = false;
|
showContextMenu = false;
|
||||||
};
|
};
|
||||||
const refreshStats = async (listIndex: number) => {
|
const refreshStats = async (listIndex: number) => {
|
||||||
const { data } = await api.libraryApi.getLibraryStatistics({ id: libraries[listIndex].id });
|
stats[listIndex] = await getLibraryStatistics({ id: libraries[listIndex].id });
|
||||||
stats[listIndex] = data;
|
|
||||||
photos[listIndex] = stats[listIndex].photos;
|
photos[listIndex] = stats[listIndex].photos;
|
||||||
videos[listIndex] = stats[listIndex].videos;
|
videos[listIndex] = stats[listIndex].videos;
|
||||||
totalCount[listIndex] = stats[listIndex].total;
|
totalCount[listIndex] = stats[listIndex].total;
|
||||||
@ -82,8 +89,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function readLibraryList() {
|
async function readLibraryList() {
|
||||||
const { data } = await api.libraryApi.getLibraries();
|
libraries = await getLibraries();
|
||||||
libraries = data;
|
|
||||||
|
|
||||||
dropdownOpen.length = libraries.length;
|
dropdownOpen.length = libraries.length;
|
||||||
|
|
||||||
@ -95,12 +101,10 @@
|
|||||||
|
|
||||||
const handleCreate = async (libraryType: LibraryType) => {
|
const handleCreate = async (libraryType: LibraryType) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.libraryApi.createLibrary({
|
const createdLibrary = await createLibrary({
|
||||||
createLibraryDto: { type: libraryType },
|
createLibraryDto: { type: libraryType },
|
||||||
});
|
});
|
||||||
|
|
||||||
const createdLibrary = data;
|
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Created library: ${createdLibrary.name}`,
|
message: `Created library: ${createdLibrary.name}`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
@ -119,7 +123,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const libraryId = libraries[updateLibraryIndex].id;
|
const libraryId = libraries[updateLibraryIndex].id;
|
||||||
await api.libraryApi.updateLibrary({ id: libraryId, updateLibraryDto: { ...event } });
|
await updateLibrary({ id: libraryId, updateLibraryDto: { ...event } });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to update library');
|
handleError(error, 'Unable to update library');
|
||||||
} finally {
|
} finally {
|
||||||
@ -130,15 +134,15 @@
|
|||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
if (confirmDeleteLibrary) {
|
if (confirmDeleteLibrary) {
|
||||||
deleteLibrary = confirmDeleteLibrary;
|
deletedLibrary = confirmDeleteLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deleteLibrary) {
|
if (!deletedLibrary) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.libraryApi.deleteLibrary({ id: deleteLibrary.id });
|
await deleteLibrary({ id: deletedLibrary.id });
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Library deleted`,
|
message: `Library deleted`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
@ -147,7 +151,7 @@
|
|||||||
handleError(error, 'Unable to remove library');
|
handleError(error, 'Unable to remove library');
|
||||||
} finally {
|
} finally {
|
||||||
confirmDeleteLibrary = null;
|
confirmDeleteLibrary = null;
|
||||||
deleteLibrary = null;
|
deletedLibrary = null;
|
||||||
await readLibraryList();
|
await readLibraryList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -156,7 +160,7 @@
|
|||||||
try {
|
try {
|
||||||
for (const library of libraries) {
|
for (const library of libraries) {
|
||||||
if (library.type === LibraryType.External) {
|
if (library.type === LibraryType.External) {
|
||||||
await api.libraryApi.scanLibrary({ id: library.id, scanLibraryDto: {} });
|
await scanLibrary({ id: library.id, scanLibraryDto: {} });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
@ -170,7 +174,7 @@
|
|||||||
|
|
||||||
const handleScan = async (libraryId: string) => {
|
const handleScan = async (libraryId: string) => {
|
||||||
try {
|
try {
|
||||||
await api.libraryApi.scanLibrary({ id: libraryId, scanLibraryDto: {} });
|
await scanLibrary({ id: libraryId, scanLibraryDto: {} });
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Scanning library for new files`,
|
message: `Scanning library for new files`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
@ -182,7 +186,7 @@
|
|||||||
|
|
||||||
const handleScanChanges = async (libraryId: string) => {
|
const handleScanChanges = async (libraryId: string) => {
|
||||||
try {
|
try {
|
||||||
await api.libraryApi.scanLibrary({ id: libraryId, scanLibraryDto: { refreshModifiedFiles: true } });
|
await scanLibrary({ id: libraryId, scanLibraryDto: { refreshModifiedFiles: true } });
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Scanning library for changed files`,
|
message: `Scanning library for changed files`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
@ -194,7 +198,7 @@
|
|||||||
|
|
||||||
const handleForceScan = async (libraryId: string) => {
|
const handleForceScan = async (libraryId: string) => {
|
||||||
try {
|
try {
|
||||||
await api.libraryApi.scanLibrary({ id: libraryId, scanLibraryDto: { refreshAllFiles: true } });
|
await scanLibrary({ id: libraryId, scanLibraryDto: { refreshAllFiles: true } });
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Forcing refresh of all library files`,
|
message: `Forcing refresh of all library files`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
@ -206,7 +210,7 @@
|
|||||||
|
|
||||||
const handleRemoveOffline = async (libraryId: string) => {
|
const handleRemoveOffline = async (libraryId: string) => {
|
||||||
try {
|
try {
|
||||||
await api.libraryApi.removeOfflineFiles({ id: libraryId });
|
await removeOfflineFiles({ id: libraryId });
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Removing Offline Files`,
|
message: `Removing Offline Files`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
@ -272,7 +276,7 @@
|
|||||||
deleteAssetCount = totalCount[selectedLibraryIndex];
|
deleteAssetCount = totalCount[selectedLibraryIndex];
|
||||||
confirmDeleteLibrary = selectedLibrary;
|
confirmDeleteLibrary = selectedLibrary;
|
||||||
} else {
|
} else {
|
||||||
deleteLibrary = selectedLibrary;
|
deletedLibrary = selectedLibrary;
|
||||||
handleDelete();
|
handleDelete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
notificationController,
|
notificationController,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { api, type UserResponseDto } from '@api';
|
import { type UserResponseDto } from '@api';
|
||||||
|
import { updateUser } from '@immich/sdk';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import { handleError } from '../../utils/handle-error';
|
import { handleError } from '../../utils/handle-error';
|
||||||
import SettingSwitch from '../admin-page/settings/setting-switch.svelte';
|
import SettingSwitch from '../admin-page/settings/setting-switch.svelte';
|
||||||
@ -13,7 +14,7 @@
|
|||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.userApi.updateUser({
|
const data = await updateUser({
|
||||||
updateUserDto: {
|
updateUserDto: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
memoriesEnabled: user.memoriesEnabled,
|
memoriesEnabled: user.memoriesEnabled,
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
try {
|
try {
|
||||||
loading = true;
|
loading = true;
|
||||||
|
|
||||||
const { data } = await oauth.link(window.location);
|
user = await oauth.link(window.location);
|
||||||
user = data;
|
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: 'Linked OAuth account',
|
message: 'Linked OAuth account',
|
||||||
@ -37,8 +36,7 @@
|
|||||||
|
|
||||||
const handleUnlink = async () => {
|
const handleUnlink = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await oauth.unlink();
|
user = await oauth.unlink();
|
||||||
user = data;
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: 'Unlinked OAuth account',
|
message: 'Unlinked OAuth account',
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type UserResponseDto } from '@api';
|
import { type UserResponseDto } from '@api';
|
||||||
import BaseModal from '../shared-components/base-modal.svelte';
|
import { getAllUsers, getPartners } from '@immich/sdk';
|
||||||
import UserAvatar from '../shared-components/user-avatar.svelte';
|
|
||||||
import ImmichLogo from '../shared-components/immich-logo.svelte';
|
|
||||||
import Button from '../elements/buttons/button.svelte';
|
|
||||||
import { createEventDispatcher, onMount } from 'svelte';
|
import { createEventDispatcher, onMount } from 'svelte';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import BaseModal from '../shared-components/base-modal.svelte';
|
||||||
|
import ImmichLogo from '../shared-components/immich-logo.svelte';
|
||||||
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
||||||
|
|
||||||
export let user: UserResponseDto;
|
export let user: UserResponseDto;
|
||||||
|
|
||||||
@ -15,13 +16,13 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
// TODO: update endpoint to have a query param for deleted users
|
// TODO: update endpoint to have a query param for deleted users
|
||||||
let { data: users } = await api.userApi.getAllUsers({ isAll: false });
|
let users = await getAllUsers({ isAll: false });
|
||||||
|
|
||||||
// remove invalid users
|
// remove invalid users
|
||||||
users = users.filter((_user) => !(_user.deletedAt || _user.id === user.id));
|
users = users.filter((_user) => !(_user.deletedAt || _user.id === user.id));
|
||||||
|
|
||||||
// exclude partners from the list of users available for selection
|
// exclude partners from the list of users available for selection
|
||||||
const { data: partners } = await api.partnerApi.getPartners({ direction: 'shared-by' });
|
const partners = await getPartners({ direction: 'shared-by' });
|
||||||
const partnerIds = new Set(partners.map((partner) => partner.id));
|
const partnerIds = new Set(partners.map((partner) => partner.id));
|
||||||
availableUsers = users.filter((user) => !partnerIds.has(user.id));
|
availableUsers = users.filter((user) => !partnerIds.has(user.id));
|
||||||
});
|
});
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { type PartnerResponseDto, type UserResponseDto, api } from '@api';
|
import { type PartnerResponseDto, type UserResponseDto } from '@api';
|
||||||
import UserAvatar from '../shared-components/user-avatar.svelte';
|
import { createPartner, getPartners, removePartner, updatePartner } from '@immich/sdk';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
|
||||||
import PartnerSelectionModal from './partner-selection-modal.svelte';
|
|
||||||
import { handleError } from '../../utils/handle-error';
|
|
||||||
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
|
||||||
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
|
||||||
import { mdiCheck, mdiClose } from '@mdi/js';
|
import { mdiCheck, mdiClose } from '@mdi/js';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import Icon from '../elements/icon.svelte';
|
import { handleError } from '../../utils/handle-error';
|
||||||
import SettingSwitch from '../admin-page/settings/setting-switch.svelte';
|
import SettingSwitch from '../admin-page/settings/setting-switch.svelte';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
||||||
|
import Icon from '../elements/icon.svelte';
|
||||||
|
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
||||||
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
||||||
|
import PartnerSelectionModal from './partner-selection-modal.svelte';
|
||||||
|
|
||||||
interface PartnerSharing {
|
interface PartnerSharing {
|
||||||
user: UserResponseDto;
|
user: UserResponseDto;
|
||||||
@ -20,8 +21,8 @@
|
|||||||
|
|
||||||
export let user: UserResponseDto;
|
export let user: UserResponseDto;
|
||||||
|
|
||||||
let createPartner = false;
|
let createPartnerFlag = false;
|
||||||
let removePartner: PartnerResponseDto | null = null;
|
let removePartnerDto: PartnerResponseDto | null = null;
|
||||||
let partners: Array<PartnerSharing> = [];
|
let partners: Array<PartnerSharing> = [];
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@ -31,9 +32,9 @@
|
|||||||
const refreshPartners = async () => {
|
const refreshPartners = async () => {
|
||||||
partners = [];
|
partners = [];
|
||||||
|
|
||||||
const [{ data: sharedBy }, { data: sharedWith }] = await Promise.all([
|
const [sharedBy, sharedWith] = await Promise.all([
|
||||||
api.partnerApi.getPartners({ direction: 'shared-by' }),
|
getPartners({ direction: 'shared-by' }),
|
||||||
api.partnerApi.getPartners({ direction: 'shared-with' }),
|
getPartners({ direction: 'shared-with' }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
for (const candidate of sharedBy) {
|
for (const candidate of sharedBy) {
|
||||||
@ -69,13 +70,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRemovePartner = async () => {
|
const handleRemovePartner = async () => {
|
||||||
if (!removePartner) {
|
if (!removePartnerDto) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.partnerApi.removePartner({ id: removePartner.id });
|
await removePartner({ id: removePartnerDto.id });
|
||||||
removePartner = null;
|
removePartnerDto = null;
|
||||||
await refreshPartners();
|
await refreshPartners();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to remove partner');
|
handleError(error, 'Unable to remove partner');
|
||||||
@ -85,11 +86,11 @@
|
|||||||
const handleCreatePartners = async (users: UserResponseDto[]) => {
|
const handleCreatePartners = async (users: UserResponseDto[]) => {
|
||||||
try {
|
try {
|
||||||
for (const user of users) {
|
for (const user of users) {
|
||||||
await api.partnerApi.createPartner({ id: user.id });
|
await createPartner({ id: user.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
await refreshPartners();
|
await refreshPartners();
|
||||||
createPartner = false;
|
createPartnerFlag = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to add partners');
|
handleError(error, 'Unable to add partners');
|
||||||
}
|
}
|
||||||
@ -97,7 +98,7 @@
|
|||||||
|
|
||||||
const handleShowOnTimelineChanged = async (partner: PartnerSharing, inTimeline: boolean) => {
|
const handleShowOnTimelineChanged = async (partner: PartnerSharing, inTimeline: boolean) => {
|
||||||
try {
|
try {
|
||||||
await api.partnerApi.updatePartner({ id: partner.user.id, updatePartnerDto: { inTimeline } });
|
await updatePartner({ id: partner.user.id, updatePartnerDto: { inTimeline } });
|
||||||
|
|
||||||
partner.inTimeline = inTimeline;
|
partner.inTimeline = inTimeline;
|
||||||
partners = partners;
|
partners = partners;
|
||||||
@ -126,7 +127,7 @@
|
|||||||
|
|
||||||
{#if partner.sharedByMe}
|
{#if partner.sharedByMe}
|
||||||
<CircleIconButton
|
<CircleIconButton
|
||||||
on:click={() => (removePartner = partner.user)}
|
on:click={() => (removePartnerDto = partner.user)}
|
||||||
icon={mdiClose}
|
icon={mdiClose}
|
||||||
size={'16'}
|
size={'16'}
|
||||||
title="Stop sharing your photos with this user"
|
title="Stop sharing your photos with this user"
|
||||||
@ -167,23 +168,23 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex justify-end mt-5">
|
<div class="flex justify-end mt-5">
|
||||||
<Button size="sm" on:click={() => (createPartner = true)}>Add partner</Button>
|
<Button size="sm" on:click={() => (createPartnerFlag = true)}>Add partner</Button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{#if createPartner}
|
{#if createPartnerFlag}
|
||||||
<PartnerSelectionModal
|
<PartnerSelectionModal
|
||||||
{user}
|
{user}
|
||||||
on:close={() => (createPartner = false)}
|
on:close={() => (createPartnerFlag = false)}
|
||||||
on:add-users={(event) => handleCreatePartners(event.detail)}
|
on:add-users={(event) => handleCreatePartners(event.detail)}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if removePartner}
|
{#if removePartnerDto}
|
||||||
<ConfirmDialogue
|
<ConfirmDialogue
|
||||||
title="Stop sharing your photos?"
|
title="Stop sharing your photos?"
|
||||||
prompt="{removePartner.name} will no longer be able to access your photos."
|
prompt="{removePartnerDto.name} will no longer be able to access your photos."
|
||||||
on:cancel={() => (removePartner = null)}
|
on:cancel={() => (removePartnerDto = null)}
|
||||||
on:confirm={() => handleRemovePartner()}
|
on:confirm={() => handleRemovePartner()}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type APIKeyResponseDto } from '@api';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
|
import { type APIKeyResponseDto } from '@api';
|
||||||
|
import { createApiKey, deleteApiKey, getApiKeys, updateApiKey } from '@immich/sdk';
|
||||||
|
import { mdiPencilOutline, mdiTrashCanOutline } from '@mdi/js';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import { handleError } from '../../utils/handle-error';
|
import { handleError } from '../../utils/handle-error';
|
||||||
|
import Button from '../elements/buttons/button.svelte';
|
||||||
import APIKeyForm from '../forms/api-key-form.svelte';
|
import APIKeyForm from '../forms/api-key-form.svelte';
|
||||||
import APIKeySecret from '../forms/api-key-secret.svelte';
|
import APIKeySecret from '../forms/api-key-secret.svelte';
|
||||||
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
||||||
import { notificationController, NotificationType } from '../shared-components/notification/notification';
|
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
||||||
import { locale } from '$lib/stores/preferences.store';
|
|
||||||
import Button from '../elements/buttons/button.svelte';
|
|
||||||
import { mdiPencilOutline, mdiTrashCanOutline } from '@mdi/js';
|
|
||||||
|
|
||||||
export let keys: APIKeyResponseDto[];
|
export let keys: APIKeyResponseDto[];
|
||||||
|
|
||||||
@ -25,13 +26,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function refreshKeys() {
|
async function refreshKeys() {
|
||||||
const { data } = await api.keyApi.getApiKeys();
|
keys = await getApiKeys();
|
||||||
keys = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCreate = async (detail: Partial<APIKeyResponseDto>) => {
|
const handleCreate = async (detail: Partial<APIKeyResponseDto>) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.keyApi.createApiKey({ aPIKeyCreateDto: detail });
|
const data = await createApiKey({ apiKeyCreateDto: detail });
|
||||||
secret = data.secret;
|
secret = data.secret;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to create a new API Key');
|
handleError(error, 'Unable to create a new API Key');
|
||||||
@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.keyApi.updateApiKey({ id: editKey.id, aPIKeyUpdateDto: { name: detail.name } });
|
await updateApiKey({ id: editKey.id, apiKeyUpdateDto: { name: detail.name } });
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Saved API Key`,
|
message: `Saved API Key`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
@ -66,7 +66,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.keyApi.deleteApiKey({ id: deleteKey.id });
|
await deleteApiKey({ id: deleteKey.id });
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Removed API Key: ${deleteKey.name}`,
|
message: `Removed API Key: ${deleteKey.name}`,
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
|
@ -3,19 +3,19 @@
|
|||||||
notificationController,
|
notificationController,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { api } from '@api';
|
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import { handleError } from '../../utils/handle-error';
|
import { handleError } from '../../utils/handle-error';
|
||||||
import SettingInputField, { SettingInputFieldType } from '../admin-page/settings/setting-input-field.svelte';
|
import SettingInputField, { SettingInputFieldType } from '../admin-page/settings/setting-input-field.svelte';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
import { updateUser } from '@immich/sdk';
|
||||||
|
|
||||||
let editedUser = cloneDeep($user);
|
let editedUser = cloneDeep($user);
|
||||||
|
|
||||||
const handleSaveProfile = async () => {
|
const handleSaveProfile = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.userApi.updateUser({
|
const data = await updateUser({
|
||||||
updateUserDto: {
|
updateUserDto: {
|
||||||
id: editedUser.id,
|
id: editedUser.id,
|
||||||
email: editedUser.email,
|
email: editedUser.email,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { api, type ServerConfigDto, type ServerFeaturesDto } from '@api';
|
import { type ServerConfigDto, type ServerFeaturesDto } from '@api';
|
||||||
|
import { getServerConfig, getServerFeatures } from '@immich/sdk';
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
export type FeatureFlags = ServerFeaturesDto & { loaded: boolean };
|
export type FeatureFlags = ServerFeaturesDto & { loaded: boolean };
|
||||||
@ -31,10 +32,7 @@ export const serverConfig = writable<ServerConfig>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const loadConfig = async () => {
|
export const loadConfig = async () => {
|
||||||
const [{ data: flags }, { data: config }] = await Promise.all([
|
const [flags, config] = await Promise.all([getServerFeatures(), getServerConfig()]);
|
||||||
api.serverInfoApi.getServerFeatures(),
|
|
||||||
api.serverInfoApi.getServerConfig(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
featureFlags.update(() => ({ ...flags, loaded: true }));
|
featureFlags.update(() => ({ ...flags, loaded: true }));
|
||||||
serverConfig.update(() => ({ ...config, loaded: true }));
|
serverConfig.update(() => ({ ...config, loaded: true }));
|
||||||
|
@ -1,34 +1,33 @@
|
|||||||
import { notificationController, NotificationType } from '$lib/components/shared-components/notification/notification';
|
import { notificationController, NotificationType } from '$lib/components/shared-components/notification/notification';
|
||||||
import { downloadManager } from '$lib/stores/download';
|
import { downloadManager } from '$lib/stores/download';
|
||||||
|
import { api } from '@api';
|
||||||
import {
|
import {
|
||||||
api,
|
addAssetsToAlbum as addAssets,
|
||||||
type BulkIdResponseDto,
|
|
||||||
type AssetResponseDto,
|
type AssetResponseDto,
|
||||||
type DownloadResponseDto,
|
type AssetTypeEnum,
|
||||||
|
type BulkIdResponseDto,
|
||||||
type DownloadInfoDto,
|
type DownloadInfoDto,
|
||||||
AssetTypeEnum,
|
type DownloadResponseDto,
|
||||||
type UserResponseDto,
|
type UserResponseDto,
|
||||||
} from '@api';
|
} from '@immich/sdk';
|
||||||
import { handleError } from './handle-error';
|
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
import { handleError } from './handle-error';
|
||||||
|
|
||||||
export const addAssetsToAlbum = async (albumId: string, assetIds: Array<string>): Promise<BulkIdResponseDto[]> =>
|
export const addAssetsToAlbum = async (albumId: string, assetIds: Array<string>): Promise<BulkIdResponseDto[]> =>
|
||||||
api.albumApi
|
addAssets({
|
||||||
.addAssetsToAlbum({
|
id: albumId,
|
||||||
id: albumId,
|
bulkIdsDto: { ids: assetIds },
|
||||||
bulkIdsDto: { ids: assetIds },
|
key: api.getKey(),
|
||||||
key: api.getKey(),
|
}).then((results) => {
|
||||||
})
|
const count = results.filter(({ success }) => success).length;
|
||||||
.then(({ data: results }) => {
|
notificationController.show({
|
||||||
const count = results.filter(({ success }) => success).length;
|
type: NotificationType.Info,
|
||||||
notificationController.show({
|
message: `Added ${count} asset${count === 1 ? '' : 's'}`,
|
||||||
type: NotificationType.Info,
|
|
||||||
message: `Added ${count} asset${count === 1 ? '' : 's'}`,
|
|
||||||
});
|
|
||||||
|
|
||||||
return results;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return results;
|
||||||
|
});
|
||||||
|
|
||||||
export const downloadBlob = (data: Blob, filename: string) => {
|
export const downloadBlob = (data: Blob, filename: string) => {
|
||||||
const url = URL.createObjectURL(data);
|
const url = URL.createObjectURL(data);
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { api } from '@api';
|
|
||||||
import { redirect } from '@sveltejs/kit';
|
|
||||||
import { AppRoute } from '../constants';
|
|
||||||
import { get } from 'svelte/store';
|
|
||||||
import { serverInfo } from '$lib/stores/server-info.store';
|
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
|
import { serverInfo } from '$lib/stores/server-info.store';
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
|
import { getMyUserInfo, getServerInfo } from '@immich/sdk';
|
||||||
|
import { redirect } from '@sveltejs/kit';
|
||||||
|
import { get } from 'svelte/store';
|
||||||
|
import { AppRoute } from '../constants';
|
||||||
|
|
||||||
export interface AuthOptions {
|
export interface AuthOptions {
|
||||||
admin?: true;
|
admin?: true;
|
||||||
@ -15,8 +15,7 @@ export const loadUser = async () => {
|
|||||||
try {
|
try {
|
||||||
let loaded = get(user);
|
let loaded = get(user);
|
||||||
if (!loaded && hasAuthCookie()) {
|
if (!loaded && hasAuthCookie()) {
|
||||||
const { data } = await api.userApi.getMyUserInfo();
|
loaded = await getMyUserInfo();
|
||||||
loaded = data;
|
|
||||||
user.set(loaded);
|
user.set(loaded);
|
||||||
}
|
}
|
||||||
return loaded;
|
return loaded;
|
||||||
@ -59,7 +58,7 @@ export const authenticate = async (options?: AuthOptions) => {
|
|||||||
|
|
||||||
export const requestServerInfo = async () => {
|
export const requestServerInfo = async () => {
|
||||||
if (get(user)) {
|
if (get(user)) {
|
||||||
const { data } = await api.serverInfoApi.getServerInfo();
|
const data = await getServerInfo();
|
||||||
serverInfo.set(data);
|
serverInfo.set(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
import { UploadState } from '$lib/models/upload-asset';
|
||||||
import { uploadAssetsStore } from '$lib/stores/upload';
|
import { uploadAssetsStore } from '$lib/stores/upload';
|
||||||
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
|
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
|
||||||
import { api, type AssetFileUploadResponseDto } from '@api';
|
|
||||||
import { UploadState } from '$lib/models/upload-asset';
|
|
||||||
import { ExecutorQueue } from '$lib/utils/executor-queue';
|
import { ExecutorQueue } from '$lib/utils/executor-queue';
|
||||||
|
import { api, type AssetFileUploadResponseDto } from '@api';
|
||||||
|
import { getSupportedMediaTypes } from '@immich/sdk';
|
||||||
import { getServerErrorMessage, handleError } from './handle-error';
|
import { getServerErrorMessage, handleError } from './handle-error';
|
||||||
|
|
||||||
let _extensions: string[];
|
let _extensions: string[];
|
||||||
@ -11,8 +12,8 @@ export const uploadExecutionQueue = new ExecutorQueue({ concurrency: 2 });
|
|||||||
|
|
||||||
const getExtensions = async () => {
|
const getExtensions = async () => {
|
||||||
if (!_extensions) {
|
if (!_extensions) {
|
||||||
const { data } = await api.serverInfoApi.getSupportedMediaTypes();
|
const { image, video } = await getSupportedMediaTypes();
|
||||||
_extensions = [...data.image, ...data.video];
|
_extensions = [...image, ...video];
|
||||||
}
|
}
|
||||||
return _extensions;
|
return _extensions;
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getAllAlbums } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
await authenticate();
|
await authenticate();
|
||||||
const { data: albums } = await api.albumApi.getAllAlbums();
|
const albums = await getAllAlbums({});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
albums,
|
albums,
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { afterNavigate, goto } from '$app/navigation';
|
import { afterNavigate, goto } from '$app/navigation';
|
||||||
|
import AlbumOptions from '$lib/components/album-page/album-options.svelte';
|
||||||
import ShareInfoModal from '$lib/components/album-page/share-info-modal.svelte';
|
import ShareInfoModal from '$lib/components/album-page/share-info-modal.svelte';
|
||||||
import UserSelectionModal from '$lib/components/album-page/user-selection-modal.svelte';
|
import UserSelectionModal from '$lib/components/album-page/user-selection-modal.svelte';
|
||||||
|
import ActivityStatus from '$lib/components/asset-viewer/activity-status.svelte';
|
||||||
|
import ActivityViewer from '$lib/components/asset-viewer/activity-viewer.svelte';
|
||||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||||
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte';
|
import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte';
|
||||||
import ArchiveAction from '$lib/components/photos-page/actions/archive-action.svelte';
|
import ArchiveAction from '$lib/components/photos-page/actions/archive-action.svelte';
|
||||||
|
import ChangeDate from '$lib/components/photos-page/actions/change-date-action.svelte';
|
||||||
|
import ChangeLocation from '$lib/components/photos-page/actions/change-location-action.svelte';
|
||||||
import CreateSharedLink from '$lib/components/photos-page/actions/create-shared-link.svelte';
|
import CreateSharedLink from '$lib/components/photos-page/actions/create-shared-link.svelte';
|
||||||
import DeleteAssets from '$lib/components/photos-page/actions/delete-assets.svelte';
|
import DeleteAssets from '$lib/components/photos-page/actions/delete-assets.svelte';
|
||||||
import DownloadAction from '$lib/components/photos-page/actions/download-action.svelte';
|
import DownloadAction from '$lib/components/photos-page/actions/download-action.svelte';
|
||||||
import FavoriteAction from '$lib/components/photos-page/actions/favorite-action.svelte';
|
import FavoriteAction from '$lib/components/photos-page/actions/favorite-action.svelte';
|
||||||
import ChangeDate from '$lib/components/photos-page/actions/change-date-action.svelte';
|
|
||||||
import ChangeLocation from '$lib/components/photos-page/actions/change-location-action.svelte';
|
|
||||||
import RemoveFromAlbum from '$lib/components/photos-page/actions/remove-from-album.svelte';
|
import RemoveFromAlbum from '$lib/components/photos-page/actions/remove-from-album.svelte';
|
||||||
import SelectAllAssets from '$lib/components/photos-page/actions/select-all-assets.svelte';
|
import SelectAllAssets from '$lib/components/photos-page/actions/select-all-assets.svelte';
|
||||||
import AssetGrid from '$lib/components/photos-page/asset-grid.svelte';
|
import AssetGrid from '$lib/components/photos-page/asset-grid.svelte';
|
||||||
@ -26,40 +30,47 @@
|
|||||||
NotificationType,
|
NotificationType,
|
||||||
notificationController,
|
notificationController,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
|
import UpdatePanel from '$lib/components/shared-components/update-panel.svelte';
|
||||||
import UserAvatar from '$lib/components/shared-components/user-avatar.svelte';
|
import UserAvatar from '$lib/components/shared-components/user-avatar.svelte';
|
||||||
import { AppRoute, dateFormats } from '$lib/constants';
|
import { AppRoute, dateFormats } from '$lib/constants';
|
||||||
|
import { numberOfComments, setNumberOfComments, updateNumberOfComments } from '$lib/stores/activity.store';
|
||||||
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
|
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
|
||||||
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
||||||
import { SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
|
||||||
import { AssetStore } from '$lib/stores/assets.store';
|
import { AssetStore } from '$lib/stores/assets.store';
|
||||||
import { locale } from '$lib/stores/preferences.store';
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
|
import { SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
||||||
|
import { user } from '$lib/stores/user.store';
|
||||||
import { downloadArchive } from '$lib/utils/asset-utils';
|
import { downloadArchive } from '$lib/utils/asset-utils';
|
||||||
import { openFileUploadDialog } from '$lib/utils/file-uploader';
|
import { autoGrowHeight } from '$lib/utils/autogrow';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
|
||||||
import { type ActivityResponseDto, ReactionLevel, ReactionType, type UserResponseDto, api } from '@api';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
|
||||||
import type { PageData } from './$types';
|
|
||||||
import { clickOutside } from '$lib/utils/click-outside';
|
import { clickOutside } from '$lib/utils/click-outside';
|
||||||
import { getContextMenuPosition } from '$lib/utils/context-menu';
|
import { getContextMenuPosition } from '$lib/utils/context-menu';
|
||||||
|
import { openFileUploadDialog } from '$lib/utils/file-uploader';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { ReactionLevel, ReactionType, type ActivityResponseDto, type UserResponseDto } from '@api';
|
||||||
|
import {
|
||||||
|
addAssetsToAlbum,
|
||||||
|
addUsersToAlbum,
|
||||||
|
createActivity,
|
||||||
|
deleteActivity,
|
||||||
|
deleteAlbum,
|
||||||
|
getActivities,
|
||||||
|
getActivityStatistics,
|
||||||
|
getAlbumInfo,
|
||||||
|
updateAlbumInfo,
|
||||||
|
} from '@immich/sdk';
|
||||||
import {
|
import {
|
||||||
mdiPlus,
|
|
||||||
mdiDotsVertical,
|
|
||||||
mdiArrowLeft,
|
mdiArrowLeft,
|
||||||
|
mdiDeleteOutline,
|
||||||
|
mdiDotsVertical,
|
||||||
mdiFileImagePlusOutline,
|
mdiFileImagePlusOutline,
|
||||||
mdiFolderDownloadOutline,
|
mdiFolderDownloadOutline,
|
||||||
mdiLink,
|
mdiLink,
|
||||||
|
mdiPlus,
|
||||||
mdiShareVariantOutline,
|
mdiShareVariantOutline,
|
||||||
mdiDeleteOutline,
|
|
||||||
} from '@mdi/js';
|
} from '@mdi/js';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { fly } from 'svelte/transition';
|
import { fly } from 'svelte/transition';
|
||||||
import ActivityViewer from '$lib/components/asset-viewer/activity-viewer.svelte';
|
import type { PageData } from './$types';
|
||||||
import ActivityStatus from '$lib/components/asset-viewer/activity-status.svelte';
|
|
||||||
import { numberOfComments, setNumberOfComments, updateNumberOfComments } from '$lib/stores/activity.store';
|
|
||||||
import AlbumOptions from '$lib/components/album-page/album-options.svelte';
|
|
||||||
import UpdatePanel from '$lib/components/shared-components/update-panel.svelte';
|
|
||||||
import { user } from '$lib/stores/user.store';
|
|
||||||
import { autoGrowHeight } from '$lib/utils/autogrow';
|
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
@ -141,13 +152,12 @@
|
|||||||
|
|
||||||
const handleToggleEnableActivity = async () => {
|
const handleToggleEnableActivity = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.albumApi.updateAlbumInfo({
|
album = await updateAlbumInfo({
|
||||||
id: album.id,
|
id: album.id,
|
||||||
updateAlbumDto: {
|
updateAlbumDto: {
|
||||||
isActivityEnabled: !album.isActivityEnabled,
|
isActivityEnabled: !album.isActivityEnabled,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
album = data;
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
message: `Activity is ${album.isActivityEnabled ? 'enabled' : 'disabled'}`,
|
message: `Activity is ${album.isActivityEnabled ? 'enabled' : 'disabled'}`,
|
||||||
@ -161,14 +171,13 @@
|
|||||||
try {
|
try {
|
||||||
if (isLiked) {
|
if (isLiked) {
|
||||||
const activityId = isLiked.id;
|
const activityId = isLiked.id;
|
||||||
await api.activityApi.deleteActivity({ id: activityId });
|
await deleteActivity({ id: activityId });
|
||||||
reactions = reactions.filter((reaction) => reaction.id !== activityId);
|
reactions = reactions.filter((reaction) => reaction.id !== activityId);
|
||||||
isLiked = null;
|
isLiked = null;
|
||||||
} else {
|
} else {
|
||||||
const { data } = await api.activityApi.createActivity({
|
isLiked = await createActivity({
|
||||||
activityCreateDto: { albumId: album.id, type: ReactionType.Like },
|
activityCreateDto: { albumId: album.id, type: ReactionType.Like },
|
||||||
});
|
});
|
||||||
isLiked = data;
|
|
||||||
reactions = [...reactions, isLiked];
|
reactions = [...reactions, isLiked];
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -179,10 +188,10 @@
|
|||||||
const getFavorite = async () => {
|
const getFavorite = async () => {
|
||||||
if ($user) {
|
if ($user) {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.activityApi.getActivities({
|
const data = await getActivities({
|
||||||
userId: $user.id,
|
userId: $user.id,
|
||||||
albumId: album.id,
|
albumId: album.id,
|
||||||
type: ReactionType.Like,
|
$type: ReactionType.Like,
|
||||||
level: ReactionLevel.Album,
|
level: ReactionLevel.Album,
|
||||||
});
|
});
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
@ -196,8 +205,8 @@
|
|||||||
|
|
||||||
const getNumberOfComments = async () => {
|
const getNumberOfComments = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.activityApi.getActivityStatistics({ albumId: album.id });
|
const { comments } = await getActivityStatistics({ albumId: album.id });
|
||||||
setNumberOfComments(data.comments);
|
setNumberOfComments(comments);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, "Can't get number of comments");
|
handleError(error, "Can't get number of comments");
|
||||||
}
|
}
|
||||||
@ -269,8 +278,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const refreshAlbum = async () => {
|
const refreshAlbum = async () => {
|
||||||
const { data } = await api.albumApi.getAlbumInfo({ id: album.id, withoutAssets: true });
|
album = await getAlbumInfo({ id: album.id, withoutAssets: true });
|
||||||
album = data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDateRange = () => {
|
const getDateRange = () => {
|
||||||
@ -302,7 +310,7 @@
|
|||||||
const assetIds = [...$timelineSelected].map((asset) => asset.id);
|
const assetIds = [...$timelineSelected].map((asset) => asset.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data: results } = await api.albumApi.addAssetsToAlbum({
|
const results = await addAssetsToAlbum({
|
||||||
id: album.id,
|
id: album.id,
|
||||||
bulkIdsDto: { ids: assetIds },
|
bulkIdsDto: { ids: assetIds },
|
||||||
});
|
});
|
||||||
@ -346,15 +354,13 @@
|
|||||||
|
|
||||||
const handleAddUsers = async (users: UserResponseDto[]) => {
|
const handleAddUsers = async (users: UserResponseDto[]) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.albumApi.addUsersToAlbum({
|
album = await addUsersToAlbum({
|
||||||
id: album.id,
|
id: album.id,
|
||||||
addUsersDto: {
|
addUsersDto: {
|
||||||
sharedUserIds: [...users].map(({ id }) => id),
|
sharedUserIds: [...users].map(({ id }) => id),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
album = data;
|
|
||||||
|
|
||||||
viewMode = ViewMode.VIEW;
|
viewMode = ViewMode.VIEW;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Error adding users to album');
|
handleError(error, 'Error adding users to album');
|
||||||
@ -381,7 +387,7 @@
|
|||||||
|
|
||||||
const handleRemoveAlbum = async () => {
|
const handleRemoveAlbum = async () => {
|
||||||
try {
|
try {
|
||||||
await api.albumApi.deleteAlbum({ id: album.id });
|
await deleteAlbum({ id: album.id });
|
||||||
goto(backUrl);
|
goto(backUrl);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, 'Unable to delete album');
|
handleError(error, 'Unable to delete album');
|
||||||
@ -399,7 +405,7 @@
|
|||||||
assetInteractionStore.clearMultiselect();
|
assetInteractionStore.clearMultiselect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.albumApi.updateAlbumInfo({
|
await updateAlbumInfo({
|
||||||
id: album.id,
|
id: album.id,
|
||||||
updateAlbumDto: {
|
updateAlbumDto: {
|
||||||
albumThumbnailAssetId: assetId,
|
albumThumbnailAssetId: assetId,
|
||||||
@ -418,7 +424,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.albumApi.updateAlbumInfo({
|
await updateAlbumInfo({
|
||||||
id: album.id,
|
id: album.id,
|
||||||
updateAlbumDto: {
|
updateAlbumDto: {
|
||||||
albumName: album.albumName,
|
albumName: album.albumName,
|
||||||
@ -436,7 +442,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await api.albumApi.updateAlbumInfo({
|
await updateAlbumInfo({
|
||||||
id: album.id,
|
id: album.id,
|
||||||
updateAlbumDto: {
|
updateAlbumDto: {
|
||||||
description,
|
description,
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getAlbumInfo } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async ({ params }) => {
|
export const load = (async ({ params }) => {
|
||||||
await authenticate();
|
await authenticate();
|
||||||
const { data: album } = await api.albumApi.getAlbumInfo({ id: params.albumId, withoutAssets: true });
|
const album = await getAlbumInfo({ id: params.albumId, withoutAssets: true });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
album,
|
album,
|
||||||
|
@ -1,158 +0,0 @@
|
|||||||
import { notificationController, NotificationType } from '$lib/components/shared-components/notification/notification';
|
|
||||||
import { api, type CreateAlbumDto } from '@api';
|
|
||||||
import { albumFactory } from '@test-data';
|
|
||||||
import { get } from 'svelte/store';
|
|
||||||
import { useAlbums } from '../albums.bloc';
|
|
||||||
import type { MockedObject } from 'vitest';
|
|
||||||
|
|
||||||
vi.mock('@api');
|
|
||||||
|
|
||||||
const apiMock: MockedObject<typeof api> = api as MockedObject<typeof api>;
|
|
||||||
|
|
||||||
describe('Albums BLoC', () => {
|
|
||||||
let sut: ReturnType<typeof useAlbums>;
|
|
||||||
const _albums = albumFactory.buildList(5);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
sut = useAlbums({ albums: [..._albums] });
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
const notifications = get(notificationController.notificationList);
|
|
||||||
|
|
||||||
for (const notification of notifications) {
|
|
||||||
notificationController.removeNotificationById(notification.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('inits with provided albums', () => {
|
|
||||||
const albums = get(sut.albums);
|
|
||||||
expect(albums.length).toEqual(5);
|
|
||||||
expect(albums).toEqual(_albums);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('loads albums from the server', async () => {
|
|
||||||
// TODO: this method currently deletes albums with no assets and albumName === '' which might not be the best approach
|
|
||||||
const loadedAlbums = [..._albums, albumFactory.build({ id: 'new_loaded_uuid' })];
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
// TODO: there needs to be a more robust mock of the @api to avoid mockResolvedValueOnce ts error
|
|
||||||
// this is a workaround to make ts checks not fail but the test will pass as expected
|
|
||||||
apiMock.albumApi.getAllAlbums.mockResolvedValueOnce({
|
|
||||||
data: loadedAlbums,
|
|
||||||
config: {},
|
|
||||||
headers: {},
|
|
||||||
status: 200,
|
|
||||||
statusText: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
await sut.loadAlbums();
|
|
||||||
const albums = get(sut.albums);
|
|
||||||
|
|
||||||
expect(apiMock.albumApi.getAllAlbums).toHaveBeenCalledTimes(1);
|
|
||||||
expect(albums).toEqual(loadedAlbums);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('shows error message when it fails loading albums', async () => {
|
|
||||||
// TODO: implement APIProblem interface in the server
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
// TODO: there needs to be a more robust mock of the @api to avoid mockResolvedValueOnce ts error
|
|
||||||
// this is a workaround to make ts checks not fail but the test will pass as expected
|
|
||||||
apiMock.albumApi.getAllAlbums.mockRejectedValueOnce({});
|
|
||||||
|
|
||||||
expect(get(notificationController.notificationList)).toHaveLength(0);
|
|
||||||
await sut.loadAlbums();
|
|
||||||
const albums = get(sut.albums);
|
|
||||||
const notifications = get(notificationController.notificationList);
|
|
||||||
|
|
||||||
expect(apiMock.albumApi.getAllAlbums).toHaveBeenCalledTimes(2);
|
|
||||||
expect(albums).toEqual(_albums);
|
|
||||||
expect(notifications).toHaveLength(1);
|
|
||||||
expect(notifications[0].type).toEqual(NotificationType.Error);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('creates a new album', async () => {
|
|
||||||
const payload: CreateAlbumDto = {
|
|
||||||
albumName: '',
|
|
||||||
};
|
|
||||||
|
|
||||||
const returnedAlbum = albumFactory.build();
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
// TODO: there needs to be a more robust mock of the @api to avoid mockResolvedValueOnce ts error
|
|
||||||
// this is a workaround to make ts checks not fail but the test will pass as expected
|
|
||||||
apiMock.albumApi.createAlbum.mockResolvedValueOnce({
|
|
||||||
data: returnedAlbum,
|
|
||||||
config: {},
|
|
||||||
headers: {},
|
|
||||||
status: 200,
|
|
||||||
statusText: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const newAlbum = await sut.createAlbum();
|
|
||||||
|
|
||||||
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledTimes(1);
|
|
||||||
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledWith({ createAlbumDto: payload });
|
|
||||||
expect(newAlbum).toEqual(returnedAlbum);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('shows error message when it fails creating an album', async () => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
// TODO: there needs to be a more robust mock of the @api to avoid mockResolvedValueOnce ts error
|
|
||||||
// this is a workaround to make ts checks not fail but the test will pass as expected
|
|
||||||
apiMock.albumApi.createAlbum.mockRejectedValueOnce({});
|
|
||||||
|
|
||||||
const newAlbum = await sut.createAlbum();
|
|
||||||
const notifications = get(notificationController.notificationList);
|
|
||||||
|
|
||||||
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledTimes(2);
|
|
||||||
expect(newAlbum).not.toBeDefined();
|
|
||||||
expect(notifications).toHaveLength(1);
|
|
||||||
expect(notifications[0].type).toEqual(NotificationType.Error);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('selects an album and deletes it', async () => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
// TODO: there needs to be a more robust mock of the @api to avoid mockResolvedValueOnce ts error
|
|
||||||
// this is a workaround to make ts checks not fail but the test will pass as expected
|
|
||||||
apiMock.albumApi.deleteAlbum.mockResolvedValueOnce({
|
|
||||||
data: undefined,
|
|
||||||
config: {},
|
|
||||||
headers: {},
|
|
||||||
status: 200,
|
|
||||||
statusText: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const albumToDelete = get(sut.albums)[2]; // delete third album
|
|
||||||
const albumToDeleteId = albumToDelete.id;
|
|
||||||
const contextMenuCoords = { x: 100, y: 150 };
|
|
||||||
|
|
||||||
expect(get(sut.isShowContextMenu)).toBe(false);
|
|
||||||
sut.showAlbumContextMenu(contextMenuCoords, albumToDelete);
|
|
||||||
expect(get(sut.contextMenuPosition)).toEqual(contextMenuCoords);
|
|
||||||
expect(get(sut.isShowContextMenu)).toBe(true);
|
|
||||||
expect(get(sut.contextMenuTargetAlbum)).toEqual(albumToDelete);
|
|
||||||
|
|
||||||
await sut.deleteAlbum(albumToDelete);
|
|
||||||
const updatedAlbums = get(sut.albums);
|
|
||||||
|
|
||||||
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledTimes(1);
|
|
||||||
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledWith({ id: albumToDeleteId });
|
|
||||||
expect(updatedAlbums).toHaveLength(4);
|
|
||||||
expect(updatedAlbums).not.toContain(albumToDelete);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('closes album context menu, deselecting album', () => {
|
|
||||||
const albumToDelete = get(sut.albums)[2]; // delete third album
|
|
||||||
sut.showAlbumContextMenu({ x: 100, y: 150 }, albumToDelete);
|
|
||||||
|
|
||||||
expect(get(sut.isShowContextMenu)).toBe(true);
|
|
||||||
|
|
||||||
sut.closeAlbumContextMenu();
|
|
||||||
expect(get(sut.isShowContextMenu)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,6 +1,7 @@
|
|||||||
import type { OnShowContextMenuDetail } from '$lib/components/album-page/album-card';
|
import type { OnShowContextMenuDetail } from '$lib/components/album-page/album-card';
|
||||||
import { notificationController, NotificationType } from '$lib/components/shared-components/notification/notification';
|
import { notificationController, NotificationType } from '$lib/components/shared-components/notification/notification';
|
||||||
import { type AlbumResponseDto, api } from '@api';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { createAlbum, deleteAlbum, getAllAlbums, type AlbumResponseDto } from '@immich/sdk';
|
||||||
import { derived, get, writable } from 'svelte/store';
|
import { derived, get, writable } from 'svelte/store';
|
||||||
|
|
||||||
type AlbumsProperties = { albums: AlbumResponseDto[] };
|
type AlbumsProperties = { albums: AlbumResponseDto[] };
|
||||||
@ -13,14 +14,14 @@ export const useAlbums = (properties: AlbumsProperties) => {
|
|||||||
|
|
||||||
async function loadAlbums(): Promise<void> {
|
async function loadAlbums(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.albumApi.getAllAlbums();
|
const data = await getAllAlbums({});
|
||||||
albums.set(data);
|
albums.set(data);
|
||||||
|
|
||||||
// Delete album that has no photos and is named ''
|
// Delete album that has no photos and is named ''
|
||||||
for (const album of data) {
|
for (const album of data) {
|
||||||
if (album.albumName === '' && album.assetCount === 0) {
|
if (album.albumName === '' && album.assetCount === 0) {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await deleteAlbum(album);
|
await handleDeleteAlbum(album);
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,30 +33,17 @@ export const useAlbums = (properties: AlbumsProperties) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createAlbum(): Promise<AlbumResponseDto | undefined> {
|
async function handleCreateAlbum(): Promise<AlbumResponseDto | undefined> {
|
||||||
try {
|
try {
|
||||||
const { data: newAlbum } = await api.albumApi.createAlbum({
|
return await createAlbum({ createAlbumDto: { albumName: '' } });
|
||||||
createAlbumDto: {
|
} catch (error) {
|
||||||
albumName: '',
|
handleError(error, 'Unable to create album');
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return newAlbum;
|
|
||||||
} catch {
|
|
||||||
notificationController.show({
|
|
||||||
message: 'Error creating album',
|
|
||||||
type: NotificationType.Error,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteAlbum(albumToDelete: AlbumResponseDto): Promise<void> {
|
async function handleDeleteAlbum(albumToDelete: AlbumResponseDto): Promise<void> {
|
||||||
await api.albumApi.deleteAlbum({ id: albumToDelete.id });
|
await deleteAlbum({ id: albumToDelete.id });
|
||||||
albums.set(
|
albums.set(get(albums).filter(({ id }) => id !== albumToDelete.id));
|
||||||
get(albums).filter(({ id }) => {
|
|
||||||
return id !== albumToDelete.id;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showAlbumContextMenu(
|
async function showAlbumContextMenu(
|
||||||
@ -80,8 +68,8 @@ export const useAlbums = (properties: AlbumsProperties) => {
|
|||||||
contextMenuPosition,
|
contextMenuPosition,
|
||||||
contextMenuTargetAlbum,
|
contextMenuTargetAlbum,
|
||||||
loadAlbums,
|
loadAlbums,
|
||||||
createAlbum,
|
createAlbum: handleCreateAlbum,
|
||||||
deleteAlbum,
|
deleteAlbum: handleDeleteAlbum,
|
||||||
showAlbumContextMenu,
|
showAlbumContextMenu,
|
||||||
closeAlbumContextMenu,
|
closeAlbumContextMenu,
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getUserById } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async ({ params }) => {
|
export const load = (async ({ params }) => {
|
||||||
await authenticate();
|
await authenticate();
|
||||||
|
|
||||||
const { data: partner } = await api.userApi.getUserById({ id: params.userId });
|
const partner = await getUserById({ id: params.userId });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
partner,
|
partner,
|
||||||
|
@ -3,38 +3,25 @@
|
|||||||
import empty2Url from '$lib/assets/empty-2.svg';
|
import empty2Url from '$lib/assets/empty-2.svg';
|
||||||
import AlbumCard from '$lib/components/album-page/album-card.svelte';
|
import AlbumCard from '$lib/components/album-page/album-card.svelte';
|
||||||
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
||||||
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
|
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
|
||||||
import {
|
|
||||||
notificationController,
|
|
||||||
NotificationType,
|
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
|
||||||
import UserAvatar from '$lib/components/shared-components/user-avatar.svelte';
|
import UserAvatar from '$lib/components/shared-components/user-avatar.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import { api } from '@api';
|
import { createAlbum } from '@immich/sdk';
|
||||||
import { flip } from 'svelte/animate';
|
|
||||||
import type { PageData } from './$types';
|
|
||||||
import { mdiLink, mdiPlusBoxOutline } from '@mdi/js';
|
import { mdiLink, mdiPlusBoxOutline } from '@mdi/js';
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import { flip } from 'svelte/animate';
|
||||||
|
import { handleError } from '../../../lib/utils/handle-error';
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
const createSharedAlbum = async () => {
|
const createSharedAlbum = async () => {
|
||||||
try {
|
try {
|
||||||
const { data: newAlbum } = await api.albumApi.createAlbum({
|
const newAlbum = await createAlbum({ createAlbumDto: { albumName: '' } });
|
||||||
createAlbumDto: {
|
|
||||||
albumName: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
goto(`${AppRoute.ALBUMS}/${newAlbum.id}`);
|
goto(`${AppRoute.ALBUMS}/${newAlbum.id}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notificationController.show({
|
handleError(error, 'Unable to create album');
|
||||||
message: 'Error creating album, check console for more details',
|
|
||||||
type: NotificationType.Error,
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('Error [createAlbum]', error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getAllAlbums, getPartners } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
await authenticate();
|
await authenticate();
|
||||||
const { data: sharedAlbums } = await api.albumApi.getAllAlbums({ shared: true });
|
const sharedAlbums = await getAllAlbums({ shared: true });
|
||||||
const { data: partners } = await api.partnerApi.getPartners({ direction: 'shared-with' });
|
const partners = await getPartners({ direction: 'shared-with' });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sharedAlbums,
|
sharedAlbums,
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import empty3Url from '$lib/assets/empty-3.svg';
|
||||||
|
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
||||||
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
import DeleteAssets from '$lib/components/photos-page/actions/delete-assets.svelte';
|
import DeleteAssets from '$lib/components/photos-page/actions/delete-assets.svelte';
|
||||||
import RestoreAssets from '$lib/components/photos-page/actions/restore-assets.svelte';
|
import RestoreAssets from '$lib/components/photos-page/actions/restore-assets.svelte';
|
||||||
import SelectAllAssets from '$lib/components/photos-page/actions/select-all-assets.svelte';
|
import SelectAllAssets from '$lib/components/photos-page/actions/select-all-assets.svelte';
|
||||||
import AssetGrid from '$lib/components/photos-page/asset-grid.svelte';
|
import AssetGrid from '$lib/components/photos-page/asset-grid.svelte';
|
||||||
import AssetSelectControlBar from '$lib/components/photos-page/asset-select-control-bar.svelte';
|
import AssetSelectControlBar from '$lib/components/photos-page/asset-select-control-bar.svelte';
|
||||||
|
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
||||||
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
|
import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
|
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
|
||||||
import {
|
import {
|
||||||
NotificationType,
|
NotificationType,
|
||||||
notificationController,
|
notificationController,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
|
||||||
import { AssetStore } from '$lib/stores/assets.store';
|
|
||||||
import { api } from '@api';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
|
||||||
import type { PageData } from './$types';
|
|
||||||
import { featureFlags, serverConfig } from '$lib/stores/server-config.store';
|
|
||||||
import { goto } from '$app/navigation';
|
|
||||||
import empty3Url from '$lib/assets/empty-3.svg';
|
|
||||||
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
|
||||||
import { mdiDeleteOutline, mdiHistory } from '@mdi/js';
|
|
||||||
import UpdatePanel from '$lib/components/shared-components/update-panel.svelte';
|
import UpdatePanel from '$lib/components/shared-components/update-panel.svelte';
|
||||||
|
import { AppRoute } from '$lib/constants';
|
||||||
|
import { createAssetInteractionStore } from '$lib/stores/asset-interaction.store';
|
||||||
|
import { AssetStore } from '$lib/stores/assets.store';
|
||||||
|
import { featureFlags, serverConfig } from '$lib/stores/server-config.store';
|
||||||
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
|
import { emptyTrash, restoreTrash } from '@immich/sdk';
|
||||||
|
import { mdiDeleteOutline, mdiHistory } from '@mdi/js';
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@
|
|||||||
const handleEmptyTrash = async () => {
|
const handleEmptyTrash = async () => {
|
||||||
isShowEmptyConfirmation = false;
|
isShowEmptyConfirmation = false;
|
||||||
try {
|
try {
|
||||||
await api.trashApi.emptyTrash();
|
await emptyTrash();
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Empty trash initiated. Refresh the page to see the changes`,
|
message: `Empty trash initiated. Refresh the page to see the changes`,
|
||||||
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
const handleRestoreTrash = async () => {
|
const handleRestoreTrash = async () => {
|
||||||
try {
|
try {
|
||||||
await api.trashApi.restoreTrash();
|
await restoreTrash();
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: `Restore trash initiated. Refresh the page to see the changes`,
|
message: `Restore trash initiated. Refresh the page to see the changes`,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getApiKeys, getAuthDevices } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
await authenticate();
|
await authenticate();
|
||||||
|
|
||||||
const { data: keys } = await api.keyApi.getApiKeys();
|
const keys = await getApiKeys();
|
||||||
const { data: devices } = await api.authenticationApi.getAuthDevices();
|
const devices = await getAuthDevices();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
keys,
|
keys,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
|
import { getServerConfig } from '@immich/sdk';
|
||||||
import { redirect } from '@sveltejs/kit';
|
import { redirect } from '@sveltejs/kit';
|
||||||
import { api } from '../api';
|
|
||||||
import { loadUser } from '../lib/utils/auth';
|
import { loadUser } from '../lib/utils/auth';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
@ -13,8 +13,8 @@ export const load = (async () => {
|
|||||||
redirect(302, AppRoute.PHOTOS);
|
redirect(302, AppRoute.PHOTOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await api.serverInfoApi.getServerConfig();
|
const { isInitialized } = await getServerConfig();
|
||||||
if (data.isInitialized) {
|
if (isInitialized) {
|
||||||
// Redirect to login page if there exists an admin account (i.e. server is initialized)
|
// Redirect to login page if there exists an admin account (i.e. server is initialized)
|
||||||
redirect(302, AppRoute.AUTH_LOGIN);
|
redirect(302, AppRoute.AUTH_LOGIN);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import JobsPanel from '$lib/components/admin-page/jobs/jobs-panel.svelte';
|
import JobsPanel from '$lib/components/admin-page/jobs/jobs-panel.svelte';
|
||||||
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
||||||
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import { type AllJobStatusResponseDto, api } from '@api';
|
import { type AllJobStatusResponseDto } from '@api';
|
||||||
import { onDestroy, onMount } from 'svelte';
|
import { getAllJobsStatus } from '@immich/sdk';
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
|
||||||
import type { PageData } from './$types';
|
|
||||||
import { mdiCog } from '@mdi/js';
|
import { mdiCog } from '@mdi/js';
|
||||||
|
import { onDestroy, onMount } from 'svelte';
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
@ -16,8 +17,7 @@
|
|||||||
let jobs: AllJobStatusResponseDto;
|
let jobs: AllJobStatusResponseDto;
|
||||||
|
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
const { data } = await api.jobApi.getAllJobsStatus();
|
jobs = await getAllJobsStatus();
|
||||||
jobs = data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getAllJobsStatus } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
await authenticate({ admin: true });
|
await authenticate({ admin: true });
|
||||||
|
|
||||||
const { data: jobs } = await api.jobApi.getAllJobsStatus();
|
const jobs = await getAllJobsStatus();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
jobs,
|
jobs,
|
||||||
|
@ -11,10 +11,11 @@
|
|||||||
import { downloadManager } from '$lib/stores/download';
|
import { downloadManager } from '$lib/stores/download';
|
||||||
import { downloadBlob } from '$lib/utils/asset-utils';
|
import { downloadBlob } from '$lib/utils/asset-utils';
|
||||||
import { handleError } from '$lib/utils/handle-error';
|
import { handleError } from '$lib/utils/handle-error';
|
||||||
import { type FileReportItemDto, api, copyToClipboard } from '@api';
|
import { type FileReportItemDto, copyToClipboard } from '@api';
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
import { mdiWrench, mdiCheckAll, mdiDownload, mdiRefresh, mdiContentCopy } from '@mdi/js';
|
import { mdiWrench, mdiCheckAll, mdiDownload, mdiRefresh, mdiContentCopy } from '@mdi/js';
|
||||||
|
import { fixAuditFiles, getAuditFiles, getFileChecksums } from '@immich/sdk';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
@ -65,7 +66,7 @@
|
|||||||
repairing = true;
|
repairing = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.auditApi.fixAuditFiles({
|
await fixAuditFiles({
|
||||||
fileReportFixDto: {
|
fileReportFixDto: {
|
||||||
items: matches.map(({ orphan, extra }) => ({
|
items: matches.map(({ orphan, extra }) => ({
|
||||||
entityId: orphan.entityId,
|
entityId: orphan.entityId,
|
||||||
@ -101,7 +102,7 @@
|
|||||||
extras = [];
|
extras = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data: report } = await api.auditApi.getAuditFiles();
|
const report = await getAuditFiles();
|
||||||
|
|
||||||
orphans = report.orphans;
|
orphans = report.orphans;
|
||||||
extras = normalize(report.extras);
|
extras = normalize(report.extras);
|
||||||
@ -144,7 +145,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadAndMatch = async (filenames: string[]) => {
|
const loadAndMatch = async (filenames: string[]) => {
|
||||||
const { data: items } = await api.auditApi.getFileChecksums({
|
const items = await getFileChecksums({
|
||||||
fileChecksumDto: { filenames },
|
fileChecksumDto: { filenames },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getAuditFiles } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
await authenticate({ admin: true });
|
await authenticate({ admin: true });
|
||||||
const {
|
const { orphans, extras } = await getAuditFiles();
|
||||||
data: { orphans, extras },
|
|
||||||
} = await api.auditApi.getAuditFiles();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
orphans,
|
orphans,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import ServerStatsPanel from '$lib/components/admin-page/server-stats/server-stats-panel.svelte';
|
import ServerStatsPanel from '$lib/components/admin-page/server-stats/server-stats-panel.svelte';
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
import { api } from '@api';
|
import { getServerStatistics } from '@immich/sdk';
|
||||||
import { onDestroy, onMount } from 'svelte';
|
import { onDestroy, onMount } from 'svelte';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
setIntervalHandler = setInterval(async () => {
|
setIntervalHandler = setInterval(async () => {
|
||||||
const { data: stats } = await api.serverInfoApi.getServerStatistics();
|
data.stats = await getServerStatistics();
|
||||||
data.stats = stats;
|
|
||||||
}, 5000);
|
}, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getServerStatistics } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
await authenticate({ admin: true });
|
await authenticate({ admin: true });
|
||||||
const { data: stats } = await api.serverInfoApi.getServerStatistics();
|
const stats = await getServerStatistics();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
stats,
|
stats,
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getConfig } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
await authenticate({ admin: true });
|
await authenticate({ admin: true });
|
||||||
const { data: configs } = await api.systemConfigApi.getConfig();
|
const configs = await getConfig();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configs,
|
configs,
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api, type UserResponseDto } from '@api';
|
import { page } from '$app/stores';
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import Icon from '$lib/components/elements/icon.svelte';
|
|
||||||
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
|
|
||||||
import CreateUserForm from '$lib/components/forms/create-user-form.svelte';
|
|
||||||
import EditUserForm from '$lib/components/forms/edit-user-form.svelte';
|
|
||||||
import DeleteConfirmDialog from '$lib/components/admin-page/delete-confirm-dialoge.svelte';
|
import DeleteConfirmDialog from '$lib/components/admin-page/delete-confirm-dialoge.svelte';
|
||||||
import RestoreDialogue from '$lib/components/admin-page/restore-dialoge.svelte';
|
import RestoreDialogue from '$lib/components/admin-page/restore-dialoge.svelte';
|
||||||
import { page } from '$app/stores';
|
|
||||||
import { locale } from '$lib/stores/preferences.store';
|
|
||||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||||
|
import Icon from '$lib/components/elements/icon.svelte';
|
||||||
|
import CreateUserForm from '$lib/components/forms/create-user-form.svelte';
|
||||||
|
import EditUserForm from '$lib/components/forms/edit-user-form.svelte';
|
||||||
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
||||||
import type { PageData } from './$types';
|
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
|
||||||
import { mdiCheck, mdiClose, mdiDeleteRestore, mdiPencilOutline, mdiTrashCanOutline } from '@mdi/js';
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
import { user } from '$lib/stores/user.store';
|
import { user } from '$lib/stores/user.store';
|
||||||
import { asByteUnitString } from '$lib/utils/byte-units';
|
import { asByteUnitString } from '$lib/utils/byte-units';
|
||||||
|
import { getAllUsers, type UserResponseDto } from '@immich/sdk';
|
||||||
|
import { mdiCheck, mdiClose, mdiDeleteRestore, mdiPencilOutline, mdiTrashCanOutline } from '@mdi/js';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
@ -47,8 +47,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onUserCreated = async () => {
|
const onUserCreated = async () => {
|
||||||
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
|
allUsers = await getAllUsers({ isAll: false });
|
||||||
allUsers = getAllUsersRes.data;
|
|
||||||
shouldShowCreateUserForm = false;
|
shouldShowCreateUserForm = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,14 +57,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onEditUserSuccess = async () => {
|
const onEditUserSuccess = async () => {
|
||||||
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
|
allUsers = await getAllUsers({ isAll: false });
|
||||||
allUsers = getAllUsersRes.data;
|
|
||||||
shouldShowEditUserForm = false;
|
shouldShowEditUserForm = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onEditPasswordSuccess = async () => {
|
const onEditPasswordSuccess = async () => {
|
||||||
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
|
allUsers = await getAllUsers({ isAll: false });
|
||||||
allUsers = getAllUsersRes.data;
|
|
||||||
shouldShowEditUserForm = false;
|
shouldShowEditUserForm = false;
|
||||||
shouldShowInfoPanel = true;
|
shouldShowInfoPanel = true;
|
||||||
};
|
};
|
||||||
@ -76,14 +73,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onUserDeleteSuccess = async () => {
|
const onUserDeleteSuccess = async () => {
|
||||||
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
|
allUsers = await getAllUsers({ isAll: false });
|
||||||
allUsers = getAllUsersRes.data;
|
|
||||||
shouldShowDeleteConfirmDialog = false;
|
shouldShowDeleteConfirmDialog = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onUserDeleteFail = async () => {
|
const onUserDeleteFail = async () => {
|
||||||
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
|
allUsers = await getAllUsers({ isAll: false });
|
||||||
allUsers = getAllUsersRes.data;
|
|
||||||
shouldShowDeleteConfirmDialog = false;
|
shouldShowDeleteConfirmDialog = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,15 +88,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onUserRestoreSuccess = async () => {
|
const onUserRestoreSuccess = async () => {
|
||||||
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
|
allUsers = await getAllUsers({ isAll: false });
|
||||||
allUsers = getAllUsersRes.data;
|
|
||||||
shouldShowRestoreDialog = false;
|
shouldShowRestoreDialog = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onUserRestoreFail = async () => {
|
const onUserRestoreFail = async () => {
|
||||||
// show fail dialog
|
// show fail dialog
|
||||||
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
|
allUsers = await getAllUsers({ isAll: false });
|
||||||
allUsers = getAllUsersRes.data;
|
|
||||||
shouldShowRestoreDialog = false;
|
shouldShowRestoreDialog = false;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { authenticate, requestServerInfo } from '$lib/utils/auth';
|
import { authenticate, requestServerInfo } from '$lib/utils/auth';
|
||||||
import { api } from '@api';
|
import { getAllUsers } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
await authenticate({ admin: true });
|
await authenticate({ admin: true });
|
||||||
await requestServerInfo();
|
await requestServerInfo();
|
||||||
const { data: allUsers } = await api.userApi.getAllUsers({ isAll: false });
|
const allUsers = await getAllUsers({ isAll: false });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
allUsers,
|
allUsers,
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import { featureFlags, serverConfig } from '$lib/stores/server-config.store';
|
import { featureFlags, serverConfig } from '$lib/stores/server-config.store';
|
||||||
import { resetSavedUser } from '$lib/stores/user.store';
|
import { resetSavedUser } from '$lib/stores/user.store';
|
||||||
import { api } from '@api';
|
import { logout } from '@immich/sdk';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
@ -13,7 +13,7 @@
|
|||||||
afterNavigate(async ({ from }) => {
|
afterNavigate(async ({ from }) => {
|
||||||
if (from?.url?.pathname === AppRoute.AUTH_CHANGE_PASSWORD) {
|
if (from?.url?.pathname === AppRoute.AUTH_CHANGE_PASSWORD) {
|
||||||
resetSavedUser();
|
resetSavedUser();
|
||||||
await api.authenticationApi.logout();
|
await logout();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import { api } from '@api';
|
import { getServerConfig } from '@immich/sdk';
|
||||||
import { redirect } from '@sveltejs/kit';
|
import { redirect } from '@sveltejs/kit';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
const { data } = await api.serverInfoApi.getServerConfig();
|
const { isInitialized } = await getServerConfig();
|
||||||
if (!data.isInitialized) {
|
if (!isInitialized) {
|
||||||
// Admin not registered
|
// Admin not registered
|
||||||
redirect(302, AppRoute.AUTH_REGISTER);
|
redirect(302, AppRoute.AUTH_REGISTER);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import OnboardingHello from '$lib/components/onboarding-page/onboarding-hello.svelte';
|
|
||||||
import OnboardingTheme from '$lib/components/onboarding-page/onboarding-theme.svelte';
|
|
||||||
import OnboadingStorageTemplate from '$lib/components/onboarding-page/onboarding-storage-template.svelte';
|
|
||||||
import { api } from '@api';
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { AppRoute, QueryParameter } from '$lib/constants';
|
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
import OnboardingHello from '$lib/components/onboarding-page/onboarding-hello.svelte';
|
||||||
|
import OnboadingStorageTemplate from '$lib/components/onboarding-page/onboarding-storage-template.svelte';
|
||||||
|
import OnboardingTheme from '$lib/components/onboarding-page/onboarding-theme.svelte';
|
||||||
|
import { AppRoute, QueryParameter } from '$lib/constants';
|
||||||
|
import { setAdminOnboarding } from '@immich/sdk';
|
||||||
|
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
const handleDoneClicked = async () => {
|
const handleDoneClicked = async () => {
|
||||||
if (index >= onboardingSteps.length - 1) {
|
if (index >= onboardingSteps.length - 1) {
|
||||||
await api.serverInfoApi.setAdminOnboarding();
|
await setAdminOnboarding();
|
||||||
goto(AppRoute.PHOTOS);
|
goto(AppRoute.PHOTOS);
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
import { api } from '@api';
|
import { getServerConfig } from '@immich/sdk';
|
||||||
import { redirect } from '@sveltejs/kit';
|
import { redirect } from '@sveltejs/kit';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async () => {
|
export const load = (async () => {
|
||||||
const { data } = await api.serverInfoApi.getServerConfig();
|
const { isInitialized } = await getServerConfig();
|
||||||
if (data.isInitialized) {
|
if (isInitialized) {
|
||||||
// Admin has been registered, redirect to login
|
// Admin has been registered, redirect to login
|
||||||
redirect(302, AppRoute.AUTH_LOGIN);
|
redirect(302, AppRoute.AUTH_LOGIN);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user