mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:17:11 -05:00 
			
		
		
		
	feat: confirm before deleting all faces and people (#2496)
This commit is contained in:
		
							parent
							
								
									a1183f4b4b
								
							
						
					
					
						commit
						a089d9891d
					
				@ -8,17 +8,35 @@
 | 
				
			|||||||
	import type { ComponentType } from 'svelte';
 | 
						import type { ComponentType } from '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 ConfirmDialogue from '../../shared-components/confirm-dialogue.svelte';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	export let jobs: AllJobStatusResponseDto;
 | 
						export let jobs: AllJobStatusResponseDto;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	type JobDetails = {
 | 
						interface JobDetails {
 | 
				
			||||||
		title: string;
 | 
							title: string;
 | 
				
			||||||
		subtitle?: string;
 | 
							subtitle?: string;
 | 
				
			||||||
		allowForceCommand?: boolean;
 | 
							allowForceCommand?: boolean;
 | 
				
			||||||
		component?: ComponentType;
 | 
							component?: ComponentType;
 | 
				
			||||||
 | 
							handleCommand?: (jobId: JobName, jobCommand: JobCommandDto) => Promise<void>;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						let faceConfirm = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const handleFaceCommand = async (jobId: JobName, dto: JobCommandDto) => {
 | 
				
			||||||
 | 
							if (dto.force) {
 | 
				
			||||||
 | 
								faceConfirm = true;
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							await handleCommand(jobId, dto);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const jobDetails: { [Key in JobName]?: JobDetails } = {
 | 
						const onFaceConfirm = () => {
 | 
				
			||||||
 | 
							faceConfirm = false;
 | 
				
			||||||
 | 
							handleCommand(JobName.RecognizeFacesQueue, { command: JobCommand.Start, force: true });
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const jobDetails: Partial<Record<JobName, JobDetails>> = {
 | 
				
			||||||
		[JobName.ThumbnailGenerationQueue]: {
 | 
							[JobName.ThumbnailGenerationQueue]: {
 | 
				
			||||||
			title: 'Generate Thumbnails',
 | 
								title: 'Generate Thumbnails',
 | 
				
			||||||
			subtitle: 'Regenerate JPEG and WebP thumbnails'
 | 
								subtitle: 'Regenerate JPEG and WebP thumbnails'
 | 
				
			||||||
@ -38,7 +56,8 @@
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		[JobName.RecognizeFacesQueue]: {
 | 
							[JobName.RecognizeFacesQueue]: {
 | 
				
			||||||
			title: 'Recognize Faces',
 | 
								title: 'Recognize Faces',
 | 
				
			||||||
			subtitle: 'Run machine learning to recognize faces'
 | 
								subtitle: 'Run machine learning to recognize faces',
 | 
				
			||||||
 | 
								handleCommand: handleFaceCommand
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		[JobName.VideoConversionQueue]: {
 | 
							[JobName.VideoConversionQueue]: {
 | 
				
			||||||
			title: 'Transcode Videos',
 | 
								title: 'Transcode Videos',
 | 
				
			||||||
@ -53,7 +72,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	const jobDetailsArray = Object.entries(jobDetails) as [JobName, JobDetails][];
 | 
						const jobDetailsArray = Object.entries(jobDetails) as [JobName, JobDetails][];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	async function runJob(jobId: JobName, jobCommand: JobCommandDto) {
 | 
						async function handleCommand(jobId: JobName, jobCommand: JobCommandDto) {
 | 
				
			||||||
		const title = jobDetails[jobId]?.title;
 | 
							const title = jobDetails[jobId]?.title;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
@ -74,8 +93,16 @@
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{#if faceConfirm}
 | 
				
			||||||
 | 
						<ConfirmDialogue
 | 
				
			||||||
 | 
							prompt="Are you sure you want to reprocess all faces? This will also clear named people."
 | 
				
			||||||
 | 
							on:confirm={onFaceConfirm}
 | 
				
			||||||
 | 
							on:cancel={() => (faceConfirm = false)}
 | 
				
			||||||
 | 
						/>
 | 
				
			||||||
 | 
					{/if}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="flex flex-col gap-7">
 | 
					<div class="flex flex-col gap-7">
 | 
				
			||||||
	{#each jobDetailsArray as [jobName, { title, subtitle, allowForceCommand, component }]}
 | 
						{#each jobDetailsArray as [jobName, { title, subtitle, allowForceCommand, component, handleCommand: handleCommandOverride }]}
 | 
				
			||||||
		{@const { jobCounts, queueStatus } = jobs[jobName]}
 | 
							{@const { jobCounts, queueStatus } = jobs[jobName]}
 | 
				
			||||||
		<JobTile
 | 
							<JobTile
 | 
				
			||||||
			{title}
 | 
								{title}
 | 
				
			||||||
@ -83,7 +110,7 @@
 | 
				
			|||||||
			{allowForceCommand}
 | 
								{allowForceCommand}
 | 
				
			||||||
			{jobCounts}
 | 
								{jobCounts}
 | 
				
			||||||
			{queueStatus}
 | 
								{queueStatus}
 | 
				
			||||||
			on:command={({ detail }) => runJob(jobName, detail)}
 | 
								on:command={({ detail }) => (handleCommandOverride || handleCommand)(jobName, detail)}
 | 
				
			||||||
		>
 | 
							>
 | 
				
			||||||
			<svelte:component this={component} />
 | 
								<svelte:component this={component} />
 | 
				
			||||||
		</JobTile>
 | 
							</JobTile>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user