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