Offline mode branch
This commit is contained in:
parent
0b12e44900
commit
0d99fb4ee1
@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<widget id="com.sineedge.pdglender" version="0.0.18" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||
<widget id="com.sineedge.pdglender" version="0.0.19" 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>
|
||||
@ -98,6 +98,7 @@
|
||||
<variable name="PLAY_SERVICES_LOCATION_VERSION" value="16.+" />
|
||||
</plugin>
|
||||
<plugin name="cordova-plugin-android-permissions" spec="1.0.2" />
|
||||
<plugin name="cordova-plugin-network-information" spec="2.0.2" />
|
||||
<engine name="browser" spec="5.0.4" />
|
||||
<engine name="android" spec="^8.1.0" />
|
||||
</widget>
|
||||
|
||||
1866
package-lock.json
generated
1866
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@ -32,6 +32,7 @@
|
||||
"@ionic-native/geolocation": "^4.20.0",
|
||||
"@ionic-native/launch-navigator": "^4.16.0",
|
||||
"@ionic-native/location-accuracy": "^4.20.0",
|
||||
"@ionic-native/network": "4.10.1",
|
||||
"@ionic-native/splash-screen": "4.4.0",
|
||||
"@ionic-native/status-bar": "^4.16.0",
|
||||
"@ionic/storage": "^2.2.0",
|
||||
@ -50,6 +51,7 @@
|
||||
"cordova-plugin-geolocation": "2.4.3",
|
||||
"cordova-plugin-ionic-keyboard": "^2.0.5",
|
||||
"cordova-plugin-ionic-webview": "^2.0.0",
|
||||
"cordova-plugin-network-information": "2.0.2",
|
||||
"cordova-plugin-request-location-accuracy": "2.3.0",
|
||||
"cordova-plugin-splashscreen": "5.0.2",
|
||||
"cordova-plugin-statusbar": "2.4.2",
|
||||
@ -62,8 +64,8 @@
|
||||
"ng2-pdf-viewer": "5.2.3",
|
||||
"ngx-image-compress": "^8.0.4",
|
||||
"ngx-mat-select-search": "^1.8.0",
|
||||
"rxjs": "^6.3.1",
|
||||
"rxjs-compat": "^6.3.1",
|
||||
"rxjs": "^6.5.4",
|
||||
"rxjs-compat": "^6.5.4",
|
||||
"sw-toolbox": "3.6.0",
|
||||
"uk.co.workingedge.phonegap.plugin.launchnavigator": "~4.2.2",
|
||||
"watermarkjs": "^2.0.0",
|
||||
@ -71,7 +73,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ionic/app-scripts": "^3.1.11",
|
||||
"typescript": "2.4.2"
|
||||
"typescript": "2.8"
|
||||
},
|
||||
"description": "An Ionic project",
|
||||
"config": {
|
||||
@ -98,7 +100,8 @@
|
||||
"cordova-plugin-request-location-accuracy": {
|
||||
"PLAY_SERVICES_LOCATION_VERSION": "16.+"
|
||||
},
|
||||
"cordova-plugin-android-permissions": {}
|
||||
"cordova-plugin-android-permissions": {},
|
||||
"cordova-plugin-network-information": {}
|
||||
},
|
||||
"platforms": [
|
||||
"browser",
|
||||
|
||||
3
plugins/android.json
Normal file → Executable file
3
plugins/android.json
Normal file → Executable file
@ -51,6 +51,9 @@
|
||||
},
|
||||
"cordova-plugin-android-permissions": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-network-information": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
}
|
||||
},
|
||||
"dependent_plugins": {
|
||||
|
||||
@ -7,49 +7,61 @@
|
||||
"files": {}
|
||||
},
|
||||
"installed_plugins": {
|
||||
"cordova-plugin-camera": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"cordova-plugin-device": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"cordova-plugin-fingerprint-aio": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"cordova-plugin-ionic-keyboard": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"cordova-plugin-ionic-webview": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"cordova-plugin-splashscreen": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"cordova-plugin-statusbar": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"cordova-plugin-whitelist": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"uk.co.workingedge.phonegap.plugin.launchnavigator": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
},
|
||||
"cordova-plugin-geolocation": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
"cordova-plugin-android-permissions": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-app-version": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-camera": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-device": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-fingerprint-aio": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-geolocation": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-ionic-keyboard": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-ionic-webview": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-network-information": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-request-location-accuracy": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-splashscreen": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-statusbar": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-whitelist": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-sqlite-storage": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-request-location-accuracy": {
|
||||
"uk.co.workingedge.phonegap.plugin.launchnavigator": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
}
|
||||
},
|
||||
"dependent_plugins": {
|
||||
"cordova-plugin-actionsheet": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-compat": {
|
||||
"PACKAGE_NAME": "io.ionic.starter"
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-dialogs": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
}
|
||||
}
|
||||
}
|
||||
0
plugins/cordova-plugin-android-permissions/LICENSE
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/LICENSE
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/README.md
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/README.md
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/package.json
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/package.json
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/plugin.xml
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/plugin.xml
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/src/android/com/android/plugins/Permissions.java
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/src/android/com/android/plugins/Permissions.java
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/www/permissions-dummy.js
vendored
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/www/permissions-dummy.js
vendored
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/www/permissions.js
vendored
Normal file → Executable file
0
plugins/cordova-plugin-android-permissions/www/permissions.js
vendored
Normal file → Executable file
@ -138,5 +138,13 @@
|
||||
},
|
||||
"is_top_level": true,
|
||||
"variables": {}
|
||||
},
|
||||
"cordova-plugin-network-information": {
|
||||
"source": {
|
||||
"type": "registry",
|
||||
"id": "cordova-plugin-network-information"
|
||||
},
|
||||
"is_top_level": true,
|
||||
"variables": {}
|
||||
}
|
||||
}
|
||||
@ -16,6 +16,7 @@ import { SalesPDlistPage } from '../pages/sales_pd/pages/sales-p-dlist/sales-p-d
|
||||
import { ConstantsProvider } from '../providers/constants/constants';
|
||||
import { SalesPdProvider } from '../pages/sales_pd/providers/sales-pd/sales-pd';
|
||||
import { PdtriggerProvider } from '../providers/pdtrigger/pdtrigger';
|
||||
import { ConnectionStatus, NetworkDetectionProvider } from '../providers/network-detection/network-detection';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'app.html'
|
||||
@ -32,7 +33,8 @@ export class MyApp {
|
||||
protected app_version: string;
|
||||
commonDetails: any;
|
||||
|
||||
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,private salesPDService:SalesPdProvider,private pdtrigger:PdtriggerProvider) {
|
||||
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,private salesPDService:SalesPdProvider,private pdtrigger:PdtriggerProvider,
|
||||
private networkProvider:NetworkDetectionProvider) {
|
||||
this.initializeApp();
|
||||
this.changeDecision();
|
||||
|
||||
@ -49,6 +51,7 @@ export class MyApp {
|
||||
this.platform.ready().then(() => {
|
||||
// Okay, so the platform is ready and our plugins are available.
|
||||
// Here you can do any higher level native things you might need.
|
||||
|
||||
this.statusBar.styleDefault();
|
||||
this.appVersionProvide.getVersionNumber().then(version_number=>{
|
||||
console.log("version number",version_number);
|
||||
@ -65,13 +68,13 @@ export class MyApp {
|
||||
this.shared.getAccessToken().then(()=>{
|
||||
this.getuserDetails();
|
||||
this.getCommonSettings()
|
||||
this.rootPage = AuthPage
|
||||
this.rootPage = SalesPDlistPage
|
||||
}).catch(()=>{
|
||||
setTimeout(() => {
|
||||
this.rootPage = LoginPage;
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
this.networkDetection()
|
||||
})
|
||||
|
||||
this.platform.registerBackButtonAction(()=>{
|
||||
@ -108,6 +111,14 @@ export class MyApp {
|
||||
this.nav.pop()
|
||||
}
|
||||
}); }
|
||||
networkDetection(){
|
||||
|
||||
this.networkProvider.onNetworkChange().subscribe((status: ConnectionStatus) => {
|
||||
if (status == ConnectionStatus.online) {
|
||||
// this.offlineManager.checkForEvents().subscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getCommonSettings(){
|
||||
// getCommonConfig
|
||||
|
||||
@ -46,7 +46,6 @@ import {
|
||||
import { AwsServiceProvider } from '../providers/aws-service/aws-service';
|
||||
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { AuthGuard } from '../providers/_guard/auth.guard';
|
||||
import { TokenInterceptor } from '../providers/_guard/token.interceptor';
|
||||
import { CognitoServiceProvider } from '../providers/aws-service/cognito.service';
|
||||
import { ConstantsProvider } from '../providers/constants/constants';
|
||||
import { AuthPage } from '../pages/auth/auth';
|
||||
@ -87,6 +86,10 @@ import { ReportViewer } from '../pages/sales_pd/pages/report-pdf-viewer/pdf-moda
|
||||
import { AndroidPermissions } from '@ionic-native/android-permissions';
|
||||
import { AdvanceFilterPage } from '../pages/sales_pd/pages/advance-filter/advance-filter';
|
||||
import { PdAdvanceFilterPage } from '../pages/pd-list/pd-advance-filter/pd-advance-filter';
|
||||
import { NetworkDetectionProvider } from '../providers/network-detection/network-detection';
|
||||
import { OfflineManagerProvider } from '../pages/sales_pd/providers/offline-manager/offline-manager';
|
||||
import { IonicStorageProvider } from '../providers/ionic-storage/ionic-storage';
|
||||
import { Network } from '@ionic-native/network';
|
||||
// need the hammerConnfig
|
||||
export class HammerConfig extends HammerGestureConfig {
|
||||
overrides = {
|
||||
@ -177,7 +180,7 @@ export class HammerConfig extends HammerGestureConfig {
|
||||
|
||||
],
|
||||
providers: [
|
||||
StatusBar,AwsServiceProvider,AuthGuard,TokenInterceptor,ToastProvider,ReqTokenInterceptor,
|
||||
StatusBar,AwsServiceProvider,AuthGuard,ToastProvider,ReqTokenInterceptor,
|
||||
ConstantsProvider,CognitoServiceProvider,SplashScreen,PdtriggerProvider,FingerprintAIO,
|
||||
{
|
||||
provide:HTTP_INTERCEPTORS,
|
||||
@ -197,7 +200,10 @@ export class HammerConfig extends HammerGestureConfig {
|
||||
provide: HAMMER_GESTURE_CONFIG,
|
||||
useClass: HammerConfig
|
||||
},
|
||||
AndroidPermissions
|
||||
AndroidPermissions,Network,
|
||||
NetworkDetectionProvider,
|
||||
OfflineManagerProvider,
|
||||
IonicStorageProvider,
|
||||
|
||||
],
|
||||
// exports:[HomePageModule]
|
||||
|
||||
@ -21,6 +21,7 @@ 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';
|
||||
import { PdtriggerProvider } from '../../providers/pdtrigger/pdtrigger';
|
||||
import { SalesPdProvider } from '../sales_pd/providers/sales-pd/sales-pd';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -51,7 +52,7 @@ config: MatDialogConfig = {
|
||||
commonDetails: any;
|
||||
constructor( public aws: AwsServiceProvider, public dialog: MatDialog,
|
||||
public shared:CognitoServiceProvider,public navCtrl:NavController,public Menu:MenuController
|
||||
,public toast:ToastProvider,public load:LoadingController,private events:Events,private constantProvider:ConstantsProvider,private pdtrigger:PdtriggerProvider) {
|
||||
,public toast:ToastProvider,public load:LoadingController,private events:Events,private constantProvider:ConstantsProvider,private pdtrigger:PdtriggerProvider,private salesPDProvider:SalesPdProvider) {
|
||||
|
||||
}
|
||||
ngOnInit(){
|
||||
@ -133,7 +134,9 @@ getlenderpddetails()
|
||||
this.events.publish(('len_user_name'),this.userDetails);
|
||||
let role= this.constantProvider.takeDecisionRouting(this.userDetails)
|
||||
if(role == 'sales'){
|
||||
this.pdtrigger.initiateMasterApis('sales')
|
||||
this.navCtrl.setRoot(SalesPDlistPage);
|
||||
|
||||
}
|
||||
else{
|
||||
this.navCtrl.setRoot(PdListPage,{'userDetails':this.userDetails});
|
||||
|
||||
0
src/pages/pd-list/pd-advance-filter/pd-advance-filter.html
Normal file → Executable file
0
src/pages/pd-list/pd-advance-filter/pd-advance-filter.html
Normal file → Executable file
0
src/pages/pd-list/pd-advance-filter/pd-advance-filter.scss
Normal file → Executable file
0
src/pages/pd-list/pd-advance-filter/pd-advance-filter.scss
Normal file → Executable file
0
src/pages/pd-list/pd-advance-filter/pd-advance-filter.ts
Normal file → Executable file
0
src/pages/pd-list/pd-advance-filter/pd-advance-filter.ts
Normal file → Executable file
@ -13,6 +13,7 @@ import { NavController } from 'ionic-angular/navigation/nav-controller';
|
||||
import { Section1,Section2,Section3,Section4,Section5,Section6,Section7,Section8,Section9 } from '../../pages/home/home';
|
||||
import { MatAccordion, MatExpansionPanel } from '@angular/material';
|
||||
import { HttpEventType, HttpResponse } from '@angular/common/http';
|
||||
import { NetworkDetectionProvider, ConnectionStatus } from '../../../../providers/network-detection/network-detection';
|
||||
|
||||
|
||||
// const originFormControlNameNgOnChanges = FormControlName.prototype.ngOnChanges;
|
||||
@ -53,7 +54,8 @@ export class QuesTemplateComponent {
|
||||
@ViewChild('accordion') Accordion: MatAccordion
|
||||
@ViewChild('mapanel') matExpansionPanel:MatExpansionPanel
|
||||
emittedFormGroup: any = null;
|
||||
constructor(private _fb:FormBuilder,private questionService:QuesServiceProvider,private salesPDProvider:SalesPdProvider,private camera:Camera,private cameraProvider:CameraProvider,private constantProvider:ConstantsProvider,private toastProvider:ToastProvider,private loadingProvider:LoadingProvider,private navCtrl:NavController) {
|
||||
sales_pd_id: any;
|
||||
constructor(private _fb:FormBuilder,private questionService:QuesServiceProvider,private salesPDProvider:SalesPdProvider,private camera:Camera,private cameraProvider:CameraProvider,private constantProvider:ConstantsProvider,private toastProvider:ToastProvider,private loadingProvider:LoadingProvider,private navCtrl:NavController,private networkDetection:NetworkDetectionProvider) {
|
||||
console.log('Hello QuesTemplateComponent Component');
|
||||
this.text = 'Hello World';
|
||||
this.cameraProvider.checkGPSPermission();
|
||||
@ -80,6 +82,7 @@ export class QuesTemplateComponent {
|
||||
|
||||
this.salesPDProvider.getData_fromLocal('sec'+this.local_ques_JSON.section_id).then(resultData=>{
|
||||
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((key_value)=>{
|
||||
this.sales_pd_id = key_value
|
||||
if(resultData != null && resultData.sales_pd_id == key_value){
|
||||
this.original_result_data=resultData
|
||||
this.checkGroupandPatchValues()
|
||||
@ -262,6 +265,7 @@ this.proceedonChangeProperty(modified)
|
||||
console.log('File is completely uploaded!');
|
||||
}
|
||||
}
|
||||
|
||||
addData(group_index, parent_index, data, event, options?: any, single_ques?) {
|
||||
console.clear();
|
||||
data=data.filter(group_indi=>!group_indi.hasOwnProperty('additional_field') && group_indi.additional_field != 1 )
|
||||
@ -274,26 +278,44 @@ this.proceedonChangeProperty(modified)
|
||||
this.geoCoordinates = localStorage.getItem('current_coordinates')
|
||||
this.cameraProvider.addWatermarks(res).then(watermarkedImage => {
|
||||
single_ques.controls.answer_value.setValue(watermarkedImage)
|
||||
// this.sales_pd_id = Number(this.sales_pd_id)
|
||||
// console.log(this.sales_pd_id)
|
||||
|
||||
single_ques.controls.is_image_status.setValue(true)
|
||||
single_ques.controls.is_loader.setValue(true);
|
||||
single_ques.controls.is_saved.setValue(false);
|
||||
this.emittedFormGroup = this.quesAnsForm.getRawValue()
|
||||
// PASSING THE VALUE TO PARENT COMPONENT
|
||||
this.imageUploadCheck.emit(this.emittedFormGroup);
|
||||
// if(this.networkDetection.getCurrentNetworkStatus() == ConnectionStatus.online && (typeof(this.sales_pd_id) == 'string' ? !this.sales_pd_id.includes('local') : true) ) {
|
||||
single_ques.controls.is_image_status.setValue(true)
|
||||
single_ques.controls.is_loader.setValue(true);
|
||||
single_ques.controls.is_saved.setValue(false);
|
||||
// }
|
||||
|
||||
//SENDING SINGLE IMAGE TO API WITH PRIMARY KEY
|
||||
let params={"fk_sales_pd_id":"","img":watermarkedImage,"img_name":single_ques.value.question_key}
|
||||
let storage_param=this.questions_JSON
|
||||
this.salesPDProvider.saveSalesPDImage(params).subscribe(apiresult=>{
|
||||
let form_structure=this.questions_JSON
|
||||
form_structure.questions=this.quesAnsForm.getRawValue().questions
|
||||
form_structure.is_complete=1
|
||||
|
||||
|
||||
// else {
|
||||
// single_ques.controls.is_image_status.setValue(true)
|
||||
// single_ques.controls.is_loader.setValue(false);
|
||||
// single_ques.controls.is_saved.setValue(true);
|
||||
// }
|
||||
this.emittedFormGroup = this.quesAnsForm.getRawValue()
|
||||
// PASSING THE VALUE TO PARENT COMPONENT
|
||||
this.imageUploadCheck.emit(this.emittedFormGroup);
|
||||
|
||||
this.salesPDProvider.saveSalesPDImage(params,form_structure).subscribe(apiresult=>{
|
||||
if(apiresult['dataStatus']){
|
||||
single_ques.controls.is_loader.setValue(false);
|
||||
single_ques.controls.is_saved.setValue(true);
|
||||
this.httpListener(apiresult);
|
||||
form_structure.questions=this.quesAnsForm.getRawValue().questions
|
||||
this.salesPDProvider.updateSectionDataLocally(params,form_structure).subscribe(res=>{
|
||||
})
|
||||
storage_param.questions=this.quesAnsForm.getRawValue().questions
|
||||
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
storage_param.sales_pd_id=key_value
|
||||
this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param)
|
||||
// this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param)
|
||||
})
|
||||
console.log("image saved successfully")
|
||||
}
|
||||
@ -395,9 +417,9 @@ this.proceedonChangeProperty(modified)
|
||||
|
||||
}
|
||||
}
|
||||
sendGeoCordsForSatellite(geoCords){
|
||||
sendGeoCordsForSatellite(geoCords,form_structure){
|
||||
let params = {"sales_pd_id":'',"geo_location":geoCords}
|
||||
this.salesPDProvider.generateSatelliteImg(params).subscribe(val=>{})
|
||||
this.salesPDProvider.generateSatelliteImg(params,form_structure).subscribe(val=>{})
|
||||
}
|
||||
captureImg(parent_index,parent_control){
|
||||
// parent_control.controls.is_image_status.setValue('l')
|
||||
@ -405,27 +427,49 @@ this.proceedonChangeProperty(modified)
|
||||
if (res != 'error') {
|
||||
this.geoCoordinates=localStorage.getItem('current_coordinates')
|
||||
this.cameraProvider.addWatermarks(res).then(watermarkedImage=>{
|
||||
this.sendGeoCordsForSatellite(this.geoCoordinates)
|
||||
|
||||
parent_control.controls.answer_value.setValue(watermarkedImage)
|
||||
parent_control.controls.is_image_status.setValue(true)
|
||||
parent_control.controls.is_loader.setValue(true);
|
||||
parent_control.controls.is_saved.setValue(false);
|
||||
this.emittedFormGroup = this.quesAnsForm.getRawValue()
|
||||
this.imageUploadCheck.emit(this.emittedFormGroup);
|
||||
|
||||
|
||||
//SENDING SINGLE IMAGE TO API WITH PRIMARY KEY
|
||||
let params={"fk_sales_pd_id":"","img":watermarkedImage,"img_name":parent_control.value.question_key}
|
||||
let storage_param=this.questions_JSON
|
||||
this.salesPDProvider.saveSalesPDImage(params).subscribe(apiresult=>{
|
||||
if(apiresult['dataStatus']){
|
||||
const form_structure=this.questions_JSON
|
||||
form_structure.questions=this.quesAnsForm.getRawValue().questions
|
||||
form_structure.is_complete=1
|
||||
|
||||
// if(this.networkDetection.getCurrentNetworkStatus() == ConnectionStatus.online && typeof(this.sales_pd_id) != 'string' && (typeof(this.sales_pd_id) == 'string' ? !this.sales_pd_id.includes('local') : true) ) {
|
||||
parent_control.controls.is_image_status.setValue(true)
|
||||
parent_control.controls.is_loader.setValue(true);
|
||||
parent_control.controls.is_saved.setValue(false);
|
||||
// }
|
||||
// else {
|
||||
// parent_control.controls.is_image_status.setValue(true)
|
||||
// parent_control.controls.is_loader.setValue(false);
|
||||
// parent_control.controls.is_saved.setValue(true);
|
||||
// }
|
||||
|
||||
this.emittedFormGroup = this.quesAnsForm.getRawValue()
|
||||
this.imageUploadCheck.emit(this.emittedFormGroup);
|
||||
|
||||
|
||||
this.salesPDProvider.saveSalesPDImage(params,form_structure).subscribe(apiresult=>{
|
||||
if(apiresult['dataStatus']){
|
||||
|
||||
parent_control.controls.is_loader.setValue(false);
|
||||
parent_control.controls.is_saved.setValue(true);
|
||||
|
||||
form_structure.questions=this.quesAnsForm.getRawValue().questions
|
||||
// this.httpListener(apiresult);
|
||||
this.salesPDProvider.updateSectionDataLocally(params,form_structure).subscribe(res=>{
|
||||
this.sendGeoCordsForSatellite(this.geoCoordinates,form_structure)
|
||||
})
|
||||
console.log("Result",apiresult['dataStatus'])
|
||||
this.toastProvider.lenderappmessage(parent_control.value.question+ " Saved Successfully")
|
||||
storage_param.questions=this.quesAnsForm.getRawValue().questions
|
||||
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
storage_param.sales_pd_id=key_value
|
||||
this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param)
|
||||
// this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param)
|
||||
})
|
||||
}
|
||||
else{
|
||||
@ -1129,7 +1173,7 @@ this.proceedonChangeProperty(modified)
|
||||
this.salesPDProvider.saveQuestions(params).subscribe((apiresult:any)=>{
|
||||
if(apiresult['dataStatus']){
|
||||
if(apiresult['records'] != true && typeof(apiresult['records']) != 'object'){
|
||||
this.salesPDProvider.insertData_Replace('sales_pd_id_PRIMARYKEY',apiresult['records']).then(local_result=>{
|
||||
this.salesPDProvider.insertData_Replace('sales_pd_id_PRIMARYKEY',String(apiresult['records'])).then(local_result=>{
|
||||
if(!this.submit_btn){
|
||||
this.sendSectiontoApi(section_data)
|
||||
}
|
||||
@ -1236,7 +1280,7 @@ this.proceedonChangeProperty(modified)
|
||||
insertSectionDataLocally(section_data){
|
||||
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
section_data.sales_pd_id=key_value
|
||||
this.salesPDProvider.insertData_Replace('sec'+section_data.section_id,section_data)
|
||||
// this.salesPDProvider.insertData_Replace('sec'+section_data.section_id,section_data)
|
||||
})
|
||||
section_data.questions=this.questions_JSON.questions
|
||||
setTimeout(()=>{
|
||||
@ -1245,7 +1289,7 @@ this.proceedonChangeProperty(modified)
|
||||
}
|
||||
// SENDING SALES PD SECTION 9 STRUCTURE(photographs)
|
||||
ngOnDestroy(){
|
||||
console.clear()
|
||||
// console.clear()
|
||||
console.log("dirty check",this.quesAnsForm.dirty)
|
||||
if(this.local_ques_JSON.section_id == 9 && this.emittedFormGroup != null){
|
||||
// FOR SENDING THE IMAGE SECTION (SECTION ID 9) JSON Structure
|
||||
@ -1284,24 +1328,40 @@ this.proceedonChangeProperty(modified)
|
||||
}
|
||||
}
|
||||
imageReupload(single_ques){
|
||||
single_ques.controls.is_image_status.setValue(true);
|
||||
single_ques.controls.is_loader.setValue(true);
|
||||
single_ques.controls.is_saved.setValue(false);
|
||||
|
||||
|
||||
let storage_param=this.questions_JSON
|
||||
storage_param.questions=this.quesAnsForm.getRawValue().questions
|
||||
|
||||
let data=single_ques.value
|
||||
let params={"fk_sales_pd_id":"","img":data.answer_value,"img_name":data.question_key}
|
||||
this.salesPDProvider.saveSalesPDImage(params).subscribe(apiresult=>{
|
||||
const form_structure=this.questions_JSON
|
||||
form_structure.questions=this.quesAnsForm.getRawValue().questions
|
||||
form_structure.is_complete=1
|
||||
|
||||
// if(this.networkDetection.getCurrentNetworkStatus() == ConnectionStatus.online && typeof(this.sales_pd_id) != 'string' && (typeof(this.sales_pd_id) == 'string' ? !this.sales_pd_id.includes('local') : true) ) {
|
||||
single_ques.controls.is_image_status.setValue(true);
|
||||
single_ques.controls.is_loader.setValue(true);
|
||||
single_ques.controls.is_saved.setValue(false);
|
||||
// }
|
||||
// else {
|
||||
// single_ques.controls.is_image_status.setValue(true)
|
||||
// single_ques.controls.is_loader.setValue(false);
|
||||
// single_ques.controls.is_saved.setValue(true);
|
||||
// }
|
||||
|
||||
this.salesPDProvider.saveSalesPDImage(params,form_structure).subscribe(apiresult=>{
|
||||
if(apiresult['dataStatus']){
|
||||
single_ques.controls.is_loader.setValue(false);
|
||||
single_ques.controls.is_saved.setValue(true);
|
||||
this.httpListener(apiresult);
|
||||
form_structure.questions=this.quesAnsForm.getRawValue().questions
|
||||
// this.httpListener(apiresult);
|
||||
this.salesPDProvider.updateSectionDataLocally(params,form_structure).subscribe(res=>{
|
||||
})
|
||||
storage_param.questions=this.quesAnsForm.getRawValue().questions
|
||||
this.salesPDProvider.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
storage_param.sales_pd_id=key_value
|
||||
this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param)
|
||||
// this.salesPDProvider.insertData_Replace('sec'+storage_param.section_id,storage_param)
|
||||
})
|
||||
console.log("image saved successfully")
|
||||
}
|
||||
|
||||
0
src/pages/sales_pd/pages/advance-filter/advance-filter.html
Normal file → Executable file
0
src/pages/sales_pd/pages/advance-filter/advance-filter.html
Normal file → Executable file
0
src/pages/sales_pd/pages/advance-filter/advance-filter.scss
Normal file → Executable file
0
src/pages/sales_pd/pages/advance-filter/advance-filter.scss
Normal file → Executable file
0
src/pages/sales_pd/pages/advance-filter/advance-filter.ts
Normal file → Executable file
0
src/pages/sales_pd/pages/advance-filter/advance-filter.ts
Normal file → Executable file
@ -4,7 +4,7 @@
|
||||
See http://ionicframework.com/docs/components/#navigation for more info on
|
||||
Ionic pages and navigation.
|
||||
-->
|
||||
<ion-header>
|
||||
<ion-header style="background: #ff7f507d">
|
||||
|
||||
<ion-navbar color="optblue">
|
||||
<button ion-button menuToggle>
|
||||
@ -15,11 +15,17 @@
|
||||
<button ion-button type="submit" color="primary">dd</button>
|
||||
</ion-buttons> -->
|
||||
</ion-navbar>
|
||||
|
||||
<!-- <div class="offline-class"> -->
|
||||
<span *ngIf="network_status == 1"
|
||||
style="width: 100%;
|
||||
height: 34px;
|
||||
text-align: center;">
|
||||
<p style="margin: 3px">No Network Connection</p></span>
|
||||
<!-- </div> -->
|
||||
</ion-header>
|
||||
|
||||
|
||||
<ion-content padding style="background:white">
|
||||
<ion-content padding >
|
||||
<mat-card>
|
||||
<mat-card-content *ngIf="question_data.questions.length > 0">
|
||||
|
||||
|
||||
@ -14,4 +14,12 @@ ion-content{
|
||||
.mat-radio-button{
|
||||
min-width: 35%;
|
||||
}
|
||||
.offline-class{
|
||||
background-color: rgba(255, 0, 0, 0.527);
|
||||
p{
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import { SalesPDlistPage } from '../sales-p-dlist/sales-p-dlist';
|
||||
import { CameraProvider } from '../../providers/camera/camera';
|
||||
import { LoadingProvider } from '../../../../providers/common-provider/loading';
|
||||
import { SectionListPage } from '../section-list/section-list';
|
||||
import { NetworkDetectionProvider, ConnectionStatus } from '../../../../providers/network-detection/network-detection';
|
||||
|
||||
|
||||
/**
|
||||
@ -54,7 +55,8 @@ export class HomePage{
|
||||
// let product= localStorage.getItem('product_id_salesPD')
|
||||
// this.navCtrl.push(Section1,{product_id:product})
|
||||
localStorage.removeItem('product_id_salesPD');
|
||||
this.salesPDService.clearLocalData()
|
||||
// this.salesPDService.clearLocalData()
|
||||
this.salesPDService.clear_local_key('sales_pd_id_PRIMARYKEY');
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -501,8 +503,10 @@ export class Section9 {
|
||||
section_local:number=9
|
||||
all_sections:any;
|
||||
formGroupValue: any=null;
|
||||
network_status: ConnectionStatus
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private loadingProvider:LoadingProvider,private toastProvider:ToastProvider) {
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private loadingProvider:LoadingProvider,private toastProvider:ToastProvider
|
||||
,private networkDetectionProvider:NetworkDetectionProvider) {
|
||||
if(this.navParams.get('section_id')){
|
||||
this.section_local=this.navParams.get('section_id')
|
||||
}
|
||||
@ -528,7 +532,11 @@ export class Section9 {
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
|
||||
console.log("######Entered");
|
||||
this.networkDetectionProvider.onNetworkChange().subscribe(result=>{
|
||||
this.network_status = result
|
||||
console.log(this.network_status);
|
||||
})
|
||||
|
||||
}
|
||||
ionViewCanLeave(){
|
||||
@ -612,11 +620,13 @@ checkTheUploadingProgress(sec_value){
|
||||
// this.sendData()
|
||||
console.log("else part")
|
||||
// this.sendDatatoApi()
|
||||
this.SalesPDService.clearLocalData()
|
||||
// this.SalesPDService.clearLocalData()
|
||||
this.SalesPDService.clear_local_key('sales_pd_id_PRIMARYKEY');
|
||||
let msg=event.hasOwnProperty('is_completed') && event.is_completed == true ? "Completed Successfully" : 'Saved Successfully..!'
|
||||
this.toastProvider.lenderappmessage(msg);
|
||||
this.SalesPDService.clearLocalData()
|
||||
localStorage.removeItem('product_id_salesPD')
|
||||
// this.SalesPDService.clearLocalData()
|
||||
this.SalesPDService.clear_local_key('sales_pd_id_PRIMARYKEY');
|
||||
localStorage.removeItem('product_id_salesPD')
|
||||
setTimeout(()=>{
|
||||
this.navCtrl.setRoot(SalesPDlistPage)
|
||||
},2000)
|
||||
|
||||
5
src/pages/sales_pd/pages/report-pdf-viewer/pdf-modal.html
Normal file → Executable file
5
src/pages/sales_pd/pages/report-pdf-viewer/pdf-modal.html
Normal file → Executable file
@ -22,7 +22,7 @@
|
||||
</ion-header>
|
||||
|
||||
<!-- add the pinchin and pinchout events -->
|
||||
<ion-content (pinchin)="pinchin($event)" (pinchout)="pinchout($event)" (tap)="tapped($event)">
|
||||
<ion-content (pinchin)="pinchin($event)" (pinchout)="pinchout($event)" (tap)="tapped($event)" *ngIf="pdf">
|
||||
|
||||
<!-- <pdf-viewer [src]="pdf" [page]="page" (after-load-complete)="afterLoadComplete($event)" [render-text]="true" [show-all]="false" [zoom]="zoom" [original-size]="false"
|
||||
style="width:100%;height:85%; overflow:scroll;display:flex;-webkit-overflow-scrolling: touch; display: -webkit-flex;">
|
||||
@ -56,3 +56,6 @@
|
||||
</div> -->
|
||||
|
||||
</ion-content>
|
||||
<ion-content padding *ngIf="error_msg">
|
||||
<h6 style="text-align:center;color: red">{{error_msg}}</h6>
|
||||
</ion-content>
|
||||
|
||||
7
src/pages/sales_pd/pages/report-pdf-viewer/pdf-modal.ts
Normal file → Executable file
7
src/pages/sales_pd/pages/report-pdf-viewer/pdf-modal.ts
Normal file → Executable file
@ -24,10 +24,17 @@ export class ReportViewer {
|
||||
currentZoom: any;
|
||||
isLoaded: boolean = false;
|
||||
doubleTap:boolean=false
|
||||
error_msg: any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,public sanitizer: DomSanitizer,private viewCtrl:ViewController) {
|
||||
if(this.navParams.get('report_link')){
|
||||
this.pdf =navParams.get('report_link') ;
|
||||
this.pdfSource=this.sanitizer.bypassSecurityTrustResourceUrl(this.pdf);
|
||||
}
|
||||
else if(this.navParams.get('error_msg')) {
|
||||
this.error_msg = this.navParams.get('error_msg');
|
||||
}
|
||||
|
||||
this.title = "Report";
|
||||
|
||||
}
|
||||
|
||||
@ -42,10 +42,15 @@
|
||||
</content-loader>
|
||||
</div>
|
||||
</div>
|
||||
<ion-list style="margin-top: 5px;" [virtualScroll]="sales_displayValue">
|
||||
<ion-item *virtualItem="let val" (click)="val.status != 'COMPLETED' ? editForm(val) :presentActionSheet(val)">
|
||||
<ion-list [virtualScroll]="sales_displayValue">
|
||||
<ion-item *virtualItem="let val" (click)="val.status != 'COMPLETED' ? editForm(val) :presentActionSheet(val)" style="padding:0px"
|
||||
[ngStyle]="{'border-left':(val.hasOwnProperty('is_pd_synced') && val.is_pd_synced == false) ||
|
||||
(val.hasOwnProperty('is_all_section_synced') && val.is_all_section_synced == false) ||
|
||||
(val.hasOwnProperty('is_pd_completed_sync') && val.hasOwnProperty('is_pd_completed') && val.is_pd_completed == true &&
|
||||
val.is_pd_completed_sync == false)? '4px solid rgb(255, 184, 0)' : '4px solid #00ff009c'}">
|
||||
<!-- <p item-start class="lettericon">{{val.abbr}}</p> -->
|
||||
<!-- <ion-icon style="font-size:90%" item-start="" class="lettericon" [style.background]="bgColor[i]" *ngIf="progess.applicat_details ===undefined || progess.applicat_details[0].applicant_name ==null">{{progess.pd_id}}</ion-icon> -->
|
||||
|
||||
<ion-row>
|
||||
<ion-col class="applicant_name" col-6 *ngIf="val.applicant_name != null">
|
||||
<h1>{{val.applicant_name}}</h1>
|
||||
|
||||
@ -7,6 +7,9 @@ import { LoadingProvider } from '../../../../providers/common-provider/loading';
|
||||
import { ReportViewer } from '../report-pdf-viewer/pdf-modal';
|
||||
import { SectionListPage } from '../section-list/section-list';
|
||||
import { AdvanceFilterPage } from '../advance-filter/advance-filter';
|
||||
import { OfflineManagerProvider } from '../../providers/offline-manager/offline-manager';
|
||||
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
||||
import { CameraProvider } from '../../providers/camera/camera';
|
||||
|
||||
|
||||
/**
|
||||
@ -16,7 +19,7 @@ import { AdvanceFilterPage } from '../advance-filter/advance-filter';
|
||||
* Ionic pages and navigation.
|
||||
*/
|
||||
|
||||
|
||||
const pd_key ='local_sales_PDs'
|
||||
@Component({
|
||||
selector: 'page-sales-p-dlist',
|
||||
templateUrl: 'sales-p-dlist.html',
|
||||
@ -28,8 +31,9 @@ export class SalesPDlistPage {
|
||||
filter_drop_down_data: { product_ids: any[]; lender_ids: any[]; pd_status: any[]; };
|
||||
filterMsg: boolean = false;
|
||||
common: any;
|
||||
|
||||
constructor(public actionSheetCtrl: ActionSheetController,public navCtrl: NavController, public navParams: NavParams,private salesPDService:SalesPdProvider,private toastProvider:ToastProvider,private loaderProvider:LoadingProvider,private modalCtrl:ModalController) {
|
||||
localPDs:any =[ ]
|
||||
constructor(public actionSheetCtrl: ActionSheetController,public navCtrl: NavController, public navParams: NavParams,private salesPDService:SalesPdProvider,private toastProvider:ToastProvider,private loaderProvider:LoadingProvider,private modalCtrl:ModalController,private offlineManager:OfflineManagerProvider,
|
||||
private ionicStorageService:IonicStorageProvider,private cameraProvider:CameraProvider) {
|
||||
|
||||
}
|
||||
|
||||
@ -42,6 +46,7 @@ export class SalesPDlistPage {
|
||||
this.common = this.common.count+' '+this.common.factor
|
||||
}
|
||||
},300)
|
||||
this.cameraProvider.checkGPSPermission();
|
||||
// this.salesPDService.clearLocalData();
|
||||
}
|
||||
ionViewDidEnter(){
|
||||
@ -55,10 +60,38 @@ export class SalesPDlistPage {
|
||||
event.complete();
|
||||
}, 1000);
|
||||
}
|
||||
getListofLocalPD() {
|
||||
return this.ionicStorageService.getLocalDataWithFilter(pd_key,{name:'local_pd_id',type:'filter',value :null}).then(result=>{
|
||||
console.log(result,this.sales_displayValue)
|
||||
if(result && result.length > 0){
|
||||
let result_val = result
|
||||
result_val.sort((a,b)=> 0 - (a>b ? -1 : 1));
|
||||
this.localPDs = result_val
|
||||
this.sales_displayValue.unshift(...this.localPDs);
|
||||
}
|
||||
})
|
||||
}
|
||||
getListofPD(){
|
||||
return this.ionicStorageService.getLocalDataWithFilter(pd_key,{name:'sales_pd_id',type:'filter',value:null}).then(local_res=>{
|
||||
console.log(local_res);
|
||||
this.salesPDService.getSalesPDList().subscribe(res=>{
|
||||
if(res['dataStatus']){
|
||||
this.sales_displayValue=res['records']
|
||||
if(local_res && local_res.length > 0) {
|
||||
local_res.forEach(local_obj=>{
|
||||
if(local_obj && local_obj.sales_pd_id && local_obj.sales_pd_id != null) {
|
||||
console.log(local_obj)
|
||||
let findListIndex = this.sales_displayValue.findIndex(val=>val.sales_pd_id == local_obj.sales_pd_id)
|
||||
this.sales_displayValue[findListIndex].is_pd_synced = local_obj.is_pd_synced
|
||||
this.sales_displayValue[findListIndex].is_all_section_synced = local_obj.is_all_section_synced
|
||||
this.sales_displayValue[findListIndex].is_pd_completed = local_obj.is_pd_completed
|
||||
this.sales_displayValue[findListIndex].is_pd_completed_sync = local_obj.is_pd_completed_sync
|
||||
if(local_obj.hasOwnProperty('status') && local_obj.status){
|
||||
this.sales_displayValue[findListIndex].status = local_obj.status
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
this.loader_access=false
|
||||
if(this.sales_displayValue.length > 0){
|
||||
this.filterMsg = true
|
||||
@ -92,8 +125,9 @@ export class SalesPDlistPage {
|
||||
}
|
||||
})
|
||||
this.filter_drop_down_data={product_ids:products,lender_ids:lenders,pd_status:pd_status}
|
||||
// console.log(this.filter_drop_down_data);
|
||||
console.log(this.sales_displayValue);
|
||||
}
|
||||
this.getListofLocalPD()
|
||||
}
|
||||
else{
|
||||
this.loader_access=false
|
||||
@ -103,6 +137,7 @@ export class SalesPDlistPage {
|
||||
console.log("Error",err)
|
||||
this.loader_access=false
|
||||
})
|
||||
})
|
||||
}
|
||||
newForm(){
|
||||
// this.salesPDService.getData_fromLocal('sec1').then(result=>{
|
||||
@ -114,7 +149,8 @@ export class SalesPDlistPage {
|
||||
// this.navCtrl.push(HomePage)
|
||||
// }
|
||||
// });
|
||||
this.salesPDService.clearLocalData()
|
||||
// this.salesPDService.clearLocalData()
|
||||
this.salesPDService.clear_local_key('sales_pd_id_PRIMARYKEY');
|
||||
localStorage.removeItem('product_id_salesPD')
|
||||
this.navCtrl.push(HomePage)
|
||||
|
||||
@ -123,7 +159,11 @@ export class SalesPDlistPage {
|
||||
editForm(value_obj){
|
||||
// let product= localStorage.getItem('product_id_salesPD')
|
||||
// storing the sales_pd_id and product id in local storagey
|
||||
this.salesPDService.insertData_Replace('sales_pd_id_PRIMARYKEY',value_obj.sales_pd_id).then(()=>{
|
||||
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(()=>{
|
||||
localStorage.setItem('product_id_salesPD',value_obj.product_id)
|
||||
this.navCtrl.push(SectionListPage,{product_id:value_obj.product_id})
|
||||
})
|
||||
@ -145,6 +185,9 @@ export class SalesPDlistPage {
|
||||
this.loaderProvider.dismissLoader();
|
||||
},err=>{
|
||||
this.loaderProvider.dismissLoader()
|
||||
console.log(err);
|
||||
let profileModal = this.modalCtrl.create(ReportViewer,{'error_msg':'Please check your internet connection to view PD reports. They are available only if you are connected.'});
|
||||
profileModal.present();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
25
src/pages/sales_pd/pages/section-list/section-list.html
Normal file → Executable file
25
src/pages/sales_pd/pages/section-list/section-list.html
Normal file → Executable file
@ -11,16 +11,37 @@
|
||||
<ion-icon name="menu"></ion-icon>
|
||||
</button>
|
||||
<ion-title>Section List</ion-title>
|
||||
<ion-buttons end *ngIf="is_sync_btn">
|
||||
<button ion-button outline round (click)="syncPDWithSections()"><ion-icon name="sync"></ion-icon> Sync</button>
|
||||
</ion-buttons>
|
||||
</ion-navbar>
|
||||
|
||||
</ion-header>
|
||||
|
||||
|
||||
<ion-content padding>
|
||||
<!-- {{pd_completed | json}} -->
|
||||
<!-- <div class="completed_note" *ngIf ="!is_sync_btn && pd_completed.is_synced == false && pd_completed.is_completed &&
|
||||
pd_completed.pd_complete_request_items != null">
|
||||
<p >PD Completion is not synced yet.
|
||||
<button small ion-button outline round (click)="syncPDWithSections()"><ion-icon name="sync"></ion-icon> Sync</button>
|
||||
</p>
|
||||
</div> -->
|
||||
<!-- <div class="completed_note" *ngIf ="is_sync_btn && pd_completed.is_synced == false && pd_completed.is_completed &&
|
||||
pd_completed.pd_complete_request_items != null">
|
||||
<p >
|
||||
PD is Completed. All the Sections are stored Locally. Please click that sync button above to send the data to server</p>
|
||||
</div> -->
|
||||
<div class="completed_note" *ngIf ="is_sync_btn">
|
||||
<p >
|
||||
PD saved. Click SYNC to complete</p>
|
||||
</div>
|
||||
<mat-card class="card-class"
|
||||
[ngClass]="{'border-disabled': sales_pd_id == null && sec.is_disabled,
|
||||
'border-saved-local': sales_pd_id != null && sec.hasOwnProperty('status') &&
|
||||
sec.status == '1' && sec.hasOwnProperty('is_synced') && sec.is_synced == false,
|
||||
'border-saved': sales_pd_id != null && sec.hasOwnProperty('status') &&
|
||||
sec.status == '1'}" *ngFor="let sec of section_template" (click)="goto(sec.order_id)">
|
||||
sec.status == '1'
|
||||
}" *ngFor="let sec of section_template" (click)="goto(sec.order_id)">
|
||||
<ion-row>
|
||||
<ion-col col-11>
|
||||
<h6>{{sec.section_name}}</h6>
|
||||
|
||||
0
src/pages/sales_pd/pages/section-list/section-list.module.ts
Normal file → Executable file
0
src/pages/sales_pd/pages/section-list/section-list.module.ts
Normal file → Executable file
26
src/pages/sales_pd/pages/section-list/section-list.scss
Normal file → Executable file
26
src/pages/sales_pd/pages/section-list/section-list.scss
Normal file → Executable file
@ -40,5 +40,31 @@ page-section-list {
|
||||
}
|
||||
// #009b2e
|
||||
}
|
||||
.border-saved-local{
|
||||
border-left: 2px solid rgb(255, 167, 5) !important;
|
||||
h6{
|
||||
margin: 0px !important;
|
||||
color:#bc7a00;
|
||||
}
|
||||
// #009b2e
|
||||
}
|
||||
.completed_note.ng-star-inserted {
|
||||
padding: 2px;
|
||||
/* font-size: 2px; */
|
||||
color: #2b7ecf;
|
||||
/* border: 1px solid lightgray; */
|
||||
p , a {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
p {
|
||||
padding: 0px;
|
||||
margin:0px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
button {
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
61
src/pages/sales_pd/pages/section-list/section-list.ts
Normal file → Executable file
61
src/pages/sales_pd/pages/section-list/section-list.ts
Normal file → Executable file
@ -3,6 +3,7 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||
import { SalesPdProvider } from '../../providers/sales-pd/sales-pd';
|
||||
import { Section9 } from '../home/home';
|
||||
import { ToastProvider } from '../../../../providers/common-provider/toast';
|
||||
import { OfflineManagerProvider } from '../../providers/offline-manager/offline-manager';
|
||||
|
||||
/**
|
||||
* Generated class for the SectionListPage page.
|
||||
@ -22,19 +23,28 @@ export class SectionListPage {
|
||||
all_sections: any;
|
||||
product_id:string
|
||||
sales_pd_id: any;
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private toastProvider:ToastProvider) {
|
||||
is_sync_btn: boolean = false;
|
||||
pd_completed: any = {};
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private toastProvider:ToastProvider,
|
||||
private offlineManager:OfflineManagerProvider) {
|
||||
|
||||
if(this.navParams.get('product_id')){
|
||||
this.product_id=this.navParams.get('product_id')
|
||||
}
|
||||
this.getTemplate()
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad SectionListPage');
|
||||
// this.getSectionData()
|
||||
this.getTemplate()
|
||||
|
||||
}
|
||||
ionViewDidEnter(){
|
||||
setTimeout(()=>{
|
||||
this.getSectionStats()
|
||||
},50)
|
||||
}
|
||||
getSectionStats() {
|
||||
this.SalesPDService.getData_fromLocal('sales_pd_id_PRIMARYKEY').then((key_value)=>{
|
||||
if(key_value && key_value != null && key_value != '' && key_value != undefined){
|
||||
this.sales_pd_id=key_value
|
||||
@ -48,7 +58,7 @@ export class SectionListPage {
|
||||
}
|
||||
else{
|
||||
setTimeout(()=>{
|
||||
console.log("Else part")
|
||||
console.log("Else part",this.section_template.length)
|
||||
if(this.section_template.length > 0)
|
||||
{
|
||||
this.merge_saved_status(res);
|
||||
@ -60,10 +70,32 @@ export class SectionListPage {
|
||||
else{
|
||||
this.sales_pd_id=null
|
||||
}
|
||||
let keyToCheck = 'sales_pd_id'
|
||||
let params:any ={}
|
||||
if(typeof(key_value) == 'string' && key_value.includes('local')) {
|
||||
params.local_pd_id = key_value
|
||||
keyToCheck = 'local_pd_id'
|
||||
}
|
||||
else {
|
||||
params.sales_pd_id = key_value
|
||||
}
|
||||
console.log("#$$$$$",params)
|
||||
if(params[keyToCheck] != null) {
|
||||
return this.offlineManager.checkTheExistingPDLocally(params[keyToCheck],keyToCheck).then(result=>{
|
||||
if(result) {
|
||||
this.pd_completed.is_synced= result.is_pd_completed_sync
|
||||
this.pd_completed.is_completed = result.is_pd_completed
|
||||
this.pd_completed.pd_complete_request_items = result.pd_complete_request_items
|
||||
if(this.pd_completed.is_synced == false || (this.pd_completed.is_completed == false && this.pd_completed.pd_complete_request_items != null)) {
|
||||
this.is_sync_btn = true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
merge_saved_status(res){
|
||||
let saved_sections=res['records'].map(val=>{return {'section_id':val.section_id , 'status':val.status}});
|
||||
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);
|
||||
const mergeById = (a1, a2) =>
|
||||
a1.map(itm => ({
|
||||
@ -71,6 +103,10 @@ export class SectionListPage {
|
||||
...itm
|
||||
}));
|
||||
this.section_template = mergeById(this.section_template,saved_sections);
|
||||
console.log("##########",this.section_template);
|
||||
if(this.section_template.length > 0) {
|
||||
this.is_sync_btn = this.section_template.filter(val=>val.is_synced == false).length > 0
|
||||
}
|
||||
}
|
||||
getTemplate(){
|
||||
|
||||
@ -122,4 +158,21 @@ export class SectionListPage {
|
||||
this.navCtrl.push(Section9,{section_id:section_id})
|
||||
},10)
|
||||
}
|
||||
syncPDWithSections() {
|
||||
this.offlineManager.checkAndSyncPDWithSection(this.sales_pd_id).then(result=>{
|
||||
console.log(result['dataStatus'])
|
||||
if(result['dataStatus']) {
|
||||
this.toastProvider.lenderappmessage("Synced Successfully")
|
||||
setTimeout(()=>{
|
||||
this.navCtrl.pop()
|
||||
},3000)
|
||||
}
|
||||
else {
|
||||
this.toastProvider.lenderappmessage(result['msg'])
|
||||
setTimeout(()=>{
|
||||
this.navCtrl.pop()
|
||||
},3000)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
414
src/pages/sales_pd/providers/offline-manager/offline-manager.ts
Executable file
414
src/pages/sales_pd/providers/offline-manager/offline-manager.ts
Executable file
@ -0,0 +1,414 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { forkJoin } from 'rxjs';
|
||||
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
||||
import { ToastProvider } from '../../../../providers/common-provider/toast';
|
||||
import { LoadingProvider } from '../../../../providers/common-provider/loading';
|
||||
|
||||
/*
|
||||
Generated class for the OfflineManagerProvider provider.
|
||||
|
||||
See https://angular.io/guide/dependency-injection for more info on providers
|
||||
and Angular DI.
|
||||
*/
|
||||
const pd_key ='local_sales_PDs'
|
||||
@Injectable()
|
||||
export class OfflineManagerProvider {
|
||||
|
||||
constructor(private ionicStorage:Storage,private _http:HttpClient,private ionicStorageProvider:IonicStorageProvider,private toastProvider:ToastProvider,
|
||||
private loaderProvider:LoadingProvider) {
|
||||
console.log('Hello OfflineManagerProvider Provider');
|
||||
}
|
||||
|
||||
checkTheExistingPDLocally(key_value,key_to_chek) {
|
||||
return this.ionicStorage.get('local_sales_PDs').then(result=> {
|
||||
if(result) {
|
||||
for(let i=0; i<result.length;i++) {
|
||||
let result_obj =result[i]
|
||||
console.log(result_obj)
|
||||
if(result_obj && result_obj.hasOwnProperty(key_to_chek) && result_obj[key_to_chek] == key_value) {
|
||||
return result_obj
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
getTheLengthOfLocalPDs() {
|
||||
return this.ionicStorage.get('local_sales_PDs').then(result=> {
|
||||
let count=1
|
||||
if(result) {
|
||||
count = result.length+1
|
||||
return 'local-'+count
|
||||
}
|
||||
else{
|
||||
return 'local-'+count
|
||||
}
|
||||
})
|
||||
}
|
||||
getlocalPDData(modified_values,connection_status,request_items?) {
|
||||
if(connection_status == 'online') {
|
||||
console.log("else part")
|
||||
modified_values.is_pd_synced = true;
|
||||
modified_values.is_all_section_synced = null
|
||||
modified_values.is_pd_completed = false
|
||||
modified_values.local_pd_id = null
|
||||
modified_values.dataStatus = true
|
||||
}
|
||||
else{
|
||||
console.log("else part")
|
||||
modified_values.is_pd_synced = false;
|
||||
modified_values.is_all_section_synced = null
|
||||
modified_values.is_pd_completed = false
|
||||
modified_values.is_pd_completed_sync = false
|
||||
modified_values.dataStatus = true
|
||||
modified_values.createdon = new Date();
|
||||
modified_values.status = 'STARTED'
|
||||
modified_values.requests = request_items
|
||||
}
|
||||
return modified_values
|
||||
}
|
||||
addcompleteRequest() {
|
||||
|
||||
}
|
||||
updateSectionData(curr_section,pd_data) {
|
||||
if(pd_data != undefined && pd_data.hasOwnProperty('section_datas') && pd_data.section_datas) {
|
||||
// if(curr_section.sales_pd_id != null) {
|
||||
if(pd_data.section_datas.filter(val=>val.section_id == curr_section.section_id).length > 0){
|
||||
let index = pd_data.section_datas.findIndex(val=>val.section_id == curr_section.section_id)
|
||||
console.log("index $#####",index,curr_section,pd_data)
|
||||
// debugger
|
||||
// pd_data.section_datas[index] = curr_section
|
||||
if(curr_section.section_id == '9' && curr_section.hasOwnProperty('request_items') && curr_section.request_items != null) {
|
||||
let request_items_fresh:any;
|
||||
if(pd_data.section_datas[index].hasOwnProperty('request_items') && pd_data.section_datas[index].request_items != null && pd_data.section_datas[index].request_items != undefined) {
|
||||
pd_data.section_datas[index].request_items.push(curr_section.request_items[0])
|
||||
request_items_fresh = pd_data.section_datas[index].request_items
|
||||
console.log("!st")
|
||||
}
|
||||
else if(pd_data.section_datas[index].request_items == undefined){
|
||||
request_items_fresh = curr_section.request_items
|
||||
console.log("2nt")
|
||||
}
|
||||
else {
|
||||
request_items_fresh = pd_data.section_datas[index].request_items
|
||||
console.log("3rt")
|
||||
}
|
||||
pd_data.section_datas[index] = curr_section
|
||||
pd_data.section_datas[index].request_items = request_items_fresh
|
||||
console.log(pd_data.section_datas[index],request_items_fresh)
|
||||
}
|
||||
else {
|
||||
pd_data.section_datas[index] = curr_section
|
||||
}
|
||||
}
|
||||
else{
|
||||
pd_data.section_datas.push(curr_section)
|
||||
}
|
||||
console.log("Befor update#######33",pd_data.section_datas)
|
||||
let update_section_datas = this.updateSectionStatus(curr_section,pd_data.section_datas)
|
||||
console.log("#########update_sec_data",pd_data.section_datas,update_section_datas);
|
||||
return update_section_datas
|
||||
// }
|
||||
}
|
||||
else{
|
||||
let dummy_section_datas = [curr_section]
|
||||
console.log("Befor Inseret#######33",dummy_section_datas)
|
||||
let update_section_datas = this.updateSectionStatus(curr_section,dummy_section_datas)
|
||||
return update_section_datas
|
||||
}
|
||||
|
||||
}
|
||||
updateSectionStatus(curr_section,section_datas) {
|
||||
|
||||
if(section_datas.length > 0 && (section_datas.filter(val=>val.section_id == "all").length) > 0){
|
||||
// let section_status_arr= section_datas.filter(val=>val.section_id == 'all')[0]
|
||||
for(let i=0;i<section_datas.length;i++) {
|
||||
let section_status_arr=section_datas[i]
|
||||
if(section_status_arr && section_status_arr.section_id == 'all'){
|
||||
console.log("section Status update####################")
|
||||
if(section_status_arr.records.filter(val=>val.section_id == curr_section.section_id).length > 0) {
|
||||
let findIndex = section_status_arr.records.findIndex(val=>val.section_id == curr_section.section_id)
|
||||
section_status_arr.records[findIndex]
|
||||
section_datas[i].records[findIndex].is_synced = curr_section.is_synced ? curr_section.is_synced : false
|
||||
return section_datas
|
||||
}
|
||||
else {
|
||||
section_datas[i].records.push({
|
||||
sales_pd_id: curr_section.sales_pd_id,
|
||||
section_id: curr_section.section_id,
|
||||
status: "1",
|
||||
is_synced:curr_section.is_synced ? curr_section.is_synced : false})
|
||||
return section_datas
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log("section Status INSERT####################")
|
||||
section_datas.push({
|
||||
dataStatus:true,
|
||||
status:true,
|
||||
section_id:'all',
|
||||
records:[{sales_pd_id:curr_section.sales_pd_id,section_id:curr_section.section_id,status:'1', is_synced:curr_section.is_synced}],
|
||||
is_synced:curr_section.is_synced ? curr_section.is_synced : false
|
||||
})
|
||||
return section_datas
|
||||
}
|
||||
}
|
||||
|
||||
getSalesPDSectionLocally(params) {
|
||||
let keyToCheck = 'sales_pd_id'
|
||||
if(typeof(params.sales_pd_id) == 'string' && params.sales_pd_id.includes('local')) {
|
||||
params.local_pd_id = params.sales_pd_id
|
||||
keyToCheck = 'local_pd_id'
|
||||
}
|
||||
return this.checkTheExistingPDLocally(params[keyToCheck],keyToCheck).then(result=>{
|
||||
if(result) {
|
||||
if(result.hasOwnProperty('section_datas') && result.section_datas) {
|
||||
if(result.section_datas.filter(val=>val.section_id == params.section_id).length !=0) {
|
||||
let index = result.section_datas.findIndex(val=>val.section_id == params.section_id)
|
||||
return result.section_datas[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
presentLoader(msg) {
|
||||
|
||||
this.loaderProvider.salesPDLoader(msg)
|
||||
}
|
||||
|
||||
//MAIN FUNCTION FOR ONLINE SYNCING
|
||||
|
||||
checkAndSyncPDWithSection(pd_primary_key) {
|
||||
console.log(pd_primary_key)
|
||||
return new Promise((resolve,reject) =>{
|
||||
let pd_id_key =this.getThePDType(pd_primary_key)
|
||||
// if(pd_id_key == 'local_pd_id') {
|
||||
// PD TO BE SYNCED
|
||||
// console.log("entered")
|
||||
return this.checkTheExistingPDLocally(pd_primary_key,pd_id_key).then(result=>{
|
||||
console.log(result)
|
||||
|
||||
if(pd_id_key == 'local_pd_id') {
|
||||
this.presentLoader('Creating PD...')
|
||||
let request_arr:any =[]
|
||||
request_arr.push(result.requests)
|
||||
console.log(request_arr);
|
||||
return this.sendRequests(request_arr,null).subscribe((api_res:any)=>{
|
||||
console.log("Request successfully sended",api_res);
|
||||
if(api_res && api_res.length > 0) {
|
||||
api_res=api_res[0]
|
||||
}
|
||||
this.loaderProvider.dismissLoader();
|
||||
return this.updatePDData(pd_primary_key,result,{is_pd_synced:true,sales_pd_id:api_res['records'],local_pd_id:null,params:{sales_pd_id:String(api_res['records'])}}).then(local_result => {
|
||||
console.log("local pd is updated",local_result)
|
||||
|
||||
// FOR SECTION TO BE SAVED
|
||||
return this.checkAndSyncPDWithSection(api_res['records']).then(result=>{
|
||||
console.log("Final complete of syncing",result);
|
||||
resolve(result)
|
||||
|
||||
})
|
||||
})
|
||||
},err=>{
|
||||
console.log(err);
|
||||
this.loaderProvider.dismissLoader()
|
||||
})
|
||||
}
|
||||
else if(result.hasOwnProperty('section_datas') && result.section_datas &&
|
||||
result.section_datas.filter(val=>val.is_synced == false && val.section_id != 'all' && val.section_id != 'complete' && val.request_items != null).length > 0){
|
||||
this.presentLoader('Sending Sections and Images....')
|
||||
let section_datas= result.section_datas
|
||||
let section_requests:any =[]
|
||||
section_requests = section_datas.filter(val=>val.is_synced == false && val.section_id != 'all' && val.section_id != 'complete' && val.request_items != null && val.section_id != '9')
|
||||
.map(sec_req=>sec_req.request_items)
|
||||
console.log(section_requests);
|
||||
if(section_datas.filter(val=>val.section_id == '9').length > 0 ) {
|
||||
let photoSection= section_datas.filter(val=>val.section_id == '9').map(sec_req=>sec_req.request_items)[0]
|
||||
if(photoSection && photoSection.length > 0) {
|
||||
console.log("#####3,",photoSection)
|
||||
photoSection.forEach(req_img=>{
|
||||
section_requests.push(req_img)
|
||||
})
|
||||
}
|
||||
}
|
||||
console.log(section_requests);
|
||||
return this.sendRequests(section_requests,pd_primary_key).subscribe((api_res:any)=>{
|
||||
this.loaderProvider.dismissLoader();
|
||||
console.log("Request successfully sended",api_res);
|
||||
section_datas.forEach(val=>{
|
||||
if(val.is_synced == false && val.section_id != 'all' && val.section_id != 'complete' && val.request_items != null){
|
||||
val.is_synced = true
|
||||
val.request_items = null
|
||||
}
|
||||
if(val.section_id == 'all') {
|
||||
if(val.hasOwnProperty('records') && val.records && val.records.length > 0)
|
||||
val.records.forEach(sub_val=>{
|
||||
sub_val.is_synced = true;
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
let updated_values = {is_all_section_synced:true,section_datas:section_datas}
|
||||
return this.updatePDData(pd_primary_key,result,updated_values).then(local_result => {
|
||||
return this.checkAndSyncPDWithSection(pd_primary_key).then(result=>{
|
||||
console.log("Final complete of syncing",result);
|
||||
// let result_val:any={}
|
||||
// result_val = result
|
||||
// result_val.dataStatus = true
|
||||
resolve(result)
|
||||
})
|
||||
})
|
||||
},err=>{
|
||||
console.log(err);
|
||||
this.loaderProvider.dismissLoader()
|
||||
})
|
||||
// return request_arr
|
||||
// this.sendRequests(request_arr).subscribe((api_res:any)=>{
|
||||
// console.log("Request successfully sended",api_res);
|
||||
// if(api_res && api_res.length > 0) {
|
||||
// api_res=api_res[0]
|
||||
// }
|
||||
// return this.updatePDData(pd_primary_key,result,{is_pd_synced:true,sales_pd_id:api_res['records'],local_pd_id:null,params:{sales_pd_id:api_res['records']}}).then(local_result => {
|
||||
// console.log("local pd is updated",local_result)
|
||||
// })
|
||||
// })
|
||||
}
|
||||
else {
|
||||
// PD Completion
|
||||
if(result.hasOwnProperty('is_pd_completed') && result.hasOwnProperty('is_pd_completed_sync')&& result.hasOwnProperty('pd_complete_request_items')
|
||||
&& result.is_pd_completed == true && result.is_pd_completed_sync == false && result.pd_complete_request_items != null) {
|
||||
this.presentLoader("Completing PD...")
|
||||
let request_arr:any =[]
|
||||
request_arr.push(result.pd_complete_request_items)
|
||||
return this.sendRequests(request_arr,pd_primary_key).subscribe((api_res:any)=>{
|
||||
this.loaderProvider.dismissLoader();
|
||||
api_res=api_res[0]
|
||||
console.log("Request successfully sended",api_res,api_res.hasOwnProperty('pd_status') && api_res['pd_status'] == 'DRAFT');
|
||||
if(api_res.hasOwnProperty('pd_status') && api_res['pd_status'] == 'DRAFT'){
|
||||
// this.toastProvider.setAlert("<small>Personal Discussion is not completed<small>","Some of the sections are saved as draft. Kindly check and complete that.")
|
||||
|
||||
let section_redirect=api_res['records']
|
||||
let section_dis_names:any=[];
|
||||
if(section_redirect.length > 0){
|
||||
section_redirect.forEach(res=>{
|
||||
section_dis_names.push(res.sectin_name)
|
||||
})
|
||||
}
|
||||
console.log(section_redirect);
|
||||
|
||||
let alert=this.toastProvider.setAlertWithOkButton("<small>Sales PD is incomplete<small>","The Following sections are not Saved <b>"+section_dis_names+'</b>')
|
||||
alert.present()
|
||||
// alert.onDidDismiss(()=>{
|
||||
// this.redirect_to_section('')
|
||||
// })
|
||||
resolve ({dataStatus:false,msg:"Unable to Complete the PD"})
|
||||
}
|
||||
else{
|
||||
// let updated_values = {is_pd_completed_sync:true,pd_complete_request_items:null,status:'COMPLETED'}
|
||||
// return this.updatePDData(pd_primary_key,result,updated_values).then(local_result => {
|
||||
// resolve ({dataStatus:true,is_all_synced:true})
|
||||
// })
|
||||
return this.deleteCompletedPD(pd_primary_key).then(vl=>{
|
||||
resolve ({dataStatus:true,is_all_synced:true})
|
||||
})
|
||||
}
|
||||
},err=>{
|
||||
console.log(err);
|
||||
this.loaderProvider.dismissLoader()
|
||||
})
|
||||
}
|
||||
else {
|
||||
resolve ({dataStatus:true,is_all_synced:true})
|
||||
}
|
||||
}
|
||||
// this.
|
||||
})
|
||||
})
|
||||
// }
|
||||
// else {
|
||||
// // FUNCTION FOR SECTION SAVING
|
||||
// return
|
||||
// }
|
||||
|
||||
}
|
||||
deleteCompletedPD(pd_id) {
|
||||
return this.ionicStorage.get(pd_key).then(result => {
|
||||
let result_arr = result
|
||||
if(result_arr && result_arr.length > 0) {
|
||||
let updated_local_pds = result_arr.filter(val=>val.sales_pd_id != pd_id)
|
||||
console.log(updated_local_pds)
|
||||
return this.ionicStorage.set(pd_key,updated_local_pds).then(inserted_res=>{
|
||||
return inserted_res
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
updatePDData(pd_primary_key,result_obj,updated_values) {
|
||||
// return this.ionicStorage.get(pd_key).then(result=>{
|
||||
// if(result && result.length > 0) {
|
||||
// // for(let val_obj of result) {
|
||||
// let pd_id_key =this.getThePDType(pd_primary_key)
|
||||
// let findIndex = result.findIndex(val=>val[pd_id_key] == pd_primary_key)
|
||||
// if(findIndex) {
|
||||
// result[findIndex]
|
||||
// Object.assign(result[findIndex],updated_values)
|
||||
// console.log("changed values",result[findIndex])
|
||||
// }
|
||||
// // }
|
||||
// }
|
||||
// })
|
||||
if(result_obj) {
|
||||
let pd_id_key =this.getThePDType(pd_primary_key)
|
||||
Object.assign(result_obj,updated_values)
|
||||
console.log(result_obj)
|
||||
let paramsToCompare :any ={};
|
||||
paramsToCompare[pd_id_key] = String(pd_primary_key)
|
||||
console.log(paramsToCompare)
|
||||
return this.ionicStorageProvider.insertDataWithoutReplace(pd_key,result_obj,paramsToCompare).then(result =>{
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
// local or synced pd
|
||||
getThePDType(pd_id){
|
||||
if(pd_id != null && typeof(pd_id) == 'string' && pd_id.includes('local')) {
|
||||
return 'local_pd_id'
|
||||
}
|
||||
else{
|
||||
return 'sales_pd_id'
|
||||
}
|
||||
}
|
||||
sendRequests(operations,pd_id) {
|
||||
let obs = [];
|
||||
for (let op of operations) {
|
||||
console.log('Make one request: ', op);
|
||||
let params = JSON.parse(op.params)
|
||||
if(params.hasOwnProperty('records')) {
|
||||
if(params.records.hasOwnProperty('sales_pd_id')) {
|
||||
params.records.sales_pd_id = pd_id
|
||||
}
|
||||
else if(params.records.hasOwnProperty('fk_sales_pd_id')){
|
||||
params.records.fk_sales_pd_id = pd_id
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(params.hasOwnProperty('sales_pd_id')) {
|
||||
params.sales_pd_id = pd_id
|
||||
}
|
||||
else if(params.hasOwnProperty('fk_sales_pd_id')){
|
||||
params.fk_sales_pd_id = pd_id
|
||||
}
|
||||
}
|
||||
let oneObs = this._http.request(op.method, op.url, {body:params});
|
||||
obs.push(oneObs);
|
||||
console.log(params);
|
||||
}
|
||||
|
||||
|
||||
// Send out all local events and return once they are finished
|
||||
return forkJoin(obs);
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,15 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ConstantsProvider } from '../../../../providers/constants/constants';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { catchError, retry } from 'rxjs/operators';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { AwsServiceProvider } from '../../../../providers/aws-service/aws-service';
|
||||
import { Observable, Observer } from 'rxjs';
|
||||
import { CameraProvider } from '../camera/camera';
|
||||
import { NetworkDetectionProvider, ConnectionStatus } from '../../../../providers/network-detection/network-detection';
|
||||
import { IonicStorageProvider } from '../../../../providers/ionic-storage/ionic-storage';
|
||||
import { OfflineManagerProvider } from '../offline-manager/offline-manager';
|
||||
import { PdtriggerProvider } from '../../../../providers/pdtrigger/pdtrigger';
|
||||
// import {environment} from '../../../../providers/constants/constants'
|
||||
|
||||
/*
|
||||
@ -14,7 +18,7 @@ import { CameraProvider } from '../camera/camera';
|
||||
See https://angular.io/guide/dependency-injection for more info on providers
|
||||
and Angular DI.
|
||||
*/
|
||||
|
||||
const pd_key ='local_sales_PDs'
|
||||
@Injectable()
|
||||
|
||||
export class SalesPdProvider {
|
||||
@ -22,17 +26,34 @@ apiUrl:string;
|
||||
available_sections:any;
|
||||
original_rawData:any;
|
||||
current_section:any;
|
||||
constructor(public http: HttpClient,private constantProvider:ConstantsProvider,private storage:Storage,private aws:AwsServiceProvider,private cameraService:CameraProvider) {
|
||||
constructor(public http: HttpClient,private constantProvider:ConstantsProvider,private storage:Storage,private aws:AwsServiceProvider,private cameraService:CameraProvider,
|
||||
private networkProvider:NetworkDetectionProvider,private ionicStorageProvider:IonicStorageProvider,private offlineManagerProvider:OfflineManagerProvider) {
|
||||
console.log('Hello SalesPdProvider Provider');
|
||||
this.apiUrl=this.constantProvider.environment().url
|
||||
}
|
||||
getData(product_id){
|
||||
let users:any=localStorage.getItem('user_details')
|
||||
users=JSON.parse(users)
|
||||
return this.http.post(this.apiUrl+'loadSalesPDTemplate',{records:{lender_id:users.fk_entity_id,product_id:product_id}})
|
||||
|
||||
let params = {records:{lender_id:users.fk_entity_id,product_id:product_id}}
|
||||
return Observable.create((observer:any)=>{
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
return this.http.post(this.apiUrl+'loadSalesPDTemplate',{records:{lender_id:users.fk_entity_id,product_id:product_id}}).subscribe(result=>{
|
||||
return this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,'loadSalesPDTemplate',true).then(res=>{
|
||||
observer.next(result)
|
||||
observer.complete();
|
||||
})
|
||||
})
|
||||
}
|
||||
else {
|
||||
return this.ionicStorageProvider.getApiDataFromLocally(params,'loadSalesPDTemplate').subscribe(result=>{
|
||||
observer.next(result)
|
||||
observer.complete();
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
saveQuestions(params): Observable<Response>{
|
||||
let result_from_api:any;
|
||||
let userid:any=localStorage.getItem("user_details")
|
||||
userid=JSON.parse(userid).userid;
|
||||
params.createdby=userid
|
||||
@ -45,13 +66,258 @@ current_section:any;
|
||||
params.sales_pd_id=key_value,
|
||||
params.lender_id=users.fk_entity_id,
|
||||
params.product_id=product_id
|
||||
return this.http.post(this.apiUrl+'saveSalesPD',{records:params}).pipe().subscribe(result => {
|
||||
observer.next(result);
|
||||
observer.complete();
|
||||
let modified_values =params;
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online && (key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true) : true)) {
|
||||
return this.http.post(this.apiUrl+'saveSalesPD',{records:params}).pipe().subscribe(result => {
|
||||
// let result = {dataStatus:false,records:{}};
|
||||
result_from_api =result
|
||||
// else{
|
||||
if(!params.hasOwnProperty('status') && params.status != 'COMPLETED') {
|
||||
if(params.sales_pd_id != null) {
|
||||
modified_values.sales_pd_id = params.sales_pd_id
|
||||
}
|
||||
else{
|
||||
modified_values.sales_pd_id = result['records']
|
||||
}
|
||||
}
|
||||
if(params.hasOwnProperty('status') && params.status == 'COMPLETED') {
|
||||
if(!result_from_api.hasOwnProperty('pd_status') && result_from_api['pd_status'] != 'DRAFT'){
|
||||
this.offlineManagerProvider.deleteCompletedPD(params.sales_pd_id).then(rd=>{
|
||||
observer.next(result_from_api);
|
||||
observer.complete();
|
||||
})
|
||||
}
|
||||
else{
|
||||
observer.next(result_from_api);
|
||||
observer.complete();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.checkAndCreatePDLocally(modified_values,params,'online').then(lc=>{
|
||||
|
||||
observer.next(result_from_api);
|
||||
observer.complete();
|
||||
})
|
||||
}
|
||||
// }
|
||||
})
|
||||
}
|
||||
else if(params.hasOwnProperty('status') && params.status == 'COMPLETED') {
|
||||
let pd_id_key =this.offlineManagerProvider.getThePDType(modified_values.sales_pd_id)
|
||||
this.offlineManagerProvider.checkTheExistingPDLocally(modified_values.sales_pd_id,pd_id_key).then(result=>{
|
||||
console.log(result)
|
||||
if(result && result.hasOwnProperty('section_datas') && result.section_datas.length > 0){
|
||||
// let product_id = localStorage.getItem('product_id_salesPD');
|
||||
let pd_section_datas = result.section_datas.filter(val=>val.section_id != 'all').map(val1=>val1.section_name)
|
||||
let template_sections:any = localStorage.getItem('question_temp_salespd')
|
||||
template_sections = JSON.parse(template_sections).sections.map(val1=>val1.section_name)
|
||||
console.log(template_sections,pd_section_datas);
|
||||
if(template_sections.length != pd_section_datas.length+1){
|
||||
let unsavedSections = template_sections.filter(function(item) {
|
||||
return !pd_section_datas.includes(item);
|
||||
})
|
||||
// let unsavedSections = template_sections.filter(o => pd_section_datas.some(({section_id,name}) => o.section_id != section_id));
|
||||
console.log(unsavedSections);
|
||||
let unsavedObj:any=[]
|
||||
unsavedSections.forEach((val,index)=>{
|
||||
unsavedObj.push({id:index,sectin_name:val})
|
||||
})
|
||||
if(unsavedSections.length > 0) {
|
||||
let local_result = {
|
||||
'pd_status': 'DRAFT',
|
||||
'records':unsavedObj,
|
||||
'dataStatus':true
|
||||
}
|
||||
observer.next(local_result);
|
||||
observer.complete();
|
||||
return
|
||||
}
|
||||
// return
|
||||
}
|
||||
}
|
||||
let req_params = {url:this.apiUrl+'saveSalesPD',
|
||||
params:JSON.stringify({records:params}),method:'POST'}
|
||||
this.checkAndCreatePDLocally(modified_values,params,'offline',req_params).then(lc=>{
|
||||
console.log("last offline",lc);
|
||||
if(params.hasOwnProperty('status') && params.status != 'COMPLETED') {
|
||||
result_from_api ={dataStatus:true,records:lc.local_pd_id}
|
||||
}
|
||||
else{
|
||||
result_from_api = {dataStatus:true,records:true}
|
||||
}
|
||||
console.log("at last ",result_from_api,params);
|
||||
// this.insertData_Replace('sales_pd_id_PRIMARYKEY',lc.local_pd_id).then(resul=>{
|
||||
observer.next(result_from_api);
|
||||
observer.complete();
|
||||
// })
|
||||
})
|
||||
})
|
||||
}
|
||||
else{
|
||||
if(params.hasOwnProperty('status') && params.status != 'COMPLETED') {
|
||||
modified_values.sales_pd_id = null
|
||||
}
|
||||
let req_params = {url:this.apiUrl+'saveSalesPD',
|
||||
params:JSON.stringify({records:params}),method:'POST'}
|
||||
let dd = {product_id:modified_values.product_id,lender_id:modified_values.lender_id}
|
||||
this.getProductAbbrbyId(dd).then(product_abbr=>{
|
||||
modified_values.abbr = product_abbr
|
||||
this.checkAndCreatePDLocally(modified_values,params,'offline',req_params).then(lc=>{
|
||||
console.log("last offline",lc);
|
||||
if(params.hasOwnProperty('status') && params.status != 'COMPLETED') {
|
||||
result_from_api ={dataStatus:true,records:lc.local_pd_id}
|
||||
}
|
||||
else{
|
||||
result_from_api = {dataStatus:true,records:true}
|
||||
}
|
||||
console.log("at last ",result_from_api,params);
|
||||
// this.insertData_Replace('sales_pd_id_PRIMARYKEY',lc.local_pd_id).then(resul=>{
|
||||
observer.next(result_from_api);
|
||||
observer.complete();
|
||||
// })
|
||||
})
|
||||
})
|
||||
}
|
||||
// observer.next(result_from_api);
|
||||
// observer.complete();
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
checkAndCreatePDLocally(modified_values,params,connection_status,request_items?,section_data?) {
|
||||
let paramsCompare;
|
||||
if(modified_values.sales_pd_id != null && modified_values.sales_pd_id != undefined && typeof(modified_values.sales_pd_id) == 'string') {
|
||||
console.log(modified_values.sales_pd_id);
|
||||
console.log("######### local pd id ",modified_values.sales_pd_id.includes('local'))
|
||||
if(modified_values.sales_pd_id.includes('local')) {
|
||||
modified_values.local_pd_id=modified_values.sales_pd_id
|
||||
modified_values.sales_pd_id =null
|
||||
}
|
||||
}
|
||||
if(modified_values.sales_pd_id != null) {
|
||||
return this.offlineManagerProvider.checkTheExistingPDLocally(modified_values.sales_pd_id,'sales_pd_id').then(result=>{
|
||||
console.log("offline result",result);
|
||||
// debugger;
|
||||
if(result || result != undefined) {
|
||||
paramsCompare = {sales_pd_id : modified_values.sales_pd_id}
|
||||
modified_values = result
|
||||
if(params.hasOwnProperty('status') && params.stautus == 'COMPLETED') {
|
||||
modified_values = result
|
||||
modified_values.dataStatus = true
|
||||
}
|
||||
if(section_data) {
|
||||
if(section_data.section_id == '1' && section_data.hasOwnProperty('questions') && section_data.questions.filter(val=>val.question_key == 'company_name').length > 0) {
|
||||
let company_ques_index = section_data.questions.findIndex(val=>val.question_key == "company_name")
|
||||
modified_values.applicant_name = section_data.questions[company_ques_index].answer_value
|
||||
}
|
||||
|
||||
let update_section_datas =this.offlineManagerProvider.updateSectionData(section_data,result)
|
||||
modified_values.section_datas = update_section_datas
|
||||
if(modified_values.section_datas.length > 0 && modified_values.section_datas.filter(val=>val.is_synced == false).length > 0){
|
||||
modified_values.is_all_section_synced = false
|
||||
}
|
||||
}
|
||||
if(params.hasOwnProperty('status') && params.status == 'COMPLETED') {
|
||||
if(connection_status == 'offline'){
|
||||
modified_values.is_pd_completed = true;
|
||||
modified_values.is_pd_completed_sync = false
|
||||
modified_values.status = '_COMPLETED'
|
||||
modified_values.pd_complete_request_items = request_items
|
||||
}
|
||||
else {
|
||||
modified_values.is_pd_completed = true;
|
||||
modified_values.is_pd_completed_sync = true
|
||||
}
|
||||
}
|
||||
// this.offlineManagerProvider.getlocalPDData(modified_values,connection_status,request_items)
|
||||
}
|
||||
else{
|
||||
// console.clear();
|
||||
// console.log("check c",modified_values)
|
||||
paramsCompare = {sales_pd_id:String(modified_values.sales_pd_id)}
|
||||
if(section_data) {
|
||||
if(section_data.section_id == '1' && section_data.hasOwnProperty('questions') && section_data.questions.filter(val=>val.question_key == 'company_name').length > 0) {
|
||||
let company_ques_index = section_data.questions.findIndex(val=>val.question_key == "company_name")
|
||||
modified_values.applicant_name = section_data.questions[company_ques_index].answer_value
|
||||
}
|
||||
|
||||
let update_section_datas =this.offlineManagerProvider.updateSectionData(section_data,result)
|
||||
modified_values.section_datas = update_section_datas
|
||||
if(modified_values.section_datas.length > 0 && modified_values.section_datas.filter(val=>val.is_synced == false).length > 0){
|
||||
modified_values.is_all_section_synced = false
|
||||
}
|
||||
}
|
||||
this.offlineManagerProvider.getlocalPDData(modified_values,connection_status,request_items)
|
||||
}
|
||||
return this.ionicStorageProvider.checkAndInsertApiDataLocally(modified_values,paramsCompare,pd_key,true).then(res=>{
|
||||
return modified_values
|
||||
})
|
||||
})
|
||||
}
|
||||
else {
|
||||
return this.offlineManagerProvider.getTheLengthOfLocalPDs().then(Res=>{
|
||||
return this.offlineManagerProvider.checkTheExistingPDLocally(modified_values.local_pd_id,'local_pd_id').then(result=>{
|
||||
console.log("local pd id",result,params.local_pd_id);
|
||||
if((result || result != undefined) && modified_values.local_pd_id != undefined) {
|
||||
paramsCompare = {local_pd_id:modified_values.local_pd_id}
|
||||
modified_values = result
|
||||
if(section_data) {
|
||||
if(section_data.section_id == '1' && section_data.hasOwnProperty('questions') && section_data.questions.filter(val=>val.question_key == 'company_name').length > 0) {
|
||||
let company_ques_index = section_data.questions.findIndex(val=>val.question_key == "company_name")
|
||||
modified_values.applicant_name = section_data.questions[company_ques_index].answer_value
|
||||
}
|
||||
|
||||
let update_section_datas =this.offlineManagerProvider.updateSectionData(section_data,result)
|
||||
modified_values.section_datas = update_section_datas
|
||||
if(modified_values.section_datas.length > 0 && modified_values.section_datas.filter(val=>val.is_synced == false).length > 0){
|
||||
modified_values.is_all_section_synced = false
|
||||
}
|
||||
}
|
||||
if(params.hasOwnProperty('status') && params.status == 'COMPLETED') {
|
||||
if(connection_status == 'offline'){
|
||||
modified_values.is_pd_completed = true;
|
||||
modified_values.is_pd_completed_sync = false
|
||||
modified_values.pd_complete_request_items = request_items
|
||||
modified_values.status = '_COMPLETED'
|
||||
}
|
||||
else {
|
||||
modified_values.is_pd_completed = true;
|
||||
modified_values.is_pd_completed_sync = true
|
||||
}
|
||||
}
|
||||
// this.offlineManagerProvider.getlocalPDData(modified_values,connection_status,request_items)
|
||||
}
|
||||
else {
|
||||
console.log("Else##########",Res)
|
||||
let pd_id:string= '1'
|
||||
if(Res){
|
||||
pd_id =Res
|
||||
}
|
||||
paramsCompare = {local_pd_id:pd_id}
|
||||
modified_values.local_pd_id = pd_id
|
||||
if(section_data) {
|
||||
if(section_data.section_id == '1' && section_data.hasOwnProperty('questions') && section_data.questions.filter(val=>val.question_key == 'company_name').length > 0) {
|
||||
let company_ques_index = section_data.questions.findIndex(val=>val.question_key == "company_name")
|
||||
modified_values.applicant_name = section_data.questions[company_ques_index].answer_value
|
||||
}
|
||||
|
||||
let update_section_datas =this.offlineManagerProvider.updateSectionData(section_data,result)
|
||||
modified_values.section_datas = update_section_datas
|
||||
if(modified_values.section_datas.length > 0 && modified_values.section_datas.filter(val=>val.is_synced == false).length > 0){
|
||||
modified_values.is_all_section_synced = false
|
||||
}
|
||||
}
|
||||
this.offlineManagerProvider.getlocalPDData(modified_values,connection_status,request_items)
|
||||
|
||||
}
|
||||
return this.ionicStorageProvider.checkAndInsertApiDataLocally(modified_values,paramsCompare,pd_key,true).then(res=>{
|
||||
return modified_values
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
saveSalesPDSection(params){
|
||||
let users:any=localStorage.getItem('user_details')
|
||||
users=JSON.parse(users)
|
||||
@ -59,28 +325,88 @@ current_section:any;
|
||||
return Observable.create((observer:Observer<any>)=>{
|
||||
this.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
params.sales_pd_id=key_value
|
||||
let values={sales_pd_id:key_value,dataStatus:true}
|
||||
let section_data=JSON.stringify({section_id:params.section_id,section_name:params.section_name,onsubmit:null,questions:params.questions})
|
||||
let modified_params = params
|
||||
console.log("###################$%%",(key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true ) : true));
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online && (key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true ) : true) ) {
|
||||
return this.http.post(this.apiUrl+'saveSalesPDsection',{records:params}).pipe().subscribe(response=>{
|
||||
// delete modified_params.questions
|
||||
modified_params.is_synced = true;
|
||||
modified_params.section_data = section_data
|
||||
if(modified_params.section_id != '9'){
|
||||
this.checkAndCreatePDLocally(values,'','online','',modified_params).then(res=>{
|
||||
observer.next(response)
|
||||
observer.complete()
|
||||
})
|
||||
}
|
||||
else {
|
||||
observer.next(response)
|
||||
observer.complete()
|
||||
}
|
||||
})
|
||||
}
|
||||
else if(modified_params.section_id != '9'){
|
||||
// console.log("#######params",modified_params)
|
||||
let offline_params = modified_params
|
||||
offline_params.request_items={url:this.apiUrl+'saveSalesPDsection',
|
||||
params:JSON.stringify({records:params}),method:'POST'}
|
||||
offline_params.is_synced = false
|
||||
offline_params.section_data = section_data
|
||||
console.log(offline_params.request_items.params)
|
||||
this.checkAndCreatePDLocally(values,'','offline','',offline_params).then(res=>{
|
||||
observer.next({dataStatus:true});
|
||||
observer.complete()
|
||||
})
|
||||
}
|
||||
else{
|
||||
observer.next({dataStatus:true});
|
||||
observer.complete()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
api_post_method(api_name:string,params,api_method?){
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
if(api_method.toUpperCase() == 'POST'){
|
||||
return this.http.post(this.apiUrl+api_name,params)
|
||||
return this.http.post(this.apiUrl+api_name,params).map(result=> {
|
||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,api_name,true);
|
||||
return result
|
||||
})
|
||||
}
|
||||
else{
|
||||
return this.http.get(this.apiUrl+api_name)
|
||||
return this.http.get(this.apiUrl+api_name).map(result=> {
|
||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,api_name);
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
return this.ionicStorageProvider.getApiDataFromLocally(params,api_name)
|
||||
}
|
||||
}
|
||||
getCityPincode(value){
|
||||
let params={records:{state_id:value}}
|
||||
return this.http.post(this.apiUrl+"getListOfStatesAndCities",params)
|
||||
return Observable.create((observer:any)=>{
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
return this.http.post(this.apiUrl+"getListOfStatesAndCities",params).subscribe(result=>{
|
||||
return this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,'getListOfStatesAndCities',true).then(res=>{
|
||||
observer.next(result);
|
||||
observer.complete();
|
||||
})
|
||||
})
|
||||
}
|
||||
else {
|
||||
return this.ionicStorageProvider.getApiDataFromLocally(params,'getListOfStatesAndCities').subscribe(result=>{
|
||||
observer.next(result);
|
||||
observer.complete();
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
insertData_Replace(key,data){
|
||||
console.log(key)
|
||||
// console.log(key)
|
||||
return this.storage.set(key,data);
|
||||
}
|
||||
// insertData_noReplace(key,data){
|
||||
@ -98,7 +424,7 @@ current_section:any;
|
||||
// }
|
||||
getData_fromLocal(key){
|
||||
// console.log("get data key",this.getKey(key));
|
||||
console.log("get data provider",this.storage.get(key))
|
||||
// console.log("get data provider",this.storage.get(key))
|
||||
// console.log("all key in storage",this.storage.keys())
|
||||
return this.storage.get(key);
|
||||
}
|
||||
@ -113,16 +439,16 @@ current_section:any;
|
||||
sendData(sections){
|
||||
return new Promise((resolve,reject)=>{
|
||||
let values_arr:any=[];
|
||||
console.log("as",sections)
|
||||
// console.log("as",sections)
|
||||
for(let i of sections){
|
||||
console.log("single sec",i);
|
||||
// console.log("single sec",i);
|
||||
this.storage.get('sec'+i).then(local_value=>{
|
||||
console.log("value",local_value)
|
||||
// console.log("value",local_value)
|
||||
values_arr.push(local_value)
|
||||
|
||||
if(sections.indexOf(i) == sections.length -1){
|
||||
resolve(values_arr)
|
||||
console.log("total",values_arr,sections.indexOf(i))
|
||||
// console.log("total",values_arr,sections.indexOf(i))
|
||||
return
|
||||
}
|
||||
})
|
||||
@ -132,35 +458,73 @@ current_section:any;
|
||||
}
|
||||
getSalesPDList(){
|
||||
// let params = new HttpParams().set("paramName",paramValue)
|
||||
|
||||
// console.log("Api Stauts ",this.networkProvider.getCurrentNetworkStatus())
|
||||
let det:any=localStorage.getItem('user_details')
|
||||
det=JSON.parse(det)
|
||||
return this.http.get(this.apiUrl+'listSalesPD/'+det.fk_entity_id+'/'+det.userid)
|
||||
let params = {'fk_entity_id':det.fk_entity_id,userid:det.userid}
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
return this.http.get(this.apiUrl+'listSalesPD/'+det.fk_entity_id+'/'+det.userid).map(res=>{
|
||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(res,params,'listSalesPD');
|
||||
return res;
|
||||
})
|
||||
}
|
||||
else{
|
||||
return this.ionicStorageProvider.getApiDataFromLocally(params,'listSalesPD');
|
||||
}
|
||||
}
|
||||
saveSalesPDImage(params): Observable<Response>{
|
||||
saveSalesPDImage(params,form_structure?): Observable<Response>{
|
||||
return Observable.create((observer:Observer<any>) => {
|
||||
this.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
this.cameraService.getGeoTag().then(geoCords=>{
|
||||
params.location=geoCords
|
||||
params.fk_sales_pd_id=key_value,
|
||||
params.fk_sales_pd_id=key_value
|
||||
// let values={sales_pd_id:key_value,dataStatus:true}
|
||||
// let section_data=JSON.stringify({section_id:form_structure.section_id,section_name:form_structure.section_name,onsubmit:null,questions:form_structure.questions})
|
||||
// let modified_params = form_structure
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online && (key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true) : true)) {
|
||||
this.http.post(this.apiUrl+'saveSalesPDImage',{records:params},{
|
||||
reportProgress: true,
|
||||
}).pipe().subscribe(result => {
|
||||
// modified_params.is_synced = true
|
||||
// modified_params.section_data = section_data
|
||||
// this.checkAndCreatePDLocally(values,'','online','',modified_params).then(res=>{
|
||||
observer.next(result);
|
||||
observer.complete();
|
||||
// })
|
||||
},err=>{
|
||||
console.clear();
|
||||
console.log("err>>>>",err)
|
||||
// console.log("err>>>>",err)
|
||||
observer.next(err);
|
||||
observer.complete();
|
||||
})
|
||||
}
|
||||
else {
|
||||
// console.log("#######params",modified_params)
|
||||
// let offline_params = modified_params
|
||||
// offline_params.request_items=[{url:this.apiUrl+'saveSalesPDImage',
|
||||
// params:JSON.stringify({records:params}),method:'POST'}]
|
||||
// offline_params.is_synced = false
|
||||
// offline_params.section_data = section_data
|
||||
// console.log(offline_params)
|
||||
// debugger
|
||||
// this.checkAndCreatePDLocally(values,'','offline','',offline_params).then(res=>{
|
||||
observer.next({dataStatus:true});
|
||||
observer.complete()
|
||||
// })
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
generateSatelliteImg(params):Observable<Response> {
|
||||
generateSatelliteImg(params,form_structure):Observable<Response> {
|
||||
return Observable.create((observer:Observer<any>)=>{
|
||||
this.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
params.sales_pd_id = key_value
|
||||
let values={sales_pd_id:key_value,dataStatus:true}
|
||||
let section_data=JSON.stringify({section_id:form_structure.section_id,section_name:form_structure.section_name,onsubmit:null,questions:form_structure.questions})
|
||||
let modified_params = form_structure
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online && (key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true) : true)) {
|
||||
this.http.post(this.apiUrl+'generateSatelliteImg',params).pipe()
|
||||
.subscribe(result =>{
|
||||
observer.next(result);
|
||||
@ -172,6 +536,20 @@ current_section:any;
|
||||
observer.next(err);
|
||||
observer.complete();
|
||||
})
|
||||
}
|
||||
else {
|
||||
console.log("#######params",modified_params)
|
||||
let offline_params = modified_params
|
||||
offline_params.request_items=[{url:this.apiUrl+'generateSatelliteImg',
|
||||
params:JSON.stringify(params),method:'POST'}]
|
||||
offline_params.is_synced = false
|
||||
offline_params.section_data = section_data
|
||||
console.log(offline_params.request_items.params)
|
||||
this.checkAndCreatePDLocally(values,'','offline','',offline_params).then(res=>{
|
||||
observer.next({dataStatus:true});
|
||||
observer.complete()
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -180,19 +558,148 @@ current_section:any;
|
||||
return this.http.get<any[]>(this.apiUrl + "downloadSalesPDReport/" + pdfdetail)
|
||||
}
|
||||
getSalesPDSectionData(params){
|
||||
return this.http.post(this.apiUrl+'getSalesPDSectionData',{records:params})
|
||||
console.log(params)
|
||||
return Observable.create((observer:Observer<any>)=>{
|
||||
this.offlineManagerProvider.getSalesPDSectionLocally(params).then(result => {
|
||||
if(result != undefined) {
|
||||
let modified_result:any={};
|
||||
if(params.section_id == 'all'){
|
||||
modified_result = result
|
||||
}
|
||||
else {
|
||||
modified_result.records = [result]
|
||||
modified_result.dataStatus = true
|
||||
modified_result.status = 200
|
||||
console.clear()
|
||||
}
|
||||
console.log(modified_result)
|
||||
observer.next(modified_result);
|
||||
observer.complete()
|
||||
|
||||
}
|
||||
else if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
let values={sales_pd_id:params.sales_pd_id,dataStatus:true}
|
||||
return this.http.post(this.apiUrl+'getSalesPDSectionData',{records:params}).subscribe(result =>{
|
||||
let modified_values:any =result
|
||||
modified_values.section_id = params.section_id
|
||||
if(result['dataStatus']) {
|
||||
if(params.section_id != 'all') {
|
||||
modified_values = result['records'][0]
|
||||
modified_values.is_synced = true
|
||||
}
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
this.checkAndCreatePDLocally(values,'','online','',modified_values).then(res=>{
|
||||
observer.next(result);
|
||||
observer.complete()
|
||||
})
|
||||
}
|
||||
else {
|
||||
observer.next(result);
|
||||
observer.complete()
|
||||
}
|
||||
}
|
||||
else{
|
||||
observer.next(result);
|
||||
observer.complete()
|
||||
}
|
||||
},err=>{
|
||||
observer.next(err);
|
||||
observer.complete();
|
||||
})
|
||||
}
|
||||
else {
|
||||
console.log("No Data Found#########");
|
||||
// observer.error({err_msg:'No Data Found'})
|
||||
// Observable.throw(new Error('No Data Found'))
|
||||
observer.next({dataStatus:false})
|
||||
observer.complete()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
clear_local_key(key){
|
||||
return this.storage.remove(key)
|
||||
}
|
||||
|
||||
getAllMasterDatas(TableName: string): Observable<any> {
|
||||
return this.http.post(this.apiUrl + 'getListOfMaster', { "master_name": TableName })
|
||||
.pipe(
|
||||
// catchError(this.handleError('role', []))
|
||||
)
|
||||
let params = { "master_name": TableName }
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
return this.http.post(this.apiUrl + 'getListOfMaster', { "master_name": TableName }).map(result=>{
|
||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,'getListOfMaster',true);
|
||||
return result
|
||||
})
|
||||
}
|
||||
else {
|
||||
return this.ionicStorageProvider.getApiDataFromLocally(params,'getListOfMaster');
|
||||
}
|
||||
}
|
||||
advancedFilter(params): Observable<any>{
|
||||
return this.http.post(this.apiUrl+'filterSalesPDList',{"records":params})
|
||||
}
|
||||
getProductAbbrbyId(obj) {
|
||||
if(obj){
|
||||
return new Promise((resolve,reject)=>{
|
||||
return this.getEntityPreferences(obj.lender_id).subscribe(result=>{
|
||||
if(result && result['dataStatus']) {
|
||||
let productforLender = result['records'].salespd_products
|
||||
if(productforLender && productforLender.length > 0) {
|
||||
let product_abbr = productforLender.filter(val=>val.product_id == obj.product_id).map(va=>va.product_abbr)[0]
|
||||
resolve(product_abbr)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
getEntityPreferences(entity_id){
|
||||
// return this.http.get(this.apiurl+'getEntityPreferences/'+entity_id);
|
||||
let params = {entity_id:entity_id}
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
return this.http.get(this.apiUrl+'getEntityPreferences/'+entity_id).map(result=>{
|
||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,'getEntityPreferences');
|
||||
return result;
|
||||
})
|
||||
}
|
||||
else {
|
||||
return this.ionicStorageProvider.getApiDataFromLocally(params,'getEntityPreferences');
|
||||
}
|
||||
}
|
||||
updateSectionDataLocally(params,form_structure){
|
||||
return Observable.create((observer:Observer<any>) => {
|
||||
this.getData_fromLocal('sales_pd_id_PRIMARYKEY').then(key_value=>{
|
||||
// params.location=geoCords
|
||||
params.fk_sales_pd_id=key_value
|
||||
let values={sales_pd_id:key_value,dataStatus:true}
|
||||
let section_data=JSON.stringify({section_id:form_structure.section_id,section_name:form_structure.section_name,onsubmit:null,questions:form_structure.questions})
|
||||
let modified_params = form_structure
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online && (key_value != null ? (typeof(key_value) == 'string' ? !key_value.includes('local') : true) : true)) {
|
||||
modified_params.is_synced = true
|
||||
modified_params.section_data = section_data
|
||||
this.checkAndCreatePDLocally(values,'','online','',modified_params).then(res=>{
|
||||
observer.next('');
|
||||
observer.complete();
|
||||
})
|
||||
// },err=>{
|
||||
// console.clear();
|
||||
// // console.log("err>>>>",err)
|
||||
// observer.next(err);
|
||||
// observer.complete();
|
||||
// })
|
||||
}
|
||||
else {
|
||||
// console.log("#######params",modified_params)
|
||||
let offline_params = modified_params
|
||||
offline_params.request_items=[{url:this.apiUrl+'saveSalesPDImage',
|
||||
params:JSON.stringify({records:params}),method:'POST'}]
|
||||
offline_params.is_synced = false
|
||||
offline_params.section_data = section_data
|
||||
console.log(offline_params)
|
||||
this.checkAndCreatePDLocally(values,'','offline','',offline_params).then(res=>{
|
||||
observer.next({dataStatus:true});
|
||||
observer.complete()
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpSentEvent |
|
||||
this.isRefreshingToken=false
|
||||
this.tokenSubject.next(newToken);
|
||||
|
||||
return next.handle(this.addToken(req, cognitoService.getToken().getIdToken().getJwtToken()))
|
||||
return <any>next.handle(this.addToken(req, cognitoService.getToken().getIdToken().getJwtToken()))
|
||||
}
|
||||
const awsService=this.injector.get(AwsServiceProvider)
|
||||
return awsService.logout();
|
||||
@ -137,7 +137,7 @@ intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpSentEvent |
|
||||
// // .filter(token => token != null)
|
||||
// .take(1)
|
||||
// .switchMap(token => {
|
||||
return next.handle(this.addToken(req, cognitoService.getToken().getIdToken().getJwtToken()));
|
||||
return <any>next.handle(this.addToken(req, cognitoService.getToken().getIdToken().getJwtToken()));
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,106 +0,0 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import {
|
||||
HttpRequest,
|
||||
HttpHandler,
|
||||
HttpEvent,
|
||||
HttpInterceptor,
|
||||
HttpHeaders
|
||||
} from '@angular/common/http';
|
||||
// import { AuthGuard } from './auth.guard';
|
||||
import { Observable, of} from 'rxjs';
|
||||
|
||||
// import { Router } from '@angular/router';
|
||||
|
||||
import { catchError, map, tap } from 'rxjs/operators';
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
|
||||
import { CognitoServiceProvider } from '../aws-service/cognito.service';
|
||||
import { ConstantsProvider } from '../constants/constants';
|
||||
|
||||
@Injectable()
|
||||
export class TokenInterceptor implements HttpInterceptor{
|
||||
constructor(public injector:Injector ) {
|
||||
|
||||
}
|
||||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
// request = request.clone({
|
||||
// setHeaders: {
|
||||
// Authorization: `${this.auth.getToken()}`
|
||||
// }
|
||||
// });
|
||||
// return Observable.create(observer=>{
|
||||
let token:any='';
|
||||
let Authorization:string
|
||||
let requests
|
||||
const cognitoService=this.injector.get(CognitoServiceProvider)
|
||||
// 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();
|
||||
// token = this.shared.getToken() || null;
|
||||
|
||||
// token = token.getIdToken().getJwtToken();
|
||||
|
||||
//console.log(token);
|
||||
requests = request.clone({
|
||||
headers:new HttpHeaders({
|
||||
|
||||
'Authorization': Authorization,
|
||||
'Token':token,
|
||||
'From':'2',
|
||||
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
// })
|
||||
return next.handle(requests).pipe(
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,8 @@ import "rxjs/add/operator/map";
|
||||
import { CognitoServiceProvider } from './cognito.service';
|
||||
import { ConstantsProvider } from '../constants/constants';
|
||||
import { UrlResolver } from '@angular/compiler';
|
||||
import { ConnectionStatus, NetworkDetectionProvider } from '../network-detection/network-detection';
|
||||
import { IonicStorageProvider } from '../ionic-storage/ionic-storage';
|
||||
const sineedgedev_poolData = {
|
||||
UserPoolId: "ap-south-1_qQ85yQZJO", // UserName :SPARQ_SINEEDGE_DEV
|
||||
ClientId: "2o5c3cs9k3als16nqhp3irh8rs" // ClientName: SINEEDGE_DEV_WEB
|
||||
@ -42,7 +44,8 @@ let lenderUserPool
|
||||
@Injectable()
|
||||
export class AwsServiceProvider {
|
||||
apiurl:any;
|
||||
constructor(public http:HttpClient,public shared:CognitoServiceProvider,public con:ConstantsProvider) {
|
||||
constructor(public http:HttpClient,public shared:CognitoServiceProvider,public con:ConstantsProvider,
|
||||
private ionicStorageProvider:IonicStorageProvider,private networkProvider:NetworkDetectionProvider) {
|
||||
this.apiurl = con.environment();
|
||||
const lender_poolData = {
|
||||
UserPoolId:this.apiurl.lenUserPoolId, // Username :SPARQ_LENDER_DEV
|
||||
@ -189,9 +192,16 @@ apiurl:any;
|
||||
//console.log(cogusers.idToken.payload.locale);
|
||||
let roles = {'userid':userid};
|
||||
|
||||
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
// let request = new RequestOptions({headers:headers});
|
||||
return this.http.post(this.apiurl.url+'getUsersDetails',roles);
|
||||
return this.http.post(this.apiurl.url+'getUsersDetails',roles).map(result=>{
|
||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,{'userid':userid},'getUsersDetails');
|
||||
return result;
|
||||
})
|
||||
}
|
||||
else {
|
||||
return this.ionicStorageProvider.getApiDataFromLocally({'userid':userid},'getUsersDetails');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -28,5 +28,11 @@ export class LoadingProvider {
|
||||
dismissLoader(){
|
||||
this.loading.dismiss()
|
||||
}
|
||||
|
||||
salesPDLoader(content) {
|
||||
this.loading = this.loadingCtrl.create({
|
||||
content: content,
|
||||
enableBackdropDismiss:true
|
||||
});
|
||||
this.loading.present();
|
||||
}
|
||||
}
|
||||
|
||||
134
src/providers/ionic-storage/ionic-storage.ts
Executable file
134
src/providers/ionic-storage/ionic-storage.ts
Executable file
@ -0,0 +1,134 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { Observable, Observer } from 'rxjs';
|
||||
|
||||
/*
|
||||
Generated class for the IonicStorageProvider provider.
|
||||
|
||||
See https://angular.io/guide/dependency-injection for more info on providers
|
||||
and Angular DI.
|
||||
*/
|
||||
@Injectable()
|
||||
export class IonicStorageProvider {
|
||||
|
||||
constructor(private ionicStorage:Storage) {
|
||||
console.log('Hello IonicStorageProvider Provider');
|
||||
}
|
||||
inserDataWithReplace(key,value) {
|
||||
return this.ionicStorage.set(key,value).then(result=>{
|
||||
return result
|
||||
})
|
||||
}
|
||||
insertDataWithoutReplace(key,value,paramsToCheck) {
|
||||
return this.ionicStorage.get(key).then(result=>{
|
||||
let result_value:any =result
|
||||
if(result_value && result_value.length > 0) {
|
||||
// let objUpdated= false
|
||||
for(let i=0;i<result_value.length;i++) {
|
||||
let obj=result_value[i]
|
||||
|
||||
if(JSON.stringify(paramsToCheck) == JSON.stringify(obj.params)) {
|
||||
console.log("Obj Compared True #####################",key,value,paramsToCheck);
|
||||
result_value[i] = value
|
||||
// objUpdated= true;
|
||||
console.log(result_value);
|
||||
return this.ionicStorage.set(key,result_value).then(resu=>{
|
||||
console.log("kcma",resu);
|
||||
return resu
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log("ins",result);
|
||||
let temp = result
|
||||
temp.push(value)
|
||||
console.log("saved",result);
|
||||
return this.ionicStorage.set(key,temp).then(resu=>{
|
||||
return resu
|
||||
})
|
||||
}
|
||||
else{
|
||||
return this.ionicStorage.set(key,[value]);
|
||||
}
|
||||
})
|
||||
}
|
||||
getLocalDataWithFilter(key,filter) {
|
||||
return this.ionicStorage.get(key).then(res=>{
|
||||
console.log("$$$$$$$$$$$$$4444",res)
|
||||
if(res && filter && filter.type == 'filter'){
|
||||
console.log(filter.name)
|
||||
return res.filter(val=>val[filter.name] != null)
|
||||
}
|
||||
})
|
||||
}
|
||||
getDataFromLocalWithParams(key,params) {
|
||||
return this.ionicStorage.get(key).then(result=>{
|
||||
console.log(result);
|
||||
if(result) {
|
||||
console.log("params compo",JSON.stringify(result.params) == JSON.stringify(params))
|
||||
console.log("#####type of ",typeof(result),result.length);
|
||||
if(result.length == undefined) {
|
||||
let val = this.compareParams(result,params)
|
||||
if(val != undefined){
|
||||
return val
|
||||
}
|
||||
else{
|
||||
let result_dummy ={dataStatus:false}
|
||||
return result_dummy
|
||||
}
|
||||
}
|
||||
else if(result.length > 0) {
|
||||
console.log("array res",result);
|
||||
for(let i=0;i<result.length;i++) {
|
||||
let val =result[i]
|
||||
let obj_res = this.compareParams(val,params)
|
||||
console.log(obj_res);
|
||||
if(obj_res != undefined){
|
||||
return obj_res
|
||||
}
|
||||
}
|
||||
let result_dummy ={dataStatus:false}
|
||||
return result_dummy
|
||||
}
|
||||
}
|
||||
else {
|
||||
let result_dummy ={dataStatus:false}
|
||||
return result_dummy
|
||||
}
|
||||
})
|
||||
}
|
||||
compareParams(result,compareParams) {
|
||||
if(JSON.stringify(result.params) == JSON.stringify(compareParams)) {
|
||||
// delete result.params
|
||||
return result
|
||||
}
|
||||
// else{
|
||||
// let result_dummy ={dataStatus:false}
|
||||
// return result_dummy
|
||||
// }
|
||||
}
|
||||
checkAndInsertApiDataLocally(res,params,api_name,is_multiple?) {
|
||||
if(res['dataStatus']) {
|
||||
let values:any = res
|
||||
values.params = params
|
||||
if(is_multiple) {
|
||||
return this.insertDataWithoutReplace(api_name,values,params).then(res=>{
|
||||
return res
|
||||
})
|
||||
}
|
||||
return this.inserDataWithReplace(api_name,values).then(res=>{
|
||||
return res
|
||||
});
|
||||
}
|
||||
}
|
||||
getApiDataFromLocally(params,api_name) {
|
||||
return Observable.create((observer:Observer<any>) => {
|
||||
return this.getDataFromLocalWithParams(api_name,params).then(result=> {
|
||||
console.log(result);
|
||||
observer.next(result);
|
||||
observer.complete();
|
||||
})
|
||||
// return ''
|
||||
})
|
||||
}
|
||||
}
|
||||
64
src/providers/network-detection/network-detection.ts
Executable file
64
src/providers/network-detection/network-detection.ts
Executable file
@ -0,0 +1,64 @@
|
||||
// import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import {BehaviorSubject} from 'rxjs'
|
||||
// import {Observable } from 'rxjs/Observable';
|
||||
// import 'rxjs/add/observable/fromEvent';
|
||||
import { Network } from '@ionic-native/network';
|
||||
import { ToastProvider } from '../common-provider/toast';
|
||||
import { Platform } from 'ionic-angular';
|
||||
|
||||
/*
|
||||
Generated class for the NetworkDetectionProvider provider.
|
||||
|
||||
See https://angular.io/guide/dependency-injection for more info on providers
|
||||
and Angular DI.
|
||||
*/
|
||||
export enum ConnectionStatus {
|
||||
online,
|
||||
offline
|
||||
}
|
||||
@Injectable()
|
||||
export class NetworkDetectionProvider {
|
||||
private network_status:BehaviorSubject<ConnectionStatus> = new BehaviorSubject(ConnectionStatus.offline)
|
||||
constructor(private network: Network, private toastProvider: ToastProvider, private plt: Platform) {
|
||||
console.log('Hello NetworkDetectionProvider Provider');
|
||||
this.plt.ready().then(()=>{
|
||||
this.initializeNetworkEvents()
|
||||
let status = this.network.type !== 'none' ? ConnectionStatus.online : ConnectionStatus.offline
|
||||
this.network_status.next(status);
|
||||
})
|
||||
}
|
||||
|
||||
public initializeNetworkEvents() {
|
||||
console.clear();
|
||||
console.log("Initialize events");
|
||||
this.network.onDisconnect().subscribe(() => {
|
||||
if (this.network_status.getValue() === ConnectionStatus.online) {
|
||||
console.log('WE ARE OFFLINE');
|
||||
this.updateNetworkStatus(ConnectionStatus.offline);
|
||||
}
|
||||
},err=>{
|
||||
console.log(err);
|
||||
});
|
||||
this.network.onConnect().subscribe(() => {
|
||||
if (this.network_status.getValue() === ConnectionStatus.offline) {
|
||||
console.log('WE ARE ONLINE');
|
||||
this.updateNetworkStatus(ConnectionStatus.online);
|
||||
}
|
||||
});
|
||||
}
|
||||
private async updateNetworkStatus(status: ConnectionStatus) {
|
||||
this.network_status.next(status);
|
||||
|
||||
let connection = status == ConnectionStatus.offline ? 'Offline' : 'Online';
|
||||
// this.toastProvider.lenderappmessage(`You are now ${connection}`);
|
||||
}
|
||||
public onNetworkChange() {
|
||||
return this.network_status.asObservable();
|
||||
}
|
||||
|
||||
public getCurrentNetworkStatus(): ConnectionStatus {
|
||||
return this.network_status.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,9 @@ import {ConstantsProvider} from '../constants/constants';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AwsServiceProvider } from '../aws-service/aws-service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { NetworkDetectionProvider, ConnectionStatus } from '../network-detection/network-detection';
|
||||
import { IonicStorageProvider } from '../ionic-storage/ionic-storage';
|
||||
import { SalesPdProvider } from '../../pages/sales_pd/providers/sales-pd/sales-pd';
|
||||
|
||||
/*
|
||||
Generated class for the PdtriggerProvider provider.
|
||||
@ -16,7 +19,8 @@ import { catchError } from 'rxjs/operators';
|
||||
@Injectable()
|
||||
export class PdtriggerProvider {
|
||||
apiurl:any;
|
||||
constructor(public http: HttpClient,public constants:ConstantsProvider,private aws:AwsServiceProvider) {
|
||||
constructor(public http: HttpClient,public constants:ConstantsProvider,private networkProvider:NetworkDetectionProvider,
|
||||
private ionicStorageProvider:IonicStorageProvider,private salesPDProvider:SalesPdProvider) {
|
||||
this.apiurl = constants.environment();
|
||||
this.apiurl=this.apiurl.url
|
||||
console.log('Hello PdtriggerProvider Provider');
|
||||
@ -79,6 +83,26 @@ export class PdtriggerProvider {
|
||||
getLenderContactPersons(datas){
|
||||
return this.http.post(this.apiurl+'getLenderContactPersons',{records:datas})
|
||||
|
||||
}
|
||||
initiateMasterApis(type) {
|
||||
if(type == 'sales') {
|
||||
// HARD CODED API PARAMS
|
||||
this.salesPDProvider.getAllMasterDatas('STATE').subscribe(res=>{})
|
||||
// SALES PD TEMPLATE FOR WCTL AND LFMP
|
||||
this.salesPDProvider.getData('8').subscribe(res=>{
|
||||
this.salesPDProvider.getData('9').subscribe(res=>{})
|
||||
})
|
||||
//SALES PD PRODUCTS LIST FOR LENDER MWISE
|
||||
this.getEntityPreferences('35').subscribe(res=>{})
|
||||
// GETTING CITY AND PINCODE FOR SOME STATES
|
||||
this.salesPDProvider.getCityPincode('5').subscribe(res=>{
|
||||
this.salesPDProvider.getCityPincode('6').subscribe(res=>{
|
||||
this.salesPDProvider.getCityPincode('15').subscribe(res=>{
|
||||
this.salesPDProvider.getCityPincode('27').subscribe(res=>{})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -146,7 +170,17 @@ getLenderContactPersons(datas){
|
||||
}
|
||||
|
||||
getEntityPreferences(entity_id){
|
||||
return this.http.get(this.apiurl+'getEntityPreferences/'+entity_id);
|
||||
// return this.http.get(this.apiurl+'getEntityPreferences/'+entity_id);
|
||||
let params = {entity_id:entity_id}
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
return this.http.get(this.apiurl+'getEntityPreferences/'+entity_id).map(result=>{
|
||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,params,'getEntityPreferences');
|
||||
return result;
|
||||
})
|
||||
}
|
||||
else {
|
||||
return this.ionicStorageProvider.getApiDataFromLocally(params,'getEntityPreferences');
|
||||
}
|
||||
}
|
||||
generatePDReportPDF(pdId: any): Observable<any> {
|
||||
// pdId.fk_createdby = this.aws.getlocale();
|
||||
@ -164,7 +198,16 @@ getLenderContactPersons(datas){
|
||||
}
|
||||
getCommonSettingsConfig()
|
||||
{
|
||||
return this.http.post(this.apiurl+'getCommonConfig','');
|
||||
if(this.networkProvider.getCurrentNetworkStatus() == ConnectionStatus.online) {
|
||||
return this.http.post(this.apiurl+'getCommonConfig','').map(result=>{
|
||||
this.ionicStorageProvider.checkAndInsertApiDataLocally(result,null,'getCommonConfig');
|
||||
return result;
|
||||
})
|
||||
}
|
||||
else {
|
||||
return this.ionicStorageProvider.getApiDataFromLocally(null,'getCommonConfig');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
0
src/theme/filter-modal.scss
Normal file → Executable file
0
src/theme/filter-modal.scss
Normal file → Executable file
File diff suppressed because one or more lines are too long
2
www/build/0.js
Normal file → Executable file
2
www/build/0.js
Normal file → Executable file
@ -1 +1 @@
|
||||
webpackJsonp([0],{530:function(a,_,e){"use strict";Object.defineProperty(_,"__esModule",{value:!0}),e.d(_,"SectionListPageModuleNgFactory",function(){return j});var t=e(0),n=e(275),c=e(398),u=e(399),l=e(400),i=e(401),o=e(402),r=e(403),b=e(404),f=e(405),s=e(406),d=e(407),v=e(3),y=e(8),p=e(15),g=e(276),k=e(6),B=e(68),M=e(119),P=e(165),j=t.Y(n.a,[],function(a){return t._12([t._13(512,t.i,t.U,[[8,[c.a,u.a,l.a,i.a,o.a,r.a,b.a,f.a,s.a,d.a]],[3,t.i],t.t]),t._13(4608,v.l,v.k,[t.s,[2,v.u]]),t._13(4608,y.B,y.B,[]),t._13(4608,y.f,y.f,[]),t._13(6144,p.b,null,[v.c]),t._13(4608,p.c,p.c,[[2,p.b]]),t._13(512,v.b,v.b,[]),t._13(512,y.y,y.y,[]),t._13(512,y.l,y.l,[]),t._13(512,y.v,y.v,[]),t._13(512,g.a,g.a,[]),t._13(512,g.b,g.b,[]),t._13(512,p.a,p.a,[]),t._13(256,k.e,!0,[]),t._13(512,k.l,k.l,[[2,k.e]]),t._13(512,B.f,B.f,[]),t._13(512,n.a,n.a,[]),t._13(256,M.a,P.a,[])])})}});
|
||||
webpackJsonp([0],{484:function(a,_,e){"use strict";Object.defineProperty(_,"__esModule",{value:!0}),e.d(_,"SectionListPageModuleNgFactory",function(){return k});var t=e(0),c=e(271),n=e(384),l=e(385),u=e(386),i=e(387),o=e(388),r=e(389),f=e(390),b=e(391),s=e(392),d=e(393),v=e(3),y=e(8),p=e(15),g=e(272),B=e(7),M=e(67),P=e(116),j=e(165),k=t.Y(c.a,[],function(a){return t._12([t._13(512,t.i,t.U,[[8,[n.a,l.a,u.a,i.a,o.a,r.a,f.a,b.a,s.a,d.a]],[3,t.i],t.t]),t._13(4608,v.m,v.l,[t.s,[2,v.v]]),t._13(4608,y.B,y.B,[]),t._13(4608,y.f,y.f,[]),t._13(6144,p.b,null,[v.d]),t._13(4608,p.c,p.c,[[2,p.b]]),t._13(512,v.c,v.c,[]),t._13(512,y.y,y.y,[]),t._13(512,y.l,y.l,[]),t._13(512,y.v,y.v,[]),t._13(512,g.a,g.a,[]),t._13(512,g.b,g.b,[]),t._13(512,p.a,p.a,[]),t._13(256,B.e,!0,[]),t._13(512,B.l,B.l,[[2,B.e]]),t._13(512,M.f,M.f,[]),t._13(512,c.a,c.a,[]),t._13(256,P.a,j.a,[])])})}});
|
||||
2
www/build/main.css
Normal file → Executable file
2
www/build/main.css
Normal file → Executable file
File diff suppressed because one or more lines are too long
2
www/build/main.js
Normal file → Executable file
2
www/build/main.js
Normal file → Executable file
File diff suppressed because one or more lines are too long
0
www/build/polyfills.js
Normal file → Executable file
0
www/build/polyfills.js
Normal file → Executable file
0
www/build/sw-toolbox.js
Normal file → Executable file
0
www/build/sw-toolbox.js
Normal file → Executable file
2
www/build/vendor.js
Normal file → Executable file
2
www/build/vendor.js
Normal file → Executable file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user