@@ -29,7 +29,7 @@
Fotografia Anexada
-
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 db2e9b480..04c3f191b 100644
--- a/src/app/shared/publication/new-publication/new-publication.page.ts
+++ b/src/app/shared/publication/new-publication/new-publication.page.ts
@@ -8,7 +8,8 @@ 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';
@Component({
selector: 'app-new-publication',
templateUrl: './new-publication.page.html',
@@ -51,6 +52,8 @@ export class NewPublicationPage implements OnInit {
private camera: Camera,
private animationController: AnimationController,
private toastService: ToastService,
+ private fileLoaderService: FileLoaderService,
+ private fileToBase64Service: FileToBase64Service
) {
this.publicationTitle = 'Nova Publicação';
}
@@ -88,7 +91,7 @@ export class NewPublicationPage implements OnInit {
}
- takePicture(){
+ takePicture() {
const options: CameraOptions = {
quality: 90,
destinationType: this.camera.DestinationType.DATA_URL,
@@ -99,9 +102,7 @@ export class NewPublicationPage implements OnInit {
}
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) => {
@@ -109,27 +110,21 @@ 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);
- });
- }
+ laodPicture() {
+ const input = this.fileLoaderService.createInput({})
+
+ input.onchange = async () => {
+ // you can use this method to get file and perform respective operations
+ let files = Array.from(input.files);
+ const file1 = files[0]
+ const imageData = await this.fileToBase64Service.convert(file1)
+
+ this.capturedImage = imageData;
+ this.capturedImageTitle = file1.name
+ };
+
+ }
runValidation() {
@@ -190,7 +185,7 @@ export class NewPublicationPage implements OnInit {
}
}
- else if (!this.publication.OriginalFileName) {
+ else if (!this.publication.OriginalFileName) { //
this.publication = {
DateIndex: this.publication.DateIndex,
DocumentId:this.publication.DocumentId,
@@ -198,6 +193,7 @@ export class NewPublicationPage implements OnInit {
Title: this.pub.Title,
Message: this.pub.Message,
DatePublication: this.publication.DatePublication,
+ OriginalFileName: this.capturedImageTitle,
// OriginalFileName: this.publication.OriginalFileName,
// FileBase64: this.publication.FileBase64,
// FileExtension: 'jpeg',
@@ -286,10 +282,10 @@ export class NewPublicationPage implements OnInit {
this.capturedImage = '';
}
setTitle(){
- if(this.publicationType == '1'){
+ if(this.publicationType == '1') {
this.publicationTitle = 'Nova Publicação Rápida';
}
- else if(this.publicationType == '2'){
+ else if(this.publicationType == '2') {
this.publicationTitle = 'Nova Publicação';
}
else if(this.publicationType == '3') {
@@ -309,33 +305,4 @@ export class NewPublicationPage implements OnInit {
}
- /* async openGallery() {
- const modal = await this.modalController.create({
- component: GalleryPage,
- componentProps:{
- },
- cssClass: 'new-publication',
- backdropDismiss: false
- });
- await modal.present();
- modal.onDidDismiss();
- } */
-
- /* async takePicture(){
- const image = await Plugins.Camera.getPhoto({
- quality: 100,
- allowEditing: false,
- resultType: CameraResultType.DataUrl,
- source: CameraSource.Camera
- });
- console.log(image);
-
- this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
- } */
-
-
-
-
-
-
}