mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(web): add types to dispatcher (#5700)
* feat: add types to dispatcher * fix: create album name * pr feedback * pr feedback * pr feedback * fix: api key name * remove newSharedAlbum * pr feedback * fix: api key creation * on:close * fix: owner * fix: onclose * remove unused code --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
502495883d
commit
4c5397d7e6
41 changed files with 199 additions and 130 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { api, UpdateLibraryDto, LibraryResponseDto, LibraryType, LibraryStatsResponseDto } from '@api';
|
||||
import { api, LibraryResponseDto, LibraryType, LibraryStatsResponseDto } from '@api';
|
||||
import { onMount } from 'svelte';
|
||||
import Button from '../elements/buttons/button.svelte';
|
||||
import { notificationController, NotificationType } from '../shared-components/notification/notification';
|
||||
|
|
@ -112,16 +112,15 @@
|
|||
}
|
||||
};
|
||||
|
||||
const handleUpdate = async (event: CustomEvent<UpdateLibraryDto>) => {
|
||||
const handleUpdate = async (event: Partial<LibraryResponseDto>) => {
|
||||
if (updateLibraryIndex === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const dto = event.detail;
|
||||
const libraryId = libraries[updateLibraryIndex].id;
|
||||
|
||||
await api.libraryApi.updateLibrary({ id: libraryId, updateLibraryDto: dto });
|
||||
await api.libraryApi.updateLibrary({ id: libraryId, updateLibraryDto: { ...event } });
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to update library');
|
||||
} finally {
|
||||
|
|
@ -375,19 +374,27 @@
|
|||
</tr>
|
||||
{#if renameLibrary === index}
|
||||
<div transition:slide={{ duration: 250 }}>
|
||||
<LibraryRenameForm {library} on:submit={handleUpdate} on:cancel={() => (renameLibrary = null)} />
|
||||
<LibraryRenameForm
|
||||
{library}
|
||||
on:submit={({ detail }) => handleUpdate(detail)}
|
||||
on:cancel={() => (renameLibrary = null)}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{#if editImportPaths === index}
|
||||
<div transition:slide={{ duration: 250 }}>
|
||||
<LibraryImportPathsForm {library} on:submit={handleUpdate} on:cancel={() => (editImportPaths = null)} />
|
||||
<LibraryImportPathsForm
|
||||
{library}
|
||||
on:submit={({ detail }) => handleUpdate(detail)}
|
||||
on:cancel={() => (editImportPaths = null)}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{#if editScanSettings === index}
|
||||
<div transition:slide={{ duration: 250 }} class="mb-4 ml-4 mr-4">
|
||||
<LibraryScanSettingsForm
|
||||
{library}
|
||||
on:submit={handleUpdate}
|
||||
on:submit={({ detail }) => handleUpdate(detail)}
|
||||
on:cancel={() => (editScanSettings = null)}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -29,10 +29,9 @@
|
|||
keys = data;
|
||||
}
|
||||
|
||||
const handleCreate = async (event: CustomEvent<APIKeyResponseDto>) => {
|
||||
const handleCreate = async (detail: Partial<APIKeyResponseDto>) => {
|
||||
try {
|
||||
const dto = event.detail;
|
||||
const { data } = await api.keyApi.createApiKey({ aPIKeyCreateDto: dto });
|
||||
const { data } = await api.keyApi.createApiKey({ aPIKeyCreateDto: detail });
|
||||
secret = data.secret;
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to create a new API Key');
|
||||
|
|
@ -42,15 +41,13 @@
|
|||
}
|
||||
};
|
||||
|
||||
const handleUpdate = async (event: CustomEvent<APIKeyResponseDto>) => {
|
||||
if (!editKey) {
|
||||
const handleUpdate = async (detail: Partial<APIKeyResponseDto>) => {
|
||||
if (!editKey || !detail.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dto = event.detail;
|
||||
|
||||
try {
|
||||
await api.keyApi.updateApiKey({ id: editKey.id, aPIKeyUpdateDto: { name: dto.name } });
|
||||
await api.keyApi.updateApiKey({ id: editKey.id, aPIKeyUpdateDto: { name: detail.name } });
|
||||
notificationController.show({
|
||||
message: `Saved API Key`,
|
||||
type: NotificationType.Info,
|
||||
|
|
@ -88,7 +85,7 @@
|
|||
title="New API Key"
|
||||
submitText="Create"
|
||||
apiKey={newKey}
|
||||
on:submit={handleCreate}
|
||||
on:submit={({ detail }) => handleCreate(detail)}
|
||||
on:cancel={() => (newKey = null)}
|
||||
/>
|
||||
{/if}
|
||||
|
|
@ -98,7 +95,12 @@
|
|||
{/if}
|
||||
|
||||
{#if editKey}
|
||||
<APIKeyForm submitText="Save" apiKey={editKey} on:submit={handleUpdate} on:cancel={() => (editKey = null)} />
|
||||
<APIKeyForm
|
||||
submitText="Save"
|
||||
apiKey={editKey}
|
||||
on:submit={({ detail }) => handleUpdate(detail)}
|
||||
on:cancel={() => (editKey = null)}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if deleteKey}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue