diff --git a/android/.idea/misc.xml b/android/.idea/misc.xml index 6b486df50..95e233687 100644 --- a/android/.idea/misc.xml +++ b/android/.idea/misc.xml @@ -10,6 +10,7 @@ + diff --git a/android/app/src/main/assets/capacitor.config.json b/android/app/src/main/assets/capacitor.config.json index 2399c4927..a8c4fab83 100644 --- a/android/app/src/main/assets/capacitor.config.json +++ b/android/app/src/main/assets/capacitor.config.json @@ -16,5 +16,8 @@ "sound" ] } + }, + "server": { + "url": "http://192.168.0.38:8101" } } diff --git a/package-lock.json b/package-lock.json index 3c9b825e8..f058d9db7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3397,18 +3397,18 @@ } }, "@ionic/angular": { - "version": "5.8.4", - "resolved": "https://registry.npmjs.org/@ionic/angular/-/angular-5.8.4.tgz", - "integrity": "sha512-pvy7qOTVih3mqcyIV6C3BK8seeZOEoanRFw+Z5m+soXDcvgrouHBBAKzURu2RUx8uDZqlX38Pkn89ontvqIZUg==", + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/@ionic/angular/-/angular-5.9.3.tgz", + "integrity": "sha512-0j4JZeGHpRvaTH0iyLTiUc4TF01bGVmk0zHZA7qS/OpS/WnGRHYNpVX/F75oODfckNvAa9uacoIMOTu54Cpx3w==", "requires": { - "@ionic/core": "5.8.4", + "@ionic/core": "5.9.3", "tslib": "^1.9.3" }, "dependencies": { "@ionic/core": { - "version": "5.8.4", - "resolved": "https://registry.npmjs.org/@ionic/core/-/core-5.8.4.tgz", - "integrity": "sha512-ioaH7wXAtexcpk23III0KArjSXStkpPrpZ5BCNkyter3EbOmDVd8XIXRcT86zRG68rbGI7Pd9GrugxeaDyMk/g==", + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/@ionic/core/-/core-5.9.3.tgz", + "integrity": "sha512-WM50vVxAAw+MQYqWXKUK4usBgkr7iQ9UWSb6t59mG4ZSy/fPAb7ZIdAjxY0U5i1ykk6A7Ur4B9ZJMpC/a7nnug==", "requires": { "@stencil/core": "^2.4.0", "ionicons": "^5.5.3", diff --git a/package.json b/package.json index 3ea0653a1..563c6bba6 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "@ionic-native/status-bar": "^5.0.0", "@ionic-native/streaming-media": "^5.36.0", "@ionic-native/wheel-selector": "^5.31.1", - "@ionic/angular": "^5.8.4", + "@ionic/angular": "^5.9.3", "@ionic/core": "^5.8.1", "@ionic/pwa-elements": "^3.0.2", "@ionic/storage": "^2.3.1", diff --git a/src/app/models/user.model.ts b/src/app/models/user.model.ts index 24f420637..a0e0855e8 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -10,6 +10,13 @@ export class LoginUserRespose { BasicAuthKey: string; UserId: number; Authorization: string; + ChatData: { + status: string, + data: { + userId: string, + authToken: string + } + } Email: string FullName: string OwnerCalendars: { @@ -38,6 +45,13 @@ export class UserSession { BasicAuthKey: string; UserId: number; Authorization: string; + ChatData: { + status: string, + data: { + userId: string, + authToken: string + } + } Email: string FullName: string ManagerName: string diff --git a/src/app/pages/chat/messages/messages.module.ts b/src/app/pages/chat/messages/messages.module.ts index 83d0d168c..631a468c8 100644 --- a/src/app/pages/chat/messages/messages.module.ts +++ b/src/app/pages/chat/messages/messages.module.ts @@ -23,7 +23,7 @@ import { PipesModule } from 'src/app/pipes/pipes.module'; MessagesPageRoutingModule, MatMenuModule, LettersAvatarModule, - PipesModule, + PipesModule ], declarations: [MessagesPage] }) diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html index d34d99f9a..7468cfd9c 100644 --- a/src/app/pages/chat/messages/messages.page.html +++ b/src/app/pages/chat/messages/messages.page.html @@ -57,6 +57,10 @@ {{msg.duration}}
+ + {{msg.msg}} + {{msg.msg}} + diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 2d2dde16f..00902e197 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -929,9 +929,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { downloadFileMsg(msg: MessageService) { - this.downloadLoader = msg.downloadLoader; msg.downloadFileMsg(); - this.downloadLoader = msg.downloadLoader; } b64toBlob(b64Data, contentType) { diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 751c3cb26..8cfd9d7d7 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -112,10 +112,10 @@ export class LoginPage implements OnInit { console.log(this.p.userPermission(this.p.permissionList.Chat.access)); - if(this.p.userPermission(this.p.permissionList.Chat.access)){ - await this.authService.loginChat(); + /* if(this.p.userPermission(this.p.permissionList.Chat.access)){*/ + await this.authService.loginChat(attempt.ChatData.data); await this.authService.loginToChatWs(); - } + //} this.getToken(); SessionStore.setInativity(true); @@ -132,10 +132,11 @@ export class LoginPage implements OnInit { this.changeProfileService.run(); - if(this.p.userPermission(this.p.permissionList.Chat.access)){ - await this.authService.loginChat(); + console.log(attempt.ChatData) + /* if(this.p.userPermission(this.p.permissionList.Chat.access)){*/ + await this.authService.loginChat(attempt.ChatData.data); await this.authService.loginToChatWs(); - } + //} this.getToken(); diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 3cebb8fc3..30e60c3ff 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -94,6 +94,10 @@ export class AuthService { SetSession(response: LoginUserRespose, user:UserForm) { const session: UserSession = Object.assign(SessionStore.user, response) + console.log('SETSESSION', response, user) + console.log('SETSESSION 2', session) + + if (response) { if( session.RoleID == 100000014) { session.Profile = 'PR' @@ -141,9 +145,13 @@ export class AuthService { //Login to rocketChat server2 //user: UserForm - async loginChat() { + async loginChat(responseChat = this.ValidatedUserChat) { - const expirationMinutes = 30; + this.ValidatedUserChat = responseChat; + localStorage.setItem('userChat', JSON.stringify(responseChat)); + this.storageService.store(AuthConnstants.AUTH, responseChat); + + /* const expirationMinutes = 30; let date = new Date().getTime(); let expirationDate = new Date(new Date().getTime() + expirationMinutes*60*1000); @@ -155,7 +163,7 @@ export class AuthService { let responseChat = await this.httpService.post('login', postData).toPromise(); if(responseChat) { - + console.log() this.ValidatedUserChat = responseChat; localStorage.setItem('userChat', JSON.stringify(responseChat)); this.storageService.store(AuthConnstants.AUTH, responseChat); @@ -165,20 +173,21 @@ export class AuthService { this.presentAlert('Network error'); } - this.autoLoginChat(expirationDate.getTime() - date); + this.autoLoginChat(expirationDate.getTime() - date); */ } async autoLoginChat(expirationDate:number) { - setTimeout(()=>{ - this.loginChat(); - }, expirationDate) + /* setTimeout(()=>{ + this.loginChat(this.ValidatedUserChat); + }, expirationDate) */ } loginToChatWs() { setTimeout(()=>{ - + console.log('loginToChatWs') this.WsChatService.connect(); this.WsChatService.login().then((message: any) => { + console.log('loginToChatWs',message) SessionStore.user.RochetChatUserId = message.result.id SessionStore.save() diff --git a/src/app/services/chat.service.ts b/src/app/services/chat.service.ts index 5be562fd6..ccbabdccf 100644 --- a/src/app/services/chat.service.ts +++ b/src/app/services/chat.service.ts @@ -38,8 +38,9 @@ export class ChatService { if(this.p.userPermission(this.p.permissionList.Chat.access)) { - this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId); - this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken); + console.log(this.loggedUserChat) + this.headers = this.headers.set('X-User-Id', this.loggedUserChat.userId); + this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat.authToken); this.options = { headers: this.headers, }; diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 5d896da90..74e846ae0 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -182,11 +182,15 @@ export class MessageService { } async sendRequest(params) { - - if(params?.attachments[0]?.image_url) { - delete params?.attachments[0]?.image_url +console.log(params) + if(params?.attachments) { + if(params?.attachments[0]?.image_url) { + delete params?.attachments[0]?.image_url + } } + + if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) { diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index 6d8ae3d30..061f68eb6 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -21,6 +21,7 @@ import { ChatMethodsService } from './chat-methods.service' import { AESEncrypt } from '../aesencrypt.service' import { AttachmentsService } from 'src/app/services/attachments.service'; import { NetworkServiceService} from 'src/app/services/network-service.service'; +import { ro } from 'date-fns/locale'; @Injectable({ providedIn: 'root' @@ -171,6 +172,7 @@ export class WsChatMethodsService { async getAllRooms () { this.loadingWholeList = true const rooms = await this.WsChatService.getRooms(); + console.log('get all rooms', rooms) await this.storage.remove('Rooms'); await rooms.result.update.forEach( async (roomData: room, index) => { diff --git a/src/app/services/chat/ws-chat.service.ts b/src/app/services/chat/ws-chat.service.ts index 98ac50c5c..7dc07f82c 100644 --- a/src/app/services/chat/ws-chat.service.ts +++ b/src/app/services/chat/ws-chat.service.ts @@ -30,7 +30,6 @@ export class WsChatService { version: "1", support: ["1"] } - this.ws.send({message, loginRequired: false, requestId: 'connectMessage'}) this.ws.send({message:{msg:"pong"}, loginRequired: false, requestId: 'connectPong'}) @@ -54,17 +53,15 @@ export class WsChatService { }) } - const requestId = uuidv4() - - console.log('chat==', SessionStore.user.RochetChatUser, SessionStore.user.Password); - + const requestId = uuidv4() + console.log('Login true', SessionStore.user) const message = { msg: "method", method: "login", id: requestId, params: [ { - user: { username: SessionStore.user.RochetChatUser }, + user: { email: SessionStore.user.Email }, password: SessionStore.user.Password } ] @@ -73,9 +70,12 @@ export class WsChatService { return new Promise((resolve, reject) => { + console.log('MESSAGE:ID', requestId) this.ws.registerCallback({type:'Onmessage', funx:(message)=>{ + console.log('MESSAGE:ID', message) if(message.id == requestId ) { // same request send - + console.log('MESSAGE:ID', message.id, requestId) + console.log('LOGIN WS',message) if(message.result) { if(message.result.token) { @@ -87,9 +87,11 @@ export class WsChatService { }, 10) resolve(message) + console.log('LOGIN WS',message) } } else { this.isLogin = false + console.log('Register FAIl', message) reject(message) } @@ -104,8 +106,8 @@ export class WsChatService { getRooms(roomOlder = 1480377601) { - const requestId = uuidv4() - + //const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg": "method", "method": "rooms/get", @@ -119,6 +121,7 @@ export class WsChatService { this.ws.registerCallback({type:'Onmessage', funx:(message)=>{ if(message.id == requestId) { // same request send resolve(message) + console.log('getRooms', message) return true } }}) @@ -127,7 +130,8 @@ export class WsChatService { readMessage(roomId) { - const requestId = uuidv4() + //const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg":"method", @@ -151,7 +155,8 @@ export class WsChatService { getUserOfRoom(roomId) { - const requestId = uuidv4() + //const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg": "method", @@ -186,6 +191,7 @@ export class WsChatService { // send message to room send({roomId, msg, attachments = null, file = null, localReference = null}) { + //const requestId = uuidv4() const requestId = uuidv4() var message = { msg: "method", @@ -216,6 +222,7 @@ export class WsChatService { updateMessage(messageObject) { + //const requestId = uuidv4() const requestId = uuidv4() var message = { msg: "method", @@ -239,7 +246,7 @@ export class WsChatService { leaveRoom(roomId) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { msg: "method", @@ -264,7 +271,7 @@ export class WsChatService { addRoomOwner(roomId, userId) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { msg: "method", @@ -290,7 +297,7 @@ export class WsChatService { hidingRoom(roomId) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { msg: "method", @@ -316,8 +323,8 @@ export class WsChatService { joinRoom() {} deleteMessage(msgId) { - const requestId = uuidv4(); - + //const requestId = uuidv4(); + const requestId = uuidv4() var message = { msg: "method", method: "deleteMessage", @@ -338,7 +345,7 @@ export class WsChatService { } createPrivateRoom(groupName, username, customFields) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { msg: "method", @@ -370,7 +377,7 @@ export class WsChatService { sendStreamNotifyRoom(roomId : string, username, event: 'typing', param: any) { - const requestId = uuidv4() + const requestId = uuidv4() let message = { msg: "method", @@ -399,7 +406,7 @@ export class WsChatService { subStreamNotifyRoom(roomId : string , event: 'typing' | 'deleteMessage' | 'readMessage', param: any) { - const requestId = uuidv4() + const requestId = uuidv4() let message = { msg: "sub", @@ -451,7 +458,7 @@ export class WsChatService { loadHistory(roomId, limit: number = 50) { - const requestId = uuidv4() + const requestId = uuidv4() const message = { msg: "method", @@ -482,7 +489,7 @@ export class WsChatService { setStatus(status: 'online' | 'busy' | 'away' | 'offline') { - const requestId = uuidv4() + const requestId = uuidv4() const message = { @@ -499,7 +506,7 @@ export class WsChatService { subscribeNotifyRoom(roomId : string) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { "msg": "sub", @@ -545,7 +552,7 @@ export class WsChatService { streamRoomMessages(roomId : string) { - const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg": "sub", @@ -571,7 +578,7 @@ export class WsChatService { streamNotifyLogged() { - const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg": "sub", @@ -597,7 +604,7 @@ export class WsChatService { streamNotifyRoom(roomId : string) { - const requestId = uuidv4() + const requestId = uuidv4() let message = { "msg": "method", @@ -625,7 +632,7 @@ export class WsChatService { streamNotifyRoomDeleteMessage(roomId:string) { - const requestId = uuidv4() + const requestId = uuidv4() let message = { "msg": "sub", @@ -667,6 +674,7 @@ export class WsChatService { registerCallback:(params: wsCallbacksParams) => { let id = params.requestId || params.key || uuidv4() + console.log('register id', params) this.wsCallbacks[id] = params this.n++ return id @@ -730,7 +738,7 @@ export class WsChatService { this.wsMsgQueue[requestId] = {message, requestId, loginRequired} } else { let messageStr = JSON.stringify(message) - // console.log('messageStr', messageStr) + console.log('messageStr', messageStr) this.socket.send(messageStr) } diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 0a5b0df12..4f208f1ed 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,8 +1,11 @@ export const environment = { - apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', - apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', - apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', + //apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', + apiURL: 'https://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', + //apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', + //apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', + apiChatUrl: 'https://www.tabularium.pt/api/v1/', + apiWsChatUrl: 'wss://www.tabularium.pt/websocket', //apiChatUrl: 'https://www.tabularium.pt/api/v1/', production: true,