This commit is contained in:
tiago.kayaya
2021-11-09 15:28:40 +01:00
parent f7c8942444
commit 3a46b77e36
6 changed files with 69 additions and 63 deletions
+4
View File
@@ -2,6 +2,10 @@
<widget version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <widget version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<access origin="*" /> <access origin="*" />
<feature name="sqlDB">
<param name="ios-package" value="sqlDB"/>
</feature>
<feature name="SQLitePlugin"> <feature name="SQLitePlugin">
<param name="ios-package" value="SQLitePlugin"/> <param name="ios-package" value="SQLitePlugin"/>
</feature> </feature>
+3
View File
@@ -9,8 +9,11 @@ install! 'cocoapods', :disable_input_output_paths => true
def capacitor_pods def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app'
pod 'CapacitorCamera', :path => '..\..\node_modules\@capacitor\camera'
pod 'CapacitorFilesystem', :path => '..\..\node_modules\@capacitor\filesystem' pod 'CapacitorFilesystem', :path => '..\..\node_modules\@capacitor\filesystem'
pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics' pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics'
pod 'CapacitorPushNotifications', :path => '..\..\node_modules\@capacitor\push-notifications'
pod 'CapacitorVoiceRecorder', :path => '..\..\node_modules\capacitor-voice-recorder' pod 'CapacitorVoiceRecorder', :path => '..\..\node_modules\capacitor-voice-recorder'
pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins' pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins' pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'
+60 -59
View File
@@ -2,14 +2,14 @@ import { Injectable } from '@angular/core';
import { FileLoaderService } from '../file/file-loader.service'; import { FileLoaderService } from '../file/file-loader.service';
import { FileToBase64Service } from '../file/file-to-base64.service'; import { FileToBase64Service } from '../file/file-to-base64.service';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
//Cordova
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
import { ChatService } from '../chat.service'; import { ChatService } from '../chat.service';
import { ModalController } from '@ionic/angular'; import { ModalController } from '@ionic/angular';
import { SearchPage } from 'src/app/pages/search/search.page'; import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchList } from 'src/app/models/search-document'; import { SearchList } from 'src/app/models/search-document';
import { ProcessesService } from '../processes.service'; import { ProcessesService } from '../processes.service';
import { ToastService } from '../toast.service'; import { ToastService } from '../toast.service';
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -22,9 +22,9 @@ export class FileService {
showLoader: boolean; showLoader: boolean;
files: Set<File>; files: Set<File>;
photos: any[] = [];
constructor( constructor(
private camera: Camera,
private fileLoaderService: FileLoaderService, private fileLoaderService: FileLoaderService,
private fileToBase64Service: FileToBase64Service, private fileToBase64Service: FileToBase64Service,
private iab: InAppBrowser, private iab: InAppBrowser,
@@ -34,26 +34,25 @@ export class FileService {
private toastService: ToastService, private toastService: ToastService,
) { } ) { }
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
// If it's base64 (DATA_URL): m
//let base64Image = 'data:image/jpeg;base64,' + imageData;
this.capturedImage = 'data:image/png;base64,'+imageData;
this.capturedImageTitle = new Date().getTime() + '.jpeg';
}, (err) => {
/* console.log(err); */
}); });
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);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
let data = { let data = {
image:this.capturedImage, image:this.capturedImage,
name: this.capturedImageTitle name: this.capturedImageTitle
@@ -62,6 +61,15 @@ export class FileService {
return data; return data;
} }
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);
});
loadPicture() { loadPicture() {
const input = this.fileLoaderService.createInput({ const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png'] accept: ['image/apng', 'image/jpeg', 'image/png']
@@ -85,19 +93,24 @@ export class FileService {
}; };
} }
addCameraPictureToChat(roomId){ async addCameraPictureToChat(roomId){
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) => { });
this.capturedImage = 'data:image/png;base64,'+imageData; 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);
this.capturedImageTitle = new Date().getTime() + '.jpeg'; this.capturedImageTitle = new Date().getTime() + '.jpeg';
let body = { let body = {
@@ -121,29 +134,26 @@ export class FileService {
this.toastService.badRequest("Não foi possível adicionar a fotografia!"); this.toastService.badRequest("Não foi possível adicionar a fotografia!");
}); });
}, (err) => {
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
});
} }
addPictureToChatMobile(roomId) { async addPictureToChatMobile(roomId) {
alert('Here')
const options: CameraOptions = { const capturedImage = await Camera.getPhoto({
quality: 90, quality: 90,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY, // allowEditing: true,
destinationType: this.camera.DestinationType.DATA_URL, resultType: CameraResultType.Uri,
encodingType: this.camera.EncodingType.JPEG, source: CameraSource.Camera
mediaType: this.camera.MediaType.PICTURE,
targetWidth: 720,
targetHeight: 720,
correctOrientation: true
}
this.camera.getPicture(options).then((imageData) => { });
let base64Image = 'data:image/jpeg;base64,' + imageData; const response = await fetch(capturedImage.webPath!);
this.capturedImage = imageData; const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg'; this.capturedImageTitle = new Date().getTime() + '.jpeg';
//const loader = this.toastService.loading(); //const loader = this.toastService.loading();
@@ -161,21 +171,12 @@ export class FileService {
}] }]
} }
} }
console.log(this.capturedImage)
this.chatService.sendMessage(body).subscribe(res=> { this.chatService.sendMessage(body).subscribe(res=> {
//loader.remove(); //loader.remove();
//console.log(res); //console.log(res);
},(error) => { },(error) => {
//loader.remove(); //loader.remove();
}); });
}, (err) => {
//console.log(err);
});
} }
addPictureToChat(roomId) { addPictureToChat(roomId) {
@@ -3,7 +3,7 @@
<div class="main-header"> <div class="main-header">
<div class="header-top"> <div class="header-top">
<div class="middle" *ngFor="let users of dmUsers"> <div class="middle" *ngFor="let users of dmUsers">
<ion-label class="title">{{users.name}}11</ion-label> <ion-label class="title">{{users.name}}</ion-label>
<span><ion-icon class="{{users.status}}" name="ellipse"></ion-icon></span> <span><ion-icon class="{{users.status}}" name="ellipse"></ion-icon></span>
</div> </div>
<div hidden class="right"> <div hidden class="right">
@@ -6,7 +6,7 @@
</button> </button>
</div> </div>
<div class="buttons"> <div class="buttons">
<button hidden (click)="takePicture()" full class="btn-ok" shape="round" >Tirar Fotografia</button> <button (click)="takePicture()" full class="btn-ok" shape="round" >Tirar Fotografia</button>
<button hidden (click)="addFile()" class="btn-ok" shape="round" >Anexar Documento</button> <button hidden (click)="addFile()" class="btn-ok" shape="round" >Anexar Documento</button>
<button hidden (click)="anexarFoto()" full class="btn-ok" shape="round" >Anexar Fotografia</button> <button hidden (click)="anexarFoto()" full class="btn-ok" shape="round" >Anexar Fotografia</button>
<button (click)="addDocGestaoDocumental()" class="btn-ok" shape="round" >Gestão Documental</button> <button (click)="addDocGestaoDocumental()" class="btn-ok" shape="round" >Gestão Documental</button>
@@ -27,7 +27,6 @@
</div> </div>
</div> </div>
<div class="picture d-flex pb-5 hide-desktop" *ngIf="publication.FileBase64 && capturedImage ==''"> <div class="picture d-flex pb-5 hide-desktop" *ngIf="publication.FileBase64 && capturedImage ==''">
<div class="post-img"> <div class="post-img">
<img src="{{publication.FileBase64}}" alt="image" > <img src="{{publication.FileBase64}}" alt="image" >
@@ -84,7 +83,6 @@
</ion-content> </ion-content>
<ion-footer class="ion-no-border"> <ion-footer class="ion-no-border">
<ion-toolbar class="footer-toolbar width-100 px-20"> <ion-toolbar class="footer-toolbar width-100 px-20">
<ion-buttons slot="start"> <ion-buttons slot="start">