mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
merge
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -23,7 +23,7 @@ import { PipesModule } from 'src/app/pipes/pipes.module';
|
||||
MessagesPageRoutingModule,
|
||||
MatMenuModule,
|
||||
LettersAvatarModule,
|
||||
PipesModule,
|
||||
PipesModule
|
||||
],
|
||||
declarations: [MessagesPage]
|
||||
})
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
<span class="time">{{msg.duration}}</span>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<ion-label *ngIf="msg.delate == false">{{msg.msg}}</ion-label>
|
||||
<ion-label *ngIf="msg.delate == true">{{msg.msg}}</ion-label>
|
||||
|
||||
<ion-label class="float-status-all float-status" >
|
||||
|
||||
<ion-icon *ngIf="msg.messageSend == false" src="assets/images/clock-regular.svg"></ion-icon>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user