linked pending downloads
This commit is contained in:
parent
99ff8ac6cd
commit
92d07a5633
@ -72,7 +72,7 @@
|
||||
<redaction-user-button
|
||||
[user]="user"
|
||||
[matMenuTriggerFor]="userMenu"
|
||||
[showDot]="userPreferenceService.areDevFeaturesEnabled && appStateService.readyDownloads.length > 0"
|
||||
[showDot]="fileDownloadService.pendingDownloads.length > 0"
|
||||
></redaction-user-button>
|
||||
<mat-menu #userMenu="matMenu">
|
||||
<button
|
||||
@ -83,7 +83,7 @@
|
||||
translate="top-bar.navigation-items.my-account.children.admin"
|
||||
></button>
|
||||
<button
|
||||
*ngIf="!permissionsService.isAdmin() && userPreferenceService.areDevFeaturesEnabled"
|
||||
*ngIf="permissionsService.isUser()"
|
||||
[routerLink]="'/ui/downloads'"
|
||||
mat-menu-item
|
||||
translate="top-bar.navigation-items.my-account.children.downloads"
|
||||
|
||||
@ -7,6 +7,7 @@ import { UserPreferenceService } from '../../common/service/user-preference.serv
|
||||
import { Router } from '@angular/router';
|
||||
import { AppConfigKey, AppConfigService } from '../../app-config/app-config.service';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { FileDownloadService } from '../../upload-download/file-download.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-base-screen',
|
||||
@ -25,6 +26,7 @@ export class BaseScreenComponent {
|
||||
public readonly permissionsService: PermissionsService,
|
||||
public readonly userPreferenceService: UserPreferenceService,
|
||||
public readonly titleService: Title,
|
||||
public readonly fileDownloadService: FileDownloadService,
|
||||
private readonly _appConfigService: AppConfigService,
|
||||
private readonly _router: Router,
|
||||
private readonly _languageService: LanguageService,
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<div class="left-container">
|
||||
<div class="header-item">
|
||||
<span class="all-caps-label">
|
||||
{{ 'downloads-list.table-header.title' | translate: { length: appStateService.allDownloads.length } }}
|
||||
{{ 'downloads-list.table-header.title' | translate: { length: fileDownloadService.downloads.length } }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -26,16 +26,16 @@
|
||||
|
||||
<div class="grid-container" redactionHasScrollbar>
|
||||
<!-- Table lines -->
|
||||
<div *ngFor="let download of appStateService.allDownloads" class="table-item">
|
||||
<div *ngFor="let download of fileDownloadService.downloads" class="table-item">
|
||||
<div>
|
||||
<div class="table-item-title heading">{{ download.name }}</div>
|
||||
<div class="table-item-title heading">{{ download.filename }}</div>
|
||||
</div>
|
||||
<div>
|
||||
{{ download.type }}
|
||||
{{ download.downloadDetails | json }}
|
||||
</div>
|
||||
<div>
|
||||
<div class="small-label">
|
||||
{{ download.date | date: 'd MMM. yyyy, hh:mm a' }}
|
||||
{{ download.creationDate | date: 'd MMM. yyyy, hh:mm a' }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
@ -46,7 +46,7 @@
|
||||
<div class="actions-container">
|
||||
<div class="action-buttons">
|
||||
<redaction-circle-button
|
||||
*ngIf="download.status === 'ready'"
|
||||
*ngIf="download.status === 'READY'"
|
||||
(action)="downloadItem(download)"
|
||||
tooltip="downloads-list.actions.download"
|
||||
tooltipPosition="before"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { AppStateService, Download } from '../../state/app-state.service';
|
||||
import { FileDownloadService } from '../../upload-download/file-download.service';
|
||||
import { DownloadStatus } from '@redaction/red-ui-http';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-downloads-list-screen',
|
||||
@ -7,15 +8,13 @@ import { AppStateService, Download } from '../../state/app-state.service';
|
||||
styleUrls: ['./downloads-list-screen.component.scss']
|
||||
})
|
||||
export class DownloadsListScreenComponent {
|
||||
constructor(public appStateService: AppStateService) {
|
||||
this.appStateService.reset();
|
||||
}
|
||||
constructor(public readonly fileDownloadService: FileDownloadService) {}
|
||||
|
||||
public get noData(): boolean {
|
||||
return this.appStateService.allDownloads.length === 0;
|
||||
return this.fileDownloadService.downloads.length === 0;
|
||||
}
|
||||
|
||||
public downloadItem(download: Download) {
|
||||
console.log('downloading', download);
|
||||
public downloadItem(download: DownloadStatus) {
|
||||
this.fileDownloadService.performDownload(download);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,14 +23,6 @@ import { FileStatusWrapper } from '../screens/file/model/file-status.wrapper';
|
||||
import { ProjectWrapper } from './model/project.wrapper';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
export interface Download {
|
||||
name: string;
|
||||
type: string;
|
||||
date: Date;
|
||||
status: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface AppState {
|
||||
projects: ProjectWrapper[];
|
||||
ruleSets: RuleSetModel[];
|
||||
@ -41,7 +33,6 @@ export interface AppState {
|
||||
totalAnalysedPages?: number;
|
||||
totalDocuments?: number;
|
||||
totalPeople?: number;
|
||||
downloads: Download[];
|
||||
versions: { [key: string]: { dictionaryVersion?: number; rulesVersion?: number } };
|
||||
}
|
||||
|
||||
@ -74,12 +65,7 @@ export class AppStateService {
|
||||
activeFileId: null,
|
||||
activeRuleSetId: null,
|
||||
activeDictionaryType: null,
|
||||
versions: {},
|
||||
downloads: [
|
||||
{ name: 'Download 1', id: '1', date: new Date(), status: 'processing', type: 'project' },
|
||||
{ name: 'Download 2', id: '2', date: new Date(), status: 'queued', type: 'project' },
|
||||
{ name: 'Download 3', id: '3', date: new Date(), status: 'ready', type: 'project' }
|
||||
]
|
||||
versions: {}
|
||||
};
|
||||
}
|
||||
|
||||
@ -139,14 +125,6 @@ export class AppStateService {
|
||||
return result;
|
||||
}
|
||||
|
||||
get allDownloads(): Download[] {
|
||||
return this._appState.downloads;
|
||||
}
|
||||
|
||||
get readyDownloads(): Download[] {
|
||||
return this._appState.downloads.filter((d) => d.status === 'ready');
|
||||
}
|
||||
|
||||
get activeRuleSetId(): string {
|
||||
return this._appState.activeRuleSetId;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<section class="red-upload-download-overlay mat-elevation-z4">
|
||||
<section class="red-upload-download-overlay mat-elevation-z4" *ngIf="downloadService.pendingDownloads.length > 0">
|
||||
<div (click)="collapsed = !collapsed" class="red-upload-download-header">
|
||||
<div class="title">
|
||||
{{ 'download-status.dialog.title' | translate: { len: downloadService.downloads.length } }}
|
||||
{{ 'download-status.dialog.title' | translate: { len: downloadService.pendingDownloads.length } }}
|
||||
</div>
|
||||
<div *ngIf="!collapsed" class="collapse-icon">
|
||||
<mat-icon svgIcon="red:arrow-down"></mat-icon>
|
||||
@ -24,13 +24,10 @@
|
||||
>
|
||||
{{ model.filename }}
|
||||
</div>
|
||||
<mat-spinner *ngIf="!ready(model)" class="upload-download-progress" diameter="15" color="primary"></mat-spinner>
|
||||
<mat-spinner *ngIf="!hasError(model)" class="upload-download-progress" diameter="15" color="primary"></mat-spinner>
|
||||
<div *ngIf="hasError(model)" class="upload-download-progress error">
|
||||
<mat-icon svgIcon="red:error"></mat-icon>
|
||||
</div>
|
||||
<div *ngIf="successful(model)" class="upload-download-progress ok">
|
||||
<mat-icon svgIcon="red:check"></mat-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -36,14 +36,6 @@ export class DownloadStatusOverlay implements OnInit {
|
||||
this._overlayRef.detach();
|
||||
}
|
||||
|
||||
ready(downloadStatus: DownloadStatus) {
|
||||
return downloadStatus.status === 'READY' || downloadStatus.status === 'FAILED';
|
||||
}
|
||||
|
||||
successful(downloadStatus: DownloadStatus) {
|
||||
return downloadStatus.status === 'READY' && downloadStatus.lastDownload;
|
||||
}
|
||||
|
||||
hasError(downloadStatus: DownloadStatus) {
|
||||
return downloadStatus.status === 'FAILED';
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ export class FileDownloadService {
|
||||
private readonly _fileManagementControllerService: FileManagementControllerService,
|
||||
private readonly _dialogService: DialogService
|
||||
) {
|
||||
interval(2500).subscribe((val) => {
|
||||
interval(5000).subscribe((val) => {
|
||||
this._getDownloadStatus().subscribe(() => {});
|
||||
});
|
||||
}
|
||||
@ -55,7 +55,8 @@ export class FileDownloadService {
|
||||
this.performDownload(d);
|
||||
}
|
||||
});
|
||||
this.pendingDownloads = this.downloads.filter((d) => !d.lastDownload && !this.inProgressDownloads.has(d.storageId));
|
||||
// never downloaded or download still pending
|
||||
this.pendingDownloads = this.downloads.filter((d) => !d.lastDownload || this.inProgressDownloads.has(d.storageId));
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -71,7 +72,10 @@ export class FileDownloadService {
|
||||
)
|
||||
.subscribe((response) => {
|
||||
download(response, status.filename);
|
||||
this.inProgressDownloads.delete(status.storageId);
|
||||
console.log('done');
|
||||
setTimeout(() => {
|
||||
this.inProgressDownloads.delete(status.storageId);
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user