mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Git pull made with camera and file system chnages
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user