mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
save
This commit is contained in:
Generated
+5
@@ -2040,6 +2040,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@capacitor/app/-/app-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@capacitor/app/-/app-1.0.5.tgz",
|
||||||
"integrity": "sha512-U0dAw1CAjKyguSRxKDabszsQ4dj679RnxaUZrSHDR5Jnt5x308oQuKXFP++wnMBbw72D02iqjG0a+/Ujye7C9g=="
|
"integrity": "sha512-U0dAw1CAjKyguSRxKDabszsQ4dj679RnxaUZrSHDR5Jnt5x308oQuKXFP++wnMBbw72D02iqjG0a+/Ujye7C9g=="
|
||||||
},
|
},
|
||||||
|
"@capacitor/camera": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@capacitor/camera/-/camera-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-NAIGWnyHBGQ/dgla/D4KDkAeQ2f3fzw+D+DIkGNH3f1ciX4bXC7lNbDVU67SMOuNt+CmcTJF64q3nVXcpv5JvQ=="
|
||||||
|
},
|
||||||
"@capacitor/cli": {
|
"@capacitor/cli": {
|
||||||
"version": "3.3.0",
|
"version": "3.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-3.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-3.3.0.tgz",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"@angular/router": "~12.1.2",
|
"@angular/router": "~12.1.2",
|
||||||
"@capacitor/android": "^3.3.0",
|
"@capacitor/android": "^3.3.0",
|
||||||
"@capacitor/app": "^1.0.5",
|
"@capacitor/app": "^1.0.5",
|
||||||
|
"@capacitor/camera": "^1.2.0",
|
||||||
"@capacitor/core": "^3.3.0",
|
"@capacitor/core": "^3.3.0",
|
||||||
"@capacitor/filesystem": "^1.0.6",
|
"@capacitor/filesystem": "^1.0.6",
|
||||||
"@capacitor/haptics": "^1.1.3",
|
"@capacitor/haptics": "^1.1.3",
|
||||||
|
|||||||
@@ -34,7 +34,9 @@
|
|||||||
<p>{{capturedImageTitle}}</p>
|
<p>{{capturedImageTitle}}</p>
|
||||||
<p hidden>size</p>
|
<p hidden>size</p>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
<ion-icon (click)="clear()" name="close"></ion-icon>
|
<div (click)="clear()">
|
||||||
|
<ion-icon name="close"></ion-icon>
|
||||||
|
</div>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,15 +9,14 @@ import { Image } from 'src/app/models/image';
|
|||||||
import { PhotoService } from 'src/app/services/photo.service';
|
import { PhotoService } from 'src/app/services/photo.service';
|
||||||
//Capacitor
|
//Capacitor
|
||||||
|
|
||||||
//Cordova
|
|
||||||
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
|
||||||
import { ToastService } from 'src/app/services/toast.service';
|
import { ToastService } from 'src/app/services/toast.service';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { ThemePalette } from '@angular/material/core';
|
import { ThemePalette } from '@angular/material/core';
|
||||||
import { formatDate } from 'src/plugin/momentG.js'
|
import { formatDate } from 'src/plugin/momentG.js'
|
||||||
import { FileLoaderService } from 'src/app/services/file/file-loader.service';
|
import { FileLoaderService } from 'src/app/services/file/file-loader.service';
|
||||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||||
import { ThemeService } from 'src/app/services/theme.service'
|
import { ThemeService } from 'src/app/services/theme.service';
|
||||||
|
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-new-publication',
|
selector: 'app-new-publication',
|
||||||
@@ -59,15 +58,15 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
guestPicture:any;
|
guestPicture:any;
|
||||||
|
|
||||||
capturedImage:any;
|
capturedImage:any = '';
|
||||||
capturedImageTitle:any;
|
capturedImageTitle:any;
|
||||||
|
public photos: any[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
public photoService: PhotoService,
|
public photoService: PhotoService,
|
||||||
private navParams: NavParams,
|
private navParams: NavParams,
|
||||||
private publications: PublicationsService,
|
private publications: PublicationsService,
|
||||||
private camera: Camera,
|
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private fileLoaderService: FileLoaderService,
|
private fileLoaderService: FileLoaderService,
|
||||||
private fileToBase64Service: FileToBase64Service,
|
private fileToBase64Service: FileToBase64Service,
|
||||||
@@ -81,32 +80,40 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.setTitle();
|
this.setTitle();
|
||||||
this.clear();
|
|
||||||
// this.takePicture();
|
// this.takePicture();
|
||||||
}
|
}
|
||||||
|
|
||||||
takePicture() {
|
async takePicture() {
|
||||||
const options: CameraOptions = {
|
const capturedImage = await Camera.getPhoto({
|
||||||
quality: 50,
|
quality: 90,
|
||||||
destinationType: this.camera.DestinationType.DATA_URL,
|
// allowEditing: true,
|
||||||
encodingType: this.camera.EncodingType.JPEG,
|
resultType: CameraResultType.Uri,
|
||||||
mediaType: this.camera.MediaType.PICTURE,
|
source: CameraSource.Camera
|
||||||
targetWidth: 720,
|
|
||||||
targetHeight: 720,
|
|
||||||
}
|
|
||||||
|
|
||||||
this.camera.getPicture(options).then((imageData) => {
|
});
|
||||||
// imageData is either a base64 encoded string or a file URI
|
const response = await fetch(capturedImage.webPath!);
|
||||||
// If it's base64 (DATA_URL): m
|
const blob = await response.blob();
|
||||||
//let base64Image = 'data:image/jpeg;base64,' + imageData;
|
|
||||||
|
|
||||||
this.capturedImage = 'data:image/png;base64,'+imageData;
|
this.photos.unshift({
|
||||||
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
filepath: "soon...",
|
||||||
}, (err) => {
|
webviewPath: capturedImage.webPath
|
||||||
/* console.log(err); */
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.capturedImage = await this.convertBlobToBase64(blob);
|
||||||
|
|
||||||
|
//console.log(this.capturedImage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader;
|
||||||
|
reader.onerror = reject;
|
||||||
|
reader.onload = () => {
|
||||||
|
resolve(reader.result);
|
||||||
|
};
|
||||||
|
reader.readAsDataURL(blob);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
laodPicture() {
|
laodPicture() {
|
||||||
const input = this.fileLoaderService.createInput({
|
const input = this.fileLoaderService.createInput({
|
||||||
@@ -125,7 +132,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPicture() {
|
/* getPicture() {
|
||||||
const options: CameraOptions = {
|
const options: CameraOptions = {
|
||||||
quality: 90,
|
quality: 90,
|
||||||
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
|
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
|
||||||
@@ -143,9 +150,9 @@ export class NewPublicationPage implements OnInit {
|
|||||||
this.capturedImage = imageData;
|
this.capturedImage = imageData;
|
||||||
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
/* console.log(err); */
|
console.log(err);
|
||||||
});
|
});
|
||||||
}
|
} */
|
||||||
|
|
||||||
runValidation() {
|
runValidation() {
|
||||||
this.validateFrom = true
|
this.validateFrom = true
|
||||||
|
|||||||
Reference in New Issue
Block a user