mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
send attachment to mobile and take picture
This commit is contained in:
@@ -5,19 +5,16 @@ import {
|
||||
ViewChild,
|
||||
ViewContainerRef,
|
||||
Output,
|
||||
NgZone,
|
||||
} from '@angular/core';
|
||||
import { ModalController, Platform } from '@ionic/angular';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
// import { ChatSystemService } from 'src/app/services/chat/chat-system.service'
|
||||
import { GroupMessagesPage } from './group-messages/group-messages.page';
|
||||
import { ContactsPage } from './messages/contacts/contacts.page';
|
||||
import { MessagesPage } from './messages/messages.page';
|
||||
import { NewGroupPage } from './new-group/new-group.page';
|
||||
import { EditGroupPage } from 'src/app/shared/chat/edit-group/edit-group.page';
|
||||
import { Observable, Subject } from "rxjs/Rx";
|
||||
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
|
||||
import { environment } from 'src/environments/environment';
|
||||
@@ -25,10 +22,8 @@ import { TimeService } from 'src/app/services/functions/time.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { DataService } from 'src/app/services/data.service';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { MessageLiveDataSourceService } from 'src/app/module/chat/data/data-source/message/message-live-data-source.service';
|
||||
import { RoomRemoteDataSourceState } from 'src/app/module/chat/data/data-source/room/room-memory-data-source';
|
||||
import { RoomListOutPutDTO } from 'src/app/module/chat/data/dto/room/roomListOutputDTO';
|
||||
import { MessageRepositoryService } from 'src/app/module/chat/data/repository/message-respository.service'
|
||||
import { RoomRepositoryService } from 'src/app/module/chat/data/repository/room-repository.service'
|
||||
import { Observable as DexieObservable } from 'Dexie';
|
||||
|
||||
@@ -117,24 +112,10 @@ export class ChatPage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
private dataService: DataService,
|
||||
private router: Router,
|
||||
// public ChatSystemService: ChatSystemService,
|
||||
public RouteService: RouteService,
|
||||
private RoomRepositoryService: RoomRepositoryService,
|
||||
private messageLiveDataSourceService: MessageLiveDataSourceService,
|
||||
) {
|
||||
|
||||
|
||||
// this.messageLiveDataSourceService.socket.messages$.subscribe(({payload, requestId, type}) => {
|
||||
// if(payload.sender == null) {
|
||||
// delete payload.sender
|
||||
// }
|
||||
|
||||
// if(type == 'createRoom') {
|
||||
// this.RoomRepositoryService.list();
|
||||
// }
|
||||
|
||||
// })
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
window.onresize = (event) => {
|
||||
if (window.innerWidth > 701) {
|
||||
@@ -319,8 +300,6 @@ export class ChatPage implements OnInit {
|
||||
|
||||
openMessagesPage(rid) {
|
||||
|
||||
console.log('rid', rid);
|
||||
|
||||
// this.chatService.refreshtoken();
|
||||
this.roomId = rid;
|
||||
|
||||
@@ -446,20 +425,6 @@ export class ChatPage implements OnInit {
|
||||
async closeNewEventComponentAndOpenChat({ roomId }) {
|
||||
this.closeAllDesktopComponents();
|
||||
|
||||
// this.ChatSystemService._group.forEach((room) => {
|
||||
// if (room.id == roomId) {
|
||||
|
||||
|
||||
// this.openGroupMessagesPage(roomId)
|
||||
// }
|
||||
// })
|
||||
|
||||
// this.ChatSystemService._dm.forEach((room) => {
|
||||
// if (room.id == roomId) {
|
||||
// this.openMessagesPage(roomId)
|
||||
// }
|
||||
// })
|
||||
|
||||
}
|
||||
|
||||
doRefresh(event) {
|
||||
|
||||
@@ -58,24 +58,45 @@
|
||||
{{ message.message }}
|
||||
</div>
|
||||
|
||||
<div *ngFor="let attachment of message.attachments">
|
||||
<div *ngIf="attachment.fileType == 1">
|
||||
<div *ngFor="let attachment of message.attachments; let i = index">
|
||||
<div *ngIf="attachment.source == MessageAttachmentFileSource.Webtrix">
|
||||
|
||||
<ion-icon src="assets/icon/webtrix.svg" class="file-icon font-25"></ion-icon>
|
||||
<ion-label>{{ attachment.fileName }}</ion-label>
|
||||
<ion-label>{{ attachment.fileName}}</ion-label>
|
||||
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'default' && attachment.type != 'webtrix' && !( msg.downloadLoader == true || msg.uploadingFile == true ) " class="icon-download" src="assets/icon/theme/default/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && attachment.type != 'webtrix' && !( msg.downloadLoader == true || msg.uploadingFile == true ) " class="icon-download" src="assets/icon/theme/gov/icons-download.svg" slot="end"></ion-icon>
|
||||
<ion-icon *ngIf="( msg.downloadLoader == true || msg.uploadingFile == true )" class="icon-download" src="assets/gif/theme/{{ThemeService.currentTheme}}/Blocks-loader.svg" slot="end"></ion-icon> -->
|
||||
|
||||
</div>
|
||||
|
||||
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Image">
|
||||
<img src="{{attachment.safeFile}}">
|
||||
</div>
|
||||
|
||||
<div *ngIf="attachment.fileType == 2">
|
||||
<img [src]="attachment.safeFile">
|
||||
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Audio">
|
||||
<audio [src]="attachment.safeFile|safehtml" preload="metadata" class="flex-grow-1" controls controlsList="nodownload noplaybackrate"></audio>
|
||||
</div>
|
||||
|
||||
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Doc">
|
||||
<fa-icon *ngIf="attachment.mimeType == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="attachment.mimeType == 'application/word'" icon="file-word" class="word-icon">
|
||||
</fa-icon>
|
||||
<fa-icon *ngIf="attachment.mimeType == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<fa-icon
|
||||
*ngIf="attachment.mimeType == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'"
|
||||
icon="file-word" class="excel-icon"></fa-icon>
|
||||
<ion-icon *ngIf="attachment.mimeType == 'application/webtrix'" src="assets/icon/webtrix.svg">
|
||||
</ion-icon>
|
||||
<ion-icon *ngIf="attachment.mimeType == 'application/meeting'" src="assets/icon/webtrix.svg">
|
||||
</ion-icon>
|
||||
|
||||
<ion-label>{{ attachment.fileName}}</ion-label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
||||
@@ -110,9 +131,6 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!--
|
||||
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
|
||||
<ion-fab-button *ngIf="scrollToBottomBtn" color="light" size="small">
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { Router } from '@angular/router'
|
||||
import { GestureController, ModalController, NavParams, PopoverController, Platform, AlertController } from '@ionic/angular';
|
||||
import { GestureController, ModalController, NavParams, PopoverController, Platform } from '@ionic/angular';
|
||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||
import { ViewDocumentSecondOptionsPage} from 'src/app/modals/view-document-second-options/view-document-second-options.page';
|
||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
|
||||
import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page';
|
||||
@@ -15,22 +14,19 @@ import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
|
||||
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
|
||||
import { VoiceRecorder, RecordingData, GenericResponse } from 'capacitor-voice-recorder';
|
||||
import { VoiceRecorder, GenericResponse } from 'capacitor-voice-recorder';
|
||||
import { Haptics, ImpactStyle } from '@capacitor/haptics';
|
||||
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||
import { FileType } from 'src/app/models/fileType';
|
||||
import { SearchPage } from 'src/app/pages/search/search.page';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { Camera, CameraResultType } from '@capacitor/camera';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||
import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
||||
import { NewEventPage } from '../../agenda/new-event/new-event.page';
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
// import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { sanitize } from "sanitize-filename-ts";
|
||||
import { FilePicker } from '@capawesome/capacitor-file-picker';
|
||||
@@ -52,6 +48,7 @@ import { MessageAttachmentFileType, MessageAttachmentSource } from 'src/app/modu
|
||||
import { compressImageBase64 } from 'src/app/utils/imageCompressore';
|
||||
import { FilePickerService } from 'src/app/infra/file-picker/file-picker.service'
|
||||
import { FilePickerMobileService } from 'src/app/infra/file-picker/mobile/file-picker-mobile.service'
|
||||
import { RecordingData } from 'capacitor-voice-recorder';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -138,6 +135,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
messageSendSubject: Subscription
|
||||
messages1: {[key: string]: MessageEntity[]} = {}
|
||||
|
||||
MessageAttachmentFileType = MessageAttachmentFileType
|
||||
MessageAttachmentFileSource = MessageAttachmentSource
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
private modalController: ModalController,
|
||||
@@ -221,11 +221,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
async getMessages() {
|
||||
|
||||
|
||||
// dont remove this line
|
||||
this.messages1[this.roomId] = []
|
||||
let messages = await this.messageRepositoryService.getItems(this.roomId)
|
||||
|
||||
|
||||
this.messages1[this.roomId] = []
|
||||
this.messages1[this.roomId] = messages
|
||||
this.loadAttachment()
|
||||
@@ -321,7 +321,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.messageReceiveSubject?.unsubscribe();
|
||||
this.messageReceiveSubject = this.chatServiceService.listenToIncomingMessage(this.roomId).subscribe(async (message) => {
|
||||
this.messages1[this.roomId].push(message as MessageEntity)
|
||||
|
||||
|
||||
if(message.hasAttachment) {
|
||||
|
||||
const result = await this.chatServiceService.getMessageAttachmentByMessageId({
|
||||
@@ -404,7 +404,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async loadFiles() {
|
||||
|
||||
this.storage.get('fileName').then((fileName) => {
|
||||
@@ -594,6 +594,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
this.chatServiceService.sendMessage(message)
|
||||
this.messages1[this.roomId].push(message)
|
||||
|
||||
this.textField = ''
|
||||
}
|
||||
@@ -615,7 +616,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
async sendAudio(fileName) {
|
||||
const roomId = this.roomId
|
||||
let audioFile;
|
||||
this.storage.get('recordData').then(async (recordData) => {
|
||||
this.storage.get('recordData').then(async (recordData:RecordingData) => {
|
||||
|
||||
audioFile = recordData;
|
||||
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
||||
@@ -625,6 +626,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||
}
|
||||
|
||||
const audioMimeType: string = recordData.value.mimeType
|
||||
//Converting base64 to blob
|
||||
const encodedData = btoa(this.audioRecorded);
|
||||
|
||||
@@ -642,9 +644,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
file: encodedData,
|
||||
fileName: "audio",
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Audio
|
||||
fileType: MessageAttachmentFileType.Audio,
|
||||
mimeType: audioMimeType
|
||||
}]
|
||||
|
||||
this.messages1[this.roomId].push(message)
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
|
||||
@@ -794,50 +798,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
await modal.present();
|
||||
}
|
||||
|
||||
async bookMeeting() {
|
||||
// let attendees = this.ChatSystemService.getDmRoom(this.roomId).members.map((val) => {
|
||||
// return {
|
||||
// Name: val.name,
|
||||
// EmailAddress: val.username + "@" + environment.domain,
|
||||
// IsRequired: "true",
|
||||
// }
|
||||
// });
|
||||
|
||||
this.popoverController.dismiss();
|
||||
if (window.innerWidth <= 1024) {
|
||||
const modal = await this.modalController.create({
|
||||
component: NewEventPage,
|
||||
componentProps: {
|
||||
// attendees: attendees,
|
||||
roomId: this.roomId
|
||||
},
|
||||
cssClass: 'modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
modal.onDidDismiss().then((data) => {
|
||||
if (data?.data && data.data.id) {
|
||||
|
||||
// const roomId = this.roomId
|
||||
|
||||
// this.ChatSystemService.getDmRoom(roomId).send({
|
||||
// file: {
|
||||
// "type": "application/meeting",
|
||||
// "subject": data.data.Subject,
|
||||
// "start_date": data.data.StartDate,
|
||||
// "end_date": data.data.EndDate,
|
||||
// "venue": data.data.venue,
|
||||
// "id": data.data.id,
|
||||
// "calendarId": data.data.CalendarId
|
||||
// },
|
||||
// temporaryData: {}
|
||||
// })
|
||||
}
|
||||
});
|
||||
|
||||
await modal.present();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async takePictureMobile() {
|
||||
@@ -877,6 +837,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
mimeType: 'image/'+picture.value.format
|
||||
}]
|
||||
|
||||
this.messages1[this.roomId].push(message)
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
}
|
||||
@@ -950,6 +911,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
docId: res.data.selected.Id,
|
||||
}]
|
||||
|
||||
this.messages1[this.roomId].push(message)
|
||||
this.chatServiceService.sendMessage(message)
|
||||
this.textField = ''
|
||||
|
||||
@@ -991,13 +953,17 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
file: compressedImage.value,
|
||||
fileName: "foto",
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Image
|
||||
fileType: MessageAttachmentFileType.Image,
|
||||
mimeType: 'image/'+file.value.format
|
||||
}]
|
||||
|
||||
this.messages1[this.roomId].push(message)
|
||||
this.chatServiceService.sendMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log(file.error)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1109,13 +1075,14 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
fileType: MessageAttachmentFileType.Doc
|
||||
}]
|
||||
|
||||
this.messages1[this.roomId].push(message)
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
const file: any = await this.fileService.getFileFromDevice(types);
|
||||
const file = await this.fileService.getFileFromDevice(types);
|
||||
console.log(file)
|
||||
|
||||
|
||||
@@ -1147,11 +1114,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
message.attachments = [{
|
||||
file: encodedData,
|
||||
fileName: "doc",
|
||||
fileName: file.name,
|
||||
source: MessageAttachmentSource.Device,
|
||||
fileType: MessageAttachmentFileType.Doc
|
||||
fileType: MessageAttachmentFileType.Doc,
|
||||
mimeType: file.type
|
||||
}]
|
||||
|
||||
this.messages1[this.roomId].push(message)
|
||||
this.chatServiceService.sendMessage(message)
|
||||
|
||||
} else {
|
||||
@@ -1192,10 +1161,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
await popover.present();
|
||||
popover.onDidDismiss().then(async (res) => {
|
||||
|
||||
if (res['data'] == 'meeting') {
|
||||
this.bookMeeting();
|
||||
}
|
||||
else if (res['data'] == 'take-picture') {
|
||||
if (res['data'] == 'take-picture') {
|
||||
this.takePictureMobile()
|
||||
}
|
||||
else if (res['data'] == 'add-picture') {
|
||||
|
||||
Reference in New Issue
Block a user