This commit is contained in:
venbatechnologies@gmail.com 2018-09-25 16:56:53 +05:30
commit 35bceabaf5
5 changed files with 238 additions and 72 deletions

View File

@ -42,7 +42,7 @@ export class TokenInterceptor implements HttpInterceptor{
return (error: any): Observable<T> => {
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']);
}

View File

@ -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('');

View File

@ -11,6 +11,8 @@
<!-- <mat-card-subtitle>Angular2 custom validation</mat-card-subtitle> -->
<form [formGroup]="regForm" (ngSubmit)="register(regForm.value)">
<mat-card-content>
<mat-card-title>Personal</mat-card-title><hr/><br/>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="First name" [formControl]="regForm.controls['firstName']">
@ -32,7 +34,7 @@
</mat-form-field>
</div>
<mat-card-title>Account Details</mat-card-title><hr/><br/>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="Email address" [formControl]="regForm.controls['email']" type="email">
@ -50,7 +52,7 @@
<mat-card-title>Contact Information</mat-card-title><hr/><br/>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="Phone number" [formControl]="regForm.controls['phone']" type="text">
@ -87,65 +89,53 @@
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;" *ngIf="usersData ===undefined">
<mat-select matInput placeholder="Select type" (selectionChange)="checktype($event.value)" [formControl]="regForm.controls['type']"
required>
<mat-option>--</mat-option>
<mat-option *ngFor="let types of types" [value]="types">
{{types.name}}
</mat-option>
</mat-select>
<mat-error *ngIf="regForm.controls['type'].hasError('required') && regForm.controls['type'].touched" class="mat-text-warn">Select User Role</mat-error>
<mat-error *ngIf="regForm.controls['type'].errors?.phone && regForm.controls['type'].touched" class="mat-text-warn">Select User Role</mat-error>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;" *ngIf="usersData !==undefined">
<mat-select matInput placeholder="Select type" (selectionChange)="checktype($event.value)" [formControl]="regForm.controls['type']"
readonly>
<mat-option>--</mat-option>
<mat-option *ngFor="let types of types" [value]="types">
{{types.name}}
</mat-option>
</mat-select>
<!-- <mat-error *ngIf="regForm.controls['type'].hasError('required') && regForm.controls['type'].touched" class="mat-text-warn">Select User Role</mat-error>
<mat-error *ngIf="regForm.controls['type'].errors?.phone && regForm.controls['type'].touched" class="mat-text-warn">Select User Role</mat-error> -->
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<mat-select matInput placeholder="Select Role" [formControl]="regForm.controls['role']" required multiple>
<!-- <mat-option #allSelected (click)="toggleAllSelection()" [value]="0">ALL</mat-option> -->
<mat-option *ngFor="let role of roles" [value]="role" (onSelectionChange)="toggleAllSelection($event)">
{{role.GroupName}}
</mat-option>
</mat-select>
<mat-error *ngIf="regForm.controls['role'].hasError('required') && regForm.controls['role'].touched" class="mat-text-warn">Select User Role</mat-error>
<mat-error *ngIf="regForm.controls['role'].errors?.phone && regForm.controls['role'].touched" class="mat-text-warn">Select User Role</mat-error>
</mat-form-field>
<!-- <pre>{{regForm.controls['role'].value | json}}</pre> -->
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<mat-select matInput placeholder="Select State" [formControl]="regForm.controls['state']" required (selectionChange)="getcity($event)">
<mat-option>--</mat-option>
<mat-option *ngFor="let s of State" [value]="s" >
{{s.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<mat-select matInput placeholder="Select City" [formControl]="regForm.controls['city']" required>
<mat-option>--</mat-option>
<mat-option *ngFor="let c of City" [value]="c">
{{c.name}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<mat-card-title>Role Information</mat-card-title><hr/><br/>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<mat-select matInput placeholder="Select State" [formControl]="regForm.controls['state']" required (selectionChange)="getcity($event)">
<mat-option>--</mat-option>
<mat-option *ngFor="let s of State" [value]="s" >
{{s.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<mat-select matInput placeholder="Select City" [formControl]="regForm.controls['city']" required>
<mat-option>--</mat-option>
<mat-option *ngFor="let c of City" [value]="c">
{{c.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<mat-select matInput placeholder="Select Enitity type" (selectionChange)="checktype($event.value)" [formControl]="regForm.controls['type']"
required>
<mat-option>--</mat-option>
<mat-option *ngFor="let types of types" [value]="types">
{{types.name}}
</mat-option>
</mat-select>
<mat-error *ngIf="regForm.controls['type'].hasError('required') && regForm.controls['type'].touched" class="mat-text-warn">Select User Role</mat-error>
<mat-error *ngIf="regForm.controls['type'].errors?.phone && regForm.controls['type'].touched" class="mat-text-warn">Select User Role</mat-error>
</mat-form-field>
<!-- <span *ngIf="roleload"> -->
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;">
<mat-select matInput placeholder="Select Role" [formControl]="regForm.controls['role']" required multiple>
<!-- <mat-option #allSelected (click)="toggleAllSelection()" [value]="0">ALL</mat-option> -->
<mat-option *ngFor="let role of roles" [value]="role" (onSelectionChange)="toggleAllSelection($event)">
{{role.GroupName}}
</mat-option>
</mat-select>
<div *ngIf="roleload"><mat-progress-bar mode="indeterminate" color="defalut"></mat-progress-bar></div>
<mat-error *ngIf="regForm.controls['role'].hasError('required') && regForm.controls['role'].touched" class="mat-text-warn">Select User Role</mat-error>
<mat-error *ngIf="regForm.controls['role'].errors?.phone && regForm.controls['role'].touched" class="mat-text-warn">Select User Role</mat-error>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;" *ngIf="typeValue == '1'">
<mat-select matInput placeholder="Select designation" [formControl]="regForm.controls['designation']" required>
@ -165,11 +155,52 @@
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2" *ngIf="roleAccess">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;" >
<mat-select matInput placeholder="Select Customer" [formControl]="regForm.controls['customer']" required (selectionChange)="getcity($event)">
<mat-option>--</mat-option>
<mat-option *ngFor="let C of customerSeg" [value]="C" >
{{C.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;" *ngIf="roleAccess">
<mat-select matInput placeholder="Select Product" [formControl]="regForm.controls['product']" required>
<mat-option>--</mat-option>
<mat-option *ngFor="let P of product" [value]="P">
{{P.name}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;" *ngIf="roleAccess">
<mat-select matInput placeholder="Select PDTEAM" [formControl]="regForm.controls['pdteam']" required (selectionChange)="getcity($event)">
<mat-option>--</mat-option>
<mat-option *ngFor="let pd of pdTeam" [value]="pd" >
{{pd.team_name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;" *ngIf="roleAccess">
<mat-select matInput placeholder="Select PDTYPE" [formControl]="regForm.controls['pdtype']" required>
<mat-option>--</mat-option>
<mat-option *ngFor="let PDT of pdType" [value]="PDT">
{{PDT.type_name}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
UserProfile
<input type="file" (change)="onFileChange($event)" [formControl]="regForm.controls['userpic']" />
<span *ngIf="usersData!=''">{{img}}</span>
<!-- <img [src]="file" style="width: 40px;height: 50px;"> -->
</div>
@ -183,7 +214,7 @@
<mat-card-actions>
<button mat-raised-button color="primary" type="submit">Submit</button>
<button mat-raised-button color="primary" type="submit">Register</button>
</mat-card-actions>
</form>
<!-- <button mat-raised-button color="primary" (click)="userupdate()" >Submit</button> -->

View File

@ -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]) {

View File

@ -89,8 +89,8 @@
<mat-header-cell *matHeaderCellDef> Actions </mat-header-cell>
<mat-cell *matCellDef="let us">
<a mat-icon-button class="hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="editUserDetails(us.userid,us.aws_name)"><mat-icon>edit</mat-icon></a>
<!-- <a mat-icon-button class="hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="deleteuser(us)"><mat-icon>delete_forever</mat-icon></a>
<a mat-icon-button class="hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="adminedituser(us)"><mat-icon>account_circle</mat-icon></a> -->
<a mat-icon-button class="hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="deleteuser(us)"><mat-icon>delete_forever</mat-icon></a>
<!-- <a mat-icon-button class="hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="adminedituser(us)"><mat-icon>account_circle</mat-icon></a> -->
</mat-cell>
</ng-container>