Newer
Older
import { Component, OnInit, AfterViewInit, Input } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
import { AppService } from '@service/app.service';
import { Time } from '@angular/common';
import { TimeAgoPipe } from '@plugins/timeAgo.pipe';
import { catchError, tap } from 'rxjs/operators';
import { of } from 'rxjs';
import { NotificationService } from '@service/notification/notification.service';
@Component({
selector: 'app-tile-last-mails-view',
templateUrl: 'tile-last-mails-view.component.html',
styleUrls: ['tile-last-mails-view.component.scss'],
providers: [TimeAgoPipe]
})
export class TileLastMailsViewDashboardComponent implements OnInit, AfterViewInit {
@Input() view: string = 'list';
testDate = new Date();
label: 'Mes derniers courriers consultés';
resources: any[] = [];
constructor(
public translate: TranslateService,
public http: HttpClient,
public appService: AppService,
async ngAfterViewInit(): Promise<void> {
console.log(this.view);
await this['get_' + this.view]();
this.loading = false;
}
async changeView(view: string) {
console.log(view);
this.loading = true;
await this['get_' + view]();
this.view = view;
this.loading = false;
}
get_list() {
return new Promise((resolve) => {
// FOR TEST
setTimeout(() => {
this.resources = [
{
recipient: 'Jan-louis ERCOLANNI (MAARCH)',
subject: 'Réservation bal des basketteurs',
creationDate: '26-01-2021',
},
{
recipient: 'Jan-louis ERCOLANNI (MAARCH)',
subject: 'Réservation bal des basketteurs',
creationDate: '26-01-2021',
},
{
recipient: 'Jan-louis ERCOLANNI (MAARCH)',
subject: 'Réservation bal des basketteurs',
creationDate: '26-01-2021',
},
{
recipient: 'Jan-louis ERCOLANNI (MAARCH)',
subject: 'Réservation bal des basketteurs',
creationDate: '26-01-2021',
},
{
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
recipient: 'Jan-louis ERCOLANNI (MAARCH)',
subject: 'Réservation bal des basketteurs',
creationDate: '26-01-2021',
}
];
resolve(true);
}, 3000);
/*this.http.get('../rest/???').pipe(
tap((data: any) => {
this.resources = data;
resolve(true);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();*/
});
}
get_resume() {
return new Promise((resolve) => {
// FOR TEST
setTimeout(() => {
this.countResources = 23;
resolve(true);
}, 3000);
/*this.http.get('../rest/???').pipe(
tap((data: any) => {
this.countResources = data;
resolve(true);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();*/
});
}
get_chart() {
return new Promise((resolve) => {
// FOR TEST
setTimeout(() => {
this.resources = [
{
name: 'Litige',
value: 24
},
{
name: 'Convocation',
value: 12
},
{
name: 'Abonnement',
value: 53
},
{
name: 'Réservation',
value: 21
},
{
name: 'Invitation',
value: 2
}
];
resolve(true);
}, 3000);
/*this.http.get('../rest/???').pipe(
tap((data: any) => {
this.resources = data;
resolve(true);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();*/
});