diff --git a/src/frontend/app/search/result-list/search-result-list.component.html b/src/frontend/app/search/result-list/search-result-list.component.html index f88ee6f75a5eb5899f246e5417c5be67527808bd..6e262dfecd92c5a32735a63e15e70472ed0f0bbd 100644 --- a/src/frontend/app/search/result-list/search-result-list.component.html +++ b/src/frontend/app/search/result-list/search-result-list.component.html @@ -169,6 +169,16 @@ <mat-icon [ngClass]="[row.mailTracking === true ? 'fas fa-star' : 'far fa-star']" style="margin-bottom: 5px;"></mat-icon> </button> + <button *ngIf="privilegeService.hasCurrentUserPrivilege('freeze_retention_rule')" + mat-icon-button [title]="this.translate.instant('lang.freezeRetentionRule')" + class="categoryLabel" (click)="toggleFreezing(row)"> + <mat-icon class="{{informationWithFreeze.includes(row.resId) === true ? 'freezeIcon' : 'thawIcon'}} fas fa-snowflake" style="font-size: 20px;"></mat-icon> + </button> + <button *ngIf="privilegeService.hasCurrentUserPrivilege('set_binding_document')" + mat-icon-button [title]="this.translate.instant('lang.setBindingDocument')" + class="categoryLabel" (click)="toggleBinding(row)"> + <mat-icon class=" {{ informationWithBinding.includes(row.resId) === true ? 'bindIcon' : 'noBindIcon'}} fas fa-exclamation" style="font-size: 20px;"></mat-icon> + </button> <span style="cursor:pointer;" [class.highlightResultIcon]="row.inStatus" class="main-info-status" (click)="launch(row);"> <mat-icon *ngIf="row.isLocked !== true" title="{{row.statusLabel}}" diff --git a/src/frontend/app/search/result-list/search-result-list.component.scss b/src/frontend/app/search/result-list/search-result-list.component.scss index e36c0ca0381c81e7caaf0e243af56dc941391d3e..7ae6da37794640b73eaedbad7dd74a4eeb1860df 100644 --- a/src/frontend/app/search/result-list/search-result-list.component.scss +++ b/src/frontend/app/search/result-list/search-result-list.component.scss @@ -174,6 +174,21 @@ width: 120px; } +.freezeIcon { + color: $secondary; +} + +.thawIcon { + color: $primary; +} + +.bindIcon { + color: $secondary; +} + +.noBindIcon { + color: $primary; +} .watermark { position: absolute; left: 50%; diff --git a/src/frontend/app/search/result-list/search-result-list.component.ts b/src/frontend/app/search/result-list/search-result-list.component.ts index d2f66468cd6e0168caa2f28adfd8d2189c501b86..9f0efb39f29fa8635599bb17600da2406a84cdc8 100644 --- a/src/frontend/app/search/result-list/search-result-list.component.ts +++ b/src/frontend/app/search/result-list/search-result-list.component.ts @@ -24,6 +24,8 @@ import { CriteriaSearchService } from '@service/criteriaSearch.service'; import { HighlightPipe } from '@plugins/highlight.pipe'; import { FilterToolComponent } from '@appRoot/search/filter-tool/filter-tool.component'; import { ContactResourceModalComponent } from '@appRoot/contact/contact-resource/modal/contact-resource-modal.component'; +import { PrivilegeService } from '@service/privileges.service'; +import { THIS_EXPR } from '@angular/compiler/src/output/output_ast'; declare var $: any; @@ -81,6 +83,12 @@ export class SearchResultListComponent implements OnInit, OnDestroy { } ]; + informationWithFreeze: any[] = []; + informationWithBinding: any[] = []; + + resourceFreezed: boolean = false; + resourceBinded: boolean = false; + resultListDatabase: ResultListHttpDao | null; data: any = []; resultsLength = 0; @@ -154,6 +162,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { public functions: FunctionsService, public indexingFieldService: IndexingFieldsService, public highlightPipe: HighlightPipe, + public privilegeService: PrivilegeService, ) { _activatedRoute.queryParams.subscribe( params => { @@ -200,6 +209,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { this.loading = false; } + initSavedCriteria() { if (Object.keys(this.listProperties.criteria).length > 0) { const obj = { query: [] }; @@ -303,6 +313,7 @@ export class SearchResultListComponent implements OnInit, OnDestroy { this.resultsLength = data.count; this.paginatorLength = data.count > 10000 ? 10000 : data.count; this.allResInBasket = data.allResources; + this.getInfos(data.resources); return data.resources; }), catchError((err: any) => { @@ -683,6 +694,76 @@ export class SearchResultListComponent implements OnInit, OnDestroy { } } + toggleFreezing(row: any) { + const indexData = this.informationWithFreeze.indexOf(row.resId); + if (this.informationWithFreeze.includes(row.resId)) { + this.resourceFreezed = false; + this.informationWithFreeze.splice(indexData, 1); + } else { + this.resourceFreezed = true; + this.informationWithFreeze.push(row.resId); + } + this.http.put('../rest/archival/freezeRetentionRule', { resources: [row.resId], freeze : this.resourceFreezed }).pipe( + tap(() => { + if (this.resourceFreezed) { + this.notify.success(this.translate.instant('lang.retentionRuleFrozen')); + } else { + this.notify.success(this.translate.instant('lang.retentionRuleThawed')); + } + } + ), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } + + toggleBinding(row: any) { + const indexData = this.informationWithBinding.indexOf(row.resId); + if (this.informationWithBinding.includes(row.resId)) { + this.resourceBinded = false; + this.informationWithBinding.splice(indexData, 1); + } else { + this.resourceBinded = true; + this.informationWithBinding.push(row.resId); + } + this.http.put('../rest/archival/binding', { resources: [row.resId], binding : this.resourceBinded }).pipe( + tap(() => { + if (this.resourceBinded) { + this.notify.success(this.translate.instant('lang.bindingMail')); + } else { + this.notify.success(this.translate.instant('lang.noBindingMal')); + } + } + ), + catchError((err: any) => { + this.resourceBinded = !this.resourceBinded; + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } + + getInfos(data) { + data.forEach(element => { + this.http.get(`../rest/resources/${element.resId}?light=true`).pipe( + tap((infos: any) => { + if (infos.retentionFrozen) { + this.informationWithFreeze.push(infos.resId); + } + if(infos.binding) { + this.informationWithBinding.push(infos.resId); + } + }), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + }); + } + viewDocument(row: any) { this.http.get(`../rest/resources/${row.resId}/content?mode=view`, { responseType: 'blob' }).pipe( tap((data: any) => {