sparqclientapp user mangement aws
This commit is contained in:
parent
f9410a50ea
commit
d52bcb1990
8
sineedge/package-lock.json
generated
8
sineedge/package-lock.json
generated
@ -6986,6 +6986,14 @@
|
||||
"resolved": "https://registry.npmjs.org/ngx-color-picker/-/ngx-color-picker-4.5.3.tgz",
|
||||
"integrity": "sha512-CJca1od05yf2j8OKUm5ar+mIVFB3n01+vbMpLeT+9/drKYCxgmtxxmmsgwWBNNXWYa2GNYB7PGH+mdKQkeypOg=="
|
||||
},
|
||||
"ngx-mat-select-search": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/ngx-mat-select-search/-/ngx-mat-select-search-1.3.1.tgz",
|
||||
"integrity": "sha512-ZggcqsfcJZ1tcy6ZgNnifrvn/ahWJqRO2B7QXHt0FDUo4lrv/2cuHALzwuwlY/z8rZeH+ZEmaAevzQtYH8mKpA==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"ngx-perfect-scrollbar": {
|
||||
"version": "5.0.0-7",
|
||||
"resolved": "https://registry.npmjs.org/ngx-perfect-scrollbar/-/ngx-perfect-scrollbar-5.0.0-7.tgz",
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
"ng2-translate": "5.0.0",
|
||||
"ng2-validation": "4.2.0",
|
||||
"ngx-color-picker": "^4.0.3",
|
||||
"ngx-mat-select-search": "^1.3.1",
|
||||
"ngx-perfect-scrollbar": "5.0.0-7",
|
||||
"node-sass": "^4.9.3",
|
||||
"perfect-scrollbar": "^1.3.0",
|
||||
|
||||
@ -10,10 +10,10 @@ import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
|
||||
import { PERFECT_SCROLLBAR_CONFIG } from 'ngx-perfect-scrollbar';
|
||||
import { PerfectScrollbarConfigInterface } from 'ngx-perfect-scrollbar';
|
||||
import { TokenInterceptor } from './_guard/token.interceptor';
|
||||
import { TranslateModule, TranslateLoader, TranslateStaticLoader } from 'ng2-translate/ng2-translate';
|
||||
import { TranslateModule, TranslateLoader, TranslateStaticLoader } from 'ng2-translate/ng2-translate';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
import { DemoMaterialModule } from './shared/demo.module';
|
||||
|
||||
|
||||
import {MatSidenavModule} from '@angular/material/sidenav';
|
||||
import {MatInputModule} from '@angular/material/input';
|
||||
|
||||
@ -2,14 +2,15 @@ import { Routes } from '@angular/router';
|
||||
|
||||
import { AdminLayoutComponent } from './layouts/admin/admin-layout.component';
|
||||
import { AuthLayoutComponent } from './layouts/auth/auth-layout.component';
|
||||
|
||||
import { SharedService } from './shared.service';
|
||||
export const AppRoutes: Routes = [{
|
||||
path: '',
|
||||
redirectTo: 'authentication',
|
||||
redirectTo: 'home',
|
||||
pathMatch: 'full',
|
||||
}, {
|
||||
path: '',
|
||||
component: AdminLayoutComponent,
|
||||
canActivateChild: [SharedService],
|
||||
children: [{
|
||||
path: 'home',
|
||||
loadChildren: './dashboard/dashboard.module#DashboardModule'
|
||||
|
||||
@ -16,11 +16,11 @@ import { LoginComponent } from "./session/login/login.component";
|
||||
import { Http, Headers, RequestOptions } from '@angular/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
|
||||
import { SharedService } from './shared.service';
|
||||
|
||||
|
||||
let apiurl = 'http://localhost/sparqapi/api/';
|
||||
|
||||
const sineedge_poolData = {
|
||||
UserPoolId: "ap-south-1_y7dt3iEaX", //ap-south-1_qQ85yQZJO UserName :SPARQ_SINEEDGE_DEV
|
||||
ClientId: "291qt4smn5pql6o8cc2hi201lj" // ClientName: SINEEDGE_DEV_WEB
|
||||
@ -48,7 +48,7 @@ const sineedgeIdentity = "ap-south-1:9a551eab-97cf-4991-b677-2f9bcd058961";//"ap
|
||||
const lenderIdentity = "ap-south-1:ca22dabc-db59-4af5-9bb8-265f7ec95907";
|
||||
const vendorIdenttiy = "";
|
||||
// serviceProvider
|
||||
// apiurl = "http://localhost/sineedge/sparqapi/api/";
|
||||
const apiurl = "http://localhost/sineedge/sparqapi/api/";
|
||||
const currentdate = new Date().toJSON().slice(0,19).replace('T',' ');
|
||||
|
||||
@Injectable({
|
||||
@ -126,7 +126,7 @@ export class AwsService {
|
||||
// gets the current user from the local storage
|
||||
this.cognitoUser = sineedgedevUserpool.getCurrentUser();
|
||||
//let sessions = '';
|
||||
|
||||
|
||||
let jwttoken = "";
|
||||
let session = "";
|
||||
if (this.cognitoUser != null) {
|
||||
@ -203,8 +203,23 @@ export class AwsService {
|
||||
*/
|
||||
logOut() {
|
||||
window.localStorage.removeItem("Currentuser");
|
||||
this.getUser().signOut();
|
||||
this.cognitoUser = null;
|
||||
let session = this.getAuthenticatedUser() || "";
|
||||
//console.log(session.getAccessToken().getJwtToken());
|
||||
let params:any = {
|
||||
AccessToken:session.getAccessToken().getJwtToken()
|
||||
//UserPoolId:sineedge_poolData.UserPoolId
|
||||
}
|
||||
return Observable.create(observe=>{
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
cognitoidentityserviceprovider.globalSignOut(params, function(err, data) {
|
||||
if (err) console.log(err, err.stack); // an error occurred
|
||||
else
|
||||
AwsService.prototype.getUser().signOut();
|
||||
AwsService.prototype.cognitoUser = null;
|
||||
observe.next(data); // successful response
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
/**
|
||||
* User Change Password
|
||||
@ -271,6 +286,7 @@ export class AwsService {
|
||||
]
|
||||
};
|
||||
} else if (userData.type.entity_type_id == 2) {
|
||||
console.log(2);
|
||||
params = {
|
||||
UserPoolId: lender_poolData.UserPoolId /* required */,
|
||||
Username: userData.email /* required */,
|
||||
@ -294,7 +310,7 @@ export class AwsService {
|
||||
]
|
||||
};
|
||||
}
|
||||
// .log(params);
|
||||
console.log(params);
|
||||
return Observable.create(observe => {
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
|
||||
@ -306,30 +322,32 @@ export class AwsService {
|
||||
// an error occurred
|
||||
|
||||
|
||||
this.mySecData = data;
|
||||
|
||||
AwsService.prototype.UserGroup(data, userData);
|
||||
observe.next(data);
|
||||
|
||||
// successful response
|
||||
});
|
||||
});
|
||||
}else{
|
||||
return alert('Admin Only create user');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UserGroup(cognitodata, userData) {
|
||||
//(userData);
|
||||
|
||||
console.log(cognitodata);
|
||||
let session = this.getAuthenticatedUser() || "";
|
||||
this.getconfig();
|
||||
|
||||
//let cognitodata = "539bfefa-ae42-4bee-bf79-4b15d1a2af7f";
|
||||
if(userData.userid ==''){
|
||||
if(userData.userid === null ){
|
||||
for(let role of userData.role){
|
||||
|
||||
let params: any;
|
||||
if (userData.type.entity_type_id == 1) {
|
||||
|
||||
|
||||
params = {
|
||||
GroupName: role.value /* required */,
|
||||
UserPoolId: sineedgedev_poolData.UserPoolId,//"ap-south-1_y7dt3iEaX" /* required */,
|
||||
@ -433,43 +451,59 @@ export class AwsService {
|
||||
createdby = this.getlocale();
|
||||
createdon = currentdate;
|
||||
}
|
||||
|
||||
|
||||
let profilepic:any;
|
||||
if(users.userpic !=null && users.userpic !='' && users.userpic !==undefined){
|
||||
profilepic= users.userpic.name;
|
||||
}
|
||||
console.log(profilepic);
|
||||
let formData = new FormData();
|
||||
console.log(users);
|
||||
|
||||
let records:any = {
|
||||
"userid":users.userid,
|
||||
"aws_name": aws_name,
|
||||
"first_name": users.firstName,
|
||||
"last_name": users.lastName,
|
||||
"mobile_no": users.phone,
|
||||
"email": users.email,
|
||||
"alt_email":users.alt_email,
|
||||
"alt_mobile_no":users.alt_mobile_no,
|
||||
"addressline1":users.address1,
|
||||
"addressline2":users.address2,
|
||||
"addressline3":users.address3,
|
||||
"isactive":users.isactive,
|
||||
"fk_entity_id":users.type.entity_type_id,
|
||||
"fk_designation":users.designation.designation_id,
|
||||
"fk_city":users.city.city_id,
|
||||
"fk_state":users.state.state_id,
|
||||
"pincode":users.pincode,
|
||||
"profilepic":users.userpic.name,
|
||||
"fk_createdby":createdby,
|
||||
"fk_updatedby":updateby,
|
||||
"createdon":createdon,
|
||||
"updatedon":updateon,
|
||||
};
|
||||
|
||||
let roles:any=[];
|
||||
for(var role of users.role){
|
||||
|
||||
roles.push({ "user_role": role.value });
|
||||
}
|
||||
console.log(roles);
|
||||
let designation:any;
|
||||
if(users.type.entity_type_id ==2){
|
||||
let lenderhie:any =[];
|
||||
lenderhie.push(users.lenderHierarchy);
|
||||
formData.append('lender_hierarchy',JSON.stringify(lenderhie));
|
||||
designation = '';
|
||||
}else if(users.type.entity_type_id ==1){
|
||||
designation =users.designation.designation_id;
|
||||
}
|
||||
let records:any = {
|
||||
"userid":users.userid,
|
||||
"aws_name": aws_name,
|
||||
"first_name": users.firstName,
|
||||
"last_name": users.lastName,
|
||||
"mobile_no": users.phone,
|
||||
"email": users.email,
|
||||
"alt_email":users.alt_email,
|
||||
"alt_mobile_no":users.alt_mobile_no,
|
||||
"addressline1":users.address1,
|
||||
"addressline2":users.address2,
|
||||
"addressline3":users.address3,
|
||||
"isactive":users.isactive,
|
||||
"fk_entity_id":users.type.entity_type_id,
|
||||
"fk_designation":designation,
|
||||
"fk_city":users.city.city_id,
|
||||
"fk_state":users.state.state_id,
|
||||
"pincode":users.pincode,
|
||||
"profilepic":profilepic,
|
||||
"fk_createdby":createdby,
|
||||
"fk_updatedby":updateby,
|
||||
"createdon":createdon,
|
||||
"updatedon":updateon,
|
||||
};
|
||||
//console.log(roles);
|
||||
formData.append('records',JSON.stringify(records));
|
||||
formData.append('roles',JSON.stringify(roles));
|
||||
formData.append('profilepic',users.userpic);
|
||||
|
||||
//new Response(formData).text().then(console.log);
|
||||
//let headers = this.shared.headercofig('');
|
||||
let session:any = this.getAuthenticatedUser() ||"";
|
||||
@ -481,7 +515,9 @@ export class AwsService {
|
||||
|
||||
//(request);
|
||||
if(users.userid !='' && users.userid !=null && users.userid !==undefined){
|
||||
delete this.localUserId;
|
||||
return this.http.post(apiurl+'updateExistUser',formData,{headers:headers}).map(res=>res.json());
|
||||
|
||||
}else{
|
||||
return this.http.post(apiurl + "saveNewUser", formData, { headers: headers }).map(res => res.json());
|
||||
}
|
||||
@ -503,9 +539,10 @@ export class AwsService {
|
||||
usergroup => usergroup == "ADMIN"
|
||||
)[0];
|
||||
//cognitosdata = 7;
|
||||
|
||||
let params:any;
|
||||
if (userGroup == 'ADMIN') {
|
||||
var params = {
|
||||
if(user.type.entity_type_id ==1){
|
||||
params = {
|
||||
UserAttributes: [ /* required */
|
||||
{
|
||||
Name: 'locale', /* required */
|
||||
@ -516,6 +553,19 @@ export class AwsService {
|
||||
UserPoolId: sineedgedev_poolData.UserPoolId, /* required */
|
||||
Username: user.email /* required */
|
||||
};
|
||||
}else if(user.type.entity_type_id ==2){
|
||||
params = {
|
||||
UserAttributes: [ /* required */
|
||||
{
|
||||
Name: 'locale', /* required */
|
||||
Value: cognitosdata.toString()
|
||||
},
|
||||
/* more items */
|
||||
],
|
||||
UserPoolId: lender_poolData.UserPoolId, /* required */
|
||||
Username: user.email /* required */
|
||||
};
|
||||
}
|
||||
//console.log(params);
|
||||
return Observable.create(observe => {
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
@ -606,11 +656,18 @@ export class AwsService {
|
||||
* @param records
|
||||
*/
|
||||
adminupendis(records){
|
||||
let headers = this.shared.headercofig('');
|
||||
console.log(headers);
|
||||
let users = this.http.post(apiurl + 'updateExistUser',JSON.stringify(records), { headers: headers }).map(res => res.json());
|
||||
console.log(users);
|
||||
return users;
|
||||
//let headers = this.shared.headercofig('');
|
||||
// console.log(headers);
|
||||
let session = this.getAuthenticatedUser() || "";
|
||||
let formData = new FormData();
|
||||
formData.append('records',JSON.stringify(records));
|
||||
let headers = new Headers(
|
||||
{
|
||||
'Authorization':'sparqvenba2018','Token':session.getIdToken().getJwtToken()
|
||||
});
|
||||
return this.http.post(apiurl+'updateExistUser',formData,{headers:headers}).map(res=>res.json());
|
||||
//console.log(users);
|
||||
|
||||
}
|
||||
/**
|
||||
* Admin Create User End
|
||||
@ -645,7 +702,7 @@ export class AwsService {
|
||||
if (userData.fk_entity_id == 1) {
|
||||
params = {
|
||||
UserPoolId: sineedgedev_poolData.UserPoolId /* required */,
|
||||
Username: userData.email,//userData.email /* required */,
|
||||
Username: userData.aws_name,//userData.email /* required */,
|
||||
|
||||
// ForceAliasCreation: true || false,
|
||||
|
||||
@ -664,7 +721,7 @@ export class AwsService {
|
||||
} else if (userData.fk_entity_id == 2) {
|
||||
params = {
|
||||
UserPoolId: lender_poolData.UserPoolId /* required */,
|
||||
Username: changeusers.email /* required */,
|
||||
Username: userData.aws_name /* required */,
|
||||
|
||||
UserAttributes: [
|
||||
{
|
||||
@ -679,6 +736,7 @@ export class AwsService {
|
||||
]
|
||||
};
|
||||
}
|
||||
console.log(params);
|
||||
return Observable.create(observe=>{
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
cognitoidentityserviceprovider.adminUpdateUserAttributes(params, function(err, data) {
|
||||
@ -774,5 +832,10 @@ adminremoveGroup(roles,users){
|
||||
let master_name = {'master_name':'DESIGNATION'};
|
||||
return this.http.post(apiurl+'getListOfMaster',master_name,{headers:headers}).map(res=>res.json());
|
||||
}
|
||||
lenderHierarchy(){
|
||||
let headers = this.shared.headercofig('');
|
||||
let master_name = {'master_name':'LENDERHIERARCHY'};
|
||||
return this.http.post(apiurl+'getListOfMaster',master_name,{headers:headers}).map(res=>res.json());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@ import PerfectScrollbar from 'perfect-scrollbar';
|
||||
import { PerfectScrollbarConfigInterface,
|
||||
PerfectScrollbarComponent, PerfectScrollbarDirective } from 'ngx-perfect-scrollbar';
|
||||
import { SharedService } from '../../shared.service';
|
||||
import { AwsService } from '../../aws.service';
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
templateUrl: './admin-layout.component.html'
|
||||
@ -42,7 +43,7 @@ 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 shared:SharedService ) {
|
||||
constructor(private router: Router, public menuItems: MenuItems, public horizontalMenuItems : HorizontalMenuItems, public translate: TranslateService,public shared:SharedService,public aws:AwsService ) {
|
||||
const browserLang: string = translate.getBrowserLang();
|
||||
translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
|
||||
}
|
||||
@ -221,4 +222,14 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
logout(){
|
||||
this.aws.logOut().subscribe(res=>{
|
||||
this.router.navigate(['/authentication/login']);
|
||||
});
|
||||
}
|
||||
|
||||
userProfile(){
|
||||
this.router.navigate(['/user-pages/userprofile']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,24 +1,27 @@
|
||||
|
||||
|
||||
<mat-card>
|
||||
<mat-card-title>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 Registration</mat-card-title>
|
||||
<!-- <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>
|
||||
<small *ngIf="regForm.controls['firstName'].hasError('required') && regForm.controls['firstName'].touched" class="mat-text-warn">You must include a first name.</small>
|
||||
<small *ngIf="regForm.controls['firstName'].hasError('minlength') && regForm.controls['firstName'].touched" class="mat-text-warn">Your first name must be at least 5 characters long.</small>
|
||||
<small *ngIf="regForm.controls['firstName'].hasError('maxlength') && regForm.controls['firstName'].touched" class="mat-text-warn">Your first name cannot exceed 10 characters.</small>
|
||||
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
<small *ngIf="regForm.controls['lastName'].hasError('required') && regForm.controls['lastName'].touched" class="mat-text-warn">You must include a last name.</small>
|
||||
<!-- <small *ngIf="regForm.controls['lastName'].hasError('minlength') && regForm.controls['lastName'].touched" class="mat-text-warn">Your first name must be at least 5 characters long.</small>
|
||||
<small *ngIf="regForm.controls['lastName'].hasError('maxlength') && regForm.controls['lastName'].touched" class="mat-text-warn">Your first name cannot exceed 10 characters.</small> -->
|
||||
<!-- <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>
|
||||
@ -28,15 +31,15 @@
|
||||
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
|
||||
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
|
||||
<input matInput placeholder="Email address" [formControl]="regForm.controls['email']" type="email">
|
||||
<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-form-field>
|
||||
<small *ngIf="regForm.controls['email'].hasError('required') && regForm.controls['email'].touched" class="mat-text-warn">You must include an email address.</small>
|
||||
<small *ngIf="regForm.controls['email'].errors?.email && regForm.controls['email'].touched" class="mat-text-warn">You must include a valid email address.</small>
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
<small *ngIf="regForm.controls['email'].errors?.email && regForm.controls['altemail'].touched" class="mat-text-warn">You must include a valid email address.</small>
|
||||
<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>
|
||||
|
||||
|
||||
@ -46,15 +49,17 @@
|
||||
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
|
||||
<mat-form-field dividerColor="primary" class="ml-xs mr-xs">
|
||||
<input matInput placeholder="Phone number" [formControl]="regForm.controls['phone']" type="text">
|
||||
<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>
|
||||
<small *ngIf="regForm.controls['phone'].hasError('required') && regForm.controls['phone'].touched" class="mat-text-warn">You must include phone number.</small>
|
||||
<small *ngIf="regForm.controls['phone'].errors?.phone && regForm.controls['phone'].touched" class="mat-text-warn">You must include a valid phone number.</small>
|
||||
|
||||
|
||||
<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>
|
||||
<!-- <small *ngIf="regForm.controls['phone'].hasError('required') && regForm.controls['phone'].touched" class="mat-text-warn">You must include phone number.</small> -->
|
||||
<small *ngIf="regForm.controls['altphone'].errors?.phone && regForm.controls['phone'].touched" class="mat-text-warn">You must include a valid phone number.</small>
|
||||
<!-- <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']">
|
||||
@ -85,21 +90,21 @@
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
||||
<small *ngIf="regForm.controls['role'].hasError('required') && regForm.controls['role'].touched" class="mat-text-warn">Select User Role</small>
|
||||
<small *ngIf="regForm.controls['role'].errors?.phone && regForm.controls['role'].touched" class="mat-text-warn">Select User Role</small>
|
||||
<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: 100%;">
|
||||
<mat-select matInput placeholder="Select type" [formControl]="regForm.controls['type']" required>
|
||||
<mat-select matInput placeholder="Select type" (selectionChange)="checktype($event.value)"[formControl]="regForm.controls['type']" required>
|
||||
<mat-option>--</mat-option>
|
||||
<mat-option *ngFor="let types of types" [value]="types" >
|
||||
{{types.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<small *ngIf="regForm.controls['type'].hasError('required') && regForm.controls['type'].touched" class="mat-text-warn">Select User Role</small>
|
||||
<small *ngIf="regForm.controls['type'].errors?.phone && regForm.controls['type'].touched" class="mat-text-warn">Select User Role</small>
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
|
||||
@ -122,7 +127,7 @@
|
||||
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 100%;">
|
||||
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 100%;" *ngIf="typeValue == '1'">
|
||||
<mat-select matInput placeholder="Select designation" [formControl]="regForm.controls['designation']" required>
|
||||
<mat-option>--</mat-option>
|
||||
<mat-option *ngFor="let d of designation" [value]="d">
|
||||
@ -130,6 +135,14 @@
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 100%;" *ngIf="typeValue == '2'">
|
||||
<mat-select matInput placeholder="Select lenderHierarchy" [formControl]="regForm.controls['lenderHierarchy']" required>
|
||||
<mat-option>--</mat-option>
|
||||
<mat-option *ngFor="let l of lenderHierarchy" [value]="l">
|
||||
{{l.lender_hierarchy}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
|
||||
@ -145,26 +158,20 @@
|
||||
</mat-slide-toggle>
|
||||
</mat-card-content>
|
||||
<hr>
|
||||
<!-- <pre>{{regForm.controls['userid'].value | json}}</pre> -->
|
||||
<!-- <mat-card-actions *ngIf="regForm.controls['userid'].value !=null">
|
||||
|
||||
<mat-card-actions *ngIf="usersData !=''">
|
||||
<button mat-raised-button color="primary" type="submit">Submit</button>
|
||||
</mat-card-actions> -->
|
||||
<mat-card-actions >
|
||||
|
||||
|
||||
<button mat-raised-button color="primary" type="submit">Submit</button>
|
||||
</mat-card-actions>
|
||||
<mat-card-actions *ngIf="usersData ==''">
|
||||
|
||||
<button mat-raised-button color="primary" [disabled]="!regForm.valid" type="submit">Submit</button>
|
||||
</mat-card-actions>
|
||||
</form>
|
||||
<!-- <button mat-raised-button color="primary" (click)="userupdate()" >Submit</button> -->
|
||||
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 100%;">
|
||||
<mat-select matInput placeholder="Select Role" [(ngModel)]="sampledrop" required multiple>
|
||||
<!-- <mat-option #allSelected (click)="toggleAllSelection()" [value]="0">ALL</mat-option> -->
|
||||
<mat-option *ngFor="let role of roles" [value]="role" (click)="toggleAllSelection(role)">
|
||||
{{role.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
||||
<!-- <small *ngIf="regForm.controls['role'].hasError('required') && regForm.controls['role'].touched" class="mat-text-warn">Select User Role</small>
|
||||
<small *ngIf="regForm.controls['role'].errors?.phone && regForm.controls['role'].touched" class="mat-text-warn">Select User Role</small> -->
|
||||
</mat-form-field>
|
||||
</mat-card>
|
||||
</mat-card>
|
||||
<div *ngIf="loader">
|
||||
<mat-progress-bar mode="indeterminate" color="accent" class="mb-1"></mat-progress-bar>
|
||||
|
||||
</div>
|
||||
@ -1,16 +1,16 @@
|
||||
|
||||
.mat-card-title{
|
||||
// .mat-card-title{
|
||||
|
||||
color: #fff;
|
||||
margin-left: 13px;
|
||||
background: rgba(157, 69, 124, 1);
|
||||
box-shadow: 0 4px 20px 0 rgba(157, 69, 124, 1), 0 7px 10px -5px rgba(157, 69, 124, 1);;
|
||||
display: inline-block;
|
||||
border-radius: 6px;
|
||||
padding: 10px;
|
||||
margin-top: -52px;
|
||||
// color: #fff;
|
||||
// margin-left: 13px;
|
||||
// background: rgba(157, 69, 124, 1);
|
||||
// box-shadow: 0 4px 20px 0 rgba(157, 69, 124, 1), 0 7px 10px -5px rgba(157, 69, 124, 1);;
|
||||
// display: inline-block;
|
||||
// border-radius: 6px;
|
||||
// padding: 10px;
|
||||
// margin-top: -52px;
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ export class RegisterComponent implements OnInit {
|
||||
img: any;
|
||||
roles: any;
|
||||
types: any;
|
||||
loader:boolean = false;
|
||||
public regForm: FormGroup;
|
||||
|
||||
// name: string;
|
||||
@ -26,14 +27,18 @@ export class RegisterComponent implements OnInit {
|
||||
City: any;
|
||||
State: any;
|
||||
designation: any;
|
||||
hierarchy:any=[];
|
||||
files: File = null
|
||||
usersData: any;
|
||||
sampledrop:any;
|
||||
typeValue:any;
|
||||
lenderHierarchy:any;
|
||||
@ViewChild('allSelected') private allSelected: MatOption;
|
||||
constructor(
|
||||
private router: Router, public fb: FormBuilder, public AWS: AwsService, private cd: ChangeDetectorRef
|
||||
, public shared: SharedService,private elementRef: ElementRef) { }
|
||||
ngOnInit() {
|
||||
|
||||
if (this.AWS.localUserId != '' && this.AWS.localUserId != null && this.AWS.localUserId !== undefined) {
|
||||
|
||||
} else {
|
||||
@ -63,6 +68,7 @@ export class RegisterComponent implements OnInit {
|
||||
userpic: [null],
|
||||
isactive: [true],
|
||||
pincode: [null],
|
||||
lenderHierarchy:[null,Validators.compose([Validators.required])],
|
||||
|
||||
});
|
||||
this.userupdate();
|
||||
@ -80,7 +86,7 @@ export class RegisterComponent implements OnInit {
|
||||
this.AWS.entityType().subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.types = res.records;
|
||||
console.log(this.types);
|
||||
//console.log(this.types);
|
||||
}
|
||||
});
|
||||
this.AWS.City().subscribe(res => {
|
||||
@ -98,10 +104,15 @@ export class RegisterComponent implements OnInit {
|
||||
this.designation = res.records;
|
||||
}
|
||||
});
|
||||
this.AWS.lenderHierarchy().subscribe(res=>{
|
||||
if(res.status ==200){
|
||||
this.lenderHierarchy = res.records;
|
||||
}
|
||||
})
|
||||
//console.log(this.State+''+this.types+''+this.City+''+this.designation);
|
||||
}
|
||||
onFileChange($event) {
|
||||
console.log($event.target.files[0]);
|
||||
//console.log($event.target.files[0]);
|
||||
|
||||
//if($event.target.files[0] < 0 ){
|
||||
this.files = $event.target.files[0];
|
||||
@ -109,26 +120,29 @@ export class RegisterComponent implements OnInit {
|
||||
//console.log(this.files);
|
||||
}
|
||||
register(userData) {
|
||||
console.log(userData);
|
||||
console.log(this.usersData);
|
||||
// console.log(this.files);
|
||||
if (this.usersData != '') {
|
||||
if (this.usersData != '' && this.usersData !== undefined) {
|
||||
if (this.files) {
|
||||
userData.userpic = this.files;
|
||||
} else {
|
||||
userData.userpic = this.usersData.profilepic;
|
||||
}
|
||||
} else {
|
||||
if (this.files) {
|
||||
if (this.files) {
|
||||
userData.userpic = this.files;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(this.usersData);
|
||||
//console.log(this.usersData);
|
||||
this.loader = true;
|
||||
if (this.usersData === undefined) {
|
||||
|
||||
this.AWS.register(userData).subscribe(res => {
|
||||
if (res.User.UserStatus != '' && res.User.UserStatus !== undefined && res.User.UserStatus != null) {
|
||||
this.AWS.saveRecords(res, userData).subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.AWS.adminUpdateuser(userData, res.record).subscribe(res => {
|
||||
this.loader =false;
|
||||
console.log(res);
|
||||
alert('user Created');
|
||||
this.shared.redirectTo('settings/userListing');
|
||||
@ -140,7 +154,10 @@ console.log(this.usersData);
|
||||
} else {
|
||||
this.AWS.adminchangeData(this.usersData,userData).subscribe(res=>{
|
||||
this.AWS.saveRecords(res,userData).subscribe(res=>{
|
||||
console.log(res);
|
||||
this.loader = false;
|
||||
alert('Update User');
|
||||
this.shared.redirectTo('settings/userListing');
|
||||
delete this.AWS.localUserId;
|
||||
})
|
||||
})
|
||||
|
||||
@ -172,36 +189,49 @@ console.log(this.usersData);
|
||||
|
||||
if (this.AWS.localUserId != '' && this.AWS.localUserId != null && this.AWS.localUserId !== undefined) {
|
||||
this.usersData = this.AWS.localUserId;
|
||||
console.log(this.usersData);
|
||||
// console.log(this.usersData);
|
||||
this.AWS.entityType().subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.types = res.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);
|
||||
}
|
||||
});
|
||||
this.AWS.City().subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.City = res.records.filter(city => city.city_id == this.usersData.fk_city);
|
||||
this.regForm.controls['city'].setValue(this.City[0]);
|
||||
console.log(this.City);
|
||||
this.City = res.records;
|
||||
let citys = this.City.filter(city => city.city_id == this.usersData.fk_city)[0];
|
||||
this.regForm.controls['city'].setValue(citys);
|
||||
// console.log(this.City);
|
||||
}
|
||||
});
|
||||
this.AWS.State().subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.State = res.records.filter(state => state.state_id == this.usersData.fk_state);
|
||||
console.log(this.State);
|
||||
this.regForm.controls['state'].setValue(this.State[0]);
|
||||
this.State = res.records;
|
||||
let states = this.State.filter(state => state.state_id == this.usersData.fk_state)[0];
|
||||
// console.log(this.State);
|
||||
this.regForm.controls['state'].setValue(states);
|
||||
}
|
||||
});
|
||||
this.AWS.designation().subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.designation = res.records.filter(des => des.designation_id == this.usersData.fk_designation);
|
||||
this.regForm.controls['designation'].setValue(this.designation[0]);
|
||||
this.designation = res.records;
|
||||
let des = this.designation.filter(des => des.designation_id == this.usersData.fk_designation)[0];
|
||||
this.regForm.controls['designation'].setValue(des);
|
||||
}
|
||||
});
|
||||
this.AWS.lenderHierarchy().subscribe(res=>{
|
||||
if(res.status ==200){
|
||||
this.lenderHierarchy = res.records;
|
||||
let hie = this.lenderHierarchy.filter(hie => hie.lender_hierarchy_id == this.usersData.fk_hierarchy_id)[0];
|
||||
console.log(hie);
|
||||
this.regForm.controls['lenderHierarchy'].setValue(hie);
|
||||
|
||||
}
|
||||
})
|
||||
let userRole: any = [];
|
||||
console.log(this.usersData.profilepic);
|
||||
//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]);
|
||||
@ -231,5 +261,26 @@ console.log(this.usersData);
|
||||
this.img = this.usersData.profilepic;
|
||||
}
|
||||
}
|
||||
|
||||
checktype(e){
|
||||
console.log(e);
|
||||
if(e !== undefined){
|
||||
switch (e.entity_type_id) {
|
||||
case "1":
|
||||
this.typeValue =1;
|
||||
break;
|
||||
case "2":
|
||||
this.typeValue =2;
|
||||
break;
|
||||
case "3":
|
||||
this.typeValue =3;
|
||||
break;
|
||||
default :
|
||||
this.typeValue = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
back(){
|
||||
this.router.navigate(['settings/userListing']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,9 @@ export const SettingsRoute: Routes = [
|
||||
{
|
||||
path:'userListing',
|
||||
component:UserListComponent
|
||||
},{
|
||||
path: 'userRegister',
|
||||
component: RegisterComponent
|
||||
},{
|
||||
path:'masters',
|
||||
component:MastersComponent
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
<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)="addRegister()" > + Add Register</button>
|
||||
</div>
|
||||
<div style="text-align: right;">
|
||||
<button mat-raised-button color="primary" (click)="add()">Add Register</button>
|
||||
</div>
|
||||
|
||||
<mat-card>
|
||||
<div datatable>
|
||||
|
||||
|
||||
|
||||
<table style="border-collapse: collapse">
|
||||
<thead>
|
||||
<th style="text-align: center;">No</th>
|
||||
@ -16,19 +19,21 @@
|
||||
<th style="text-align: center;">Action</th>
|
||||
<th style="text-align: center;">Isactive</th>
|
||||
</thead>
|
||||
|
||||
<tr *ngFor="let us of userdata; let i=index" >
|
||||
<tbody>
|
||||
<tr *ngFor="let us of userdata; let i=index;" >
|
||||
<td style="text-align: center;">{{i+1}}</td>
|
||||
|
||||
<td style="text-align: center;">{{us.user_first_name}} {{us.user_last_name}}</td>
|
||||
<td style="text-align: center;">{{us.email}}</td>
|
||||
<td style="text-align: center;">{{us.mobile_no}}</td>
|
||||
<td style="text-align: center;font-size: 20px"><a (click)="editUserDetails(us.userid,us.aws_name)"><i class="fa fa-pencil"></i></a></td>
|
||||
<td style="text-align: center;font-size: 20px"><a (click)="editUserDetails(us.userid,us.aws_name)"><mat-icon>edit</mat-icon></a></td>
|
||||
|
||||
<td *ngIf="us.isactive ==1" style="text-align: center;"><a (click)="isactive(us.userid,us.aws_name)"><i class="fa fa-check-circle active"></i></a></td>
|
||||
<td *ngIf="us.isactive ==1" style="text-align: center;"><a class="active" (click)="isactive(us.userid,us.aws_name)"><mat-icon>done</mat-icon></a></td>
|
||||
|
||||
<td *ngIf="us.isactive ==0" style="text-align: center;"><a (click)="isactive(us.userid,us.aws_name)"><i class="fa fa-times-circle deactive"></i></a></td>
|
||||
<td *ngIf="us.isactive ==0" style="text-align: center;"><a class="deactive" (click)="isactive(us.userid,us.aws_name)"><mat-icon>close</mat-icon></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
@ -6,12 +6,20 @@ table {
|
||||
text-align: left;
|
||||
}
|
||||
.active{
|
||||
padding-left: 6px;
|
||||
|
||||
color: green;
|
||||
font-size: 20px;
|
||||
}
|
||||
.active:hover{
|
||||
color:red;
|
||||
font-size:25px;
|
||||
}
|
||||
.deactive{
|
||||
padding-left: 6px;
|
||||
|
||||
color: red;
|
||||
font-size: 20px;
|
||||
}
|
||||
.deactive:hover{
|
||||
color: green;
|
||||
font-size: 25px;
|
||||
}
|
||||
@ -13,13 +13,17 @@ export class UserListComponent implements OnInit {
|
||||
|
||||
userdata: any = [];
|
||||
loader: boolean = false;
|
||||
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
|
||||
constructor(public aws: AwsService, public route: Router, public shared: SharedService) { }
|
||||
|
||||
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.getusers();
|
||||
delete this.aws.localUserId;
|
||||
}
|
||||
|
||||
getusers() {
|
||||
@ -32,18 +36,18 @@ export class UserListComponent implements OnInit {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
isactive(id, awsname) {
|
||||
let userstatus = this.userdata.filter((users) => users.userid == id)[0];
|
||||
if (userstatus.isactive == 1) {
|
||||
this.aws.admindisabelUser(userstatus, awsname).subscribe(res => {
|
||||
if (res == 0) {
|
||||
let users = {
|
||||
'records': {
|
||||
|
||||
'userid': userstatus.userid,
|
||||
'isactive': '0',
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.aws.adminupendis(users).subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.shared.redirectTo(this.route.url);
|
||||
@ -57,11 +61,11 @@ export class UserListComponent implements OnInit {
|
||||
console.log(res);
|
||||
if (res == 1) {
|
||||
let users = {
|
||||
'records': {
|
||||
'userid': userstatus.userid,
|
||||
'userid': userstatus.userid,
|
||||
'isactive': '1',
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.aws.adminupendis(users).subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.shared.redirectTo(this.route.url);
|
||||
@ -79,8 +83,7 @@ export class UserListComponent implements OnInit {
|
||||
this.route.navigate(['settings/userRegister']);
|
||||
});
|
||||
}
|
||||
|
||||
addRegister(){
|
||||
add(){
|
||||
this.route.navigate(['settings/userRegister']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AuthenticationDetails, CognitoUser, CognitoUserPool } from 'amazon-cognito-identity-js';
|
||||
import { Router } from "@angular/router";
|
||||
import { Router, CanActivate, CanActivateChild } from "@angular/router";
|
||||
import * as aws from 'aws-sdk';
|
||||
import { Http, Headers, RequestOptions } from '@angular/http';
|
||||
import { of } from 'rxjs';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { BooleanNullable } from 'aws-sdk/clients/glue';
|
||||
let apiUrl = 'http://localhost/sparqapi/api/'
|
||||
let currentuser: any = window.localStorage.getItem("Currentuser");
|
||||
console.log(currentuser);
|
||||
@ -10,23 +13,14 @@ let poolData: any;
|
||||
|
||||
let userPool: any;
|
||||
|
||||
if (currentuser != '' && currentuser != null && currentuser == 1) {
|
||||
//if (currentuser != '' && currentuser != null && currentuser == 1) {
|
||||
poolData = {
|
||||
UserPoolId: 'ap-south-1_qQ85yQZJO', // Your user pool id here
|
||||
ClientId: '2o5c3cs9k3als16nqhp3irh8rs' // Your client id here
|
||||
};
|
||||
|
||||
} else if (currentuser != '' && currentuser != null && currentuser == 2) {
|
||||
poolData = {
|
||||
UserPoolId: "ap-south-1_hFiGyr1Gw", // Your user pool id here
|
||||
ClientId: "6egsdssf0i7h2o9mscqgqbn788" // Your client id here
|
||||
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
console.log(poolData);
|
||||
//console.log(poolData);
|
||||
|
||||
if (poolData !== undefined) {
|
||||
userPool = new CognitoUserPool(poolData);
|
||||
@ -34,19 +28,40 @@ if (poolData !== undefined) {
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SharedService {
|
||||
export class SharedService implements CanActivateChild {
|
||||
cognitoUser: any;
|
||||
jwttoken: any;
|
||||
constructor(public route: Router,public http:Http) {
|
||||
|
||||
|
||||
if (this.getAuthenticatedUser() !== '' && this.getAuthenticatedUser() !== undefined) {
|
||||
this.route.navigate(['/home']);
|
||||
} else {
|
||||
this.route.navigate(['/']);
|
||||
}
|
||||
|
||||
// canActivate() {
|
||||
// if(this.getroutersession()){
|
||||
// // alert('session valid')
|
||||
// return true;
|
||||
// }else{
|
||||
// this
|
||||
// alert('session valid timeout');
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
canActivateChild(){
|
||||
if(this.getroutersession()){
|
||||
//alert('session valid')
|
||||
return true;
|
||||
}else{
|
||||
this.route.navigate(['/authentication/login']);
|
||||
//alert('session valid timeout');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
constructor(public route: Router,public http:Http) {
|
||||
this.route.navigate([this.route.url]);
|
||||
|
||||
// if (this.getAuthenticatedUser() !== '' && this.getAuthenticatedUser() !== undefined) {
|
||||
// this.route.navigate(['/home']);
|
||||
// } else {
|
||||
// this.route.navigate(['/']);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* refresh session function
|
||||
@ -72,37 +87,83 @@ export class SharedService {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
getheaderssession() {
|
||||
getroutersession(): any {
|
||||
// gets the current user from the local storage
|
||||
if (userPool !== undefined) {
|
||||
this.cognitoUser = userPool.getCurrentUser();
|
||||
console.log(this.cognitoUser);
|
||||
}
|
||||
let jwttoken = '';
|
||||
let session = '';
|
||||
//let sessions = '';
|
||||
|
||||
let jwttoken:boolean = false;
|
||||
let session = "";
|
||||
if (this.cognitoUser != null) {
|
||||
this.cognitoUser.getSession(function (err, session) {
|
||||
if (err) {
|
||||
alert(err.message || JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
console.log('session validity: ' + session.isValid());
|
||||
jwttoken = session;
|
||||
if(session.isValid()){
|
||||
jwttoken = true;
|
||||
}else{
|
||||
jwttoken = false;
|
||||
}
|
||||
////(jwttoken);
|
||||
|
||||
});
|
||||
//console.log()
|
||||
|
||||
////()
|
||||
|
||||
|
||||
|
||||
return jwttoken;
|
||||
}
|
||||
}
|
||||
|
||||
getheaderssession() {
|
||||
if (userPool !== undefined) {
|
||||
this.cognitoUser = userPool.getCurrentUser();
|
||||
console.log(this.cognitoUser);
|
||||
}
|
||||
let jwttoken:any = '';
|
||||
let sesvalid = '';
|
||||
if (this.cognitoUser != null) {
|
||||
this.cognitoUser.getSession(function (err, session) {
|
||||
|
||||
if (err) {
|
||||
alert(err.message || JSON.stringify(err));
|
||||
return;
|
||||
}else{
|
||||
console.log("else");
|
||||
jwttoken = session;
|
||||
|
||||
}
|
||||
// if(session.isValid()){
|
||||
|
||||
|
||||
// jwttoken = session;
|
||||
// }else{
|
||||
// alert("session valid timeout");
|
||||
// }
|
||||
});
|
||||
//console.log(jwttoken.isValid());
|
||||
|
||||
return jwttoken;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
headercofig(customeData){
|
||||
let session:any = this.getheaderssession() ||"";
|
||||
let session:any = this.getheaderssession() || null;
|
||||
|
||||
let headers = new Headers(
|
||||
let headers:any
|
||||
if(session !=null){
|
||||
headers = new Headers(
|
||||
{
|
||||
'Content-Type':'application/json','Authorization':'sparqvenba2018','Token':session.getIdToken().getJwtToken()
|
||||
});
|
||||
}else{
|
||||
//alert('token not attached');
|
||||
this.redirectTo(this.route.url);
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
@ -118,10 +179,10 @@ export class SharedService {
|
||||
* Get Roles
|
||||
*/
|
||||
getroles(){
|
||||
let cogusers:any = this.getheaderssession() ||"";
|
||||
let cogusers:any = this.getheaderssession();
|
||||
console.log(cogusers.idToken.payload.locale);
|
||||
let roles = {'userid':cogusers.idToken.payload.locale};
|
||||
let headers = this.headercofig('');
|
||||
return this.http.post(apiUrl+'getUsersDetails',roles,{headers:headers}).map(res=>res.json());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,9 +64,9 @@ const MENUITEMS : Menu[] = [
|
||||
type:'sub',
|
||||
icon:'settings',
|
||||
children:[
|
||||
{state:'userRegister',name:'User Register'},
|
||||
{state: 'masters',name:'Master Details'},
|
||||
{state:'userListing',name:'User Listing'},
|
||||
{state: 'masters',name:'Master Details'}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@ -26,14 +26,16 @@
|
||||
<img src="../../../assets/images/test3.jpg" width="200" height="200" alt="user">
|
||||
</div>
|
||||
<div class="profile-info">
|
||||
<h3 class="profile-name"><strong>Jane Doe</strong></h3>
|
||||
<span class="user-name">@JaneDoe</span>
|
||||
<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">
|
||||
CEO at @DoeCorp
|
||||
|
||||
</span>
|
||||
<span><i class="fa fa-map-marker"></i> San Jose,USA</span>
|
||||
<span><i class="fa fa-calendar"></i>Joined March 2009</span>
|
||||
<span><i class="fa fa-birthday-cake"></i>29 December,1978</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">
|
||||
@ -55,10 +57,14 @@
|
||||
</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 3, 2017</span>
|
||||
<p>Continued jobless claims at lowest level in more than 28 years</p>
|
||||
<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>
|
||||
|
||||
@ -3,6 +3,7 @@ import { AwsService } from '../../aws.service';
|
||||
import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material';
|
||||
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||
import { CustomValidators } from 'ng2-validation';
|
||||
import { SharedService } from '../../shared.service';
|
||||
@Component({
|
||||
selector: 'ms-user-profile',
|
||||
templateUrl:'./user-profile-component.html',
|
||||
@ -21,30 +22,36 @@ export class UserProfileComponent implements OnInit {
|
||||
right: ''
|
||||
}
|
||||
};
|
||||
constructor(public AWS:AwsService,public dialog: MatDialog) {}
|
||||
userDetails:any=[];
|
||||
constructor(public AWS:AwsService,public dialog: MatDialog,public shared:SharedService ) {}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.getuser();
|
||||
|
||||
|
||||
}
|
||||
|
||||
getuser(){
|
||||
console.log(this.AWS.getUser());
|
||||
//console.log(this.AWS.getUser());
|
||||
this.shared.getroles().subscribe(res=>{
|
||||
this.userDetails = res.records[0];
|
||||
});
|
||||
}
|
||||
changePassword(){
|
||||
let dialogRef = this.dialog.open(ChangePasswordDialog,this.config);
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
|
||||
console.log(result);
|
||||
if(result.confirmPassword !="" && result.newPassword !="" && result.oldPassword !=""){
|
||||
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);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user