Fairoj : Token Refresh problem resolved and new interceptor is implemented in the name of req-token.interceptor

This commit is contained in:
venbatechnologies@gmail.com 2019-11-25 14:49:52 +05:30
parent f74b2e83d0
commit e0aa385bbc
51 changed files with 240310 additions and 73 deletions

View File

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.sineedge.pdglender" version="0.0.9" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="com.sineedge.pdglender" version="0.0.10" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>PD Genie</name>
<description>info@pdgenie.com</description>
<author email="info@pdgenie.com" href="https://pdgenie.com">PD Genie</author>

View File

@ -64,7 +64,7 @@
"zone.js": "0.8.18"
},
"devDependencies": {
"@ionic/app-scripts": "^3.2.4",
"@ionic/app-scripts": "^3.1.11",
"typescript": "2.4.2"
},
"description": "An Ionic project",
@ -98,4 +98,4 @@
"android"
]
}
}
}

View File

@ -13,6 +13,8 @@ import {AppVersion} from '@ionic-native/app-version'
import { SalesPDlistPage } from '../pages/sales_pd/pages/sales-p-dlist/sales-p-dlist';
import { HomePage, Section3 } from '../pages/sales_pd/pages/home/home';
import { ConstantsProvider } from '../providers/constants/constants';
@Component({
templateUrl: 'app.html'
@ -28,7 +30,7 @@ export class MyApp {
pages: Array<{title: string,icon:any, method: any}>;
protected app_version: string;
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen,public aws:AwsServiceProvider,public shared:CognitoServiceProvider,public AWS:AwsServiceProvider,public alertCtrl:AlertController,private appVersionProvide:AppVersion,private events:Events) {
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen,public aws:AwsServiceProvider,public shared:CognitoServiceProvider,public AWS:AwsServiceProvider,public alertCtrl:AlertController,private appVersionProvide:AppVersion,private events:Events,private constant:ConstantsProvider) {
this.initializeApp();
this.changeDecision();
@ -113,8 +115,9 @@ export class MyApp {
{
this.userAccess = true;
this.userDetails = this.userDetails.records[0];
this.events.publish('len_user_name',this.userDetails)
localStorage.setItem("user_details",JSON.stringify( this.userDetails));
// if(this.userDetails.short_name == 'SMC'){
// if(this.userDetails.short_name == 'MWISE'){
// this.pages.splice(-1,1)
// this.pages.push( { title :'Sales PD',icon:'list',method:()=>this.menulist(3)},
// { title: 'Logout', icon: 'md-exit',method:()=>this.menulist(2)})
@ -124,17 +127,26 @@ export class MyApp {
});
}
changeDecision(){
this.events.subscribe('len_short_name',(data)=>{
this.events.subscribe('len_user_name',(data)=>{
console.log("event data",data)
if(data == 'SMC'){
this.pages.splice(-1,1)
this.pages=this.pages.filter(ele=>ele.title != 'Sales PD')
this.pages.push( { title :'Sales PD',icon:'list',method:()=>this.menulist(3)},
{ title: 'Logout', icon: 'md-exit',method:()=>this.menulist(2)})
}
else{
this.pages=this.pages.filter(ele=>ele.title != 'Sales PD')
}
this.userDetails=data
this.userAccess=true;
// if(data == 'MWISE'){
// this.pages.splice(-1,1)
// this.pages=this.pages.filter(ele=>ele.title != 'Sales PD')
// this.pages.push( { title :'Sales PD',icon:'list',method:()=>this.menulist(3)},
// { title: 'Logout', icon: 'md-exit',method:()=>this.menulist(2)})
// }
// else{
// this.pages=this.pages.filter(ele=>ele.title != 'Sales PD')
// }
let role= this.constant.takeDecisionRouting(this.userDetails)
if(role == 'sales'){
this.pages[0].method=()=>this.menulist(3)
}
else{
this.pages[0].method=()=>this.menulist(1)
}
})
}
menulist(id){

View File

@ -79,6 +79,7 @@ import { HomePageModule } from '../pages/sales_pd/pages/home/home.module';
import { CameraProvider } from '../pages/sales_pd/providers/camera/camera';
import { SalesPDlistPage } from '../pages/sales_pd/pages/sales-p-dlist/sales-p-dlist';
import { LocationAccuracy } from '@ionic-native/location-accuracy';
import { ReqTokenInterceptor } from '../providers/_guard/req-token.interceptor';
@ -148,11 +149,11 @@ import { LocationAccuracy } from '@ionic-native/location-accuracy';
],
providers: [
StatusBar,AwsServiceProvider,AuthGuard,TokenInterceptor,ToastProvider,
StatusBar,AwsServiceProvider,AuthGuard,TokenInterceptor,ToastProvider,ReqTokenInterceptor,
ConstantsProvider,CognitoServiceProvider,SplashScreen,PdtriggerProvider,FingerprintAIO,
{
provide:HTTP_INTERCEPTORS,
useClass: TokenInterceptor,
useClass:ReqTokenInterceptor,
multi: true
},
{

View File

@ -10,6 +10,7 @@ import { AwsServiceProvider } from '../../providers/aws-service/aws-service';
import { LoadingProvider } from '../../providers/common-provider/loading';
import { ConstantsProvider } from '../../providers/constants/constants';
import { SalesPDlistPage } from '../sales_pd/pages/sales-p-dlist/sales-p-dlist';
/**
* Generated class for the AuthPage page.
*
@ -34,10 +35,10 @@ pin:any;
constructor(public navCtrl: NavController, public navParams: NavParams,public Menu:MenuController,public fb:FormBuilder,public shared:CognitoServiceProvider,public toast:ToastProvider,public faio:FingerprintAIO,public aws:AwsServiceProvider,public loadingCtrl:LoadingProvider,public commonconstant:ConstantsProvider) {
this.commonImage = this.commonconstant.commonimage;
this.shared.refresh();
this.getuserDetails();
console.log("entered")
this.shared.refresh()
this.getuserDetails();
}
@ -88,7 +89,22 @@ pin:any;
this.newpindetails = res;
if(this.newpindetails.dataStatus == true)
{
this.navCtrl.setRoot(PdListPage);
// let role_name=this.userDetails[0].role_name.toLowerCase()
// console.log("e",role_name)
// if(role_name.includes('sales')){
// this.navCtrl.setRoot(SalesPDlistPage);
// }
// else{
// this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
// }
let role=this.commonconstant.takeDecisionRouting(this.userDetails[0])
if(role == 'sales'){
this.navCtrl.setRoot(SalesPDlistPage);
}
else{
this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
}
// this.navCtrl.setRoot(PdListPage);
}
})
}
@ -100,7 +116,14 @@ pin:any;
{
if(this.userDetails[0].mpin == pin)
{
this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
let role=this.commonconstant.takeDecisionRouting(this.userDetails[0])
if(role == 'sales'){
this.navCtrl.setRoot(SalesPDlistPage);
}
else{
this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
}
}else
{
this.toast.lenderappmessage('Enter The Correct PIN');
@ -123,7 +146,15 @@ pin:any;
disableBackup:true,
})
.then((result: any) => {
console.log(this.userDetails);
let role_name=(this.userDetails[0].role_name).toLowerCase()
console.log("e",role_name)
if(role_name.includes('sales')){
this.navCtrl.setRoot(SalesPDlistPage);
}
else{
this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
}
})
.catch((error: any) => {
this.toast.lenderappmessage('err: '+ error);

View File

@ -1,5 +1,5 @@
import { Component,OnInit, ViewEncapsulation } from '@angular/core';
import { IonicPage, NavController, NavParams, MenuController,LoadingController } from 'ionic-angular';
import { IonicPage, NavController, NavParams, MenuController,LoadingController, Events } from 'ionic-angular';
import { AlertController } from 'ionic-angular';
// import {Validators, FormBuilder, FormGroup } from '@angular/forms';
// import { GridPage } from '../grid/grid';
@ -18,6 +18,8 @@ import { CognitoServiceProvider } from '../../providers/aws-service/cognito.serv
import { PdListPage } from '../pd-list/pd-list';
import { PasswordPage } from '../password/password';
import { ToastProvider } from '../../providers/common-provider/toast';
import { ConstantsProvider } from '../../providers/constants/constants';
import { SalesPDlistPage } from '../sales_pd/pages/sales-p-dlist/sales-p-dlist';
@Component({
@ -44,9 +46,10 @@ config: MatDialogConfig = {
right: ''
}
};
userDetails: any;
constructor( public aws: AwsServiceProvider, public dialog: MatDialog,
public shared:CognitoServiceProvider,public navCtrl:NavController,public Menu:MenuController
,public toast:ToastProvider,public load:LoadingController) {
,public toast:ToastProvider,public load:LoadingController,private events:Events,private constantProvider:ConstantsProvider) {
}
ngOnInit(){
@ -79,7 +82,8 @@ login() {
this.aws.dologin(auth).subscribe(awsres => {
this.presentLoading()
setTimeout(()=>{
this.navCtrl.setRoot(PdListPage);
this.getlenderpddetails()
// this.navCtrl.setRoot(PdListPage);
},1000)
@ -103,6 +107,30 @@ login() {
this.toast.lenderappmessage('Enter Email or Password');
}
}
getlenderpddetails()
{
let userid = this.aws.getlocale();
this.aws.getuserprofile(userid).subscribe(res=>
{
this.userDetails = res;
if(this.userDetails.dataStatus == true){
this.userDetails = this.userDetails.records[0];
localStorage.setItem("user_details",JSON.stringify( this.userDetails));
this.events.publish(('len_user_name'),this.userDetails);
let role= this.constantProvider.takeDecisionRouting(this.userDetails)
if(role == 'sales'){
this.navCtrl.setRoot(SalesPDlistPage);
}
else{
this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
}
// console.log('this.userDetails.records[0]',this.userDetails.records[0]);
};
});
}
/**
* New password set
* Defalut aws function

View File

@ -1,9 +1,10 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { IonicPage, NavController, NavParams, Events } from 'ionic-angular';
import { AwsServiceProvider } from '../../providers/aws-service/aws-service';
import { PdListPage } from '../pd-list/pd-list';
import { ToastProvider } from '../../providers/common-provider/toast';
import { ConstantsProvider } from '../../providers/constants/constants';
import { SalesPDlistPage } from '../sales_pd/pages/sales-p-dlist/sales-p-dlist';
/**
* Generated class for the PasswordPage page.
*
@ -23,7 +24,8 @@ export class PasswordPage {
pin:any;
Username:any;
Password:any;
constructor(public navCtrl: NavController, public navParams: NavParams,public aws:AwsServiceProvider,public commonconstant:ConstantsProvider,public toast:ToastProvider) {
userDetails: any;
constructor(public navCtrl: NavController, public navParams: NavParams,public aws:AwsServiceProvider,public commonconstant:ConstantsProvider,public toast:ToastProvider,private events:Events,private constantProvider:ConstantsProvider) {
this.commonImage = this.commonconstant.commonimage;
this.Username = this.navParams.get('Username');
this.Password = this.navParams.get('Password');
@ -39,7 +41,8 @@ export class PasswordPage {
console.log(auth);
this.aws.dologin(auth).subscribe(res => {
console.log(res);
this.navCtrl.setRoot(PdListPage);
// this.navCtrl.setRoot(PdListPage);
this.getlenderpddetails()
// this.router.navigate(['/home']);
}, err => {
this.toast.lenderappmessage(err.message);
@ -50,4 +53,29 @@ export class PasswordPage {
this.toast.lenderappmessage('Enter the new Password');
}
}
getlenderpddetails()
{
let userid = this.aws.getlocale();
this.aws.getuserprofile(userid).subscribe(res=>
{
this.userDetails = res;
if(this.userDetails.dataStatus == true){
this.userDetails = this.userDetails.records[0];
localStorage.setItem("user_details",JSON.stringify( this.userDetails));
this.events.publish(('len_user_name'),this.userDetails);
let role= this.constantProvider.takeDecisionRouting(this.userDetails)
if(role == 'sales'){
this.navCtrl.setRoot(SalesPDlistPage);
}
else{
this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
}
// console.log('this.userDetails.records[0]',this.userDetails.records[0]);
};
});
}
}

View File

@ -69,7 +69,7 @@ export class PdListPage {
if(this.userDetails.dataStatus == true){
this.userDetails = this.userDetails.records[0];
localStorage.setItem("user_details",JSON.stringify( this.userDetails));
this.events.publish('len_short_name',this.userDetails.short_name);
this.events.publish(('len_user_name'),this.userDetails);
// console.log('this.userDetails.records[0]',this.userDetails.records[0]);
this.pdofficer.getpddetails(this.userDetails.fk_entity_id,this.userDetails.userid).subscribe(res=>

View File

@ -10,10 +10,11 @@ import { BrowserModule } from '@angular/platform-browser';
import { IonicModule } from 'ionic-angular';
import { MyApp } from '../../../app/app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NumToWordsPipe } from '../../../pipes/num-to-words/num-to-words';
@NgModule({
declarations: [QuesTemplateComponent],
declarations: [QuesTemplateComponent,NumToWordsPipe],
imports: [MatButtonToggleModule,
BrowserModule,
IonicModule.forRoot(MyApp),

View File

@ -11,17 +11,24 @@
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '1'">
<mat-label>{{parent_ques.get('question').value}}</mat-label>
<input matInput [type]="parent_ques.get('field_type').value == 'num' ? 'number' : 'text'" formControlName="answer_value" placeholder="Enter the Text"
autocomplete="off">
<input matInput [type]="parent_ques.get('field_type').value == 'num' || parent_ques.get('field_type').value == 'numtoword' ? 'number' : parent_ques.get('field_type').value == 'string' ? 'text' : parent_ques.get('field_type').value" formControlName="answer_value"
[placeholder]="parent_ques.get('field_type').value == 'num' || parent_ques.get('field_type').value == 'numtoword' ? 'Entert the Number' : 'Enter the Text'"
autocomplete="off" (change)="onChangeProperty($event,parent_ques,p_i)">
<mat-hint *ngIf="parent_ques.get('answer_value').value != '' && parent_ques.get('field_type').value == 'numtoword'" align="end" style="font-size: 12px;">{{"&#8377;"}}{{parent_ques.get('answer_value').value | numToWords}}</mat-hint>
<!-- <mat-hint align="end" style="font-size: 11.5px;color: gray;" *ngIf="parent_ques.get('is_amt_in_words').value == true">One Lack</mat-hint> -->
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<!-- <mat-form-field> -->
<div class="radio-gap" *ngIf="parent_ques.get('type').value == '2'">
<mat-label>{{parent_ques.get('question').value}}</mat-label>
<mat-label>{{parent_ques.get('question').value}}</mat-label><br/>
<mat-radio-group aria-label="Select an option" formControlName="answer_value" (change)="onChangeProperty($event,parent_ques)">
<mat-radio-button class="radio-btn-gap" *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-radio-button><br />
</mat-radio-group>
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</div>
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '3'">
@ -29,12 +36,18 @@
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques,p_i)">
<mat-option *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
</mat-select>
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<div class="radio-gap" formArrayName="answer_value" *ngIf="parent_ques.get('type').value == '5'">
<mat-label>{{parent_ques.get('question').value}}</mat-label>
<mat-checkbox class="radio-btn-gap" *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer" (change)="onChange_checkbox($event,parent_ques)">{{val.answer}}</mat-checkbox><br />
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</div>
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '4'">
@ -42,7 +55,10 @@
<mat-select multiple formControlName="answer_value" >
<mat-option *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
</mat-select>
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<div *ngIf="parent_ques.get('type').value == '6'">
@ -70,7 +86,10 @@
<mat-label>{{parent_ques.get('question').value}}</mat-label>
<textarea matInput type="text" rows="3" formControlName="answer_value" placeholder="Enter the Text"
autocomplete="off" ></textarea>
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '8'">
@ -87,7 +106,10 @@
<mat-option *ngFor="let val of fileredSearchValue.length > 0 ? fileredSearchValue[p_i] : parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
</mat-select>
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of parent_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="parent_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
</div>
@ -125,16 +147,24 @@
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '1'">
<mat-label>{{single_ques.get('question').value}}</mat-label>
<input matInput [type]="single_ques.get('field_type').value == 'num' ? 'number' : 'text'" formControlName="answer_value" placeholder="Enter the Text"
autocomplete="off">
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<input matInput [type]="single_ques.get('field_type').value == 'num' || single_ques.get('field_type').value == 'numtoword' ? 'number' : single_ques.get('field_type').value == 'string' ? 'text' : single_ques.get('field_type').value" formControlName="answer_value"
[placeholder]="single_ques.get('field_type').value == 'num' || single_ques.get('field_type').value == 'numtoword' ? 'Enter the Number' : 'Enter the Text'"
autocomplete="off" (change)="onChangeProperty($event,single_ques,group_ques,2,s_i)">
<mat-hint *ngIf="single_ques.get('answer_value').value != '' && single_ques.get('field_type').value == 'numtoword'" align="end" style="font-size: 10px;">{{"&#8377;"}}{{single_ques.get('answer_value').value | numToWords}}</mat-hint>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<div class="radio-gap" *ngIf="single_ques.get('type').value == '2'">
<mat-label>{{single_ques.get('question').value}}</mat-label>
<mat-label>{{single_ques.get('question').value}}</mat-label><br/>
<mat-radio-group aria-label="Select an option" formControlName="answer_value" (change)="onChangeProperty($event,single_ques,group_ques,2)">
<mat-radio-button class="radio-btn-gap" *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-radio-button><br />
</mat-radio-group>
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</div>
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '3'">
@ -142,13 +172,18 @@
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,single_ques,group_ques,2)">
<mat-option *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
</mat-select>
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<div class="radio-gap" formArrayName="answer_value" *ngIf="single_ques.get('type').value == '5'">
<mat-label>{{single_ques.get('question').value}}</mat-label>
<mat-checkbox class="radio-btn-gap" *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer" (change)="onChange_checkbox($event,single_ques)">{{val.answer}}</mat-checkbox><br />
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</div>
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '4'">
@ -156,14 +191,20 @@
<mat-select multiple formControlName="answer_value">
<mat-option *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
</mat-select>
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '7'">
<mat-label>{{single_ques.get('question').value}}</mat-label>
<textarea matInput type="text" rows="3" formControlName="answer_value" placeholder="Enter the Text"
autocomplete="off" ></textarea>
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '8'">
@ -180,7 +221,10 @@
<mat-option *ngFor="let val of fileredSearchValue.length > 0 ? fileredSearchValue[p_i] : parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
</mat-select>
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
<!-- <mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error> -->
<ng-container *ngFor="let validation of single_ques.get('validations').value;" ngProjectAs="mat-error">
<mat-error align="end" *ngIf="single_ques.get('answer_value').hasError(validation.name.toLowerCase())">{{validation.message}}</mat-error>
</ng-container>
</mat-form-field>
<div *ngIf="single_ques.controls['subfield_key']">

View File

@ -1,4 +1,4 @@
import { Component, Input, EventEmitter, Output } from '@angular/core';
import { Component, Input, EventEmitter, Output, group } from '@angular/core';
import { FormGroup, FormArray, FormBuilder, FormControl } from '@angular/forms';
import { QuesServiceProvider } from '../../providers/ques-service/ques-service';
import { SalesPdProvider } from '../../providers/sales-pd/sales-pd';
@ -204,9 +204,10 @@ export class QuesTemplateComponent {
control.removeAt(i);
}
}
onChangeProperty(event,sec_control,group_ques,options?){
onChangeProperty(event,sec_control,group_ques,options?,sec_index?){
this.fileredSearchValue=[]
console.log(event,sec_control,this.quesAnsForm,group_ques);
if( sec_control.value.answers!= null && sec_control.value.answers.length > 0){
let curr_answer=sec_control.value.answers.filter(val=>val.answer == event.value && val.hasOwnProperty('subfield_key') && val.subfield_key != '' && val.subfield_caption != '')
if(curr_answer.length >0){
curr_answer=curr_answer[0]
@ -220,6 +221,7 @@ export class QuesTemplateComponent {
sec_control.removeControl('subfield_caption')
sec_control.removeControl('subfield_value')
}
}
//FOR API CALLS
if(sec_control.value.onchange_properties != null && sec_control.value.onchange_properties.length >0){
@ -275,10 +277,142 @@ export class QuesTemplateComponent {
})
}
}
else if(onChangeProperty.purpose == 'validations'){
console.log("op",options,onChangeProperty.validations)
if(options == 2){
this.setValidations_onChange(onChangeProperty,group_ques,sec_control,sec_index)
}
else{
this.setValidations_onChange(onChangeProperty,this.quesAnsForm,sec_control,sec_index)
}
}
})
}
}
setValidations_onChange(validation_obj_raw,group_ques,sec_control,sec_index){
console.log("onchange validations",group_ques,sec_control,validation_obj_raw)
if(validation_obj_raw.validations.length > 0){
validation_obj_raw.validations.forEach(validation_obj=>{
console.log("sing",validation_obj)
//FOR CHECKING THE EXPRESSION OR NORMAL VALIDATION
if(validation_obj.hasOwnProperty('value_keys')){
if( validation_obj.value_keys != null){
let expression_value=validation_obj.value
validation_obj.value_keys.forEach(res=>{
let validator_value_obj=group_ques.value.questions.filter(val=>val.question_key ==
res)[0]
if(validator_value_obj){
expression_value=expression_value.replace(res,validator_value_obj.answer_value)
}
})
console.log("validation_obj",expression_value)
// validation_obj.value=expression_value
validation_obj.validator=eval(expression_value)
console.log("c",validation_obj);
if(validation_obj.validator == false){
validation_obj.isactive='0'
// // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS
this.proceedValidationSet(validation_obj,group_ques,sec_index,'')
}
else{
validation_obj.isactive='1'
let validator_single=this.questionService.setValueForValidator(validation_obj)
console.log(validator_single)
// // MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS
this.proceedValidationSet(validation_obj,group_ques,sec_index,validator_single)
}
//END OF EXPRESSION CHECK
}
else{
// STARTING VALUE VALIDATION
let validator_value_obj
console.log("value key null");
validator_value_obj=group_ques.value.questions.filter(val=>val.question_key ==
validation_obj.value)[0]
console.log(validator_value_obj)
validation_obj.validator=validator_value_obj.answer_value
// let validator_single=this.questionService.setValueForValidator(validation_obj)
// console.log(validator_single)
// MAKING THE DECISION FOR SETTING THE VALIDATOR FOR CURRENT CONTROL OR OTHERS
this.proceedValidationSet(validation_obj,group_ques,sec_index,'')
// END OF VALUE VALIDATION
}
//
// }
// else{
// }
}
})
}
}
proceedValidationSet(validation_obj,group_ques,sec_index,validator_single?){
let ques_control;
if(validation_obj.validation_to == null){
console.log("entered");
ques_control=group_ques.controls.questions['controls'][sec_index]
console.log('im* im',validation_obj,validator_single);
// if(validation_obj.isactive == '1'){
// ques_control.controls.answer_value.setValidators(validator_single)
// ques_control.controls.answer_value.updateValueAndValidity()
// }
// else{
// ques_control.controls.answer_value.clearValidators()
// ques_control.controls.answer_value.updateValueAndValidity()
// }
// validation_obj.validator=validator_single
let new_validation_obj=this.updateValidationMsg(ques_control,validation_obj)
console.log("new validations obj",new_validation_obj)
this.questionService.settingArrayofValidators({validations:new_validation_obj},ques_control,sec_index)
}
else{
ques_control=group_ques.controls.questions['controls']
let other_control=ques_control.filter(val=>{
if(val.controls.question_key.value == validation_obj.validation_to){
return val
}
})[0]
// let updateMsg=other_control.value.validations.filter(val=>val.name != validation_obj.name)
// updateMsg.push(validation_obj)
console.log(other_control)
// other_control.controls.answer_value.setValidators(validator_single)
// if(validation_obj.isactive == '1'){
// other_control.controls.answer_value.setValidators(validator_single)
// other_control.controls.answer_value.updateValueAndValidity()
// }
// else{
// other_control.controls.answer_value.clearValidators()
// other_control.controls.answer_value.updateValueAndValidity()
// }
// other_control.controls.validations.setValue(updateMsg);
// validation_obj.validator=validator_single
let new_validations_obj=this.updateValidationMsg(other_control,validation_obj)
console.log("new validations obj",new_validations_obj,other_control)
this.questionService.settingArrayofValidators({validations:new_validations_obj},other_control,'')
}
}
updateValidationMsg(ques_control,validation_obj){
console.log("updae msg",ques_control,validation_obj);
let updateMsg=ques_control.value.validations.filter(val=>val.name != validation_obj.name)
updateMsg.push(validation_obj)
ques_control.controls.validations.setValue(updateMsg);
return updateMsg;
}
searchFun(control,index){
console.log(control,index);

View File

@ -21,9 +21,13 @@
<ion-content padding style="background:white">
<mat-card>
<mat-card-content>
<mat-card-content *ngIf="question_data.questions.length > 0">
<ques-template (emitter)="navigate($event)" [questions_JSON]="question_data"></ques-template>
<!-- <button ion-button (click)="onChange()"></button> -->
</mat-card-content>
<mat-card-content *ngIf="question_data.questions.length == 0">
<h5>No Templates Found</h5>
</mat-card-content>
</mat-card>
</ion-content>

View File

@ -64,6 +64,7 @@ export class Section1 {
// this.raw_data=this.SalesPDService.getData()
this.SalesPDService.getData(product_id).subscribe(result=>{
console.log("result",result)
if(result.hasOwnProperty('records')){
this.raw_data=JSON.parse(result['records'].template)
this.raw_data.sections.forEach((val,index)=>{
val.order_id=index+1
@ -78,7 +79,10 @@ export class Section1 {
console.log(this.all_sections)
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
console.log(this.question_data)
}
else{
}
})
}
@ -393,7 +397,7 @@ export class Section7 {
this.toastProvider.lenderappmessage("Saved Successfully..!");
setTimeout(()=>{
this.navCtrl.setRoot(SalesPDlistPage)
})
},2000)
}
}
@ -452,7 +456,7 @@ export class Section8 {
this.toastProvider.lenderappmessage("Saved Successfully..!");
setTimeout(()=>{
this.navCtrl.setRoot(SalesPDlistPage)
})
},2000)
}
}
@ -516,7 +520,7 @@ export class Section9 {
this.toastProvider.lenderappmessage("Saved Successfully..!");
setTimeout(()=>{
this.navCtrl.setRoot(SalesPDlistPage)
})
},2000)
}
}
// sendDatatoApi(){

View File

@ -43,6 +43,7 @@ export class QuesServiceProvider {
// let param
// val.api_properties.forEach(val=>param=val)
// console.log(param)
group_indi.raw_validations=group_indi.validations
sub_childControl.push(this.createValue(group_indi))
this.addAdditionalControl(group_indi,sub_childControl,arr_index)
// if(group_indi.type == '5'){
@ -96,6 +97,7 @@ export class QuesServiceProvider {
// let curr_object
// console.log("apikd",typeof(val.api_properties))
// if(val.api_properties != null && typeof(val.api_properties) == 'object'){
val.raw_validations=val.validations
control.push(this.createValue(val))
// for checkbox remove the form control and add the formarray for multiple values
this.addAdditionalControl(val,control,index)
@ -156,10 +158,12 @@ export class QuesServiceProvider {
// }
// }
return this._fb.group({
"answer_value":[{value:answer_value_loc,disabled:answer_value_loc != '' ? true : false},data.type != '6' ? Validators.compose([Validators.required]) : ''],
"answer_value":[{value:answer_value_loc,disabled:answer_value_loc != '' ? true : false}], // OLD VALIDATION >>>> data.type != '6' ? Validators.compose([Validators.required]) : ''
"question":[data.question],
"question_key":[data.question_key],
"type":[data.type],
"raw_validations":[data.raw_validations],
"validations":[data.raw_validations],
"api_properties":[data.api_properties],
"onchange_properties":[data.onchange_properties],
"answers":[data.answers],
@ -230,16 +234,107 @@ export class QuesServiceProvider {
return ''
}
addAdditionalControl(data,curr_control,curr_index){
//FOR CHECKBOX CHANGE THE VALUE STORAGE AS ARRAY
if(data.type == '5'){
curr_control.controls[curr_index].removeControl('answer_value');
curr_control.controls[curr_index].addControl('answer_value',this._fb.array([]))
}
//FOR numeric of string field
if(data.type == '1'){
curr_control.controls[curr_index].addControl('field_type',new FormControl(data.field_type))
}
//FOR SEARCHABLE FIELD VALUE KEY ()
if(data.type == '8'){
curr_control.controls[curr_index].addControl('select_search',new FormControl(data.field_type))
}
//FOR SETTING THE VALIDATORS
this.settingArrayofValidators(data,curr_control.controls[curr_index],curr_index)
}
settingArrayofValidators(data,curr_control,curr_index){
console.log("entered",data);
if(data.hasOwnProperty('validations') && data.validations.length > 0 ){
const validList :any= [];
let validator_value
data.validations=data.validations.filter(val=>val.isactive != '0')
data.validations.forEach(valid => {
if(valid.value != null && !valid.hasOwnProperty('validation_to')){
validator_value= this.getvalidatorValue(valid)
}
else{
validator_value=this.setValueForValidator(valid)
console.log("cc",validator_value)
}
validList.push(validator_value);
});
// console.log("valid",validList,curr_control)
// let val="Validators.required"
// console.log(typeof(Validators))
// console.log(typeof(`${val}`))
// let val1=`${val}`
// console.log(typeof(eval(val)))
// console.log(eval(val))
console.log(validList)
// curr_control.controls[curr_index].controls.answer_value.setValidators(validList)
curr_control.controls.answer_value.setValidators(validList)
console.log("ddvdeeqq",validList)
curr_control.controls.answer_value.updateValueAndValidity()
console.log("after setting validators",curr_control)
}
}
getvalidatorValue(value_obj){
if(value_obj != null && value_obj.hasOwnProperty('value')){
let value_of_validator
switch(value_obj.value){
case 'CURRENT_YEAR':
value_of_validator=new Date().getFullYear()
break;
default:
value_of_validator=''
break;
}
value_obj.validator=String(value_of_validator)
return this.setValueForValidator(value_obj)
}
}
setValueForValidator(value_obj){
console.log("setvlaue of validator",value_obj.validator,typeof(value_obj.validator))
let return_value
if(value_obj != null && value_obj.hasOwnProperty('validator')){
switch(value_obj.name)
{
case 'required':
return_value=Validators.required
break;
case 'minLength':
return_value=Validators.minLength(value_obj.validator)
break;
case 'maxLength':
return_value=Validators.maxLength(value_obj.validator)
break;
case 'min':
return_value=Validators.min(value_obj.validator)
break;
case 'max':
return_value=Validators.max(value_obj.validator)
break;
case 'pattern':
return_value=Validators.pattern(value_obj.validator)
break;
default:
return_value=''
break;
}
return return_value
}
else{
return false
}
}
}

View File

@ -0,0 +1,77 @@
import { Pipe, PipeTransform } from '@angular/core';
/**
* Generated class for the NumToWordsPipe pipe.
*
* See https://angular.io/api/core/Pipe for more info on Angular Pipes.
*/
@Pipe({
name: 'numToWords',
})
export class NumToWordsPipe implements PipeTransform {
/**
* Takes a value and makes it lowercase.
*/
a = [
'',
'one ',
'two ',
'three ',
'four ',
'five ',
'six ',
'seven ',
'eight ',
'nine ',
'ten ',
'eleven ',
'twelve ',
'thirteen ',
'fourteen ',
'fifteen ',
'sixteen ',
'seventeen ',
'eighteen ',
'nineteen '];
b = [
'',
'',
'twenty',
'thirty',
'forty',
'fifty',
'sixty',
'seventy',
'eighty',
'ninety'];
transform(value: string, ...args) {
if (value) {
let num: any = Number(value);
if (num) {
if ((num = num.toString()).length > 9) {
// return 'We are not the Iron Bank, you can lower down the stakes :)';
return ''
}
const n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
if (!n) {return ''; }
let str = '';
str += (Number(n[1]) !== 0) ? (this.a[Number(n[1])] || this.b[n[1][0]] + ' ' + this.a[n[1][1]]) + 'crore ' : '';
str += (Number(n[2]) !== 0) ? (this.a[Number(n[2])] || this.b[n[2][0]] + ' ' + this.a[n[2][1]]) + 'lakh ' : '';
str += (Number(n[3]) !== 0) ? (this.a[Number(n[3])] || this.b[n[3][0]] + ' ' + this.a[n[3][1]]) + 'thousand ' : '';
str += (Number(n[4]) !== 0) ? (this.a[Number(n[4])] || this.b[n[4][0]] + ' ' + this.a[n[4][1]]) + 'hundred ' : '';
str += (Number(n[5]) !== 0) ? ((str !== '') ? 'and ' : '') +
(this.a[Number(n[5])] || this.b[n[5][0]] + ' ' +
this.a[n[5][1]]) + 'rupee' : '';
// return str;
return str.charAt(0).toUpperCase() +
str.slice(1);
} else {
return '';
}
} else {
return '';
}
}
}

View File

@ -0,0 +1,8 @@
import { NgModule } from '@angular/core';
import { NumToWordsPipe } from './num-to-words/num-to-words';
@NgModule({
declarations: [],
imports: [],
exports: []
})
export class PipesModule {}

View File

@ -0,0 +1,160 @@
import { Injectable, Injector } from '@angular/core';
import {
HttpRequest,
HttpHandler,
HttpInterceptor,
HttpSentEvent,
HttpHeaderResponse,
HttpProgressEvent,
HttpResponse,
HttpUserEvent
} from '@angular/common/http';
// import { AuthGuard } from './auth.guard';
import { Observable, of, BehaviorSubject} from 'rxjs';
// import { Router } from '@angular/router';
import { catchError, switchMap } from 'rxjs/operators';
import { HttpErrorResponse } from "@angular/common/http";
import { CognitoServiceProvider } from '../aws-service/cognito.service';
import { ConstantsProvider } from '../constants/constants';
// import { Observable, EMPTY, throwError } from 'rxjs';
// import { catchError } from 'rxjs/operators';
import 'rxjs/add/operator/catch';
import { AwsServiceProvider } from '../aws-service/aws-service';
// const cognitoService=this.injector.get(CognitoServiceProvider)
// const constantProvider=this.injector.get(ConstantsProvider)
@Injectable()
export class ReqTokenInterceptor implements HttpInterceptor{
constructor(public injector:Injector ) {
}
isRefreshingToken: boolean = false;
tokenSubject: BehaviorSubject<string> = new BehaviorSubject<string>(null);
addToken(req: HttpRequest<any>, token: string): HttpRequest<any> {
const constantProvider = this.injector.get(ConstantsProvider)
return req.clone({
setHeaders: {
'Authorization': constantProvider.environment().authorization,
'Token': token,
'From': '2',
}
})
}
// addToken1(req: HttpRequest<any>, token: string): HttpRequest<any> {
// const constantProvider=this.injector.get(ConstantsProvider)
// console.log("Token 1",token,req);
// return req.clone({ setHeaders: {'Authorization': constantProvider.environment().authorization,
// 'Token':token,
// 'From':'2',
// }})
// }
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
const cognitoService=this.injector.get(CognitoServiceProvider)
let token=cognitoService.getToken()
console.log("Token From Interceptor >>",cognitoService.getToken())
if(token!=''){
token=token.getIdToken().getJwtToken()
}
return next.handle(this.addToken(req, token)).pipe(
catchError(error => {
if (error instanceof HttpErrorResponse) {
if((<HttpErrorResponse>error).status) {
return this.handle401Error(req,next,error)
}
} else {
console.log("observable error")
return Observable.throw(error);
}
}));
}
handle401Error(req: HttpRequest<any>, next: HttpHandler,err) {
console.log("err",err)
const cognitoService=this.injector.get(CognitoServiceProvider)
console.log("entered",this.isRefreshingToken,this.tokenSubject);
if (err instanceof HttpErrorResponse) {
if(err.status == 401 && err.error.error.toLowerCase() == 'invalid token!'){
if (!this.isRefreshingToken) {
this.isRefreshingToken = true;
// Reset here so that the following requests wait until the token
// comes back from the refreshToken call.
this.tokenSubject.next(null);
// return cognitoService.refresh()
// .subscribe((newToken: string) => {
// console.log("new",newToken)
// if (newToken) {
// this.tokenSubject.next( cognitoService.getToken().getIdToken().getJwtToken());
// console.log(this.tokenSubject);
// next.handle(this.addToken1(req, cognitoService.getToken().getIdToken().getJwtToken()));
// }
// // If we don't get a new token, we are in trouble so logout.
// const awsService=this.injector.get(AwsServiceProvider)
// awsService.logout();
// },err=>console.log("Error refresh",err))
return cognitoService.refresh().pipe(
switchMap((newToken: string) =>{
if(newToken){
this.isRefreshingToken=false
this.tokenSubject.next(newToken);
return next.handle(this.addToken(req, cognitoService.getToken().getIdToken().getJwtToken()))
}
const awsService=this.injector.get(AwsServiceProvider)
return awsService.logout();
})
)
// .catch(error => {
// // If there is an exception calling 'refreshToken', bad news so logout.
// return this.logoutUser();
// })
// .finally(() => {
// this.isRefreshingToken = false;
// });
} else {
console.log("Else Part 1201")
// return this.tokenSubject
// // .filter(token => token != null)
// .take(1)
// .switchMap(token => {
return next.handle(this.addToken(req, cognitoService.getToken().getIdToken().getJwtToken()));
// });
}
}
else{
this.handleError('Error From Token Interceptor',err);
}
}
else{
return Observable.throw("Observable throw",err);
}
}
private handleError<T> (operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
if(error instanceof HttpErrorResponse){
console.error("Error: " + error.status);
if(error.status == 401){
localStorage.clear();
// this.router.navigate(['/authentication/login']);
}
return of(result as T);
}
};
}
}

View File

@ -28,12 +28,21 @@ export class TokenInterceptor implements HttpInterceptor{
// Authorization: `${this.auth.getToken()}`
// }
// });
let token:any;
// return Observable.create(observer=>{
let token:any='';
let Authorization:string
let requests
const cognitoService=this.injector.get(CognitoServiceProvider)
cognitoService.refresh();
// cognitoService.refresh().subscribe(res=>{
cognitoService.refresh()
// console.log("res token",res)
token=cognitoService.getToken() || null
if(token != null){
token=token.getIdToken().getJwtToken();
}
// });
console.log("Token from interceptor >>>", token)
const constantProvider=this.injector.get(ConstantsProvider)
Authorization=constantProvider.environment().authorization
// this.shared.refresh();
@ -42,7 +51,7 @@ export class TokenInterceptor implements HttpInterceptor{
// token = token.getIdToken().getJwtToken();
//console.log(token);
let requests = request.clone({
requests = request.clone({
headers:new HttpHeaders({
'Authorization': Authorization,
@ -53,10 +62,33 @@ export class TokenInterceptor implements HttpInterceptor{
})
});
// })
return next.handle(requests).pipe(
catchError(this.handleError<any>('role', []))
catchError(
this.handleError<any>('role', []))
)
}
addAuthenticationToken(request) {
// Get access token from Local Storage
let token;
const cognitoService=this.injector.get(CognitoServiceProvider)
token=cognitoService.getToken() || null
token=token.getIdToken().getJwtToken();
// If access token is null this means that user is not logged in
// And we return the original request
if (!token) {
return request;
}
// We clone the request, because the original request is immutable
return request.clone({
setHeaders: {
Authorization: token
}
});
}
private handleError<T> (operation = 'operation', result?: T) {

View File

@ -174,7 +174,10 @@ apiurl:any;
getlocale(){
let session:any = this.shared.getToken() || null;
let userid = session.idToken.payload.locale;
let userid
if(session != null){
userid= session.idToken.payload.locale;
}
return userid;
}
getuserprofile(userid)

View File

@ -90,9 +90,9 @@ isloggin:boolean = false;
return this.loggedIn; // {2}
}
refresh() {
refresh() {
let tokenexp:boolean;
return Observable.create(observer=>{
if(this.getCurrentUser() !=null){
this.getCurrentUser().getSession(function (err, session) {
@ -111,14 +111,24 @@ refresh() {
console.log("CognitoUtil: refreshed but session is still not valid");
}
console.log("Else Part End");
}
observer.next(tokenexp)
observer.complete()
return tokenexp;
// resolve(tokenexp)
},err=>{
console.log("cognito refresh error",err)
});
}else{
console.log("Cognito refresh error getCurrentUser()")
this.loggedIn = false;
// return this.loggedIn
}
// })
})
}
getAccessToken(){
this.refresh();
@ -161,9 +171,11 @@ getToken():any {
if (err) {
// console.log("CognitoUtil: Can't set the credentials:" + err);
isloggin = false;
console.log("getToken Error",err)
//console.log('81 if')
}
else {
console.log("Session",session)
//alert('function else');
if (session.isValid()) {
console.log('85 else if');
@ -174,10 +186,12 @@ getToken():any {
isloggin = false;
}
}
},err=>{
console.log("Error in getToken",err);
});
}
else {
// console.log("else");
console.log("else logged in false in getCurrent token");
isloggin = false;
}
return jwttoken;

View File

@ -1,6 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
// app-scripts v:3.2.4
/*
Generated class for the ConstantsProvider provider.
@ -84,4 +85,15 @@ export class ConstantsProvider {
return returnDataVal
}
takeDecisionRouting(userDetails){
let role_name=userDetails.role_name.toLowerCase()
console.log("e",role_name)
if(role_name.includes('sales')){
return 'sales'
}
else{
// this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
return 'credit'
}
}
}

Binary file not shown.

View File

@ -0,0 +1,50 @@
// Ionicons Icon Font CSS
// --------------------------
// Ionicons CSS for Ionic's <ion-icon> element
// ionicons-icons.scss has the icons and their unicode characters
$ionicons-font-path: $font-path !default;
@import "ionicons-icons";
@import "ionicons-variables";
@font-face {
font-family: "Ionicons";
src: url("#{$ionicons-font-path}/ionicons.woff2?v=#{$ionicons-version}") format("woff2"),
url("#{$ionicons-font-path}/ionicons.woff?v=#{$ionicons-version}") format("woff"),
url("#{$ionicons-font-path}/ionicons.ttf?v=#{$ionicons-version}") format("truetype");
font-weight: normal;
font-style: normal;
}
ion-icon {
display: inline-block;
font-family: "Ionicons";
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-style: normal;
font-variant: normal;
font-weight: normal;
line-height: 1;
text-rendering: auto;
text-transform: none;
speak: none;
@include rtl() {
&[aria-label^="arrow"]::before,
&[flip-rtl]::before {
transform: scaleX(-1);
}
&[unflip-rtl]::before {
transform: scaleX(1);
}
}
&::before {
display: inline-block;
}
}

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 391 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,34 @@
// Noto Sans Font
// Google
// Apache License, version 2.0
// http://www.apache.org/licenses/LICENSE-2.0.html
$noto-sans-font-path: $font-path !default;
@font-face {
font-family: "Noto Sans";
font-style: normal;
font-weight: 300;
src: local("Noto Sans"), local("Noto-Sans-Regular"), url("#{$noto-sans-font-path}/noto-sans-regular.woff") format("woff"), url("#{$noto-sans-font-path}/noto-sans-regular.ttf") format("truetype");
}
@font-face {
font-family: "Noto Sans";
font-style: normal;
font-weight: 400;
src: local("Noto Sans"), local("Noto-Sans-Regular"), url("#{$noto-sans-font-path}/noto-sans-regular.woff") format("woff"), url("#{$noto-sans-font-path}/noto-sans-regular.ttf") format("truetype");
}
@font-face {
font-family: "Noto Sans";
font-style: normal;
font-weight: 500;
src: local("Noto Sans Bold"), local("Noto-Sans-Bold"), url("#{$noto-sans-font-path}/noto-sans-bold.woff") format("woff"), url("#{$noto-sans-font-path}/noto-sans-bold.ttf") format("truetype");
}
@font-face {
font-family: "Noto Sans";
font-style: normal;
font-weight: 700;
src: local("Noto Sans Bold"), local("Noto-Sans-Bold"), url("#{$noto-sans-font-path}/noto-sans-bold.woff") format("woff"), url("#{$noto-sans-font-path}/noto-sans-bold.ttf") format("truetype");
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,34 @@
// Roboto Font
// Google
// Apache License, version 2.0
// http://www.apache.org/licenses/LICENSE-2.0.html
$roboto-font-path: $font-path !default;
@font-face {
font-family: "Roboto";
font-style: normal;
font-weight: 300;
src: local("Roboto Light"), local("Roboto-Light"), url("#{$roboto-font-path}/roboto-light.woff2") format("woff2"), url("#{$roboto-font-path}/roboto-light.woff") format("woff"), url("#{$roboto-font-path}/roboto-light.ttf") format("truetype");
}
@font-face {
font-family: "Roboto";
font-style: normal;
font-weight: 400;
src: local("Roboto"), local("Roboto-Regular"), url("#{$roboto-font-path}/roboto-regular.woff2") format("woff2"), url("#{$roboto-font-path}/roboto-regular.woff") format("woff"), url("#{$roboto-font-path}/roboto-regular.ttf") format("truetype");
}
@font-face {
font-family: "Roboto";
font-style: normal;
font-weight: 500;
src: local("Roboto Medium"), local("Roboto-Medium"), url("#{$roboto-font-path}/roboto-medium.woff2") format("woff2"), url("#{$roboto-font-path}/roboto-medium.woff") format("woff"), url("#{$roboto-font-path}/roboto-medium.ttf") format("truetype");
}
@font-face {
font-family: "Roboto";
font-style: normal;
font-weight: 700;
src: local("Roboto Bold"), local("Roboto-Bold"), url("#{$roboto-font-path}/roboto-bold.woff2") format("woff2"), url("#{$roboto-font-path}/roboto-bold.woff") format("woff"), url("#{$roboto-font-path}/roboto-bold.ttf") format("truetype");
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
www/build/main.css.map Normal file
View File

@ -0,0 +1 @@
null

File diff suppressed because one or more lines are too long

1
www/build/main.js.map Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
www/build/vendor.js.map Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,6 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<script data-ionic="inject">
(function(w){var i=w.Ionic=w.Ionic||{};i.version='3.9.2';i.angular='5.0.3';i.staticDir='build/';})(window);
</script>
<meta charset="UTF-8">
<title>Ionic App</title>
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">