mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
improve rocket-chat-cliente interface
This commit is contained in:
Generated
+17
@@ -19818,6 +19818,23 @@
|
||||
"glob": "^7.1.3"
|
||||
}
|
||||
},
|
||||
"rocket.chat.realtime.api.rxjs": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/rocket.chat.realtime.api.rxjs/-/rocket.chat.realtime.api.rxjs-2.1.1.tgz",
|
||||
"integrity": "sha512-R+aAbUi66CBwsXuji0AsQGOrUx4STXw9I8lf4hpPK/mRocyjcA+r+ri0bDHGoB0FGnooSvkvauqpy+RjbB2dEg==",
|
||||
"requires": {
|
||||
"crypto-js": "^3.1.9-1",
|
||||
"rxjs": "^6.4.0",
|
||||
"uuid": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"crypto-js": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz",
|
||||
"integrity": "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"rsvp": {
|
||||
"version": "4.8.5",
|
||||
"resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz",
|
||||
|
||||
@@ -136,6 +136,7 @@
|
||||
"pdfjs": "^2.4.6",
|
||||
"pdfjs-dist": "^2.9.359",
|
||||
"puppeteer": "^10.1.0",
|
||||
"rocket.chat.realtime.api.rxjs": "^2.1.1",
|
||||
"rxjs": "~6.6.3",
|
||||
"rxjs-compat": "^6.6.7",
|
||||
"sharp": "^0.29.1",
|
||||
|
||||
+82
-42
@@ -29,6 +29,8 @@ import { Device } from '@capacitor/device';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { RocketChatClientService } from 'src/app/services/socket/rocket-chat-client.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { RealTimeAPI } from "rocket.chat.realtime.api.rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -94,6 +96,86 @@ export class HomePage implements OnInit {
|
||||
private RouteService: RouteService,
|
||||
private RocketChatClientService: RocketChatClientService) {
|
||||
|
||||
// this.RocketChatClientService.connect()
|
||||
// this.RocketChatClientService.login({
|
||||
// username: 'paulo.pinto@gabinetedigital.local',
|
||||
// password: 'tabteste@006'
|
||||
// })
|
||||
|
||||
|
||||
|
||||
// const url = 'wss://gabinetedigitalchat.dyndns.info/websocket'
|
||||
// const socket = new WebSocket(url);
|
||||
|
||||
|
||||
// socket.onopen = ()=> {
|
||||
|
||||
// console.log('============================ welcome to rocket chat =========================================');
|
||||
|
||||
// const connectMessage = {
|
||||
// msg: "connect",
|
||||
// version: "1",
|
||||
// support: ["1"]
|
||||
// }
|
||||
|
||||
// socket.send(JSON.stringify(connectMessage))
|
||||
|
||||
// const loginRequest = {
|
||||
// msg: "method",
|
||||
// method: "login",
|
||||
// id: uuidv4(),
|
||||
// params: [
|
||||
// {
|
||||
// "user": {
|
||||
// "email": 'paulo.pinto@gabinetedigital.local'
|
||||
// },
|
||||
// "password": {
|
||||
// "digest": 'tabteste@006',
|
||||
// "algorithm":"sha-256"
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
|
||||
// // temp login
|
||||
// socket.send(JSON.stringify(loginRequest))
|
||||
// };
|
||||
|
||||
// socket.onmessage = (event: any)=> {
|
||||
// // console.log('rocket chat message', event)
|
||||
// console.log('event.data', JSON.parse(event.data))
|
||||
// };
|
||||
|
||||
// socket.onclose = (event: any)=> {
|
||||
// console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
|
||||
// };
|
||||
|
||||
// socket.onerror =(event: any)=> {
|
||||
// console.log(`[error] ${event.message}`);
|
||||
// };
|
||||
|
||||
|
||||
// const realTimeAPI = new RealTimeAPI("wss://gabinetedigitalchat.dyndns.info/websocket");
|
||||
// realTimeAPI.keepAlive().subscribe();
|
||||
// const auth = realTimeAPI.login('tiago.kayaya@gabinetedigital.local', 'tabteste@006');
|
||||
|
||||
// //Subscribe to messages and errors
|
||||
// auth.subscribe(
|
||||
// (data) => console.log('socket data', data),
|
||||
// (err) => console.log('socket err', err),
|
||||
// () => console.log('completed')
|
||||
// );
|
||||
|
||||
// // Subscribe to a specific channel, identified by roomId
|
||||
// realTimeAPI.sendMessage({
|
||||
// msg: 'sub',
|
||||
// id: '<a unique Id for subscription>',
|
||||
// name: 'stream-room-messages',
|
||||
// params: ['44', false],
|
||||
// });
|
||||
|
||||
// this.RocketChatClientService.send()
|
||||
|
||||
/* this.webNotificationPopupService.askNotificationPermission() */
|
||||
|
||||
this.router.events.subscribe((val) => {
|
||||
@@ -238,45 +320,3 @@ export class HomePage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const url = 'wss://gabinetedigitalchat.dyndns.info/websocket'
|
||||
const socket = new WebSocket(url);
|
||||
|
||||
|
||||
socket.onopen = ()=> {
|
||||
|
||||
console.log('============================ welcome to rocket chat =========================================');
|
||||
|
||||
|
||||
const loginRequest = {
|
||||
msg: "method",
|
||||
method: "login",
|
||||
id: "42",
|
||||
params: [
|
||||
{
|
||||
"user": { "username": 'paulo.pinto@gabinetedigital.local' },
|
||||
"password": {
|
||||
"digest": 'tabteste@006',
|
||||
"algorithm":"sha-256"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// temp login
|
||||
socket.send(JSON.stringify(loginRequest))
|
||||
};
|
||||
|
||||
socket.onmessage = (event: any)=> {
|
||||
console.log('rocket chat message', event)
|
||||
console.log('event.data', JSON.parse(event.data))
|
||||
};
|
||||
|
||||
socket.onclose = (event: any)=> {
|
||||
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
|
||||
};
|
||||
|
||||
socket.onerror =(event: any)=> {
|
||||
console.log(`[error] ${event.message}`);
|
||||
};
|
||||
@@ -22,7 +22,7 @@ export class AESEncrypt {
|
||||
|
||||
//Decrypting the string contained in cipherParams using the PBKDF2 key
|
||||
var decrypted = CryptoJS.AES.encrypt(encryptData, key128Bits1000Iterations, { mode: CryptoJS.mode.CBC, iv: iv, padding: CryptoJS.pad.Pkcs7 });
|
||||
console.log('AES encrypt',decrypted.toString());
|
||||
// console.log('AES encrypt',decrypted.toString());
|
||||
|
||||
return decrypted.toString();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export class SocketInterfaceService {
|
||||
private url = ''
|
||||
private connected = false
|
||||
private callBacks: {
|
||||
type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notification' | 'Notifications' | '',
|
||||
type: 'Offline' | 'Online' | 'Open' ,
|
||||
object?: string
|
||||
funx: Function
|
||||
}[] = []
|
||||
@@ -17,6 +17,14 @@ export class SocketInterfaceService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
registerCallback(type: 'Offline' | 'Online' | 'Open', funx: Function, object = '') {
|
||||
this.callBacks.push({
|
||||
type,
|
||||
funx,
|
||||
object
|
||||
})
|
||||
}
|
||||
|
||||
connect(url) {
|
||||
|
||||
this.url = url
|
||||
@@ -28,8 +36,20 @@ export class SocketInterfaceService {
|
||||
this.socket.onerror = this.onerror;
|
||||
}
|
||||
|
||||
onopen() {
|
||||
this.connected = true
|
||||
|
||||
// send all saved data due to internet connection
|
||||
this.msgQueue.forEach((item, index, object) => {
|
||||
this.send(item);
|
||||
object.splice(index, 1);
|
||||
})
|
||||
}
|
||||
|
||||
send(message: object) {
|
||||
if (!this.connected) { // save data to send when back online
|
||||
console.log(this.connected, message)
|
||||
|
||||
if (this.connected === false) { // save data to send when back online
|
||||
this.msgQueue.push(message)
|
||||
} else {
|
||||
let messageStr = JSON.stringify(message)
|
||||
@@ -37,12 +57,12 @@ export class SocketInterfaceService {
|
||||
}
|
||||
}
|
||||
|
||||
onopen() {
|
||||
|
||||
onmessage(event: any) {
|
||||
console.log('event.data', JSON.parse(event.data))
|
||||
}
|
||||
onmessage() {}
|
||||
|
||||
onclose(event: any) {
|
||||
this.connected = false
|
||||
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
|
||||
setTimeout(()=>{
|
||||
this.connect(this.url)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SocketInterfaceService } from './interface/socket-interface.service'
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -9,16 +10,25 @@ export class RocketChatClientService {
|
||||
|
||||
private SocketInterfaceService = new SocketInterfaceService()
|
||||
|
||||
constructor() {
|
||||
const url = environment.apiChatUrl.replace('https','wss')
|
||||
// this.SocketInterfaceService.connect(url);
|
||||
constructor() {}
|
||||
|
||||
connect(url = 'wss://gabinetedigitalchat.dyndns.info/websocket') {
|
||||
|
||||
this.SocketInterfaceService.connect(url);
|
||||
|
||||
const connectMessage = {
|
||||
msg: "connect",
|
||||
version: "1",
|
||||
support: ["1"]
|
||||
}
|
||||
this.SocketInterfaceService.send(connectMessage)
|
||||
}
|
||||
|
||||
login(user) {
|
||||
const loginRequest = {
|
||||
msg: "method",
|
||||
method: "login",
|
||||
id: "42",
|
||||
id: uuidv4(),
|
||||
params: [
|
||||
{
|
||||
"user": { "username": user.username },
|
||||
@@ -29,17 +39,31 @@ export class RocketChatClientService {
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// this.SocketInterfaceService.send(loginRequest)
|
||||
this.SocketInterfaceService.send(loginRequest)
|
||||
}
|
||||
|
||||
logout(){ }
|
||||
|
||||
send(roomId, message, option) {}
|
||||
send(roomId, message, option) {
|
||||
var request = {
|
||||
"msg": "method",
|
||||
"method": "sendMessage",
|
||||
"id": uuidv4(),
|
||||
"params": [{
|
||||
"_id": "message-id",
|
||||
"rid": "room-id",
|
||||
"msg": "Hello World!"
|
||||
}]
|
||||
}
|
||||
|
||||
this.SocketInterfaceService.send(request);
|
||||
}
|
||||
|
||||
receive() {}
|
||||
joinRoom(){}
|
||||
deleteMessage() {}
|
||||
|
||||
createRoom() {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ export class ToastService {
|
||||
</div>
|
||||
`;
|
||||
|
||||
console.log(document.querySelector('body').classList)
|
||||
// console.log(document.querySelector('body').classList)
|
||||
document.body.append(loader)
|
||||
|
||||
loader.addEventListener('click', ()=>{
|
||||
|
||||
Reference in New Issue
Block a user