prod iss fixes on user

This commit is contained in:
venbatechnologies@gmail.com 2019-06-29 17:01:13 +05:30
parent 561287e1e9
commit d54d5dcd6c
3 changed files with 66 additions and 46 deletions

View File

@ -272,6 +272,7 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
//alert();
this.aws.logout().subscribe(res=>{
//alert("res");
localStorage.removeItem('user_role');
this.router.navigate(['/authentication/login']);
})
}

View File

@ -65,6 +65,7 @@ export class RegisterComponent implements OnInit {
if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined) {
} else {
this.regdata();
}
@ -95,20 +96,22 @@ export class RegisterComponent implements OnInit {
regdata() {
this.users.entityType().subscribe(res => {
this.types = res;
if (this.types.status == 200) {
this.types = this.types.records;
//console.log(this.types);
this.regForm.controls['type'].setValue(this.types[0]);
this.users.roles().subscribe(res=>{
// console.log(res);
this.roleload = false;
//console.log(roleload);
this.role = res;
if(this.role.dataStatus == true){
this.role = this.role.records;
this.checktype(this.types[0]);
}
});
// this.users.roles().subscribe(res=>{
// console.log('res',res);
// this.roleload = false;
// console.log('this.roleload',this.roleload);
// this.role = res;
// if(this.role.dataStatus == true){
// this.role = this.role.records;
// this.checktype(this.types[0]);
// }
// });
this.callrole(1,this.types[0],'');
}
});
this.users.City().subscribe(res => {
@ -267,42 +270,27 @@ this.loader = true;
this.usersData = this.users.localUserId;
this.users.entityType().subscribe(res => {
this.types = res;
if (this.types.status == 200) {
let type = this.types.records.filter(type=>type.isactive ==1);
let type = this.types.records.filter(type=>type.isactive ==1);
this.types= type.filter(type => type.entity_type_id == this.usersData.fk_entity_type_id);
this.regForm.controls['type'].setValue(this.types[0]);
this.users.entitiesDetails().subscribe(res=>{
this.entitiesDetails = res;
if(this.entitiesDetails.dataStatus == true){
this.entitiesDetails = this.entitiesDetails.records.filter(ent=>ent.isactive ==1);
let entitiy = this.entitiesDetails.filter(ent=>this.usersData.fk_entity_id == ent.entity_id)[0];
this.regForm.controls['lenVenName'].setValue(entitiy);
this.users.roles().subscribe(res=>{
this.roleload = false;
//console.log(roleload);
this.role = res;
if(this.role.dataStatus == true){
this.role = this.role.records;
this.checktype(this.types[0]);
let role = this.role.filter(role=>role.role_type == this.usersData.fk_entity_type_id && role.role_id == this.usersData.user_role)[0];
this.regForm.controls['role'].setValue(role);
// console.log(role);
this.toggleAllSelection(role,this.types[0]);
// this.regForm.controls['role'].setValue(role);
}
this.regForm.controls['type'].setValue(this.types[0]);
this.users.entitiesDetails().subscribe(res=>{
this.entitiesDetails = res;
if(this.entitiesDetails.dataStatus == true){
this.entitiesDetails = this.entitiesDetails.records.filter(ent=>ent.isactive ==1);
let entitiy = this.entitiesDetails.filter(ent=>this.usersData.fk_entity_id == ent.entity_id)[0];
this.regForm.controls['lenVenName'].setValue(entitiy);
this.callrole(2,this.types[0],this.usersData);
}
else{
this.callrole(2,this.types[0],this.usersData);
}
},error => {
alert('Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!');
});
}
})
}
});
@ -387,9 +375,40 @@ this.loader = true;
onResetForEdit(){
this.userupdate();
}
/** to call role api
* params are flag are if 1 - add and 2 - edit
**/
callrole(flag,type,usersData){
this.users.roles().subscribe(res=>{
this.roleload = false;
this.role = res;
if(this.role.dataStatus == true){
this.role = this.role.records;
this.checktype(type);
if(flag == 2){
let role = this.role.filter(role=>role.role_type == usersData.fk_entity_type_id && role.role_id == usersData.user_role)[0];
this.regForm.controls['role'].setValue(role);
this.toggleAllSelection(role,type);
// this.regForm.controls['role'].setValue(role);
}
}
else{
console.log('something went wrong - role master can`t able to call');
}
},error => {
alert('Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!');
});
}
checktype(e){
// console.log(e);
this.roleAccess= false;
let userRole:any;
if(e !== undefined){
@ -397,7 +416,7 @@ this.loader = true;
//console.log(roleload);
this.roles = this.role.filter(role=>role.role_type == e.entity_type_id);
// console.log(this.roles);
// let role = this.roles.filter(role=>role.role_id == this.usersData.user_role_id);
// console.log(role);
// this.regForm.controls['role'].setValue(role);
@ -419,7 +438,7 @@ this.loader = true;
this.entities = this.entitiesDetails.filter(entity=>entity.fk_entity_type_id == e.entity_type_id);
break;
default :
this.typeValue = -1;
this.typeValue = -1;
break;
}

View File

@ -3,7 +3,7 @@ export const environment = {
environmentName: 'Production Environment',//Live Environment.
apiEndpoint: 'https://pdgenie.com/sparqprod/api',
apiEndpoint: 'https://pdgenie.com/sparqprod/api/',
authorization: 'TnAwuc64pVpcB9xf',