mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
save, work in progress!
This commit is contained in:
@@ -69,8 +69,6 @@ import {NgxImageCompressService} from 'ngx-image-compress';
|
||||
import { CustomImageCachePageRoutingModule } from './services/file/custom-image-cache/custom-image-cache-routing.module';
|
||||
import { IonicImageLoaderComponent, IonicImageLoaderModule } from 'ionic-image-loader-v5';
|
||||
|
||||
import { FileOpener } from '@ionic-native/file-opener/ngx';
|
||||
|
||||
/* import { FCM } from '@ionic-native/fcm/ngx';
|
||||
import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||
//import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
|
||||
@@ -146,7 +144,6 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||
StreamingMedia,
|
||||
PhotoViewer,
|
||||
NgxImageCompressService,
|
||||
FileOpener
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
|
||||
@@ -12,6 +12,7 @@ import { BtnModalDismissPage } from 'src/app/shared/btn-modal-dismiss/btn-modal-
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { LettersAvatarModule } from "ngx-letters-avatar";
|
||||
import { PipesModule } from 'src/app/pipes/pipes.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -21,7 +22,8 @@ import { LettersAvatarModule } from "ngx-letters-avatar";
|
||||
FontAwesomeModule,
|
||||
MessagesPageRoutingModule,
|
||||
MatMenuModule,
|
||||
LettersAvatarModule
|
||||
LettersAvatarModule,
|
||||
PipesModule,
|
||||
],
|
||||
declarations: [MessagesPage]
|
||||
})
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<ion-icon *ngIf="msg.attachments[0].image_url == null" name="download-outline"></ion-icon>
|
||||
</div>
|
||||
<div *ngIf="msg.file.type != 'application/img'">
|
||||
<div class="file">
|
||||
<div class="file" *ngIf="msg.file.type != 'aplication/audio'">
|
||||
<div (click)="docIndex(i); viewDocument(msg, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
@@ -98,11 +98,14 @@
|
||||
<ion-label class="file-title">{{file.title}}</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file" *ngIf="msg.file.type == 'aplication/audio'">
|
||||
<audio [src]="file.title_link|safehtml" class="d-flex width-100 mt-10 mb-10" controls controlsList="nodownload noplaybackrate"></audio>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file && msg.file != ''">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix' && msg.file.type != 'aplication/audio'">{{msg.displayType}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -180,18 +183,16 @@
|
||||
<button hidden (click)="startRecording()">Start Recording</button>
|
||||
<button hidden (click)="stopRecording()">Stop Recording</button>
|
||||
|
||||
<audio *ngIf="audioRecorded" controls [src]="audioRecorded">
|
||||
</audio>
|
||||
|
||||
<audio controls>
|
||||
<!-- <audio controls controlsList="nodownload noplaybackrate">
|
||||
<source src="assets/audio/Audiorecord.mp3" type="audio/ogg">
|
||||
<source src="assets/audio/Audiorecord.mp3" type="audio/mpeg">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
</audio> -->
|
||||
|
||||
<div class="width-100">
|
||||
<div class="width-100 pl-20 pr-20">
|
||||
<span *ngIf="!lastAudioRecorded">{{durationDisplay}}</span>
|
||||
<span *ngIf="lastAudioRecorded" (click)="playFile(lastAudioRecorded)">{{lastAudioRecorded}}</span>
|
||||
<audio [src]="audioRecorded" class="d-flex width-100 mt-10 mb-10" *ngIf="lastAudioRecorded" controls controlsList="nodownload noplaybackrate"></audio>
|
||||
<span hidden *ngIf="lastAudioRecorded" (click)="playFile(lastAudioRecorded)">{{lastAudioRecorded}}</span>
|
||||
</div>
|
||||
|
||||
<div class="container width-100 d-flex">
|
||||
|
||||
@@ -228,7 +228,6 @@
|
||||
justify-content: center;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
.chat-icon-options{
|
||||
|
||||
@@ -40,7 +40,7 @@ import { SearchPage } from 'src/app/pages/search/search.page';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { FileOpener } from '@ionic-native/file-opener/ngx';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
/* import {Plugins} from '@capacitor/core';
|
||||
|
||||
const { Filesystem } = Plugins; */
|
||||
@@ -88,6 +88,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
storedFileNames = [];
|
||||
lastAudioRecorded = '';
|
||||
audioRecorded:any = "";
|
||||
audioDownloaded:any = "";
|
||||
durationDisplay = '';
|
||||
duration = 0;
|
||||
@ViewChild('recordbtn', { read: ElementRef }) recordBtn: ElementRef;
|
||||
@@ -119,7 +120,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private processesService: ProcessesService,
|
||||
private storage: Storage,
|
||||
private fileToBase64Service: FileToBase64Service,
|
||||
private fileOpener: FileOpener,
|
||||
private sanitiser: DomSanitizer,
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
@@ -131,6 +132,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
};
|
||||
|
||||
console.log(this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({}));
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
this.wsChatMethodsService.openRoom(this.roomId)
|
||||
@@ -203,6 +206,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log(result);
|
||||
this.storedFileNames = result.files.reverse();
|
||||
this.lastAudioRecorded = this.storedFileNames[0];
|
||||
this.getFile(this.lastAudioRecorded);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -261,7 +265,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log(audioFile);
|
||||
const base64sound = audioFile.data;
|
||||
|
||||
//this.audioRecorded = `data:audio/aac;base64,${base64sound}`;
|
||||
this.audioRecorded = `data:audio/aac;base64,${base64sound}`;
|
||||
|
||||
console.log(this.audioRecorded);
|
||||
|
||||
@@ -269,12 +273,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
const audioRef = new Audio(`data:audio/aac;base64,${base64sound}`)
|
||||
//this.audioRecorded = audioRef;
|
||||
//console.log(audioRef);
|
||||
console.log(audioRef);
|
||||
audioRef.oncanplaythrough = () => audioRef.play();
|
||||
audioRef.load();
|
||||
|
||||
//this.getFile(fileName);
|
||||
|
||||
}
|
||||
|
||||
async getFile(fileName?:any){
|
||||
@@ -298,6 +300,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
|
||||
handlePress(id?: string) {
|
||||
this.selectedMsgId = id;
|
||||
this.showMessageOptions = true;
|
||||
@@ -425,6 +428,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
//Converting base64 to blob
|
||||
const base64 = await fetch(base64sound);
|
||||
const base64Response = await fetch(`data:audio/aac;base64,${base64sound}`);
|
||||
console.log(base64Response);
|
||||
|
||||
const blob = await base64Response.blob();
|
||||
|
||||
console.log(blob);
|
||||
@@ -434,19 +439,20 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": "audio/aac",
|
||||
"type": "aplication/audio",
|
||||
/* "guid": '', */
|
||||
},
|
||||
attachments: [{
|
||||
"title": fileName ,
|
||||
"title_link": base64Response.url,
|
||||
"title_link": `data:audio/aac;base64,${base64sound}`,
|
||||
"title_link_download": true,
|
||||
"type": "file"
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
|
||||
alert('OK')
|
||||
this.allowTyping = true;
|
||||
this.lastAudioRecorded = '';
|
||||
|
||||
}
|
||||
|
||||
@@ -498,6 +504,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
/* playSound(url?:any){
|
||||
alert('here')
|
||||
console.log(url);
|
||||
//this.audioDownloaded = this.sanitiser.bypassSecurityTrustResourceUrl(url);
|
||||
this.audioDownloaded = url;
|
||||
} */
|
||||
|
||||
docIndex(index: number) {
|
||||
this.dicIndex = index
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@ import { EventPipe } from './event.pipe';
|
||||
import { PublicationPipe } from './publication.pipe';
|
||||
import { ExpedienteTaskPipe } from './expediente-task.pipe';
|
||||
import { ParticipantsPipe } from './participants.pipe';
|
||||
import { SafehtmlPipe } from './safehtml.pipe';
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [FilterPipe, SearchDocumentPipe, CustomTaskPipe, EventPipe, PublicationPipe, ExpedienteTaskPipe, ParticipantsPipe],
|
||||
exports: [FilterPipe],
|
||||
declarations: [FilterPipe, SearchDocumentPipe, CustomTaskPipe, EventPipe, PublicationPipe, ExpedienteTaskPipe, ParticipantsPipe, SafehtmlPipe],
|
||||
exports: [FilterPipe, SafehtmlPipe],
|
||||
imports: []
|
||||
})
|
||||
export class PipesModule { }
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { SafehtmlPipe } from './safehtml.pipe';
|
||||
|
||||
describe('SafehtmlPipe', () => {
|
||||
it('create an instance', () => {
|
||||
const pipe = new SafehtmlPipe();
|
||||
expect(pipe).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
|
||||
@Pipe({
|
||||
name: 'safehtml'
|
||||
})
|
||||
export class SafehtmlPipe implements PipeTransform {
|
||||
constructor(private sanitiser: DomSanitizer){}
|
||||
|
||||
transform(html): unknown {
|
||||
return this.sanitiser.bypassSecurityTrustResourceUrl(html);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -99,29 +99,29 @@ export class RoomService {
|
||||
|
||||
let ChatMessage = _ChatMessage.fields.args[0]
|
||||
ChatMessage = this.fix_updatedAt(ChatMessage)
|
||||
|
||||
|
||||
if(!this.messagesLocalReference.includes(ChatMessage.localReference)) {
|
||||
const message = this.prepareMessage(ChatMessage)
|
||||
this.lastMessage = message
|
||||
this.calDateDuration(ChatMessage._updatedAt)
|
||||
|
||||
|
||||
if (message.t == 'r') {
|
||||
this.name = message.msg
|
||||
}
|
||||
|
||||
|
||||
if(this.isSenderIsNotMe(ChatMessage)) {
|
||||
this.NativeNotificationService.sendNotificationChat({
|
||||
message: message.msg,
|
||||
title: this.name
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.addMessageDB(ChatMessage)
|
||||
|
||||
|
||||
setTimeout(()=>{
|
||||
this.scrollDown()
|
||||
}, 50)
|
||||
}, 50)
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ export class RoomService {
|
||||
}
|
||||
|
||||
async updateMessageDB(ChatMessage, localReference) {
|
||||
if (environment.chatOffline) {
|
||||
if (environment.chatOffline) {
|
||||
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
|
||||
if(!Array.isArray(messages)) {
|
||||
messages = []
|
||||
@@ -197,14 +197,14 @@ export class RoomService {
|
||||
messages[index] = ChatMessage
|
||||
this.storage.set('chatmsg' + this.id, messages)
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async updateViewedMessage(id, userId) {
|
||||
if (environment.chatOffline) {
|
||||
if (environment.chatOffline) {
|
||||
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
|
||||
if(!Array.isArray(messages)) {
|
||||
messages = []
|
||||
@@ -212,12 +212,12 @@ export class RoomService {
|
||||
|
||||
let index;
|
||||
const find = messages.find((message, _index)=> {
|
||||
|
||||
|
||||
if(message._id == id) {
|
||||
index = _index
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
@@ -231,7 +231,7 @@ export class RoomService {
|
||||
this.storage.set('chatmsg' + this.id, messages)
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@@ -247,15 +247,15 @@ export class RoomService {
|
||||
if(!Array.isArray(messages)) {
|
||||
messages = []
|
||||
}
|
||||
|
||||
|
||||
messages.forEach((message, index) => {
|
||||
|
||||
|
||||
if(message._id == id) {
|
||||
messages.splice(index, 1)
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
this.storage.set('chatmsg' + this.id, messages).then((value) => {
|
||||
console.log('MSG SAVED ON STORAGE', value)
|
||||
});
|
||||
@@ -332,7 +332,7 @@ export class RoomService {
|
||||
if (environment.chatOffline) {
|
||||
this.messagesLocalReference.push(localReference)
|
||||
this.addMessageDB(offlineChatMessage)
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
this.scrollDown()
|
||||
}, 150)
|
||||
@@ -347,9 +347,9 @@ export class RoomService {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
* @param ChatMessage
|
||||
*
|
||||
* @param message
|
||||
* @param ChatMessage
|
||||
* @description when creating message we use offline data, then we need redefined with live data
|
||||
*/
|
||||
redefinedMessage (message: MessageService, ChatMessage) {
|
||||
@@ -497,9 +497,9 @@ export class RoomService {
|
||||
|
||||
/**
|
||||
* @description find or create message
|
||||
* @param message
|
||||
* @param save
|
||||
* @returns
|
||||
* @param message
|
||||
* @param save
|
||||
* @returns
|
||||
*/
|
||||
prepareMessage(message, save = true): MessageService {
|
||||
message = this.fix_updatedAt(message)
|
||||
@@ -515,7 +515,7 @@ export class RoomService {
|
||||
|
||||
const found = this.messages.find((MessageService) => {
|
||||
if (MessageService._id == message._id) {
|
||||
if(this.hasLoadHistory) console.log(`${MessageService._id} == ${message._id}`)
|
||||
if(this.hasLoadHistory) /* console.log(`${MessageService._id} == ${message._id}`) */
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
class AudioPlayer extends HTMLElement{
|
||||
constructor(){
|
||||
super()
|
||||
|
||||
this.attachShadow({ mode: 'open' });
|
||||
this.render();
|
||||
}
|
||||
|
||||
render(){
|
||||
this.shadowRoot.innerHTML = `
|
||||
<audio *ngIf="audioRecorded" controls src="assets/audio/Audiorecord.mp3"></audio>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
customElements.define('audio-player', AudioPlayer)
|
||||
}
|
||||
Reference in New Issue
Block a user