1
|
import {Component, OnInit} from '@angular/core';
|
2
|
import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
3
|
import {FileDownloadSearchComponent} from '../../file-download-search/file-download-search.component';
|
4
|
import {InvoiceDownloadSchedulerService} from '../../../../../shared/services/invoice-download-scheduler.service';
|
5
|
import { NotificationsHandlingService } from 'src/app/shared/services/notifications-handling/notifications-handling.service';
|
6
|
|
7
|
@Component({
|
8
|
selector: 'app-file-download-scheduler-configurations-dialog',
|
9
|
templateUrl: './file-download-scheduler-configurations-dialog.component.html',
|
10
|
styleUrls: ['./file-download-scheduler-configurations-dialog.component.scss']
|
11
|
|
12
|
})
|
13
|
export class FileDownloadSchedulerConfigurationsDialogComponent implements OnInit {
|
14
|
//TODO when this window first open it doesn't show the correct value in the dropdown selected after the first time everything is fine
|
15
|
frequency: string;
|
16
|
frequencies: string[] = [];
|
17
|
|
18
|
constructor(public ref: DynamicDialogRef, public config: DynamicDialogConfig, private dialogService: DialogService
|
19
|
, private downloadService: InvoiceDownloadSchedulerService, private notificationService: NotificationsHandlingService) {
|
20
|
this.config.header = 'Configuration';
|
21
|
// TODO this must be fixed
|
22
|
//this.config.width = '23%';
|
23
|
//this.config.contentStyle = {'text-align': 'center', height: '100%'};
|
24
|
}
|
25
|
|
26
|
ngOnInit(): void {
|
27
|
this.downloadService.getTimeIntervals().subscribe(x => {
|
28
|
console.log(x);
|
29
|
this.frequencies = x;
|
30
|
this.frequencies = this.frequencies.map(item => item = `Every ${item} min`);
|
31
|
this.frequency = this.config?.data?.frequency;
|
32
|
//this.config.height = `${this.frequencies.length * 5 + 5}%`;
|
33
|
});
|
34
|
}
|
35
|
|
36
|
onSave(): void {
|
37
|
this.downloadService.updateTimeIntervals(this.frequency).subscribe(x => {
|
38
|
this.notificationService.showUpdateTimeIntervalsSuccess();
|
39
|
this.ref.close(this.frequency);
|
40
|
});
|
41
|
}
|
42
|
|
43
|
closeDialog(): void {
|
44
|
this.ref.close();
|
45
|
}
|
46
|
}
|