mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: review suggestions for web/../integrity.service.ts
Signed-off-by: izzy <me@insrt.uk>
This commit is contained in:
@@ -11,7 +11,7 @@ export const getIntegrityReportActions = ($t: MessageFormatter, reportType: Inte
|
|||||||
type: $t('command'),
|
type: $t('command'),
|
||||||
title: $t('admin.download_csv'),
|
title: $t('admin.download_csv'),
|
||||||
icon: mdiDownload,
|
icon: mdiDownload,
|
||||||
onAction() {
|
onAction: () => {
|
||||||
handleDownloadIntegrityReportCsv(reportType);
|
handleDownloadIntegrityReportCsv(reportType);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -21,7 +21,7 @@ export const getIntegrityReportActions = ($t: MessageFormatter, reportType: Inte
|
|||||||
title: $t('trash_page_delete_all'),
|
title: $t('trash_page_delete_all'),
|
||||||
icon: mdiTrashCanOutline,
|
icon: mdiTrashCanOutline,
|
||||||
color: 'danger',
|
color: 'danger',
|
||||||
onAction() {
|
onAction: () => {
|
||||||
void handleRemoveAllIntegrityReportItems(reportType);
|
void handleRemoveAllIntegrityReportItems(reportType);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -34,22 +34,20 @@ export const getIntegrityReportItemActions = (
|
|||||||
reportId: string,
|
reportId: string,
|
||||||
reportType: IntegrityReportType,
|
reportType: IntegrityReportType,
|
||||||
) => {
|
) => {
|
||||||
const Download =
|
const Download = {
|
||||||
reportType === IntegrityReportType.UntrackedFile || reportType === IntegrityReportType.ChecksumMismatch
|
title: $t('download'),
|
||||||
? {
|
icon: mdiDownload,
|
||||||
title: $t('download'),
|
onAction: () => {
|
||||||
icon: mdiDownload,
|
void handleDownloadIntegrityReportFile(reportId);
|
||||||
onAction() {
|
},
|
||||||
void handleDownloadIntegrityReportFile(reportId);
|
$if: reportType === IntegrityReportType.UntrackedFile || reportType === IntegrityReportType.ChecksumMismatch,
|
||||||
},
|
};
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const Delete = {
|
const Delete = {
|
||||||
title: $t('delete'),
|
title: $t('delete'),
|
||||||
icon: mdiTrashCanOutline,
|
icon: mdiTrashCanOutline,
|
||||||
color: 'danger',
|
color: 'danger',
|
||||||
onAction() {
|
onAction: () => {
|
||||||
void handleRemoveIntegrityReportItem(reportId);
|
void handleRemoveIntegrityReportItem(reportId);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -71,43 +69,45 @@ export const handleRemoveAllIntegrityReportItems = async (reportType: IntegrityR
|
|||||||
confirmText: $t('delete'),
|
confirmText: $t('delete'),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (confirm) {
|
if (!confirm) {
|
||||||
let name: ManualJobName;
|
return;
|
||||||
switch (reportType) {
|
}
|
||||||
case IntegrityReportType.UntrackedFile: {
|
|
||||||
name = ManualJobName.IntegrityUntrackedFilesDeleteAll;
|
let name: ManualJobName;
|
||||||
break;
|
switch (reportType) {
|
||||||
}
|
case IntegrityReportType.UntrackedFile: {
|
||||||
case IntegrityReportType.MissingFile: {
|
name = ManualJobName.IntegrityUntrackedFilesDeleteAll;
|
||||||
name = ManualJobName.IntegrityMissingFilesDeleteAll;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IntegrityReportType.ChecksumMismatch: {
|
|
||||||
name = ManualJobName.IntegrityChecksumMismatchDeleteAll;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case IntegrityReportType.MissingFile: {
|
||||||
try {
|
name = ManualJobName.IntegrityMissingFilesDeleteAll;
|
||||||
eventManager.emit('IntegrityReportDeleteStatus', {
|
break;
|
||||||
type: reportType,
|
|
||||||
isDeleting: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
await createJob({ jobCreateDto: { name } });
|
|
||||||
toastManager.success($t('admin.job_created'));
|
|
||||||
|
|
||||||
eventManager.emit('IntegrityReportDeleted', {
|
|
||||||
type: reportType,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
handleError(error, $t('failed_to_delete_file'));
|
|
||||||
|
|
||||||
eventManager.emit('IntegrityReportDeleteStatus', {
|
|
||||||
type: reportType,
|
|
||||||
isDeleting: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
case IntegrityReportType.ChecksumMismatch: {
|
||||||
|
name = ManualJobName.IntegrityChecksumMismatchDeleteAll;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
eventManager.emit('IntegrityReportDeleteStatus', {
|
||||||
|
type: reportType,
|
||||||
|
isDeleting: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await createJob({ jobCreateDto: { name } });
|
||||||
|
toastManager.success($t('admin.job_created'));
|
||||||
|
|
||||||
|
eventManager.emit('IntegrityReportDeleted', {
|
||||||
|
type: reportType,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
handleError(error, $t('failed_to_delete_file'));
|
||||||
|
|
||||||
|
eventManager.emit('IntegrityReportDeleteStatus', {
|
||||||
|
type: reportType,
|
||||||
|
isDeleting: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,27 +117,29 @@ export const handleRemoveIntegrityReportItem = async (reportId: string) => {
|
|||||||
confirmText: $t('delete'),
|
confirmText: $t('delete'),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (confirm) {
|
if (!confirm) {
|
||||||
try {
|
return;
|
||||||
eventManager.emit('IntegrityReportDeleteStatus', {
|
}
|
||||||
id: reportId,
|
|
||||||
isDeleting: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
await deleteIntegrityReport({
|
try {
|
||||||
id: reportId,
|
eventManager.emit('IntegrityReportDeleteStatus', {
|
||||||
});
|
id: reportId,
|
||||||
|
isDeleting: true,
|
||||||
|
});
|
||||||
|
|
||||||
eventManager.emit('IntegrityReportDeleted', {
|
await deleteIntegrityReport({
|
||||||
id: reportId,
|
id: reportId,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
|
||||||
handleError(error, $t('failed_to_delete_file'));
|
|
||||||
|
|
||||||
eventManager.emit('IntegrityReportDeleteStatus', {
|
eventManager.emit('IntegrityReportDeleted', {
|
||||||
id: reportId,
|
id: reportId,
|
||||||
isDeleting: false,
|
});
|
||||||
});
|
} catch (error) {
|
||||||
}
|
handleError(error, $t('failed_to_delete_file'));
|
||||||
|
|
||||||
|
eventManager.emit('IntegrityReportDeleteStatus', {
|
||||||
|
id: reportId,
|
||||||
|
isDeleting: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user