Fairoj : sales pd changes
This commit is contained in:
parent
fa613819c3
commit
3b7404f9b0
@ -91,9 +91,12 @@
|
||||
<plugin name="cordova-plugin-geolocation" spec="2.4.3">
|
||||
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="To locate you" />
|
||||
</plugin>
|
||||
<plugin name="cordova-plugin-camera" spec="~4.0.3" />
|
||||
<plugin name="cordova-plugin-app-version" spec="0.1.9" />
|
||||
<plugin name="cordova-sqlite-storage" spec="3.4.0" />
|
||||
<plugin name="cordova-plugin-camera" spec="~4.0.3" />
|
||||
<plugin name="cordova-plugin-request-location-accuracy" spec="2.3.0">
|
||||
<variable name="PLAY_SERVICES_LOCATION_VERSION" value="16.+" />
|
||||
</plugin>
|
||||
<engine name="browser" spec="5.0.4" />
|
||||
<engine name="android" spec="7.1.1" />
|
||||
<plugin name="cordova-sqlite-storage" spec="3.4.0" />
|
||||
</widget>
|
||||
|
||||
21
package-lock.json
generated
21
package-lock.json
generated
@ -141,9 +141,9 @@
|
||||
"integrity": "sha512-qLd0nXhLtDzeiavrdIP4ge679L2NYEl0NIRRcNmEyC69zAXv8rNj1ziRsVLPH319sUgYS/AQjbCFACPFls1Spg=="
|
||||
},
|
||||
"@ionic-native/camera": {
|
||||
"version": "4.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@ionic-native/camera/-/camera-4.16.0.tgz",
|
||||
"integrity": "sha512-YNa1C8AK7WtNhWMR/KR8U458bdpezu+7rqAlrZyKjLorBlNjGWUSxh8gigYYEf1My4slV517IvonUS49kR04zw=="
|
||||
"version": "4.20.0",
|
||||
"resolved": "https://registry.npmjs.org/@ionic-native/camera/-/camera-4.20.0.tgz",
|
||||
"integrity": "sha512-WnfQq8RV+7ezOqpCyNx9Xgpy7Y8TZehGLSxZXnCqCbFZ72CpC70Q5AV/eTIRGiKkotx2U6nUopYF+gTj1cunFA=="
|
||||
},
|
||||
"@ionic-native/core": {
|
||||
"version": "4.4.0",
|
||||
@ -165,6 +165,11 @@
|
||||
"resolved": "https://registry.npmjs.org/@ionic-native/launch-navigator/-/launch-navigator-4.16.0.tgz",
|
||||
"integrity": "sha512-cBloEL2mNvgb7s64lGZjszgu3BmB/3ZnQNW/hlj0RB14XcsVZo3Fv2u1licDTjjDYUTqU3ybjAt/oV5EOn+pDg=="
|
||||
},
|
||||
"@ionic-native/location-accuracy": {
|
||||
"version": "4.20.0",
|
||||
"resolved": "https://registry.npmjs.org/@ionic-native/location-accuracy/-/location-accuracy-4.20.0.tgz",
|
||||
"integrity": "sha512-GB0kdW+4cZ4dE4319PsVV2zbRnV8qgBUih57195QSz5FRiFC4E0GPE6cVtUWJBrtvcyAMexk1L45bRlv5lYW3w=="
|
||||
},
|
||||
"@ionic-native/splash-screen": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@ionic-native/splash-screen/-/splash-screen-4.4.0.tgz",
|
||||
@ -2464,6 +2469,11 @@
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-ionic-webview/-/cordova-plugin-ionic-webview-2.2.0.tgz",
|
||||
"integrity": "sha512-mNTJaIRsz83Vntk2d3jrPCnlqEPQsfOJW6U2AzS7WV1T15Jj/STdXI/Uv1vIyvPVd9h1OLF+yu64ZsmQH2VRMQ=="
|
||||
},
|
||||
"cordova-plugin-request-location-accuracy": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-request-location-accuracy/-/cordova-plugin-request-location-accuracy-2.3.0.tgz",
|
||||
"integrity": "sha512-Rgr3DnRC8PUQyxmsOs76KxvDJB28MoCoYFfceiGn9Nzwsg6nAJmAwEtrYzm283x1cDhBPvzkZ6lzuldTkmnWjA=="
|
||||
},
|
||||
"cordova-plugin-splashscreen": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-splashscreen/-/cordova-plugin-splashscreen-5.0.2.tgz",
|
||||
@ -7504,6 +7514,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"watermarkjs": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/watermarkjs/-/watermarkjs-2.0.0.tgz",
|
||||
"integrity": "sha1-adw+sb6qT3DBGJsgLj3mWF7NWyI="
|
||||
},
|
||||
"webpack": {
|
||||
"version": "3.12.0",
|
||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-3.12.0.tgz",
|
||||
|
||||
12
package.json
12
package.json
@ -24,11 +24,12 @@
|
||||
"@angular/platform-browser": "5.0.3",
|
||||
"@angular/platform-browser-dynamic": "5.0.3",
|
||||
"@ionic-native/app-version": "^4.20.0",
|
||||
"@ionic-native/camera": "^4.16.0",
|
||||
"@ionic-native/camera": "^4.20.0",
|
||||
"@ionic-native/core": "4.4.0",
|
||||
"@ionic-native/fingerprint-aio": "^4.16.0",
|
||||
"@ionic-native/geolocation": "^4.16.0",
|
||||
"@ionic-native/launch-navigator": "^4.16.0",
|
||||
"@ionic-native/location-accuracy": "^4.20.0",
|
||||
"@ionic-native/splash-screen": "4.4.0",
|
||||
"@ionic-native/status-bar": "^4.16.0",
|
||||
"@ionic/storage": "^2.1.3",
|
||||
@ -45,6 +46,7 @@
|
||||
"cordova-plugin-geolocation": "2.4.3",
|
||||
"cordova-plugin-ionic-keyboard": "^2.0.5",
|
||||
"cordova-plugin-ionic-webview": "^2.0.0",
|
||||
"cordova-plugin-request-location-accuracy": "2.3.0",
|
||||
"cordova-plugin-splashscreen": "5.0.2",
|
||||
"cordova-plugin-statusbar": "2.4.2",
|
||||
"cordova-plugin-whitelist": "1.3.3",
|
||||
@ -58,6 +60,7 @@
|
||||
"rxjs-compat": "^6.3.1",
|
||||
"sw-toolbox": "3.6.0",
|
||||
"uk.co.workingedge.phonegap.plugin.launchnavigator": "~4.2.2",
|
||||
"watermarkjs": "^2.0.0",
|
||||
"zone.js": "0.8.18"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -85,11 +88,14 @@
|
||||
"GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
|
||||
},
|
||||
"cordova-plugin-app-version": {},
|
||||
"cordova-sqlite-storage": {}
|
||||
"cordova-sqlite-storage": {},
|
||||
"cordova-plugin-request-location-accuracy": {
|
||||
"PLAY_SERVICES_LOCATION_VERSION": "16.+"
|
||||
}
|
||||
},
|
||||
"platforms": [
|
||||
"browser",
|
||||
"android"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,6 +44,10 @@
|
||||
},
|
||||
"cordova-sqlite-storage": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-request-location-accuracy": {
|
||||
"PLAY_SERVICES_LOCATION_VERSION": "16.+",
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
}
|
||||
},
|
||||
"dependent_plugins": {
|
||||
|
||||
@ -42,6 +42,9 @@
|
||||
},
|
||||
"cordova-sqlite-storage": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
},
|
||||
"cordova-plugin-request-location-accuracy": {
|
||||
"PACKAGE_NAME": "com.sineedge.pdglender"
|
||||
}
|
||||
},
|
||||
"dependent_plugins": {
|
||||
|
||||
390
plugins/cordova-plugin-request-location-accuracy/README.md
Normal file
390
plugins/cordova-plugin-request-location-accuracy/README.md
Normal file
@ -0,0 +1,390 @@
|
||||
Cordova Request Location Accuracy Plugin [](https://www.npmjs.com/package/cordova-plugin-request-location-accuracy) [](https://npm-stat.com/charts.html?package=cordova-plugin-request-location-accuracy)
|
||||
==========================================================================================================================================================================================================================================================================================================================================================================================================
|
||||
<!-- doctoc README.md --maxlevel=3 -->
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
**Table of Contents**
|
||||
|
||||
- [Overview](#overview)
|
||||
- [Why is this plugin not just part of cordova-diagnostic-plugin?](#why-is-this-plugin-not-just-part-of-cordova-diagnostic-plugin)
|
||||
- [Android overview](#android-overview)
|
||||
- [Android Play Services library dependency](#android-play-services-library-dependency)
|
||||
- [iOS overview](#ios-overview)
|
||||
- [iOS "Cancel" button caveat](#ios-cancel-button-caveat)
|
||||
- [Example project](#example-project)
|
||||
- [Installation](#installation)
|
||||
- [Using the Cordova/Phonegap CLI](#using-the-cordovaphonegap-cli)
|
||||
- [PhoneGap Build](#phonegap-build)
|
||||
- [Usage](#usage)
|
||||
- [Android & iOS](#android--ios)
|
||||
- [request()](#request)
|
||||
- [isRequesting()](#isrequesting)
|
||||
- [canRequest()](#canrequest)
|
||||
- [Android-only](#android-only)
|
||||
- [Request constants](#request-constants)
|
||||
- [Callback constants](#callback-constants)
|
||||
- [Full Android & iOS example](#full-android--ios-example)
|
||||
- [License](#license)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
# Overview
|
||||
|
||||
This Cordova/Phonegap plugin for Android and iOS to request enabling/changing of Location Services by triggering a native dialog from within the app, avoiding the need for the user to leave your app to change location settings manually.
|
||||
|
||||
<!-- DONATE -->
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZRD3W47HQ3EMJ)
|
||||
|
||||
I dedicate a considerable amount of my free time to developing and maintaining this Cordova plugin, along with my other Open Source software.
|
||||
To help ensure this plugin is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this plugin in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes.
|
||||
<!-- END DONATE -->
|
||||
|
||||
## Why is this plugin not just part of [cordova-diagnostic-plugin](https://github.com/dpa99c/cordova-diagnostic-plugin)?
|
||||
|
||||
Because:
|
||||
- you may not wish to use the location features of the diagnostic plugin and therefore may not require it
|
||||
- you may not wish to use the features of this plugin
|
||||
- on Android, the dependency on the Google Play Services library increases the size of the app APK by about 2Mb
|
||||
|
||||
However, since this plugin requires runtime authorization to use location to be granted by the user, you may want to use the diagnostic plugin to check for/request location permission.
|
||||
|
||||
|
||||
## Android overview
|
||||
|
||||
[](https://www.youtube.com/watch?v=pbNdnMDRstg)
|
||||
|
||||
On Android, this plugin allows an app to request a specific accuracy for Location Services.
|
||||
If the requested accuracy is higher than the current Location Mode setting of the device, the user is asked to confirm the change with a Yes/No dialog.
|
||||
|
||||
For example, if a navigation app that requires GPS, the plugin is able to switch on Location Services or change the Location Mode from low accuracy to high accuracy,
|
||||
without the user needing to leave the app to do this manually on the Location Settings page.
|
||||
|
||||
It uses the Google Play Services Location API (v7+) to change the device location settings. In case the user doesn't have an up-to-date version of Google Play Services or there's some other problem accessing it, you may want to use another of my plugins, [cordova.plugins.diagnostic](https://github.com/dpa99c/cordova-diagnostic-plugin) as a fallback. This is able to switch the user directly to the Location Settings page where they can manually change the Location Mode.
|
||||
|
||||
|
||||
|
||||
### Android Play Services library dependency
|
||||
This plugin depends on the Google Play Services library so you must install the "Google Repository" package under the "Extras" section in Android SDK Manager.
|
||||

|
||||
|
||||
#### Play Services version
|
||||
* **IMPORTANT:** This plugin is not directly responsible for, nor cannot it resolve, Android build errors which occur due to version conflicts in Gradle dependencies.
|
||||
* If you encounter Android build errors, please read the section below in detail to understand Gradle version dependencies in relation to this plugin.
|
||||
* Also see the [Android Library Versions guide](https://developers.google.com/android/guides/versioning).
|
||||
* Any issues which are opened which relate to build errors caused by Gradle version conflicts will be closed immediately with a reference given to the following section.
|
||||
|
||||
* This plugin depends on the `play-services-location` component of the [Google Play Services library](https://developers.google.com/android/guides/overview#the_google_play_services_client_library), which is satisfied via Gradle during the Android build process.
|
||||
* By default, [this plugin references](https://github.com/dpa99c/cordova-plugin-request-location-accuracy/blob/master/plugin.xml#L32) the most recently released major version of the `play-services-location` component (currently `v16` - see the [Android Library Release Notes](https://developers.google.com/android/guides/releases) for most recent minor/patch version).
|
||||
* Android build errors can occur if different versions of the same library or component are specified as Gradle dependencies in the same Android project.
|
||||
* You may encounter build errors if your Cordova project includes:
|
||||
* other plugins which specify a different major version of the Play Services library
|
||||
* In this case you may need to specify a custom version of the `play-services-location` component which is referenced by this plugin.
|
||||
* You can do this using the `PLAY_SERVICES_LOCATION_VERSION` plugin variable at plugin installation - see the [installation section](#installation) for an example.
|
||||
* You can find what other versions of the Play Services library are being referenced by looking at the `build.gradle` files in the `platforms/android/` directory of your Cordova project.
|
||||
* Look for entries that contain `com.google.android.gms`, for example `implementation "com.google.android.gms:play-services-location:15.+"`
|
||||
* other plugins which reference the Play Services library but do not allow you to specify a custom version (i.e the version is hard-coded) .
|
||||
* You can use [cordova-android-play-services-gradle-release](https://github.com/dpa99c/cordova-android-play-services-gradle-release) to override the Play Services library version specified by these other plugins in order to align them and prevent build errors.
|
||||
* other plugins which reference the Firebase library (or Google Services plugin), such as:
|
||||
* [phonegap-plugin-push](https://github.com/phonegap/phonegap-plugin-push)
|
||||
* [cordova-plugin-fcm](https://github.com/fechanique/cordova-plugin-fcm)
|
||||
* [cordova-plugin-firebase](https://github.com/arnesson/cordova-plugin-firebase))
|
||||
* This is because the major versions of the Play Services and Firebase libraries need to align.
|
||||
* You can use [cordova-android-firebase-gradle-release](https://github.com/dpa99c/cordova-android-firebase-gradle-release) to override the Firebase library versions specified by other plugins to align with the Play Services library version.
|
||||
* See [#50](https://github.com/dpa99c/cordova-plugin-request-location-accuracy/issues/50#issuecomment-390025013) for an example of this.
|
||||
|
||||
## iOS overview
|
||||
|
||||
[](https://www.youtube.com/watch?v=PBZKH7u5RlQ)
|
||||
|
||||
If Location Services is turned OFF on an iOS device, no app on the device can access the location.
|
||||
|
||||
It is not programmatically possible to switch Location Services ON or to directly open the Location Services page in the Settings app.
|
||||
|
||||
The best that can be done by direct programmatic invocation of the Settings app is to open the app's own permissions page - the [`switchToSettings()`](https://github.com/dpa99c/cordova-diagnostic-plugin#switchtosettings) of [cordova-diagnostic-plugin](https://github.com/dpa99c/cordova-diagnostic-plugin#switchtosettings) enables you to do this. However, the user must still manually navigate from the app permissions page in the Settings app to the Location Services setting on the Privacy page.
|
||||
|
||||
If Location Services is turned OFF, this plugin enables an app to display a native iOS system dialog which gives user the option of directly opening the Privacy page in the Settings app which contains the switch to turn Location Services ON.
|
||||
|
||||
In order to show the native dialog allowing direct opening of the Privacy page, a location must be requested via the native location manager. So why can't you just use [cordova-plugin-geolocation](https://github.com/apache/cordova-plugin-geolocation) to request the location? Because when Location Services is OFF, the app reports that use of location is unauthorized, and [cordova-plugin-geolocation](https://github.com/apache/cordova-plugin-geolocation) will not request a location if it determines location is unauthorized: see [this Cordova issue](https://issues.apache.org/jira/browse/CB-10478).
|
||||
|
||||
### iOS "Cancel" button caveat
|
||||
|
||||
As highlighted by [issue #16](https://github.com/dpa99c/cordova-plugin-request-location-accuracy/issues/16), there is one scenario in which the iOS implementation of this plugin fails: if, upon successfully showing the native dialog, the user presses "Cancel" instead of "Settings", any subsequent requests via this plugin **will not** show the dialog again. Ever! This is because iOS assumes that if the user pressed "Cancel", they don't want your app to use their location, so iOS prevents you from asking them again to switch on Location Services.
|
||||
|
||||
There's no way to tell which button the user pressed in the native dialog or whether "Cancel" was pressed and the dialog is not being shown. Consequently, if the user has pressed "Cancel" in the native dialog, any subsequent calls to the plugin will still result in the success callback being invoked, since (as far as the plugin is concerned), it successfully requested a location from the native location manager.
|
||||
|
||||
The best approach to workaround this is to recheck the state of Location Services using [canRequest()](#canrequest) on each [resume event](https://cordova.apache.org/docs/en/latest/cordova/events/events.html#resume). If the user has pressed "Settings", your app will be put in the background while the Settings app is brought into the foreground, so when the user returns to your app, it will resume from the background.
|
||||
|
||||
# Example project
|
||||
|
||||
An example project illustrating use of this plugin can be found here: [https://github.com/dpa99c/cordova-plugin-request-location-accuracy-example](https://github.com/dpa99c/cordova-plugin-request-location-accuracy-example)
|
||||
|
||||
# Installation
|
||||
|
||||
## Using the Cordova/Phonegap CLI
|
||||
|
||||
# Install with default Play Services Location library version
|
||||
$ cordova plugin add cordova-plugin-request-location-accuracy
|
||||
|
||||
# Install with custom Play Services Location library version
|
||||
$ cordova plugin add cordova-plugin-request-location-accuracy --variable PLAY_SERVICES_LOCATION_VERSION=15.0.0
|
||||
|
||||
## PhoneGap Build
|
||||
Add the following xml to your config.xml to use the latest version of this plugin from [npm](https://www.npmjs.com/package/cordova-plugin-request-location-accuracy):
|
||||
|
||||
<plugin name="cordova-plugin-request-location-accuracy" source="npm" />
|
||||
|
||||
|
||||
|
||||
# Usage
|
||||
|
||||
The plugin is exposed via the `cordova.plugins.locationAccuracy` object.
|
||||
|
||||
## Android & iOS
|
||||
|
||||
### request()
|
||||
|
||||
This is the main plugin method.
|
||||
|
||||
#### Android
|
||||
|
||||
Requests a specific accuracy for Location Services.
|
||||
|
||||
cordova.plugins.locationAccuracy.request(successCallback, errorCallback, accuracy)
|
||||
|
||||
Parameters:
|
||||
|
||||
- {Function} successCallback - callback to be invoked on successful resolution of the requested accuracy.
|
||||
A single object argument will be passed which has two keys:
|
||||
"code" in an integer corresponding to a [SUCCESS constant](#success-constants) and indicates the reason for success;
|
||||
"message" is a string containing a description of the success.
|
||||
- {Function} errorCallback - callback to be invoked on failure to resolve the requested accuracy.
|
||||
A single object argument will be passed which has two keys:
|
||||
"code" in an integer corresponding to an [ERROR constant](#error-constants) and indicates the reason for failure;
|
||||
"message" is a string containing a description of the error.
|
||||
- {Integer} accuracy - The location accuracy to request defined by an integer corresponding to a [REQUEST constant](#request-constants).
|
||||
|
||||
Example usage:
|
||||
|
||||
cordova.plugins.locationAccuracy.canRequest(function(canRequest){
|
||||
if(canRequest){
|
||||
cordova.plugins.locationAccuracy.request(function (success){
|
||||
console.log("Successfully requested accuracy: "+success.message);
|
||||
}, function (error){
|
||||
console.error("Accuracy request failed: error code="+error.code+"; error message="+error.message);
|
||||
if(error.code !== cordova.plugins.locationAccuracy.ERROR_USER_DISAGREED){
|
||||
if(window.confirm("Failed to automatically set Location Mode to 'High Accuracy'. Would you like to switch to the Location Settings page and do this manually?")){
|
||||
cordova.plugins.diagnostic.switchToLocationSettings();
|
||||
}
|
||||
}
|
||||
}, cordova.plugins.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY);
|
||||
}else{
|
||||
// request location permission and try again
|
||||
}
|
||||
});
|
||||
|
||||
#### iOS
|
||||
|
||||
If Location Services is OFF, invokes the native dialog to directly open the Location Services page in the Settings app.
|
||||
|
||||
cordova.plugins.locationAccuracy.request(successCallback, errorCallback)
|
||||
|
||||
Parameters:
|
||||
|
||||
- {Function} successCallback - callback to be invoked on successful request to invoke the dialog.
|
||||
- {Function} errorCallback - callback to be invoked on failure to request a location and invoked the dialog.
|
||||
|
||||
Example usage:
|
||||
|
||||
cordova.plugins.locationAccuracy.canRequest(function(canRequest){
|
||||
if(canRequest){
|
||||
cordova.plugins.locationAccuracy.request(function(){
|
||||
console.log("Successfully made request to invoke native Location Services dialog");
|
||||
}, function(){
|
||||
console.error("Failed to invoke native Location Services dialog");
|
||||
});
|
||||
}else{
|
||||
// request location permission and try again
|
||||
}
|
||||
});
|
||||
|
||||
### isRequesting()
|
||||
|
||||
Indicates if a request is currently in progress.
|
||||
|
||||
cordova.plugins.locationAccuracy.isRequesting(successCallback);
|
||||
|
||||
Parameters:
|
||||
|
||||
- {Function} successCallback - callback to pass result to.
|
||||
This is passed a boolean argument indicating if a request is currently in progress.
|
||||
|
||||
Example usage:
|
||||
|
||||
cordova.plugins.locationAccuracy.isRequesting(function(requesting){
|
||||
console.log("A request " + (requesting ? "is" : "is not") + " currently in progress");
|
||||
});
|
||||
|
||||
### canRequest()
|
||||
|
||||
Indicates if a request is possible to invoke a request.
|
||||
On iOS, this will return true if Location Services is currently OFF and request is not currently in progress.
|
||||
On Android, this will return true if the app has authorization to use location.
|
||||
|
||||
cordova.plugins.locationAccuracy.canRequest(successCallback);
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
- {Function} successCallback - callback to pass result to.
|
||||
This is passed a boolean argument indicating if a request can be made.
|
||||
|
||||
Example usage:
|
||||
|
||||
cordova.plugins.locationAccuracy.canRequest(function(canRequest){
|
||||
console.log("A request " + (canRequest ? "can" : "cannot") + " currently be made");
|
||||
});
|
||||
|
||||
## Android-only
|
||||
|
||||
### Request constants
|
||||
|
||||
The location accuracy which is to be requested is defined as a set of REQUEST constants on the `cordova.plugins.locationAccuracy` object:
|
||||
|
||||
- `cordova.plugins.locationAccuracy.REQUEST_PRIORITY_NO_POWER`: Request location mode priority "no power": the best accuracy possible with zero additional power consumption.
|
||||
- `cordova.plugins.locationAccuracy.REQUEST_PRIORITY_LOW_POWER`: Request location mode priority "low power": "city" level accuracy (about 10km accuracy).
|
||||
- `cordova.plugins.locationAccuracy.REQUEST_PRIORITY_BALANCED_POWER_ACCURACY`: Request location mode priority "balanced power": "block" level accuracy (about 100 meter accuracy).
|
||||
- `cordova.plugins.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY`: Request location mode priority "high accuracy": the most accurate locations available. This will use GPS hardware to retrieve positions.
|
||||
|
||||
|
||||
See [https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#constants](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#constants)
|
||||
|
||||
### Callback constants
|
||||
|
||||
Both the `successCallback()` and `errorCallback()` functions will be passed an object which contains both a descriptive message and a code indicating the result of the operation.
|
||||
These constants are defined on the `cordova.plugins.locationAccuracy` object.
|
||||
|
||||
#### Success constants
|
||||
|
||||
The `successCallback()` function will be pass an object where the "code" key may correspond to the following values:
|
||||
|
||||
- `cordova.plugins.locationAccuracy.SUCCESS_SETTINGS_SATISFIED`: Success due to current location settings already satisfying requested accuracy.
|
||||
- `cordova.plugins.locationAccuracy.SUCCESS_USER_AGREED`: Success due to user agreeing to requested accuracy change
|
||||
|
||||
#### Error constants
|
||||
|
||||
The `errorCallback()` function will be pass an object where the "code" key may correspond to the following values:
|
||||
|
||||
- `cordova.plugins.locationAccuracy.ERROR_ALREADY_REQUESTING`: Error due an unresolved request already being in progress.
|
||||
- `cordova.plugins.locationAccuracy.ERROR_INVALID_ACTION`: Error due invalid action requested.
|
||||
- `cordova.plugins.locationAccuracy.ERROR_INVALID_ACCURACY`: Error due invalid accuracy requested.
|
||||
- `cordova.plugins.locationAccuracy.ERROR_EXCEPTION`: Error due to exception in the native code.
|
||||
- `cordova.plugins.locationAccuracy.ERROR_CANNOT_CHANGE_ACCURACY`: Error due to not being able to change location accuracy to requested state.
|
||||
- `cordova.plugins.locationAccuracy.ERROR_USER_DISAGREED`: Error due to user rejecting requested accuracy change.
|
||||
- `cordova.plugins.locationAccuracy.ERROR_GOOGLE_API_CONNECTION_FAILED`: Error due to failure to connect to Google Play Services API. The "message" key will contain a detailed description of the Google Play Services error.
|
||||
|
||||
|
||||
# Full Android & iOS example
|
||||
|
||||
The following example illustrates how to use the plugin cross-platform on both Android & iOS,
|
||||
and also how to use [cordova-diagnostic-plugin](https://github.com/dpa99c/cordova-diagnostic-plugin) to request runtime permission to use location if necessary.
|
||||
|
||||
var platform;
|
||||
function onDeviceReady(){
|
||||
platform = cordova.platformId;
|
||||
}
|
||||
|
||||
|
||||
function onError(error) {
|
||||
console.error("The following error occurred: " + error);
|
||||
}
|
||||
|
||||
function handleLocationAuthorizationStatus(status) {
|
||||
switch (status) {
|
||||
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
|
||||
if(platform === "ios"){
|
||||
onError("Location services is already switched ON");
|
||||
}else{
|
||||
_makeRequest();
|
||||
}
|
||||
break;
|
||||
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
|
||||
requestLocationAuthorization();
|
||||
break;
|
||||
case cordova.plugins.diagnostic.permissionStatus.DENIED:
|
||||
if(platform === "android"){
|
||||
onError("User denied permission to use location");
|
||||
}else{
|
||||
_makeRequest();
|
||||
}
|
||||
break;
|
||||
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
|
||||
// Android only
|
||||
onError("User denied permission to use location");
|
||||
break;
|
||||
case cordova.plugins.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE:
|
||||
// iOS only
|
||||
onError("Location services is already switched ON");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function requestLocationAuthorization() {
|
||||
cordova.plugins.diagnostic.requestLocationAuthorization(handleLocationAuthorizationStatus, onError);
|
||||
}
|
||||
|
||||
function requestLocationAccuracy() {
|
||||
cordova.plugins.diagnostic.getLocationAuthorizationStatus(handleLocationAuthorizationStatus, onError);
|
||||
}
|
||||
|
||||
function _makeRequest(){
|
||||
cordova.plugins.locationAccuracy.canRequest(function(canRequest){
|
||||
if (canRequest) {
|
||||
cordova.plugins.locationAccuracy.request(function () {
|
||||
handleSuccess("Location accuracy request successful");
|
||||
}, function (error) {
|
||||
onError("Error requesting location accuracy: " + JSON.stringify(error));
|
||||
if (error) {
|
||||
// Android only
|
||||
onError("error code=" + error.code + "; error message=" + error.message);
|
||||
if (platform === "android" && error.code !== cordova.plugins.locationAccuracy.ERROR_USER_DISAGREED) {
|
||||
if (window.confirm("Failed to automatically set Location Mode to 'High Accuracy'. Would you like to switch to the Location Settings page and do this manually?")) {
|
||||
cordova.plugins.diagnostic.switchToLocationSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, cordova.plugins.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY // iOS will ignore this
|
||||
);
|
||||
} else {
|
||||
// On iOS, this will occur if Location Services is currently on OR a request is currently in progress.
|
||||
// On Android, this will occur if the app doesn't have authorization to use location.
|
||||
onError("Cannot request location accuracy");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Make the request
|
||||
requestLocationAccuracy();
|
||||
|
||||
# License
|
||||
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2016 Dave Alden (Working Edge Ltd.)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@ -0,0 +1,66 @@
|
||||
{
|
||||
"_from": "cordova-plugin-request-location-accuracy",
|
||||
"_id": "cordova-plugin-request-location-accuracy@2.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Rgr3DnRC8PUQyxmsOs76KxvDJB28MoCoYFfceiGn9Nzwsg6nAJmAwEtrYzm283x1cDhBPvzkZ6lzuldTkmnWjA==",
|
||||
"_location": "/cordova-plugin-request-location-accuracy",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "cordova-plugin-request-location-accuracy",
|
||||
"name": "cordova-plugin-request-location-accuracy",
|
||||
"escapedName": "cordova-plugin-request-location-accuracy",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cordova-plugin-request-location-accuracy/-/cordova-plugin-request-location-accuracy-2.3.0.tgz",
|
||||
"_shasum": "46c21ca92e46b7f9a209fbb7f5662562f14cbb97",
|
||||
"_spec": "cordova-plugin-request-location-accuracy",
|
||||
"_where": "/home/rajasekar/project/SineEdge/sineedgelenderapp",
|
||||
"author": {
|
||||
"name": "Dave Alden"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/dpa99c/cordova-plugin-request-location-accuracy/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-request-location-accuracy",
|
||||
"platforms": [
|
||||
"android",
|
||||
"ios"
|
||||
]
|
||||
},
|
||||
"cordova_name": "Request Location Accuracy",
|
||||
"deprecated": false,
|
||||
"description": "Cordova/Phonegap plugin for Android to request Location Accuracy mode via Google Play Services.",
|
||||
"homepage": "https://github.com/dpa99c/cordova-plugin-request-location-accuracy#readme",
|
||||
"issue": "https://github.com/dpa99c/cordova-plugin-request-location-accuracy/issues",
|
||||
"keywords": [
|
||||
"ecosystem:cordova",
|
||||
"cordova",
|
||||
"cordova-android",
|
||||
"cordova-ios",
|
||||
"phonegap",
|
||||
"diagnostic",
|
||||
"location",
|
||||
"accuracy",
|
||||
"high accuracy",
|
||||
"fine accuracy",
|
||||
"gps",
|
||||
"settings"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "cordova-plugin-request-location-accuracy",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/dpa99c/cordova-plugin-request-location-accuracy.git"
|
||||
},
|
||||
"version": "2.3.0"
|
||||
}
|
||||
53
plugins/cordova-plugin-request-location-accuracy/plugin.xml
Normal file
53
plugins/cordova-plugin-request-location-accuracy/plugin.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cordova-plugin-request-location-accuracy"
|
||||
version="2.3.0">
|
||||
|
||||
<name>Request Location Accuracy</name>
|
||||
<description>Cordova/Phonegap plugin for Android and iOS to request enabling/changing of Location Services by triggering a native dialog</description>
|
||||
<author>Dave Alden</author>
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.0.0" />
|
||||
</engines>
|
||||
|
||||
<repo>https://github.com/dpa99c/cordova-plugin-request-location-accuracy.git</repo>
|
||||
<issue>https://github.com/dpa99c/cordova-plugin-request-location-accuracy/issues</issue>
|
||||
<keywords>ecosystem:cordova,cordova,phonegap,android,diagnostic,location,accuracy,high accuracy,fine accuracy,gps,settings</keywords>
|
||||
<license>MIT</license>
|
||||
|
||||
<platform name="android">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="RequestLocationAccuracy" >
|
||||
<param name="android-package" value="cordova.plugin.RequestLocationAccuracy"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<js-module src="www/android/RequestLocationAccuracy.js" name="RequestLocationAccuracy">
|
||||
<clobbers target="cordova.plugins.locationAccuracy" />
|
||||
</js-module>
|
||||
|
||||
<source-file src="src/android/RequestLocationAccuracy.java" target-dir="src/cordova/plugin" />
|
||||
|
||||
<preference name="PLAY_SERVICES_LOCATION_VERSION" default="16.+" />
|
||||
<framework src="com.google.android.gms:play-services-location:$PLAY_SERVICES_LOCATION_VERSION" />
|
||||
</platform>
|
||||
|
||||
<platform name="ios">
|
||||
|
||||
<js-module src="www/ios/RequestLocationAccuracy.js" name="RequestLocationAccuracy">
|
||||
<clobbers target="cordova.plugins.locationAccuracy" />
|
||||
</js-module>
|
||||
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="RequestLocationAccuracy">
|
||||
<param name="ios-package" value="RequestLocationAccuracy"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<header-file src="src/ios/RequestLocationAccuracy.h" />
|
||||
<source-file src="src/ios/RequestLocationAccuracy.m" />
|
||||
|
||||
<framework src="CoreLocation.framework" />
|
||||
</platform>
|
||||
</plugin>
|
||||
@ -0,0 +1,525 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
package cordova.plugin;
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.util.Log;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import com.google.android.gms.common.api.GoogleApiClient;
|
||||
import com.google.android.gms.common.api.PendingResult;
|
||||
import com.google.android.gms.common.api.ResultCallback;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.location.LocationSettingsRequest;
|
||||
import com.google.android.gms.location.LocationSettingsResult;
|
||||
import com.google.android.gms.location.LocationSettingsStatusCodes;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class RequestLocationAccuracy extends CordovaPlugin implements
|
||||
GoogleApiClient.ConnectionCallbacks,
|
||||
GoogleApiClient.OnConnectionFailedListener,
|
||||
ResultCallback<LocationSettingsResult> {
|
||||
public static final String TAG = "RequestLocationAccuracy";
|
||||
|
||||
/**
|
||||
* Provides the entry point to Google Play services.
|
||||
*/
|
||||
protected GoogleApiClient mGoogleApiClient = null;
|
||||
|
||||
/**
|
||||
* Google API availability
|
||||
*/
|
||||
protected GoogleApiAvailability googleApiAvailability;
|
||||
|
||||
|
||||
/**
|
||||
* Stores parameters for requests to the FusedLocationProviderApi.
|
||||
*/
|
||||
protected LocationRequest mLocationRequest;
|
||||
|
||||
/**
|
||||
* Stores the types of location services the client is interested in using. Used for checking
|
||||
* settings to determine if the device has optimal location settings.
|
||||
*/
|
||||
protected LocationSettingsRequest mLocationSettingsRequest;
|
||||
|
||||
/**
|
||||
* Constant used in the location settings dialog.
|
||||
*/
|
||||
protected static final int REQUEST_CHECK_SETTINGS = 0x1;
|
||||
|
||||
/**
|
||||
* Constant to indicated request for LocationRequest.PRIORITY_NO_POWER
|
||||
*/
|
||||
protected static final int REQUEST_PRIORITY_NO_POWER = 0;
|
||||
|
||||
/**
|
||||
* Constant to indicated request for LocationRequest.PRIORITY_LOW_POWER
|
||||
*/
|
||||
protected static final int REQUEST_PRIORITY_LOW_POWER = 1;
|
||||
|
||||
/**
|
||||
* Constant to indicated request for LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY
|
||||
*/
|
||||
protected static final int REQUEST_PRIORITY_BALANCED_POWER_ACCURACY = 2;
|
||||
|
||||
/**
|
||||
* Constant to indicated request for LocationRequest.HIGH_ACCURACY
|
||||
*/
|
||||
protected static final int REQUEST_PRIORITY_HIGH_ACCURACY = 3;
|
||||
|
||||
/**
|
||||
* Success due to current location settings already satisfying requested
|
||||
* accuracy
|
||||
*/
|
||||
protected static final int SUCCESS_SETTINGS_SATISFIED = 0;
|
||||
|
||||
/**
|
||||
* Success due to user agreeing to requested accuracy change
|
||||
*/
|
||||
protected static final int SUCCESS_USER_AGREED = 1;
|
||||
|
||||
/**
|
||||
* Error due invalid action requested
|
||||
*/
|
||||
protected static final int ERROR_INVALID_ACTION = 0;
|
||||
|
||||
/**
|
||||
* Error due invalid accuracy requested
|
||||
*/
|
||||
protected static final int ERROR_INVALID_ACCURACY = 1;
|
||||
|
||||
/**
|
||||
* Error due to exception
|
||||
*/
|
||||
protected static final int ERROR_EXCEPTION = 2;
|
||||
|
||||
/**
|
||||
* Error due to not being able to change location accuracy to requested state
|
||||
*/
|
||||
protected static final int ERROR_CANNOT_CHANGE_ACCURACY = 3;
|
||||
|
||||
/**
|
||||
* Error due to user rejecting requested accuracy change
|
||||
*/
|
||||
protected static final int ERROR_USER_DISAGREED = 4;
|
||||
|
||||
/**
|
||||
* Error due to failure to connect to Google Play Services API
|
||||
*/
|
||||
protected static final int ERROR_GOOGLE_API_CONNECTION_FAILED = 5;
|
||||
|
||||
/**
|
||||
* Cordova callback context
|
||||
*/
|
||||
protected CallbackContext context = null;
|
||||
|
||||
/**
|
||||
* Indicates a permanent error, so doesn't recheck since the Google APIs won't invoke the listeners on subsequent calls.
|
||||
*/
|
||||
protected ConnectionResult permanentError = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public RequestLocationAccuracy() {}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the context of the Command. This can then be used to do things like
|
||||
* get file paths associated with the Activity.
|
||||
*
|
||||
* @param cordova The context of the main Activity.
|
||||
* @param webView The CordovaWebView Cordova is running in.
|
||||
*/
|
||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||
super.initialize(cordova, webView);
|
||||
try {
|
||||
googleApiAvailability = GoogleApiAvailability.getInstance();
|
||||
buildGoogleApiClient();
|
||||
}catch(Exception e ) {
|
||||
handleError(e.getMessage(), ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackContext The callback id used when calling back into JavaScript.
|
||||
* @return True if the action was valid, false if not.
|
||||
*/
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
boolean result;
|
||||
context = callbackContext;
|
||||
try {
|
||||
if(action.equals("request")) {
|
||||
result = request(args.getInt(0));
|
||||
}else if(action.equals("canRequest")) {
|
||||
result = canRequest();
|
||||
}else {
|
||||
handleError("Invalid action", ERROR_INVALID_ACTION);
|
||||
result = false;
|
||||
}
|
||||
}catch(Exception e ) {
|
||||
handleError(e.getMessage(), ERROR_EXCEPTION);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean request(int requestedAccuracy) throws Exception{
|
||||
if(permanentError != null){
|
||||
this.onConnectionFailed(permanentError);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(mGoogleApiClient == null){
|
||||
handleError("Google Play Services Client failed to initialize", ERROR_GOOGLE_API_CONNECTION_FAILED);
|
||||
return true;
|
||||
}
|
||||
|
||||
int priority;
|
||||
switch(requestedAccuracy){
|
||||
case REQUEST_PRIORITY_NO_POWER:
|
||||
priority = LocationRequest.PRIORITY_NO_POWER;
|
||||
break;
|
||||
case REQUEST_PRIORITY_LOW_POWER:
|
||||
priority = LocationRequest.PRIORITY_LOW_POWER;
|
||||
break;
|
||||
case REQUEST_PRIORITY_BALANCED_POWER_ACCURACY:
|
||||
priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
|
||||
break;
|
||||
case REQUEST_PRIORITY_HIGH_ACCURACY:
|
||||
priority = LocationRequest.PRIORITY_HIGH_ACCURACY;
|
||||
break;
|
||||
default:
|
||||
handleError("'"+requestedAccuracy+"' is not a valid accuracy constant", ERROR_INVALID_ACCURACY);
|
||||
return false;
|
||||
}
|
||||
|
||||
createLocationRequest(priority);
|
||||
buildLocationSettingsRequest();
|
||||
checkLocationSettings();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canRequest() throws Exception{
|
||||
boolean _canRequest = isLocationAuthorized();
|
||||
context.success(_canRequest ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isLocationAuthorized() throws Exception {
|
||||
boolean authorized = hasPermission(Manifest.permission.ACCESS_FINE_LOCATION) || hasPermission(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
Log.v(TAG, "Location permission is " + (authorized ? "authorized" : "unauthorized"));
|
||||
return authorized;
|
||||
}
|
||||
|
||||
private boolean hasPermission(String permission) throws Exception{
|
||||
boolean hasPermission = true;
|
||||
Method method = null;
|
||||
try {
|
||||
method = cordova.getClass().getMethod("hasPermission", permission.getClass());
|
||||
Boolean bool = (Boolean) method.invoke(cordova, permission);
|
||||
hasPermission = bool.booleanValue();
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.w(TAG, "Cordova v" + CordovaWebView.CORDOVA_VERSION + " does not support runtime permissions so defaulting to GRANTED for " + permission);
|
||||
}
|
||||
return hasPermission;
|
||||
}
|
||||
|
||||
protected void handleError(String errorMsg, int errorCode){
|
||||
try {
|
||||
Log.e(TAG, errorMsg);
|
||||
if(context != null){
|
||||
JSONObject error = new JSONObject();
|
||||
error.put("message", errorMsg);
|
||||
error.put("code", errorCode);
|
||||
context.error(error);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleSuccess(String msg, int code){
|
||||
try {
|
||||
Log.i(TAG, msg);
|
||||
if(context != null){
|
||||
JSONObject success = new JSONObject();
|
||||
success.put("message", msg);
|
||||
success.put("code", code);
|
||||
context.success(success);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
handleError(e.getMessage(), ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a GoogleApiClient. Uses the {@code #addApi} method to request the
|
||||
* LocationServices API.
|
||||
*/
|
||||
protected synchronized void buildGoogleApiClient() {
|
||||
Log.i(TAG, "Building GoogleApiClient");
|
||||
mGoogleApiClient = new GoogleApiClient.Builder(this.cordova.getActivity())
|
||||
.addConnectionCallbacks(this)
|
||||
.addOnConnectionFailedListener(this)
|
||||
.addApi(LocationServices.API)
|
||||
.build();
|
||||
|
||||
Log.i(TAG, "Connect Google API client");
|
||||
mGoogleApiClient.connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the location request. Android has two location request settings:
|
||||
* {@code ACCESS_COARSE_LOCATION} and {@code ACCESS_FINE_LOCATION}. These settings control
|
||||
* the accuracy of the current location. This sample uses ACCESS_FINE_LOCATION, as defined in
|
||||
* the AndroidManifest.xml.
|
||||
* <p/>
|
||||
* When the ACCESS_FINE_LOCATION setting is specified, combined with a fast update
|
||||
* interval (5 seconds), the Fused Location Provider API returns location updates that are
|
||||
* accurate to within a few feet.
|
||||
* <p/>
|
||||
* These settings are appropriate for mapping applications that show real-time location
|
||||
* updates.
|
||||
*/
|
||||
protected void createLocationRequest(int priority) {
|
||||
Log.i(TAG, "Create location request");
|
||||
mLocationRequest = new LocationRequest();
|
||||
mLocationRequest.setPriority(priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses a {@link com.google.android.gms.location.LocationSettingsRequest.Builder} to build
|
||||
* a {@link com.google.android.gms.location.LocationSettingsRequest} that is used for checking
|
||||
* if a device has the needed location settings.
|
||||
*/
|
||||
protected void buildLocationSettingsRequest() {
|
||||
Log.i(TAG, "Build location settings request");
|
||||
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
|
||||
builder.addLocationRequest(mLocationRequest);
|
||||
builder.setAlwaysShow(true);
|
||||
mLocationSettingsRequest = builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the device's location settings are adequate for the app's needs using the
|
||||
* {@link com.google.android.gms.location.SettingsApi#checkLocationSettings(GoogleApiClient,
|
||||
* LocationSettingsRequest)} method, with the results provided through a {@code PendingResult}.
|
||||
*/
|
||||
protected void checkLocationSettings() {
|
||||
Log.i(TAG, "Check location settings");
|
||||
PendingResult<LocationSettingsResult> result =
|
||||
LocationServices.SettingsApi.checkLocationSettings(
|
||||
mGoogleApiClient,
|
||||
mLocationSettingsRequest
|
||||
);
|
||||
result.setResultCallback(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback invoked when
|
||||
* {@link com.google.android.gms.location.SettingsApi#checkLocationSettings(GoogleApiClient,
|
||||
* LocationSettingsRequest)} is called. Examines the
|
||||
* {@link com.google.android.gms.location.LocationSettingsResult} object and determines if
|
||||
* location settings are adequate. If they are not, begins the process of presenting a location
|
||||
* settings dialog to the user.
|
||||
*/
|
||||
@Override
|
||||
public void onResult(LocationSettingsResult locationSettingsResult) {
|
||||
Log.i(TAG, "onResult()");
|
||||
final Status status = locationSettingsResult.getStatus();
|
||||
switch (status.getStatusCode()) {
|
||||
case LocationSettingsStatusCodes.SUCCESS:
|
||||
String msg = "All location settings are satisfied.";
|
||||
Log.i(TAG, msg);
|
||||
handleSuccess(msg, SUCCESS_SETTINGS_SATISFIED);
|
||||
break;
|
||||
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
|
||||
Log.i(TAG, "Location settings are not satisfied. Show the user a dialog to upgrade location settings ");
|
||||
try {
|
||||
// Show the dialog by calling startResolutionForResult(), and check the result
|
||||
// in onActivityResult().
|
||||
this.cordova.setActivityResultCallback(this);
|
||||
status.startResolutionForResult(this.cordova.getActivity(), REQUEST_CHECK_SETTINGS);
|
||||
} catch (IntentSender.SendIntentException e) {
|
||||
handleError("PendingIntent unable to execute request: ".concat(e.getMessage()), ERROR_CANNOT_CHANGE_ACCURACY);
|
||||
}
|
||||
break;
|
||||
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
|
||||
handleError("Location settings are inadequate, and cannot be fixed here. Dialog not created.", ERROR_CANNOT_CHANGE_ACCURACY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
Log.i(TAG, "onActivityResult()");
|
||||
switch (requestCode) {
|
||||
// Check for the integer request code originally supplied to startResolutionForResult().
|
||||
case REQUEST_CHECK_SETTINGS:
|
||||
switch (resultCode) {
|
||||
case Activity.RESULT_OK:
|
||||
String msg = "User agreed to make required location settings changes.";
|
||||
Log.i(TAG, msg);
|
||||
handleSuccess(msg, SUCCESS_USER_AGREED);
|
||||
break;
|
||||
case Activity.RESULT_CANCELED:
|
||||
handleError("User chose not to make required location settings changes.", ERROR_USER_DISAGREED);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs when a GoogleApiClient object successfully connects.
|
||||
*/
|
||||
@Override
|
||||
public void onConnected(Bundle connectionHint) {
|
||||
Log.i(TAG, "Connected to GoogleApiClient");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionSuspended(int cause) {
|
||||
Log.i(TAG, "Connection suspended");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
Log.i(TAG, "On start");
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.i(TAG, "On onDestroy");
|
||||
if(mGoogleApiClient != null){
|
||||
super.onStop();
|
||||
Log.i(TAG, "Disconnect Google API client");
|
||||
try {
|
||||
mGoogleApiClient.disconnect();
|
||||
}catch(Exception e ) {
|
||||
handleError(e.getMessage(), ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(ConnectionResult result) {
|
||||
// https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult
|
||||
permanentError = result;
|
||||
String reason;
|
||||
switch (result.getErrorCode()){
|
||||
case ConnectionResult.API_UNAVAILABLE:
|
||||
reason = "One of the API components you attempted to connect to is not available.";
|
||||
break;
|
||||
case ConnectionResult.CANCELED:
|
||||
reason = "The connection was canceled.";
|
||||
break;
|
||||
case ConnectionResult.DEVELOPER_ERROR:
|
||||
reason = "The application is misconfigured.";
|
||||
break;
|
||||
case ConnectionResult.INTERNAL_ERROR:
|
||||
reason = "An internal error occurred.";
|
||||
break;
|
||||
case ConnectionResult.INTERRUPTED:
|
||||
reason = "An interrupt occurred while waiting for the connection complete.";
|
||||
break;
|
||||
case ConnectionResult.INVALID_ACCOUNT:
|
||||
reason = "he client attempted to connect to the service with an invalid account name specified.";
|
||||
break;
|
||||
case ConnectionResult.LICENSE_CHECK_FAILED:
|
||||
reason = "The application is not licensed to the user.";
|
||||
break;
|
||||
case ConnectionResult.NETWORK_ERROR:
|
||||
reason = "A network error occurred.";
|
||||
break;
|
||||
case ConnectionResult.RESOLUTION_REQUIRED:
|
||||
reason = "Completing the connection requires some form of resolution.";
|
||||
break;
|
||||
case ConnectionResult.SERVICE_DISABLED:
|
||||
reason = "The installed version of Google Play services has been disabled on this device.";
|
||||
break;
|
||||
case ConnectionResult.SERVICE_INVALID:
|
||||
reason = "The version of the Google Play services installed on this device is not authentic.";
|
||||
break;
|
||||
case ConnectionResult.SERVICE_MISSING:
|
||||
reason = "Google Play services is missing on this device.";
|
||||
break;
|
||||
case ConnectionResult.SERVICE_MISSING_PERMISSION:
|
||||
reason = "Google Play service doesn't have one or more required permissions.";
|
||||
break;
|
||||
case ConnectionResult.SERVICE_UPDATING:
|
||||
reason = "Google Play service is currently being updated on this device.";
|
||||
break;
|
||||
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
|
||||
reason = "The installed version of Google Play services is out of date.";
|
||||
break;
|
||||
case ConnectionResult.SIGN_IN_FAILED:
|
||||
reason = "The client attempted to connect to the service but the user is not signed in.";
|
||||
break;
|
||||
case ConnectionResult.SIGN_IN_REQUIRED:
|
||||
reason = "The client attempted to connect to the service but the user is not signed in.";
|
||||
break;
|
||||
case ConnectionResult.TIMEOUT:
|
||||
reason = "The timeout was exceeded while waiting for the connection to complete.";
|
||||
break;
|
||||
default:
|
||||
reason = "Unknown reason";
|
||||
}
|
||||
handleError("Failed to connect to Google Play Services: ".concat(reason), ERROR_GOOGLE_API_CONNECTION_FAILED);
|
||||
|
||||
int status = googleApiAvailability.isGooglePlayServicesAvailable(cordova.getActivity().getApplicationContext());
|
||||
if (googleApiAvailability.isUserResolvableError (status)) {
|
||||
Dialog dialog = googleApiAvailability.getErrorDialog(cordova.getActivity(),status, 0);
|
||||
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialogInterface) {
|
||||
cordova.getActivity().finish();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
permanentError = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
|
||||
@interface RequestLocationAccuracy : CDVPlugin <CLLocationManagerDelegate>{
|
||||
@private BOOL __locationStarted;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) CLLocationManager* locationManager;
|
||||
|
||||
- (void) request:(CDVInvokedUrlCommand*)command;
|
||||
- (void) isRequesting:(CDVInvokedUrlCommand*)command;
|
||||
- (void) canRequest:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
@ -0,0 +1,119 @@
|
||||
#import "RequestLocationAccuracy.h"
|
||||
|
||||
@implementation RequestLocationAccuracy
|
||||
|
||||
// Initialization
|
||||
@synthesize locationManager;
|
||||
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
self.locationManager = [[CLLocationManager alloc] init];
|
||||
self.locationManager.delegate = self;
|
||||
__locationStarted = NO;
|
||||
}
|
||||
|
||||
// Plugin API
|
||||
- (void) request:(CDVInvokedUrlCommand*)command;{
|
||||
CDVPluginResult* pluginResult;
|
||||
@try {
|
||||
if (__locationStarted) {
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Location is already being requested"];
|
||||
}else if(![self canRequest]){
|
||||
// Location services is already enabled
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||
}else{
|
||||
[self.locationManager startUpdatingLocation];
|
||||
__locationStarted = YES;
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||
}
|
||||
}@catch (NSException *exception) {
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
||||
}
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
- (void) isRequesting:(CDVInvokedUrlCommand*)command;{
|
||||
int result;
|
||||
if(__locationStarted){
|
||||
result = 1;
|
||||
}else{
|
||||
result = 0;
|
||||
}
|
||||
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:result] callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
- (void) canRequest:(CDVInvokedUrlCommand*)command;{
|
||||
int result;
|
||||
if([self canRequest]){
|
||||
result = 1;
|
||||
}else{
|
||||
result = 0;
|
||||
}
|
||||
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:result] callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
// Internals
|
||||
|
||||
- (BOOL) canRequest
|
||||
{
|
||||
return ![self isLocationServicesEnabled] && !__locationStarted;
|
||||
}
|
||||
|
||||
|
||||
- (void)stopRequestingLocation
|
||||
{
|
||||
if (__locationStarted) {
|
||||
[self.locationManager stopUpdatingLocation];
|
||||
__locationStarted = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isAuthorized
|
||||
{
|
||||
BOOL authorizationStatusClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
|
||||
|
||||
if (authorizationStatusClassPropertyAvailable) {
|
||||
NSUInteger authStatus = [CLLocationManager authorizationStatus];
|
||||
#ifdef __IPHONE_8_0
|
||||
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { //iOS 8.0+
|
||||
return (authStatus == kCLAuthorizationStatusAuthorizedWhenInUse) || (authStatus == kCLAuthorizationStatusAuthorizedAlways) || (authStatus == kCLAuthorizationStatusNotDetermined);
|
||||
}
|
||||
#endif
|
||||
return (authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusNotDetermined);
|
||||
}
|
||||
|
||||
// by default, assume YES (for iOS < 4.2)
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isLocationServicesEnabled
|
||||
{
|
||||
BOOL locationServicesEnabledInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 3.x
|
||||
BOOL locationServicesEnabledClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 4.x
|
||||
|
||||
if (locationServicesEnabledClassPropertyAvailable) { // iOS 4.x
|
||||
return [CLLocationManager locationServicesEnabled];
|
||||
} else if (locationServicesEnabledInstancePropertyAvailable) { // iOS 2.x, iOS 3.x
|
||||
return [(id)self.locationManager locationServicesEnabled];
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - locationManager delegate
|
||||
|
||||
- (void)locationManager:(CLLocationManager*)manager
|
||||
didUpdateToLocation:(CLLocation*)newLocation
|
||||
fromLocation:(CLLocation*)oldLocation
|
||||
{
|
||||
[self stopRequestingLocation];
|
||||
|
||||
}
|
||||
|
||||
- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
|
||||
{
|
||||
NSLog(@"locationManager::didFailWithError %@", [error localizedFailureReason]);
|
||||
[self stopRequestingLocation];
|
||||
}
|
||||
|
||||
@end
|
||||
151
plugins/cordova-plugin-request-location-accuracy/www/android/RequestLocationAccuracy.js
vendored
Normal file
151
plugins/cordova-plugin-request-location-accuracy/www/android/RequestLocationAccuracy.js
vendored
Normal file
@ -0,0 +1,151 @@
|
||||
/**
|
||||
* Request Location Accuracy plugin
|
||||
*
|
||||
* Copyright (c) 2016 Dave Alden (Working Edge Ltd.)
|
||||
**/
|
||||
var RequestLocationAccuracy = function(){
|
||||
this.requesting = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Request location mode priority "no power": the best accuracy possible with zero additional power consumption.
|
||||
* https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#PRIORITY_NO_POWER
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.REQUEST_PRIORITY_NO_POWER = 0;
|
||||
|
||||
/**
|
||||
* Request location mode priority "low power": "city" level accuracy (about 10km accuracy)
|
||||
* https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#PRIORITY_LOW_POWER
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.REQUEST_PRIORITY_LOW_POWER = 1;
|
||||
|
||||
/**
|
||||
* Request location mode priority "balanced power": "block" level accuracy (about 100 meter accuracy)
|
||||
* https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#PRIORITY_BALANCED_POWER_ACCURACY
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.REQUEST_PRIORITY_BALANCED_POWER_ACCURACY = 2;
|
||||
|
||||
/**
|
||||
* Request location mode priority "high accuracy": the most accurate locations available. This will use GPS hardware to retrieve positions.
|
||||
* https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#PRIORITY_HIGH_ACCURACY
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.REQUEST_PRIORITY_HIGH_ACCURACY = 3;
|
||||
|
||||
|
||||
/**
|
||||
* Success due to current location settings already satisfying requested accuracy
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.SUCCESS_SETTINGS_SATISFIED = 0;
|
||||
|
||||
/**
|
||||
* Success due to user agreeing to requested accuracy change
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.SUCCESS_USER_AGREED = 1;
|
||||
|
||||
/**
|
||||
* Error due an unresolved request already being in progress.
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.ERROR_ALREADY_REQUESTING = -1;
|
||||
|
||||
/**
|
||||
* Error due invalid action requested
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.ERROR_INVALID_ACTION = 0;
|
||||
|
||||
/**
|
||||
* Error due invalid accuracy requested
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.ERROR_INVALID_ACCURACY = 1;
|
||||
|
||||
/**
|
||||
* Error due to exception in the native code
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.ERROR_EXCEPTION = 2;
|
||||
|
||||
/**
|
||||
* Error due to not being able to change location accuracy to requested state
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.ERROR_CANNOT_CHANGE_ACCURACY = 3;
|
||||
|
||||
/**
|
||||
* Error due to user rejecting requested accuracy change
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.ERROR_USER_DISAGREED = 4;
|
||||
|
||||
/**
|
||||
* Error due to failure to connect to Google Play Services API
|
||||
* @type {number}
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.ERROR_GOOGLE_API_CONNECTION_FAILED = 5;
|
||||
|
||||
/**
|
||||
* Requests a specific accuracy for Location Services.
|
||||
*
|
||||
* @param [Function} successCallback - callback to be invoked on successful resolution of the requested accuracy.
|
||||
* A single object argument will be passed which has two keys: "code" in an integer corresponding to a SUCCESS constant and indicates the reason for success;
|
||||
* "message" is a string containing a description of the success.
|
||||
* @param {Function} errorCallback - callback to be invoked on failure to resolve the requested accuracy.
|
||||
* A single object argument will be passed which has two keys: "code" in an integer corresponding to an ERROR constant and indicates the reason for failure;
|
||||
* "message" is a string containing a description of the error.
|
||||
* @param {Integer} accuracy - The location accuracy to request defined by an integer corresponding to a REQUEST constant.
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.request = function(successCallback, errorCallback, accuracy) {
|
||||
var _this = this;
|
||||
|
||||
if(this.requesting){
|
||||
return errorCallback({
|
||||
code: _this.ERROR_ALREADY_REQUESTING,
|
||||
message: "A request is already in progress"
|
||||
});
|
||||
}
|
||||
|
||||
this.requesting = true;
|
||||
|
||||
return cordova.exec(function(data){
|
||||
_this.requesting = false;
|
||||
successCallback(data)
|
||||
},
|
||||
function(err) {
|
||||
_this.requesting = false;
|
||||
errorCallback(err);
|
||||
},
|
||||
'RequestLocationAccuracy',
|
||||
'request',
|
||||
[accuracy]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates if a request is currently in progress.
|
||||
*
|
||||
* @param [Function} successCallback - callback to pass result to.
|
||||
* This is passed a boolean argument indicating if a request is currently in progress;
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.isRequesting = function(successCallback) {
|
||||
successCallback(!!this.requesting);
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates if it is possible to request a specific location accuracy.
|
||||
* This will return true if the app is authorized to use location.
|
||||
*
|
||||
* @param [Function} successCallback - callback to pass result to.
|
||||
* This is passed a boolean argument indicating if a request can be made.
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.canRequest = function(successCallback) {
|
||||
return cordova.exec(successCallback, null, 'RequestLocationAccuracy', 'canRequest', []);
|
||||
};
|
||||
|
||||
module.exports = new RequestLocationAccuracy();
|
||||
|
||||
42
plugins/cordova-plugin-request-location-accuracy/www/ios/RequestLocationAccuracy.js
vendored
Normal file
42
plugins/cordova-plugin-request-location-accuracy/www/ios/RequestLocationAccuracy.js
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Request Location Accuracy plugin
|
||||
*
|
||||
* Copyright (c) 2016 Dave Alden (Working Edge Ltd.)
|
||||
**/
|
||||
var RequestLocationAccuracy = function(){
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Requests a position to invoke to native dialog to turn on Location Services.
|
||||
*
|
||||
* @param [Function} successCallback - callback to be invoked on successful position request.
|
||||
* @param {Function} errorCallback - callback to be invoked on failure to request position.
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.request = function(successCallback, errorCallback) {
|
||||
return cordova.exec(successCallback, errorCallback, 'RequestLocationAccuracy', 'request', []);
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates if a request is possible to invoke to native dialog to turn on Location Services.
|
||||
* This will return true if Location Services is currently OFF and request is not currently in progress.
|
||||
*
|
||||
* @param [Function} successCallback - callback to pass result to.
|
||||
* This is passed a boolean argument indicating if a request can be made.
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.canRequest = function(successCallback) {
|
||||
return cordova.exec(successCallback, null, 'RequestLocationAccuracy', 'canRequest', []);
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates if a request is currently in progress.
|
||||
*
|
||||
* @param [Function} successCallback - callback to pass result to.
|
||||
* This is passed a boolean argument indicating if a request is currently in progress;
|
||||
*/
|
||||
RequestLocationAccuracy.prototype.isRequesting = function(successCallback) {
|
||||
return cordova.exec(successCallback, null, 'RequestLocationAccuracy', 'isRequesting', []);
|
||||
};
|
||||
|
||||
module.exports = new RequestLocationAccuracy();
|
||||
|
||||
@ -122,5 +122,13 @@
|
||||
},
|
||||
"is_top_level": true,
|
||||
"variables": {}
|
||||
},
|
||||
"cordova-plugin-request-location-accuracy": {
|
||||
"source": {
|
||||
"type": "registry",
|
||||
"id": "cordova-plugin-request-location-accuracy"
|
||||
},
|
||||
"is_top_level": true,
|
||||
"variables": {}
|
||||
}
|
||||
}
|
||||
@ -12,8 +12,7 @@ import { AuthPage } from '../pages/auth/auth';
|
||||
import {AppVersion} from '@ionic-native/app-version'
|
||||
import { HomePageModule } from '../pages/sales_pd/pages/home/home.module';
|
||||
import { HomePage } from '../pages/sales_pd/pages/home/home';
|
||||
|
||||
|
||||
import { SalesPDlistPage } from '../pages/sales_pd/pages/sales-p-dlist/sales-p-dlist';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'app.html'
|
||||
@ -35,8 +34,7 @@ export class MyApp {
|
||||
// used for an example of ngFor and navigation
|
||||
this.pages = [
|
||||
// { title: 'Home', component: HomePage, icon: 'home' },
|
||||
{ title: 'Home', icon: 'home',method:()=>this.menulist(3) },
|
||||
{ title :'Sales PD',icon:'list',method:()=>this.menulist(3)},
|
||||
{ title: 'Home', icon: 'home',method:()=>this.menulist(1) },
|
||||
{ title: 'Logout', icon: 'md-exit',method:()=>this.menulist(2)}
|
||||
];
|
||||
|
||||
@ -114,7 +112,12 @@ export class MyApp {
|
||||
{
|
||||
this.userAccess = true;
|
||||
this.userDetails = this.userDetails.records[0];
|
||||
|
||||
localStorage.setItem("user_details",JSON.stringify( this.userDetails));
|
||||
if(this.userDetails.short_name == 'SMC'){
|
||||
this.pages.splice(-1,1)
|
||||
this.pages.push( { title :'Sales PD',icon:'list',method:()=>this.menulist(3)},
|
||||
{ title: 'Logout', icon: 'md-exit',method:()=>this.menulist(2)})
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@ -133,7 +136,7 @@ export class MyApp {
|
||||
});
|
||||
break;
|
||||
case 3:
|
||||
this.nav.setRoot(HomePage);
|
||||
this.nav.setRoot(SalesPDlistPage);
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
|
||||
@ -66,7 +66,7 @@ import { QuestionCategoryProvider } from '../providers/question-category/questio
|
||||
|
||||
import { ReactiveFormsModule,FormsModule} from '@angular/forms';
|
||||
import { IonicImageViewerModule } from 'ionic-img-viewer';
|
||||
import { CameraProvider } from '../providers/common-provider/camera';
|
||||
// import { CameraProvider } from '../providers/common-provider/camera';
|
||||
import { LoadingProvider } from '../providers/common-provider/loading';
|
||||
import { Camera } from '@ionic-native/camera';
|
||||
|
||||
@ -76,6 +76,10 @@ import {AppVersion} from '@ionic-native/app-version'
|
||||
// import { SalesPdProvider } from '../pages/sales_pd/providers/sales-pd/sales-pd';
|
||||
// import { HomePage } from '../pages/sales_pd/pages/home/home';
|
||||
import { HomePageModule } from '../pages/sales_pd/pages/home/home.module';
|
||||
import { CameraProvider } from '../pages/sales_pd/providers/camera/camera';
|
||||
import { SalesPDlistPage } from '../pages/sales_pd/pages/sales-p-dlist/sales-p-dlist';
|
||||
import { LocationAccuracy } from '@ionic-native/location-accuracy';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
@ -88,7 +92,7 @@ import { HomePageModule } from '../pages/sales_pd/pages/home/home.module';
|
||||
PasswordPage,
|
||||
PdAllocationPage,
|
||||
InputPage,
|
||||
|
||||
SalesPDlistPage
|
||||
|
||||
],
|
||||
imports: [
|
||||
@ -140,6 +144,7 @@ import { HomePageModule } from '../pages/sales_pd/pages/home/home.module';
|
||||
PasswordPage,
|
||||
PdAllocationPage,
|
||||
InputPage,
|
||||
SalesPDlistPage
|
||||
|
||||
],
|
||||
providers: [
|
||||
@ -156,8 +161,9 @@ import { HomePageModule } from '../pages/sales_pd/pages/home/home.module';
|
||||
},LaunchNavigator,
|
||||
AwsServiceProvider,
|
||||
QuestionCategoryProvider,
|
||||
CameraProvider,Camera,
|
||||
CameraProvider,Camera,LocationAccuracy,
|
||||
LoadingProvider,Geolocation,AppVersion,
|
||||
CameraProvider,
|
||||
|
||||
|
||||
],
|
||||
|
||||
@ -234,4 +234,5 @@ ion-content {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
src/assets/img/PD_watermark.png
Executable file
BIN
src/assets/img/PD_watermark.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@ -68,6 +68,7 @@ export class PdListPage {
|
||||
this.userDetails = res;
|
||||
if(this.userDetails.dataStatus == true){
|
||||
this.userDetails = this.userDetails.records[0];
|
||||
localStorage.setItem("user_details",JSON.stringify( this.userDetails));
|
||||
// console.log('this.userDetails.records[0]',this.userDetails.records[0]);
|
||||
this.pdofficer.getpddetails(this.userDetails.fk_entity_id,this.userDetails.userid).subscribe(res=>
|
||||
{
|
||||
|
||||
@ -10,6 +10,8 @@ import { BrowserModule } from '@angular/platform-browser';
|
||||
import { IonicModule } from 'ionic-angular';
|
||||
import { MyApp } from '../../../app/app.component';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [QuesTemplateComponent],
|
||||
imports: [MatButtonToggleModule,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!-- Generated template for the QuesTemplateComponent component -->
|
||||
<div>
|
||||
<form [formGroup]="quesAnsForm" (ngSubmit)="onSubmit()">
|
||||
<div *ngIf="questions_JSON.questions.length > 0">
|
||||
<form [formGroup]="quesAnsForm" >
|
||||
<div *ngIf="quesAnsForm.controls['questions']">
|
||||
<div formArrayName="questions">
|
||||
<div *ngFor="let parent_ques of quesAnsForm.controls['questions'].controls;let p_i=index">
|
||||
@ -11,39 +11,90 @@
|
||||
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '1'">
|
||||
|
||||
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||
<input matInput type="text" formControlName="answer_value" placeholder="Enter the Text" (change)="onChangeProperty($event,parent_ques)"
|
||||
<input matInput [type]="parent_ques.get('field_type').value == 'num' ? 'number' : 'text'" formControlName="answer_value" placeholder="Enter the Text"
|
||||
autocomplete="off">
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
<!-- <mat-form-field> -->
|
||||
<div class="radio-gap" *ngIf="parent_ques.get('type').value == '2'">
|
||||
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||
<mat-radio-group aria-label="Select an option" formControlName="answer_value" (change)="onChangeProperty($event,parent_ques)">
|
||||
<mat-radio-button class="radio-btn-gap" *ngFor="let val of parent_ques.get('answers').value" [value]="val.answer">{{val.answer}}</mat-radio-button><br />
|
||||
<mat-radio-button class="radio-btn-gap" *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-radio-button><br />
|
||||
</mat-radio-group>
|
||||
</div>
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '3'">
|
||||
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||
<mat-select required formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques,p_i)">
|
||||
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques,p_i)">
|
||||
<mat-option *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="radio-gap" formArrayName="answer_value" *ngIf="parent_ques.get('type').value == '5'">
|
||||
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||
<mat-checkbox class="radio-btn-gap" *ngFor="let val of parent_ques.get('answers').value" [value]="val.answer" (change)="onChange_checkbox($event,parent_ques);onChangeProperty($event,parent_ques)">{{val.answer}}</mat-checkbox><br />
|
||||
<mat-checkbox class="radio-btn-gap" *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer" (change)="onChange_checkbox($event,parent_ques)">{{val.answer}}</mat-checkbox><br />
|
||||
</div>
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '4'">
|
||||
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||
<mat-select multiple formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques)">
|
||||
<mat-option *ngFor="let val of parent_ques.get('answers').value" [value]="val.answer">{{val.answer}}</mat-option>
|
||||
<mat-select multiple formControlName="answer_value" >
|
||||
<mat-option *ngFor="let val of parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div *ngIf="parent_ques.get('type').value == '6'">
|
||||
<ion-grid >
|
||||
<ion-row>
|
||||
<ion-col col-6 no-padding>
|
||||
<div >
|
||||
<img *ngIf="parent_ques.get('answer_value').value != ''" [src]="parent_ques.get('answer_value').value" imageViewer class="doc-image-bucket"><br/>
|
||||
<label ><strong>{{parent_ques.get('question').value}}</strong></label>
|
||||
<!-- <input *ngIf="image.Name =='' && image.option != 'dummy'" width="20px" ion-input type="text" placeholder="Document Name" (blur)="changeName($event.target.value,i,image.image)"> -->
|
||||
<!-- <button *ngIf="image.option != 'dummy'" ion-button clear color="optblue" (click)="removeImg(i)"><ion-icon style="font-size:22px" name="md-trash"></ion-icon></button> -->
|
||||
</div>
|
||||
<div style="justify-content: center">
|
||||
<button ion-button clear color="optblue" (click)="captureImg(p_i,parent_ques)"><ion-icon style="font-size: 30px" name="md-camera"></ion-icon></button>
|
||||
</div>
|
||||
</ion-col>
|
||||
<hr/>
|
||||
</ion-row>
|
||||
<hr/>
|
||||
<hr/>
|
||||
</ion-grid>
|
||||
</div>
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '7'">
|
||||
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||
<textarea matInput type="text" rows="3" formControlName="answer_value" placeholder="Enter the Text"
|
||||
autocomplete="off" ></textarea>
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="parent_ques.get('type').value == '8'">
|
||||
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques,p_i)">
|
||||
<mat-option>
|
||||
<ngx-mat-select-search formControlName="select_search"
|
||||
[placeholderLabel]="'Search'"
|
||||
[noEntriesFoundLabel]="'No Matching Result'" (keyup)="searchFun(parent_ques,p_i)">
|
||||
<ion-icon name="md-close" ngxMatSelectSearchClear></ion-icon>
|
||||
</ngx-mat-select-search>
|
||||
</mat-option>
|
||||
<mat-option>--</mat-option>
|
||||
|
||||
<mat-option *ngFor="let val of fileredSearchValue.length > 0 ? fileredSearchValue[p_i] : parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="radio-gap" *ngIf="parent_ques.get('is_repeatable').value == '1'">
|
||||
|
||||
<div class="radio-gap" *ngIf="parent_ques.get('is_repeatable').value == '1' && parent_ques.controls['questions_group']">
|
||||
<!-- <mat-card> -->
|
||||
<!-- <mat-card-header>
|
||||
<mat-card-title>
|
||||
@ -51,11 +102,11 @@
|
||||
</mat-card-title>
|
||||
</mat-card-header> -->
|
||||
|
||||
<div formArrayName="questions_group">
|
||||
<div
|
||||
<div formArrayName="questions_group" *ngIf="parent_ques.get('group_type').value != '6'">
|
||||
<span
|
||||
*ngFor="let group_ques of parent_ques.controls.questions_group['controls'];let g_i=index;let g_l=last"
|
||||
[formGroupName]="g_i">
|
||||
<mat-accordion>
|
||||
<mat-accordion *ngIf="parent_ques.get('group_type').value != '6'">
|
||||
<mat-expansion-panel [expanded]="step === g_i" >
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
@ -66,43 +117,81 @@
|
||||
</mat-panel-description> -->
|
||||
</mat-expansion-panel-header>
|
||||
|
||||
<div formArrayName="questions">
|
||||
<div formArrayName="questions" *ngIf="group_ques.controls['questions']">
|
||||
<div
|
||||
*ngFor="let single_ques of group_ques.controls.questions['controls'];let s_i=index;let s_l=last"
|
||||
[formGroupName]="s_i">
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '1'">
|
||||
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||
<input matInput type="text" formControlName="answer_value" placeholder="Enter the Text"
|
||||
<input matInput [type]="single_ques.get('field_type').value == 'num' ? 'number' : 'text'" formControlName="answer_value" placeholder="Enter the Text"
|
||||
autocomplete="off">
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="radio-gap" *ngIf="single_ques.get('type').value == '2'">
|
||||
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||
<mat-radio-group aria-label="Select an option" formControlName="answer_value">
|
||||
<mat-radio-button class="radio-btn-gap" *ngFor="let val of single_ques.get('answers').value" [value]="val.answer">{{val.answer}}</mat-radio-button><br />
|
||||
<mat-radio-group aria-label="Select an option" formControlName="answer_value" (change)="onChangeProperty($event,single_ques,group_ques,2)">
|
||||
<mat-radio-button class="radio-btn-gap" *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-radio-button><br />
|
||||
</mat-radio-group>
|
||||
</div>
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '3'">
|
||||
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||
<mat-select required formControlName="answer_value">
|
||||
<mat-option *ngFor="let val of single_ques.get('answers').value" [value]="val.answer">{{val.answer}}</mat-option>
|
||||
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,single_ques,group_ques,2)">
|
||||
<mat-option *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="radio-gap" formArrayName="answer_value" *ngIf="single_ques.get('type').value == '5'">
|
||||
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||
<mat-checkbox class="radio-btn-gap" *ngFor="let val of single_ques.get('answers').value" [value]="val.answer" (change)="onChange_checkbox($event,single_ques,group_ques)">{{val.answer}}</mat-checkbox><br />
|
||||
<mat-checkbox class="radio-btn-gap" *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer" (change)="onChange_checkbox($event,single_ques)">{{val.answer}}</mat-checkbox><br />
|
||||
|
||||
</div>
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '4'">
|
||||
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||
<mat-select multiple formControlName="answer_value">
|
||||
<mat-option *ngFor="let val of single_ques.get('answers').value" [value]="val.answer">{{val.answer}}</mat-option>
|
||||
<mat-option *ngFor="let val of single_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '7'">
|
||||
<mat-label>{{single_ques.get('question').value}}</mat-label>
|
||||
<textarea matInput type="text" rows="3" formControlName="answer_value" placeholder="Enter the Text"
|
||||
autocomplete="off" ></textarea>
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="single_ques.get('type').value == '8'">
|
||||
<mat-label>{{parent_ques.get('question').value}}</mat-label>
|
||||
<mat-select formControlName="answer_value" (selectionChange)="onChangeProperty($event,parent_ques,p_i)">
|
||||
<mat-option>
|
||||
<ngx-mat-select-search formControlName="select_search"
|
||||
[placeholderLabel]="'Search'"
|
||||
[noEntriesFoundLabel]="'No Matching Result'" (keyup)="searchFun(parent_ques,p_i)">
|
||||
<ion-icon name="md-close" ngxMatSelectSearchClear></ion-icon>
|
||||
</ngx-mat-select-search>
|
||||
</mat-option>
|
||||
<mat-option>--</mat-option>
|
||||
|
||||
<mat-option *ngFor="let val of fileredSearchValue.length > 0 ? fileredSearchValue[p_i] : parent_ques.get('answers').value" [value]="val.hasOwnProperty('answer_id') ? val.answer_id : val.answer">{{val.answer}}</mat-option>
|
||||
</mat-select>
|
||||
<mat-error align="end" style="font-style: italic;margin-right: 5px;">Field is Required</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<div *ngIf="single_ques.controls['subfield_key']">
|
||||
<!-- <div *ngIf="parent_ques.controls[parent_ques.get('subfield_key').value]"> -->
|
||||
<mat-form-field style="width: 100%" >
|
||||
|
||||
<mat-label>{{single_ques.get('subfield_caption').value}}</mat-label>
|
||||
<input matInput type="text" formControlName="subfield_value" placeholder="Enter the Text"
|
||||
autocomplete="off">
|
||||
</mat-form-field>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -121,9 +210,63 @@
|
||||
</ion-buttons>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<div formArrayName="questions_group" *ngIf="parent_ques.get('group_type').value == '6'">
|
||||
<hr class="hr">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
<h5> {{parent_ques.get('group_title').value}}</h5>
|
||||
</mat-card-title>
|
||||
</mat-card-header>
|
||||
|
||||
<ion-grid >
|
||||
<ion-row>
|
||||
<span
|
||||
*ngFor="let group_ques of parent_ques.controls.questions_group['controls'];let g_i=index;let g_l=last"
|
||||
[formGroupName]="g_i">
|
||||
<!-- </mat-card> -->
|
||||
<span formArrayName="questions" *ngIf="group_ques.controls['questions'] && parent_ques.get('group_type').value == '6'" >
|
||||
<!-- <div > -->
|
||||
|
||||
<!-- <div *ngIf="single_ques.get('type').value == '10'"> -->
|
||||
|
||||
<ion-col col-6 no-padding *ngFor="let single_ques of group_ques.controls.questions['controls'];let s_i=index;let s_l=last"
|
||||
[formGroupName]="s_i">
|
||||
<div style="justify-content: center;text-align: center" *ngIf="single_ques.get('answer_value').value != ''">
|
||||
<img [src]="single_ques.get('answer_value').value" imageViewer class="doc-image-bucket" width="130px"><br/>
|
||||
<label style="font-size: 10px">{{single_ques.get('question').value}} {{g_i+1}}</label>
|
||||
<!-- <input *ngIf="image.Name =='' && image.option != 'dummy'" width="20px" ion-input type="text" placeholder="Document Name" (blur)="changeName($event.target.value,i,image.image)"> -->
|
||||
<button ion-button clear color="optblue" (click)="removeData(g_i,parent_ques)"><ion-icon style="font-size:22px" name="md-trash"></ion-icon></button>
|
||||
</div>
|
||||
<!-- <div style="justify-content: center">
|
||||
<button ion-button clear color="optblue" (click)="captureImg()"><ion-icon style="font-size: 30px" name="md-camera"></ion-icon></button>
|
||||
</div> -->
|
||||
<div class="add-more-image" *ngIf="g_l">
|
||||
<button ion-button clear style="color: black" (click)="addData(g_i,parent_ques,group_ques.get('questions').value,$event,'camera',single_ques)"><ion-icon style="font-size:35px" name="md-camera"></ion-icon>+</button>
|
||||
</div>
|
||||
</ion-col>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- </div> -->
|
||||
|
||||
<!-- </div> -->
|
||||
</span>
|
||||
<div *ngIf="g_l" style="justify-content: flex-end">
|
||||
|
||||
</div>
|
||||
</span>
|
||||
</ion-row>
|
||||
|
||||
</ion-grid>
|
||||
<hr class="hr">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="parent_ques.controls['subfield_key']">
|
||||
@ -131,7 +274,7 @@
|
||||
<mat-form-field style="width: 100%" >
|
||||
|
||||
<mat-label>{{parent_ques.get('subfield_caption').value}}</mat-label>
|
||||
<input matInput type="text" formControlName="subfield_key" placeholder="Enter the Text"
|
||||
<input matInput type="text" formControlName="subfield_value" placeholder="Enter the Text"
|
||||
autocomplete="off">
|
||||
</mat-form-field>
|
||||
<!-- </div> -->
|
||||
@ -141,8 +284,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ion-buttons end>
|
||||
<button ion-button type="submit" color="primary">dd</button>
|
||||
<ion-buttons end class="save-btn">
|
||||
<button ion-button type="submit" round color="optblue" (click)="onSubmit()"><ion-icon style="color:gray;font-size: 30px;" name="md-arrow-dropright-circle"></ion-icon> {{submit_btn ? 'Submit' : 'Proceed'}} </button>
|
||||
</ion-buttons>
|
||||
</form>
|
||||
</div>
|
||||
@ -9,4 +9,27 @@ ques-template {
|
||||
.radio-btn-gap{
|
||||
margin:10px;
|
||||
}
|
||||
.doc-image-bucket{
|
||||
padding:0 5px 0 0 !important;
|
||||
width: 120px;
|
||||
height: 80px !important;
|
||||
color:black;
|
||||
//width:130px;
|
||||
//border:3px solid black;
|
||||
//border-radius: 20px;
|
||||
//background-color: gray;
|
||||
}
|
||||
.add-more-image{
|
||||
width: 60%;
|
||||
padding:0 5px 0 0 !important;
|
||||
width: 120px;
|
||||
height: 80px !important;
|
||||
// border: 2px solid gainsboro;
|
||||
// border-style: dashed;
|
||||
// border-radius: 10px;
|
||||
}
|
||||
.hr, hr{
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from 'ionic-angular';
|
||||
import { HomePage } from './home';
|
||||
import { HomePage, Section2, Section3, Section4, Section5, Section6, Section7, Section8, Section9, Section1 } from './home';
|
||||
import { QuesTemplateComponent } from '../../components/ques-template/ques-template';
|
||||
import { ComponentsModule } from '../../components/components.module';
|
||||
import { SalesPdProvider } from '../../providers/sales-pd/sales-pd';
|
||||
@ -12,8 +12,17 @@ import { IonicStorageModule } from '@ionic/storage';
|
||||
@NgModule({
|
||||
declarations: [
|
||||
HomePage,
|
||||
Section1,
|
||||
Section2,
|
||||
Section3,
|
||||
Section4,
|
||||
Section5,
|
||||
Section6,
|
||||
Section7,
|
||||
Section8,
|
||||
Section9
|
||||
],
|
||||
entryComponents:[HomePage],
|
||||
entryComponents:[HomePage,Section1, Section2,Section3, Section4, Section5, Section6, Section7, Section8, Section9],
|
||||
imports: [
|
||||
ComponentsModule,
|
||||
IonicPageModule.forChild(HomePage),
|
||||
|
||||
@ -3,4 +3,15 @@ ion-content{
|
||||
background: white!important;
|
||||
background-color: white
|
||||
}
|
||||
.mat-radio-label {
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
white-space: pre-line;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.mat-radio-button{
|
||||
min-width: 35%;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||
import { IonicPage, NavController, NavParams, Toast } from 'ionic-angular';
|
||||
import { SalesPdProvider } from '../../providers/sales-pd/sales-pd';
|
||||
import { ToastProvider } from '../../../../providers/common-provider/toast';
|
||||
import { PdtriggerProvider } from '../../../../providers/pdtrigger/pdtrigger';
|
||||
import { SalesPDlistPage } from '../sales-p-dlist/sales-p-dlist';
|
||||
import { CameraProvider } from '../../providers/camera/camera';
|
||||
|
||||
|
||||
/**
|
||||
* Generated class for the HomePage page.
|
||||
@ -12,17 +17,111 @@ import { SalesPdProvider } from '../../providers/sales-pd/sales-pd';
|
||||
@IonicPage()
|
||||
@Component({
|
||||
selector: 'page-home',
|
||||
templateUrl: 'product-list.html',
|
||||
})
|
||||
export class HomePage{
|
||||
productList: any;
|
||||
product:string='';
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private toastProvider:ToastProvider,private pdTriggerProvider:PdtriggerProvider){
|
||||
this.getProducts()
|
||||
}
|
||||
getProducts(){
|
||||
let users:any=localStorage.getItem('user_details')
|
||||
users=JSON.parse(users)
|
||||
this.pdTriggerProvider.getEntityPreferences(users.fk_entity_id).subscribe(result=>{
|
||||
if(result['dataStatus']){
|
||||
this.productList=result['records'].products;
|
||||
}
|
||||
})
|
||||
}
|
||||
sendProduct(){
|
||||
if(this.product != ''){
|
||||
localStorage.setItem('product_id_salesPD',this.product)
|
||||
this.navCtrl.push(Section1,{product_id:this.product})
|
||||
}
|
||||
else{
|
||||
this.toastProvider.lenderappmessage("Please Choose the Product")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'section1',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class HomePage {
|
||||
export class Section1 {
|
||||
question_data: any={section_name:'',questions:[]};
|
||||
raw_data:any;
|
||||
section_local:number=1
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private toastProvider:ToastProvider,private cameraProvider:CameraProvider) {
|
||||
let product_id;
|
||||
if(this.navParams.get('product_id')){
|
||||
product_id=this.navParams.get('product_id')
|
||||
}
|
||||
// this.raw_data=this.SalesPDService.getData()
|
||||
this.SalesPDService.getData(product_id).subscribe(result=>{
|
||||
console.log("result",result)
|
||||
this.raw_data=JSON.parse(result['records'].template)
|
||||
this.raw_data.sections.forEach((val,index)=>{
|
||||
val.order_id=index+1
|
||||
})
|
||||
|
||||
this.SalesPDService.original_rawData=this.raw_data
|
||||
localStorage.setItem('question_temp_salespd',JSON.stringify(this.raw_data))
|
||||
console.log("sales pd",this.SalesPDService.original_rawData)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
this.SalesPDService.available_sections=this.all_sections
|
||||
this.SalesPDService.current_section='1';
|
||||
console.log(this.all_sections)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
this.cameraProvider.enableAccuracy()
|
||||
|
||||
|
||||
}
|
||||
onChange(){
|
||||
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event);
|
||||
if(this.all_sections.length != event.section_id){
|
||||
this.navCtrl.push(Section2)
|
||||
}
|
||||
else{
|
||||
// this.sendData()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'section2',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class Section2 {
|
||||
question_data: any;
|
||||
raw_data:any;
|
||||
section_local:number=0
|
||||
section_local:number=2
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider) {
|
||||
|
||||
this.raw_data=this.SalesPDService.getData()
|
||||
this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local+1)[0]
|
||||
// if(this.navParams.get('sec_no')){
|
||||
// this.section_local=this.navParams.get('sec_no')
|
||||
// }
|
||||
this.raw_data=localStorage.getItem('question_temp_salespd')
|
||||
this.raw_data=JSON.parse(this.raw_data)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
}
|
||||
|
||||
@ -35,7 +134,403 @@ export class HomePage {
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event);
|
||||
this.navCtrl.push(Section3)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'section3',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class Section3 {
|
||||
question_data: any;
|
||||
raw_data:any;
|
||||
section_local:number=3
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider) {
|
||||
// if(this.navParams.get('sec_no')){
|
||||
// this.section_local=this.navParams.get('sec_no')
|
||||
// }
|
||||
// this.SalesPDService.getData().subscribe(result=>{
|
||||
// this.raw_data=result['records']
|
||||
// this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
// this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local)[0]
|
||||
// console.log(this.question_data)
|
||||
// })
|
||||
this.raw_data=localStorage.getItem('question_temp_salespd')
|
||||
this.raw_data=JSON.parse(this.raw_data)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
console.log(this.all_sections)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
|
||||
|
||||
}
|
||||
onChange(){
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event);
|
||||
if(this.all_sections[this.all_sections.length - 1] != event.section_id){
|
||||
this.navCtrl.push(Section4)
|
||||
}
|
||||
else{
|
||||
// this.sendData()
|
||||
console.log("else part")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'section4',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class Section4 {
|
||||
question_data: any;
|
||||
raw_data:any;
|
||||
section_local:number=4
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider) {
|
||||
// if(this.navParams.get('sec_no')){
|
||||
// this.section_local=this.navParams.get('sec_no')
|
||||
// }
|
||||
// this.SalesPDService.getData().subscribe(result=>{
|
||||
// this.raw_data=result['records']
|
||||
// this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
// this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local)[0]
|
||||
// console.log(this.question_data)
|
||||
// })
|
||||
this.raw_data=localStorage.getItem('question_temp_salespd')
|
||||
this.raw_data=JSON.parse(this.raw_data)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
console.log(this.all_sections)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
|
||||
|
||||
}
|
||||
onChange(){
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event);
|
||||
if(this.all_sections[this.all_sections.length - 1] != event.section_id){
|
||||
this.navCtrl.push(Section5)
|
||||
}
|
||||
else{
|
||||
// this.sendData()
|
||||
console.log("else part")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'section5',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class Section5 {
|
||||
question_data: any;
|
||||
raw_data:any;
|
||||
section_local:number=5
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider) {
|
||||
// if(this.navParams.get('sec_no')){
|
||||
// this.section_local=this.navParams.get('sec_no')
|
||||
// }
|
||||
// this.SalesPDService.getData().subscribe(result=>{
|
||||
// this.raw_data=result['records']
|
||||
// this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
// this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local)[0]
|
||||
// console.log(this.question_data)
|
||||
// })
|
||||
this.raw_data=localStorage.getItem('question_temp_salespd')
|
||||
this.raw_data=JSON.parse(this.raw_data)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
console.log(this.all_sections)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
|
||||
|
||||
}
|
||||
onChange(){
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event);
|
||||
if(this.all_sections[this.all_sections.length - 1] != event.section_id){
|
||||
this.navCtrl.push(Section6)
|
||||
}
|
||||
else{
|
||||
// this.sendData()
|
||||
console.log("else part")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'section6',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class Section6 {
|
||||
question_data: any;
|
||||
raw_data:any;
|
||||
section_local:number=6
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider) {
|
||||
// if(this.navParams.get('sec_no')){
|
||||
// this.section_local=this.navParams.get('sec_no')
|
||||
// }
|
||||
// this.SalesPDService.getData().subscribe(result=>{
|
||||
// this.raw_data=result['records']
|
||||
// this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
// this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local)[0]
|
||||
// console.log(this.question_data)
|
||||
// })
|
||||
this.raw_data=localStorage.getItem('question_temp_salespd')
|
||||
this.raw_data=JSON.parse(this.raw_data)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
console.log(this.all_sections)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
|
||||
|
||||
}
|
||||
onChange(){
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event);
|
||||
if(this.all_sections[this.all_sections.length - 1] != event.section_id){
|
||||
this.navCtrl.push(Section7)
|
||||
}
|
||||
else{
|
||||
// this.sendData()
|
||||
console.log("else part")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Component({
|
||||
selector: 'section7',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class Section7 {
|
||||
question_data: any;
|
||||
raw_data:any;
|
||||
section_local:number=7
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private toastProvider:ToastProvider) {
|
||||
// if(this.navParams.get('sec_no')){
|
||||
// this.section_local=this.navParams.get('sec_no')
|
||||
// }
|
||||
// this.SalesPDService.getData().subscribe(result=>{
|
||||
// this.raw_data=result['records']
|
||||
// this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
// this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local)[0]
|
||||
// console.log(this.question_data)
|
||||
// })
|
||||
this.raw_data=localStorage.getItem('question_temp_salespd')
|
||||
this.raw_data=JSON.parse(this.raw_data)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
console.log(this.all_sections)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
|
||||
|
||||
}
|
||||
onChange(){
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event);
|
||||
if(this.all_sections[this.all_sections.length - 1] != event.section_id){
|
||||
this.navCtrl.push(Section8)
|
||||
}
|
||||
else{
|
||||
// this.sendData()
|
||||
console.log("else part")
|
||||
this.SalesPDService.sendData(this.all_sections).then(res=>{
|
||||
console.log(res)
|
||||
let params={pd_json:JSON.stringify(res)}
|
||||
this.SalesPDService.saveQuestions(params).subscribe(apiresult=>{
|
||||
if(apiresult['dataStatus']){
|
||||
this.SalesPDService.clearLocalData()
|
||||
this.toastProvider.lenderappmessage("Saved Successfully..!");
|
||||
setTimeout(()=>{
|
||||
this.navCtrl.setRoot(SalesPDlistPage)
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'section8',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class Section8 {
|
||||
question_data: any;
|
||||
raw_data:any;
|
||||
section_local:number=8
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private toastProvider:ToastProvider) {
|
||||
// if(this.navParams.get('sec_no')){
|
||||
// this.section_local=this.navParams.get('sec_no')
|
||||
// }
|
||||
// this.SalesPDService.getData().subscribe(result=>{
|
||||
// this.raw_data=result['records']
|
||||
// this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
// this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local)[0]
|
||||
// console.log(this.question_data)
|
||||
// })
|
||||
this.raw_data=localStorage.getItem('question_temp_salespd')
|
||||
this.raw_data=JSON.parse(this.raw_data)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
console.log(this.all_sections)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
|
||||
|
||||
}
|
||||
onChange(){
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event);
|
||||
if(this.all_sections[this.all_sections.length - 1] != event.section_id){
|
||||
this.navCtrl.push(Section9)
|
||||
}
|
||||
else{
|
||||
// this.sendData()
|
||||
console.log("else part")
|
||||
this.SalesPDService.sendData(this.all_sections).then(res=>{
|
||||
console.log(res)
|
||||
let params={pd_json:JSON.stringify(res)}
|
||||
this.SalesPDService.saveQuestions(params).subscribe(apiresult=>{
|
||||
if(apiresult['dataStatus']){
|
||||
this.SalesPDService.clearLocalData()
|
||||
this.toastProvider.lenderappmessage("Saved Successfully..!");
|
||||
setTimeout(()=>{
|
||||
this.navCtrl.setRoot(SalesPDlistPage)
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'section9',
|
||||
templateUrl: 'home.html',
|
||||
})
|
||||
export class Section9 {
|
||||
question_data: any;
|
||||
raw_data:any;
|
||||
section_local:number=9
|
||||
all_sections:any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private SalesPDService:SalesPdProvider,private toastProvider:ToastProvider) {
|
||||
// if(this.navParams.get('sec_no')){
|
||||
// this.section_local=this.navParams.get('sec_no')
|
||||
// }
|
||||
// this.SalesPDService.getData().subscribe(result=>{
|
||||
// this.raw_data=result['records']
|
||||
// this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
// this.question_data=this.raw_data.sections.filter(val => val.section_id == this.section_local)[0]
|
||||
// console.log(this.question_data)
|
||||
// })
|
||||
this.raw_data=localStorage.getItem('question_temp_salespd')
|
||||
this.raw_data=JSON.parse(this.raw_data)
|
||||
this.all_sections=this.raw_data.sections.map(val=>val.section_id)
|
||||
console.log(this.all_sections)
|
||||
this.question_data=this.raw_data.sections.filter(val => val.order_id == this.section_local)[0]
|
||||
console.log(this.question_data)
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad HomePage');
|
||||
|
||||
|
||||
}
|
||||
onChange(){
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
navigate(event){
|
||||
|
||||
console.log(event,this.all_sections[this.all_sections.length - 1]);
|
||||
if(this.all_sections[this.all_sections.length - 1] != event.section_id){
|
||||
this.navCtrl.push(Section9)
|
||||
}
|
||||
else{
|
||||
// this.sendData()
|
||||
console.log("else part")
|
||||
this.SalesPDService.sendData(this.all_sections).then(res=>{
|
||||
console.log(res)
|
||||
let params={pd_json:JSON.stringify(res)}
|
||||
this.SalesPDService.saveQuestions(params).subscribe(apiresult=>{
|
||||
if(apiresult['dataStatus']){
|
||||
this.SalesPDService.clearLocalData()
|
||||
this.toastProvider.lenderappmessage("Saved Successfully..!");
|
||||
setTimeout(()=>{
|
||||
this.navCtrl.setRoot(SalesPDlistPage)
|
||||
},2000)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
41
src/pages/sales_pd/pages/home/product-list.html
Normal file
41
src/pages/sales_pd/pages/home/product-list.html
Normal file
@ -0,0 +1,41 @@
|
||||
<ion-header>
|
||||
|
||||
<ion-navbar color="optblue">
|
||||
<button ion-button menuToggle>
|
||||
<ion-icon name="menu"></ion-icon>
|
||||
</button>
|
||||
<ion-title>Choose the Product</ion-title>
|
||||
<!-- <ion-buttons end>
|
||||
<button ion-button type="submit" color="primary">dd</button>
|
||||
</ion-buttons> -->
|
||||
</ion-navbar>
|
||||
|
||||
</ion-header>
|
||||
|
||||
|
||||
|
||||
<ion-content padding style="background:white">
|
||||
<mat-card style="
|
||||
width: 100%;
|
||||
min-height: 50%;
|
||||
margin-top: 25%;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 16px 38px -12px rgba(0,0,0,.56), 0 4px 25px 0 rgba(0,0,0,.12), 0 8px 10px -5px rgba(0,0,0,.2) !important;
|
||||
">
|
||||
<mat-card-content style="margin-top:7%">
|
||||
<!-- <mat-form-field style="width: 100%;" appearence="outline"> -->
|
||||
<mat-label><h6>Choose the Product</h6></mat-label>
|
||||
<mat-radio-group placeholder="Product" [(ngModel)]="product" class="radio-group">
|
||||
<mat-radio-button color="primary" style="background-color: lightgrey;
|
||||
padding: 10px;
|
||||
margin: 5px;
|
||||
white-space: pre-line;
|
||||
border-radius: 10px;" *ngFor="let val of productList" [value]="val.product_id" ><span>{{val.product_abbr}}</span></mat-radio-button>
|
||||
</mat-radio-group>
|
||||
<!-- </mat-form-field> -->
|
||||
<ion-buttons end>
|
||||
<button ion-button color="optblue" (click)="sendProduct()">Submit</button>
|
||||
</ion-buttons>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</ion-content>
|
||||
67
src/pages/sales_pd/pages/sales-p-dlist/sales-p-dlist.html
Normal file
67
src/pages/sales_pd/pages/sales-p-dlist/sales-p-dlist.html
Normal file
@ -0,0 +1,67 @@
|
||||
<!--
|
||||
Generated template for the SalesPDlistPage page.
|
||||
|
||||
See http://ionicframework.com/docs/components/#navigation for more info on
|
||||
Ionic pages and navigation.
|
||||
-->
|
||||
<ion-header>
|
||||
|
||||
<ion-navbar color="optblue">
|
||||
<button ion-button menuToggle>
|
||||
<ion-icon name="menu"></ion-icon>
|
||||
</button>
|
||||
<ion-title>Sales PD List</ion-title>
|
||||
</ion-navbar>
|
||||
|
||||
</ion-header>
|
||||
|
||||
|
||||
<ion-content padding>
|
||||
<ion-list >
|
||||
<ion-grid class="fadeIn">
|
||||
<mat-card class="md-box" reorder="true" >
|
||||
<ion-list style="margin-top: 5px;">
|
||||
<ion-item *ngFor="let val of sales_displayValue">
|
||||
<!-- <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-7 *ngIf="val.applicant_name != null">
|
||||
<h1>{{val.applicant_name}}</h1>
|
||||
<!--<p>28 Sep 2018 10:00 AM</p>-->
|
||||
</ion-col>
|
||||
<ion-col col-7 *ngIf="val.applicant_name == null">
|
||||
<h1>Name Not Given</h1>
|
||||
|
||||
</ion-col>
|
||||
<ion-col text-right>
|
||||
<div style="font-size: 12px;color:black">
|
||||
<p>{{val.createdon}}</p>
|
||||
<!-- <p>Chennai</p> -->
|
||||
</div>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col col-7>
|
||||
<h6 class="app_id">{{val.applicant_id}}</h6>
|
||||
</ion-col>
|
||||
<ion-col text-right>
|
||||
<div style="font-size: 13px;">
|
||||
<h6>{{val.abbr}}</h6>
|
||||
|
||||
</div>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-item>
|
||||
<div *ngIf="sales_displayValue.length == 0" style="padding: 10px; margin:5px;">
|
||||
<h6 >No Records Found</h6>
|
||||
</div>
|
||||
|
||||
</ion-list>
|
||||
|
||||
</mat-card>
|
||||
</ion-grid>
|
||||
</ion-list>
|
||||
<ion-fab right bottom (click)="newForm()">
|
||||
<button ion-fab mini color="optblue"><ion-icon color="light" name="md-add"></ion-icon></button>
|
||||
</ion-fab>
|
||||
</ion-content>
|
||||
105
src/pages/sales_pd/pages/sales-p-dlist/sales-p-dlist.scss
Normal file
105
src/pages/sales_pd/pages/sales-p-dlist/sales-p-dlist.scss
Normal file
@ -0,0 +1,105 @@
|
||||
page-sales-p-dlist {
|
||||
mat-grid-tile {
|
||||
background: white!important;
|
||||
}
|
||||
.grid{
|
||||
padding:0px;
|
||||
}
|
||||
.scroll-content{
|
||||
padding: 0px !important;
|
||||
// margin-top: 45px !important;
|
||||
}
|
||||
.fadeIn {
|
||||
animation-name: fadeIn;
|
||||
animation-duration: 15s;
|
||||
transition: all 0.5s cubic-bezier(.36,-0.64,.34,1.76);
|
||||
}
|
||||
@font-face{
|
||||
font-family: Roboto;
|
||||
src: url('../../assets/fonts/Roboto-Bold.ttf')!important;
|
||||
}
|
||||
h1{
|
||||
margin: 2px 0;
|
||||
font-size: 2.1rem !important;
|
||||
// overflow-wrap:break-word;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
// height: 10px;
|
||||
// font-weight: bold!important;
|
||||
}
|
||||
// .box{
|
||||
// box-shadow: 0 5px 20px 0 rgba(0,0,0,.2),0 13px 24px -11px rgba(50, 114, 178, 0.59) !important;
|
||||
// }
|
||||
.scroll-content{
|
||||
//background-color: #eee !important;
|
||||
padding:0px !important;
|
||||
}
|
||||
.mat-card{
|
||||
// border-top: 3px solid rgba(50, 114, 178, 0.78);
|
||||
padding: 0px !important;
|
||||
box-shadow: none !important;
|
||||
// margin-top: 10px;
|
||||
// height: 100%;
|
||||
}
|
||||
*{
|
||||
font-size: 10px;
|
||||
// margin-top: 5px;
|
||||
}
|
||||
.mat-card-title{
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.list-md{
|
||||
margin: 0px;
|
||||
}
|
||||
// .lettericon{
|
||||
// background-color: cadetblue;
|
||||
// padding: 7px 8px 7px 8px;
|
||||
// border-radius: 20%;
|
||||
// color: #fff;
|
||||
// font-size: 90%;
|
||||
// font-weight:bold;
|
||||
// text-align: center;
|
||||
// }
|
||||
.lettericon{
|
||||
// padding: 7px 8px 7px 8px;
|
||||
// border-radius: 20%;
|
||||
color: red;
|
||||
font-size: 90%;
|
||||
font-weight:bold;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.app_id{
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
// font-size: 16px;
|
||||
// font-weight: bold;
|
||||
}
|
||||
.label-md{
|
||||
margin: 0px;
|
||||
}
|
||||
.item-md h4 {
|
||||
font-size: 1.7rem;
|
||||
}
|
||||
.item-md ion-icon[item-start] + .item-inner{
|
||||
margin-left: 0px;
|
||||
}
|
||||
// ion-segment {
|
||||
// justify-content: space-between;
|
||||
// overflow: auto;
|
||||
|
||||
// &::-webkit-scrollbar {
|
||||
// width: 0;
|
||||
// height: 0;
|
||||
// display: none;
|
||||
// }
|
||||
|
||||
// ion-segment-button.segment-button {
|
||||
// flex: 1 0 100px;
|
||||
// }
|
||||
// }
|
||||
// .applicant_name{
|
||||
// overflow: hidden;
|
||||
// text-overflow: ellipsis;
|
||||
// }
|
||||
}
|
||||
40
src/pages/sales_pd/pages/sales-p-dlist/sales-p-dlist.ts
Normal file
40
src/pages/sales_pd/pages/sales-p-dlist/sales-p-dlist.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||
import { SalesPdProvider } from '../../providers/sales-pd/sales-pd';
|
||||
import { HomePage } from '../home/home';
|
||||
|
||||
/**
|
||||
* Generated class for the SalesPDlistPage page.
|
||||
*
|
||||
* See https://ionicframework.com/docs/components/#navigation for more info on
|
||||
* Ionic pages and navigation.
|
||||
*/
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'page-sales-p-dlist',
|
||||
templateUrl: 'sales-p-dlist.html',
|
||||
})
|
||||
export class SalesPDlistPage {
|
||||
sales_displayValue: any=[];
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams,private salesPDService:SalesPdProvider) {
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad SalesPDlistPage');
|
||||
this.getListofPD()
|
||||
}
|
||||
getListofPD(){
|
||||
this.salesPDService.getSalesPDList().subscribe(res=>{
|
||||
if(res['dataStatus']){
|
||||
this.sales_displayValue=res['records']
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
newForm(){
|
||||
console.log("chec")
|
||||
this.navCtrl.push(HomePage)
|
||||
}
|
||||
}
|
||||
154
src/pages/sales_pd/providers/camera/camera.ts
Normal file
154
src/pages/sales_pd/providers/camera/camera.ts
Normal file
@ -0,0 +1,154 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Camera } from '@ionic-native/camera';
|
||||
import { ConstantsProvider } from '../../../../providers/constants/constants';
|
||||
import {Geolocation} from '@ionic-native/geolocation'
|
||||
import { DatePipe } from '@angular/common';
|
||||
import * as watermark from 'watermarkjs'
|
||||
import { LocationAccuracy } from '@ionic-native/location-accuracy';
|
||||
|
||||
/*
|
||||
Generated class for the CameraProvider provider.
|
||||
|
||||
See https://angular.io/guide/dependency-injection for more info on providers
|
||||
and Angular DI.
|
||||
*/
|
||||
@Injectable()
|
||||
export class CameraProvider {
|
||||
geoCords: any;
|
||||
pipe: DatePipe;
|
||||
|
||||
constructor(public http: HttpClient,private camera:Camera,private geo:Geolocation,private locationAccuracy:LocationAccuracy) {
|
||||
console.log('Hello CameraProvider Provider');
|
||||
this.pipe=new DatePipe('en-US')
|
||||
}
|
||||
enableAccuracy()
|
||||
{
|
||||
return this.locationAccuracy.canRequest().then((canRequest: boolean) => {
|
||||
|
||||
if(canRequest) {
|
||||
// the accuracy option will be ignored by iOS
|
||||
this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then(
|
||||
() => {
|
||||
return this.getGeoTag()
|
||||
// this.getcurrentBackgroundLocation();
|
||||
},
|
||||
error =>{ console.log('Error requesting location permissions'+JSON.stringify(error))
|
||||
alert("We need location access to capture the geocoordinates of your place. Please turn on the location to continue");
|
||||
this.enableAccuracy()
|
||||
return false
|
||||
}
|
||||
);
|
||||
return true
|
||||
}
|
||||
},err=>{
|
||||
console.log("Error",err)
|
||||
return false
|
||||
});
|
||||
}
|
||||
getpicture()
|
||||
{
|
||||
|
||||
|
||||
localStorage.removeItem('current_coordinates')
|
||||
|
||||
const options = {
|
||||
quality: 75,
|
||||
destinationType: this.camera.DestinationType.DATA_URL,
|
||||
targetWidth: 500,
|
||||
targetHeight: 600,
|
||||
correctOrientation: true,
|
||||
encodingType: this.camera.EncodingType.PNG,
|
||||
saveToPhotoAlbum:false,
|
||||
};
|
||||
console.log(localStorage.getItem('current_coordinates'))
|
||||
|
||||
// If set to crop, restricts the image to a square of 600 by 600
|
||||
|
||||
// return this.saveRecovery().then(()=>{
|
||||
|
||||
return this.camera.getPicture(options).then(imageData => {
|
||||
return this.getGeoTag().then(geoCoordinates => {
|
||||
this.geoCords = geoCoordinates
|
||||
localStorage.setItem('current_coordinates',this.geoCords)
|
||||
|
||||
console.log('From Camera.ts - getPicture fn image are',imageData)
|
||||
const base64Image = 'data:image/png;base64,' + imageData;
|
||||
// this.myObject=base64Image
|
||||
// console.log("base 64",base64Image);
|
||||
return base64Image;
|
||||
});
|
||||
}, error => {
|
||||
localStorage.removeItem('current_coordinates')
|
||||
console.log('CAMERA ERROR -> ' + JSON.stringify(error));
|
||||
return "error"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
addWatermarks(base64Img) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// this.constant.getGeoTag().then(geoCoordinates => {
|
||||
// this.geoCords = geoCoordinates
|
||||
// });
|
||||
this.geoCords=localStorage.getItem('current_coordinates')
|
||||
console.log("corrds",this.geoCords)
|
||||
let raw_img = base64Img
|
||||
var today = new Date();
|
||||
// let today_loc = today.toLocaleString('en-US', { timeZone: "Asia/Kolkata" })
|
||||
let today_loc=this.pipe.transform(today, 'yyyy-MM-dd, h:mm a')
|
||||
var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
|
||||
// var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
|
||||
var dateTime = 'Date : ' + today_loc;
|
||||
|
||||
console.log(date)
|
||||
|
||||
// fetch(raw_img)
|
||||
// .then(res => res.blob())
|
||||
// .then(blob => {
|
||||
watermark([raw_img, 'assets/img/PD_watermark.png'])
|
||||
.image(watermark.image.upperRight())
|
||||
.then(img => {
|
||||
raw_img = img.src;
|
||||
|
||||
let text = watermark.text
|
||||
watermark([raw_img])
|
||||
.image(text.upperLeft(dateTime, '18px sans-serif', '#ff0000', 1.0, 40))
|
||||
.then(img => {
|
||||
raw_img = img.src;
|
||||
console.log("2d", raw_img)
|
||||
|
||||
let Location = `Location : ` + this.geoCords
|
||||
watermark([raw_img])
|
||||
.image(text.upperLeft(Location, '18px sans-serif', '#ff0000', 1.0))
|
||||
.then(img => {
|
||||
raw_img = img.src
|
||||
console.log("3rd", raw_img)
|
||||
resolve(img.src)
|
||||
localStorage.removeItem('current_coordinates')
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
// });
|
||||
}
|
||||
getGeoTag(){
|
||||
// this.enableAccuracy()
|
||||
return this.geo.getCurrentPosition().then(res=>{
|
||||
console.log("res from getGeoTag",res.coords)
|
||||
console.log("res from provider",new Date(res.timestamp))
|
||||
let lat=res.coords.latitude;
|
||||
let long=res.coords.longitude;
|
||||
let curr_pos=lat+","+long
|
||||
return curr_pos
|
||||
}).catch(err=>console.log("error in getGeoTag",err))
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { FormGroup, FormControl, FormArray, FormBuilder } from '@angular/forms';
|
||||
import { FormGroup, FormControl, FormArray, FormBuilder, Validators } from '@angular/forms';
|
||||
import { SalesPdProvider } from '../sales-pd/sales-pd';
|
||||
import { DatePipe } from '@angular/common';
|
||||
|
||||
/*
|
||||
Generated class for the QuesServiceProvider provider.
|
||||
@ -11,18 +12,20 @@ import { SalesPdProvider } from '../sales-pd/sales-pd';
|
||||
*/
|
||||
@Injectable()
|
||||
export class QuesServiceProvider {
|
||||
datepipe: DatePipe;
|
||||
|
||||
constructor(public http: HttpClient,private _fb:FormBuilder,private salesPDProvider:SalesPdProvider) {
|
||||
console.log('Hello QuesServiceProvider Provider');
|
||||
this.datepipe=new DatePipe('en-US')
|
||||
}
|
||||
assignFormControl_array(formgroup:FormGroup,ques_data:any){
|
||||
console.log(formgroup,ques_data)
|
||||
const control:any=formgroup.get('questions') as FormArray
|
||||
ques_data.forEach((val,index)=>{
|
||||
|
||||
console.log("quees",val)
|
||||
if(val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1'){
|
||||
control.push(this._fb.group({ "is_repeatable":[val.is_repeatable || null],
|
||||
"group_title":[val.group_title || null]}))
|
||||
"group_title":[val.group_title || null],"group_type":[val.group_type || null]}))
|
||||
// let temp=val
|
||||
|
||||
// control.push(this.createValue(temp))
|
||||
@ -32,31 +35,52 @@ export class QuesServiceProvider {
|
||||
let childControl:any=control.controls[index].get('questions_group') as FormArray
|
||||
|
||||
childControl.push(this._fb.group({'questions':this._fb.array([])}))
|
||||
|
||||
let sub_childControl:any=childControl.controls[index].get('questions') as FormArray
|
||||
console.log("cc",childControl,control,index)
|
||||
let sub_childControl:any=childControl.controls[0].get('questions') as FormArray
|
||||
val.question.forEach((group_indi,arr_index)=>{
|
||||
if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){
|
||||
// if(group_indi.api_properties != null && typeof(group_indi.api_properties) == 'object'){
|
||||
console.log("api pro",val.api_properties)
|
||||
// let param
|
||||
// val.api_properties.forEach(val=>param=val)
|
||||
// console.log(param)
|
||||
this.apiPropertiesCall(group_indi).then(res=>{
|
||||
if(res){
|
||||
group_indi.answers=[]
|
||||
group_indi.answers=this.convertArrayNames(val.api_properties.fields,res)
|
||||
sub_childControl.push(this.createValue(group_indi))
|
||||
if(group_indi.type == '5'){
|
||||
sub_childControl.controls[arr_index].removeControl('answer_value');
|
||||
console.log("loop",arr_index,sub_childControl);
|
||||
sub_childControl.controls[arr_index].addControl('answer_value',this._fb.array([]))
|
||||
}
|
||||
if(group_indi.type == '1'){
|
||||
sub_childControl.controls[arr_index].addControl('field_type',new FormControl(group_indi.field_type))
|
||||
}
|
||||
if(val.type == '8'){
|
||||
control.controls[index].addControl('select_search',new FormControl(val.field_type))
|
||||
}
|
||||
|
||||
if(group_indi.api_properties != null){
|
||||
this.apiPropertiesCall(group_indi).then(res=>{
|
||||
if(res != false){
|
||||
group_indi.answers=[]
|
||||
// group_indi.answers=this.convertArrayNames(val.api_properties.fields,res)
|
||||
sub_childControl.controls[arr_index]['controls'].answers.setValue(this.convertArrayNames(group_indi.api_properties.fields,res))
|
||||
|
||||
}
|
||||
sub_childControl.push(this.createValue(group_indi))
|
||||
})
|
||||
}
|
||||
else{
|
||||
sub_childControl.push(this.createValue(group_indi))
|
||||
}
|
||||
if(group_indi.type == '5'){
|
||||
sub_childControl.controls[arr_index].removeControl('answer_value');
|
||||
console.log("loop",arr_index,sub_childControl);
|
||||
sub_childControl.controls[arr_index].addControl('answer_value',this._fb.array([]))
|
||||
}
|
||||
})
|
||||
// else{
|
||||
// setTimeout(()=>{
|
||||
// sub_childControl.push(this.createValue(group_indi))
|
||||
// },200)
|
||||
// }
|
||||
// sub_childControl.push(this.createValue(group_indi))
|
||||
})
|
||||
// }
|
||||
// else{
|
||||
// sub_childControl.push(this.createValue(group_indi))
|
||||
// }
|
||||
// setTimeout(()=>{
|
||||
|
||||
// },500)
|
||||
|
||||
console.log("dd112",formgroup,childControl)
|
||||
// let key_list=Object.keys(val)
|
||||
// console.log(Object.keys(val))
|
||||
@ -71,40 +95,60 @@ export class QuesServiceProvider {
|
||||
let curr_object
|
||||
console.log("apikd",typeof(val.api_properties))
|
||||
// if(val.api_properties != null && typeof(val.api_properties) == 'object'){
|
||||
control.push(this.createValue(val))
|
||||
// for checkbox remove the form control and add the formarray for multiple values
|
||||
if(val.type == '5'){
|
||||
control.controls[index].removeControl('answer_value');
|
||||
console.log("loop",index,control);
|
||||
control.controls[index].addControl('answer_value',this._fb.array([]))
|
||||
}
|
||||
if(val.type == '1'){
|
||||
control.controls[index].addControl('field_type',new FormControl(val.field_type))
|
||||
}
|
||||
if(val.type == '8'){
|
||||
control.controls[index].addControl('select_search',new FormControl(val.field_type))
|
||||
}
|
||||
if(val.api_properties!= null){
|
||||
this.apiPropertiesCall(val).then(res=>{
|
||||
console.log("chekc",res)
|
||||
if(res != false){
|
||||
val.answers=[]
|
||||
val.answers=this.convertArrayNames(val.api_properties.fields,res)
|
||||
control.push(this.createValue(val))
|
||||
}
|
||||
else{
|
||||
setTimeout(()=>{
|
||||
control.push(this.createValue(val))
|
||||
},200)
|
||||
// val.answers=[]
|
||||
// val.answers=this.convertArrayNames(val.api_properties.fields,res)
|
||||
control.controls[index]['controls'].answers.setValue(this.convertArrayNames(val.api_properties.fields,res))
|
||||
|
||||
}
|
||||
},err=>console.log(err))
|
||||
}
|
||||
// else{
|
||||
// setTimeout(()=>{
|
||||
// control.push(this.createValue(val))
|
||||
// },200)
|
||||
// }
|
||||
|
||||
// }
|
||||
// else{
|
||||
// control.push(this.createValue(val))
|
||||
// }
|
||||
// if(val.type == '5'){
|
||||
// control.controls[index].removeControl('answer_value');
|
||||
// console.log("loop",index,control);
|
||||
// control.controls[index].addControl('answer_value',this._fb.array([]))
|
||||
// }
|
||||
},err=>console.log(err))
|
||||
|
||||
// for checkbox remove the form control and add the formarray for multiple values
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
console.log(formgroup)
|
||||
|
||||
}
|
||||
},err=>console.log(err))
|
||||
return formgroup
|
||||
}
|
||||
createValue(data){
|
||||
let answer_value_loc='';
|
||||
if(data.type == '1' && data.hasOwnProperty('answer_value') && data.answer_value != '' || null){
|
||||
answer_value_loc = this.getAnswerValue(data)
|
||||
}
|
||||
return this._fb.group({
|
||||
"answer_value":[''],
|
||||
"answer_value":[{value:answer_value_loc,disabled:answer_value_loc != '' ? true : false},data.type != '6' ? Validators.compose([Validators.required]) : ''],
|
||||
"question":[data.question],
|
||||
"question_key":[data.question_key],
|
||||
"type":[data.type],
|
||||
@ -118,7 +162,7 @@ export class QuesServiceProvider {
|
||||
apiPropertiesCall(val){
|
||||
return new Promise((resolve,reject)=>{
|
||||
if(val.api_properties != null && typeof(val.api_properties) == 'object'){
|
||||
this.salesPDProvider.api_post_method(val.api_properties.api,{master_name:'STATE'}).subscribe(res=>{
|
||||
this.salesPDProvider.api_post_method(val.api_properties.api,val.api_properties.params,val.api_properties.api_method).subscribe(res=>{
|
||||
if(res['dataStatus']){
|
||||
if(res.hasOwnProperty('records')){
|
||||
res=res['records']
|
||||
@ -150,6 +194,31 @@ export class QuesServiceProvider {
|
||||
return modified_json
|
||||
}
|
||||
|
||||
|
||||
getAnswerValue(value_obj){
|
||||
if(value_obj != null && value_obj.hasOwnProperty('answer_value')){
|
||||
let return_value;
|
||||
let user_det:any=localStorage.getItem("user_details")
|
||||
user_det=JSON.parse(user_det);
|
||||
switch(value_obj.answer_value){
|
||||
case 'CURRENT_USER':
|
||||
console.log("current user",user_det)
|
||||
return_value=user_det.user_first_name+' '+user_det.user_last_name
|
||||
break;
|
||||
case "CURRENT_DESIGNATION":
|
||||
console.log("current user",user_det)
|
||||
return_value=user_det.role_name
|
||||
break;
|
||||
case "CURRENT_DATE":
|
||||
let date=new Date()
|
||||
return_value=this.datepipe.transform(date,'dd-MM-yyyy, h:mm:ss a')
|
||||
break;
|
||||
default:
|
||||
return_value=''
|
||||
break
|
||||
}
|
||||
return return_value
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ConstantsProvider } from '../../../../providers/constants/constants';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { AwsServiceProvider } from '../../../../providers/aws-service/aws-service';
|
||||
// import {environment} from '../../../../providers/constants/constants'
|
||||
|
||||
/*
|
||||
@ -16,425 +17,37 @@ import { Storage } from '@ionic/storage';
|
||||
|
||||
export class SalesPdProvider {
|
||||
apiUrl:string;
|
||||
constructor(public http: HttpClient,private constantProvider:ConstantsProvider,private storage:Storage) {
|
||||
available_sections:any;
|
||||
original_rawData:any;
|
||||
current_section:any;
|
||||
constructor(public http: HttpClient,private constantProvider:ConstantsProvider,private storage:Storage,private aws:AwsServiceProvider) {
|
||||
console.log('Hello SalesPdProvider Provider');
|
||||
this.apiUrl=this.constantProvider.environment().url
|
||||
}
|
||||
getData(){
|
||||
let data=`
|
||||
{
|
||||
"form_name":"Personal Discussion Sheet - Business Loans (For Sales Team)",
|
||||
"sections":
|
||||
[
|
||||
{
|
||||
"section_id":"1",
|
||||
"section_name":"Details of Key Stakeholders in the Business",
|
||||
|
||||
"questions":
|
||||
[
|
||||
|
||||
{
|
||||
"question":
|
||||
[
|
||||
{
|
||||
"question":"Name",
|
||||
"question_key":"name",
|
||||
"type":"1",
|
||||
"api_properties":null,
|
||||
"answers":null,
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Share Holding",
|
||||
"question_key":"share_holding",
|
||||
"type":"2",
|
||||
"api_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
],
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Vintage in Current Biz",
|
||||
"question_key":"vintage_in_current_biz",
|
||||
"type":"3",
|
||||
"api_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
],
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Total Work Exp",
|
||||
"question_key":"total_work_exp",
|
||||
"type":"4",
|
||||
"api_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
],
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Previous Experience Details",
|
||||
"question_key":"previous_experience_details",
|
||||
"type":"5",
|
||||
"api_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
],
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Started Biz (Yes / No)",
|
||||
"question_key":"started_biz",
|
||||
"type":"1",
|
||||
"api_properties":null,
|
||||
"onchange_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
]
|
||||
}
|
||||
],
|
||||
"is_repeatable":"1",
|
||||
"group_title":"Details of Key Stakeholders in the Business"
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Brief of the Business / Service",
|
||||
"question_key":"brief_business_service",
|
||||
"type":"1",
|
||||
"api_properties":null,
|
||||
"onchange_properties":null,
|
||||
"answers":null
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Share Holding",
|
||||
"question_key":"share_holding",
|
||||
"type":"2",
|
||||
"api_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
],
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Vintage in Current Biz",
|
||||
"question_key":"vintage_in_current_biz",
|
||||
"type":"3",
|
||||
"api_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
],
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Total Work Exp",
|
||||
"question_key":"total_work_exp",
|
||||
"type":"5",
|
||||
"api_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
],
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Previous Experience Details",
|
||||
"question_key":"previous_experience_details",
|
||||
"type":"3",
|
||||
"api_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Yes","subfield_key":"name_of_the_field","subfield_caption":"What is your name","subfield_type":""},
|
||||
{"answer":"No","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
],
|
||||
"onchange_properties":[
|
||||
{
|
||||
"purpose":"subfiled",
|
||||
"api":null,
|
||||
"params":null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"question":"Actual Property Usage",
|
||||
"question_key":"actual_property_usage",
|
||||
"type":"3",
|
||||
"api_properties":
|
||||
{
|
||||
|
||||
"api":"getListOfMaster",
|
||||
"api_method":"POST",
|
||||
"params":["STATE"],
|
||||
"fields":["state_id","name"]
|
||||
}
|
||||
,
|
||||
"onchange_properties":[
|
||||
{
|
||||
"purpose":"api",
|
||||
"api":"getListOfStatesAndCities",
|
||||
"api_method":"POST",
|
||||
"params":"{records:{state_id:'value_of_answer'}}",
|
||||
"fields":["state_id","name"],
|
||||
"local_variable":"local_city"
|
||||
}
|
||||
],
|
||||
"answers":[
|
||||
{"answer":"Residential ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Commercial ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Industrial","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"question":"City",
|
||||
"question_key":"city",
|
||||
"type":"3",
|
||||
"api_properties":"local_city",
|
||||
"onchange_properties":[
|
||||
{
|
||||
"purpose":"subfiled",
|
||||
"api":null,
|
||||
"params":null
|
||||
}
|
||||
],
|
||||
"answers":[
|
||||
{"answer":"Residential ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Commercial ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Industrial","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Pincode",
|
||||
"question_key":"pin",
|
||||
"type":"3",
|
||||
"api_properties":"local_pincode",
|
||||
"onchange_properties":[
|
||||
{
|
||||
"purpose":"subfiled",
|
||||
"api":null,
|
||||
"params":null
|
||||
}
|
||||
],
|
||||
"answers":[
|
||||
{"answer":"Residential ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Commercial ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Industrial","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"section_id":"2",
|
||||
"section_name":"Property Information",
|
||||
|
||||
"questions":
|
||||
[
|
||||
{
|
||||
"question":"Property Address (With Landmark & PIN)",
|
||||
"question_key":"property_address",
|
||||
"type":"1",
|
||||
"api_properties":null,
|
||||
"answers":null,
|
||||
"onchange_properties":null
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Property Type",
|
||||
"question_key":"property_type",
|
||||
"type":"3",
|
||||
"api_properties":null,
|
||||
"onchange_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Bungalow","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Apartment","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Row House","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Builder Floor","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Others (Specify)","subfield_key":"other_property_type","subfield_caption":"Specifiy Other property type","subfield_type":"1"}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Occupancy Status",
|
||||
"question_key":"occupancy_status",
|
||||
"type":"3",
|
||||
"api_properties":null,
|
||||
"onchange_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Self-Occupied","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Rented ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Vacant","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Permitted Property Usage",
|
||||
"question_key":"permitted_property_usage",
|
||||
"type":"3",
|
||||
"api_properties":null,
|
||||
"onchange_properties":null,
|
||||
"answers":[
|
||||
{"answer":"Residential ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Commercial ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Industrial","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Actual Property Usage",
|
||||
"question_key":"actual_property_usage",
|
||||
"type":"3",
|
||||
"api_properties":null,
|
||||
"onchange_properties":[
|
||||
{
|
||||
"purpose":"subfiled",
|
||||
"api":null,
|
||||
"params":null
|
||||
}
|
||||
],
|
||||
"answers":[
|
||||
{"answer":"Residential ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Commercial ","subfield_key":"","subfield_caption":"","subfield_type":""},
|
||||
{"answer":"Industrial","subfield_key":"","subfield_caption":"","subfield_type":""}
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Built-Up Area (Sq. Ft.)",
|
||||
"question_key":"built_up_area",
|
||||
"type":"1",
|
||||
"api_properties":null,
|
||||
"onchange_properties":null,
|
||||
"answers":null
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Approx Mkt. Val (Rs)",
|
||||
"question_key":"approx_mkt_val",
|
||||
"type":"1",
|
||||
"api_properties":null,
|
||||
"onchange_properties":null,
|
||||
"answers":null
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Property Ownership Status (Enter the names of the Property Owner(s) and their relationships)",
|
||||
"question_key":"Property_Ownership_Status",
|
||||
"type":"1",
|
||||
"api_properties":null,
|
||||
"onchange_properties":null,
|
||||
"answers":null
|
||||
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"section_id":"3",
|
||||
"section_name":"Financial Information",
|
||||
|
||||
"questions":
|
||||
[
|
||||
{
|
||||
"question":"Name of the Company / Firm whose financials are noted >>",
|
||||
"question_key":"name_of_the_company",
|
||||
"type":"1",
|
||||
"answers":null,
|
||||
"api_properties":null,
|
||||
"onchange_properties":null
|
||||
|
||||
},
|
||||
{
|
||||
"question":
|
||||
[
|
||||
{
|
||||
"question":"Enter FY",
|
||||
"question_key":"fy",
|
||||
"type":"1",
|
||||
"answers":null,
|
||||
"api_properties":null,
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Sales / Revenue (Rs) ",
|
||||
"question_key":"sales_revenue",
|
||||
"type":"1",
|
||||
"answers":null,
|
||||
"api_properties":null,
|
||||
"onchange_properties":null
|
||||
},
|
||||
{
|
||||
"question":"Net Profit / (Net Loss) (Rs) ",
|
||||
"question_key":"net_profit",
|
||||
"type":"1",
|
||||
"answers":null,
|
||||
"api_properties":null,
|
||||
"onchange_properties":null
|
||||
}
|
||||
],
|
||||
"is_repeatable":"1",
|
||||
"group_title":"Particulars of Financials as per books of Accounts (Can be captured prior to PD)"
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Income to be Considered (Rs Per Annum) >>",
|
||||
"question_key":"income_to_be_considered",
|
||||
"type":"1",
|
||||
"answers":null,
|
||||
"api_properties":null,
|
||||
"onchange_properties":null
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Income Considered (Rs Per Mth) >>",
|
||||
"question_key":"income_considered",
|
||||
"type":"1",
|
||||
"answers":null,
|
||||
"api_properties":null,
|
||||
"onchange_properties":null
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Income assessment Program Recommended >>",
|
||||
"question_key":"income_assessment_program_recommended",
|
||||
"type":"1",
|
||||
"answers":null,
|
||||
"api_properties":null,
|
||||
"onchange_properties":null
|
||||
|
||||
},
|
||||
{
|
||||
"question":"Fixed Obligations (Rs per month) >>",
|
||||
"question_key":"fixed_obligations>>",
|
||||
"type":"1",
|
||||
"answers":null,
|
||||
"api_properties":null,
|
||||
"onchange_properties":null
|
||||
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
]
|
||||
}`
|
||||
return JSON.parse(data)
|
||||
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}})
|
||||
|
||||
}
|
||||
api_post_method(api_method:string,params){
|
||||
return this.http.post(this.apiUrl+api_method,params)
|
||||
saveQuestions(params){
|
||||
params.createdby=this.aws.getlocale();
|
||||
let product_id=localStorage.getItem('product_id_salesPD')
|
||||
let users:any=localStorage.getItem('user_details')
|
||||
users=JSON.parse(users)
|
||||
params.sales_pd_id='',
|
||||
params.lender_id=users.fk_entity_id,
|
||||
params.product_id=product_id
|
||||
return this.http.post(this.apiUrl+'saveSalesPD',{records:params})
|
||||
}
|
||||
|
||||
api_post_method(api_name:string,params,api_method?){
|
||||
if(api_method.toUpperCase() == 'POST'){
|
||||
return this.http.post(this.apiUrl+api_name,params)
|
||||
}
|
||||
else{
|
||||
return this.http.get(this.apiUrl+api_name)
|
||||
}
|
||||
}
|
||||
getCityPincode(value){
|
||||
let params={records:{state_id:value}}
|
||||
@ -463,8 +76,39 @@ apiUrl:string;
|
||||
// console.log("all key in storage",this.storage.keys())
|
||||
return this.storage.get(key);
|
||||
}
|
||||
clearLocalData(){
|
||||
this.storage.clear().then(res=>{
|
||||
|
||||
})
|
||||
}
|
||||
// handleError(api_method,err:any){
|
||||
// console.log()
|
||||
// }
|
||||
sendData(sections){
|
||||
return new Promise((resolve,reject)=>{
|
||||
let values_arr:any=[];
|
||||
console.log("as",sections)
|
||||
for(let i of sections){
|
||||
console.log("single sec",i);
|
||||
this.storage.get('sec'+i).then(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))
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
getSalesPDList(){
|
||||
// let params = new HttpParams().set("paramName",paramValue)
|
||||
let det:any=localStorage.getItem('user_details')
|
||||
det=JSON.parse(det)
|
||||
return this.http.get(this.apiUrl+'listSalesPD/'+det.fk_entity_id+'/'+det.userid)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -78,6 +78,9 @@ export class ConstantsProvider {
|
||||
else if(option=='pin'){
|
||||
returnDataVal=exist_data.filter(res=>res.pincode.toLowerCase().indexOf(searchVal) > -1)
|
||||
}
|
||||
else{
|
||||
returnDataVal=exist_data.filter(res=>res.answer.toLowerCase().indexOf(searchVal) > -1)
|
||||
}
|
||||
|
||||
return returnDataVal
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -1,50 +0,0 @@
|
||||
|
||||
// Ionicons Icon Font CSS
|
||||
// --------------------------
|
||||
// Ionicons CSS for Ionic's <ion-icon> element
|
||||
// ionicons-icons.scss has the icons and their unicode characters
|
||||
|
||||
$ionicons-font-path: $font-path !default;
|
||||
|
||||
@import "ionicons-icons";
|
||||
@import "ionicons-variables";
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: "Ionicons";
|
||||
src: url("#{$ionicons-font-path}/ionicons.woff2?v=#{$ionicons-version}") format("woff2"),
|
||||
url("#{$ionicons-font-path}/ionicons.woff?v=#{$ionicons-version}") format("woff"),
|
||||
url("#{$ionicons-font-path}/ionicons.ttf?v=#{$ionicons-version}") format("truetype");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
ion-icon {
|
||||
display: inline-block;
|
||||
|
||||
font-family: "Ionicons";
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-style: normal;
|
||||
font-variant: normal;
|
||||
font-weight: normal;
|
||||
line-height: 1;
|
||||
text-rendering: auto;
|
||||
text-transform: none;
|
||||
speak: none;
|
||||
|
||||
@include rtl() {
|
||||
&[aria-label^="arrow"]::before,
|
||||
&[flip-rtl]::before {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
||||
&[unflip-rtl]::before {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
}
|
||||
|
||||
&::before {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 391 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,34 +0,0 @@
|
||||
// Noto Sans Font
|
||||
// Google
|
||||
// Apache License, version 2.0
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
$noto-sans-font-path: $font-path !default;
|
||||
|
||||
@font-face {
|
||||
font-family: "Noto Sans";
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
src: local("Noto Sans"), local("Noto-Sans-Regular"), url("#{$noto-sans-font-path}/noto-sans-regular.woff") format("woff"), url("#{$noto-sans-font-path}/noto-sans-regular.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Noto Sans";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local("Noto Sans"), local("Noto-Sans-Regular"), url("#{$noto-sans-font-path}/noto-sans-regular.woff") format("woff"), url("#{$noto-sans-font-path}/noto-sans-regular.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Noto Sans";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
src: local("Noto Sans Bold"), local("Noto-Sans-Bold"), url("#{$noto-sans-font-path}/noto-sans-bold.woff") format("woff"), url("#{$noto-sans-font-path}/noto-sans-bold.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Noto Sans";
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local("Noto Sans Bold"), local("Noto-Sans-Bold"), url("#{$noto-sans-font-path}/noto-sans-bold.woff") format("woff"), url("#{$noto-sans-font-path}/noto-sans-bold.ttf") format("truetype");
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,34 +0,0 @@
|
||||
// Roboto Font
|
||||
// Google
|
||||
// Apache License, version 2.0
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
$roboto-font-path: $font-path !default;
|
||||
|
||||
@font-face {
|
||||
font-family: "Roboto";
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
src: local("Roboto Light"), local("Roboto-Light"), url("#{$roboto-font-path}/roboto-light.woff2") format("woff2"), url("#{$roboto-font-path}/roboto-light.woff") format("woff"), url("#{$roboto-font-path}/roboto-light.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Roboto";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local("Roboto"), local("Roboto-Regular"), url("#{$roboto-font-path}/roboto-regular.woff2") format("woff2"), url("#{$roboto-font-path}/roboto-regular.woff") format("woff"), url("#{$roboto-font-path}/roboto-regular.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Roboto";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
src: local("Roboto Medium"), local("Roboto-Medium"), url("#{$roboto-font-path}/roboto-medium.woff2") format("woff2"), url("#{$roboto-font-path}/roboto-medium.woff") format("woff"), url("#{$roboto-font-path}/roboto-medium.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Roboto";
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local("Roboto Bold"), local("Roboto-Bold"), url("#{$roboto-font-path}/roboto-bold.woff2") format("woff2"), url("#{$roboto-font-path}/roboto-bold.woff") format("woff"), url("#{$roboto-font-path}/roboto-bold.ttf") format("truetype");
|
||||
}
|
||||
BIN
www/assets/img/PD_watermark.png
Normal file
BIN
www/assets/img/PD_watermark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
1
www/build/0.js
Normal file
1
www/build/0.js
Normal file
File diff suppressed because one or more lines are too long
28655
www/build/main.css
28655
www/build/main.css
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
null
|
||||
3609
www/build/main.js
3609
www/build/main.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
201359
www/build/vendor.js
201359
www/build/vendor.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user