summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.ts')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.ts525
1 files changed, 523 insertions, 2 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.ts
index 8509f089..b7e14bc6 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/security/security.component.ts
@@ -1,4 +1,5 @@
-import { Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit, Input, AfterViewInit } from '@angular/core';
+import { SecurityService } from './security.service';
@Component({
selector: 'app-security',
@@ -8,11 +9,531 @@ import { Component, OnInit, Input } from '@angular/core';
export class SecurityComponent implements OnInit {
@Input("reportId") reportId1 : string;
+ @Input("reportType") reportType : string;
+
+ reportOwnerList : {}[];
+ reportRoleList : {}[];
+ reportSecurityInfo : {};
+ reportUserList : any[];
+ reportSecurityRoles : any[];
+ showSpinner : boolean;
+ fetchCnt : number;
+ reportOwner : string;
+ reportOwnerId : string;
+ publicReport : string;
+ reportUser : string;
+ showUserListSpinner : boolean;
+ userEditAccessArr : boolean[];
+ userEditAccess : string;
+ showRoleListSpinner : boolean;
+ reportRole : string;
+ addRoleEditAccessArr : boolean[];
+ stepNo : string;
- constructor() { }
+ constructor(private _securityService : SecurityService) {
+ this.reportOwnerList = new Array();
+ this.reportRoleList = new Array();
+ this.reportSecurityInfo = new Object();
+ this.reportUserList = new Array();
+ this.reportSecurityRoles = new Array();
+ this.showSpinner = true;
+ this.fetchCnt = 0;
+ this.reportOwner = "";
+ this.publicReport = "";
+ this.showUserListSpinner = false;
+ this.userEditAccessArr = new Array();
+ this.showRoleListSpinner = false;
+ this.addRoleEditAccessArr = new Array();
+
+
+ }
ngOnInit() {
+ this.showSpinner = true;
+
+ if(this.reportType === "Dashboard")
+ {
+ this.stepNo = "2";
+ }
+ else
+ {
+ this.stepNo = "6";
+ }
+
+ this._securityService.getReportOwnerList()
+ .subscribe((responseOwnerList) => {
+ this.reportOwnerList = responseOwnerList;
+
+ // console.log(this.reportOwnerList);
+
+ this._securityService.getReportSecurityInfo()
+ .subscribe((responseSecurityInfo) => {
+ this.reportSecurityInfo = responseSecurityInfo;
+
+ console.log(this.reportSecurityInfo);
+
+ this.reportOwnerId = this.reportSecurityInfo["ownerId"];
+
+ this.publicReport = this.reportSecurityInfo["isPublic"] == "true" ? "YES" : "NO";
+
+ for(let k=0; k<this.reportOwnerList.length; k++)
+ {
+ if(this.reportOwnerId === this.reportOwnerList[k]["id"])
+ {
+ this.reportOwner = this.reportOwnerList[k]["name"];
+ }
+ }
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+
+
+
+ this._securityService.getReportUserList()
+ .subscribe((responseUserList) => {
+ this.reportUserList = responseUserList;
+
+ console.log(this.reportUserList);
+
+ for(let ru=0; ru<this.reportUserList.length; ru++)
+ {
+ if(this.reportUserList[ru]["readOnly"] === true)
+ {
+ this.userEditAccessArr[ru] = false;
+ }
+ else
+ {
+ this.userEditAccessArr[ru] = true;
+ }
+ }
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+ this._securityService.getReportSecurityRoles()
+ .subscribe((responseSecurityRoles) => {
+ this.reportSecurityRoles = responseSecurityRoles;
+
+ console.log(this.reportSecurityRoles);
+
+ for(let sr=0; sr<this.reportSecurityRoles.length; sr++)
+ {
+ if(this.reportSecurityRoles[sr]["readOnly"] === true)
+ {
+ this.addRoleEditAccessArr[sr] = false;
+ }
+ else
+ {
+ this.addRoleEditAccessArr[sr] = true;
+ }
+ }
+ console.log(this.reportSecurityRoles);
+
+ this._securityService.getReportRoleList()
+ .subscribe((responseRoleList) => {
+ this.reportRoleList = responseRoleList;
+
+ console.log(this.reportRoleList);
+
+ for(let m=0; m<this.reportSecurityRoles.length; m++)
+ {
+ for(let n=0; n<this.reportRoleList.length; n++)
+ {
+ if(this.reportSecurityRoles[m] === this.reportRoleList[n])
+ {
+ this.reportRoleList.splice(n, 1);
+ }
+ }
+ }
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+
+ }
+
+ addReportUser()
+ {
+
+ this.showUserListSpinner = true;
+ let reportUserId = "";
+ for(let p=0; p<this.reportOwnerList.length; p++)
+ {
+ if(this.reportOwnerList[p]["name"] === this.reportUser)
+ {
+ reportUserId = this.reportOwnerList[p]["id"];
+ }
+ }
+
+ console.log(reportUserId);
+
+ this._securityService.addReportUser(reportUserId)
+ .subscribe((responseAddUser) => {
+
+
+ this._securityService.getReportUserList()
+ .subscribe((responseUserList) => {
+ this.reportUserList = responseUserList;
+
+ console.log(this.reportUserList);
+
+ this.showUserListSpinner = false;
+ });
+
+
+ });
+
+ }
+
+ removeReportUser(reportUserName : string)
+ {
+ this.showUserListSpinner = true;
+ let reportUserId = "";
+ for(let p=0; p<this.reportOwnerList.length; p++)
+ {
+ if(this.reportOwnerList[p]["name"] === reportUserName)
+ {
+ reportUserId = this.reportOwnerList[p]["id"];
+ this.userEditAccessArr[p] = false;
+ }
+ }
+
+ console.log(reportUserId);
+
+ this._securityService.removeReportUser(reportUserId)
+ .subscribe((responseRemoveUser) => {
+
+
+ this._securityService.getReportUserList()
+ .subscribe((responseUserList) => {
+ this.reportUserList = responseUserList;
+
+ console.log(this.reportUserList);
+
+ this.showUserListSpinner = false;
+ });
+
+
+ });
+ }
+
+ addUserEditAccess(reportUserId : string, reportUserIndex : number)
+ {
+ console.log(reportUserId, reportUserIndex);
+ console.log(this.userEditAccessArr);
+ let readOnly="";
+
+ if(this.userEditAccessArr[reportUserIndex] === true)
+ {
+ readOnly = "N";
+ }
+ else
+ {
+ readOnly = "Y";
+ }
+
+ this._securityService.addUserEditAccess(reportUserId, readOnly)
+ .subscribe((responseAddUserAccess) => {
+
+ });
+ }
+
+
+ addReportRole()
+ {
+ let roleId;
+ this.showRoleListSpinner = true;
+
+ console.log(this.reportRoleList);
+
+ for(let ro=0; ro<this.reportRoleList.length; ro++)
+ {
+ if(this.reportRoleList[ro]["name"] === this.reportRole)
+ {
+ roleId = this.reportRoleList[ro]["id"];
+ }
+ }
+
+ console.log(roleId);
+
+ this._securityService.addReportRole(roleId)
+ .subscribe((addRoleResponse) => {
+
+ this._securityService.getReportSecurityRoles()
+ .subscribe((responseSecurityRoles) => {
+ this.reportSecurityRoles = responseSecurityRoles;
+
+ console.log(this.reportSecurityRoles);
+
+ this._securityService.getReportRoleList()
+ .subscribe((responseRoleList) => {
+ this.reportRoleList = responseRoleList;
+
+ console.log(this.reportRoleList);
+
+ for(let m=0; m<this.reportSecurityRoles.length; m++)
+ {
+ for(let n=0; n<this.reportRoleList.length; n++)
+ {
+ if(this.reportSecurityRoles[m] === this.reportRoleList[n])
+ {
+ this.reportRoleList.splice(n, 1);
+ }
+ }
+ }
+
+ this.showRoleListSpinner = false;
+ });
+
+ });
+
+ });
+ }
+
+ removeReportRole(roleId : string)
+ {
+ this.showRoleListSpinner = true;
+
+ for(let rl=0; rl<this.reportSecurityRoles.length; rl++)
+ {
+ if(this.reportSecurityRoles[rl]["id"] === roleId)
+ {
+ this.addRoleEditAccessArr[rl] = false;
+ }
+ }
+
+
+ this._securityService.removeReportRole(roleId)
+ .subscribe((removeRoleResponse) => {
+ this._securityService.getReportSecurityRoles()
+ .subscribe((responseSecurityRoles) => {
+ this.reportSecurityRoles = responseSecurityRoles;
+
+ console.log(this.reportSecurityRoles);
+
+ this._securityService.getReportRoleList()
+ .subscribe((responseRoleList) => {
+ this.reportRoleList = responseRoleList;
+
+ console.log(this.reportRoleList);
+
+ for(let m=0; m<this.reportSecurityRoles.length; m++)
+ {
+ for(let n=0; n<this.reportRoleList.length; n++)
+ {
+ if(this.reportSecurityRoles[m] === this.reportRoleList[n])
+ {
+ this.reportRoleList.splice(n, 1);
+ }
+ }
+ }
+
+ this.showRoleListSpinner = false;
+ });
+
+ });
+ });
+ }
+
+ addRoleEditAccess(roleId : string, roleIndex : number)
+ {
+ console.log(this.addRoleEditAccessArr);
+ let readOnly = "";
+
+ if(this.addRoleEditAccessArr[roleIndex] === true)
+ {
+ readOnly = "N";
+ }
+ else
+ {
+ readOnly = "Y";
+ }
+
+
+ this._securityService.addRoleEditAccess(roleId, readOnly)
+ .subscribe((responseEditRoleAccess) => {
+
+ });
+ }
+
+
+ saveSecurityTabData()
+ {
+ this.fetchCnt = 0;
+ let finalPostObj = new Object();
+
+ // console.log(this.reportOwnerList);
+ for(let kl=0; kl<this.reportOwnerList.length; kl++)
+ {
+ if(this.reportOwnerList[kl]["name"] == this.reportOwner)
+ {
+ finalPostObj["userId"] = this.reportOwnerList[kl]["id"];
+ }
+ }
+
+ if(this.publicReport === "YES")
+ {
+ finalPostObj["isPublic"] = "true";
+ }
+ else
+ {
+ finalPostObj["isPublic"] = "false";
+ }
+ // console.log(finalPostObj);
+
+ this._securityService.saveSecurityTabInfo(finalPostObj)
+ .subscribe((responseFinalPost) => {
+
+
+ this.showSpinner = true;
+
+ this._securityService.getReportOwnerList()
+ .subscribe((responseOwnerList) => {
+ this.reportOwnerList = responseOwnerList;
+
+ console.log(this.reportOwnerList);
+
+ this._securityService.getReportSecurityInfo()
+ .subscribe((responseSecurityInfo) => {
+ this.reportSecurityInfo = responseSecurityInfo;
+
+ console.log(this.reportSecurityInfo);
+
+ this.reportOwnerId = this.reportSecurityInfo["ownerId"];
+
+ this.publicReport = this.reportSecurityInfo["isPublic"] == "true" ? "YES" : "NO";
+
+ for(let k=0; k<this.reportOwnerList.length; k++)
+ {
+ if(this.reportOwnerId === this.reportOwnerList[k]["id"])
+ {
+ this.reportOwner = this.reportOwnerList[k]["name"];
+ }
+ }
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+
+
+
+ this._securityService.getReportUserList()
+ .subscribe((responseUserList) => {
+ this.reportUserList = responseUserList;
+
+ console.log(this.reportUserList);
+
+ for(let ru=0; ru<this.reportUserList.length; ru++)
+ {
+ if(this.reportUserList[ru]["readOnly"] === true)
+ {
+ this.userEditAccessArr[ru] = false;
+ }
+ else
+ {
+ this.userEditAccessArr[ru] = true;
+ }
+ }
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+ this._securityService.getReportSecurityRoles()
+ .subscribe((responseSecurityRoles) => {
+ this.reportSecurityRoles = responseSecurityRoles;
+
+ console.log(this.reportSecurityRoles);
+
+ for(let sr=0; sr<this.reportSecurityRoles.length; sr++)
+ {
+ if(this.reportSecurityRoles[sr]["readOnly"] === true)
+ {
+ this.addRoleEditAccessArr[sr] = false;
+ }
+ else
+ {
+ this.addRoleEditAccessArr[sr] = true;
+ }
+ }
+ console.log(this.reportSecurityRoles);
+
+ this._securityService.getReportRoleList()
+ .subscribe((responseRoleList) => {
+ this.reportRoleList = responseRoleList;
+
+ console.log(this.reportRoleList);
+
+ for(let m=0; m<this.reportSecurityRoles.length; m++)
+ {
+ for(let n=0; n<this.reportRoleList.length; n++)
+ {
+ if(this.reportSecurityRoles[m] === this.reportRoleList[n])
+ {
+ this.reportRoleList.splice(n, 1);
+ }
+ }
+ }
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+ this.fetchCnt++;
+ if(this.fetchCnt == 5)
+ {
+ this.showSpinner = false;
+ }
+ });
+
+ });
}
}