diff --git a/ng6-seed/src/app/_guard/token.interceptor.ts b/ng6-seed/src/app/_guard/token.interceptor.ts index 48ff7d06e..e5b78dc5e 100644 --- a/ng6-seed/src/app/_guard/token.interceptor.ts +++ b/ng6-seed/src/app/_guard/token.interceptor.ts @@ -42,7 +42,7 @@ export class TokenInterceptor implements HttpInterceptor{ return (error: any): Observable => { if(error instanceof HttpErrorResponse){ console.error("Error: " + error.status); - if(error.status == 401 || error.status == 500){ + if(error.status == 401){ localStorage.clear(); this.router.navigate(['/authentication/login']); } diff --git a/ng6-seed/src/app/settings/service/user.service.ts b/ng6-seed/src/app/settings/service/user.service.ts index cdbe12f5e..a41da7000 100644 --- a/ng6-seed/src/app/settings/service/user.service.ts +++ b/ng6-seed/src/app/settings/service/user.service.ts @@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs/internal/Observable'; import { AwsService } from '../../AwsService/aws.service'; import { environment } from 'environments/environment'; -const apiurl = "http://ssa.sineedge.com/sparqapi/api/";; +const apiurl = "http://ssa.sineedge.com/sparqapi/api/"; const currentdate = new Date().toJSON().slice(0,19).replace('T',' '); @Injectable({ @@ -64,6 +64,26 @@ export class UserService { let master_name = {'master_name':'LENDERHIERARCHY'}; return this.http.post(apiurl+'getListOfMaster',master_name); } + products(){ + + let master_name = {'master_name':'PRODUCTS'}; + return this.http.post(apiurl+'getListOfMaster',master_name); + } + pdType(){ + + let master_name = {'master_name':'PDTYPE'}; + return this.http.post(apiurl+'getListOfMaster',master_name); + } + pdTeam(){ + + let master_name = {'master_name':'PDTEAM'}; + return this.http.post(apiurl+'getListOfMaster',master_name); + } + customerSegment(){ + + let master_name = {'master_name':'CUSTOMERSEGMENT'}; + return this.http.post(apiurl+'getListOfMaster',master_name); + } /** @@ -109,6 +129,7 @@ export class UserService { roles.push({ "user_role": role.GroupName }); } + let designation:any; if(users.type.entity_type_id ==2){ let lenderhie:any =[]; @@ -118,6 +139,16 @@ export class UserService { }else if(users.type.entity_type_id ==1){ designation =users.designation.designation_id; } + + + let pdofficer = { + 'fk_pd_type_id':users.pdtype.pd_type_id, + 'fk_product_id':users.product.product_id, + 'fk_customer_segment':users.customer.customer_segment_id, + 'fk_team_id':users.pdteam.pdteam_id, + 'fk_user_id':users.userid + + }; let records:any = { "userid":users.userid, "aws_name": aws_name, @@ -146,7 +177,8 @@ export class UserService { formData.append('records',JSON.stringify(records)); formData.append('roles',JSON.stringify(roles)); formData.append('profilepic',users.userpic); - console.log(records); + formData.append('pdofficer',JSON.stringify(pdofficer)); + //new Response(formData).text().then(console.log); //let headers = this.shared.headercofig(''); diff --git a/ng6-seed/src/app/settings/users/register/register.component.html b/ng6-seed/src/app/settings/users/register/register.component.html index f827bbff1..ecc6daee6 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.html +++ b/ng6-seed/src/app/settings/users/register/register.component.html @@ -11,6 +11,8 @@
+ Personal

+
@@ -32,7 +34,7 @@
- + Account Details

@@ -50,7 +52,7 @@ - + Contact Information

@@ -87,65 +89,53 @@
- - - -- - - {{types.name}} - - - Select User Role - Select User Role - - - - -- - - {{types.name}} - - - - - - - - - - - {{role.GroupName}} - - - - Select User Role - Select User Role - - - - - + + + -- + + {{s.name}} + + + + + + + -- + + {{c.name}} + + + +
+ Role Information

- - - -- - - {{s.name}} - - - - - - - -- - - {{c.name}} - - - - + + + -- + + {{types.name}} + + + Select User Role + Select User Role + + + + + + + + + + {{role.GroupName}} + + +
+ Select User Role + Select User Role +
@@ -165,11 +155,52 @@
+
+ + + -- + + {{C.name}} + + + + + + + -- + + {{P.name}} + + + + +
+
+ + + -- + + {{pd.team_name}} + + + + + + + -- + + {{PDT.type_name}} + + + + +
UserProfile {{img}} +
@@ -183,7 +214,7 @@ - + diff --git a/ng6-seed/src/app/settings/users/register/register.component.ts b/ng6-seed/src/app/settings/users/register/register.component.ts index fe996650e..5e6359593 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.ts +++ b/ng6-seed/src/app/settings/users/register/register.component.ts @@ -9,16 +9,26 @@ import { FileUploader } from 'ng2-file-upload/ng2-file-upload'; import { MatOption } from '@angular/material'; import { UserService } from '../../service/user.service'; import { ifStmt } from '@angular/compiler/src/output/output_ast'; +const pdoff = "PDOFFICER"; + @Component({ selector: 'app-register', templateUrl: './register.component.html', styleUrls: ['./register.component.scss'] }) + + export class RegisterComponent implements OnInit { + roleload:boolean = false; + pdTeam: any = []; + customerSeg: any = []; + pdType: any = []; + product: any = []; img: any; roles: any; types: any = []; loader:boolean = false; + roleAccess:boolean = false; public regForm: FormGroup; // name: string; @@ -68,6 +78,11 @@ export class RegisterComponent implements OnInit { isactive: [true], pincode: [null], lenderHierarchy:[null,Validators.compose([Validators.required])], + customer:[null,Validators.compose([Validators.required])], + product:[null,Validators.compose([Validators.required])], + pdteam:[null,Validators.compose([Validators.required])], + pdtype:[null,Validators.compose([Validators.required])], + }); this.userupdate(); @@ -92,27 +107,54 @@ export class RegisterComponent implements OnInit { this.users.City().subscribe(res => { this.City = res; if (this.City.status == 200) { - this.City = this.City.records; + this.City = this.City.records.filter(City=>City.isactive ==1); } }); this.users.State().subscribe(res => { this.State = res; if (this.State.status == 200) { - this.State = this.State.records; + this.State = this.State.records.filter(state=>state.isactive ==1); } }); this.users.designation().subscribe(res => { this.designation = res; if (this.designation.status == 200) { - this.designation = this.designation.records; + this.designation = this.designation.records.filter(des=>des.isactive ==1); } }); this.users.lenderHierarchy().subscribe(res=>{ this.lenderHierarchy = res; if(this.lenderHierarchy.status ==200){ - this.lenderHierarchy = this.lenderHierarchy.records; + this.lenderHierarchy = this.lenderHierarchy.records.filter(len=>len.isactive ==1); } - }) + }); + this.users.products().subscribe(res=>{ + this.product = res; + if(this.product.status == 200){ + this.product = this.product.records.filter(product=>product.isactive ==1); + + } + }); + this.users.pdTeam().subscribe(res=>{ + + this.pdTeam = res; + if(this.pdTeam.status == 200){ + this.pdTeam = this.pdTeam.records.filter(pdt=>pdt.isactive ==1); + } + }); + this.users.pdType().subscribe(res=>{ + this.pdType = res; + if(this.pdType.status == 200){ + this.pdType = this.pdType.records.filter(pdty=>pdty.isactive ==1); + } + }); + this.users.customerSegment().subscribe(res=>{ + this.customerSeg = res; + if(this.customerSeg.status == 200){ + this.customerSeg = this.customerSeg.records.filter(cus=>cus.isactive ==1); + console.log(this.customerSeg); + } + }); //console.log(this.State+''+this.types+''+this.City+''+this.designation); } onFileChange($event) { @@ -120,13 +162,16 @@ export class RegisterComponent implements OnInit { //if($event.target.files[0] < 0 ){ this.files = $event.target.files[0]; + // console.log(this.files); + // let file = ; + console.log($event.target.result); //} //console.log(this.files); } register(userData) { // console.log(userData); let data:any; - console.log(this.usersData); + // console.log(this.files); if (this.usersData != '' && this.usersData !== undefined) { if (this.files) { @@ -175,10 +220,22 @@ this.loader = true; } toggleAllSelection(e) { - + + if(e.source.selected){ + + if(e.source.value.GroupName == pdoff){ + + this.roleAccess = true; + } + }else{ + if(e.source.value.GroupName == pdoff){ + this.roleAccess = false; + } + } if (this.usersData != '' && this.usersData !==undefined) { let users: any; + console.log(this.usersData); //for (let role of this.usersData[0]) { //this.AWS.adminremoveGroup(roles,this.usersData); @@ -254,6 +311,47 @@ this.loader = true; }) + + this.users.products().subscribe(res=>{ + this.product = res; + if(this.product.status == 200){ + this.product = this.product.records; + //console.log(this.usersData.fk_product_id); + let pro = this.product.filter(pro=>pro.product_id == this.usersData.fk_product_id)[0]; + //console.log(pro); + this.regForm.controls['product'].setValue(pro); + + } + }); + this.users.pdTeam().subscribe(res=>{ + + this.pdTeam = res; + if(this.pdTeam.status == 200){ + this.pdTeam = this.pdTeam.records; + let pdteam = this.pdTeam.filter(pd=>pd.pdteam_id == this.usersData.fk_team_id)[0]; + this.regForm.controls['pdteam'].setValue(pdteam); + } + }); + this.users.pdType().subscribe(res=>{ + this.pdType = res; + if(this.pdType.status == 200){ + this.pdType = this.pdType.records; + let pdtype = this.pdType.filter(pdt=>pdt.pd_type_id == this.usersData.fk_pd_type_id)[0]; + this.regForm.controls['pdtype'].setValue(pdtype); + } + }); + + this.users.customerSegment().subscribe(res=>{ + this.customerSeg = res; + if(this.customerSeg.status == 200){ + this.customerSeg = this.customerSeg.records; + let cust = this.customerSeg.filter(cus=>cus.customer_segment_id == this.usersData.fk_customer_segment)[0]; + this.regForm.controls['customer'].setValue(cust); + } + }); + + + //console.log(userRole); // this.regForm.controls['firstName'].setValue({'firstName':'sriram'}); @@ -280,9 +378,14 @@ this.loader = true; } checktype(e){ //console.log(e); + let userRole:any = []; if(e !== undefined){ + this.roleload = true; + //console.log(roleload); this.AWS.adminlistgroup(e.entity_type_id).subscribe(res=>{ + this.roleload = false; + //console.log(roleload); this.roles = res; if(this.usersData !==undefined){ for (let role of this.usersData[0]) { diff --git a/ng6-seed/src/app/settings/users/user-list/user-list.component.html b/ng6-seed/src/app/settings/users/user-list/user-list.component.html index c6c6e98b7..90297ec13 100644 --- a/ng6-seed/src/app/settings/users/user-list/user-list.component.html +++ b/ng6-seed/src/app/settings/users/user-list/user-list.component.html @@ -89,8 +89,8 @@ Actions edit - + delete_forever +