diff --git a/ng6-seed/src/app/app.module.ts b/ng6-seed/src/app/app.module.ts index baefec1..66606e1 100755 --- a/ng6-seed/src/app/app.module.ts +++ b/ng6-seed/src/app/app.module.ts @@ -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 { NewPasswordDialog2,ForgotPass2 } from './session/otp/otp.component'; +import { AutoLoginComponent } from './session/auto-login/auto-login.component'; import { AuthGuard } from './_guard/auth.guard'; import { RoleMenuItemsPipe } from './layouts/role-menu-items.pipe'; import { ResizableModule } from 'angular-resizable-element'; @@ -76,8 +77,8 @@ export function createTranslateLoader(http: HttpClient) { AuthLayoutComponent, NewPasswordDialog,ForgotPass,NewPasswordDialog2,ForgotPass2,ChangePasswordDialog, RoleMenuItemsPipe, HttpLoaderComponent, - DialogOverviewExampleDialog,OtpComponent - + DialogOverviewExampleDialog,OtpComponent, + AutoLoginComponent ], imports: [ BrowserModule, diff --git a/ng6-seed/src/app/app.routing.ts b/ng6-seed/src/app/app.routing.ts index 0a88f48..275769e 100755 --- a/ng6-seed/src/app/app.routing.ts +++ b/ng6-seed/src/app/app.routing.ts @@ -4,6 +4,7 @@ import { AdminLayoutComponent } from './layouts/admin/admin-layout.component'; import { AuthLayoutComponent } from './layouts/auth/auth-layout.component'; import { CognitoService} from './AwsService/cognito.service'; import { AuthGuard } from './_guard/auth.guard'; +import { AutoLoginComponent } from './session/auto-login/auto-login.component'; // import { SalesPdComponent } from './sales-pd/sales-pd.component'; // let role = localStorage.g('user_role'); // console.log(role) @@ -76,4 +77,4 @@ export const AppRoutes: Routes = [{ }, { path: '**', redirectTo: 'session/404' -}]; +}, { path: 'auto', component: AutoLoginComponent }]; diff --git a/ng6-seed/src/app/layouts/admin/admin-layout.component.html b/ng6-seed/src/app/layouts/admin/admin-layout.component.html index cd74f65..07b88af 100755 --- a/ng6-seed/src/app/layouts/admin/admin-layout.component.html +++ b/ng6-seed/src/app/layouts/admin/admin-layout.component.html @@ -210,10 +210,12 @@ settings Setting + + @@ -243,8 +248,8 @@ matTooltip="View" matTooltipPosition="top" >visibility
- +
@@ -254,6 +259,7 @@
+
diff --git a/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.ts b/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.ts index f43f1b4..909e8f2 100644 --- a/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.ts +++ b/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.ts @@ -13,19 +13,26 @@ import { environment } from 'environments/environment'; templateUrl: './sales-pd.component.html', styleUrls: ['./sales-pd.component.scss'] }) +export class SalesPdComponent implements OnInit { export class SalesPdComponent implements OnInit { public dataLengthTab4: number; public dataSourceTab4 = new MatTableDataSource(); displayedColumns = ['SalesPdId', 'SalesPdSno', 'Applicant Name', 'Short Name', 'Officer Name', 'status', 'Create On', 'Action']; + displayedColumns = ['SalesPdId', 'SalesPdSno', 'Applicant Name', 'Short Name', 'Officer Name', 'status', 'Create On', 'Action']; + @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; + // data source variable details + salesPdData: any[] = []; + salesPdpdf: any[] = []; // data source variable details salesPdData: any[] = []; salesPdpdf: any[] = []; + errorMessage: any[] = []; errorMessage: any[] = []; recordStatus: boolean; @@ -37,14 +44,21 @@ export class SalesPdComponent implements OnInit { pageSize = 10; pageEvent: PageEvent; todaydate: Date = new Date(); + todaydate: Date = new Date(); filter_drop_down_data: { product_ids: any[]; lender_ids: any[]; pd_status: any[]; }; limitMsg: boolean = false; common: any; user_type: string = ''; is_sales_login: boolean = false + user_type: string = ''; + is_sales_login: boolean = false public finallink: any; roleID: any; + loginTypeId: any; + local_spdid: string; + login_type_id: number; + constructor(private loaderService: LoaderService, private constantProvider: ConstantsProvider, private dialog: MatDialog, private route: ActivatedRoute, private router: Router, private _creditPdService: ApiServiceService, private SalesPDService: SalesPdService) { constructor(private loaderService: LoaderService, private constantProvider: ConstantsProvider, private dialog: MatDialog, private route: ActivatedRoute, private router: Router, private _creditPdService: ApiServiceService, private SalesPDService: SalesPdService) { // this.common = JSON.parse(localStorage.getItem('commonSettings')).default_pd_list_count; @@ -67,13 +81,17 @@ export class SalesPdComponent implements OnInit { } }, 4000) + setTimeout(() => { setTimeout(() => { this.common = JSON.parse(localStorage.getItem('commonSettings')) + if (this.common) { if (this.common) { this.common = this.common.default_pd_list_count; this.common = this.common.count + ' ' + this.common.factor + this.common = this.common.count + ' ' + this.common.factor } }, 300) + }, 300) // this.cameraProvider.checkGPSPermission(); // this.salesPDService.clearLocalData(); // setTimeout(()=>{ @@ -81,11 +99,20 @@ export class SalesPdComponent implements OnInit { // },100) + } + // this.salesPDService.clearLocalData(); + // setTimeout(()=>{ + // this.getListofPD() + // },100) + + } ngOnInit() { // this.getListofPD(); // this.salesPDpdf(); + this.local_spdid = localStorage.getItem("sales_pd_id_PRIMARYKEY"); + } @@ -102,18 +129,34 @@ export class SalesPdComponent implements OnInit { this.errorMessage.push(error); alert(error.html_format); }); + this.SalesPDService.uploadSalesDatatoCET(salespdid).subscribe(res => { + if (res['dataStatus']) { + let user1 = localStorage.getItem('user_details'); + let user = (JSON.parse(user1)) + this.roleID = localStorage.getItem('user_role') + alert(res['msg']); + } else { alert(res['msg']); } + }, error => { + this.errorMessage.push(error); + alert(error.html_format); + }); } getListofPD() { // this.SalesPDService.getSalesPDList() // .subscribe( // data => { // if (data.status == 200) { + this.SalesPDService.getSalesPDList(this.is_sales_login).subscribe(res => { + if (res['dataStatus']) { this.SalesPDService.getSalesPDList(this.is_sales_login).subscribe(res => { if (res['dataStatus']) { let user1 = localStorage.getItem('user_details'); let user = (JSON.parse(user1)) this.roleID = localStorage.getItem('user_role') + let user1 = localStorage.getItem('user_details'); + let user = (JSON.parse(user1)) + this.roleID = localStorage.getItem('user_role') this.salesPdData = res['records']; this.dataLengthTab4 = res['records'].length; @@ -193,8 +236,77 @@ export class SalesPdComponent implements OnInit { this.recordStatus = true; this.limitMsg = false } + } + // https://gstapp.smcfinance.com/home?saltkey=VQDa79tyBlpu7ZuKt6U&PDID=123&Email=manojsahrawat@smcfinance.com + //let link = "http://gstapp.devopsmcfinance.com/home?saltkey=VQDa79tyBlpu7ZuKt6U" + console.log(environment) + let link + if (environment.authorization == 'TnAwuc64pVpcB9xf') { + console.log('293') + link = "https://salesapp.smcfinance.com/app/secure?saltkey=VQDa79tyBlpu7ZuKt6U" + } else if (environment.authorization == 'sparqvenba2018') { + console.log('296') + link = "http://salesapp.devopsmcfinance.com/secure?saltkey=VQDa79tyBlpu7ZuKt6U" + } + + var string: any = { + EmpName: user.user_first_name, + EmpCode: "", + PDID: val.sales_pd_sno, + //PD_NO:val.sales_pd_sno, + } + //console.log(string); + //var encodedString = btoa(JSON.stringify(string)); + //console.log("encode",encodedString); // Outputs: "SGVsbG8gV29ybGQh" + //var decodedString = atob(encodedString); + //console.log("decode",JSON.parse(decodedString)); + //let email="mwisesales1@sine.com"; + let PDID = val.sales_pd_sno; + // let mail="&Email=manojsahrawat@smcfinance.com" + this.finallink = link + "&PDID=" + PDID + "&Email=" + user.email; + + console.log('this.finallink') + console.log(this.finallink); + val.link = this.finallink; + + if (products.length > 0) { + if (products.filter(pro => pro == val.product_id).length == 0) { + products.push(val.product_id) + } + } + else { + products.push(val.product_id) + } + if (lenders.length > 0) { + if (lenders.filter(pro => pro == val.lender_id).length == 0) { + lenders.push(val.lender_id) + } + } + else { + lenders.push(val.lender_id) + } + if (pd_status.length > 0) { + if (pd_status.filter(pro => pro == val.status).length == 0) { + pd_status.push(val.status) + } + } + else { + pd_status.push(val.status) + } + }) + this.filter_drop_down_data = { product_ids: products, lender_ids: lenders, pd_status: pd_status } + // console.log(this.filter_drop_down_data); + } + } + else { + this.salesPdData = []; + this.dataLengthTab4 = null; + this.recordStatus = true; + this.limitMsg = false + } } // , error => this.errorMessage = error); + , error => { , error => { this.errorMessage.push(error); // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); @@ -226,6 +338,25 @@ export class SalesPdComponent implements OnInit { // //}) // } + // editForm2(value_obj){ + // // let product= localStorage.getItem('product_id_salesPD') + // // storing the sales_pd_id and product id in local storagey + // let primary_key= 'sales_pd_id' + // if(value_obj.hasOwnProperty('local_pd_id') && value_obj.local_pd_id != null && value_obj.sales_pd_id == null && value_obj.hasOwnProperty('is_pd_synced') && value_obj.is_pd_synced == false) { + // primary_key = 'local_pd_id' + // } + // this.salesPDService.insertData_Replace('sales_pd_id_PRIMARYKEY',value_obj[primary_key]).then(()=>{ + // this.salesPDService.insertData_Replace('sales_rand_string',value_obj['rand_string']).then(()=>{ + // localStorage.setItem('product_id_salesPD',value_obj.product_id) + // if(!value_obj.hasOwnProperty('sales_pd_type')&& !value_obj.sales_pd_type) { + // value_obj.sales_pd_type = '1' + // } + // console.log(value_obj); + // localStorage.setItem('sales_pd_type',value_obj.sales_pd_type) + // this.navCtrl.push(SectionListPage,{product_id:value_obj.product_id,sales_pd_type:value_obj.sales_pd_type}) + // }) + // }) + // } // editForm2(value_obj){ // // let product= localStorage.getItem('product_id_salesPD') // // storing the sales_pd_id and product id in local storagey @@ -246,6 +377,22 @@ export class SalesPdComponent implements OnInit { // }) // } + editForm(value_obj) { + console.log(value_obj.sales_pd_id, value_obj.rand_string) + // alert('abc'); + console.log('value'); + console.log(value_obj); + let campletedCase = JSON.stringify(value_obj) + localStorage.setItem('completedPD', campletedCase) + // let product= localStorage.getItem('product_id_salesPD') + // storing the sales_pd_id and product id in local storagey + let primary_key = 'sales_pd_id' + if (value_obj.hasOwnProperty('local_pd_id') && value_obj.local_pd_id != null && value_obj.sales_pd_id == null && value_obj.hasOwnProperty('is_pd_synced') && value_obj.is_pd_synced == false) { + primary_key = 'local_pd_id' + } + console.log(value_obj[primary_key]) + localStorage.setItem('sales_pd_id_PRIMARYKEY', value_obj[primary_key]); + localStorage.setItem('sales_rand_string', value_obj.rand_string); editForm(value_obj) { console.log(value_obj.sales_pd_id, value_obj.rand_string) // alert('abc'); @@ -264,6 +411,7 @@ export class SalesPdComponent implements OnInit { localStorage.setItem('sales_rand_string', value_obj.rand_string); + // this.salesPDService.insertData_Replace('sales_pd_id_PRIMARYKEY',value_obj[primary_key]).then(()=>{ // this.salesPDService.insertData_Replace('sales_pd_id_PRIMARYKEY',value_obj[primary_key]).then(()=>{ //this.salesPDService.insertData_Replace('sales_rand_string',value_obj['rand_string']).then(()=>{ localStorage.setItem('product_id_salesPD', value_obj.product_id) @@ -292,6 +440,13 @@ export class SalesPdComponent implements OnInit { this.dataSourceTab4.data = this.salesPdData; this.recordStatus = false this.limitMsg = false + if (this.salesPdData.length > 0) { + let products = [] + let lenders = [] + let pd_status = [] + this.salesPdData.map(val => { + this.recordStatus = false + this.limitMsg = false if (this.salesPdData.length > 0) { let products = [] let lenders = [] @@ -330,35 +485,83 @@ export class SalesPdComponent implements OnInit { console.log(this.finallink); val.link = this.finallink; + if (products.length > 0) { + if (products.filter(pro => pro == val.product_id).length == 0) { + products.push(val.product_id) + // https://gstapp.smcfinance.com/home?saltkey=VQDa79tyBlpu7ZuKt6U&PDID=123&Email=manojsahrawat@smcfinance.com + //let link = "http://gstapp.devopsmcfinance.com/home?saltkey=VQDa79tyBlpu7ZuKt6U" + console.log(environment) + let link + if (environment.authorization == 'TnAwuc64pVpcB9xf') { + console.log('293') + link = "https://salesapp.smcfinance.com/app/secure?saltkey=VQDa79tyBlpu7ZuKt6U" + } else if (environment.authorization == 'sparqvenba2018') { + console.log('296') + link = "http://salesapp.devopsmcfinance.com/secure?saltkey=VQDa79tyBlpu7ZuKt6U" + } + + var string: any = { + EmpName: user.user_first_name, + EmpCode: "", + PDID: val.sales_pd_sno, + //PD_NO:val.sales_pd_sno, + } + //console.log(string); + //var encodedString = btoa(JSON.stringify(string)); + //console.log("encode",encodedString); // Outputs: "SGVsbG8gV29ybGQh" + //var decodedString = atob(encodedString); + //console.log("decode",JSON.parse(decodedString)); + //let email="mwisesales1@sine.com"; + let PDID = val.sales_pd_sno; + // let mail="&Email=manojsahrawat@smcfinance.com" + this.finallink = link + "&PDID=" + PDID + "&Email=" + user.email; + + console.log('this.finallink') + console.log(this.finallink); + val.link = this.finallink; + if (products.length > 0) { if (products.filter(pro => pro == val.product_id).length == 0) { products.push(val.product_id) } } + else { else { products.push(val.product_id) } + if (lenders.length > 0) { + if (lenders.filter(pro => pro == val.lender_id).length == 0) { if (lenders.length > 0) { if (lenders.filter(pro => pro == val.lender_id).length == 0) { lenders.push(val.lender_id) } } + else { else { lenders.push(val.lender_id) } + if (pd_status.length > 0) { + if (pd_status.filter(pro => pro == val.status).length == 0) { if (pd_status.length > 0) { if (pd_status.filter(pro => pro == val.status).length == 0) { pd_status.push(val.status) } } + else { else { pd_status.push(val.status) } }) this.filter_drop_down_data = { product_ids: products, lender_ids: lenders, pd_status: pd_status } + this.filter_drop_down_data = { product_ids: products, lender_ids: lenders, pd_status: pd_status } // console.log(this.filter_drop_down_data); } } + else { + this.salesPdData = []; + this.dataLengthTab4 = null; + this.recordStatus = true; + this.limitMsg = false else { this.salesPdData = []; this.dataLengthTab4 = null; @@ -366,7 +569,9 @@ export class SalesPdComponent implements OnInit { this.limitMsg = false } } + } + salesPDpdf(pdfdetail) { salesPDpdf(pdfdetail) { this.loaderService.showMatSpinnerDialog('Processing...') this.SalesPDService.getSalesPdpdf(pdfdetail) @@ -386,6 +591,22 @@ export class SalesPdComponent implements OnInit { // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); alert(error.html_format); }); + .subscribe( + data => { + if (data.status == 200) { + // window.location.href=res['records']; + window.open(data.records, '_blank'); + } + this.loaderService.closeMatSpinnerDialog() + + } + // , error => this.errorMessage = error); + , error => { + this.loaderService.closeMatSpinnerDialog() + this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + alert(error.html_format); + }); } pageChange(e) { @@ -402,12 +623,15 @@ export class SalesPdComponent implements OnInit { newcreditTrigger(curr_list_obj) { console.log(curr_list_obj); + const dialogRef = this.dialog.open(DialogOverviewExampleDialog, { width: '500px', data: curr_list_obj }); dialogRef.afterClosed().subscribe(result => { + console.log('The dialog was closed', result); + if (result) { console.log('The dialog was closed', result); if (result) { let new_credit_pd_info = curr_list_obj @@ -417,9 +641,11 @@ export class SalesPdComponent implements OnInit { new_credit_pd_info.smc_credit_pd = null this._creditPdService.curr_credit_pd_data = new_credit_pd_info this.router.navigate(['../credit_pd/pdQuestions']) + this.router.navigate(['../credit_pd/pdQuestions']) } }); } + newForm() { newForm() { // this.salesPDService.getData_fromLocal('sec1').then(result=>{ // console.log("image",result); @@ -432,7 +658,7 @@ export class SalesPdComponent implements OnInit { // }); // this.SalesPDService.clearLocalData() // this.SalesPDService.clear_local_key('sales_pd_id_PRIMARYKEY'); - localStorage.removeItem('sales_pd_id_PRIMARYKEY') + parseInt(localStorage.getItem('login_type_id')) == 0 ? localStorage.removeItem('sales_pd_id_PRIMARYKEY') : ''; localStorage.removeItem('product_id_salesPD') localStorage.removeItem('sales_pd_type') // this.navCtrl.push(HomePage) @@ -471,6 +697,7 @@ export class SalesPdComponent implements OnInit { minWidth: '30%', maxWidth: '40%', + }) dialogRef.afterClosed() .subscribe(dataresult => { @@ -478,6 +705,7 @@ export class SalesPdComponent implements OnInit { }) } + } @Component({ @@ -485,6 +713,12 @@ export class SalesPdComponent implements OnInit { templateUrl: 'trigger-confirm-dialog.html', }) export class DialogOverviewExampleDialog { + pd_type_list: any = [{ + id: "1", + dis_name: "Physical PD" + }, { + id: "2", + dis_name: "Telephonic PD" pd_type_list: any = [{ id: "1", dis_name: "Physical PD" @@ -493,16 +727,20 @@ export class DialogOverviewExampleDialog { dis_name: "Telephonic PD" }] choosedPD: any = null + choosedPD: any = null // notifier:NotifierService constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data) { // this.notifier=notifier } + // this.notifier=notifier + } onNoClick(): void { this.dialogRef.close(); } + onSubmit() { onSubmit() { console.log(this.choosedPD); if (this.choosedPD != '' && !this.choosedPD) { @@ -536,6 +774,34 @@ export class DialogOverviewExampleDialog { console.log('finallink'); console.log(finallink); window.open(finallink, '_system', 'location=yes'); + console.log("decode", JSON.parse(decodedString)); + let finallink = link + encodedString; + console.log('finallink'); + console.log(finallink); + window.open(finallink, '_system', 'location=yes'); } + // viewReport(){ + // const dialogRef = this.dialog.open(componen_name, { + // data: {data:this.raw_data,section_id:section_id}, + // // position: { right: '0'}, + // maxWidth: '100vw', + // maxHeight: '100vh', + // height: '100%', + // width: '100%', + // disableClose: true, + // closeOnNavigation:true, + // panelClass:'no-padding' + // }); + // dialogRef.afterClosed() + // .subscribe(dataresult => { + // // this.notifier.notify('success', 'Successfully allocated.!'); + // // if(dataresult == 'refresh') { + // // this.loadTemplates(this.product_id,2,this.sales_pd_type); + // // } + // }); + // } + + + } diff --git a/ng6-seed/src/app/sales-pd/section-list/section-list.component.ts b/ng6-seed/src/app/sales-pd/section-list/section-list.component.ts index ec585be..32ab40d 100644 --- a/ng6-seed/src/app/sales-pd/section-list/section-list.component.ts +++ b/ng6-seed/src/app/sales-pd/section-list/section-list.component.ts @@ -37,6 +37,8 @@ export class SectionListComponent implements OnInit { flyHiUserId: any; sales_pd_id_PRIMARYKEY: string; rand_string: string; + login_type_id: number; + constructor(public dialogRef: MatDialogRef,private constantProvider:ConstantsProvider,notifier: NotifierService,private dialog: MatDialog, private fb: FormBuilder, private route: ActivatedRoute,private SalesPDService:SalesPdService, private router: Router,private loaderService:LoaderService ) { @@ -48,6 +50,7 @@ export class SectionListComponent implements OnInit { this.sales_pd_type = localStorage.getItem('sales_pd_type') console.log( this.sales_pd_type) this.sales_pd_id_PRIMARYKEY = localStorage.getItem('sales_pd_id_PRIMARYKEY') + this.login_type_id = parseInt(localStorage.getItem('login_type_id')); } if(this.route.snapshot.params['product_id']){ @@ -297,8 +300,9 @@ export class SectionListComponent implements OnInit { merge_saved_status(res){ let saved_sections=res['records'].map(val=>{return {'section_id':val.section_id , 'status':val.status,'is_synced':val.is_synced}}); - - console.log("saved",saved_sections); + console.log("B4 saved",saved_sections); + saved_sections = saved_sections.filter(val=>parseInt(val.status) == 1); + console.log("After saved",saved_sections); const mergeById = (a1, a2) => a1.map(itm => ({ ...a2.find((item) => (item.section_id === itm.section_id) && item), diff --git a/ng6-seed/src/app/sales-pd/services/sales-pd.service.ts b/ng6-seed/src/app/sales-pd/services/sales-pd.service.ts index a7652cb..467a04c 100644 --- a/ng6-seed/src/app/sales-pd/services/sales-pd.service.ts +++ b/ng6-seed/src/app/sales-pd/services/sales-pd.service.ts @@ -159,7 +159,13 @@ saveQuestions(params): Observable{ let result_from_api:any; let userid:any=localStorage.getItem("user_details") userid=JSON.parse(userid).userid; - params.createdby=userid + + if(localStorage.getItem('login_type_id') == '1'){ //aout-login means + params.createdby = localStorage.getItem('officer_id'); + }else{ + params.createdby=userid + } + let product_id=localStorage.getItem('product_id_salesPD') let sales_pd_type = localStorage.getItem('sales_pd_type'); let users:any=localStorage.getItem('user_details') @@ -569,14 +575,19 @@ getCityPincode(value){ // console.log("Api Stauts ",this.networkProvider.getCurrentNetworkStatus()) let det:any=localStorage.getItem('user_details') - console.log('494',det,localStorage.getItem('user_details')) - det=JSON.parse(det) - console.log('494',det) + + let login_type_id = parseInt(localStorage.getItem('login_type_id')); // 1 na auto-login , 0 na manual-login + console.log('service call b4...',typeof det,det,localStorage.getItem('user_details')) + det=JSON.parse(det); + let user_id = (login_type_id == 1) ? localStorage.getItem('officer_id') : det.userid ; + let user_role_id = det.user_role; + console.log('service call after...',typeof det,det); let params = {'fk_entity_id':det.fk_entity_id,userid:det.userid} // if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) { let complete_url = api_url+'listSalesPD/'+det.fk_entity_id if(is_sales_login) { - complete_url = complete_url+'/'+det.userid+'/'+det.user_role + if(user_role_id != "") { complete_url = complete_url+'/'+user_id+'/'+det.user_role } + else if(user_role_id == "") { complete_url = complete_url+'/'+user_id} } return this._http.get(complete_url).map(res=>{ // this.ionicStorageProvider.checkAndInsertApiDataLocally(res,params,'listSalesPD'); diff --git a/ng6-seed/src/app/session/auto-login/auto-login.component.html b/ng6-seed/src/app/session/auto-login/auto-login.component.html new file mode 100644 index 0000000..39a1440 --- /dev/null +++ b/ng6-seed/src/app/session/auto-login/auto-login.component.html @@ -0,0 +1,3 @@ + diff --git a/ng6-seed/src/app/session/auto-login/auto-login.component.scss b/ng6-seed/src/app/session/auto-login/auto-login.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/ng6-seed/src/app/session/auto-login/auto-login.component.ts b/ng6-seed/src/app/session/auto-login/auto-login.component.ts new file mode 100644 index 0000000..bd78e6d --- /dev/null +++ b/ng6-seed/src/app/session/auto-login/auto-login.component.ts @@ -0,0 +1,185 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { Router } from "@angular/router"; +import { AwsService } from '../../AwsService/aws.service'; +import { DashboardService } from 'app/dashboard/dashboard.service'; +import { DatePipe } from '@angular/common'; +import { SalesPdService } from '../../sales-pd/services/sales-pd.service'; +import { UserService } from '../../settings/service/user.service'; + +@Component({ + selector: 'app-auto-login', + templateUrl: './auto-login.component.html', + styleUrls: ['./auto-login.component.scss'], + providers: [DatePipe] +}) +export class AutoLoginComponent implements OnInit { + + errorMessage: any; + salesPdData:any = []; + // currentUser: Object; + currentUser: any={short_name : ''}; + userDetails: any; + userDep: string; + fullName: string; + roleName: any; + profileurl: any; + + constructor(private router: Router,private route: ActivatedRoute,public aws: AwsService,private dashBoardService:DashboardService,public users:UserService,private salespdservice:SalesPdService) { } + + token: string; + password: string; + + + ngOnInit(): void { + + this.route.queryParams.subscribe(params => { + console.log(params); + this.token = params.token; + console.log('encrypted token :',this.token); + }); + // old http://localhost:4200/#/auto?token=bXdpc2VzYWxlczFAc2luZS5jb20jdGVzdDEyMzQ= + // new http://localhost:4200/#/auto?token=TXdpc2VTYWxlc0B5YWhvby5jb20jc2luZTEyMzQjMjkzIzE5 + + // error flag redirect pannanum + const decoded= this.decodeBase64String(this.token); + if (decoded !== null) { + console.log('decrypted token :', decoded); + const splitparts = decoded.split('#'); + const mailid = splitparts[0].split(/\s/).join(''); + const password = splitparts[1].split(/\s/).join(''); + const officer_id = splitparts[2].split(/\s/).join(''); + const role_id = splitparts[3].split(/\s/).join(''); + const date_timing = splitparts[4]; // for vaildation + const officer_mail_id = splitparts[5].split(/\s/).join(''); + const sales_pd_id = splitparts[6].split(/\s/).join(''); + + + console.log("splited Values are \n 1) UN :",mailid," \n 2) PWD :",password, " \n 3) OFFS ID : ",officer_id,"\n 4) ROLE ID : ",role_id,"\n 5) BE DATED :",date_timing,"\n 6) OFFS MAIL :",officer_mail_id," \n 7) SALES PD : ",sales_pd_id); + let today : Date = new Date(); + console.log(today); + + if(this.dateRangeValidator(date_timing,today)){ + console.log('Token vaild because within 24 Hrs ! So, permitted to log in'); + // http://localhost:4200/#/auto?token=TXdpc2VTYWxlc0B5YWhvby5jb20jc2luZTEyMzQjMjkzIzE5IzA0LzA3LzIwMjMgMTk6MzE6MTYjbXdpc2VzYWxlczFAc2luZS5jb20%3D + let auth = { 'Username': mailid, 'Password': password }; + this.aws.dologin(auth).subscribe(res => { + console.log("Auto login",res); + if (res !== undefined) { + localStorage.setItem('user_role',role_id); + localStorage.setItem('user_role_nav',role_id); + localStorage.setItem('login_type','auto-login'); + localStorage.setItem('login_type_id','1'); + localStorage.setItem('officer_id',officer_id); + localStorage.setItem('officer_mail_id',officer_mail_id); + // this.salesPdData = this.callingSalesPDListApi(sales_pd_id); + localStorage.setItem('sales_pd_id_PRIMARYKEY',sales_pd_id); + + + this.router.navigate(['/sales-pd-list']); + // localStorage.setItem('sales_pd_id_PRIMARYKEY',sales_pd_id); + } + }, err => { + this.router.navigate(['/auto?token='+this.token]); + console.log(err.message); + }) + console.log("AWS getlocale = ",this.aws.getlocale()); + } else { + alert('Token Expried'); + console.log('Token Not-vaild because 24 Hrs Expried'); + // Handle the decoding error + // this.router.navigate(['/']); + console.log('Due To Time Out.'); + } + return ; + }else { + // Handle the decoding error + // this.router.navigate(['/auto?token='+this.token]); + console.log('Error occurred while decoding the string.'); + } + return ; + } + + dateRangeValidator(fromDate,toDate){ + const inputDate = fromDate; + const [day, month, year, hour, minute, second] = inputDate.split(/[/: ]/); + + // Months in JavaScript are zero-indexed, so we need to subtract 1 from the month value + const jsMonth = parseInt(month, 10) - 1; + const date = new Date(parseInt(year, 10), jsMonth, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10)); + const angularDate = date.toString(); + + const from_Date = new Date(angularDate); + const to_Date = new Date(toDate); + console.log("Aftr Date ",from_Date," to ",to_Date); + + if (from_Date && to_Date) { + const timeDifference = to_Date.getTime() - from_Date.getTime(); + console.log('time Difference',timeDifference); + const hoursDifference = timeDifference / (1000 * 60 * 60); + console.log('hours Difference',hoursDifference); + if (hoursDifference <= 24) { + // The time duration is within 24 hours + console.log('Valid: Time duration is within 24 hours'); + return true; + } else { + // The time duration is more than 24 hours + console.log('Invalid: Time duration exceeds 24 hours'); + return false; + // http://localhost:4200/#/auto?token=TXdpc2VTYWxlc0B5YWhvby5jb20jc2luZTEyMzQjMjkzIzE5IzA3LzA3LzIwMjMgMTA6MDQ6NDkjbXdpc2VzYWxlczFAc2luZS5jb20jOTA2 + } + + }else{ + console.log('Invalid: Date Not Founded'); + return false; + } + } + + // dateRangeValidator(fromDate,toDate){ + // // Perform validation logic + // if (fromDate && toDate) { + // const fromDateTime = new Date(fromDate).getTime(); + // const toDateTime = new Date(toDate).getTime(); + // const twentyFourHours = 24 * 60 * 60 * 1000; // 24 hours in milliseconds + // // console.log('toDateTime - fromDateTime > twentyFourHours'); + // // console.log(toDateTime,'-',fromDateTime,'>',twentyFourHours); + // // console.log(toDateTime - fromDateTime > twentyFourHours); + // if (toDateTime - fromDateTime >= twentyFourHours) { + // return true; + // } + // else{ + // return true; + // } + // // Calculate the time difference in milliseconds + // // const diffInMilliseconds = Math.abs(toDateTime - fromDateTime); + // // const diffInHours = diffInMilliseconds / (1000 * 60 * 60); + // // Check if the difference is at least 24 hours if (diffInHours < 24) + // }else{ + // return false; + // } + // } + + decodeBase64String(encodedString) { + try { + const decodedString = atob(encodedString); + return decodedString; + } catch (error) { + // Handle the error + console.error('Failed to decode the base64 string:', error); + + // Return a default or error value, or perform any other error handling logic + return null; + } + } + + getCommonSettings(){ + this.dashBoardService.getCommonSettingsConfig().subscribe(res=>{ + if(res['dataStatus'] == true){ + localStorage.setItem("commonSettings",JSON.stringify(res['records'])); + } + }) + } + + + +} \ No newline at end of file diff --git a/ng6-seed/src/app/session/login/login.component.ts b/ng6-seed/src/app/session/login/login.component.ts index ab5f5a9..4db0006 100755 --- a/ng6-seed/src/app/session/login/login.component.ts +++ b/ng6-seed/src/app/session/login/login.component.ts @@ -16,7 +16,7 @@ import { CognitoService } from '../../AwsService/cognito.service'; import { DashboardService } from 'app/dashboard/dashboard.service'; import { LoaderService } from 'app/shared/loaderService/loader.service'; import { OtpComponent } from '../otp/otp.component'; - +import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'ms-login-session', @@ -47,9 +47,8 @@ export class LoginComponent implements OnInit{ dialogRef: MatDialogRef; hide: boolean; constructor( - private router: Router, public aws: AwsService, public dialog: MatDialog, + private router: Router, public aws: AwsService, public dialog: MatDialog,private route: ActivatedRoute, public shared:CognitoService,private dashBoardService:DashboardService , private loaderService:LoaderService) { - } ngOnInit(){ this.hide = true; @@ -82,6 +81,8 @@ export class LoginComponent implements OnInit{ // local storage for validate user access localStorage.setItem('user_role',res.idToken.payload["custom:role_id"]); localStorage.setItem('user_role_nav',res.idToken.payload["custom:role_id"]); + localStorage.setItem('login_type','manual-login'); + localStorage.setItem('login_type_id','0'); let role = localStorage.getItem('user_role'); console.log(res.idToken.payload ["custom:role_id"],role); // alert(localStorage.getItem('user_role')) @@ -115,6 +116,7 @@ export class LoginComponent implements OnInit{ this.loaderService.closeMatSpinnerDialog(); //alert(err.message); }) + // console.log("AWS getlocale = ",this.aws.getlocale()); } /** * New password set diff --git a/ng6-seed/src/app/shared/menu-items/horizontal-menu-items.ts b/ng6-seed/src/app/shared/menu-items/horizontal-menu-items.ts index 7c454f1..313e99b 100755 --- a/ng6-seed/src/app/shared/menu-items/horizontal-menu-items.ts +++ b/ng6-seed/src/app/shared/menu-items/horizontal-menu-items.ts @@ -108,6 +108,9 @@ export class HorizontalMenuItems { salesgetAll(): Menu[] { let filtered_sales_menu = salesmenu let user_type= localStorage.getItem('len_user_role') + if(parseInt(localStorage.getItem('login_type_id')) == 1){ + filtered_sales_menu = salesmenu.filter(vv=>vv.icon != 'work') + } // if(user_type != 'credit'){ // filtered_sales_menu = salesmenu.filter(vv=>vv.state != 'credit_pd') // } diff --git a/ng6-seed/src/app/shared/menu-items/menu-items.ts b/ng6-seed/src/app/shared/menu-items/menu-items.ts index 531a4eb..612a161 100755 --- a/ng6-seed/src/app/shared/menu-items/menu-items.ts +++ b/ng6-seed/src/app/shared/menu-items/menu-items.ts @@ -193,6 +193,9 @@ export class MenuItems { // if(user_type != 'credit'){ // filtered_sales_menu = salesMenus.filter(vv=>vv.state != 'credit_pd') // } + if(parseInt(localStorage.getItem('login_type_id')) == 1){ + filtered_sales_menu = salesMenus.filter(vv=>vv.icon != 'work') + } return filtered_sales_menu; } diff --git a/ng6-seed/src/environments/environment.stage.ts b/ng6-seed/src/environments/environment.stage.ts index 45cc3d1..ba9067c 100644 --- a/ng6-seed/src/environments/environment.stage.ts +++ b/ng6-seed/src/environments/environment.stage.ts @@ -9,7 +9,8 @@ export const environment = { environmentName: 'Development Environment',//Localhost Environment. // apiEndpoint: 'https://demo.pdgenie.com/sparqtest/api/', - apiEndpoint: ' https://apitest.pdgenie.com/sparqtest/api/', + // apiEndpoint: ' https://apitest.pdgenie.com/sparqtest/api/', + apiEndpoint: 'http://localhost/AWSEC2/sparqapi/api/', authorization: 'sparqvenba2018', diff --git a/ng6-seed/src/environments/environment.ts b/ng6-seed/src/environments/environment.ts index 7ae4399..78018b4 100644 --- a/ng6-seed/src/environments/environment.ts +++ b/ng6-seed/src/environments/environment.ts @@ -10,6 +10,7 @@ export const environment = { // apiEndpoint: 'https://apitest.pdgenie.com/sparqtest/api/', apiEndpoint: ' https://apitest.pdgenie.com/sparqtest/api/', + // apiEndpoint: 'http://localhost/AWSEC2/sparqapi/api/', authorization: 'sparqvenba2018',