2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
39 import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core';
40 import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
41 import { WebAnalyticsService } from 'src/app/shared/services';
44 selector: 'app-web-analytics-details-dialog',
45 templateUrl: './web-analytics-details-dialog.component.html',
46 styleUrls: ['./web-analytics-details-dialog.component.scss']
48 export class WebAnalyticsDetailsDialogComponent implements OnInit {
51 isEditMode: boolean = false;
52 isAllApplications: boolean = true;
54 allApplications: any = [];
70 constructor(public activeModal: NgbActiveModal, public ngbModal: NgbModal,
71 public webAnalyticsService : WebAnalyticsService) { }
73 @Input() userTableAppReport: any;
74 @Output() passEntry: EventEmitter<any> = new EventEmitter();
77 this.isAllApplications = true;
78 if(this.userTableAppReport.appName){
79 this.isEditMode = true;
81 this.isEditMode = false;
83 //console.log("IsEditMode in Web analytycs Dialog :: ",this.isEditMode)
84 this.getAllApplications();
88 this.isAllApplications = true;
89 this.webAnalyticsService.getAllApplications()
92 if (this.result == null || this.result == 'undefined') {
93 //console.log('WebAnalyticsService::getAllApplications Failed: Result or result.data is null');
95 for (let i = 0; i < this.result.length; i++) {
97 appId : this.result[i].id,
98 appName: this.result[i].name,
99 enabled : this.result[i].enabled,
100 restrictedApp :this.result[i].restrictedApp,
102 this.allApps.push(application);
104 for (let i = 0; i < this.allApps.length; i++) {
105 if((this.allApps[i].enabled == true && this.allApps[i].restrictedApp == false) || (this.allApps[i].appId == 1) ) {
106 var validApplication = {
107 appId : this.allApps[i].appId,
108 appName: this.allApps[i].appName,
110 this.allApplications.push(validApplication);
115 this.isAllApplications = false;
121 //console.log("Save Changes Called.");
122 let selectedApplication = this.userTableAppReport.appName;
123 this.newAppModel.appId = selectedApplication.appId;
124 this.newAppModel.appName = selectedApplication.appName;
125 this.newAppModel.reportName = this.userTableAppReport.reportName;
126 this.newAppModel.reportSrc = this.userTableAppReport.reportSrc;
127 this.newAppModel.resourceId = this.userTableAppReport.resourceId;
129 if (this.isEditMode) {
130 this.newAppModel.appId = this.userTableAppReport.appId;
131 //console.log("Update Analytics..newAppModel :: ",this.userTableAppReport);
132 this.webAnalyticsService.updateWebAnalyticsReport(this.newAppModel)
133 .subscribe(_data => {
135 //console.log("Update Analytics Response:: ",this.result);
136 this.passEntry.emit(this.result);
137 this.ngbModal.dismissAll();
139 this.isAllApplications = false;
143 //console.log("Save Analytics.newAppModel :: ",this.userTableAppReport);
144 this.webAnalyticsService.save(this.newAppModel)
145 .subscribe(_data => {
147 //console.log("Save Analytics Response:: ",this.result);
148 this.passEntry.emit(this.result);
149 this.ngbModal.dismissAll();
151 this.isAllApplications = false;