Merge remote-tracking branch 'origin/dual_session_test' into dialogflow
commit
e2fc5c267e
|
@ -81,6 +81,6 @@
|
||||||
"supertest": "^5.0.0",
|
"supertest": "^5.0.0",
|
||||||
"ts-jest": "^26.4.1",
|
"ts-jest": "^26.4.1",
|
||||||
"ts-node-dev": "^1.0.0-pre.63",
|
"ts-node-dev": "^1.0.0-pre.63",
|
||||||
"typescript": "4.1"
|
"typescript": "4.1.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import ShowQueuesByUser from "../services/UserServices/ShowQueuesByUser";
|
||||||
// import { filter } from "bluebird";
|
// import { filter } from "bluebird";
|
||||||
|
|
||||||
import { getIO } from "../libs/socket";
|
import { getIO } from "../libs/socket";
|
||||||
|
import { Json } from "sequelize/types/lib/utils";
|
||||||
|
|
||||||
type IndexQuery = {
|
type IndexQuery = {
|
||||||
userId: string;
|
userId: string;
|
||||||
|
@ -87,6 +88,10 @@ export const reportUserService = async (req: Request, res: Response): Promise<Re
|
||||||
let openCloseOnQueue = openByUserOnQueue.concat(closedByUserOnQueue)
|
let openCloseOnQueue = openByUserOnQueue.concat(closedByUserOnQueue)
|
||||||
let openCloseOutQueue = openByUserOutQueue.concat(closedUserOutQueue)
|
let openCloseOutQueue = openByUserOutQueue.concat(closedUserOutQueue)
|
||||||
|
|
||||||
|
|
||||||
|
// console.log('onlineUsers: ',JSON.parse(JSON.stringify(onlineUsers)))
|
||||||
|
// console.log('sumUserOlineTime: ', JSON.parse(JSON.stringify(sumUserOlineTime)))
|
||||||
|
|
||||||
for (let i = 0; i < queuesByUser.length; i++) {
|
for (let i = 0; i < queuesByUser.length; i++) {
|
||||||
|
|
||||||
queuesByUser[i].countOpen = 0
|
queuesByUser[i].countOpen = 0
|
||||||
|
@ -113,6 +118,8 @@ export const reportUserService = async (req: Request, res: Response): Promise<Re
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
user.sumOnlineTime = sumUserOlineTime[index];
|
user.sumOnlineTime = sumUserOlineTime[index];
|
||||||
|
|
||||||
|
// console.log('user.sumOlineTime: 'user.sumOnlineTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
index = closedByUser.findIndex((e: any) => e.userId == user.id)
|
index = closedByUser.findIndex((e: any) => e.userId == user.id)
|
||||||
|
@ -169,7 +176,7 @@ export const reportUserService = async (req: Request, res: Response): Promise<Re
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return res.status(200).json(usersProfile);
|
return res.status(200).json({usersProfile: usersProfile});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ import { redisConn } from './TicketCache'
|
||||||
import Whatsapp from "../models/Whatsapp";
|
import Whatsapp from "../models/Whatsapp";
|
||||||
import { response } from 'express'
|
import { response } from 'express'
|
||||||
|
|
||||||
const deleteWhatsappCache = async (hash:any) => {
|
const deleteWhatsappCache = async (hash: any) => {
|
||||||
|
|
||||||
const redis: any = await redisConn();
|
const redis: any = await redisConn();
|
||||||
|
|
||||||
if(!redis) return
|
if (!redis) return
|
||||||
|
|
||||||
if (redis.status !== 'connect') return
|
if (redis.status !== 'connect') return
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ const updateWhatsappCache = async (hash: any, json_object: any) => {
|
||||||
|
|
||||||
const redis: any = await redisConn();
|
const redis: any = await redisConn();
|
||||||
|
|
||||||
if(!redis) return
|
if (!redis) return
|
||||||
|
|
||||||
if (redis.status !== 'connect') return
|
if (redis.status !== 'connect') return
|
||||||
|
|
||||||
|
@ -57,11 +57,11 @@ const updateWhatsappCache = async (hash: any, json_object: any) => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateWhatsappCacheById = async (hash:any, update_fields: object | any) => {
|
const updateWhatsappCacheById = async (hash: any, update_fields: object | any) => {
|
||||||
|
|
||||||
const redis: any = await redisConn();
|
const redis: any = await redisConn();
|
||||||
|
|
||||||
if(!redis) return
|
if (!redis) return
|
||||||
|
|
||||||
if (redis.status !== 'connect') return
|
if (redis.status !== 'connect') return
|
||||||
|
|
||||||
|
@ -109,15 +109,15 @@ async function searchWhatsappCache(id: string, status: string) {
|
||||||
|
|
||||||
const redis: any = await redisConn();
|
const redis: any = await redisConn();
|
||||||
|
|
||||||
if(!redis) return
|
if (!redis) return
|
||||||
|
|
||||||
if (redis.status !== 'connect') return null
|
if (redis.status !== 'connect') return null
|
||||||
|
|
||||||
|
|
||||||
const number_cache: any = await redis.hgetall(`whatsapp:${id}`)
|
const number_cache: any = await redis.hgetall(`whatsapp:${id}`)
|
||||||
|
|
||||||
if(Object.entries(number_cache).length == 0){
|
if (Object.entries(number_cache).length == 0) {
|
||||||
await redis.quit()
|
await await redis.quit()
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,15 +155,15 @@ async function searchWhatsappCache(id: string, status: string) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const insertOrUpeateWhatsCache = async (hash:any, whatsapp: any) => {
|
const insertOrUpeateWhatsCache = async (hash: any, whatsapp: any) => {
|
||||||
|
|
||||||
const redis: any = await redisConn();
|
const redis: any = await redisConn();
|
||||||
|
|
||||||
if(!redis) return
|
if (!redis) return
|
||||||
|
|
||||||
if (redis.status !== 'connect') return
|
if (redis.status !== 'connect') return
|
||||||
|
|
||||||
if(Array.isArray(whatsapp)){
|
if (Array.isArray(whatsapp)) {
|
||||||
|
|
||||||
const pipeline = redis.pipeline()
|
const pipeline = redis.pipeline()
|
||||||
|
|
||||||
|
@ -174,9 +174,9 @@ const insertOrUpeateWhatsCache = async (hash:any, whatsapp: any) => {
|
||||||
|
|
||||||
await pipeline.exec(() => { console.log(`${whatsapp.length} WHATSAPP INSERTED IN CACHE!`) });
|
await pipeline.exec(() => { console.log(`${whatsapp.length} WHATSAPP INSERTED IN CACHE!`) });
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
|
|
||||||
await redis.hmset(hash,JSON.parse(JSON.stringify(whatsapp)));
|
await redis.hmset(hash, JSON.parse(JSON.stringify(whatsapp)));
|
||||||
|
|
||||||
console.log(`WHATSAPP ID ${whatsapp.id} INSERTED OR UPADTED IN CACHE!`)
|
console.log(`WHATSAPP ID ${whatsapp.id} INSERTED OR UPADTED IN CACHE!`)
|
||||||
|
|
||||||
|
@ -195,11 +195,11 @@ const loadWhatsappCache = async () => {
|
||||||
|
|
||||||
const redis: any = await redisConn();
|
const redis: any = await redisConn();
|
||||||
|
|
||||||
if(!redis) return
|
if (!redis) return
|
||||||
|
|
||||||
if (redis.status !== 'connect') return
|
if (redis.status !== 'connect') return
|
||||||
|
|
||||||
let whatsapps:any = await Whatsapp.findAll({raw: true})
|
let whatsapps: any = await Whatsapp.findAll({ raw: true })
|
||||||
|
|
||||||
const pipeline = redis.pipeline()
|
const pipeline = redis.pipeline()
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ const createWhatsappIndexCache = async (hashIndex: string) => {
|
||||||
|
|
||||||
const redis: any = await redisConn();
|
const redis: any = await redisConn();
|
||||||
|
|
||||||
if(!redis) return
|
if (!redis) return
|
||||||
|
|
||||||
if (redis.status !== 'connect') return
|
if (redis.status !== 'connect') return
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ const createWhatsappIndexCache = async (hashIndex: string) => {
|
||||||
await redis.call('FT.DROPINDEX', hashIndex)
|
await redis.call('FT.DROPINDEX', hashIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await redis.call('FT.CREATE', hashIndex, 'ON', 'HASH', 'PREFIX', '1', 'whatsapp:', 'SCHEMA','id', 'NUMERIC', 'status', 'TEXT', 'SORTABLE', 'number', 'TEXT', 'SORTABLE')
|
const response = await redis.call('FT.CREATE', hashIndex, 'ON', 'HASH', 'PREFIX', '1', 'whatsapp:', 'SCHEMA', 'id', 'NUMERIC', 'status', 'TEXT', 'SORTABLE', 'number', 'TEXT', 'SORTABLE')
|
||||||
|
|
||||||
console.log('Whatsapp index created: ', response)
|
console.log('Whatsapp index created: ', response)
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ let whoIsOnline_monitor: any;
|
||||||
// const listUserId:any[] = [{'id':8, status: 'offline'},{'id':3, status: 'offline'},{'id':5, status: 'offline'}]
|
// const listUserId:any[] = [{'id':8, status: 'offline'},{'id':3, status: 'offline'},{'id':5, status: 'offline'}]
|
||||||
let listUserId: any[] = []
|
let listUserId: any[] = []
|
||||||
let count = 0
|
let count = 0
|
||||||
let countTest = 0
|
// let countTest = 0
|
||||||
let uuid: any = 0
|
let uuid: any = 0
|
||||||
let dateTime = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR })))
|
let dateTime = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR })))
|
||||||
let timeInterval = 5
|
let timeInterval = 5
|
||||||
|
@ -51,6 +51,10 @@ const emitterOnline = (user: any, status: string, showOnlineTime: boolean = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('ENTROU NO EMMITER ONLINE: ', user.id)
|
||||||
|
|
||||||
|
// console.log('-------------> onlineTime: ', onlineTime)
|
||||||
|
|
||||||
const io = getIO();
|
const io = getIO();
|
||||||
io.emit("onlineStatus", {
|
io.emit("onlineStatus", {
|
||||||
action: "update",
|
action: "update",
|
||||||
|
@ -113,12 +117,14 @@ const monitor = async () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log('el: ', el)
|
||||||
|
|
||||||
if (el.status == 'waiting...') {
|
if (el.status == 'waiting...') {
|
||||||
emitterOnline(el, el.status, false)
|
emitterOnline(el, el.status, false)
|
||||||
}
|
}
|
||||||
else {
|
// else {
|
||||||
emitterOnline(el, el.status)
|
// emitterOnline(el, el.status)
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,36 +156,12 @@ const monitor = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (countTest > 5) {
|
|
||||||
countTest = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if (countTest == 0) {
|
|
||||||
try {
|
|
||||||
console.log(' Carregando usuarios no listUserId...')
|
|
||||||
listUserId = await ListUserParamiterService({ profile: 'user' })
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.log('There was an erro on ListUserParamiterService: ', error)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
countTest = 1
|
|
||||||
|
|
||||||
listUserId.forEach((u) => {
|
|
||||||
|
|
||||||
const io = getIO();
|
|
||||||
io.emit("isOnline", { action: "online", userId: u.id });
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('>>> There was an error no WhoIsOnlineMonitor.ts: ', error)
|
console.log('>>> There was an error no WhoIsOnlineMonitor.ts: ', error)
|
||||||
|
|
||||||
listUserId = []
|
listUserId = []
|
||||||
count = 0
|
count = 0
|
||||||
countTest = 0
|
// countTest = 0
|
||||||
uuid = 0
|
uuid = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +193,7 @@ const startWhoIsOnlineMonitor = async (mileseconds?: number) => {
|
||||||
|
|
||||||
listUserId = []
|
listUserId = []
|
||||||
count = 0
|
count = 0
|
||||||
countTest = 0
|
// countTest = 0
|
||||||
uuid = 0
|
uuid = 0
|
||||||
|
|
||||||
clearInterval(_fifo);
|
clearInterval(_fifo);
|
||||||
|
|
|
@ -48,6 +48,8 @@ export const initIO = (httpServer: Server): SocketIO => {
|
||||||
|
|
||||||
socket.on("online", (userId: any) => {
|
socket.on("online", (userId: any) => {
|
||||||
|
|
||||||
|
// console.log('userId: ', userId)
|
||||||
|
|
||||||
obj.uuid = uuidv4()
|
obj.uuid = uuidv4()
|
||||||
|
|
||||||
if (userId.logoutUserId) {
|
if (userId.logoutUserId) {
|
||||||
|
|
|
@ -40,6 +40,29 @@ const useStyles = makeStyles(theme => ({
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
let _fifo
|
||||||
|
|
||||||
|
// const onlineEmitter = async (socket, user) => {
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// clearInterval(_fifo);
|
||||||
|
|
||||||
|
// socket.emit("online", user.id)
|
||||||
|
|
||||||
|
// } catch (error) {
|
||||||
|
// console.log('error on onlineEmitter: ', error)
|
||||||
|
// }
|
||||||
|
// finally {
|
||||||
|
// _fifo = setInterval(onlineEmitter, 3000);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _fifo = setInterval(onlineEmitter, 3000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const NotificationsPopOver = () => {
|
const NotificationsPopOver = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
@ -95,13 +118,13 @@ const NotificationsPopOver = () => {
|
||||||
|
|
||||||
socket.on("onlineStatus", (data) => {
|
socket.on("onlineStatus", (data) => {
|
||||||
|
|
||||||
if(data.action === "logout"){
|
if (data.action === "logout") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(`${user.id}` === data.userOnlineTime['userId']){
|
if (`${user.id}` === data.userOnlineTime['userId']) {
|
||||||
|
|
||||||
socket.emit("online", {logoutUserId: user.id})
|
socket.emit("online", { logoutUserId: user.id })
|
||||||
handleLogout();
|
handleLogout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,20 +133,37 @@ const NotificationsPopOver = () => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("isOnline", (data) => {
|
// socket.on("isOnline", (data) => {
|
||||||
|
|
||||||
|
// if (data.action === "online") {
|
||||||
|
|
||||||
|
// if (data.userId === user.id) {
|
||||||
|
|
||||||
|
// socket.emit("online", user.id)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
if(user.profile === 'user'){
|
||||||
|
|
||||||
if(data.action === "online"){
|
if(_fifo){
|
||||||
|
clearInterval(_fifo);
|
||||||
if(data.userId === user.id){
|
}
|
||||||
|
|
||||||
|
_fifo = setInterval(()=>{
|
||||||
|
console.log('user.id: ', user.id)
|
||||||
socket.emit("online", user.id)
|
socket.emit("online", user.id)
|
||||||
}
|
}, 3000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import React, { useContext, useReducer, useEffect, useState } from "react";
|
import React, { useContext, useReducer, useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import { addHours, addMinutes, addSeconds, intervalToDuration, add } from "date-fns";
|
||||||
|
|
||||||
import Paper from "@material-ui/core/Paper";
|
import Paper from "@material-ui/core/Paper";
|
||||||
import Container from "@material-ui/core/Container";
|
import Container from "@material-ui/core/Container";
|
||||||
import Grid from "@material-ui/core/Grid";
|
import Grid from "@material-ui/core/Grid";
|
||||||
|
@ -104,6 +106,36 @@ const useStyles = makeStyles((theme) => ({
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
var _fifo
|
||||||
|
|
||||||
|
const sumOnlineTimeNow = (oldOnlineTimeSum) => {
|
||||||
|
|
||||||
|
let onlineTime = new Date()
|
||||||
|
|
||||||
|
onlineTime.setUTCHours(new Date(oldOnlineTimeSum.onlineTime).getHours())
|
||||||
|
onlineTime.setUTCMinutes(new Date(oldOnlineTimeSum.onlineTime).getMinutes())
|
||||||
|
onlineTime.setUTCSeconds(new Date(oldOnlineTimeSum.onlineTime).getSeconds())
|
||||||
|
|
||||||
|
|
||||||
|
let newtTime = intervalToDuration({ start: new Date(oldOnlineTimeSum.updatedAt), end: new Date() })
|
||||||
|
|
||||||
|
|
||||||
|
if (newtTime.hours && +newtTime.hours > 0) {
|
||||||
|
onlineTime = addHours(onlineTime, newtTime.hours)
|
||||||
|
}
|
||||||
|
if (newtTime.minutes && +newtTime.minutes > 0) {
|
||||||
|
onlineTime = addMinutes(onlineTime, newtTime.minutes)
|
||||||
|
}
|
||||||
|
if (newtTime.seconds && +newtTime.seconds > 0) {
|
||||||
|
onlineTime = addSeconds(onlineTime, newtTime.seconds)
|
||||||
|
}
|
||||||
|
|
||||||
|
const isoDate = new Date(onlineTime);
|
||||||
|
const newOnlinetime = isoDate.toJSON().slice(0, 19).replace('T', ' ');
|
||||||
|
|
||||||
|
return newOnlinetime
|
||||||
|
}
|
||||||
|
|
||||||
const reducer = (state, action) => {
|
const reducer = (state, action) => {
|
||||||
if (action.type === "DELETE_USER_STATUS") {
|
if (action.type === "DELETE_USER_STATUS") {
|
||||||
const userId = action.payload;
|
const userId = action.payload;
|
||||||
|
@ -138,6 +170,8 @@ const reducer = (state, action) => {
|
||||||
let onlineUser = action.payload;
|
let onlineUser = action.payload;
|
||||||
let index = -1;
|
let index = -1;
|
||||||
|
|
||||||
|
// console.log('UPDATE_STATUS_ONLINE: ', onlineUser)
|
||||||
|
|
||||||
let onlySumOpenClosed = false;
|
let onlySumOpenClosed = false;
|
||||||
|
|
||||||
if (onlineUser.sumOpen || onlineUser.sumClosed) {
|
if (onlineUser.sumOpen || onlineUser.sumClosed) {
|
||||||
|
@ -157,18 +191,27 @@ const reducer = (state, action) => {
|
||||||
if (!("statusOnline" in state[index])) {
|
if (!("statusOnline" in state[index])) {
|
||||||
state[index].statusOnline = onlineUser;
|
state[index].statusOnline = onlineUser;
|
||||||
} else if ("statusOnline" in state[index]) {
|
} else if ("statusOnline" in state[index]) {
|
||||||
|
|
||||||
state[index].statusOnline["status"] = onlineUser.status;
|
state[index].statusOnline["status"] = onlineUser.status;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ("onlineTime" in onlineUser) {
|
if ("onlineTime" in onlineUser) {
|
||||||
|
|
||||||
if ("sumOnlineTime" in state[index]) {
|
if ("sumOnlineTime" in state[index]) {
|
||||||
state[index].sumOnlineTime["sum"] = onlineUser.onlineTime.split(" ")[1];
|
|
||||||
|
// console.log(' ffffffffffffffffffffffffffff ')
|
||||||
|
state[index].sumOnlineTime.sum = onlineUser.onlineTime.split(" ")[1]
|
||||||
|
|
||||||
} else if (!("sumOnlineTime" in state[index])) {
|
} else if (!("sumOnlineTime" in state[index])) {
|
||||||
|
|
||||||
state[index].sumOnlineTime = {
|
state[index].sumOnlineTime = {
|
||||||
userId: onlineUser.userId,
|
userId: onlineUser.userId,
|
||||||
sum: onlineUser.onlineTime.split(" ")[1],
|
sum: onlineUser.onlineTime.split(" ")[1],
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,11 +278,14 @@ const Dashboard = () => {
|
||||||
let date = new Date().toLocaleDateString("pt-BR").split("/");
|
let date = new Date().toLocaleDateString("pt-BR").split("/");
|
||||||
let dateToday = `${date[2]}-${date[1]}-${date[0]}`;
|
let dateToday = `${date[2]}-${date[1]}-${date[0]}`;
|
||||||
|
|
||||||
const dataQuery = await api.get("/reports/user/services", {
|
const { data } = await api.get("/reports/user/services", {
|
||||||
params: { userId: null, startDate: dateToday, endDate: dateToday },
|
params: { userId: null, startDate: dateToday, endDate: dateToday },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.log('data.data: ', data.usersProfile)
|
||||||
|
|
||||||
dispatch({ type: "RESET" });
|
dispatch({ type: "RESET" });
|
||||||
dispatch({ type: "LOAD_QUERY", payload: dataQuery.data });
|
dispatch({ type: "LOAD_QUERY", payload: data.usersProfile });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -250,6 +296,37 @@ const Dashboard = () => {
|
||||||
return () => clearTimeout(delayDebounceFn);
|
return () => clearTimeout(delayDebounceFn);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
|
||||||
|
if (!usersOnlineInfo || usersOnlineInfo.length == 0) return
|
||||||
|
|
||||||
|
if (_fifo) {
|
||||||
|
clearInterval(_fifo);
|
||||||
|
}
|
||||||
|
|
||||||
|
_fifo = setInterval(() => {
|
||||||
|
|
||||||
|
usersOnlineInfo.map((e) => {
|
||||||
|
|
||||||
|
if (e.statusOnline && e.statusOnline.status === 'online') {
|
||||||
|
|
||||||
|
let onlineTimeCurrent = sumOnlineTimeNow({onlineTime: e.statusOnline.onlineTime, updatedAt: e.statusOnline.updatedAt})
|
||||||
|
|
||||||
|
dispatch({ type: "UPDATE_STATUS_ONLINE", payload: { userId: e.id, status: e.statusOnline.status, onlineTime: onlineTimeCurrent } });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
|
||||||
|
}, [usersOnlineInfo])
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||||
|
|
||||||
|
@ -372,10 +449,10 @@ const Dashboard = () => {
|
||||||
style={{ overflow: "hidden" }}
|
style={{ overflow: "hidden" }}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
>
|
>
|
||||||
<Typography component="h3" variant="h6" color="primary" style={{marginBottom:"0"}} paragraph>
|
<Typography component="h3" variant="h6" color="primary" style={{ marginBottom: "0" }} paragraph>
|
||||||
Em Atendimento
|
Em Atendimento
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography paragraph style={{fontSize: "12px", margin:"0px"}}>Hoje/Todo Periodo</Typography>
|
<Typography paragraph style={{ fontSize: "12px", margin: "0px" }}>Hoje/Todo Periodo</Typography>
|
||||||
|
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<Typography component="h1" variant="h4">
|
<Typography component="h1" variant="h4">
|
||||||
|
|
|
@ -728,7 +728,7 @@ const Report = () => {
|
||||||
|
|
||||||
{ title: 'Tempo online', field: 'sumOnlineTime.sum' },
|
{ title: 'Tempo online', field: 'sumOnlineTime.sum' },
|
||||||
{ title: `${i18n.t("reports.dateStart")}`, field: 'startDate' },
|
{ title: `${i18n.t("reports.dateStart")}`, field: 'startDate' },
|
||||||
{ title: `${i18n.t("reports.dateStart")}`, field: 'endDate' },
|
{ title: `${i18n.t("reports.dateEnd")}`, field: 'endDate' },
|
||||||
{ title: 'Em atendimento', field: 'sumOpen.count' },
|
{ title: 'Em atendimento', field: 'sumOpen.count' },
|
||||||
{ title: 'Finalizado', field: 'sumClosed.count' },
|
{ title: 'Finalizado', field: 'sumClosed.count' },
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue