Git pull made with camera and file system chnages

This commit is contained in:
Eudes Inácio
2021-11-09 17:54:52 +01:00
58 changed files with 1279 additions and 318 deletions
+17 -4
View File
@@ -48,7 +48,6 @@
<ion-refresher-content>
</ion-refresher-content>
</ion-refresher> -->
<div (click)="handleClick()" class="messages" #scrollMe>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of chatMessageStore.message[roomId]; let last = last"
[class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
@@ -124,6 +123,19 @@
</ion-footer> -->
<ion-footer>
<ion-list hidden>
<ion-item (click)="playFile(storedFileNames)">
{{storedFileNames}}
</ion-item>
<ion-item (click)="playFile(storedFileNames)">
{{storedFileNames}}
</ion-item>
</ion-list>
<audio hidden controls>
<source src="https://www.tabularium.pt/file-upload/5g6DkyMC4MHcuaDyp/Audio%20record.mp3" type="audio/mpeg">
</audio>
<!-- <button (click)="startRecording()">Start Recording</button>
<button (click)="stopRecording()">Stop Recording</button> -->
<div class="container width-100 d-flex">
<div>
<button class="btn-no-color" (click)="openChatOptions()">
@@ -133,9 +145,10 @@
</div>
<div class="width-70">
<ion-item class="ion-no-padding ion-no-margin type-message" lines="none">
<ion-textarea clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
<button hidden class="btn-no-color" (click)="notImplemented()">
<!-- <ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon> -->
<ion-textarea *ngIf="!recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
<ion-textarea *ngIf="recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="durationDisplay"></ion-textarea>
<button hidden #recordbtn class="btn-no-color" (click)="notImplemented()">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
</button>
</ion-item>
</div>
+105 -63
View File
@@ -20,6 +20,9 @@ import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
import { environment } from 'src/environments/environment';
import { ThemeService } from 'src/app/services/theme.service'
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, CurrentRecordingStatus } from 'capacitor-voice-recorder';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
@Component({
selector: 'app-messages',
@@ -44,8 +47,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
members:any;
scrollingOnce:boolean = true;
chatMessageStore = ChatMessageStore
chatUserStorage = ChatUserStorage
chatMessageStore = ChatMessageStore;
chatUserStorage = ChatUserStorage;
private scrollChangeCallback: () => void;
currentPosition: any;
@@ -60,6 +63,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
task: ExpedientTaskModalPageNavParamsTask;
LoadedDocument:any = null;
recording = false;
storedFileNames = [];
durationDisplay = '';
duration = 0;
@ViewChild('recordbtn', { read: ElementRef }) recordBtn: ElementRef;
myAudio: any;
constructor(
public popoverController: PopoverController,
private modalController: ModalController,
@@ -75,11 +85,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private processes: ProcessesService,
public ThemeService: ThemeService
) {
/* this.activatedRoute.paramMap.subscribe(params => {
if(params["params"].SerialNumber) {
this.roomId = params["params"].roomId;
}
}); */
this.loggedUser = authService.ValidatedUserChat['data'];
this.roomId = this.navParams.get('roomId');
@@ -91,57 +96,110 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
ngOnInit() {
/* setInterval(()=>{ */
this.load();
/* }, 9000); */
/* this.el = document.getElementById("scrollToBottom");
this.el.scrollTop = this.el.scrollHeight - this.el.scrollTop; */
this.load();
this.setStatus('online');
//this.onPressingMessage();
/* setInterval(()=>{
const gesture = this.gestureController.create({
el: this.rectangle.nativeElement,
gestureName:'my-gesture',
onMove: (detail) => { this.onMove(detail); }
})
gesture.enable();
}, 9000); */
this.loadFiles();
VoiceRecorder.requestAudioRecordingPermission();
}
ngAfterViewInit() {
this.scrollChangeCallback = () => this.onContentScrolled(event);
window.addEventListener('scroll', this.scrollChangeCallback, true);
// const gesture = this.gestureController.create({
// el: this.rectangle.nativeElement,
// gestureName:'long-press',
// onStart: () => { alert('OP') },
// /* onMove () => {
// console.log('Move');
// }, */
// onEnd: () => {
// console.log('ENNNNNDS');
// },
// })
const longpress = this.gestureController.create({
el: this.recordBtn.nativeElement,
threshold: 0,
gestureName: 'long-press',
onStart: ev => {
Haptics.impact({ style: ImpactStyle.Light })
this.startRecording();
this.calculateDuration();
},
onEnd: ev =>{
Haptics.impact({ style: ImpactStyle.Light })
this.stopRecording();
}
}, true);
longpress.enable();
}
calculateDuration(){
if(!this.recording){
this.duration = 0;
this.durationDisplay = '';
return;
}
this.duration += 1;
const minutes = Math.floor(this.duration / 60);
const seconds = (this.duration % 60).toString().padStart(2,'0');
this.durationDisplay = `${minutes}:${seconds}`;
setTimeout(()=>{
this.calculateDuration();
}, 1000)
}
async loadFiles(){
Filesystem.readdir({
path: '',
directory: Directory.Data
}).then(result =>{
console.log(result);
const temp:any[] = result.files.reverse();
this.storedFileNames = temp[0];
console.log(this.storedFileNames);
})
}
startRecording(){
if(this.recording){
return;
}
this.recording = true;
VoiceRecorder.startRecording();
}
stopRecording(){
if(!this.recording){
return;
}
this.recording = false;
VoiceRecorder.stopRecording().then(async (result: RecordingData) =>{
this.recording = false;
if(result.value && result.value.recordDataBase64){
const recordData = result.value.recordDataBase64;
console.log(recordData);
this.myAudio = recordData;
const fileName = new Date().getTime() + ".wav";
await Filesystem.writeFile({
path: fileName,
directory: Directory.Data,
data: recordData,
})
}
})
}
async playFile(fileName?:any){
const audioFile = await Filesystem.readFile({
path: fileName,
directory: Directory.Data
})
console.log(audioFile);
const base64sound = audioFile.data;
const audioRef = new Audio(`data:audio/aac;base64,${base64sound}`)
audioRef.oncanplaythrough = () => audioRef.play();
audioRef.load();
// gesture.enable();
}
handlePress(id?:string){
this.selectedMsgId = id;
this.showMessageOptions = true;
/* if(!this.showMessageOptions){
this.showMessageOptions = true;
}
else{
this.showMessageOptions = false;
} */
}
handleClick(){
@@ -149,22 +207,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.selectedMsgId = "";
}
/* onPressingMessage(){
const gesture = this.gestureController.create({
el: this.messageContainer.nativeElement,
gestureName: 'long-press',
onStart: ev =>{
this.longPressActive = true;
console.log('Pressing');
},
onEnd: ev => {
this.longPressActive = false;
console.log('Stop pressing');
}
});
gesture.enable(true);
} */
deleteMessage(msgId:string){
let body = {
"roomId": this.roomId,
@@ -273,7 +315,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
const roomId = this.roomId;
this.chatService.getRoomMessages(this.roomId).subscribe(res => {
/* console.log(res); */
console.log(res);
this.messages = res['messages'].reverse();
this.chatMessageStore.add(roomId, this.messages)
console.log(this.messages);
@@ -519,7 +561,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.messages = res['messages'].reverse();
this.chatMessageStore.add(roomId, this.messages)
console.log(this.messages);
//console.log(this.messages);
// Reconnect in one second
if(this.route.url != "/home/chat"){
console.log("Timer message stop")
@@ -528,7 +570,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
if(document.querySelector('.isMessagesChatOpened')){
await new Promise(resolve => setTimeout(resolve, 5000));
await this.serverLongPull();
console.log('Timer message running')
//console.log('Timer message running')
}
}
+5 -4
View File
@@ -109,13 +109,13 @@ export class EventsPage implements OnInit {
// console.log('Resize event detected');
});
window['zipPhoneCallback'] = function (zipphone) {
var frame = document.getElementById('home-iframe');
if(frame) {
frame['contentWindow']['postMessage']({call:'cookies', value: { cookies: {} }});
}
}
}
}
@@ -493,12 +493,13 @@ export class EventsPage implements OnInit {
}
goToExpediente(SerialNumber: any) {
if (this.loggeduser.Profile == 'MDGPR') {
this.router.navigate(['/home/events/expediente', SerialNumber, 'events']);
/* if (this.loggeduser.Profile == 'MDGPR') {
this.router.navigate(['/home/events/expediente', SerialNumber, 'events']);
}
else if (this.loggeduser.Profile == 'PR') {
this.router.navigate(['/home/events/expedientes-pr', SerialNumber, 'events']);
}
} */
}
viewExpedientListPage() {
@@ -104,7 +104,7 @@
<button *ngIf="!p.userRole(['PR'])" (click)="attachDocument()" class="btn-cancel" shape="round" >Anexar Documentos</button>
<button (click)="distartExpedientModal('descartar')" class="btn-cancel" shape="round" >Descartar</button>
<button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" full class="btn-cancel" shape="round" >Enviar para pendentes</button>
<button (click)="openNewGroupPage()" class="btn-cancel" shape="round" >Inicair Conversa</button>
<button (click)="openNewGroupPage()" class="btn-cancel" shape="round" >Iniciar Conversa</button>
<div class="solid"></div>
</div>
</div>
@@ -118,8 +118,10 @@
<button (click)="openExpedientActionsModal('1',fulltask)" class="btn-cancel" shape="round" >Solicitar Parecer</button>
<button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
<button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
<button (click)="openNewGroupPage()" class="btn-cancel" shape="round" >Iniciar Conversa</button>
<div hidden class="solid"></div>
<button hidden class="btn-cancel" shape="round" >Delegar</button>
</div>
</div>
@@ -34,8 +34,8 @@
<ion-list>
<div
class="expediente ion-no-padding ion-no-margin cursor-pointer"
*ngFor = "let task of listToPresent"
class="expediente ion-no-padding ion-no-margin cursor-pointer"
*ngFor = "let task of expedientegbstore.list"
(click)="goToExpediente(task.SerialNumber)"
>
<div class="item width-100">
@@ -67,13 +67,13 @@
</ion-list>
<div
*ngIf="!skeletonLoader && listToPresent.length == 0 && listToPresent.length == 0"
*ngIf="!skeletonLoader && expedientegbstore.list.length == 0 && expedientegbstore.list.length == 0"
class="empty-list d-flex height-100 align-center justify-content-center"
>
<span>Lista vazia</span>
</div>
<div *ngIf="skeletonLoader && listToPresent.length == 0">
<div *ngIf="skeletonLoader && expedientegbstore.list.length == 0">
<ion-list>
<ion-item>
@@ -25,7 +25,8 @@ export class ExpedientePage implements OnInit {
taskslist = [];
serialNumber: string;
expedienteGdStore = ExpedienteGdStore
//expedienteGdStore = ExpedienteGdStore;
expedientegbstore = ExpedienteGdStore
expedienteTaskPipe = new ExpedienteTaskPipe()
onlinecheck: boolean;
@@ -60,10 +61,9 @@ export class ExpedientePage implements OnInit {
this.backgroundservice.registerBackService('Online', () => {
this.LoadList();
});
}
async LoadList() {
LoadList() {
this.processes.GetTaskListExpediente(false).subscribe(async res => {
this.skeletonLoader = true
@@ -85,7 +85,6 @@ export class ExpedientePage implements OnInit {
}, (error) => {
this.getEventsFromLocalDb();
})
}
async refreshing() {
@@ -68,7 +68,7 @@ export class ExpedientesPrPage implements OnInit {
LoadList() {
this.skeletonLoader = true
this.processes.GetTaskListExpediente(false).subscribe(result => {
console.log(result);
this.skeletonLoader = false
@@ -99,7 +99,8 @@ export class ExpedientesPrPage implements OnInit {
}
goToExpediente(serialNumber:any){
this.router.navigate(['/home/gabinete-digital/expedientes-pr',serialNumber,'gabinete-digital']);
//this.router.navigate(['/home/gabinete-digital/expedientes-pr',serialNumber,'gabinete-digital']);
this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']);
}
async viewExpedientDetail(serialNumber:any) {
@@ -34,7 +34,9 @@
<p>{{capturedImageTitle}}</p>
<p hidden>size</p>
</ion-label>
<ion-icon (click)="clear()" name="close"></ion-icon>
<div (click)="clear()">
<ion-icon name="close"></ion-icon>
</div>
</ion-item>
@@ -51,7 +53,6 @@
<div class="flex-grow-1 d-flex align-center justify-end" *ngIf="publication.FileBase64">
<div style="color: red;">X</div>
</div>
</div>
<div class="ion-item-container-no-border">
@@ -9,15 +9,14 @@ import { Image } from 'src/app/models/image';
import { PhotoService } from 'src/app/services/photo.service';
//Capacitor
//Cordova
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
import { ToastService } from 'src/app/services/toast.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ThemePalette } from '@angular/material/core';
import { formatDate } from 'src/plugin/momentG.js'
import { FileLoaderService } from 'src/app/services/file/file-loader.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({
selector: 'app-new-publication',
@@ -59,21 +58,21 @@ export class NewPublicationPage implements OnInit {
guestPicture:any;
capturedImage:any;
capturedImage:any = '';
capturedImageTitle:any;
public photos: any[] = [];
constructor(
private modalController: ModalController,
public photoService: PhotoService,
private navParams: NavParams,
private publications: PublicationsService,
private camera: Camera,
private toastService: ToastService,
private fileLoaderService: FileLoaderService,
private fileToBase64Service: FileToBase64Service,
public ThemeService: ThemeService
) {
this.publicationType = this.navParams.get('publicationType');
this.folderId = this.navParams.get('folderId');
this.publicationTitle = 'Nova Publicação';
@@ -81,38 +80,70 @@ export class NewPublicationPage implements OnInit {
ngOnInit() {
this.setTitle();
this.clear();
console.log(this.folderId);
// this.takePicture();
}
takePicture() {
const options: CameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
targetWidth: 720,
targetHeight: 720,
}
async takePicture() {
const capturedImage = await Camera.getPhoto({
quality: 90,
// allowEditing: true,
resultType: CameraResultType.Uri,
source: CameraSource.Camera
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';
//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() {
async laodPicture() {
const capturedImage = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Photos,
quality: 90,
width: 1080,
height: 720,
});
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';
}
/* laodPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
@@ -123,29 +154,9 @@ export class NewPublicationPage implements OnInit {
console.log(this.capturedImage)
};
}
} */
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); */
});
}
runValidation() {
this.validateFrom = true
@@ -168,20 +179,20 @@ export class NewPublicationPage implements OnInit {
])
})
}
async save() {
this.injectValidation()
this.runValidation()
if(this.Form.invalid) return false
if(this.publicationType == '3') {
console.log(this.navParams.get('publication'));
if(this.capturedImage != '') {
if(this.capturedImage != ''){
this.publication = {
DateIndex: this.publication.DateIndex,
DocumentId:this.publication.DocumentId,
@@ -198,13 +209,13 @@ export class NewPublicationPage implements OnInit {
try {
console.log(this.publication);
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
this.toastService.successMessage("Publicação criado")
this.toastService.successMessage("Publicação editada")
this.close();
} catch (error) {
this.toastService.badRequest("Publicação não criado")
this.toastService.badRequest("Publicação não editada")
} finally {
loader.remove()
}
@@ -232,7 +243,7 @@ export class NewPublicationPage implements OnInit {
console.log(this.publication);
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
this.toastService.successMessage("Publicação criado")
this.close();
} catch (error) {
this.toastService.badRequest("Publicação não criado")
@@ -273,7 +284,9 @@ export class NewPublicationPage implements OnInit {
else {
const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')
console.log(date)
console.log(date);
console.log(this.folderId);
this.publication = {
DateIndex: date,
@@ -294,7 +307,7 @@ export class NewPublicationPage implements OnInit {
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
this.close();
this.toastService.successMessage("Publicação criado")
this.close();
} catch (error) {
@@ -312,7 +325,7 @@ export class NewPublicationPage implements OnInit {
this.showLoader=true;
});
}
clear() {
this.capturedImage = '';
}
@@ -352,8 +365,8 @@ export class NewPublicationPage implements OnInit {
source: CameraSource.Camera
});
console.log(image);
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
} */
}
}
@@ -196,7 +196,7 @@ export class ViewPublicationsPage implements OnInit {
component: NewPublicationPage,
componentProps: {
publicationType: publicationType,
folderId: folderId,
folderId: this.folderId,
},
cssClass: 'new-publication modal modal-desktop',
backdropDismiss: false