diff --git a/docs/configuration.md b/docs/configuration.md index b2b2b925a..889e2a92d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1366,13 +1366,13 @@ processing. This only has an effect if #### [`EMPTY_TRASH_DELAY=`](#EMPTY_TRASH_DELAY) {#EMPTY_TRASH_DELAY} -: Sets how long in days objects remain in the 'trash' before they are permanently deleted. +: Sets how long in days documents remain in the 'trash' before they are permanently deleted. Defaults to 30 days, minimum of 1 day. #### [`PAPERLESS_EMPTY_TRASH_TASK_CRON=`](#PAPERLESS_EMPTY_TRASH_TASK_CRON) {#PAPERLESS_EMPTY_TRASH_TASK_CRON} -: Configures the schedule to empty the trash of expired deleted objects. +: Configures the schedule to empty the trash of expired deleted documents. Defaults to `0 1 * * *`, once per day. diff --git a/src-ui/src/app/components/admin/trash/trash.component.html b/src-ui/src/app/components/admin/trash/trash.component.html index 94d20bcd4..87bb24d2c 100644 --- a/src-ui/src/app/components/admin/trash/trash.component.html +++ b/src-ui/src/app/components/admin/trash/trash.component.html @@ -32,7 +32,7 @@ info="Manage trashed items." Name - Deleted + Remaining Actions @@ -54,7 +54,7 @@ info="Manage trashed items." {{ document.title }} - {{ document.deleted_at | customDate }} + {{ getDaysRemaining(document) }} days
diff --git a/src-ui/src/app/components/admin/trash/trash.component.ts b/src-ui/src/app/components/admin/trash/trash.component.ts index 4821a51f9..f5349434e 100644 --- a/src-ui/src/app/components/admin/trash/trash.component.ts +++ b/src-ui/src/app/components/admin/trash/trash.component.ts @@ -5,6 +5,8 @@ import { ToastService } from 'src/app/services/toast.service' import { TrashService } from 'src/app/services/trash.service' import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component' import { Subject, takeUntil } from 'rxjs' +import { SettingsService } from 'src/app/services/settings.service' +import { SETTINGS_KEYS } from 'src/app/data/ui-settings' @Component({ selector: 'pngx-trash', @@ -22,7 +24,8 @@ export class TrashComponent implements OnDestroy { constructor( private trashService: TrashService, private toastService: ToastService, - private modalService: NgbModal + private modalService: NgbModal, + private settingsService: SettingsService ) { this.reload() } @@ -120,4 +123,11 @@ export class TrashComponent implements OnDestroy { this.allToggled = false this.selectedDocuments.clear() } + + getDaysRemaining(document: Document): number { + const delay = this.settingsService.get(SETTINGS_KEYS.EMPTY_TRASH_DELAY) + const diff = new Date().getTime() - new Date(document.deleted_at).getTime() + const days = Math.ceil(diff / (1000 * 3600 * 24)) + return delay - days + } } diff --git a/src-ui/src/app/data/ui-settings.ts b/src-ui/src/app/data/ui-settings.ts index 29ea08786..e22d33a83 100644 --- a/src-ui/src/app/data/ui-settings.ts +++ b/src-ui/src/app/data/ui-settings.ts @@ -63,6 +63,7 @@ export const SETTINGS_KEYS = { 'general-settings:document-editing:remove-inbox-tags', SEARCH_DB_ONLY: 'general-settings:search:db-only', SEARCH_FULL_TYPE: 'general-settings:search:more-link', + EMPTY_TRASH_DELAY: 'general-settings:trash:empty-trash-delay', } export const SETTINGS: UiSetting[] = [ @@ -236,4 +237,9 @@ export const SETTINGS: UiSetting[] = [ type: 'string', default: GlobalSearchType.TITLE_CONTENT, }, + { + key: SETTINGS_KEYS.EMPTY_TRASH_DELAY, + type: 'number', + default: 30, + }, ] diff --git a/src/documents/views.py b/src/documents/views.py index 916a376e8..e9a099f81 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -1559,6 +1559,8 @@ class UiSettingsView(GenericAPIView): "backend_setting": settings.ENABLE_UPDATE_CHECK, } + ui_settings["trash_delay"] = settings.EMPTY_TRASH_DELAY + general_config = GeneralConfig() ui_settings["app_title"] = settings.APP_TITLE diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 3f92f0751..83b87bc59 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -1166,4 +1166,4 @@ if DEBUG: # pragma: no cover ############################################################################### # Soft Delete ############################################################################### -EMPTY_TRASH_DELAY = max(__get_int("PAPERLESS_SOFT_DELETE_DELAY", 30), 1) +EMPTY_TRASH_DELAY = max(__get_int("PAPERLESS_EMPTY_TRASH_DELAY", 30), 1)