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