Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { LANG } from '../../translate.component';
import { HttpClient } from '@angular/common/http';
import { map, tap, catchError } from 'rxjs/operators';
import { of } from 'rxjs';
import { NotificationService } from '../../notification.service';
@Component({
selector: 'folder-menu',
templateUrl: "folder-menu.component.html",
styleUrls: ['folder-menu.component.scss'],
providers: [NotificationService],
})
export class FolderMenuComponent implements OnInit {
lang: any = LANG;
foldersList: any[] = [];
@Input('resIds') resIds: number[];
@Output('refreshList') refreshList = new EventEmitter<string>();
constructor(
public http: HttpClient,
private notify: NotificationService
) { }
ngOnInit(): void { }
getFolders() {
this.http.get("../../rest/folders").pipe(
map((data: any) => data.folders),
tap((data: any) => {
this.foldersList = data;
}),
).subscribe();
}
classifyDocuments(folder: any) {
this.http.post('../../rest/folders/' + folder.id + '/resources', { resources: this.resIds }).pipe(
tap(() => {
this.refreshList.emit();
this.notify.success('Courrier classé');
}),
catchError((err) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
}