From 214d1f472ea3c0e9df74a2845ddf8bc9021668a8 Mon Sep 17 00:00:00 2001 From: sriram-at-840620226347 Date: Fri, 24 Jul 2020 12:49:31 +0530 Subject: [PATCH] QC completed tab hidden --- ng6-seed/src/app/AwsService/aws.service.ts | 32 ++ .../manage-pd/list-pd/list-pd.component.html | 4 +- .../src/app/settings/service/user.service.ts | 21 +- .../users/register/register.component.html | 184 ++++++ .../users/register/register.component.scss | 14 + .../users/register/register.component.spec.ts | 25 + .../users/register/register.component.ts | 540 ++++++++++++++++++ .../register.component.ts.2018-08-30 16.52.33 | 53 ++ .../register.component.ts.2018-08-30 16.57.40 | 53 ++ .../users/user-list/user-list.component.html | 99 ++++ .../users/user-list/user-list.component.scss | 91 +++ .../user-list/user-list.component.spec.ts | 25 + .../users/user-list/user-list.component.ts | 201 +++++++ .../src/app/settings/users/users.module.ts | 48 +- .../src/app/settings/users/users.routing.ts | 8 + .../menu-items/horizontal-menu-items.ts | 33 +- .../src/app/shared/menu-items/menu-items.ts | 33 +- 17 files changed, 1442 insertions(+), 22 deletions(-) create mode 100755 ng6-seed/src/app/settings/users/register/register.component.html create mode 100755 ng6-seed/src/app/settings/users/register/register.component.scss create mode 100755 ng6-seed/src/app/settings/users/register/register.component.spec.ts create mode 100755 ng6-seed/src/app/settings/users/register/register.component.ts create mode 100755 ng6-seed/src/app/settings/users/register/register.component.ts.2018-08-30 16.52.33 create mode 100755 ng6-seed/src/app/settings/users/register/register.component.ts.2018-08-30 16.57.40 create mode 100755 ng6-seed/src/app/settings/users/user-list/user-list.component.html create mode 100755 ng6-seed/src/app/settings/users/user-list/user-list.component.scss create mode 100755 ng6-seed/src/app/settings/users/user-list/user-list.component.spec.ts create mode 100755 ng6-seed/src/app/settings/users/user-list/user-list.component.ts diff --git a/ng6-seed/src/app/AwsService/aws.service.ts b/ng6-seed/src/app/AwsService/aws.service.ts index 66dba41..a152dc1 100755 --- a/ng6-seed/src/app/AwsService/aws.service.ts +++ b/ng6-seed/src/app/AwsService/aws.service.ts @@ -786,5 +786,37 @@ adminlistgroup(enitiy){ }); } +// adminSetpassword(awsuser,lenname){ +// // console.log(awsuser,lenname); +// this.getconfig(); +// if(lenname == 'SINEEDGE'){ +// var params = { +// Password: 'temp1234', /* required */ +// UserPoolId: se_poolData.UserPoolId, /* required */ +// Username: awsuser, /* required */ +// Permanent: false +// }; +// } +// else{ +// if(lenname == 'LENDER'){ +// var params = { +// Password: 'temp1234', /* required */ +// UserPoolId: lender_poolData.UserPoolId, /* required */ +// Username: awsuser, /* required */ +// Permanent: false +// }; +// } + +// } + +// return Observable.create(observe=>{ +// let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider(); +// cognitoidentityserviceprovider.adminSetUserPassword(params, function(err, data) { +// if (err) console.log(err, err.stack); // an error occurred +// else {observe.next('success'); console.log(data);} // successful response +// }); +// }); + +// } } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/list-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/list-pd.component.html index ded2f67..53389ae 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/list-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/list-pd.component.html @@ -32,12 +32,12 @@ - + diff --git a/ng6-seed/src/app/settings/service/user.service.ts b/ng6-seed/src/app/settings/service/user.service.ts index a0d20a7..eeac687 100755 --- a/ng6-seed/src/app/settings/service/user.service.ts +++ b/ng6-seed/src/app/settings/service/user.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs/internal/Observable'; import { AwsService } from '../../AwsService/aws.service'; import { environment } from 'environments/environment'; @@ -18,12 +18,13 @@ export class UserService { constructor(public http:HttpClient,public aws:AwsService) { } - getuserdata() { - - return this.http.get(apiurl + 'getListOfUsers'); - - - } + getuserdata(): Observable { + let LocalSetEntity : string = localStorage.getItem('LocalSetEntity'); + let entityID = + { params: new HttpParams().set('eid', LocalSetEntity) }; + return this.http.get(apiurl + 'getListOfUsers/',entityID); + + } /** * Admin Local Update @@ -241,5 +242,11 @@ export class UserService { return 'credit' } } + + // get lenders list + getLenderDetails(): Observable { + return this.http.get(apiurl + 'getListOfLenders'); + +} } diff --git a/ng6-seed/src/app/settings/users/register/register.component.html b/ng6-seed/src/app/settings/users/register/register.component.html new file mode 100755 index 0000000..2c6df0d --- /dev/null +++ b/ng6-seed/src/app/settings/users/register/register.component.html @@ -0,0 +1,184 @@ + +
+ +
+
+
User Registration
+
+
+ +
+
+
+
+ + Personal
+ +
+ + + + + + + + First Name Required. + Atleast 5 Characters. + Not More Than 10 Characters. + + + + Last Name Required. + + + + + + Isactive + + +
+
+
+
+
+ + Contact
+ +
+ + + Email Address Required. + Invalid Email Address. + + + + + Phone Number Required. + Invalid Phone Number. + + + + + + -- + + {{s.name}} + + + State Required. + + + + + -- + + {{c.name}} + + + city Required. + +
+ +
+
+
+
+ + + Role
+ +
+ + + -- + + {{types.name}} + + + Enitity Type Required + Enitity Type Required + + + + + -- + + {{ent.full_name}} + + + Lender Name Required. + + + + + -- + + {{ent.full_name}} + + Vendor Name Required. + + + + + + + {{role.role_name}} + + + +
+ User Role Required + User Role Required +
+ + + + {{branch.branch_name}} + + + Branch is Required + + + + + -- + + {{pd.team_name}} + + + + +
+
+
+
+
+
+
+ + + + + + + + + + + +
+
+
+ + +
\ No newline at end of file diff --git a/ng6-seed/src/app/settings/users/register/register.component.scss b/ng6-seed/src/app/settings/users/register/register.component.scss new file mode 100755 index 0000000..34effee --- /dev/null +++ b/ng6-seed/src/app/settings/users/register/register.component.scss @@ -0,0 +1,14 @@ +.hoverdp:hover img { + opacity: 0.5; +} + +.hoverdp mat-icon{ + display:none; +} +.hoverdp:hover mat-icon{ + display:block; +} +mat-form-field { + width:23%; +} + \ No newline at end of file diff --git a/ng6-seed/src/app/settings/users/register/register.component.spec.ts b/ng6-seed/src/app/settings/users/register/register.component.spec.ts new file mode 100755 index 0000000..6c19551 --- /dev/null +++ b/ng6-seed/src/app/settings/users/register/register.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RegisterComponent } from './register.component'; + +describe('RegisterComponent', () => { + let component: RegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ RegisterComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/settings/users/register/register.component.ts b/ng6-seed/src/app/settings/users/register/register.component.ts new file mode 100755 index 0000000..3b9d51a --- /dev/null +++ b/ng6-seed/src/app/settings/users/register/register.component.ts @@ -0,0 +1,540 @@ +import { Component, OnInit, ChangeDetectorRef, ViewChild, ElementRef,Pipe } from '@angular/core'; + +import { Router } from "@angular/router"; +import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; +import { CustomValidators } from 'ng2-validation'; + import { AwsService } from '../../../AwsService/aws.service'; +import { FileUploader } from 'ng2-file-upload/ng2-file-upload'; +// import { SharedService } from '../../shared.service'; +import { MatOption } from '@angular/material'; +import { UserService } from '../../service/user.service'; +import { ifStmt } from '@angular/compiler/src/output/output_ast'; + /**sweet alert */ +import Swal from 'sweetalert2'; +import { NotifierService } from 'angular-notifier'; + +const pdoff = "PD Officer"; +const pdexu = "PD Executive"; + +@Component({ + selector: 'app-register', + templateUrl: './register.component.html', + styleUrls: ['./register.component.scss'] +}) + + +export class RegisterComponent implements OnInit { + Cities: any; + role: any; + imageaccess: boolean = false; + filename:any; + 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; + // email: string; + // password: string; + // passwordConfirm: string; + entityType: any; + City: any = []; + State: any; + designation: any; + hierarchy:any=[]; + files: File = null + usersData: any; + sampledrop:any; + typeValue:any; + lenderHierarchy:any; + @ViewChild('allSelected') private allSelected: MatOption; + profileurl: any; + profileaccess: boolean; + entitiesDetails:any; + entities:any; + notifier:NotifierService; + entity_for_branch: any; + branchList: any; + enableBranch: boolean=false; + constructor( + private router: Router, public fb: FormBuilder, public AWS: AwsService, private cd: ChangeDetectorRef + ,private elementRef: ElementRef,public users:UserService,notifier:NotifierService) { + this.notifier=notifier + // console.log(this.notifier) + } + ngOnInit() { + if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined) { + + } else { + + this.regdata(); + } + + + this.regForm = this.fb.group({ + userid: [null], + firstName: [null, Validators.compose([Validators.required, Validators.minLength(2)])], + lastName: [''], + phone: [null, Validators.compose([Validators.required, Validators.minLength(10), Validators.maxLength(12)])], + email: [null, Validators.compose([Validators.required, CustomValidators.email])], + role: [null, Validators.compose([Validators.required])], + type: [null, Validators.compose([Validators.required])], + state: [null, Validators.compose([Validators.required])], + city: [null, Validators.compose([Validators.required])], + lenVenName: [null], + userpic: [null], + isactive: [true], + pdteam:[null], + pdtype:[null], + fk_lender_branch_id:[null] + + }); + this.userupdate(); + + } + + + 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',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 => { + this.Cities = res; + if (this.Cities.status == 200) { + this.Cities = this.Cities.records.filter(City=>City.isactive ==1); + } + }); + this.users.State().subscribe(res => { + this.State = res; + if (this.State.status == 200) { + this.State = this.State.records.filter(state=>state.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.entitiesDetails().subscribe(res=>{ + this.entitiesDetails = res; + if(this.entitiesDetails.dataStatus == true){ + this.entitiesDetails = this.entitiesDetails.records; + } + }) + this.users.getLenderDetails().subscribe(res=>{ + this.entity_for_branch=res + if(this.entity_for_branch.dataStatus == true){ + this.entity_for_branch = this.entity_for_branch.records; + } + }) + } + + + onFileChange($event) { + //console.log($event.target.files[0]); + this.imageaccess = true; + var reader = new FileReader(); + //if($event.target.files[0] < 0 ){ + this.files = $event.target.files[0]; + // console.log(this.files); + + reader.onload = ($event: ProgressEvent) => { + // console.log(($event.target).result); + this.filename = ($event.target).result; + } + + reader.readAsDataURL($event.target.files[0]); + //} + //console.log(this.files); + } + + + register(userData) { + if(this.regForm.invalid){ + // this.notifier.notify('success','Please Fill all the Fields') + Swal('Please Fill all the Fields'); + const invalid = []; + const controls = this.regForm.controls; + for (const name in controls) { + if (controls[name].invalid) { + invalid.push(name); + } + } + console.log(invalid); + return; + } + // console.log(userData); + let data:any; + + // console.log(this.files); + if (this.usersData != '' && this.usersData !== undefined) { + if (this.files) { + userData.userpic = this.files; + } else { + userData.userpic = this.usersData.profilepic; + } + } else { + if (this.files) { + userData.userpic = this.files; + } + } +//console.log(this.usersData); +this.loader = true; +console.log("cog",userData,this.usersData) + if (this.usersData === undefined) { + this.AWS.register(userData).subscribe(res => { + if (res.User.UserStatus != '' && res.User.UserStatus !== undefined && res.User.UserStatus != null) { + if(userData.role.role_id == 10){ + this.AWS.UserGroup(res,userData).subscribe(res=>{});} + this.users.saveRecords(res, userData).subscribe(res => { + data = res; + if (data.status == 200) { + this.AWS.adminUpdateuser(userData, data.record).subscribe(res => {}); + + this.loader =false; + // console.log(res); + Swal('User Created'); + this.router.navigate(['setting/users/userlist']); + + } + }) + //}) + } + }); + } else { + this.AWS.adminchangeData(this.usersData,userData).subscribe(res=>{ + if(userData.role.role_id == 10){ + userData.aws_name = this.usersData.aws_name; + this.AWS.UserGroup(res,userData).subscribe(res=>{ + });} + this.users.saveRecords(res,userData).subscribe(res=>{ + this.loader = false; + Swal('User Updated'); + this.router.navigate(['setting/users/userlist']); + //this.shared.redirectTo('settings/userListing'); + delete this.AWS.localUserId; + }) + }) + + } + } + + toggleAllSelection(e,enitiyid,flag?) { + console.log(enitiyid,e); + // if(e.value){ + + // if(e.value.role_name == pdoff && enitiyid.entity_type_id == 1){ + // console.log(e.value); + // this.roleAccess = true; + // }else{ + // this.roleAccess = false; + // } + // } + if (this.usersData != '' && this.usersData !==undefined || e.role_name == pdoff && enitiyid.entity_type_id == 1 || e.role_name == pdexu && enitiyid.entity_type_id == 1) { + + if(e.role_name == pdoff && enitiyid.entity_type_id == 1 ||e.role_name == pdexu && enitiyid.entity_type_id == 1 || e.role_name == pdoff && enitiyid.entity_type_id == 1 || e.role_name == pdexu && enitiyid.entity_type_id == 1){ + + this.roleAccess = true; + }else{ + this.roleAccess = false; + } + }else{ + this.roleAccess = false; + } + this.getBranch(flag); + } +getBranch(flag?){ + if(this.regForm.value.role != null && (this.regForm.value.role.role_name == "Branch Credit" || this.regForm.value.role.role_name == "Branch Sales") && this.regForm.value.lenVenName != null){ + console.log(this.regForm.value.role,this.entity_for_branch,this.regForm.value.lenVenName); + if(this.entity_for_branch.length > 0){ + this.enableBranch=true + // this.branchList=this.entity_for_branch + this.branchList=this.entity_for_branch.filter(val=>val.short_name == this.regForm.value.lenVenName.short_name).map(b=>b.branches) + console.log("dgg",this.branchList) + if(this.branchList.length > 0){ + this.branchList=this.branchList[0] + if(flag == 1){ // for edit purpose + console.log(this.usersData.fk_lender_branch_id) + this.regForm.controls['fk_lender_branch_id'].setValue(this.usersData.fk_lender_branch_id) + } + else{ + this.regForm.controls['fk_lender_branch_id'].setValue(null); + } + this.regForm.controls['fk_lender_branch_id'].setValidators(Validators.required) + } + } + } + else{ + this.regForm.controls['fk_lender_branch_id'].clearValidators() + this.enableBranch=false + this.branchList=[] + this.regForm.controls['fk_lender_branch_id'].setValue(null); + } + +} + getcity(e){ + // console.log(e); + // console.log(this.Cities); + + + this.City = this.Cities.filter(city=>city.fk_state_id == e.value.state_id); + + + } + userupdate() { + + if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined) { + 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); + 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.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.!'); + }); + } + }); + + this.users.State().subscribe(res => { + this.State = res; + if (this.State.status == 200) { + this.State = this.State.records.filter(ent=>ent.isactive ==1); + let states = this.State.filter(state => state.state_id == this.usersData.fk_state)[0]; + // console.log(states); + this.regForm.controls['state'].setValue(states); + this.users.City().subscribe(res => { + this.Cities = res; + if (this.Cities.status == 200) { + //this.City = this.Cities.records; + this.Cities = this.Cities.records.filter(ent=>ent.isactive ==1); + let City = this.Cities.filter(city=>city.fk_state_id == states.state_id && city.city_id == this.usersData.fk_city)[0]; + let value = {'value':{'state_id':states.state_id}}; + this.getcity(value); + this.regForm.controls['city'].setValue(City); + // let citys = this.Cities.filter(city => city.city_id == this.usersData.fk_city)[0]; + // this.regForm.controls['city'].setValue(citys); + // console.log(this.City); + + } + }); + } + }); + + this.users.pdTeam().subscribe(res=>{ + + this.pdTeam = res; + if(this.pdTeam.status == 200){ + this.pdTeam = this.pdTeam.records.filter(ent=>ent.isactive ==1); + 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.filter(ent=>ent.isactive ==1); + 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.getLenderDetails().subscribe(res=>{ + this.entity_for_branch=res + if(this.entity_for_branch.dataStatus == true){ + this.entity_for_branch = this.entity_for_branch.records; + // this.getBranch(1); //for edit functionality + + } + }) + + let users= { + 'userid':this.usersData.userid, + 'entityid':this.usersData.fk_entity_type_id, + 'profilepic':this.usersData.profilepic + } + this.profileaccess = false; + this.users.getprofilepic(users).subscribe(res=>{ + this.profileurl = res; + if(this.profileurl.dataStatus == true){ + this.profileaccess = true; + this.profileurl = this.profileurl.records; + } + }) + + + //console.log(userRole); + // this.regForm.controls['firstName'].setValue({'firstName':'sriram'}); + this.regForm.controls['userid'].setValue(this.usersData.userid); + this.regForm.controls['firstName'].setValue(this.usersData.user_first_name); + this.regForm.controls['lastName'].setValue(this.usersData.user_last_name); + this.regForm.controls['phone'].setValue(this.usersData.mobile_no); + + this.regForm.controls['email'].setValue(this.usersData.email); + if (this.usersData.isactive == 1) { + this.regForm.controls['isactive'].setValue(true); + } else { + this.regForm.controls['isactive'].setValue(false); + } + + // this.regForm.controls['userpic'].setValue(this.usersData.profilepic); + + this.img = this.usersData.profilepic; + } + } + + onResetForEdit(){ + this.userupdate(); + } + +/** to call role api + * params are flag are if 1 - add and 2 - edit + **/ +callrole(flag,type,usersData){ + console.log(this.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,1); + // 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){ + + this.roleAccess= false; + let userRole:any; + if(e !== undefined){ + + //console.log(roleload); + + this.roles = this.role.filter(role=>role.role_type == e.entity_type_id); + + // let role = this.roles.filter(role=>role.role_id == this.usersData.user_role_id); + // console.log(role); + // this.regForm.controls['role'].setValue(role); + } + + + + switch (e.entity_type_id) { + case "1": + this.typeValue =1; + + break; + case "2": + this.typeValue =2; + this.entities = this.entitiesDetails.filter(entity=>entity.fk_entity_type_id == e.entity_type_id); + break; + case "3": + this.typeValue =3; + this.entities = this.entitiesDetails.filter(entity=>entity.fk_entity_type_id == e.entity_type_id); + break; + default : + this.typeValue = -1; + break; + } + + + + + } + back(){ + delete this.users.localUserId; + this.router.navigate(['setting/users/userlist']); + } + /** On Key Press Event For Numbers */ + keyPress(event: any) { + const pattern = /[0-9]/; + + let inputChar = String.fromCharCode(event.charCode); + if (event.keyCode != 8 && !pattern.test(inputChar)) { + event.preventDefault(); + } + } + + + + // resetAdminPassword(){ + // // console.log(this.types); + // this.AWS.adminSetpassword(this.users.localUserId.aws_name,this.types[0].name).subscribe(res=>{ + + // if(res == 'success'){ + // // this.notifier.notify('success','Please Fill all the Fields') + // Swal('Successfully Reset'); + // } + // console.log('999',res); + + // }) + // } +} + \ No newline at end of file diff --git a/ng6-seed/src/app/settings/users/register/register.component.ts.2018-08-30 16.52.33 b/ng6-seed/src/app/settings/users/register/register.component.ts.2018-08-30 16.52.33 new file mode 100755 index 0000000..c5accf6 --- /dev/null +++ b/ng6-seed/src/app/settings/users/register/register.component.ts.2018-08-30 16.52.33 @@ -0,0 +1,53 @@ +import { Component, OnInit } from '@angular/core'; + +import {Router} from "@angular/router"; +import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; +import { CustomValidators } from 'ng2-validation'; +import { AwsService } from '../../aws.service'; +@Component({ + selector: 'app-register', + templateUrl: './register.component.html', + styleUrls: ['./register.component.scss'] +}) +export class RegisterComponent implements OnInit { +roles:any; +types:any; + public regForm :FormGroup; + + // name: string; + // email: string; + // password: string; + // passwordConfirm: string; + + constructor( + private router: Router,public fb:FormBuilder,public AWS:AwsService + ) { } + ngOnInit(){ + this.roles = [ + {name:'Admin',value:'ADMIN'}, + {name:'Audit',value:'AUDIT'} + ] + this.types = [ + {name:'Sineedge',value:'1'}, + {name:'Lender',value:'2'} + ] + this.regForm = this.fb.group({ + firstName:[null, Validators.compose([Validators.required, Validators.minLength(5), Validators.maxLength(10)])], + lastName:[null,Validators.compose([Validators.required])], + phone:[null,Validators.compose([Validators.required,Validators.minLength(10),Validators.maxLength(12)])], + email:[null,Validators.compose([Validators.required,CustomValidators.email])], + role:[null,Validators.compose([Validators.required])], + type:[null,Validators.compose([Validators.required])] + + }) + this.AWS.adminGetuser(); + } + + register(userData) { + console.log(userData); + this.AWS.register(userData); + // this.router.navigate(['/']); + } + + +} diff --git a/ng6-seed/src/app/settings/users/register/register.component.ts.2018-08-30 16.57.40 b/ng6-seed/src/app/settings/users/register/register.component.ts.2018-08-30 16.57.40 new file mode 100755 index 0000000..edfd808 --- /dev/null +++ b/ng6-seed/src/app/settings/users/register/register.component.ts.2018-08-30 16.57.40 @@ -0,0 +1,53 @@ +import { Component, OnInit } from '@angular/core'; + +import {Router} from "@angular/router"; +import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; +import { CustomValidators } from 'ng2-validation'; +import { AwsService } from '../../aws.service'; +@Component({ + selector: 'app-register', + templateUrl: './register.component.html', + styleUrls: ['./register.component.scss'] +}) +export class RegisterComponent implements OnInit { +roles:any; +types:any; + public regForm :FormGroup; + + // name: string; + // email: string; + // password: string; + // passwordConfirm: string; + + constructor( + private router: Router,public fb:FormBuilder,public AWS:AwsService + ) { } + ngOnInit(){ + this.roles = [ + {name:'Admin',value:'ADMIN'}, + {name:'Audit',value:'AUDIT'} + ]; + this.types = [ + {name:'Sineedge',value:'1'}, + {name:'Lender',value:'2'} + ]; + this.regForm = this.fb.group({ + firstName:[null, Validators.compose([Validators.required, Validators.minLength(5), Validators.maxLength(10)])], + lastName:[null,Validators.compose([Validators.required])], + phone:[null,Validators.compose([Validators.required,Validators.minLength(10),Validators.maxLength(12)])], + email:[null,Validators.compose([Validators.required,CustomValidators.email])], + role:[null,Validators.compose([Validators.required])], + type:[null,Validators.compose([Validators.required])] + + }) + this.AWS.adminGetuser(); + } + + register(userData) { + console.log(userData); + this.AWS.register(userData); + // this.router.navigate(['/']); + } + + +} 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 new file mode 100755 index 0000000..4a9ed0e --- /dev/null +++ b/ng6-seed/src/app/settings/users/user-list/user-list.component.html @@ -0,0 +1,99 @@ +
+ +
+
+ Users +
+
+ +
+
+
+ + + + +
+
+ + + + Sl + {{us.SerialNo}} + + + + Name + {{us.user_first_name}} {{us.user_last_name}} + + + + Email + {{us.email}} + + + Mobile + {{us.mobile_no}} + + + Role + {{us.role_name}} + + + Entity + {{us.entitytypename}} + + + Active + + + + + + + + + + + + + Action + + edit + + + + + + + + + + + +
+
+
+
+ \ No newline at end of file diff --git a/ng6-seed/src/app/settings/users/user-list/user-list.component.scss b/ng6-seed/src/app/settings/users/user-list/user-list.component.scss new file mode 100755 index 0000000..04873a4 --- /dev/null +++ b/ng6-seed/src/app/settings/users/user-list/user-list.component.scss @@ -0,0 +1,91 @@ +table { + width: 100%; + } + + th { + text-align: left; + } +.active{ + + color: green; + font-size: 20px; +} +.active:hover{ + color:red; + font-size:25px; +} +.deactive{ + + color: red; + font-size: 20px; +} +.deactive:hover{ + color: green; + font-size: 25px; +} + +.example-container { + display: flex; + flex-direction: column; + min-width: 300px; +} + +.example-header { + min-height: 64px; + padding: 8px 24px 0; + background: #fff; +} + +.mat-form-field { + font-size: 14px; + width: 100%; +} + +.mat-table { + overflow: auto; + max-height: 500px; +} +.mat-table { + display: table; + width: 100%; + overflow: auto; + max-height: 500px; + + > .mat-header-row, > .mat-row { + display: table-row; + padding: 0; + border: none; + + > .mat-header-cell, > .mat-cell { + display: table-cell; + height: 48px; + vertical-align: middle; + + border-bottom: 1px solid rgba(0, 0, 0, 0.12); + } + } +} + +/** Table CSS -nocontent */ +.nocontent { + color: red; + font-size: 16px; + text-align: center; +} + +/** Table CSS - Search(or)Filter Field */ +.mat-form-field { + font-size: 14px; + width: 100%; +} + +.filter-container { + display: flex; + flex-direction: column; + min-width: 300px; +} + +.filter-header { + min-height: 64px; + padding: 8px 24px 0; +} \ No newline at end of file diff --git a/ng6-seed/src/app/settings/users/user-list/user-list.component.spec.ts b/ng6-seed/src/app/settings/users/user-list/user-list.component.spec.ts new file mode 100755 index 0000000..9d52180 --- /dev/null +++ b/ng6-seed/src/app/settings/users/user-list/user-list.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UserListComponent } from './user-list.component'; + +describe('UserListComponent', () => { + let component: UserListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ UserListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(UserListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/settings/users/user-list/user-list.component.ts b/ng6-seed/src/app/settings/users/user-list/user-list.component.ts new file mode 100755 index 0000000..05f90a8 --- /dev/null +++ b/ng6-seed/src/app/settings/users/user-list/user-list.component.ts @@ -0,0 +1,201 @@ +import { Component, OnInit, ViewChild, } from '@angular/core'; +import { Router, RouterOutlet } from '@angular/router'; +import { AwsService } from '../../../AwsService/aws.service'; +import { MatPaginator, MatTableDataSource,MatSort } from '@angular/material'; +import { UserService } from '../../service/user.service'; +import { DataSource } from '@angular/cdk/table'; +import { CognitoService } from '../../../AwsService/cognito.service'; + /**sweet alert */ +import Swal from 'sweetalert2' + +@Component({ + selector: 'app-user-list', + templateUrl: './user-list.component.html', + styleUrls: ['./user-list.component.scss'] +}) +export class UserListComponent implements OnInit { + public dataLength: number; + public dataSource = new MatTableDataSource(); + displayedColumns = ['SerialNo','FullName','Email','Mobile','Roles','Entity','Actions', 'IsActive']; + + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + color="primary"; + // pagination variable details + pageSize = 10; + userdata: any = []; + loader: boolean = false; + + + + constructor(public aws: AwsService, public route: Router,public users:UserService,public shared:CognitoService) { + let session:any = this.shared.getAccessToken(); + //console.log(session.idToken.payload["cognito:groups"]); + // let userGroup = session.idToken.payload["cognito:groups"].filter( + // usergroup => usergroup == "ADMIN" + // )[0]; + + // if(userGroup == "ADMIN" ){ + + // }else{ + // alert('Admin Only Access Page'); + // this.route.navigate(['home']); + + // } + this.getusers(); + + } + + ngOnInit() { + + delete this.aws.localUserId; + } + ngAfterViewInit() { + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + + applyFilter(filterValue: string) { + filterValue = filterValue.trim(); // Remove whitespace + filterValue = filterValue.toLowerCase(); // Datasource defaults to lowercase matches + this.dataSource.filter = filterValue; + } + getusers() { + this.loader = true; + let data:any; + this.users.getuserdata().subscribe(res => { + this.loader = false; + // console.log(res); + data = res; + if (data.status == 200) { + this.userdata = data.records; + // console.log(data.records.length); + this.dataLength = data.records.length; + this.dataSource.data = this.userdata; + if(data.records.length >= 1){ + this.userdata = this.userdata.map((val, i)=>{ + val['SerialNo'] = i + 1; + return val; + }) + } + } + }) + } + isactive(id, awsname) { + let data:any; + let userstatus = this.userdata.filter((users) => users.userid == id)[0]; + if (userstatus.isactive == 1) { + Swal({ + title: 'Are you sure?', + type: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, deactivate it!' + }).then((result) => { + if (result.value) { + this.aws.admindisabelUser(userstatus, awsname).subscribe(res => { + if (res == 0) { + let users = { 'userid': userstatus.userid,'isactive': '0'} + this.users.adminupendis(users).subscribe(res => { + data = res; + if (data.status == 200) { + Swal( + 'Deactivated!', + 'success' + ) + this.getusers(); + //this.shared.redirectTo(this.route.url); + } + else{ + Swal("Sorry Try Again !"); + } + }) + } + }) + } + else{ + this.getusers(); + } + })//swal End Here + } else { + + Swal({ + title: 'Are you sure?', + type: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, activate it!' + }).then((result) => { + if (result.value) { + this.aws.adminenableUser(userstatus, awsname).subscribe(res => { + //console.log(res); + if (res == 1) { + let users = { 'userid': userstatus.userid, + 'isactive': '1'} + this.users.adminupendis(users).subscribe(res => { + data = res; + if (data.status == 200) { + Swal( + 'Activated!', + 'success' + ) + this.getusers(); + //this.shared.redirectTo(this.route.url); + } + else{ + Swal("Sorry Try Again !"); + } + }) + } + }) + } + else{ + this.getusers(); + } + })//swal End Here +} +} + editUserDetails(userId){ + + let userDetails = this.userdata.filter(users=>users.userid == userId)[0]; + this.users.adminGetUsers(userDetails).subscribe(res=>{ + + this.route.navigate(['setting/users/register']); + }); + } + add(){ + this.route.navigate(['setting/users/register']); + } + deleteuser(user){ + this.aws.admindelete(user).subscribe(res=>{ + this.getusers(); + }); + } + adminedituser(user){ + this.aws.adminresetpassword(user).subscribe(res=>{ + this.getusers(); + }) + } + //Sweetalert2 for active and deactive +deactive() +{ + Swal({ + title: 'Are you sure?', + type: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, deactivate it!' + }).then((result) => { + if (result.value) { + Swal( + 'Deactivated!', + 'success' + ) + } + }) +} + +} diff --git a/ng6-seed/src/app/settings/users/users.module.ts b/ng6-seed/src/app/settings/users/users.module.ts index 766383b..b0d84ee 100755 --- a/ng6-seed/src/app/settings/users/users.module.ts +++ b/ng6-seed/src/app/settings/users/users.module.ts @@ -22,13 +22,59 @@ import { UserRoutes} from './users.routing'; import { UserProfileComponent, ChangePasswordDialog } from './user-profile/user-profile.component'; import { UserService } from './../service/user.service'; import { NewPasswordDialog, ForgotPass } from '../../session/login/login.component'; +import { UserListComponent } from './user-list/user-list.component'; +import { RegisterComponent } from './register/register.component'; +import { NotifierModule, NotifierOptions } from 'angular-notifier'; // import { HttpClientModule } from '@angular/common/http'; + +const pdCustomNotifierOptions: NotifierOptions = { + position: { + horizontal: { + position: 'right', + distance: 12 + }, + vertical: { + position: 'top', + distance: 32, + gap: 10 + } + }, + theme: 'material', + behaviour: { + autoHide: 2000, + onClick: 'hide', + onMouseover: 'pauseAutoHide', + showDismissButton: true, + stacking: 4 + }, + animations: { + enabled: true, + show: { + preset: 'slide', + speed: 300, + easing: 'ease' + }, + hide: { + preset: 'fade', + speed: 300, + easing: 'ease', + offset: 50 + }, + shift: { + speed: 300, + easing: 'ease' + }, + overlap: 150 + } +}; + @NgModule({ imports: [ CommonModule, RouterModule.forChild(UserRoutes), MatCardModule, MatIconModule, + NotifierModule.withConfig(pdCustomNotifierOptions), MatInputModule, MatRadioModule, MatButtonModule,MatTableModule,MatPaginatorModule, @@ -38,7 +84,7 @@ import { NewPasswordDialog, ForgotPass } from '../../session/login/login.compone FormsModule, ReactiveFormsModule, // HttpClientModule, ], - declarations: [UserProfileComponent], + declarations: [UserProfileComponent,UserListComponent,RegisterComponent], providers: [ UserService ] }) diff --git a/ng6-seed/src/app/settings/users/users.routing.ts b/ng6-seed/src/app/settings/users/users.routing.ts index 0acdacd..0f2dfc4 100755 --- a/ng6-seed/src/app/settings/users/users.routing.ts +++ b/ng6-seed/src/app/settings/users/users.routing.ts @@ -1,4 +1,6 @@ import { Routes } from '@angular/router'; +import { UserListComponent } from './user-list/user-list.component'; +import { RegisterComponent } from './register/register.component'; import { UserProfileComponent } from './user-profile/user-profile.component'; export const UserRoutes: Routes = [{ path: '', @@ -7,6 +9,12 @@ export const UserRoutes: Routes = [{ },{ path: '', children: [{ + path: 'userlist', + component: UserListComponent + },{ + path: 'register', + component: RegisterComponent + },{ path:'userprofile', component:UserProfileComponent }] diff --git a/ng6-seed/src/app/shared/menu-items/horizontal-menu-items.ts b/ng6-seed/src/app/shared/menu-items/horizontal-menu-items.ts index 2b65018..828c0b6 100755 --- a/ng6-seed/src/app/shared/menu-items/horizontal-menu-items.ts +++ b/ng6-seed/src/app/shared/menu-items/horizontal-menu-items.ts @@ -38,6 +38,17 @@ const HORIZONTALMENUITEMS = [ // {state:'pdtriggerlist',name:'Pd Trigger Listing'} // ] }, + // { + // state:'setting/users', + // name:'Users', + // type:'link', + // icon:'settings', + + // // children:[ + // // {state:'pdtriggerlist',name:'Pd Trigger Listing'} + // // ] + // }, + // { // state:'quality_check_discussion', // name:'Quality Check', @@ -68,12 +79,22 @@ const salesmenu = [ // {state:'pdtriggerlist',name:'Pd Trigger Listing'} // ] }, - { - state:'sales-pd-list', - name:'Sales PD', - type:'link', - icon:'work', - }, + // { + // state:'setting/users', + // name:'Users', + // type:'link', + // icon:'settings', + + // // children:[ + // // {state:'pdtriggerlist',name:'Pd Trigger Listing'} + // // ] + // }, + // { + // state:'sales-pd-list', + // name:'Sales PD', + // type:'link', + // icon:'work', + // }, // { // state:'quality_check_discussion', // name:'Quality Check', diff --git a/ng6-seed/src/app/shared/menu-items/menu-items.ts b/ng6-seed/src/app/shared/menu-items/menu-items.ts index 8ef2a95..9004b38 100755 --- a/ng6-seed/src/app/shared/menu-items/menu-items.ts +++ b/ng6-seed/src/app/shared/menu-items/menu-items.ts @@ -80,6 +80,16 @@ const MENUITEMS : Menu[] = [ // ] }, // { + // state:'setting/users', + // name:'Users', + // type:'link', + // icon:'settings', + + // // children:[ + // // {state:'pdtriggerlist',name:'Pd Trigger Listing'} + // // ] + // }, + // { // state:'quality_check_discussion', // name:'Quality Check', // type:'link', @@ -150,12 +160,23 @@ const salesMenus: Menu[]= [ // {state:'pdtriggerlist',name:'Pd Trigger Listing'} // ] }, - { - state:'sales-pd-list', - name:'Sales PD', - type:'link', - icon:'work', - }, + // { + // state:'setting/users', + // name:'Users', + // type:'link', + // icon:'settings', + + // // children:[ + // // {state:'pdtriggerlist',name:'Pd Trigger Listing'} + // // ] + // }, + + // { + // state:'sales-pd-list', + // name:'Sales PD', + // type:'link', + // icon:'work', + // }, // { // state:'quality_check_discussion', // name:'Quality Check',