This commit is contained in:
venbatechnologies@gmail.com 2018-09-25 16:37:15 +05:30
commit 4caf09989b
30 changed files with 3500 additions and 2565 deletions

File diff suppressed because it is too large Load Diff

View File

@ -167,9 +167,12 @@ export class AwsService {
* Logout function
*/
logout(){
return Observable.create(observe=>{
this.shared.getCurrentUser().signOut();
observe.next();
observe.complete();
});
}
@ -393,14 +396,14 @@ export class AwsService {
if (userData.type.entity_type_id == 1) {
params = {
GroupName: role.value /* required */,
GroupName: role.GroupName /* required */,
UserPoolId: sineedgedev_poolData.UserPoolId,//"ap-south-1_y7dt3iEaX" /* required */,
Username: cognitodata.User.Username //'539bfefa-ae42-4bee-bf79-4b15d1a2af7f' /* required */
};
} else if (userData.type.entity_type_id == 2) {
params = {
GroupName: role.value /* required */,
GroupName: role.GroupName /* required */,
UserPoolId: lender_poolData.UserPoolId,//"ap-south-1_y7dt3iEaX" /* required */,
Username: cognitodata.User.Username //'539bfefa-ae42-4bee-bf79-4b15d1a2af7f' /* required */
};
@ -435,14 +438,14 @@ export class AwsService {
if (userData.fk_entity_id == 1) {
params = {
GroupName: cognitodata.value /* required */,
GroupName: cognitodata.GroupName /* required */,
UserPoolId: sineedgedev_poolData.UserPoolId,//"ap-south-1_y7dt3iEaX" /* required */,
Username: userData.aws_name //'539bfefa-ae42-4bee-bf79-4b15d1a2af7f' /* required */
};
} else if (userData.fk_entity_id == 2) {
params = {
GroupName: cognitodata.value /* required */,
GroupName: cognitodata.GroupName /* required */,
UserPoolId: lender_poolData.UserPoolId,//"ap-south-1_y7dt3iEaX" /* required */,
Username: userData.aws_name //'539bfefa-ae42-4bee-bf79-4b15d1a2af7f' /* required */
};
@ -494,7 +497,13 @@ export class AwsService {
{
Name: 'locale', /* required */
Value: cognitosdata.toString()
},
},{
Name:"email_verified",
Value:"true"
},{
Name:"phone_number_verified",
Value:"true"
}
/* more items */
],
UserPoolId: sineedgedev_poolData.UserPoolId, /* required */
@ -506,7 +515,13 @@ export class AwsService {
{
Name: 'locale', /* required */
Value: cognitosdata.toString()
},
},{
Name:"email_verified",
Value:"true"
},{
Name:"phone_number_verified",
Value:"true"
}
/* more items */
],
UserPoolId: lender_poolData.UserPoolId, /* required */
@ -598,11 +613,20 @@ adminremoveGroup(roles,users){
let session:any = this.shared.getAccessToken() ||"";
this.getconfig();
var params = {
GroupName: roles.value, /* required */
let params:any;
if(users.fk_entity_id ==1){
params = {
GroupName: roles.GroupName, /* required */
UserPoolId: sineedgedev_poolData.UserPoolId, /* required */
Username: users.aws_name//'2c64866e-e96f-453b-903f-2b6f831688af' /* required */
};
}else if(users.fk_entity_id ==2){
params = {
GroupName: roles.GroupName, /* required */
UserPoolId: lender_poolData.UserPoolId, /* required */
Username: users.aws_name//'2c64866e-e96f-453b-903f-2b6f831688af' /* required */
};
}
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
cognitoidentityserviceprovider.adminRemoveUserFromGroup(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
@ -610,4 +634,104 @@ adminremoveGroup(roles,users){
});
}
}
adminresetpassword(awsuser){
this.getconfig();
let params:any;
if(awsuser.fk_entity_id ==1){
params= {
UserPoolId: sineedgedev_poolData.UserPoolId, /* required */
Username: awsuser.email /* required */
};
}else if(awsuser.fk_entity_id ==2){
params= {
UserPoolId: lender_poolData.UserPoolId, /* required */
Username: awsuser.email /* required */
};
}
return Observable.create(observe=>{
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
cognitoidentityserviceprovider.changePassword(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else { console.log(data);
observe.next(data);
} // successful response
});
});
}
changepassword(passData) {
let session:any = this.shared.getAccessToken() || "";
console.log(session);
this.getconfig();
var params = {
AccessToken: session.accessToken.jwtToken, /* required */
PreviousPassword: passData.oldPassword, /* required */
ProposedPassword: passData.newPassword /* required */
};
return Observable.create(observe => {
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
cognitoidentityserviceprovider.changePassword(params, function (err, data) {
if (err) console.log(err, err.stack); // an error occurred
console.log(data);
observe.next(data);
// successful response
});
})
}
admindelete(aws){
this.getconfig();
let params:any;
if(aws.fk_entity_id ==1){
params= {
UserPoolId: sineedgedev_poolData.UserPoolId, /* required */
Username: aws.email /* required */
};
}else if(aws.fk_entity_id ==2){
params= {
UserPoolId: lender_poolData.UserPoolId, /* required */
Username: aws.email /* required */
};
}
return Observable.create(observe=>{
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
cognitoidentityserviceprovider.adminDeleteUser(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else { console.log(data);
observe.next(data);
} // successful response
});
});
}
adminlistgroup(enitiy){
// console.log(enitiy);
this.getconfig();
let params:any;
if(enitiy ==1){
params = {
UserPoolId:sineedgedev_poolData.UserPoolId,
}
}else if(enitiy ==2){
params = {
UserPoolId:lender_poolData.UserPoolId
}
}
//console.log(enitiy);
return Observable.create(observe=>{
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
cognitoidentityserviceprovider.listGroups(params,function(err,data){
if(err) alert(err.stack);
else {console.log(data);observe.next(data.Groups);}
})
});
}
// waiting for image api
getpicurl(userid){
let users = {'userid':userid}
return this.http.post(apiurl+'getSingedProfilePicURL',users);
}
}

View File

@ -11,6 +11,7 @@ import {
CognitoUserSession
} from "amazon-cognito-identity-js";
import { environment } from '../../environments/environment';
import { BehaviorSubject } from 'rxjs';
const sineedge_poolData = {
UserPoolId: "ap-south-1_y7dt3iEaX", //ap-south-1_qQ85yQZJO UserName :SPARQ_SINEEDGE_DEV
ClientId: "291qt4smn5pql6o8cc2hi201lj" // ClientName: SINEEDGE_DEV_WEB
@ -49,6 +50,7 @@ export interface Callback {
providedIn: 'root'
})
export class CognitoService implements CanActivateChild {
public loggedIn :boolean = false;
// public static _REGION = environment.region;
// public static _IDENTITY_POOL_ID = environment.identityPoolId;
@ -59,6 +61,14 @@ export class CognitoService implements CanActivateChild {
// UserPoolId: CognitoService._USER_POOL_ID,
// ClientId: CognitoService._CLIENT_ID
// };
get isLoggedIn() {
if(sineedgedevUserpool.getCurrentUser() !=null){
this.loggedIn = true;
}else{
this.loggedIn = false;
}
return this.loggedIn; // {2}
}
canActivateChild(){
if(this.getToken()){
//alert('session valid')
@ -82,6 +92,7 @@ isloggin:boolean = false;
// }
getCurrentUser() {
return sineedgedevUserpool.getCurrentUser();
}
constructor(public route:Router) { }

View File

@ -1,54 +1,46 @@
// import { Injectable } from '@angular/core';
// import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanActivateChild } from '@angular/router';
// import { Observable , of } from 'rxjs';
import { Injectable } from '@angular/core';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanActivateChild } from '@angular/router';
import { Observable , of } from 'rxjs';
import { CognitoService } from '../AwsService/cognito.service';
@Injectable()
export class AuthGuard implements CanActivate, CanActivateChild {
// @Injectable()
// export class AuthGuard implements CanActivate, CanActivateChild {
constructor(private router: Router,public shared:CognitoService) { }
// constructor(private router: Router) { }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
if (this.shared.getToken()) {
alert("if");
// this.router.navigate(['']);
return true
} else {
alert("else");
this.router.navigate(['/login']);
return false;
}
}
// canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
// if (localStorage.getItem('token') != null) {
// // this.router.navigate(['']);
// return true
// } else {
// this.router.navigate(['/login']);
// return false;
// }
// }
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
if (this.shared.getToken()) {
// alert("if");
return true;
} else {
// alert("else");
this.router.navigate(['/login']);
return false;
}
}
// canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
// if (this.loginService.loggedIn()) {
// let roles = route.data["role"] as Array<string>;
// console.log("dataRole: " +roles);
// if(roles.length > -1){
// var match = this.loginService.roleMatch(roles);
// if(match){
// // this.router.navigate(['./dashboard']);
// return this.loginService.loggedIn()
// }
// else {
// this.router.navigate(['./404']);
// return this.loginService.loggedIn();
// }
// } else {
// this.router.navigate(['/login']);
// return this.loginService.loggedIn();
// }
// } else {
// this.router.navigate(['/login']);
// return this.loginService.loggedIn();
// }
// }
// public getToken(): string {
// return localStorage.getItem('token');
// }
// public getToken(): string {
// return localStorage.getItem('token');
// }
// public logOut() {
// localStorage.clear();
// if(localStorage.getItem('token') === null){
// this.router.navigate(['/login']);
// }
// }
// }
// public logOut() {
// localStorage.clear();
// if(localStorage.getItem('token') === null){
// this.router.navigate(['/login']);
// }
// }
}

View File

@ -30,6 +30,7 @@ import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatProgressBarModule} from '@angular/material/progress-bar';
import {MatSelectModule} from '@angular/material/select';
import {MatCardModule} from '@angular/material/card';
import {ChangePasswordDialog} from './settings/users/user-profile/user-profile.component';
import { AppRoutes } from './app.routing';
import { AppComponent } from './app.component';
@ -39,6 +40,7 @@ import { SharedModule } from './shared/shared.module';
import { AwsService } from './AwsService/aws.service';
import { TokenInterceptor } from './_guard/token.interceptor';
import { NewPasswordDialog, ForgotPass } from './session/login/login.component';
import { AuthGuard } from './_guard/auth.guard';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
@ -56,7 +58,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
AppComponent,
AdminLayoutComponent,
AuthLayoutComponent,
NewPasswordDialog,ForgotPass
NewPasswordDialog,ForgotPass,ChangePasswordDialog,
],
imports: [
BrowserModule,
@ -92,7 +94,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
provide: LocationStrategy,
useClass: HashLocationStrategy,
},
AwsService,
AwsService,AuthGuard,
TranslateService,
// {
// provide: PERFECT_SCROLLBAR_CONFIG,
@ -104,7 +106,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
multi: true
}
],
entryComponents: [NewPasswordDialog,ForgotPass],
entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog],
bootstrap: [AppComponent]
})
export class AppModule { }

View File

@ -3,6 +3,7 @@ import { Routes } from '@angular/router';
import { AdminLayoutComponent } from './layouts/admin/admin-layout.component';
import { AuthLayoutComponent } from './layouts/auth/auth-layout.component';
import { CognitoService} from './AwsService/cognito.service';
import { AuthGuard } from './_guard/auth.guard';
export const AppRoutes: Routes = [{
path: '',
redirectTo: 'home',
@ -10,7 +11,7 @@ export const AppRoutes: Routes = [{
}, {
path: '',
component: AdminLayoutComponent,
canActivateChild:[CognitoService],
canActivateChild:[AuthGuard],
children: [{
path: 'home',
loadChildren: './dashboard/dashboard.module#DashboardModule'
@ -18,10 +19,10 @@ export const AppRoutes: Routes = [{
path:'setting',
loadChildren:'./settings/settings.module#SettingsModule'
}
// ,{
// path:'pdtrigger',
// loadChildren:'./pd-trigger/pd-trigger.module#PdTriggerModule'
// }
,{
path:'pdtrigger',
loadChildren:'./pd-triger/pd-triger.module#PdTrigerModule'
}
]
}, {
path: '',

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@ import {TranslateService} from '@ngx-translate/core';
import PerfectScrollbar from 'perfect-scrollbar';
import { PerfectScrollbarConfigInterface,
PerfectScrollbarComponent, PerfectScrollbarDirective } from 'ngx-perfect-scrollbar';
import { UserService } from '../../settings/service/user.service';
import { AwsService } from '../../AwsService/aws.service';
@ -18,6 +19,9 @@ import { AwsService } from '../../AwsService/aws.service';
})
export class AdminLayoutComponent implements OnInit, OnDestroy {
userDep: string;
fullName: any;
currentUser: any;
private _router: Subscription;
today: number = Date.now();
@ -39,9 +43,26 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
@ViewChild('sidemenu') sidemenu;
public config: PerfectScrollbarConfigInterface = {};
constructor(private router: Router, public menuItems: MenuItems, public horizontalMenuItems : HorizontalMenuItems, public translate: TranslateService,public aws:AwsService ) {
constructor(private router: Router, public menuItems: MenuItems, public horizontalMenuItems : HorizontalMenuItems, public translate: TranslateService,public aws:AwsService,public users:UserService ) {
const browserLang: string = translate.getBrowserLang();
translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
this.users.getroles().subscribe(res=>{
this.currentUser = res;
if(this.currentUser.dataStatus == true){
this.currentUser = this.currentUser.records[0];
this.fullName = this.currentUser.user_full_name;
console.log(this.currentUser);
if(this.currentUser.fk_entity_id == 1 ){
this.userDep = "SINEEGDE";
}else if(this.currentUser.fk_entity_id ==2){
this.userDep = "LENDOR";
}else{
this.userDep = "VENDOR";
}
}
});
}
ngOnInit(): void {
@ -201,6 +222,9 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
]
});
}
userprofile(){
this.router.navigate(['setting/users/userprofile']);
}
logout(){
//alert();
this.aws.logout().subscribe(res=>{

View File

@ -0,0 +1,164 @@
<mat-card class="p-1">
<form [formGroup]="PDtriggerForm" (submit)="submitPdDetails()">
<mat-card-content>
<div class="mb-2"></div>
<div fxLayout="row" fxLayoutWrap="wrap">
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<mat-card class="p-2">
<h5>PD Details</h5>
<div fxLayout="column" fxLayoutAlign="start stretch">
<!-- <mat-form-field style="width: 100%">
<input matInput placeholder="First Name" type="text" name="name" required>
</mat-form-field> -->
<mat-form-field style="width: 100%">
<mat-select placeholder="Lender Name" [formControl]="PDtriggerForm.controls['fk_lender_id']" required>
<mat-option *ngFor="let LL of LenderList" [value]="LL.lender_hierarchy_id" >
{{LL.lender_hierarchy}}
</mat-option>
<mat-error *ngIf="!PDtriggerForm.controls['fk_lender_id'].valid && PDtriggerForm.controls['fk_lender_id'].touched" class="mat-text-warn">You must include a Pick up Lender Name.</mat-error>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Lender Applicant ID" required [formControl]="PDtriggerForm.controls['lender_applicant_id']" type="text">
<mat-error *ngIf="!PDtriggerForm.controls['lender_applicant_id'].valid && PDtriggerForm.controls['lender_applicant_id'].touched" class="mat-text-warn">You must include Lender Applicant Id.</mat-error>
</mat-form-field>
<!-- <mat-form-field style="width: 100%">
<input matInput placeholder="PD Date of Initiation" [formControl]="PDtriggerForm.controls['pd_date_of_initiation']" type="date">
</mat-form-field>-->
<mat-form-field style="width: 100%">
<mat-select placeholder="Product Name" [formControl]="PDtriggerForm.controls['fk_product_id']">
<mat-option *ngFor="let PL of ProductList" [value]="PL" >
{{PL.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 100%">
<mat-select placeholder="Sub product Name" [formControl]="PDtriggerForm.controls['fk_subproduct_id']">
<mat-option *ngFor="let SPL of SubProductList" [value]="SPL" >
{{SPL.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 100%">
<mat-select placeholder="Customer Segment" [formControl]="PDtriggerForm.controls['fk_customer_segment']">
<mat-option *ngFor="let CSL of CustomerSegmentList" [value]="CSL.customer_segment_id" >
{{CSL.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 100%">
<mat-select placeholder="PD Type" [formControl]="PDtriggerForm.controls['fk_pd_type']">
<mat-option *ngFor="let PDL of PDTypeList" [value]="PDL.pd_type_id" >
{{PDL.type_name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Loan Amount" [formControl]="PDtriggerForm.controls['loan_amount']">
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Address 1" [formControl]="PDtriggerForm.controls['addressline1']">
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Address 2" [formControl]="PDtriggerForm.controls['addressline2']">
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Address 3" [formControl]="PDtriggerForm.controls['addressline3']">
</mat-form-field>
<mat-form-field style="width: 100%;">
<mat-select placeholder="Select City" [formControl]="PDtriggerForm.controls['fk_city']" >
` <mat-option *ngFor="let CL of CityList" [value]="CL">
{{CL.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 100%;">
<mat-select placeholder="Pickup the State" [formControl]="PDtriggerForm.controls['fk_state']" >
<mat-option *ngFor="let SL of StateList" [value]="SL">
{{SL.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 100%;">
<input matInput placeholder="Pincode" [formControl]="PDtriggerForm.controls['pincode']">
</mat-form-field>
</div>
</mat-card>
</div>
</div>
<div fxLayout="row" fxLayoutWrap="wrap">
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<mat-card class="p-2">
<h5>Main Applicant Details</h5>
<mat-form-field style="width: 100%">
<input matInput placeholder="Name" [formControl]="PDtriggerForm.controls['applicant_name']">
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Email" [formControl]="PDtriggerForm.controls['email']" type="email">
<!-- <small *ngIf="PDtriggerForm.controls['email'].hasError('required') && PDtriggerForm.controls['email'].touched" class="mat-text-warn">You must include an email address.</small>
<small *ngIf="PDtriggerForm.controls['email'].errors?.email && PDtriggerForm.controls['email'].touched" class="mat-text-warn">You must include a valid email address.</small> -->
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Phone" [formControl]="PDtriggerForm.controls['mobile_no']" type="text">
<!-- <small *ngIf="PDtriggerForm.controls['mobile_no'].hasError('required') && PDtriggerForm.controls['mobile_no'].touched" class="mat-text-warn">You must include phone number.</small>
<small *ngIf="PDtriggerForm.controls['mobile_no'].errors?.phone && PDtriggerForm.controls['mobile_no'].touched" class="mat-text-warn">You must include a valid phone number.</small> -->
</mat-form-field>
</mat-card>
</div>
</div>
<div fxLayout="row" fxLayoutWrap="wrap" formArrayName="items" *ngFor="let coDetails of PDtriggerForm.get('items')['controls']; let i = index;">
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100">
<mat-card class="p-2">
<h5>{{PDtriggerForm.controls.items.controls[i].controls.label.value}} {{i+1}}</h5>
<div [formGroupName]="i">
<mat-form-field style="width: 100%">
<input matInput placeholder="Name" formControlName="coapplicantName" type="text">
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Relation" formControlName="relationship" type="text">
</mat-form-field>
</div>
</mat-card>
</div>
</div>
<div fxLayout="row" fxLayoutWrap="wrap">
<div class="column" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="30" fxFlex.lg="50" fxFlex.xl="30">
<mat-card class="p-2" style="opacity: 0.5;">
<!-- <button _ngcontent-c29="" class="mr-1 mb-2 mat-fab1 mat-accent" mat-fab="" (click)="addCoApplicant(createWithLongContent)"><span class="mat-button-wrapper"><mat-icon _ngcontent-c29="" class="mat-icon material-icons" role="img" aria-hidden="true">add</mat-icon></span><div class="mat-button-ripple mat-ripple mat-button-ripple-round" matripple=""></div><div class="mat-button-focus-overlay"></div></button> -->
<button _ngcontent-c39="" class="mr-1 mb-1 mat-button" mat-button=""><span style="opacity: 0.5;" (click)="addCoApplicant()" class="mat-button-wrapper">Add More Co-Applicant</span><div class="mat-button-ripple mat-ripple" matripple=""></div><div class="mat-button-focus-overlay"></div></button>
</mat-card>
</div>
</div>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button color="primary" type="submit" [disabled]="!PDtriggerForm.valid">Submit</button>
</mat-card-actions>
</form>
</mat-card>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AddPdComponent } from './add-pd.component';
describe('AddPdComponent', () => {
let component: AddPdComponent;
let fixture: ComponentFixture<AddPdComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddPdComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddPdComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,152 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms';
import { CustomValidators } from 'ng2-validation';
import { PdTrigerService } from '../pd-service/pd-triger.service';
@Component({
selector: 'app-add-pd',
templateUrl: './add-pd.component.html',
styleUrls: ['./add-pd.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class AddPdComponent implements OnInit {
public PDtriggerForm: FormGroup;
items: FormArray;
CityList: any;
StateList: any;
LenderList: any;
ProductList: any;
SubProductList: any;
CustomerSegmentList: any;
PDTypeList: any;
ApplicantTypeList: any;
errorMessage: any;
// Dynamic co applicant
createWithLongContent = false;
dynamicCoApplicant = [];
constructor(private _fb: FormBuilder,
private _pd: PdTrigerService) { }
ngOnInit() {
this.PDtriggerForm = this._fb.group({
fk_lender_id: [null, Validators.compose([Validators.required])],
lender_applicant_id: [null, Validators.compose([Validators.required])],
fk_product_id: [null, Validators.compose([Validators.required])],
fk_subproduct_id: [null, Validators.compose([Validators.required])],
fk_pd_type: [null, Validators.compose([Validators.required])],
fk_customer_segment: [null, Validators.compose([Validators.required])],
loan_amount: [null],
applicant_name: [null, Validators.compose([Validators.required])],
mobile_no: [null, Validators.compose([Validators.required])],
email: [null, Validators.compose([Validators.required, CustomValidators.email])],
  addressline1: [null, Validators.compose([Validators.required])],
addressline2: [null],
addressline3: [null],
fk_city: [null, Validators.compose([Validators.required])],
fk_state: [null, Validators.compose([Validators.required])],
  pincode : [null],
items: this._fb.array([])
});
this._pd.getAllMasterDatas('CITY')
.subscribe(
data => {
if (data.status == 200) {
this.CityList = data.records;
this.CityList = this.CityList.filter(city=>city.isactive == 1 );
}
}, error => this.errorMessage = <any> error);
this._pd.getAllMasterDatas('STATE')
.subscribe(
data => {
if (data.status == 200) {
this.StateList = data.records;
this.StateList = this.StateList.filter(city=>city.isactive == 1 );
}
}, error => this.errorMessage = <any> error);
this._pd.getAllMasterDatas('LENDERHIERARCHY')
.subscribe(
data => {
if (data.status == 200) {
this.LenderList = data.records;
this.LenderList = this.LenderList.filter(city=>city.isactive == 1 );
}
}, error => this.errorMessage = <any> error);
this._pd.getAllMasterDatas('PRODUCTS')
.subscribe(
data => {
if (data.status == 200) {
this.ProductList = data.records;
this.ProductList = this.ProductList.filter(city=>city.isactive == 1 );
}
}, error => this.errorMessage = <any> error);
this._pd.getAllMasterDatas('SUBPRODUCTS')
.subscribe(
data => {
if (data.status == 200) {
this.SubProductList = data.records;
this.SubProductList = this.SubProductList.filter(city=>city.isactive == 1 );
}
}, error => this.errorMessage = <any> error);
this._pd.getAllMasterDatas('CUSTOMERSEGMENT')
.subscribe(
data => {
if (data.status == 200) {
this.CustomerSegmentList = data.records;
this.CustomerSegmentList = this.CustomerSegmentList.filter(city=>city.isactive == 1 );
}
}, error => this.errorMessage = <any> error);
this._pd.getAllMasterDatas('PDTYPE')
.subscribe(
data => {
if (data.status == 200) {
this.PDTypeList = data.records;
this.PDTypeList = this.PDTypeList.filter(city=>city.isactive == 1 );
}
}, error => this.errorMessage = <any> error);
}
createItem(): FormGroup {
return this._fb.group({
label: ['Co Applicant Details'],
coapplicantName: [null, Validators.compose([Validators.required])],
relationship: [null],
});
};
addCoApplicant() {
if(this.PDtriggerForm.valid){
this.items = this.PDtriggerForm.get('items') as FormArray;
this.items.push(this.createItem());
}
}
submitPdDetails() {
if(this.PDtriggerForm.valid){
var my_array = this.PDtriggerForm.value;
Object.keys(my_array).forEach((key) => ( my_array[key] == null) && delete my_array[key]);
}
}
}

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { PdTrigerService } from './pd-triger.service';
describe('PdTrigerService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: PdTrigerService = TestBed.get(PdTrigerService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,41 @@
/** Common Import Section */
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';//for Datatables
import { HttpClient } from '@angular/common/http';
import { catchError } from 'rxjs/operators';
import { of } from 'rxjs';
/** Imported Service Files Are., */
import { AwsService } from '../../AwsService/aws.service';
const currentdate = new Date().toJSON().slice(0,19).replace('T',' ');
/** Master Interface */
export interface Master {
master_id:number;
master_name:string;
constant_name:string;
}
@Injectable()
export class PdTrigerService {
private apiUrl = "http://ssa.sineedge.com/sparqapi/api/";
constructor(private _http: HttpClient,
private _aws:AwsService) { }
// get add pd master details
getAllMasterDatas(TableName:string): Observable<any> {
return this._http.post<any>(this.apiUrl+'getListOfMaster', { "master_name":TableName })
.pipe(
catchError(this.handleError('role', []))
)
}
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return of(result as T);
};
}
}

View File

@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AddPdComponent } from './add-pd/add-pd.component';
export const PdTrigerRoutes: Routes = [
{
path: '',
component: AddPdComponent
// children:
// [{
// path: 'pdtriggerlist',
// component: AddPdComponent
// }]
}
];

View File

@ -0,0 +1,13 @@
import { PdTrigerModule } from './pd-triger.module';
describe('PdTrigerModule', () => {
let pdTrigerModule: PdTrigerModule;
beforeEach(() => {
pdTrigerModule = new PdTrigerModule();
});
it('should create an instance', () => {
expect(pdTrigerModule).toBeTruthy();
});
});

View File

@ -0,0 +1,52 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import {
MatCardModule,
MatIconModule,
MatInputModule,
MatRadioModule,
MatButtonModule,MatTableModule,MatPaginatorModule,
MatProgressBarModule,MatDialogModule, MatSortModule,
MatToolbarModule,MatSelectModule } from '@angular/material';
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
import { TreeModule } from 'angular-tree-component';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
import { FlexLayoutModule } from '@angular/flex-layout';
import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
import 'hammerjs';
import { PdTrigerRoutes } from './pd-triger-routing.module';
import { AddPdComponent } from './add-pd/add-pd.component';
import { PdTrigerService } from './pd-service/pd-triger.service';
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(PdTrigerRoutes),
MatCardModule,
MatIconModule,
MatInputModule,
MatRadioModule,
MatTableModule,
MatPaginatorModule,
MatButtonModule,
MatProgressBarModule,
MatToolbarModule,
FlexLayoutModule,
NgxDatatableModule,
FormsModule,MatSlideToggleModule,
MatSelectModule,
ReactiveFormsModule,
FileUploadModule,
TreeModule,
MatDialogModule,
NgxMatSelectSearchModule
],
declarations: [AddPdComponent],
providers: [PdTrigerService]
})
export class PdTrigerModule { }

View File

@ -20,7 +20,7 @@ import { CognitoService } from '../../AwsService/cognito.service';
styleUrls: ['./login-component.scss'],
encapsulation: ViewEncapsulation.None,
})
export class LoginComponent {
export class LoginComponent implements OnInit{
changepass: FormGroup;
email: string;
password: string;
@ -43,6 +43,10 @@ export class LoginComponent {
private router: Router, public aws: AwsService, public dialog: MatDialog,
public shared:CognitoService,) {
}
ngOnInit(){
this.loggedInCheck();
}
/**
* @param email
@ -103,9 +107,17 @@ export class LoginComponent {
console.log(res);
})
}
loggedInCheck(){
//alert(this.shared.isLoggedIn);
if(this.shared.isLoggedIn){
// alert("if");
this.router.navigate(['/home']);
return false;
}else{
//alert("else");
return true;
}
}
}

View File

@ -107,7 +107,7 @@ export class UserService {
let roles:any=[];
for(var role of users.role){
roles.push({ "user_role": role.value });
roles.push({ "user_role": role.GroupName });
}
let designation:any;
if(users.type.entity_type_id ==2){
@ -125,8 +125,8 @@ export class UserService {
"last_name": users.lastName,
"mobile_no": users.phone,
"email": users.email,
"alt_email":users.alt_email,
"alt_mobile_no":users.alt_mobile_no,
"alt_email":users.altemail,
"alt_mobile_no":users.altphone,
"addressline1":users.address1,
"addressline2":users.address2,
"addressline3":users.address3,
@ -146,7 +146,7 @@ export class UserService {
formData.append('records',JSON.stringify(records));
formData.append('roles',JSON.stringify(roles));
formData.append('profilepic',users.userpic);
console.log(records);
//new Response(formData).text().then(console.log);
//let headers = this.shared.headercofig('');
@ -173,6 +173,13 @@ export class UserService {
observe.next(this.localUserId);
})
}
getroles(){
// alert();
let cogusers:any = this.aws.getlocale();
//console.log(cogusers.idToken.payload.locale);
let roles = {'userid':cogusers};
return this.http.post(apiurl+'getUsersDetails',roles);
}
}

View File

@ -1,30 +1,35 @@
<mat-card>
<mat-card-title> <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon button" (click)="back()"><mat-icon>chevron_left</mat-icon></button> User Registration</mat-card-title>
<mat-card-title>
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon button" (click)="back()">
<mat-icon>chevron_left</mat-icon>
</button> User Registrations</mat-card-title>
<!-- <div class="profile-avatar">
<img fxFlexOffset="50px" [src]="'https://www.google.co.in/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=2ahUKEwi8qsnv7NPdAhWFWysKHZIZBDcQjRx6BAgBEAU&url=https%3A%2F%2Fwww.facebook.com%2FProfilePictures%2F&psig=AOvVaw12u0YbndUEVORSODg1OWeg&ust=1537885714967641'" style="width: 70px;height: 100px;border-radius: 50%;">
</div> -->
<!-- <mat-card-subtitle>Angular2 custom validation</mat-card-subtitle> -->
<form [formGroup]="regForm" (ngSubmit)="register(regForm.value)">
<mat-card-content>
<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']">
<mat-error *ngIf="regForm.controls['firstName'].hasError('required') && regForm.controls['firstName'].touched" class="mat-text-warn">You must include a first name.</mat-error>
<mat-error *ngIf="regForm.controls['firstName'].hasError('minlength') && regForm.controls['firstName'].touched" class="mat-text-warn">Your first name must be at least 5 characters long.</mat-error>
<mat-error *ngIf="regForm.controls['firstName'].hasError('maxlength') && regForm.controls['firstName'].touched" class="mat-text-warn">Your first name cannot exceed 10 characters.</mat-error>
</mat-form-field>
<input matInput placeholder="First name" [formControl]="regForm.controls['firstName']">
<mat-error *ngIf="regForm.controls['firstName'].hasError('required') && regForm.controls['firstName'].touched" class="mat-text-warn">You must include a first name.</mat-error>
<mat-error *ngIf="regForm.controls['firstName'].hasError('minlength') && regForm.controls['firstName'].touched" class="mat-text-warn">Your first name must be at least 5 characters long.</mat-error>
<mat-error *ngIf="regForm.controls['firstName'].hasError('maxlength') && regForm.controls['firstName'].touched" class="mat-text-warn">Your first name cannot exceed 10 characters.</mat-error>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="Last name" [formControl]="regForm.controls['lastName']">
<mat-error *ngIf="regForm.controls['lastName'].hasError('required') && regForm.controls['lastName'].touched" class="mat-text-warn">You must include a last name.</mat-error>
</mat-form-field>
<!-- <mat-error *ngIf="regForm.controls['lastName'].hasError('minlength') && regForm.controls['lastName'].touched" class="mat-text-warn">Your first name must be at least 5 characters long.</mat-error>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="Last name" [formControl]="regForm.controls['lastName']">
<mat-error *ngIf="regForm.controls['lastName'].hasError('required') && regForm.controls['lastName'].touched" class="mat-text-warn">You must include a last name.</mat-error>
</mat-form-field>
<!-- <mat-error *ngIf="regForm.controls['lastName'].hasError('minlength') && regForm.controls['lastName'].touched" class="mat-text-warn">Your first name must be at least 5 characters long.</mat-error>
<mat-error *ngIf="regForm.controls['lastName'].hasError('maxlength') && regForm.controls['lastName'].touched" class="mat-text-warn">Your first name cannot exceed 10 characters.</mat-error> -->
<mat-form-field style="display: none;">
<input matInput placeholder="User Id" [formControl]="regForm.controls['userid']">
</mat-form-field>
<mat-form-field style="display: none;">
<input matInput placeholder="User Id" [formControl]="regForm.controls['userid']">
</mat-form-field>
</div>
@ -32,14 +37,14 @@
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="Email address" [formControl]="regForm.controls['email']" type="email">
<mat-error *ngIf="regForm.controls['email'].hasError('required') && regForm.controls['email'].touched" class="mat-text-warn">You must include an email address.</mat-error>
<mat-error *ngIf="regForm.controls['email'].errors?.email && regForm.controls['email'].touched" class="mat-text-warn">You must include a valid email address.</mat-error>
<mat-error *ngIf="regForm.controls['email'].errors?.email && regForm.controls['email'].touched" class="mat-text-warn">You must include a valid email address.</mat-error>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="Alt Email address" [formControl]="regForm.controls['altemail']" type="email">
</mat-form-field>
<mat-error *ngIf="regForm.controls['email'].errors?.email && regForm.controls['altemail'].touched" class="mat-text-warn">You must include a valid email address.</mat-error>
</div>
@ -51,19 +56,19 @@
<input matInput placeholder="Phone number" [formControl]="regForm.controls['phone']" type="text">
<mat-error *ngIf="regForm.controls['phone'].hasError('required') && regForm.controls['phone'].touched" class="mat-text-warn">You must include phone number.</mat-error>
<mat-error *ngIf="regForm.controls['phone'].errors?.phone && regForm.controls['phone'].touched" class="mat-text-warn">You must include a valid phone number.</mat-error>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="Alt Phone number" [formControl]="regForm.controls['altphone']" type="text">
<mat-error *ngIf="regForm.controls['altphone'].errors?.phone && regForm.controls['phone'].touched" class="mat-text-warn">You must include a valid phone number.</mat-error>
</mat-form-field>
<!-- <mat-error *ngIf="regForm.controls['phone'].hasError('required') && regForm.controls['phone'].touched" class="mat-text-warn">You must include phone number.</mat-error> -->
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
<input matInput placeholder="Address 1" [formControl]="regForm.controls['address1']">
</mat-form-field>
<input matInput placeholder="Address 1" [formControl]="regForm.controls['address1']">
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
@ -82,36 +87,51 @@
</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%;">
<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.name}}
</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 type" (selectionChange)="checktype($event.value)"[formControl]="regForm.controls['type']" required>
<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 *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> -->
</div>
<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>
<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">
<mat-option *ngFor="let s of State" [value]="s" >
{{s.name}}
</mat-option>
</mat-select>
@ -124,7 +144,7 @@
{{c.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 30%;" *ngIf="typeValue == '1'">
@ -143,32 +163,32 @@
</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>
</div>
UserProfile
<input type="file" (change)="onFileChange($event)" [formControl]="regForm.controls['userpic']" />
<mat-slide-toggle color="primary" [formControl]="regForm.controls['isactive']">
Isactive
</mat-slide-toggle>
<span *ngIf="usersData!=''">{{img}}</span>
</div>
<mat-slide-toggle color="primary" [formControl]="regForm.controls['isactive']">
Isactive
</mat-slide-toggle>
</mat-card-content>
<hr>
<!-- <pre>{{regForm.controls['userid'].value | json}}</pre> -->
<mat-card-actions >
<button mat-raised-button color="primary" type="submit">Submit</button>
<mat-card-actions>
<button mat-raised-button color="primary" type="submit">Submit</button>
</mat-card-actions>
</form>
<!-- <button mat-raised-button color="primary" (click)="userupdate()" >Submit</button> -->
</mat-card>
<div *ngIf="loader">
<mat-progress-bar mode="indeterminate" color="accent" class="mb-1"></mat-progress-bar>
<mat-progress-bar mode="indeterminate" color="accent" class="mb-1"></mat-progress-bar>
</div>

View File

@ -17,7 +17,7 @@ import { ifStmt } from '@angular/compiler/src/output/output_ast';
export class RegisterComponent implements OnInit {
img: any;
roles: any;
types: any;
types: any = [];
loader:boolean = false;
public regForm: FormGroup;
@ -26,7 +26,7 @@ export class RegisterComponent implements OnInit {
// password: string;
// passwordConfirm: string;
entityType: any;
City: any;
City: any = [];
State: any;
designation: any;
hierarchy:any=[];
@ -46,14 +46,11 @@ export class RegisterComponent implements OnInit {
} else {
this.regdata();
}
this.roles = [
{ name: 'Admin', value: 'ADMIN' },
{ name: 'Audit', value: 'AUDIT' }
];
this.regForm = this.fb.group({
userid: [null],
firstName: [null, Validators.compose([Validators.required, Validators.minLength(2), Validators.maxLength(10)])],
firstName: [null, Validators.compose([Validators.required, Validators.minLength(2)])],
lastName: [null, Validators.compose([Validators.required])],
phone: [null, Validators.compose([Validators.required, Validators.minLength(10), Validators.maxLength(12)])],
altphone: [null, Validators.compose([Validators.minLength(10), Validators.maxLength(12)])],
@ -127,6 +124,7 @@ export class RegisterComponent implements OnInit {
//console.log(this.files);
}
register(userData) {
// console.log(userData);
let data:any;
console.log(this.usersData);
// console.log(this.files);
@ -197,19 +195,25 @@ this.loader = true;
}
}
getcity(e){
// console.log(e)
// this.City =[]= this.City.filter(city=>city.fk_state == e.state_id)[0];
}
userupdate() {
if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined) {
this.usersData = this.users.localUserId;
console.log(this.usersData);
console.log(this.usersData);
this.users.entityType().subscribe(res => {
this.types = res;
if (this.types.status == 200) {
this.types = this.types.records;
let type = this.types.filter(type => type.entity_type_id == this.usersData.fk_entity_id)[0];
this.regForm.controls['type'].setValue(type);
this.checktype(type);
let type = this.types.records;
this.types= type.filter(type => type.entity_type_id == this.usersData.fk_entity_id);
this.checktype(this.types[0]);
this.regForm.controls['type'].setValue(this.types[0]);
}
});
this.users.City().subscribe(res => {
@ -248,13 +252,8 @@ this.loader = true;
}
})
let userRole: any = [];
//console.log(this.usersData.profilepic);
for (let role of this.usersData[0]) {
//console.log(role);
userRole.push(this.roles.filter(roles => roles.value == role.user_role)[0]);
//console.log(userRole);
}
//console.log(userRole);
// this.regForm.controls['firstName'].setValue({'firstName':'sriram'});
@ -273,18 +272,32 @@ this.loader = true;
} else {
this.regForm.controls['isactive'].setValue(false);
}
this.regForm.controls['role'].setValue(userRole);
// this.regForm.controls['userpic'].setValue(this.usersData.profilepic);
this.regForm.controls['pincode'].setValue(this.usersData.pincode);
this.img = this.usersData.profilepic;
}
}
checktype(e){
console.log(e);
//console.log(e);
let userRole:any = [];
if(e !== undefined){
this.AWS.adminlistgroup(e.entity_type_id).subscribe(res=>{
this.roles = res;
if(this.usersData !==undefined){
for (let role of this.usersData[0]) {
//console.log(role);
userRole.push(this.roles.filter(roles => roles.GroupName == role.user_role)[0]);
//console.log(userRole);
this.regForm.controls['role'].setValue(userRole);
}
}
})
switch (e.entity_type_id) {
case "1":
this.typeValue =1;
break;
case "2":
this.typeValue =2;
@ -296,7 +309,10 @@ this.loader = true;
this.typeValue = -1;
break;
}
}
}
back(){
delete this.users.localUserId;

View File

@ -40,66 +40,67 @@
</mat-card> -->
<mat-card-content>
<div style="text-align: right;">
<button mat-raised-button color="primary" (click)="add()"> + Add Register</button>
</div>
<br>
<div *ngIf="loader">
<mat-progress-bar mode="indeterminate" color="accent" class="mb-1"></mat-progress-bar>
</div>
<div style="text-align: right;">
<button mat-raised-button color="primary" (click)="add()"> + Add Register</button>
</div>
<br>
<div *ngIf="loader">
<mat-progress-bar mode="indeterminate" color="accent" class="mb-1"></mat-progress-bar>
</div>
<div class="example-header">
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>
</div>
<div class="example-container mat-elevation-z8">
<mat-table [dataSource]="dataSource" matSort >
<ng-container matColumnDef="SerialNo">
<mat-header-cell *matHeaderCellDef mat-sort-header>Sl </mat-header-cell>
<mat-cell *matCellDef="let row; let i = index;"> {{i+1}} </mat-cell>
</ng-container>
<ng-container matColumnDef="FullName">
<mat-header-cell *matHeaderCellDef mat-sort-header> Full Name </mat-header-cell>
<mat-cell *matCellDef="let us"> {{us.user_first_name}} {{us.user_last_name}} </mat-cell>
</ng-container>
<ng-container matColumnDef="Email">
<mat-header-cell *matHeaderCellDef mat-sort-header> Email Id </mat-header-cell>
<mat-cell *matCellDef="let us"> {{us.email}} </mat-cell>
</ng-container>
<ng-container matColumnDef="Mobile">
<mat-header-cell *matHeaderCellDef mat-sort-header> Mobile No </mat-header-cell>
<mat-cell *matCellDef="let us"> {{us.mobile_no}} </mat-cell>
<div class="example-header">
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>
</div>
<div class="example-container mat-elevation-z8">
<mat-table [dataSource]="dataSource" matSort >
<ng-container matColumnDef="SerialNo">
<mat-header-cell *matHeaderCellDef mat-sort-header>Sl </mat-header-cell>
<mat-cell *matCellDef="let row; let i = index;"> {{i+1}} </mat-cell>
</ng-container>
<ng-container matColumnDef="IsActive">
<mat-header-cell *matHeaderCellDef mat-sort-header> Is Active </mat-header-cell>
<mat-cell *matCellDef="let us"><!--{{row.isactive}}-->
<a (click)="isactive(us.userid,us.aws_name)"><mat-icon *ngIf="us.isactive == 1;else notactive;" class="active" matTooltip="Active" matTooltipPosition="above">done</mat-icon></a>
<a (click)="isactive(us.userid,us.aws_name)"><ng-template #notactive ><mat-icon class="deactive" matTooltip="Inactive" matTooltipPosition="above">close</mat-icon></ng-template></a>
</mat-cell>
</ng-container>
<ng-container matColumnDef="Actions">
<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>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;">
</mat-row>
</mat-table>
<ng-container matColumnDef="FullName">
<mat-header-cell *matHeaderCellDef mat-sort-header> Full Name </mat-header-cell>
<mat-cell *matCellDef="let us"> {{us.user_first_name}} {{us.user_last_name}} </mat-cell>
</ng-container>
<ng-container matColumnDef="Email">
<mat-header-cell *matHeaderCellDef mat-sort-header> Email Id </mat-header-cell>
<mat-cell *matCellDef="let us"> {{us.email}} </mat-cell>
</ng-container>
<ng-container matColumnDef="Mobile">
<mat-header-cell *matHeaderCellDef mat-sort-header> Mobile No </mat-header-cell>
<mat-cell *matCellDef="let us"> {{us.mobile_no}} </mat-cell>
</ng-container>
<ng-container matColumnDef="IsActive">
<mat-header-cell *matHeaderCellDef mat-sort-header> Is Active </mat-header-cell>
<mat-cell *matCellDef="let us"><!--{{row.isactive}}-->
<a (click)="isactive(us.userid,us.aws_name)"><mat-icon *ngIf="us.isactive == 1;else notactive;" class="active" matTooltip="Active" matTooltipPosition="above">done</mat-icon></a>
<a (click)="isactive(us.userid,us.aws_name)"><ng-template #notactive ><mat-icon class="deactive" matTooltip="Inactive" matTooltipPosition="above">close</mat-icon></ng-template></a>
</mat-cell>
</ng-container>
<!-- <div *ngIf="dataSource.length === 0">No records found</div> -->
<mat-paginator [pageSizeOptions]="[5, 10, 25, 50, 100]"></mat-paginator>
</div>
<ng-container matColumnDef="Actions">
<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> -->
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;">
</mat-row>
</mat-table>
<!-- <div *ngIf="dataSource.length === 0">No records found</div> -->
<mat-paginator [pageSizeOptions]="[5, 10, 25, 50, 100]"></mat-paginator>
</div>
</mat-card-content>

View File

@ -26,6 +26,7 @@ export class UserListComponent implements OnInit {
constructor(public aws: AwsService, public route: Router,public users:UserService) {
this.getusers();
}
@ -116,9 +117,15 @@ export class UserListComponent implements OnInit {
add(){
this.route.navigate(['setting/users/register']);
}
// deleteuser(user){
// this.aws.deleteAws(user).subscribe(res=>{
// this.getusers();
// });
// }
deleteuser(user){
this.aws.admindelete(user).subscribe(res=>{
this.getusers();
});
}
adminedituser(user){
this.aws.adminresetpassword(user).subscribe(res=>{
this.getusers();
})
}
}

View File

@ -0,0 +1,126 @@
<div class="user-profile relative">
<div class="profile-cover">
</div>
<div class="">
<!-- <div fxLayout="row" fxLayoutWrap="wrap" class="profile-w">
<div fxFlex.gt-sm="25" fxFlex.gt-xs="25" fxFlex="20">
</div>
<div fxFlex.gt-sm="50" fxFlex.gt-xs="50" fxFlex="80" class="user-links">
<ul class="profile-menu">
<li><a href="">Tweets<span class="block text-lg-center">217</span></a></li>
<li><a href="">Followings<span class="block text-lg-center">89</span></a></li>
<li><a href="">Followers<span class="block text-lg-center">78,6790</span></a></li>
<li><a href="">Likes<span class="block text-lg-center">7</span></a></li>
<li><a href="">Moments<span class="block text-lg-center">0</span></a></li>
</ul>
</div>
<div fxFlex.gt-sm="25" fxFlex.gt-xs="25" fxFlex="100" class="align-self-center">
<button type="button" class="UserActions-editButton edit-button EdgeButton EdgeButton--tertiary" data-scribe-element="profile_edit_button">
<span class="button-text">Edit profile</span>
</button>
</div>
</div> -->
<div fxLayout="row" fxLayoutWrap="wrap">
<div fxFlex.gt-sm="25" fxFlex.gt-xs="50" fxFlex="100" class="relative">
<div class="profile-avatar">
<img src="../../../assets/images/test3.jpg" width="200" height="200" alt="user">
</div>
<div class="profile-info">
<h3 class="profile-name"><strong>{{userDetails.user_full_name}}</strong></h3>
<span class="user-name">{{userDetails.email}}</span>
<span class="user-name">{{userDetails.mobile_no}}</span>
<span class="pro-des">
</span>
<span><i class="fa fa-map-marker"></i> {{userDetails.addressline1}} {{userDetails.addressline2}}</span>
<span><i class="fa fa-calendar"></i>{{userDetails.addressline3}} {{userDetails.state_name}} - {{userDetails.pincode}}</span>
<span>{{userDetails.createdon | date:'dd MMM yyyy'}}</span>
</div>
</div>
<div fxFlex.gt-sm="50" fxFlex.gt-xs="50" fxFlex="100" class="mt-1">
<div class="profile-content">
<div class="profile-head">
<h4>Tweets</h4>
<div fxFlex.gt-sm="25" fxFlex.gt-xs="25" fxFlexOffset="50" fxFlex="100" class="align-self-center">
<button type="button" class="UserActions-editButton edit-button EdgeButton EdgeButton--tertiary" data-scribe-element="profile_edit_button" (click)="changePassword()">
<span class="button-text">Edit profile</span>
</button>
</div>
<hr>
</div>
<div class="profile-cont">
<ul class="pl-0">
<li>
<div fxLayout="row">
<div fxFlex.xs="15" fxFlex.sm="15" fxFlex.md="15" fxFlex.lg="15" fxFlex.xl="15"> <img class="profile-thumb" src="../../../assets/images/test3.jpg" width="80" height="80" alt="user">
</div>
<div class="pl-1 pr-1 profile-i" fxFlex.xs="85" fxFlex.sm="85" fxFlex.md="85" fxFlex.lg="85" fxFlex.xl="85">
<div>
<span class="post-profile-head">{{userDetails.user_full_name}}</span>
<span class="twitter-uname"><i class="fa fa-email"></i> {{userDetails.email}}</span>
<span class="time">{{userDetails.createdon | date:'dd MMM yyyy'}}</span>
<p><i class="fa fa-mobile"></i> {{userDetails.mobile_no}}</p>
<p>{{userDetails.addressline1}} {{userDetails.addressline2}} <br/>
{{userDetails.addressline3}} - {{userDetails.pincode}} {{userDetails.state_name}}
</p>
</div>
<div class="profile-action"><a href=""><i class="fa fa-retweet"></i></a><a href=""><i class="fa fa-comment-o"></i></a><a href=""><i class="fa fa-heart-o"></i></a></div>
</div>
</div>
</li>
<li>
<div fxLayout="row">
<div fxFlex.xs="15" fxFlex.sm="15" fxFlex.md="15" fxFlex.lg="15" fxFlex.xl="15"> <img class="profile-thumb" src="../../../assets/images/test3.jpg" width="80" height="80" alt="user">
</div>
<div class="pl-1 pr-1 profile-i" fxFlex.xs="85" fxFlex.sm="85" fxFlex.md="85" fxFlex.lg="85" fxFlex.xl="85">
<div>
<span class="post-profile-head">Jane Doe</span>
<span class="twitter-uname">@JaneDoe</span>
<span class="time">Sep 11, 2017</span>
<p>
“Tomorrow belongs to those who can hear it coming.” - David Bowie
</p>
</div>
<div class="profile-action"><a href=""><i class="fa fa-retweet"></i></a><a href=""><i class="fa fa-comment-o"></i></a><a href=""><i class="fa fa-heart-o"></i></a></div>
</div>
</div>
</li>
<li>
<div fxLayout="row">
<div fxFlex.xs="15" fxFlex.sm="15" fxFlex.md="15" fxFlex.lg="15" fxFlex.xl="15"> <img class="profile-thumb" src="../../../assets/images/test3.jpg" width="80" height="80" alt="user">
</div>
<div class="pl-1 pr-1 profile-i" fxFlex.xs="85" fxFlex.sm="85" fxFlex.md="85" fxFlex.lg="85" fxFlex.xl="85">
<div>
<span class="post-profile-head">Jane Doe</span>
<span class="twitter-uname">@JaneDoe</span>
<span class="time">Sep 13, 2017</span>
<p>our recent work</p>
</div>
<div class="img-wrp" fxLayout="row" fxLayoutWrap="space-around">
<div fxFlex.gt-sm="50" fxFlex.gt-xs="50" fxFlex="100">
<div class="thumb-border">
<img src="../../../assets/images/blog-1.jpg" alt="user">
</div>
</div>
<div fxFlex.gt-sm="50" fxFlex.gt-xs="50" fxFlex="100">
<div class="thumb-border">
<img src="../../../assets/images/blog-2.jpg" alt="user">
</div>
</div>
</div>
<div class="profile-action"><a href=""><i class="fa fa-retweet"></i></a><a href=""><i class="fa fa-comment-o"></i></a><a href=""><i class="fa fa-heart-o"></i></a></div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div fxFlex.gt-sm="25" fxFlex.gt-xs="50" fxFlex="100" class="align-self-center">
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,109 @@
import { Component, OnInit,ViewEncapsulation } from '@angular/core';
import { AwsService } from '../../../AwsService/aws.service';
import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { CustomValidators } from 'ng2-validation';
import { UserService } from '../../service/user.service';
@Component({
selector: 'ms-user-profile',
templateUrl:'./user-profile-component.html',
styleUrls: ['./user-profile-component.scss'],
encapsulation: ViewEncapsulation.None
})
export class UserProfileComponent implements OnInit {
config: MatDialogConfig = {
disableClose: false,
width: '',
height: '',
position: {
top: '',
bottom: '',
left: '',
right: ''
}
};
userDetails:any=[];
constructor(public AWS:AwsService,public dialog: MatDialog,public users:UserService ) {
this.getuser();
}
ngOnInit() {
}
getuser(){
//console.log(this.AWS.getUser());
this.users.getroles().subscribe(res=>{
this.userDetails = res;
this.userDetails = this.userDetails.records[0];
});
}
changePassword(){
let dialogRef = this.dialog.open(ChangePasswordDialog,this.config);
dialogRef.afterClosed().subscribe(result => {
if(result !==undefined){
if(result.confirmPassword !== undefined && result.confirmPassword !="" && result.newPassword !="" && result.oldPassword !=""){
this.AWS.changepassword(result)
.subscribe(res=>{
alert('Change Password');
})
}
}
//console.log(ChangePasswordDialog.prototype.pass);
});
}
}
@Component({
selector: 'app-jazz-dialog',
template: `
<h5 class="mt-0">New Password Change.</h5>
<mat-form-field>
<input matInput placeholder="Old Password" [(ngModel)]="pass.oldPassword" type="password" style="width: 100%;">
</mat-form-field>
<br/>
<mat-form-field>
<input matInput placeholder="New Password" [(ngModel)]="pass.newPassword" type="password" style="width: 100%;">
</mat-form-field>
<br/>
<mat-form-field>
<input matInput placeholder="ConfirmPassword" [(ngModel)]="pass.confirmPassword" type="password" style="width: 100%;">
</mat-form-field>
<small *ngIf="pass.confirmPassword !='' && pass.newPassword != pass.confirmPassword" class="mat-text-warn">Passwords do not math.</small>
<br>
<button mat-raised-button class="mat-green" type="submit" (click)="dialogRef.close(pass)">Submit</button>
`
})
export class ChangePasswordDialog{
pass = {
oldPassword:'',
newPassword:'',
confirmPassword:'',
}
jazzMessage = 'Jazzy jazz jazz';
constructor(public dialogRef: MatDialogRef <ChangePasswordDialog>,public aws:AwsService) {
}
}

View File

@ -18,6 +18,7 @@ import { RouterModule } from '@angular/router';
import { UserRoutes} from './users.routing';
import { RegisterComponent } from './register/register.component';
import { UserListComponent} from './user-list/user-list.component';
import { UserProfileComponent, ChangePasswordDialog } from './user-profile/user-profile.component';
import { NewPasswordDialog, ForgotPass } from '../../session/login/login.component';
// import { HttpClientModule } from '@angular/common/http';
@ -36,7 +37,7 @@ import { NewPasswordDialog, ForgotPass } from '../../session/login/login.compone
FormsModule, ReactiveFormsModule,
// HttpClientModule,
],
declarations: [UserListComponent, RegisterComponent],
declarations: [UserListComponent, RegisterComponent,UserProfileComponent],
})

View File

@ -2,6 +2,7 @@ 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: '',
redirectTo: 'userlist',
@ -14,5 +15,8 @@ export const UserRoutes: Routes = [{
},{
path: 'register',
component: RegisterComponent
},{
path:'userprofile',
component:UserProfileComponent
}]
}];

View File

@ -36,15 +36,15 @@ const MENUITEMS : Menu[] = [
{state:'mastermodule',name:'Master Details'}
]
},
// {
// state:'pdtrigger',
// name:'PD Trigger',
// type:'sub',
// icon:'bubble_chart',
// children:[
// {state:'pdtriggerlist',name:'Pd Trigger Listing'}
// ]
// },
{
state:'pdtrigger',
name:'PD Trigger',
type:'link',
icon:'bubble_chart',
// children:[
// {state:'pdtriggerlist',name:'Pd Trigger Listing'}
// ]
},
{
state: 'authentication',
name: 'AUTHENTICATION',