This commit is contained in:
Peter Maquiran
2022-02-16 15:55:29 +01:00
15 changed files with 100 additions and 227 deletions
+3 -3
View File
@@ -235,7 +235,7 @@ export class ChatPage implements OnInit {
this.idSelected = '';
this.groupRoomId = data;
this.closeAllDesktopComponents();
if (window.innerWidth < 801) {
if (window.innerWidth < 701) {
}
else {
@@ -270,7 +270,7 @@ export class ChatPage implements OnInit {
}
openNewGroupPage() {
this.idSelected = '';
if (window.innerWidth < 801) {
if (window.innerWidth < 701) {
this.newGroup();
}
else {
@@ -280,7 +280,7 @@ export class ChatPage implements OnInit {
}
openEditGroupPage(rid) {
if (window.innerWidth < 801) {
if (window.innerWidth < 701) {
this.editGroup(rid);
}
else {
@@ -820,7 +820,7 @@ downloadFileMsg(msg) {
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -828,7 +828,7 @@ async openPreview(msg) {
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
+10 -10
View File
@@ -108,7 +108,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private sqlservice: SqliteService,
public wsChatMethodsService: WsChatMethodsService,
private AttachmentsService: AttachmentsService,
private CameraService: CameraService,
private processesService: ProcessesService,
private storage: Storage,
@@ -127,7 +127,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
this.wsChatMethodsService.openRoom(this.roomId)
setTimeout(()=>{
this.scrollToBottomClicked()
}, 150)
@@ -518,13 +518,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
async takePicture() {
const roomId = this.roomId
const image = await this.CameraService.takePicture();
await this.fileService.saveImage(image)
const lastphoto: any = await this.fileService.loadFiles();
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
const base64 = await fetch(capturedImage);
const blob = await base64.blob();
const formData = new FormData();
@@ -550,11 +550,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
async addImageMobile() {
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
}
async addImage() {
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
}
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
}
@@ -618,7 +618,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
@@ -647,7 +647,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
const formData = new FormData();
formData.append("blobFile", file);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
@@ -809,7 +809,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -817,7 +817,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
@@ -87,62 +87,6 @@ export class NewGroupPage implements OnInit {
this.wsChatMethodsService.subscribeToRoomUpdate(res.result.rid, res.result);
//this.addGroupMessage.emit(res.result.rid);
/*
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
console.log(res['group']);
//this.addGroupMessage.emit(res['group']._id);
if(this.thedate){
let countDownBody = {
"roomId": res['group']._id,
"customFields":{"countDownDate":this.thedate}
}
this.chatService.setGroupCustomFields(countDownBody).subscribe(res=>{
console.log(res);
});
}
this.isGroupCreated = true;
this.addContacts(res['group']);
if(this.documents.length > 0){
//If there is documents add
this.documents.forEach(async document => {
let url = await this.processesService.GetDocumentUrl(document.DocId, document.ApplicationId).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
let body = {
"message":
{
"rid": res['group']._id,
"msg": "",
"attachments": [{
"title": document.Assunto,
"description": document.DocTypeDesc,
"title_link": url_no_options,
"title_link_download": true,
//"thumb_url": "assets/images/webtrix-logo.png",
"message_link": url_no_options,
"type": "webtrix"
}],
"file":{
"name": document.Assunto,
"type": "application/webtrix",
"ApplicationId": document.ApplicationType,
"DocId": document.Id,
"Assunto": document.Assunto,
}
}
}
this.chatService.sendMessage(body).toPromise();
});
}
}); */
}
async addContacts(room){
@@ -132,22 +132,21 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = true;
const folderId = this.folderId
this.getFromDB()
this.publications.GetPublicationsImages(this.folderId).subscribe(res => {
console.log('publications ids', res)
this.publicationList = new Array();
for(let i = 0; i < res.length; i++) {
/* for(let i = 0; i < res.length; i++) {
this.publications.GetPublicationById(res[i]).subscribe(ress => {
console.log('publications by ids', ress)
let item: Publication = this.publicationPipe.itemList(ress)
console.log('publications by ids 2', item)
this.publicationList.push(item);
})
}
} */
/* res.forEach(element => {
res.forEach(element => {
console.log('publications elements', element)
this.publications.GetPublicationById(element).subscribe(ress => {
console.log('publications by ids', ress)
@@ -156,7 +155,7 @@ export class ViewPublicationsPage implements OnInit {
this.publicationList.push(item);
})
}); */
});
console.log('PUBLICATIONS IMAGEs',this.publicationList)
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
console.log('PUBLICATIONS IMAGEs',this.publicationList)
@@ -175,6 +174,8 @@ export class ViewPublicationsPage implements OnInit {
this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList; */
}, (error) => {
this.getFromDB()
});
}
+1 -1
View File
@@ -83,8 +83,8 @@ export class ChatService {
params: params
}
return this.http.get(environment.apiChatUrl+'rooms.info', opts);
}
customsRooms(params:any){
let opts = {
headers: this.headers,
@@ -44,7 +44,7 @@ export class WsChatMethodsService {
private NfService: NfService,
private changeProfileService: ChangeProfileService,
) {
this.loadChat()
this.WsChatService.registerCallback({
@@ -63,7 +63,7 @@ export class WsChatMethodsService {
for (const id in this.dm) {
this.dm[id].hasLoadHistory = false
}
for (const id in this.group) {
this.group[id].hasLoadHistory = false
}
@@ -79,7 +79,7 @@ export class WsChatMethodsService {
this.storage.remove('Rooms');
})
// this.WsChatService.registerCallback({
// type:'Onmessage',
// funx:(message) => {
@@ -97,7 +97,7 @@ export class WsChatMethodsService {
// }
// } else if(message.msg =='changed' && message.collection == "stream-notify-room") {
// if(message.fields.eventName.includes('deleteMessage')) {
// // delete message
// // delete message
// const DeletedMessageId = message.fields.args[0]._id;
// setTimeout(()=>{
@@ -131,7 +131,7 @@ export class WsChatMethodsService {
clearChat() {
this.dm = {}
this.group = {}
this.group = {}
this._dm = []
this._group = []
@@ -139,7 +139,7 @@ export class WsChatMethodsService {
this.dmCount = 0;
this.groupCount = 0;
this.currentRoom = null
this.users = []
}
@@ -154,11 +154,11 @@ export class WsChatMethodsService {
if(this.getDmRoom(roomId)) {
this.currentRoom = this.getDmRoom(roomId)
} else if(this.getGroupRoom(roomId)) {
this.currentRoom = this.getGroupRoom(roomId)
this.currentRoom = this.getGroupRoom(roomId)
}
this.currentRoom.open()
}
@@ -171,7 +171,7 @@ export class WsChatMethodsService {
await rooms.result.update.forEach( async (roomData: room) => {
await this.prepareRoom(roomData);
});
}
} catch(e){}
@@ -271,7 +271,7 @@ export class WsChatMethodsService {
lastMessage: this.getRoomLastMessage(roomData),
_updatedAt: new Date(roomData._updatedAt['$date'])
}
let roomId = this.getRoomId(roomData)
// create room
@@ -284,19 +284,20 @@ export class WsChatMethodsService {
room.sortRoomList = this.sortRoomList
// create individual room
if(this.isIndividual(roomData)) {
this.dm[roomId] = room
this._dm.push(room)
this.dmCount++
} else {
// create group room
this.group[roomId] = room
this._group.push(room)
this.groupCount++
}
} else {
// in this case room is already present, therefor it will only be necessary,
@@ -379,12 +380,29 @@ export class WsChatMethodsService {
return this.WsChatService.leaveRoom(id);
}
async hideRoom(id) {
this._dm.forEach((md, index)=>{
if(md.id == id) {
this._dm.splice(index, 1)
delete this.dm[id]
}
});
this._group.forEach((group, index)=>{
if(group.id == id) {
this._group.splice(index, 1)
delete this.group[id]
}
})
}
hidingRoom(id?) {
return this.WsChatService.hidingRoom(id).then(()=>{
// this.hideRoom(id)
})
return this.WsChatService.hidingRoom(id);
}
addRoomOwner(roomid, userId){
+4 -2
View File
@@ -277,6 +277,8 @@ export class WsChatService {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId ) { // same request send
resolve(message)
console.log(message);
return true
}
}})
@@ -659,7 +661,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
setTimeout(()=>{
this.ws.wsMsgQueue()
}, 10)
if(this.wsReconnect >= 1) {
for (const [key, value] of Object.entries(this.wsCallbacks)) {
if(value.type== 'reConnect') {
@@ -702,7 +704,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
} else {
let messageStr = JSON.stringify(message)
// console.log('messageStr', messageStr)
this.socket.send(messageStr)
}
return requestId
@@ -367,9 +367,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
console.log(res);
if (res.data == 'leave') {
this.getRoomInfo();
this.wsChatMethodsService.hidingRoom(this.roomId);
this.closeAllDesktopComponents.emit();
this.showEmptyContainer.emit();
this.wsChatMethodsService.hidingRoom(this.roomId);
}
else if (res.data == 'delete') {
this.closeAllDesktopComponents.emit();
@@ -559,7 +559,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getGroupRoom(roomId).send({
file: {
"type": "application/img",
@@ -676,7 +676,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getGroupRoom(roomId).send({
file: {
"type": "application/img",
@@ -833,7 +833,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -841,7 +841,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
+15 -14
View File
@@ -101,7 +101,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
public wsChatMethodsService: WsChatMethodsService,
public WsChatService: WsChatService,
private AttachmentsService: AttachmentsService,
private CameraService: CameraService,
private processesService: ProcessesService,
private fileToBase64Service: FileToBase64Service,
@@ -458,7 +458,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
@@ -477,7 +477,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async takePicture() {
const roomId = this.roomId
const image = await this.CameraService.takePicture();
await this.fileService.saveImage(image)
const lastphoto: any = await this.fileService.loadFiles();
@@ -505,11 +505,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
})
}
async addImage() {
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
}
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
}
@@ -572,7 +572,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
@@ -592,7 +592,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async addFileToChat(types: typeof FileType[] ) {
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
@@ -602,10 +602,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}) */
const blob = new Blob([file],{type: file.type})
console.log('Add file', blob)
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": file.type,
@@ -623,7 +623,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
bookMeeting() {
let data = {
@@ -678,7 +678,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
await modal.present();
modal.onDidDismiss().then( async (res) => {
console.log(res['data']);
if (res['data'] == 'meeting') {
//this.closeAllDesktopComponents.emit();
@@ -706,7 +706,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
else if (res['data'] == 'documentoGestaoDocumental') {
this.addFileWebtrix()
this.showLoader = false;
}
@@ -755,8 +755,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
async openPreview(msg) {
console.log(msg);
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -764,7 +765,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
@@ -113,64 +113,6 @@ export class NewGroupPage implements OnInit{
this.wsChatMethodsService.subscribeToRoomUpdate(res.result.rid, res.result);
this.addGroupMessage.emit(res.result.rid);
/*
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
console.log(res['group']);
this.addGroupMessage.emit(res['group']._id); */
/* this.addGroupMessage.emit(res['group']._id);
if(this.thedate){
let countDownBody = {
"roomId": res['group']._id,
"customFields":{"countDownDate":this.thedate}
}
this.chatService.setGroupCustomFields(countDownBody).subscribe(res=>{
console.log(res);
});
}
if(this.documents.length > 0){
//If there is documents add
this.documents.forEach(async document => {
let url = await this.processesService.GetDocumentUrl(document.DocId, document.ApplicationId).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
let body = {
"message":
{
"rid": res['group']._id,
"msg": "",
"attachments": [{
"title": document.Assunto,
"description": document.DocTypeDesc,
"title_link": url_no_options,
"title_link_download": true,
//"thumb_url": "assets/images/webtrix-logo.png",
"message_link": url_no_options,
"type": "webtrix"
}],
"file":{
"name": document.Assunto,
"type": "application/webtrix",
"ApplicationId": document.ApplicationType,
"DocId": document.Id,
"Assunto": document.Assunto,
}
}
}
this.chatService.sendMessage(body).toPromise();
});
} */
//});
}
async addContacts(){
@@ -35,7 +35,7 @@ export class ChatPopoverPage implements OnInit {
}
close(action:any){
if( window.innerWidth <= 701){
if( window.innerWidth < 701){
this.popoverController.dismiss(action);
this.modalController.dismiss(action);
}
@@ -50,7 +50,7 @@ export class ChatPopoverPage implements OnInit {
async setRoomOwner(){
let classs;
if (window.innerWidth <= 800) {
if (window.innerWidth < 701) {
classs = 'modal modal-desktop'
} else {
classs = 'centered-rounded-modal'
@@ -68,6 +68,7 @@ export class ChatPopoverPage implements OnInit {
modal.onDidDismiss().then((res)=>{
if(res.data == 'success'){
this.leaveGroup();
//this.wsChatMethodsService.hidingRoom(this.roomId);
}
});
}
@@ -94,65 +94,26 @@ export class NewPublicationPage implements OnInit {
const capturedImage = await Camera.getPhoto({
quality: 90,
// allowEditing: true,
resultType: CameraResultType.Uri,
resultType: CameraResultType.Base64,
source: CameraSource.Camera
});
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.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
this.capturedImageTitle = capturedImage.path;
//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);
});
async laodPicture() {
const capturedImage = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Photos,
quality: 90,
width: 1080,
height: 720,
resultType: CameraResultType.Base64,
source: CameraSource.Photos
});
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.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
this.capturedImageTitle = capturedImage.path;
}
/* laodPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
const imageData = await this.fileToBase64Service.convert(file)
this.capturedImage = imageData;
this.capturedImageTitle = file.name
};
} */
runValidation() {
this.validateFrom = true
@@ -41,7 +41,7 @@
<div class="main-container px-20">
<ion-list>
<div class="post-item d-md-block mb-10 cursor-pointer"
*ngFor="let publication of getpublication"
*ngFor="let publication of publicationList"
(click)="viewPublicationDetail(publication.DocumentId)">
<div *ngIf="publication.FileBase64.length > 30" class="mb-10 post-img width-md-100">
<img src="{{publication.FileBase64}}" alt="image">
@@ -53,7 +53,7 @@ export class ViewPublicationsPage implements OnInit {
this.folderId = this.folderId['ProcessId']
}
this.getPublications();
this.getPublicationsIds();
this.getPublicationDetail();
window['app-view-publications-page-doRefresh'] = this.doRefresh
@@ -67,15 +67,16 @@ export class ViewPublicationsPage implements OnInit {
console.log('change view to ',this.folderId)
//setTimeout(()=>{
this.getPublications();
this.getPublicationDetail();
this.getPublicationsIds();
//}, 100)
}
doRefresh =(event) => {
this.getPublications();
this.getPublicationsIds();
setTimeout(() => {
this.getPublicationDetail();
@@ -97,22 +98,22 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = true;
const folderId = this.folderId
this.getFromDB()
//this.getFromDB()
this.publications.GetPublicationsImages(this.folderId).subscribe(res => {
console.log('publications ids', res)
this.publicationList = new Array();
for(let i = 0; i < res.length; i++) {
/* for(let i = 0; i < res.length; i++) {
this.publications.GetPublicationById(res[i]).subscribe(ress => {
console.log('publications by ids', ress)
let item: Publication = this.publicationPipe.itemList(ress)
console.log('publications by ids 2', item)
this.publicationList.push(item);
})
}
} */
/* res.forEach(element => {
res.forEach(element => {
console.log('publications elements', element)
this.publications.GetPublicationById(element).subscribe(ress => {
console.log('publications by ids', ress)
@@ -121,7 +122,7 @@ export class ViewPublicationsPage implements OnInit {
this.publicationList.push(item);
})
}); */
});
console.log('PUBLICATIONS IMAGEs',this.publicationList)
this.storage.remove('view_publications');
this.storage.set('view_publications', this.publicationList);
@@ -129,6 +130,8 @@ export class ViewPublicationsPage implements OnInit {
this.getpublication = this.publicationList;
this.showLoader = false;
},() => {
this.getFromDB();
});
}
@@ -142,7 +145,7 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = true;
const folderId = this.folderId
this.publicationList = new Array();
this.getFromDB();
//this.getFromDB();
this.publications.GetPublications(folderId).subscribe(async res=> {
res.forEach(element => {