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 bfb47a6d9..9a5b88f9f 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,15 +53,15 @@ export class WsChatService { }) } - const requestId = uuidv4() - + const requestId = SessionStore.user.ChatData.data.userId + 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 } ] @@ -71,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) { @@ -85,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) } @@ -102,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", @@ -117,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 } }}) @@ -125,7 +130,8 @@ export class WsChatService { readMessage(roomId) { - const requestId = uuidv4() + //const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg":"method", @@ -149,7 +155,8 @@ export class WsChatService { getUserOfRoom(roomId) { - const requestId = uuidv4() + //const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg": "method", @@ -184,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", @@ -214,6 +222,7 @@ export class WsChatService { updateMessage(messageObject) { + //const requestId = uuidv4() const requestId = uuidv4() var message = { msg: "method", @@ -237,7 +246,7 @@ export class WsChatService { leaveRoom(roomId) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { msg: "method", @@ -262,7 +271,7 @@ export class WsChatService { addRoomOwner(roomId, userId) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { msg: "method", @@ -288,7 +297,7 @@ export class WsChatService { hidingRoom(roomId) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { msg: "method", @@ -314,8 +323,8 @@ export class WsChatService { joinRoom() {} deleteMessage(msgId) { - const requestId = uuidv4(); - + //const requestId = uuidv4(); + const requestId = uuidv4() var message = { msg: "method", method: "deleteMessage", @@ -336,7 +345,7 @@ export class WsChatService { } createPrivateRoom(groupName, username, customFields) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { msg: "method", @@ -368,7 +377,7 @@ export class WsChatService { sendStreamNotifyRoom(roomId : string, username, event: 'typing', param: any) { - const requestId = uuidv4() + const requestId = uuidv4() let message = { msg: "method", @@ -397,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", @@ -449,7 +458,7 @@ export class WsChatService { loadHistory(roomId, limit: number = 50) { - const requestId = uuidv4() + const requestId = uuidv4() const message = { msg: "method", @@ -480,7 +489,7 @@ export class WsChatService { setStatus(status: 'online' | 'busy' | 'away' | 'offline') { - const requestId = uuidv4() + const requestId = uuidv4() const message = { @@ -497,7 +506,7 @@ export class WsChatService { subscribeNotifyRoom(roomId : string) { - const requestId = uuidv4() + const requestId = uuidv4() var message = { "msg": "sub", @@ -543,7 +552,7 @@ export class WsChatService { streamRoomMessages(roomId : string) { - const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg": "sub", @@ -569,7 +578,7 @@ export class WsChatService { streamNotifyLogged() { - const requestId = uuidv4() + const requestId = uuidv4() const message = { "msg": "sub", @@ -595,7 +604,7 @@ export class WsChatService { streamNotifyRoom(roomId : string) { - const requestId = uuidv4() + const requestId = uuidv4() let message = { "msg": "method", @@ -623,7 +632,7 @@ export class WsChatService { streamNotifyRoomDeleteMessage(roomId:string) { - const requestId = uuidv4() + const requestId = uuidv4() let message = { "msg": "sub", @@ -665,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 @@ -728,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/app/shared/popover/opts-expediente/opts-expediente.page.html b/src/app/shared/popover/opts-expediente/opts-expediente.page.html index c10130669..74d594800 100644 --- a/src/app/shared/popover/opts-expediente/opts-expediente.page.html +++ b/src/app/shared/popover/opts-expediente/opts-expediente.page.html @@ -22,7 +22,7 @@ - +
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, diff --git a/src/environments/environment.ts b/src/environments/environment.ts index b59595989..e1c6e905b 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -23,10 +23,10 @@ export const environment = { production: false, //apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', apiURL: 'http://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://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: 'http://chat.gabinetedigital.local:3000/api/v1/', */ domain: 'gabinetedigital.local', //gabinetedigital.local defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local