mirror of
https://github.com/immich-app/immich.git
synced 2025-01-22 11:42:46 +01:00
Added limit on total of file upload on web (#535)
This commit is contained in:
parent
87f7b0849a
commit
5ad2d62039
5 changed files with 31 additions and 14 deletions
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ImmichNotification,
|
ImmichNotification,
|
||||||
notificationList,
|
notificationController,
|
||||||
NotificationType
|
NotificationType
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
@ -50,8 +50,8 @@
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
notificationList.removeNotificationById(notificationInfo.id);
|
notificationController.removeNotificationById(notificationInfo.id);
|
||||||
}, 2500);
|
}, 3000);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -66,5 +66,5 @@
|
||||||
<h2 style:color={primaryColor()} class="font-medium">{notificationInfo.type.toString()}</h2>
|
<h2 style:color={primaryColor()} class="font-medium">{notificationInfo.type.toString()}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="text-sm pl-[28px] pr-[16px]">{notificationInfo.message} {notificationInfo.id}</p>
|
<p class="text-sm pl-[28px] pr-[16px]">{notificationInfo.message}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { notificationList } from './notification';
|
import { ImmichNotification, notificationController } from './notification';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
|
|
||||||
import NotificationCard from './notification-card.svelte';
|
import NotificationCard from './notification-card.svelte';
|
||||||
import { flip } from 'svelte/animate';
|
import { flip } from 'svelte/animate';
|
||||||
import { quintOut } from 'svelte/easing';
|
import { quintOut } from 'svelte/easing';
|
||||||
|
|
||||||
|
let notificationList: ImmichNotification[] = [];
|
||||||
|
|
||||||
|
notificationController.notificationList.subscribe((list) => {
|
||||||
|
notificationList = list;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $notificationList?.length > 0}
|
{#if notificationList.length > 0}
|
||||||
<section
|
<section
|
||||||
transition:fade={{ duration: 250 }}
|
transition:fade={{ duration: 250 }}
|
||||||
id="notification-list"
|
id="notification-list"
|
||||||
class="absolute right-5 top-[80px] z-[99999999]"
|
class="absolute right-5 top-[80px] z-[99999999]"
|
||||||
>
|
>
|
||||||
{#each $notificationList as notificationInfo (notificationInfo.id)}
|
{#each notificationList as notificationInfo (notificationInfo.id)}
|
||||||
<div animate:flip={{ duration: 250, easing: quintOut }}>
|
<div animate:flip={{ duration: 250, easing: quintOut }}>
|
||||||
<NotificationCard {notificationInfo} />
|
<NotificationCard {notificationInfo} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,25 +12,25 @@ export class ImmichNotification {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNotificationList() {
|
function createNotificationList() {
|
||||||
const { set, update, subscribe } = writable<ImmichNotification[]>([]);
|
const notificationList = writable<ImmichNotification[]>([]);
|
||||||
|
|
||||||
const show = ({ message = '', type = NotificationType.Info }) => {
|
const show = ({ message = '', type = NotificationType.Info }) => {
|
||||||
const notification = new ImmichNotification();
|
const notification = new ImmichNotification();
|
||||||
notification.message = message;
|
notification.message = message;
|
||||||
notification.type = type;
|
notification.type = type;
|
||||||
|
|
||||||
update((currentList) => [...currentList, notification]);
|
notificationList.update((currentList) => [...currentList, notification]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeNotificationById = (id: number) => {
|
const removeNotificationById = (id: number) => {
|
||||||
update((currentList) => currentList.filter((n) => n.id != id));
|
notificationList.update((currentList) => currentList.filter((n) => n.id != id));
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
show,
|
show,
|
||||||
removeNotificationById,
|
removeNotificationById,
|
||||||
subscribe
|
notificationList
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const notificationList = createNotificationList();
|
export const notificationController = createNotificationList();
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
|
import {
|
||||||
|
notificationController,
|
||||||
|
NotificationType
|
||||||
|
} from './../components/shared-components/notification/notification';
|
||||||
/* @vite-ignore */
|
/* @vite-ignore */
|
||||||
import * as exifr from 'exifr';
|
import * as exifr from 'exifr';
|
||||||
import { uploadAssetsStore } from '$lib/stores/upload';
|
import { uploadAssetsStore } from '$lib/stores/upload';
|
||||||
import type { UploadAsset } from '../models/upload-asset';
|
import type { UploadAsset } from '../models/upload-asset';
|
||||||
import { api, AssetFileUploadResponseDto } from '@api';
|
import { api, AssetFileUploadResponseDto } from '@api';
|
||||||
import { albumUploadAssetStore } from '$lib/stores/album-upload-asset';
|
import { albumUploadAssetStore } from '$lib/stores/album-upload-asset';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the upload is for album or for the user general backup
|
* Determine if the upload is for album or for the user general backup
|
||||||
* @variant GENERAL - Upload assets to the server for general backup
|
* @variant GENERAL - Upload assets to the server for general backup
|
||||||
|
@ -33,6 +36,15 @@ export const openFileUploadDialog = (uploadType: UploadType) => {
|
||||||
fileSelector.onchange = async (e: any) => {
|
fileSelector.onchange = async (e: any) => {
|
||||||
const files = Array.from<File>(e.target.files);
|
const files = Array.from<File>(e.target.files);
|
||||||
|
|
||||||
|
if (files.length > 50) {
|
||||||
|
notificationController.show({
|
||||||
|
message: `Cannot upload more than 50 files at a time - you are uploading ${files.length} files`,
|
||||||
|
type: NotificationType.Error
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const acceptedFile = files.filter(
|
const acceptedFile = files.filter(
|
||||||
(e) => e.type.split('/')[0] === 'video' || e.type.split('/')[0] === 'image'
|
(e) => e.type.split('/')[0] === 'video' || e.type.split('/')[0] === 'image'
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { redirect } from '@sveltejs/kit';
|
||||||
import { api } from '@api';
|
import { api } from '@api';
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/env';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
import { goto } from '$app/navigation';
|
|
||||||
|
|
||||||
export const load: PageLoad = async ({ parent }) => {
|
export const load: PageLoad = async ({ parent }) => {
|
||||||
const { user } = await parent();
|
const { user } = await parent();
|
||||||
|
|
Loading…
Reference in a new issue