role access changes
This commit is contained in:
parent
fa5e372434
commit
f277b42c6f
@ -30,8 +30,11 @@ import { CognitoService } from './cognito.service';
|
||||
// };
|
||||
const sineedgedev_poolData = {
|
||||
UserPoolId: "ap-south-1_qQ85yQZJO", // UserName :SPARQ_SINEEDGE_DEV
|
||||
ClientId: "2o5c3cs9k3als16nqhp3irh8rs" // ClientName: SINEEDGE_DEV_WEB
|
||||
ClientId: "67b4fnbuols5upms5to8bvqddh"// ClientName: SINEEDGE_DEV_WEB
|
||||
}
|
||||
// client id changed on 12-04-2019 by kms
|
||||
//ClientId: "2o5c3cs9k3als16nqhp3irh8rs"
|
||||
|
||||
const lender_poolData = {
|
||||
UserPoolId: "ap-south-1_hFiGyr1Gw", // Username :SPARQ_LENDER_DEV
|
||||
ClientId: "6egsdssf0i7h2o9mscqgqbn788" // ClientName:LENDER_DEV_WEB
|
||||
@ -223,7 +226,6 @@ export class AwsService {
|
||||
//cognitosdata = 7;
|
||||
let params: any;
|
||||
if (userGroup == 'ADMIN') {
|
||||
console.log(userdata);
|
||||
if (userdata.fk_entity_type_id == 1) {
|
||||
params = {
|
||||
UserPoolId: sineedgedev_poolData.UserPoolId, /* required */
|
||||
@ -235,7 +237,6 @@ export class AwsService {
|
||||
Username: awsName /* required */
|
||||
};
|
||||
}
|
||||
console.log(params);
|
||||
return Observable.create(observe => {
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
cognitoidentityserviceprovider.adminDisableUser(params, function (err, data) {
|
||||
@ -254,7 +255,6 @@ export class AwsService {
|
||||
adminenableUser(userdata, awsName) {
|
||||
let session:any = this.shared.getAccessToken() || "";
|
||||
// this.getconfig();
|
||||
console.log(userdata);
|
||||
let config = "";
|
||||
AWS.config.region = "ap-south-1";
|
||||
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
|
||||
@ -284,7 +284,6 @@ export class AwsService {
|
||||
Username: awsName /* required */
|
||||
};
|
||||
}
|
||||
console.log(params);
|
||||
return Observable.create(observe => {
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
cognitoidentityserviceprovider.adminEnableUser(params, function (err, data) {
|
||||
@ -328,12 +327,14 @@ export class AwsService {
|
||||
{
|
||||
Name: "phone_number" /* required */,
|
||||
Value: "+91" + userData.phone
|
||||
},{
|
||||
Name: "custom:role_id" /* required */,
|
||||
Value: userData.role.role_id
|
||||
}
|
||||
/* more items */
|
||||
]
|
||||
};
|
||||
} else if (userData.type.entity_type_id == 2) {
|
||||
console.log(2);
|
||||
params = {
|
||||
UserPoolId: lender_poolData.UserPoolId /* required */,
|
||||
Username: userData.email /* required */,
|
||||
@ -352,6 +353,9 @@ export class AwsService {
|
||||
{
|
||||
Name: "phone_number" /* required */,
|
||||
Value: "+91" + userData.phone
|
||||
},{
|
||||
Name: "custom:role_id" /* required */,
|
||||
Value: userData.role.role_id
|
||||
}
|
||||
/* more items */
|
||||
]
|
||||
@ -375,12 +379,14 @@ export class AwsService {
|
||||
{
|
||||
Name: "phone_number" /* required */,
|
||||
Value: "+91" + userData.phone
|
||||
},{
|
||||
Name: "custom:role_id" /* required */,
|
||||
Value: userData.role.role_id
|
||||
}
|
||||
/* more items */
|
||||
]
|
||||
};
|
||||
}
|
||||
console.log(params);
|
||||
return Observable.create(observe => {
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
|
||||
@ -408,9 +414,6 @@ export class AwsService {
|
||||
|
||||
UserGroup(cognitodata, userData) {
|
||||
//console.log(cognitodata);
|
||||
|
||||
|
||||
console.log(userData);
|
||||
this.getconfig();
|
||||
//console.log(userData);
|
||||
//let cognitodata = "539bfefa-ae42-4bee-bf79-4b15d1a2af7f";
|
||||
@ -535,7 +538,7 @@ export class AwsService {
|
||||
|
||||
cognitoidentityserviceprovider.adminUpdateUserAttributes(params, function (err, data) {
|
||||
if (err) //(err, err.stack);
|
||||
console.log(data); // an error occurred
|
||||
//console.log(data); // an error occurred
|
||||
observe.next(data); // successful response
|
||||
});
|
||||
});
|
||||
@ -549,8 +552,6 @@ export class AwsService {
|
||||
}
|
||||
|
||||
adminchangeData(userData,changeusers){
|
||||
console.log(userData);
|
||||
console.log(changeusers);
|
||||
let session:any = this.shared.getAccessToken() || "";
|
||||
this.getconfig();
|
||||
let registeredData: any = "";
|
||||
@ -575,6 +576,10 @@ export class AwsService {
|
||||
{
|
||||
Name: "phone_number" /* required */,
|
||||
Value: "+91"+ changeusers.phone
|
||||
},
|
||||
{
|
||||
Name: "custom:role_id" /* required */,
|
||||
Value: userData.user_role
|
||||
}
|
||||
/* more items */
|
||||
]
|
||||
@ -592,6 +597,9 @@ export class AwsService {
|
||||
{
|
||||
Name: "phone_number" /* required */,
|
||||
Value: "+91" + changeusers.phone
|
||||
},{
|
||||
Name: "custom:role_id" /* required */,
|
||||
Value: userData.user_role
|
||||
}
|
||||
/* more items */
|
||||
]
|
||||
@ -610,12 +618,14 @@ export class AwsService {
|
||||
{
|
||||
Name: "phone_number" /* required */,
|
||||
Value: "+91" + changeusers.phone
|
||||
},{
|
||||
Name: "custom:role_id" /* required */,
|
||||
Value: userData.user_role
|
||||
}
|
||||
/* more items */
|
||||
]
|
||||
};
|
||||
}
|
||||
console.log(params);
|
||||
return Observable.create(observe=>{
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
cognitoidentityserviceprovider.adminUpdateUserAttributes(params, function(err, data) {
|
||||
@ -672,7 +682,7 @@ adminresetpassword(awsuser){
|
||||
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);
|
||||
else {
|
||||
observe.next(data);
|
||||
} // successful response
|
||||
});
|
||||
@ -681,7 +691,6 @@ adminresetpassword(awsuser){
|
||||
|
||||
changepassword(passData) {
|
||||
let session:any = this.shared.getAccessToken() || "";
|
||||
console.log(session);
|
||||
this.getconfig();
|
||||
var params = {
|
||||
AccessToken: session.accessToken.jwtToken, /* required */
|
||||
@ -692,7 +701,6 @@ changepassword(passData) {
|
||||
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
|
||||
});
|
||||
@ -717,7 +725,7 @@ admindelete(aws){
|
||||
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);
|
||||
else {
|
||||
observe.next(data);
|
||||
} // successful response
|
||||
});
|
||||
@ -743,7 +751,7 @@ adminlistgroup(enitiy){
|
||||
let cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
|
||||
cognitoidentityserviceprovider.listGroups(params,function(err,data){
|
||||
if(err) alert(err.stack);
|
||||
else {console.log(data);observe.next(data.Groups);}
|
||||
else {observe.next(data.Groups);}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ const sineedge_poolData = {
|
||||
};
|
||||
const sineedgedev_poolData = {
|
||||
UserPoolId: "ap-south-1_qQ85yQZJO", // UserName :SPARQ_SINEEDGE_DEV
|
||||
ClientId: "2o5c3cs9k3als16nqhp3irh8rs" // ClientName: SINEEDGE_DEV_WEB
|
||||
ClientId: "67b4fnbuols5upms5to8bvqddh" // ClientName: SINEEDGE_DEV_WEB
|
||||
}
|
||||
const lender_poolData = {
|
||||
UserPoolId: "ap-south-1_hFiGyr1Gw", // Username :SPARQ_LENDER_DEV
|
||||
@ -128,19 +128,15 @@ refresh() {
|
||||
let tokenexp:boolean;
|
||||
this.getCurrentUser().getSession(function (err, session) {
|
||||
if (err) {
|
||||
console.log("CognitoUtil: Can't set the credentials:" + err);
|
||||
}
|
||||
|
||||
else {
|
||||
if (session.isValid()) {
|
||||
tokenexp = session.isValid();
|
||||
of(tokenexp)
|
||||
console.log("CognitoUtil: refreshed successfully");
|
||||
|
||||
} else {
|
||||
tokenexp = session.isValid();
|
||||
console.log("CognitoUtil: refreshed but session is still not valid");
|
||||
|
||||
tokenexp = session.isValid();
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +152,6 @@ getAccessToken(){
|
||||
// console.log('76 if');
|
||||
this.getCurrentUser().getSession(function (err, session) {
|
||||
if (err) {
|
||||
console.log("CognitoUtil: Can't set the credentials:" + err);
|
||||
jwttoken ='';
|
||||
// console.log('81 if')
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ 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';
|
||||
import { RoleMenuItemsPipe } from './layouts/role-menu-items.pipe';
|
||||
export function HttpLoaderFactory(http: HttpClient) {
|
||||
return new TranslateHttpLoader(http);
|
||||
}
|
||||
@ -59,7 +60,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
|
||||
AppComponent,
|
||||
AdminLayoutComponent,
|
||||
AuthLayoutComponent,
|
||||
NewPasswordDialog,ForgotPass,ChangePasswordDialog,
|
||||
NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<mat-nav-list appAccordion class="navigation relative">
|
||||
<mat-list-item appAccordionLink *ngFor="let menuitem of menuItems.getAll()">
|
||||
<mat-list-item appAccordionLink *ngFor="let menuitem of menuItems.getAll() | roleMenuItems:'2'">
|
||||
<a appAccordionToggle class="relative" mat-ripple [routerLink]="['/', menuitem.state]" *ngIf="menuitem.type === 'link'">
|
||||
<mat-icon>{{ menuitem.icon }}</mat-icon>
|
||||
<span>{{ menuitem.name | translate }}</span>
|
||||
@ -118,13 +118,13 @@
|
||||
|
||||
<div fxFlex.sm="100" fxFlex.xs="100" fxFlex.md="33.33" fxFlex.lg="33.33" fxFlex.xl="33.33" fxFlex="100">
|
||||
<div class="menu-links">
|
||||
<span *ngFor="let menuitem of horizontalMenuItems.getAll()">
|
||||
<span *ngFor="let menuitem of horizontalMenuItems.getAll() | roleMenuItems:'1'">
|
||||
<button mat-icon-button matTooltip="{{ menuitem.name}}" matTooltipPosition="below" [routerLink]="['/'+menuitem.state]" *ngIf="menuitem.type === 'link'">
|
||||
<mat-icon>{{ menuitem.icon }}</mat-icon>
|
||||
<!--<span>{{ menuitem.name | translate }}</span>-->
|
||||
</button>
|
||||
</span>
|
||||
<button [mat-menu-trigger-for]="multi" matTooltip="Settings" matTooltipPosition="below" mat-icon-button class="ml-xs">
|
||||
<button [mat-menu-trigger-for]="multi" matTooltip="Settings" matTooltipPosition="below" mat-icon-button class="ml-xs" *ngIf="userRoleType=='10'">
|
||||
<mat-icon>settings</mat-icon>
|
||||
</button>
|
||||
<mat-menu #multi="matMenu" class="opt-menu" x-position="before">
|
||||
|
||||
@ -12,10 +12,12 @@ PerfectScrollbarComponent, PerfectScrollbarDirective } from 'ngx-perfect-scrollb
|
||||
import { UserService } from '../../settings/service/user.service';
|
||||
import { DashboardService } from '../../dashboard/dashboard.service';
|
||||
import { AwsService } from '../../AwsService/aws.service';
|
||||
import { RoleMenuItemsPipe } from './../role-menu-items.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
templateUrl: './admin-layout.component.html'
|
||||
templateUrl: './admin-layout.component.html',
|
||||
providers: [RoleMenuItemsPipe],
|
||||
})
|
||||
export class AdminLayoutComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ -48,15 +50,16 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
|
||||
alertMsgTriggerType : any[];
|
||||
alertMsgAllocateType : any[];
|
||||
alertCount: any;
|
||||
|
||||
userRoleType: String;
|
||||
constructor(private router: Router, public menuItems: MenuItems, public horizontalMenuItems : HorizontalMenuItems, public translate: TranslateService,public aws:AwsService,public users:UserService,private _dashboardService: DashboardService) {
|
||||
const browserLang: string = translate.getBrowserLang();
|
||||
translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
|
||||
this.users.getroles().subscribe(res=>{
|
||||
this.currentUser = res;
|
||||
this.currentUser = res;
|
||||
if(this.currentUser.dataStatus == true){
|
||||
|
||||
this.currentUser = this.currentUser.records[0];
|
||||
|
||||
this.fullName = this.currentUser.user_first_name +' '+this.currentUser.user_last_name;
|
||||
//console.log(this.currentUser);
|
||||
if(this.currentUser.fk_entity_type_id == 1 ){
|
||||
@ -102,6 +105,7 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userRoleType=localStorage.getItem('user_role');
|
||||
// console.clear();
|
||||
const elemSidebar = <HTMLElement>document.querySelector('.sidebar-container ');
|
||||
|
||||
@ -140,6 +144,7 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
|
||||
|
||||
ngOnDestroy() {
|
||||
this._router.unsubscribe();
|
||||
|
||||
}
|
||||
|
||||
isOver(): boolean {
|
||||
|
||||
8
ng6-seed/src/app/layouts/role-menu-items.pipe.spec.ts
Normal file
8
ng6-seed/src/app/layouts/role-menu-items.pipe.spec.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { RoleMenuItemsPipe } from './role-menu-items.pipe';
|
||||
|
||||
describe('RoleMenuItemsPipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new RoleMenuItemsPipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
||||
39
ng6-seed/src/app/layouts/role-menu-items.pipe.ts
Normal file
39
ng6-seed/src/app/layouts/role-menu-items.pipe.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'roleMenuItems'
|
||||
})
|
||||
export class RoleMenuItemsPipe implements PipeTransform {
|
||||
|
||||
transform(value: any, type: any): any {
|
||||
//this is for horizontal menu filter
|
||||
if(type=="1"){
|
||||
if(localStorage.getItem('user_role')=="10"){
|
||||
return value
|
||||
}
|
||||
else if(localStorage.getItem('user_role')=="6" || localStorage.getItem('user_role')=="7"){
|
||||
return value.filter(val=>val.state!="setting" && val.state!="personal_discussion")
|
||||
}
|
||||
else{
|
||||
return value.filter(val=>val.state!="setting" && val.state!="quality_check_discussion")
|
||||
}
|
||||
}
|
||||
//this is for vertical menu filter
|
||||
else if(type=="2"){
|
||||
if(localStorage.getItem('user_role')=="10"){
|
||||
return value
|
||||
}
|
||||
else if(localStorage.getItem('user_role')=="6" || localStorage.getItem('user_role')=="7"){
|
||||
return value.filter(val=>val.state!='' && val.state!="personal_discussion")
|
||||
}
|
||||
else{
|
||||
return value.filter(val=>val.state!='' && val.state!="quality_check_discussion")
|
||||
}
|
||||
}
|
||||
else{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,7 +8,7 @@
|
||||
</div>
|
||||
<div fxFlex="50" class="pb-0 text-sm-right">
|
||||
<button mat-fab (click)="viewMapPdDetails()" class="mr-1 mb-1 hover-icon" matTooltip="Map view" matTooltipPosition="above"><mat-icon>map</mat-icon></button>
|
||||
<button mat-fab (click)="addPdDetails()" class="mr-1 mb-1 hover-icon" matTooltip="Add PD" matTooltipPosition="above"><mat-icon>add</mat-icon></button>
|
||||
<button mat-fab (click)="addPdDetails()" class="mr-1 mb-1 hover-icon" matTooltip="Add PD" matTooltipPosition="above" *ngIf="roleAccessDetails.trigger"><mat-icon>add</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
<mat-card>
|
||||
|
||||
@ -36,10 +36,13 @@ export class ListPdComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(CompletedPdComponent) completedTabC: CompletedPdComponent;
|
||||
@ViewChild(QcCompletedPdComponent) qcCompletedTabC: QcCompletedPdComponent;
|
||||
|
||||
// roles checks for enables events
|
||||
roleAccessDetails:any
|
||||
|
||||
constructor( notifier: NotifierService, private route: ActivatedRoute,
|
||||
private router: Router, private _pd: PdTrigerService) {
|
||||
this.notifier = notifier;
|
||||
this.roleAccessDetails=this._pd.getRoleAccessDetails();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@ -36,8 +36,8 @@
|
||||
<span style="font-size: 13px;" >{{details.lender_full_name}} ({{details.lender_applicant_id}})</span><br>
|
||||
</div>
|
||||
<div fxFlex="45" style="text-align:right;" *ngIf="details.pd_status!=pdStatusCheck.DRAFT">
|
||||
<button mat-raised-button mat-button-sm mat-icon-button class="mr-1 hover-icon" type="button" matTooltip="PD Allocation" matTooltipPosition="above" (click)="pdAllocationTo(details)"><mat-icon>verified_user</mat-icon></button>
|
||||
<button mat-raised-button mat-button-sm mat-icon-button class=" hover-icon" type="button" matTooltip="Schedule" matTooltipPosition="above" (click)="scheduleDetails(details)"><mat-icon>schedule</mat-icon></button>
|
||||
<button mat-raised-button mat-button-sm mat-icon-button class="mr-1 hover-icon" type="button" matTooltip="PD Allocation" matTooltipPosition="above" (click)="pdAllocationTo(details)" *ngIf="roleAccessDetails.allocate"><mat-icon>verified_user</mat-icon></button>
|
||||
<button mat-raised-button mat-button-sm mat-icon-button class=" hover-icon" type="button" matTooltip="Schedule" matTooltipPosition="above" (click)="scheduleDetails(details)" *ngIf="roleAccessDetails.schedule"><mat-icon>schedule</mat-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-title>
|
||||
|
||||
@ -47,6 +47,8 @@ pdList:any[] = [];
|
||||
"COMPLETED" :'COMPLETED',
|
||||
"QC_COMPLETED" :'QC_COMPLETED',
|
||||
};
|
||||
// roles checks for enables events
|
||||
roleAccessDetails:any
|
||||
public getColor(type: number): string{
|
||||
|
||||
return type == 1 ? "#009688" : "#673ab7" ;
|
||||
@ -54,7 +56,8 @@ pdList:any[] = [];
|
||||
|
||||
constructor(notifier:NotifierService,private route: ActivatedRoute,
|
||||
private router: Router,private _pd: PdTrigerService,private dialog: MatDialog,private _geolocation: GetGeometricLocationService, private ListPdComponent : ListPdComponent) {
|
||||
this.notifier=notifier
|
||||
this.notifier=notifier;
|
||||
this.roleAccessDetails=this._pd.getRoleAccessDetails();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@ -79,6 +79,10 @@ export class ViewPdComponent implements OnInit, OnDestroy {
|
||||
|
||||
mandatoryFieldsValidations: any = [];
|
||||
|
||||
// roles checks for enables events
|
||||
roleAccessDetails:any;
|
||||
|
||||
|
||||
// @Input() childData: string;
|
||||
// @Output() loadParent = new EventEmitter<string>();
|
||||
public _EditPDtriggerForm: FormGroup;
|
||||
@ -86,6 +90,7 @@ export class ViewPdComponent implements OnInit, OnDestroy {
|
||||
private _pd: PdTrigerService, private route: ActivatedRoute, private router: Router, private ListPdComponent: ListPdComponent) {
|
||||
this.notifier = notifier;
|
||||
this.enableStartPD = false;
|
||||
this.roleAccessDetails=this._pd.getRoleAccessDetails();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@ -396,7 +401,6 @@ export class ViewPdComponent implements OnInit, OnDestroy {
|
||||
|
||||
let pdid = masterdetail.pd_id;
|
||||
let getValues = data.filter(val => val).map(Val => Val);
|
||||
console.log('getValues',getValues);
|
||||
this.FilteredFieldNames = getValues.map(x => {
|
||||
let findIndex = this.localMandatoryFields.map(val => val.backEnd_FieldName).indexOf(x);
|
||||
return this.localMandatoryFields[findIndex];
|
||||
|
||||
@ -624,6 +624,59 @@ export class PdTrigerService {
|
||||
catchError(this.handleError('operation', []))
|
||||
)
|
||||
}
|
||||
//set role access
|
||||
getRoleAccessDetails() {
|
||||
let setValues:any={};
|
||||
setValues.trigger=false;
|
||||
setValues.allocate=false;
|
||||
setValues.schedule=false;
|
||||
setValues.discussions=false;
|
||||
setValues.reports=false;
|
||||
function roleResult(value){
|
||||
switch (value) {
|
||||
//central manager
|
||||
case "1":
|
||||
setValues.reports=true;
|
||||
return setValues;
|
||||
// pd manager
|
||||
case "3":
|
||||
setValues.trigger=true;
|
||||
setValues.allocate=true;
|
||||
setValues.schedule=true;
|
||||
setValues.discussions=true;
|
||||
return setValues;
|
||||
// pd executive
|
||||
case "4":
|
||||
setValues.schedule=true;
|
||||
setValues.discussions=true;
|
||||
return setValues;
|
||||
// pd officer
|
||||
case "5":
|
||||
setValues.schedule=true;
|
||||
setValues.discussions=true;
|
||||
return setValues;
|
||||
// Admin
|
||||
case "10":
|
||||
setValues.trigger=true;
|
||||
setValues.allocate=true;
|
||||
setValues.schedule=true;
|
||||
setValues.discussions=true;
|
||||
setValues.reports=true;
|
||||
return setValues;
|
||||
default:
|
||||
setValues.trigger=false;
|
||||
setValues.allocate=false;
|
||||
setValues.schedule=false;
|
||||
setValues.discussions=false;
|
||||
setValues.reports=false;
|
||||
return setValues;
|
||||
}
|
||||
}
|
||||
|
||||
let result = roleResult(localStorage.getItem('user_role'));
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -56,18 +56,15 @@ export class LoginComponent implements OnInit{
|
||||
login() {
|
||||
let auth = { 'Username': this.email, 'Password': this.password };
|
||||
this.aws.dologin(auth).subscribe(res => {
|
||||
console.log(res);
|
||||
if (res !== undefined) {
|
||||
// local storage for validate user access
|
||||
localStorage.setItem('user_role',res.idToken.payload["custom:role_id"]);
|
||||
this.router.navigate(['/home']);
|
||||
console.log(this.shared.getToken());
|
||||
}
|
||||
}, err => {
|
||||
console.log(err.message);
|
||||
if (err.message == "New password is required.") {
|
||||
//console.log("if");
|
||||
this.newpassopen();
|
||||
} else {
|
||||
console.log("else");
|
||||
|
||||
}
|
||||
//alert(err.message);
|
||||
@ -83,9 +80,7 @@ export class LoginComponent implements OnInit{
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (result !== undefined) {
|
||||
let auth = { 'Username': this.email, 'Password': this.password, 'newpassword': result };
|
||||
console.log(auth);
|
||||
this.aws.dologin(auth).subscribe(res => {
|
||||
console.log(res);
|
||||
this.router.navigate(['/home']);
|
||||
}, err => {
|
||||
// alert(err.message);
|
||||
@ -102,9 +97,7 @@ export class LoginComponent implements OnInit{
|
||||
forgotpassword() {
|
||||
|
||||
let auth = { 'Username': this.email };
|
||||
console.log(auth);
|
||||
this.aws.userforgotpass(auth).subscribe(res => {
|
||||
console.log(res);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@ -129,9 +129,7 @@ export class UserService {
|
||||
if(users.userpic !=null && users.userpic !='' && users.userpic !==undefined){
|
||||
profilepic= users.userpic.name;
|
||||
}
|
||||
console.log(profilepic);
|
||||
let formData = new FormData();
|
||||
console.log(users);
|
||||
|
||||
|
||||
// let roles:any=[];
|
||||
@ -212,10 +210,8 @@ export class UserService {
|
||||
}
|
||||
|
||||
adminGetUsers(userId){
|
||||
console.log(userId);
|
||||
this.localUserId = userId;
|
||||
return Observable.create(observe=>{
|
||||
console.log(this.localUserId);
|
||||
observe.next(this.localUserId);
|
||||
})
|
||||
}
|
||||
|
||||
@ -62,7 +62,6 @@ export class RegisterComponent implements OnInit {
|
||||
private router: Router, public fb: FormBuilder, public AWS: AwsService, private cd: ChangeDetectorRef
|
||||
,private elementRef: ElementRef,public users:UserService) { }
|
||||
ngOnInit() {
|
||||
console.log(this.users.localUserId);
|
||||
if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined) {
|
||||
|
||||
} else {
|
||||
@ -188,7 +187,6 @@ export class RegisterComponent implements OnInit {
|
||||
//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) {
|
||||
if(userData.role.role_id == 10){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user