Commit ebca4461 by Alen Jose

Merge branch 'alen' into 'master'

doc upld See merge request alen/CMC-driver!13
parents aab71349 9522a2c4
......@@ -88,4 +88,8 @@
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-x-toast" spec="^2.6.2" />
<plugin name="com-sarriaroman-photoviewer" spec="^1.1.18" />
<plugin name="cordova-plugin-file-opener2" spec="^2.0.19" />
<plugin name="cordova-plugin-file-transfer" spec="^1.7.1" />
<plugin name="cordova-plugin-file" spec="^6.0.1" />
</widget>
......@@ -310,6 +310,26 @@
"resolved": "https://registry.npmjs.org/@ionic-native/device/-/device-4.9.0.tgz",
"integrity": "sha512-AnwB6dsgpepfYXe5Ow40Y2E/cGLIF8nq2BAhSULdw1/ANtAAszVQyFGGxbV3bPy4ahi/d2mRRfzerqtYiSw/Vg=="
},
"@ionic-native/document-viewer": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@ionic-native/document-viewer/-/document-viewer-4.9.1.tgz",
"integrity": "sha512-eK7zgGDym8yvgPfnrZ+RJ6/T99ZKT3w1PQzKaR97NbXw5aaGIqdNWG4TZMOLKFIaqrzFrh3+k19AH7y/rJdlyw=="
},
"@ionic-native/file": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@ionic-native/file/-/file-4.9.1.tgz",
"integrity": "sha512-ZqRpCXBtbY/DF8xlkg90x42wqoVSqFkZn0nm5E0dhMlpndZpcW/pQ6zgrwrVs9VYHSBma3qQYShdBWI1XeAQ6g=="
},
"@ionic-native/file-opener": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@ionic-native/file-opener/-/file-opener-4.9.1.tgz",
"integrity": "sha512-v6OI9J55Fk6l2tpu9EXGKmZDFN1nB6jx3R39/JHHM0tegGkONIEhAs7C6kGJYZcH6kioHxpyOeAB+pt2PmehWw=="
},
"@ionic-native/file-transfer": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@ionic-native/file-transfer/-/file-transfer-4.9.1.tgz",
"integrity": "sha512-qrCv83I0AaCvHnLNVON2utwjQ595GvBjFFsLSxxXGJvFU4gVg6b1i4cSzcJ+seK2Re+kW8E0azST8hReqs9LeQ=="
},
"@ionic-native/geolocation": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/@ionic-native/geolocation/-/geolocation-4.9.0.tgz",
......@@ -335,6 +355,11 @@
"resolved": "https://registry.npmjs.org/@ionic-native/onesignal/-/onesignal-4.9.0.tgz",
"integrity": "sha512-zSq4lp0fdIsoGYU7CRsyJLs9migmowYK8Kbg2hVE1pYbLgAJk86B53928k7sO6gJrDLNlBFqYhc2wC8T+N9hRw=="
},
"@ionic-native/photo-viewer": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@ionic-native/photo-viewer/-/photo-viewer-4.9.1.tgz",
"integrity": "sha512-okCJCGf9N7oeFN6EFBlQ7Y/zz3HVV+bYl7hm6hWAbcFv02UJN7aeBLej7LRHZ1t3+q7bGjlCZLjhcQm+BUrEcw=="
},
"@ionic-native/splash-screen": {
"version": "4.8.0",
"resolved": "https://registry.npmjs.org/@ionic-native/splash-screen/-/splash-screen-4.8.0.tgz",
......@@ -1286,6 +1311,11 @@
"resolved": "https://registry.npmjs.org/colour/-/colour-0.7.1.tgz",
"integrity": "sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g="
},
"com-sarriaroman-photoviewer": {
"version": "1.1.18",
"resolved": "https://registry.npmjs.org/com-sarriaroman-photoviewer/-/com-sarriaroman-photoviewer-1.1.18.tgz",
"integrity": "sha512-ExogN6XpvsX+uthA7ll3jpNNts/rb3qksT9yRrYFkFTvg9w7PzoLkRw0RGU+B+q19qBlN7Fs7crUT9lNtGrueA=="
},
"combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
......@@ -1602,6 +1632,21 @@
"resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.2.tgz",
"integrity": "sha1-/Ajzci5n7ve2xnv8mag99q3Quro="
},
"cordova-plugin-file": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.1.tgz",
"integrity": "sha1-SWBrjBWlaI1HKPkuSnMloGHeB/U="
},
"cordova-plugin-file-opener2": {
"version": "2.0.19",
"resolved": "https://registry.npmjs.org/cordova-plugin-file-opener2/-/cordova-plugin-file-opener2-2.0.19.tgz",
"integrity": "sha1-yjrhIlOVt3qx/lsgrMv+zGiOJJM="
},
"cordova-plugin-file-transfer": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/cordova-plugin-file-transfer/-/cordova-plugin-file-transfer-1.7.1.tgz",
"integrity": "sha1-p12L4uvDu5sjxbG70ZkhTsJnWGs="
},
"cordova-plugin-ionic-keyboard": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/cordova-plugin-ionic-keyboard/-/cordova-plugin-ionic-keyboard-2.0.5.tgz",
......
......@@ -23,21 +23,30 @@
"@angular/platform-browser-dynamic": "5.2.11",
"@ionic-native/core": "4.8.0",
"@ionic-native/device": "^4.9.0",
"@ionic-native/document-viewer": "^4.9.1",
"@ionic-native/file": "^4.9.1",
"@ionic-native/file-opener": "^4.9.1",
"@ionic-native/file-transfer": "^4.9.1",
"@ionic-native/geolocation": "^4.9.0",
"@ionic-native/local-notifications": "^4.9.0",
"@ionic-native/location-accuracy": "^4.9.0",
"@ionic-native/network": "^4.9.0",
"@ionic-native/onesignal": "^4.9.0",
"@ionic-native/photo-viewer": "^4.9.1",
"@ionic-native/splash-screen": "4.8.0",
"@ionic-native/status-bar": "4.8.0",
"@ionic-native/toast": "^4.9.0",
"@ionic/storage": "2.1.3",
"angularfire2": "^5.0.0-rc.11",
"com-sarriaroman-photoviewer": "^1.1.18",
"cordova-android": "^6.3.0",
"cordova-android-support-gradle-release": "^1.4.4",
"cordova-plugin-app-event": "^1.2.1",
"cordova-plugin-badge": "^0.8.7",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-file-opener2": "^2.0.19",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.1.19",
"cordova-plugin-local-notification": "^0.9.0-beta.2",
......@@ -69,7 +78,11 @@
"cordova-plugin-local-notification": {},
"cordova-android-support-gradle-release": {
"ANDROID_SUPPORT_VERSION": "27.1.0"
}
},
"com-sarriaroman-photoviewer": {},
"cordova-plugin-file-opener2": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-file": {}
},
"platforms": [
"android"
......
......@@ -23,6 +23,10 @@ import { DatePipe } from '@angular/common';
import * as firebase from "firebase";
import { LocalNotifications } from '@ionic-native/local-notifications';
import { Toast } from '@ionic-native/toast';
import { PhotoViewer } from '@ionic-native/photo-viewer';
import { FileOpener } from '@ionic-native/file-opener';
import { FileTransfer } from '@ionic-native/file-transfer';
import { File } from '@ionic-native/file';
export const firebaseConfig = {
apiKey: "AIzaSyDLrbLd4RCCh86xuTVu7-cfJ28We_cG1sU",
......@@ -65,6 +69,10 @@ firebase.initializeApp(firebaseConfig);
DatePipe,
LocalNotifications,
Toast,
PhotoViewer,
FileOpener,
FileTransfer,
File
]
})
export class AppModule {}
......@@ -15,17 +15,18 @@
<br>
<p>Your documents must be readable<br>
and clear</p>
<button ion-button class="upload_btn" id="upld_btn">
<input type="file" (change)="fileChange($event)" accept="image/*">
<button ion-button class="upload_btn" id="upld_btn" *ngIf="fileData?.fileStatus=='0' || fileData?.fileStatus=='3'">{{butonName}}
<input type="file" (change)="fileChange($event)" accept="application/pdf,image/*">
</button>
<div class="check_box">
<div class="check_box" *ngIf="fileData?.fileStatus=='2'">
</div>
<h6>{{filename}}</h6>
<!-- <h5>Upload Complete</h5> -->
<h5 *ngIf="fileData?.fileStatus=='1'">Processing</h5>
</div>
</ion-content>
<ion-footer padding>
<button ion-button class="primary btn_primary" (click)="upload()">DONE</button>
<button ion-button class="primary btn_primary" (click)="upload()" *ngIf="fileData?.fileStatus=='0' || fileData?.fileStatus=='3'">DONE</button>
<button ion-button class="primary btn_primary" (click)="view()" *ngIf="fileData?.fileStatus!='0'">view</button>
</ion-footer>
......@@ -99,5 +99,6 @@ page-docupdate {
height: 45px;
font-size: 16px;
letter-spacing: 2px;
color:#f7941e;
}
}
......@@ -5,6 +5,10 @@ import { Storage } from "@ionic/storage";
import { driver } from "../../models/mymodel";
import { Toast } from '@ionic-native/toast';
import { dataService } from "../../providers/common.service";
import { PhotoViewer } from '@ionic-native/photo-viewer';
import { FileOpener } from '@ionic-native/file-opener';
import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer';
import { File } from '@ionic-native/file';
@IonicPage()
@Component({
......@@ -17,26 +21,30 @@ export class DocupdatePage {
filename: string;
local: driver;
fileData: any;
baseUrl: string = this.myservice.base_url
myData = { 'secret_key': 'My_key' }
butonName:string;
constructor(public navCtrl: NavController, public navParams: NavParams, private myservice: Myservice, private storage: Storage, private toast: Toast, private comService: dataService) {
constructor(public navCtrl: NavController, public navParams: NavParams, private myservice: Myservice, private storage: Storage, private toast: Toast, private comService: dataService, private photoViewer: PhotoViewer, private fileOpener: FileOpener, private transfer: FileTransfer, private file: File) {
}
ionViewDidEnter() {
this.fileData = this.comService.getdocData();
console.log(this.fileData)
this.storage.get('driver_data').then(data => {
if (data) {
this.myservice.hide_loader()
this.local = data
// if (response.status == 'success') {
// document.getElementById("upld_btn").textContent = 'UPDATE'
// this.fileData = response.data
// }
// else{
// document.getElementById("upld_btn").textContent = 'UPLOAD'
// }
if (this.fileData.fileStatus == '3') {
this.butonName = 'UPDATE'
// document.getElementById("upld_btn").innerText = 'UPDATE'
}
else if (this.fileData.fileStatus == '0') {
this.butonName = 'UPLOAD'
// document.getElementById("upld_btn").innerText = 'UPLOAD'
}
}
})
}
......@@ -46,9 +54,9 @@ export class DocupdatePage {
if (fileList.length > 0) {
var reader = new FileReader();
reader.readAsDataURL(event.target.files[0]);
let file = fileList[0];
var ext = (file.name).split(".").pop();
if (ext == 'jpg' || ext == 'jpeg' || ext == 'png' || ext == 'pdf') {
......@@ -62,21 +70,51 @@ export class DocupdatePage {
}
upload() {
this.myservice.show_loader()
// this.formdata.append('data', JSON.stringify(this.myData));
if (this.fileData)
this.formdata.append('id', JSON.stringify(this.fileData.id));
this.myservice.fileUpload(this.formdata, 'driverDocUpload').subscribe(resp => {
this.myservice.hide_loader()
if (resp.status == 'success') {
// this.toast.show(resp.message, '2000', 'center').subscribe(toast => {
// console.log(toast);
// });
}
else
this.myservice.show_alert('', resp.message);
})
if (this.filename) {
this.myservice.show_loader()
this.formdata.append('data', JSON.stringify(this.myData));
if (this.fileData)
this.formdata.append('id', JSON.stringify(this.fileData.fileId));
this.myservice.fileUpload(this.formdata, 'driverDocUpload').subscribe(resp => {
this.myservice.hide_loader()
if (resp.status == 'success') {
this.navCtrl.pop();
this.toast.show(resp.message, '2000', 'center').subscribe(toast => {
console.log(toast);
});
}
else
this.myservice.show_alert('', resp.message);
})
}
else
this.myservice.show_alert('','Please select a file to upload')
}
view() {
if (this.fileData.image.includes(".pdf")) {
// const options: DocumentViewerOptions = {
// title: ''
// }
console.log(this.baseUrl + this.fileData.image)
const fileTransfer: FileTransferObject = this.transfer.create();
const url = this.baseUrl + this.fileData.image;
fileTransfer.download(url, this.file.dataDirectory + this.title +'.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
this.fileOpener.open(entry.toURL(), 'application/pdf')
.then(() => console.log('File is opened'))
.catch(e => console.log('Error openening file', e));
}, (error) => {
// handle error
});
// this.document.viewDocument(this.baseUrl + this.fileData.image, 'application/pdf', options)
}
else {
this.photoViewer.show(this.baseUrl + this.fileData.image);
}
}
back() {
......
......@@ -49,7 +49,7 @@ tab_swap(type) {
rideDetails(data){
this.data.setrideData(data)
// this.navCtrl.push('RidedetailsPage')
this.navCtrl.setRoot('QuickridePage', { id: '38'})
this.navCtrl.push('RidedetailsPage')
// this.navCtrl.setRoot('QuickridePage', { id: '38'})
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment