Newer
Older
import { Component, OnInit, Output, EventEmitter, AfterViewInit } from '@angular/core';

Alex ORLUC
committed
import { HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
import { MatDialog } from '@angular/material/dialog';
import { MatTableDataSource } from '@angular/material/table';
import { NotificationService } from '@service/notification/notification.service';
import { HeaderService } from '@service/header.service';

Alex ORLUC
committed
import { finalize } from 'rxjs/operators';
export interface MPDocument {
id: string;
title: string;
reference: string;
mode: string;
owner: boolean;
}
@Component({
selector: 'app-maarch-parapheur-list',
templateUrl: 'maarch-parapheur-list.component.html',

Alex ORLUC
committed
styleUrls: ['maarch-parapheur-list.component.scss'],
})
export class MaarchParapheurListComponent implements OnInit, AfterViewInit {

Alex ORLUC
committed

Alex ORLUC
committed
loading: boolean = true;
userList: MPDocument[] = [];
dataSource: MatTableDataSource<MPDocument>;
displayedColumns: string[] = ['id', 'title'];
maarchParapheurUrl: string = '';
@Output() triggerEvent = new EventEmitter<string>();
constructor(public translate: TranslateService, public http: HttpClient, public dialog: MatDialog, private notify: NotificationService, private headerService: HeaderService) {

Alex ORLUC
committed
this.dataSource = new MatTableDataSource(this.userList);
}
ngOnInit(): void {
this.loading = true;
}
ngAfterViewInit(): void {
this.http.get('../rest/home/maarchParapheurDocuments')

Alex ORLUC
committed
.pipe(
finalize(() => this.loading = false)
)
.subscribe((data: any) => {
setTimeout(() => {
this.dataSource = new MatTableDataSource(data.documents);
this.maarchParapheurUrl = data.url;
this.triggerEvent.emit(data.count.current);
}, 0);
}, (err: any) => {
this.notify.handleErrors(err);
});
}
goTo(row: any) {
window.open(this.maarchParapheurUrl + '/dist/index.html#/documents/' + row.id, '_blank');