import { Component, OnInit, Input, AfterViewInit } from '@angular/core'; import { SecurityService } from './security.service'; @Component({ selector: 'app-security', templateUrl: './security.component.html', styleUrls: ['./security.component.css'] }) 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(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.reportUserList = responseUserList; console.log(this.reportUserList); for(let ru=0; ru { this.reportSecurityRoles = responseSecurityRoles; console.log(this.reportSecurityRoles); for(let sr=0; sr { this.reportRoleList = responseRoleList; console.log(this.reportRoleList); for(let m=0; m { 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._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._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._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 { }); } saveSecurityTabData() { this.fetchCnt = 0; let finalPostObj = new Object(); // console.log(this.reportOwnerList); for(let kl=0; kl { 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.reportUserList = responseUserList; console.log(this.reportUserList); for(let ru=0; ru { this.reportSecurityRoles = responseSecurityRoles; console.log(this.reportSecurityRoles); for(let sr=0; sr { this.reportRoleList = responseRoleList; console.log(this.reportRoleList); for(let m=0; m