c2c89780f4e3d553db8b13f6acc77d3d5ac4be5f
[portal/sdk.git] /
1 import { Component, OnInit, Input, SimpleChanges } from '@angular/core';
2 import { Router } from '@angular/router';
3 import { environment } from '../../../../../environments/environment';
4 import {MatTabChangeEvent, VERSION} from '@angular/material';
5 import { Observable, Observer } from 'rxjs';
6
7
8 export interface ExampleTab {
9   label: string;
10   content: any;
11 }
12
13
14
15 @Component({
16   selector: 'app-header-tabs-component',
17   templateUrl: './header-tabs.component.html',
18   styleUrls: ['./header-tabs.component.css']
19 })
20 export class HeaderTabsComponent implements OnInit {
21
22   asyncTabs: Observable<ExampleTab[]>;
23
24   @Input("reportId") reportId : string;
25   @Input ("reportMode") reportMode : string;
26
27   finalReportId : string;
28   repMode : string;
29   navLinks : {}[];
30
31   tabChanged : any;
32   
33   constructor(private _router : Router) {
34
35     this.asyncTabs = new Observable((observer: Observer<ExampleTab[]>) => {
36       setTimeout(() => {
37         observer.next([
38           {label: 'Definition', content: '<app-pilot-page [reportId]="reportId"></app-pilot-page>'},
39          
40         ]);
41       }, 1000);
42     });
43     
44     //console.log(this.reportId);
45     if(this.reportId == "" && this.reportMode=="")
46     {
47       this.finalReportId = "-1";
48       this.repMode = "Create";
49       
50       this.reportId = "-1";
51       this.reportMode = "Create";
52       console.log(this.finalReportId, this.repMode);
53     }
54     else
55     {
56       if(this.reportId !== undefined && this.reportMode !== undefined)
57       {
58         this.finalReportId = this.reportId;
59         this.repMode = this.reportMode;
60         console.log(this.finalReportId, this.repMode);
61       }
62     }
63
64    
65    }
66
67   ngOnInit() {
68
69
70     if(this.reportId == "" && this.reportMode=="")
71     {
72       this.finalReportId = "-1";
73       this.repMode = "Create";
74
75       this.reportId = "-1";
76       this.reportMode = "Create";
77       console.log(this.finalReportId, this.repMode);
78     }
79     else
80     {
81       if(this.reportId !== undefined && this.reportMode !== undefined)
82       {
83         this.finalReportId = this.reportId;
84         this.repMode = this.reportMode;
85         console.log(this.finalReportId, this.repMode);
86       }
87     }
88    }
89
90    ngAfterViewInit()
91    {
92     //console.log(this.reportId);
93
94    
95
96     if(this.reportId == "" && this.reportMode=="")
97     {
98       this.finalReportId = "-1";
99       this.repMode = "Create";
100       
101       this.reportId = "-1";
102       this.reportMode = "Create";
103       console.log(this.finalReportId, this.repMode);
104     }
105     else
106     {
107       if(this.reportId !== undefined && this.reportMode !== undefined)
108       {
109         this.finalReportId = this.reportId;
110         this.repMode = this.reportMode;
111         console.log(this.finalReportId, this.repMode);
112       }
113     }
114    }
115
116    ngDoCheck()
117    {
118     // var id = this.finalReportId;
119     //  console.log(this.finalReportId);
120
121     this.tabChanged = (tabChangeEvent: MatTabChangeEvent): void => {
122       console.log('tabChangeEvent => ', tabChangeEvent);
123       console.log('index => ', tabChangeEvent.index);
124     };
125    }
126
127    ngOnChanges(changes: SimpleChanges)
128    {
129     this.tabChanged = (tabChangeEvent: MatTabChangeEvent): void => {
130       console.log('tabChangeEvent => ', tabChangeEvent);
131       console.log('index => ', tabChangeEvent.index);
132     };
133
134     // this.navLinks = [{
135     //   path : "definition/" + changes["reportId"]["currentValue"],
136     //   label : "Definition"
137     // },  
138     // {
139     //   path : "sql",
140     //   label : "SQL"
141     // },
142     // {
143     //   path : "columns",
144     //   label : "Columns"
145     // },
146     // {
147     //   path : "formFields",
148     //   label : "Form Fields"
149     // },
150     // {
151     //   path : "chartWizard",
152     //   label : "Chart Wizard"
153     // },
154     // {
155     //   path : "security",
156     //   label : "Security"
157     // },
158     // {
159     //   path : "log",
160     //   label : "Log"
161     // },
162     // {
163     //   path : "run/" + changes["reportId"]["currentValue"],
164     //   label : "Run"
165     // }];
166       console.log(changes);
167
168       // this._router.navigate(["search/definition", 7]);  
169    }
170   
171
172 }