Fotografia Anexada
-
+
- {{photoService.photos[0].fileName}}
- size
+ {{capturedImageTitle}}
+ size
diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts
index 6d5b3e507..c5a993c65 100644
--- a/src/app/pages/publications/new-publication/new-publication.page.ts
+++ b/src/app/pages/publications/new-publication/new-publication.page.ts
@@ -1,16 +1,19 @@
import { Component, OnInit } from '@angular/core';
-import { ModalController, NavParams } from '@ionic/angular';
+import { AlertController, ModalController, NavParams } from '@ionic/angular';
import { GalleryPage } from '../gallery/gallery.page';
-import {Plugins, CameraResultType, CameraSource} from '@capacitor/core';
+/* import {Plugins, CameraResultType, CameraSource} from '@capacitor/core'; */
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { PublicationsService } from 'src/app/services/publications.service';
import { Publication } from 'src/app/models/publication';
import { Image } from 'src/app/models/image';
import { ThrowStmt } from '@angular/compiler';
import { PhotoService } from 'src/app/services/photo.service';
+import { AlertService } from 'src/app/services/alert.service';
-const { Camera } = Plugins;
+/* const { Camera } = Plugins; */
+
+import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
@Component({
selector: 'app-new-publication',
@@ -35,14 +38,18 @@ export class NewPublicationPage implements OnInit {
guestPicture:any;
capturedImage:any;
+ capturedImageTitle:any;
+
constructor(
private modalController: ModalController,
public photoService: PhotoService,
private navParams: NavParams,
+ private alertService: AlertService,
/* private camera: Camera, */
private sanitizer: DomSanitizer,
private publications: PublicationsService,
+ private camera: Camera,
) {
this.publicationType = this.navParams.get('publicationType');
this.folderId = this.navParams.get('folderId');
@@ -55,7 +62,23 @@ export class NewPublicationPage implements OnInit {
}
takePictureCodova(){
- this.photoService.takePicture();
+ const options: CameraOptions = {
+ quality: 100,
+ destinationType: this.camera.DestinationType.DATA_URL,
+ encodingType: this.camera.EncodingType.JPEG,
+ mediaType: this.camera.MediaType.PICTURE
+ }
+
+ 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();
+ }, (err) => {
+ // Handle error
+ });
+
}
/* takePictureCapacitor() {
@@ -88,21 +111,31 @@ export class NewPublicationPage implements OnInit {
async save(){
console.log(this.pub.FileBase64);
if(this.publicationType == '3'){
- this.image = {
- title: this.image.title,
- url: this.image.url,
- format: 'png'
+ if(this.capturedImage != ''){
+ this.publication = {
+ DocumentId:this.publication.DocumentId,
+ ProcessId:this.publication.ProcessId,
+ Title: this.pub.Title,
+ Message: this.pub.Message,
+ DatePublication: this.publication.DatePublication,
+ OriginalFileName: this.capturedImageTitle,
+ FileBase64: this.capturedImage,
+ FileExtension: 'jpg',
+ }
}
- this.publication = {
- DocumentId:this.publication.DocumentId,
- ProcessId:this.publication.ProcessId,
- Title: this.pub.Title,
- Message: this.pub.Message,
- DatePublication: this.publication.DatePublication,
- OriginalFileName: '',
- FileBase64: this.publication.FileBase64,
- FileExtension: 'jpg',
+ else{
+ this.publication = {
+ DocumentId:this.publication.DocumentId,
+ ProcessId:this.publication.ProcessId,
+ Title: this.pub.Title,
+ Message: this.pub.Message,
+ DatePublication: this.publication.DatePublication,
+ OriginalFileName: '',
+ FileBase64: this.publication.FileBase64,
+ FileExtension: 'jpg',
+ }
}
+
console.log('Edit');
console.log(this.publication);
this.publications.UpdatePublication(this.publication.ProcessId, this.publication);
@@ -110,19 +143,14 @@ export class NewPublicationPage implements OnInit {
}
else{
- this.image = {
- title: this.image.title,
- url: this.image.url,
- format: 'png'
- }
this.publication = {
DocumentId:null,
ProcessId:this.folderId,
Title: this.pub.Title,
Message: this.pub.Message,
DatePublication: new Date(),
- OriginalFileName: 'foto',
- FileBase64: this.photoService.photos[0].webviewPath,
+ OriginalFileName: this.capturedImageTitle,
+ FileBase64: this.capturedImage,
FileExtension: 'jpg',
}
@@ -138,7 +166,7 @@ export class NewPublicationPage implements OnInit {
this.modalController.dismiss();
}
clear(){
- this.photoService.photos = [];
+ this.capturedImage = '';
}
setTitle(){
if(this.publicationType == '1'){
@@ -165,7 +193,7 @@ export class NewPublicationPage implements OnInit {
modal.onDidDismiss();
} */
- async takePicture(){
+ /* async takePicture(){
const image = await Plugins.Camera.getPhoto({
quality: 100,
allowEditing: false,
@@ -175,7 +203,7 @@ export class NewPublicationPage implements OnInit {
console.log(image);
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
- }
+ } */
openCamera(){
/* this.camera.getPicture({
sourceType: this.camera.PictureSourceType.CAMERA,
diff --git a/src/app/resolvers/userData.resolver.ts b/src/app/resolvers/userData.resolver.ts
index b5b5bbc93..8d9771fc6 100644
--- a/src/app/resolvers/userData.resolver.ts
+++ b/src/app/resolvers/userData.resolver.ts
@@ -8,6 +8,6 @@ export class UserDataResolver{
constructor(private authService: AuthService){}
resolve(){
- return this.authService.getUserData();
+ /* return this.authService.getUserData(); */
}
}
\ No newline at end of file
diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts
index a8835bfa6..4d4e1c4dd 100644
--- a/src/app/services/auth.service.ts
+++ b/src/app/services/auth.service.ts
@@ -56,24 +56,24 @@ export class AuthService {
}
//Get user data from RocketChat
- getUserData(){
+ /* getUserData(){
this.storageService.get(AuthConnstants.AUTH).then(res=>{
this.userData$.next(res);
})
- }
+ } */
- getProfile(){
+ /* getProfile(){
this.storageService.get(AuthConnstants.PROFILE).then(res=>{
return res;
});
- }
+ } */
logoutChat(){
//this.storageService.clear();
- this.storageService.removeStorageItem(AuthConnstants.AUTH).then(res =>{
+ /* this.storageService.removeStorageItem(AuthConnstants.AUTH).then(res =>{
this.userData$.next('');
this.router.navigate(['']);
- })
+ }) */
}
diff --git a/src/app/services/fcm.service.ts b/src/app/services/fcm.service.ts
index 02793945e..202caa552 100644
--- a/src/app/services/fcm.service.ts
+++ b/src/app/services/fcm.service.ts
@@ -1,14 +1,14 @@
import { Injectable } from '@angular/core';
-import {
+/* import {
Plugins,
PushNotification,
PushNotificationToken,
PushNotificationActionPerformed,
Capacitor
-} from '@capacitor/core';
+} from '@capacitor/core'; */
import { Router } from '@angular/router';
-const { PushNotifications } = Plugins;
+/* const { PushNotifications } = Plugins; */
@Injectable({
providedIn: 'root'
@@ -17,7 +17,7 @@ export class FcmService {
constructor(private router: Router) { }
- initPush() {
+ /* initPush() {
if (Capacitor.platform !== 'web') {
this.registerPush();
}
@@ -58,7 +58,7 @@ export class FcmService {
}
}
);
- }
+ } */
}
diff --git a/src/app/services/photo.service.ts b/src/app/services/photo.service.ts
index fcfdcfda8..c9f72b947 100644
--- a/src/app/services/photo.service.ts
+++ b/src/app/services/photo.service.ts
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
-import { Plugins, CameraResultType, Capacitor, FilesystemDirectory, CameraPhoto, CameraSource } from '@capacitor/core';
+/* import { Plugins, CameraResultType, Capacitor, FilesystemDirectory, CameraPhoto, CameraSource } from '@capacitor/core'; */
import { Photo } from '../models/photo';
import { Platform } from '@ionic/angular';
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
@@ -27,6 +27,8 @@ export class PhotoService {
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
+
+
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
diff --git a/src/app/services/storage.service.ts b/src/app/services/storage.service.ts
index d47dacad2..e65b0037a 100644
--- a/src/app/services/storage.service.ts
+++ b/src/app/services/storage.service.ts
@@ -1,13 +1,13 @@
import { Injectable } from '@angular/core';
-import { Plugins } from '@capacitor/core';
-const { Storage } = Plugins;
+/* import { Plugins } from '@capacitor/core';
+const { Storage } = Plugins; */
@Injectable({
providedIn: 'root'
})
export class StorageService {
constructor() {}
- // Store the value
+ /* // Store the value
async store(storageKey: string, value: any) {
const encryptedValue = btoa(escape(JSON.stringify(value)));
await Storage.set({
@@ -29,5 +29,5 @@ const { Storage } = Plugins;
// Clear storage
async clear() {
await Storage.clear();
- }
+ } */
}