RED-858: Show download-all button if all files are in APPROVED state
This commit is contained in:
parent
5c284096af
commit
1e145809c5
@ -194,7 +194,8 @@ export class PermissionsService {
|
||||
if (!fileStatus) {
|
||||
fileStatus = this._appStateService.activeFile;
|
||||
}
|
||||
return fileStatus.status === 'APPROVED' && this.isManagerAndOwner();
|
||||
const project = this._appStateService.getProjectById(fileStatus.projectId);
|
||||
return fileStatus.status === 'APPROVED' && this.isManagerAndOwner(project);
|
||||
}
|
||||
|
||||
canDeleteProject(project?: ProjectWrapper) {
|
||||
|
||||
@ -152,12 +152,18 @@
|
||||
icon="red:refresh"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
|
||||
<redaction-circle-button
|
||||
(action)="downloadRedactedFiles($event, pw)"
|
||||
*ngIf="canDownloadRedactedFiles(pw)"
|
||||
tooltip="project-listing.download-files.action"
|
||||
type="dark-bg"
|
||||
icon="red:download"
|
||||
></redaction-circle-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="scrollbar-placeholder"></div>
|
||||
</div>
|
||||
|
||||
<!-- <redaction-virtual-scroll></redaction-virtual-scroll>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Project } from '@redaction/red-ui-http';
|
||||
import { FileManagementControllerService, Project } from '@redaction/red-ui-http';
|
||||
import { AppStateService } from '../../state/app-state.service';
|
||||
import { UserService } from '../../user/user.service';
|
||||
import { DoughnutChartConfig } from '../../components/simple-doughnut-chart/simple-doughnut-chart.component';
|
||||
import { groupBy, humanize } from '../../utils/functions';
|
||||
import { computerize, groupBy, humanize } from '../../utils/functions';
|
||||
import { DialogService } from '../../dialogs/dialog.service';
|
||||
import { FilterModel } from '../../common/filter/model/filter.model';
|
||||
import {
|
||||
@ -25,6 +25,7 @@ import { StatusSorter } from '../../common/sorters/status-sorter';
|
||||
import { Router } from '@angular/router';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { debounce } from '../../utils/debounce';
|
||||
import { download } from '../../utils/file-download-utils';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-project-listing-screen',
|
||||
@ -60,7 +61,8 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy {
|
||||
private readonly _router: Router,
|
||||
public readonly sortingService: SortingService,
|
||||
public readonly translateChartService: TranslateChartService,
|
||||
private readonly _formBuilder: FormBuilder
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
private readonly _fileManagementControllerService: FileManagementControllerService
|
||||
) {
|
||||
this.searchForm = this._formBuilder.group({
|
||||
query: ['']
|
||||
@ -257,7 +259,12 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy {
|
||||
const filters = [
|
||||
{ values: this.statusFilters, checker: projectStatusChecker },
|
||||
{ values: this.peopleFilters, checker: projectMemberChecker },
|
||||
{ values: this.needsWorkFilters, checker: annotationFilterChecker, matchAll: true, checkerArgs: this.permissionsService }
|
||||
{
|
||||
values: this.needsWorkFilters,
|
||||
checker: annotationFilterChecker,
|
||||
matchAll: true,
|
||||
checkerArgs: this.permissionsService
|
||||
}
|
||||
];
|
||||
return getFilteredEntities(this.appStateService.allProjects, filters);
|
||||
}
|
||||
@ -282,4 +289,18 @@ export class ProjectListingScreenComponent implements OnInit, OnDestroy {
|
||||
this._calculateData();
|
||||
});
|
||||
}
|
||||
|
||||
// Download Files
|
||||
public downloadRedactedFiles($event: MouseEvent, project: ProjectWrapper) {
|
||||
$event.stopPropagation();
|
||||
this._fileManagementControllerService
|
||||
.downloadRedactedFiles({ fileIds: project.files.map((file) => file.fileId) }, project.projectId, false, 'response')
|
||||
.subscribe((data) => {
|
||||
download(data, 'redacted_files_' + computerize(project.name) + '.zip');
|
||||
});
|
||||
}
|
||||
|
||||
public canDownloadRedactedFiles(project: ProjectWrapper) {
|
||||
return project.files.reduce((acc, file) => acc && this.permissionsService.canDownloadRedactedFile(file), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,6 +69,15 @@
|
||||
tooltipPosition="below"
|
||||
icon="red:refresh"
|
||||
></redaction-circle-button>
|
||||
|
||||
<redaction-circle-button
|
||||
(action)="downloadRedactedFiles()"
|
||||
*ngIf="canDownloadRedactedFiles"
|
||||
tooltip="project-overview.header-actions.download-redacted-files"
|
||||
tooltipPosition="below"
|
||||
icon="red:download"
|
||||
></redaction-circle-button>
|
||||
|
||||
<redaction-circle-button
|
||||
class="ml-14"
|
||||
(action)="fileInput.click()"
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NotificationService, NotificationType } from '../../notification/notification.service';
|
||||
import { NotificationService } from '../../notification/notification.service';
|
||||
import { AppStateService } from '../../state/app-state.service';
|
||||
import { FileDropOverlayService } from '../../upload/file-drop/service/file-drop-overlay.service';
|
||||
import { FileUploadModel } from '../../upload/model/file-upload.model';
|
||||
import { FileUploadService } from '../../upload/file-upload.service';
|
||||
import { UploadStatusOverlayService } from '../../upload/upload-status-dialog/service/upload-status-overlay.service';
|
||||
import { humanize } from '../../utils/functions';
|
||||
import { computerize, humanize } from '../../utils/functions';
|
||||
import { DialogService } from '../../dialogs/dialog.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { FileActionService } from '../file/service/file-action.service';
|
||||
@ -18,13 +18,14 @@ import { annotationFilterChecker, getFilteredEntities, keyChecker, processFilter
|
||||
import { SortingOption, SortingService } from '../../utils/sorting.service';
|
||||
import { PermissionsService } from '../../common/service/permissions.service';
|
||||
import { UserService } from '../../user/user.service';
|
||||
import { FileStatus } from '@redaction/red-ui-http';
|
||||
import { FileManagementControllerService, FileStatus } from '@redaction/red-ui-http';
|
||||
import { Subscription, timer } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { RedactionFilterSorter } from '../../common/sorters/redaction-filter-sorter';
|
||||
import { StatusSorter } from '../../common/sorters/status-sorter';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { debounce } from '../../utils/debounce';
|
||||
import { download } from '../../utils/file-download-utils';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-project-overview-screen',
|
||||
@ -65,7 +66,8 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
|
||||
private readonly _changeDetectorRef: ChangeDetectorRef,
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _fileDropOverlayService: FileDropOverlayService,
|
||||
private readonly _formBuilder: FormBuilder
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
private readonly _fileManagementControllerService: FileManagementControllerService
|
||||
) {
|
||||
this.searchForm = this._formBuilder.group({
|
||||
query: ['']
|
||||
@ -331,4 +333,22 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy {
|
||||
public toggleCollapsedDetails() {
|
||||
this.collapsedDetails = !this.collapsedDetails;
|
||||
}
|
||||
|
||||
// Download Files
|
||||
public downloadRedactedFiles() {
|
||||
this._fileManagementControllerService
|
||||
.downloadRedactedFiles(
|
||||
{ fileIds: this.appStateService.activeProject.files.map((file) => file.fileId) },
|
||||
this.appStateService.activeProjectId,
|
||||
false,
|
||||
'response'
|
||||
)
|
||||
.subscribe((data) => {
|
||||
download(data, 'redacted_files_' + computerize(this.appStateService.activeProject.name) + '.zip');
|
||||
});
|
||||
}
|
||||
|
||||
public get canDownloadRedactedFiles() {
|
||||
return this.appStateService.activeProject.files.reduce((acc, file) => acc && this.permissionsService.canDownloadRedactedFile(file), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +77,9 @@
|
||||
"assign": {
|
||||
"action": "Assign Owner & Members"
|
||||
},
|
||||
"download-files": {
|
||||
"action": "Download Redacted Files"
|
||||
},
|
||||
"table-header": {
|
||||
"title": "{{length}} active projects",
|
||||
"bulk-select": "Toggle Selection",
|
||||
@ -155,7 +158,8 @@
|
||||
"edit": "Edit",
|
||||
"delete": "Delete",
|
||||
"assign": "Assign Owner & Members",
|
||||
"upload-document": "Upload Document"
|
||||
"upload-document": "Upload Document",
|
||||
"download-redacted-files": "Download Redacted Files"
|
||||
},
|
||||
"download-redacted-file": "Download Redacted File",
|
||||
"download-redacted-files": "Download Redacted Files",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user