added svcapi ui and camunda code
[it/otf.git] / otf-frontend / client / src / app / layout / components / stats / schedule / schedule.component.ts
1 /*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
2 #                                                                              #\r
3 #   Licensed under the Apache License, Version 2.0 (the "License");            #\r
4 #   you may not use this file except in compliance with the License.           #\r
5 #   You may obtain a copy of the License at                                    #\r
6 #                                                                              #\r
7 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
8 #                                                                              #\r
9 #   Unless required by applicable law or agreed to in writing, software        #\r
10 #   distributed under the License is distributed on an "AS IS" BASIS,          #\r
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
12 #   See the License for the specific language governing permissions and        #\r
13 #   limitations under the License.                                             #\r
14 ##############################################################################*/\r
15 \r
16 \r
17 import { Component, OnInit, NgZone, ChangeDetectorRef } from '@angular/core';\r
18 //import material from "@amcharts/amcharts4/themes/material";\r
19 import am4themes_animated from "@amcharts/amcharts4/themes/animated";\r
20 import { GroupService } from 'app/shared/services/group.service';\r
21 import { StatsService } from '../stats.service';\r
22 import { Observable, Subject } from 'rxjs';\r
23 \r
24 export interface ScheduleElement {\r
25   name: string;\r
26   dateExec: string;\r
27   timeExec: string;\r
28 }\r
29 \r
30 @Component({\r
31   selector: 'app-schedule',\r
32   templateUrl: './schedule.component.pug',\r
33   styleUrls: ['./schedule.component.scss']\r
34 })\r
35 \r
36 export class ScheduleComponent implements OnInit {\r
37 \r
38   protected stats: StatsService;\r
39   public doneLoadingfalse;\r
40   public dataSource;\r
41 \r
42   displayedColumns: string[] = ['name', 'dateExec', 'timeExec'];\r
43 \r
44   constructor(private zone: NgZone, private _groups: GroupService, private statsService: StatsService, private changeDetector: ChangeDetectorRef) {\r
45     this.stats = statsService;\r
46   }\r
47 \r
48   ngOnInit() {\r
49 \r
50     this.stats.onDefaultDataCallFinished().subscribe(res => {\r
51       this.dataSource = this.stats.getData("Schedule");\r
52     })\r
53     this.dataSource = this.stats.getData("Schedule");\r
54 \r
55     this.refresh();\r
56   }\r
57 \r
58   defaultDataListener(): Observable<Object> {\r
59     return this.stats.finishedDefaultData;\r
60   }\r
61 \r
62   refresh(){\r
63     this.stats.onScheduleChangeFinished().subscribe(res => {\r
64       this.dataSource = this.stats.getData("Schedule");\r
65       this.dataSource = this.dataSource.slice();\r
66       \r
67       this.changeDetector.detectChanges();\r
68     })\r
69   }\r
70 \r
71 }