diff --git a/locales/index.d.ts b/locales/index.d.ts index da0f7a963f..51043e51dc 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -13265,6 +13265,36 @@ export interface Locale extends ILocale { * Signup Reason */ "signupReason": string; + "clearCachedFilesOptions": { + /** + * Delete all cached remote files + */ + "title": string; + /** + * Only delete files older than: + */ + "olderThan": string; + /** + * now + */ + "now": string; + /** + * one week + */ + "oneWeek": string; + /** + * one month + */ + "oneMonth": string; + /** + * one year + */ + "oneYear": string; + /** + * Don't delete files used as avatars&c + */ + "keepFilesInUse": string; + }; } declare const locales: { [lang: string]: Locale; diff --git a/packages/frontend/src/pages/admin/files.vue b/packages/frontend/src/pages/admin/files.vue index 87595a820b..fb40bbeeed 100644 --- a/packages/frontend/src/pages/admin/files.vue +++ b/packages/frontend/src/pages/admin/files.vue @@ -58,14 +58,39 @@ const pagination = { })), }; -function clear() { - os.confirm({ - type: 'warning', - text: i18n.ts.clearCachedFilesConfirm, - }).then(({ canceled }) => { - if (canceled) return; +async function clear() { + const { canceled, result } = await os.form(i18n.ts.clearCachedFilesOptions.title, { + olderThanEnum: { + label: i18n.ts.clearCachedFilesOptions.olderThan, + type: 'enum', + default: 'now', + required: true, + enum: [ + { label: i18n.ts.clearCachedFilesOptions.now, value: 'now' }, + { label: i18n.ts.clearCachedFilesOptions.oneWeek, value: 'oneWeek' }, + { label: i18n.ts.clearCachedFilesOptions.oneMonth, value: 'oneMonth' }, + { label: i18n.ts.clearCachedFilesOptions.oneYear, value: 'oneYear' }, + ], + }, + keepFilesInUse: { + label: i18n.ts.clearCachedFilesOptions.keepFilesInUse, + type: 'boolean', + default: true, + }, + }); - os.apiWithDialog('admin/drive/clean-remote-files', {}); + if (canceled) return; + + const timesMap = { + now: 0, + oneWeek: 7 * 86400, + oneMonth: 30 * 86400, + oneYear: 365 * 86400, + }; + + await os.apiWithDialog('admin/drive/clean-remote-files', { + olderThanSeconds: timesMap[result.olderThanEnum] ?? 0, + keepFilesInUse: result.keepFilesInUse, }); } diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index c79302ff7a..ab6712225f 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -632,3 +632,12 @@ rawInfoDescription: "Extended user data in its raw form. These fields are privat rawApDescription: "ActivityPub user data in its raw form. These fields are public and accessible to other instances." signupReason: "Signup Reason" + +clearCachedFilesOptions: + title: "Delete all cached remote files" + olderThan: "Only delete files older than:" + now: "now" + oneWeek: "one week" + oneMonth: "one month" + oneYear: "one year" + keepFilesInUse: "Don't delete files used as avatars&c"