Downloads listing extends base listing

This commit is contained in:
Adina Țeudan 2021-07-28 10:40:46 +03:00
parent b3b12ba47e
commit b350b2a933
5 changed files with 56 additions and 50 deletions

View File

@ -1,41 +1,23 @@
<section>
<div class="page-header">
<div class="actions flex-1">
<redaction-circle-button
[tooltip]="'common.close' | translate"
icon="red:close"
redactionNavigateLastDossiersScreen
tooltipPosition="below"
></redaction-circle-button>
</div>
</div>
<redaction-page-header [showCloseButton]="true"></redaction-page-header>
<div class="red-content-inner">
<div class="content-container">
<div class="header-item">
<span class="all-caps-label">
{{ 'downloads-list.table-header.title' | translate: { length: fileDownloadService.downloads.length } }}
</span>
</div>
<div [class.no-data]="noData" class="table-header" redactionSyncWidth="table-item">
<redaction-table-col-name [label]="'downloads-list.table-col-names.name' | translate"></redaction-table-col-name>
<redaction-table-col-name [label]="'downloads-list.table-col-names.size' | translate"></redaction-table-col-name>
<redaction-table-col-name [label]="'downloads-list.table-col-names.date' | translate"></redaction-table-col-name>
<redaction-table-col-name [label]="'downloads-list.table-col-names.status' | translate"></redaction-table-col-name>
<div></div>
<div class="scrollbar-placeholder"></div>
</div>
<redaction-table-header
[hasEmptyColumn]="true"
[tableColConfigs]="tableColConfigs"
[tableHeaderLabel]="tableHeaderLabel"
></redaction-table-header>
<redaction-empty-state
*ngIf="noData"
*ngIf="screenStateService.noData$ | async"
[text]="'downloads-list.no-data.title' | translate"
icon="red:download"
></redaction-empty-state>
<cdk-virtual-scroll-viewport [itemSize]="80" redactionHasScrollbar>
<cdk-virtual-scroll-viewport [itemSize]="itemSize" redactionHasScrollbar>
<!-- Table lines -->
<div *cdkVirtualFor="let download of fileDownloadService.downloads" class="table-item">
<div *cdkVirtualFor="let download of sortedDisplayedEntities$ | async; trackBy: trackByPrimaryKey" class="table-item">
<div>
<div [class.no-bold]="download.lastDownload" class="table-item-title heading">
{{ download.filename }}

View File

@ -1,34 +1,55 @@
import { Component, OnInit } from '@angular/core';
import { Component, Injector, OnInit } from '@angular/core';
import { FileDownloadService } from '@upload-download/services/file-download.service';
import { DownloadStatusWrapper } from '@upload-download/model/download-status.wrapper';
import { DownloadControllerService } from '@redaction/red-ui-http';
import { BaseListingComponent } from '@shared/base/base-listing.component';
import { FilterService } from '@shared/services/filter.service';
import { SearchService } from '@shared/services/search.service';
import { ScreenStateService } from '@shared/services/screen-state.service';
import { SortingService } from '@services/sorting.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { TableColConfig } from '@shared/components/table-col-name/table-col-name.component';
@Component({
selector: 'redaction-downloads-list-screen',
templateUrl: './downloads-list-screen.component.html',
styleUrls: ['./downloads-list-screen.component.scss']
styleUrls: ['./downloads-list-screen.component.scss'],
providers: [FilterService, SearchService, ScreenStateService, SortingService]
})
export class DownloadsListScreenComponent implements OnInit {
export class DownloadsListScreenComponent extends BaseListingComponent<DownloadStatusWrapper> implements OnInit {
itemSize = 80;
tableColConfigs: TableColConfig[] = [
{ label: _('downloads-list.table-col-names.name') },
{ label: _('downloads-list.table-col-names.size') },
{ label: _('downloads-list.table-col-names.date') },
{ label: _('downloads-list.table-col-names.status') }
];
protected readonly _primaryKey = 'storageId';
protected _tableHeaderLabel = _('downloads-list.table-header.title');
constructor(
readonly fileDownloadService: FileDownloadService,
private readonly _downloadControllerService: DownloadControllerService
) {}
get noData(): boolean {
return this.fileDownloadService.downloads.length === 0;
private readonly _downloadControllerService: DownloadControllerService,
protected readonly _injector: Injector
) {
super(_injector);
}
ngOnInit(): void {
this.fileDownloadService.getDownloadStatus().subscribe();
async ngOnInit() {
await this._loadData();
}
async downloadItem(download: DownloadStatusWrapper) {
await this.fileDownloadService.performDownload(download);
}
deleteItem(download: DownloadStatusWrapper) {
this._downloadControllerService
.deleteDownload({ storageIds: [download.storageId] })
.subscribe(() => this.fileDownloadService.getDownloadStatus().subscribe());
async deleteItem(download: DownloadStatusWrapper) {
await this._downloadControllerService.deleteDownload({ storageIds: [download.storageId] }).toPromise();
await this._loadData();
}
private async _loadData() {
await this.fileDownloadService.getDownloadStatus().toPromise();
this.screenStateService.setEntities(this.fileDownloadService.downloads);
}
}

View File

@ -18,5 +18,7 @@
[withSort]="config.withSort"
></redaction-table-col-name>
<div *ngIf="hasEmptyColumn"></div>
<div class="scrollbar-placeholder"></div>
</div>

View File

@ -11,6 +11,7 @@ import { ScreenStateService } from '@shared/services/screen-state.service';
export class TableHeaderComponent<T> {
@Input() tableHeaderLabel: string;
@Input() tableColConfigs: TableColConfig[];
@Input() hasEmptyColumn = false;
constructor(readonly screenStateService: ScreenStateService<T>) {}
}

View File

@ -181,6 +181,10 @@
"error": "Failed to recategorize image: {error}",
"success": "Image recategorized."
},
"remove": {
"error": "Failed to remove redaction: {error}",
"success": "Redaction removed!"
},
"request-change-legal-basis": {
"error": "Failed to request annotation reason change: {error}",
"success": "Annotation reason change requested."
@ -193,6 +197,10 @@
"error": "Failed to request image recategorization: {error}",
"success": "Image recategorization requested."
},
"request-remove": {
"error": "Failed to request removal of redaction: {error}",
"success": "Requested to remove redaction!"
},
"suggest": {
"error": "Failed to save redaction suggestion: {error}",
"success": "Redaction suggestion saved"
@ -200,14 +208,6 @@
"undo": {
"error": "Failed to undo: {error}",
"success": "Undo successful"
},
"remove": {
"error": "Failed to remove redaction: {error}",
"success": "Redaction removed!"
},
"request-remove": {
"error": "Failed to request removal of redaction: {error}",
"success": "Requested to remove redaction!"
}
}
},
@ -957,10 +957,10 @@
"error": "Re-processing required",
"excluded": "Excluded",
"full-reprocess": "Processing",
"indexing": "Processing",
"ocr-processing": "OCR Processing",
"processing": "Processing",
"reprocess": "Processing",
"indexing": "Processing",
"unassigned": "Unassigned",
"under-approval": "Under Approval",
"under-review": "Under Review",