mirror of
https://github.com/immich-app/immich.git
synced 2025-06-02 21:24:28 -04:00
* fix(web): show warning on duplicate uploads #2557 * Prettier fix * color --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
57a7103d75
commit
66b2ad7939
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
let infoPrimaryColor = '#4250AF';
|
let infoPrimaryColor = '#4250AF';
|
||||||
let errorPrimaryColor = '#E64132';
|
let errorPrimaryColor = '#E64132';
|
||||||
|
let warningPrimaryColor = '#D08613';
|
||||||
|
|
||||||
$: icon = notificationInfo.type === NotificationType.Error ? CloseCircleOutline : InformationOutline;
|
$: icon = notificationInfo.type === NotificationType.Error ? CloseCircleOutline : InformationOutline;
|
||||||
|
|
||||||
@ -26,6 +27,10 @@
|
|||||||
if (notificationInfo.type === NotificationType.Error) {
|
if (notificationInfo.type === NotificationType.Error) {
|
||||||
return '#FBE8E6';
|
return '#FBE8E6';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notificationInfo.type === NotificationType.Warning) {
|
||||||
|
return '#FFF6DC';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$: borderStyle = () => {
|
$: borderStyle = () => {
|
||||||
@ -36,6 +41,10 @@
|
|||||||
if (notificationInfo.type === NotificationType.Error) {
|
if (notificationInfo.type === NotificationType.Error) {
|
||||||
return '1px solid #F0E8E7';
|
return '1px solid #F0E8E7';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notificationInfo.type === NotificationType.Warning) {
|
||||||
|
return '1px solid #FFE6A5';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$: primaryColor = () => {
|
$: primaryColor = () => {
|
||||||
@ -46,6 +55,10 @@
|
|||||||
if (notificationInfo.type === NotificationType.Error) {
|
if (notificationInfo.type === NotificationType.Error) {
|
||||||
return errorPrimaryColor;
|
return errorPrimaryColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notificationInfo.type === NotificationType.Warning) {
|
||||||
|
return warningPrimaryColor;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let removeNotificationTimeout: NodeJS.Timeout | undefined = undefined;
|
let removeNotificationTimeout: NodeJS.Timeout | undefined = undefined;
|
||||||
|
@ -3,10 +3,11 @@ import { writable } from 'svelte/store';
|
|||||||
export enum NotificationType {
|
export enum NotificationType {
|
||||||
Info = 'Info',
|
Info = 'Info',
|
||||||
Error = 'Error',
|
Error = 'Error',
|
||||||
|
Warning = 'Warning',
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ImmichNotification {
|
export class ImmichNotification {
|
||||||
id = new Date().getTime();
|
id = new Date().getTime() + Math.random();
|
||||||
type!: NotificationType;
|
type!: NotificationType;
|
||||||
message!: string;
|
message!: string;
|
||||||
action!: NotificationAction;
|
action!: NotificationAction;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
let showDetail = true;
|
let showDetail = true;
|
||||||
let uploadLength = 0;
|
let uploadLength = 0;
|
||||||
|
let duplicateCount = 0;
|
||||||
let isUploading = false;
|
let isUploading = false;
|
||||||
|
|
||||||
// Reactive action to update asset uploadLength whenever there is a new one added to the list
|
// Reactive action to update asset uploadLength whenever there is a new one added to the list
|
||||||
@ -21,6 +22,10 @@
|
|||||||
uploadAssetsStore.isUploading.subscribe((value) => {
|
uploadAssetsStore.isUploading.subscribe((value) => {
|
||||||
isUploading = value;
|
isUploading = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
uploadAssetsStore.duplicateCounter.subscribe((value) => {
|
||||||
|
duplicateCount = value;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isUploading}
|
{#if isUploading}
|
||||||
@ -32,6 +37,13 @@
|
|||||||
message: 'Upload success, refresh the page to see new upload assets',
|
message: 'Upload success, refresh the page to see new upload assets',
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
});
|
});
|
||||||
|
if (duplicateCount > 0) {
|
||||||
|
notificationController.show({
|
||||||
|
message: `Skipped ${duplicateCount} duplicate picture${duplicateCount > 1 ? 's' : ''}`,
|
||||||
|
type: NotificationType.Warning,
|
||||||
|
});
|
||||||
|
uploadAssetsStore.duplicateCounter.set(0);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
class="absolute bottom-6 right-6 z-[10000]"
|
class="absolute bottom-6 right-6 z-[10000]"
|
||||||
>
|
>
|
||||||
|
@ -3,6 +3,7 @@ import type { UploadAsset } from '../models/upload-asset';
|
|||||||
|
|
||||||
function createUploadStore() {
|
function createUploadStore() {
|
||||||
const uploadAssets = writable<Array<UploadAsset>>([]);
|
const uploadAssets = writable<Array<UploadAsset>>([]);
|
||||||
|
const duplicateCounter = writable(0);
|
||||||
|
|
||||||
const { subscribe } = uploadAssets;
|
const { subscribe } = uploadAssets;
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ function createUploadStore() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
|
duplicateCounter,
|
||||||
isUploading,
|
isUploading,
|
||||||
addNewUploadAsset,
|
addNewUploadAsset,
|
||||||
updateProgress,
|
updateProgress,
|
||||||
|
@ -151,6 +151,10 @@ async function fileUploader(
|
|||||||
if (response.status == 200 || response.status == 201) {
|
if (response.status == 200 || response.status == 201) {
|
||||||
const res: AssetFileUploadResponseDto = response.data;
|
const res: AssetFileUploadResponseDto = response.data;
|
||||||
|
|
||||||
|
if (res.duplicate) {
|
||||||
|
uploadAssetsStore.duplicateCounter.update((count) => count + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (albumId && res.id) {
|
if (albumId && res.id) {
|
||||||
await addAssetsToAlbum(albumId, [res.id], sharedKey);
|
await addAssetsToAlbum(albumId, [res.id], sharedKey);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user