diff --git a/src/app/shared/publication/new-publication/new-publication.page.html b/src/app/shared/publication/new-publication/new-publication.page.html
index f3d9dcd50..b4fc4163b 100644
--- a/src/app/shared/publication/new-publication/new-publication.page.html
+++ b/src/app/shared/publication/new-publication/new-publication.page.html
@@ -43,17 +43,6 @@
-
-
-
-
-
-
- Anexar Fotografia
-
-
-
-
Fotografia Anexada
@@ -65,7 +54,9 @@
{{capturedImageTitle}}
size
-
+
@@ -82,7 +73,7 @@
-
+
diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts
index a6beb44ca..2846b000e 100644
--- a/src/app/shared/publication/new-publication/new-publication.page.ts
+++ b/src/app/shared/publication/new-publication/new-publication.page.ts
@@ -4,11 +4,11 @@ import { PublicationsService } from 'src/app/services/publications.service';
import { Publication } from 'src/app/models/publication';
import { Image } from 'src/app/models/image';
import { PhotoService } from 'src/app/services/photo.service';
-import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
import { ToastService } from 'src/app/services/toast.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { FileLoaderService } from 'src/app/services/file/file-loader.service'
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
+import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
@Component({
selector: 'app-new-publication',
templateUrl: './new-publication.page.html',
@@ -38,16 +38,16 @@ export class NewPublicationPage implements OnInit {
@Output() openPublicationDetails = new EventEmitter();
@Output() goBackToViewPublications = new EventEmitter();
@Output() goBacktoPublicationDetails = new EventEmitter();
-
+
guestPicture:any;
- capturedImage:any;
+ capturedImage:any = '';
capturedImageTitle:any;
+ photos: any[] = [];
constructor(
public photoService: PhotoService,
private publications: PublicationsService,
- private camera: Camera,
private toastService: ToastService,
private fileLoaderService: FileLoaderService,
private fileToBase64Service: FileToBase64Service
@@ -60,11 +60,11 @@ export class NewPublicationPage implements OnInit {
this.getPublicationDetail();
}
this.setTitle();
- this.clear();
- this.takePicture();
+ //this.clear();
+ //this.takePicture();
}
- getPublicationDetail() {
+ getPublicationDetail() {
this.showLoader = true;
//console.log(this.publicationId);
/* console.log(this.folderId); */
@@ -88,30 +88,42 @@ export class NewPublicationPage implements OnInit {
}
- takePicture() {
- const options: CameraOptions = {
+ async takePicture() {
+ const capturedImage = await Camera.getPhoto({
quality: 90,
- destinationType: this.camera.DestinationType.DATA_URL,
- encodingType: this.camera.EncodingType.JPEG,
- mediaType: this.camera.MediaType.PICTURE,
- targetWidth: 720,
- targetHeight: 720,
+ // allowEditing: true,
+ resultType: CameraResultType.Uri,
+ source: CameraSource.Camera
+
+ });
+ const response = await fetch(capturedImage.webPath!);
+ const blob = await response.blob();
+
+ this.photos.unshift({
+ filepath: "soon...",
+ webviewPath: capturedImage.webPath
+ });
+
+ this.capturedImage = await this.convertBlobToBase64(blob);
+
+ //console.log(this.capturedImage);
+
}
- this.camera.getPicture(options).then((imageData) => {
-
- this.capturedImage = imageData;
- this.capturedImageTitle = new Date().getTime() + '.jpeg';
- }, (err) => {
- console.log(err);
+ convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
+ const reader = new FileReader;
+ reader.onerror = reject;
+ reader.onload = () => {
+ resolve(reader.result);
+ };
+ reader.readAsDataURL(blob);
});
- }
laodPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
-
+
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
@@ -200,14 +212,14 @@ export class NewPublicationPage implements OnInit {
console.log(this.publication);
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
this.toastService.successMessage()
-
+
this.goBack();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
-
+
} else {
this.publication = {
DateIndex: this.publication.DateIndex,
@@ -252,7 +264,7 @@ export class NewPublicationPage implements OnInit {
FileBase64: this.capturedImage,
FileExtension: 'jpeg',
}
-
+
const loader = this.toastService.loading()
try {
@@ -270,28 +282,6 @@ export class NewPublicationPage implements OnInit {
}
}
- getPicture() {
- const options: CameraOptions = {
- quality: 90,
- sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
- destinationType: this.camera.DestinationType.DATA_URL,
- encodingType: this.camera.EncodingType.JPEG,
- mediaType: this.camera.MediaType.PICTURE,
- targetWidth: 720,
- targetHeight: 720,
- }
-
- this.camera.getPicture(options).then((imageData) => {
- // imageData is either a base64 encoded string or a file URI
- // If it's base64 (DATA_URL):
- let base64Image = 'data:image/jpeg;base64,' + imageData;
- this.capturedImage = imageData;
- this.capturedImageTitle = new Date().getTime() + '.jpeg';
- }, (err) => {
- /* console.log(err); */
- });
- }
-
close(){
this.goBack();
}
@@ -312,14 +302,14 @@ export class NewPublicationPage implements OnInit {
}
async goBack(){
-
+
if(this.publicationType == '2'){
this.goBackToViewPublications.emit();
} else {
this.goBackToViewPublications.emit();
//this.goBacktoPublicationDetails.emit();
}
-
+
}
}