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============================================
38 import { Component, OnInit, ViewChild, Input} from '@angular/core';
39 import { WebAnalyticsService } from '../../shared/services/index';
40 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
41 import { MatTableDataSource } from '@angular/material';
42 import { MatSort, MatPaginator } from '@angular/material';
43 import { WebAnalyticsDetailsDialogComponent } from './web-analytics-details-dialog/web-analytics-details-dialog.component';
44 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
45 import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
48 selector: 'app-web-analytics',
49 templateUrl: './web-analytics.component.html',
50 styleUrls: ['./web-analytics.component.scss']
52 export class WebAnalyticsComponent implements OnInit {
55 isAppSelectDisabled: boolean;
58 userAppReports: any = [];
59 userTableAppReports: any= [];
60 userJourneyAnalytics: any = [];
63 isEditMode: boolean = false;
65 displayedColumns: string[] = ['applicationName', 'reportName', 'reportURL','delete'];
66 dataSource = new MatTableDataSource(this.userTableAppReports);
67 @ViewChild(MatSort) sort: MatSort;
68 @ViewChild(MatPaginator) paginator: MatPaginator;
71 constructor(public webAnalyticsService: WebAnalyticsService, public ngbModal: NgbModal) { }
75 this.application = null;
76 this.isAppSelectDisabled = false;
77 this.selectApp = 'All Applications';
80 appName: 'All Applications',
81 value: 'All Applications'
84 this.getAllWebAnalyticsReport();
89 getAllWebAnalyticsReport(){
90 //console.log("getAllWebAnalyticsReport called");
91 this.webAnalyticsService.getAllWebAnalyticsReport()
94 if (this.result == null || this.result == 'undefined') {
95 console.log('WebAnalyticsService::getAllWebAnalyticsReport Failed: Result or result.data is null');
97 //console.log('WebAnalyticsService::getAllWebAnalyticsReport', this.result);
98 for (let i = 0; i < this.result.length; i++) {
99 var userTableAppReport = {
100 reportName: this.result[i].reportName,
101 reportSrc: this.result[i].reportSrc,
102 appName: this.result[i].appName,
103 appId : this.result[i].appId,
104 resourceId : this.result[i].resourceId
106 this.userTableAppReports.push(userTableAppReport);
108 this.populateTableData(this.userTableAppReports);
115 deleteWebAnalyticsReport(deleteObj: any){
116 let confirmationMsg = 'You are about to delete this Web Analytics : ' + deleteObj.reportName+ '. Click OK to continue.';
117 this.openInformationModal("Confirmation",confirmationMsg).result.then((result) => {
118 if (result === 'Ok') {
119 this.userTableAppReports.splice(this.userTableAppReports.indexOf(deleteObj), 1);
120 this.webAnalyticsService.deleteWebAnalyticsReport(deleteObj)
121 .subscribe(_data => {
122 this.userTableAppReports = [];
123 this.getAllWebAnalyticsReport();
134 //console.log("getUserApps called");
135 this.webAnalyticsService.getWebAnalyticsAppReports()
136 .subscribe(_data => {
138 if (this.result == null || this.result == 'undefined') {
139 console.log('WebAnalyticsService::getServiceList Failed: Result or result.data is null');
141 for (let i = 0; i < this.result.length; i++) {
142 var userAppReport = {
145 reportName: this.result[i].reportName,
146 reportSrc: this.result[i].reportSrc,
147 appName: this.result[i].appName,
150 if(this.result[i].reportSrc.includes("appName")){
151 let appName = this.result[i].reportSrc.split("appName=").splice(-1)[0];
152 this.webAnalyticsService.getUserJourneyList(appName)
153 .subscribe(_data => {
154 let userJourneyReports = {
157 title: appName+" User journey",
158 analyticsList: this.result
160 this.userJourneyAnalytics.push(userJourneyReports);
166 this.userAppReports.push(userAppReport);
169 for (var i = 0; i < this.result.length; i++) {
171 appName: this.result[i].appName,
174 this.userApps.push(userApp);
176 /*angular.forEach($scope.userApps, function(value, key) {
177 var index = $scope.uniqueUserApps.indexOf(value.appName);
180 $scope.uniqueUserApps.push(value.appName);
185 for (let i = 1; i <= $scope.uniqueUserApps.length; i++) {
186 this.sortedApps.push({
188 appName: $scope.uniqueUserApps[i - 1],
189 value: $scope.uniqueUserApps[i - 1]
194 //console.log(error);
198 openWebAnalyticsModal(rowData: any) {
199 const modalRef = this.ngbModal.open(WebAnalyticsDetailsDialogComponent, { size: 'lg' });
200 //console.log("selectedData in parent",rowData);
201 if(rowData != 'undefined' && rowData){
202 modalRef.componentInstance.userTableAppReport = rowData;
203 this.isEditMode = true;
205 modalRef.componentInstance.userTableAppReport = {};
206 this.isEditMode = false;
208 modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => {
209 if(receivedEntry.httpStatusCode && receivedEntry.httpStatusCode ==='200' ||
210 receivedEntry.status && receivedEntry.status === 'OK'){
211 this.userTableAppReports = [];
212 this.getAllWebAnalyticsReport();
218 populateTableData(userTableAppReports: Array<Object>){
219 this.dataSource = new MatTableDataSource(userTableAppReports);
220 this.dataSource.sort = this.sort;
221 this.dataSource.paginator = this.paginator;
224 applyFilter(filterValue: string) {
225 this.dataSource.filter = filterValue.trim().toLowerCase();
228 openConfirmationModal(_title: string, _message: string) {
229 const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent);
230 modalInfoRef.componentInstance.title = _title;
231 modalInfoRef.componentInstance.message = _message;
234 openInformationModal(_title: string, _message: string){
235 const modalInfoRef = this.ngbModal.open(InformationModalComponent);
236 modalInfoRef.componentInstance.title = _title;
237 modalInfoRef.componentInstance.message = _message;