Relative days

[skip ci]
This commit is contained in:
shamoon
2024-04-23 01:33:00 -07:00
parent e58c2d4bbf
commit e4092d2ad1
6 changed files with 24 additions and 6 deletions

View File

@@ -32,7 +32,7 @@ info="Manage trashed items."
</div>
</th>
<th scope="col" class="fw-normal" i18n>Name</th>
<th scope="col" class="fw-normal d-none d-sm-table-cell" i18n>Deleted</th>
<th scope="col" class="fw-normal d-none d-sm-table-cell" i18n>Remaining</th>
<th scope="col" class="fw-normal" i18n>Actions</th>
</tr>
</thead>
@@ -54,7 +54,7 @@ info="Manage trashed items."
</div>
</td>
<td scope="row">{{ document.title }}</td>
<td scope="row">{{ document.deleted_at | customDate }}</td>
<td scope="row" i18n>{{ getDaysRemaining(document) }} days</td>
<td scope="row">
<div class="btn-group d-block d-sm-none">
<div ngbDropdown container="body" class="d-inline-block">

View File

@@ -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
}
}

View File

@@ -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,
},
]