diff --git a/backend/sys_stats.js b/backend/sys_stats.js index 32bb5cd..d57ecef 100644 --- a/backend/sys_stats.js +++ b/backend/sys_stats.js @@ -17,39 +17,43 @@ function updateActiveSystems() { // While there are still Systems to work with if (item) { - var active = false; - var callAvg = 0; - // if you have recieved some calls during that last period, make the system active if ((callTotals[item.shortName] != undefined) && (callTotals[item.shortName][0] > 0)) { - active = true; - callAvg = callTotals[item.shortName][0] / timePeriod; + const active = true; + const callAvg = callTotals[item.shortName][0] / timePeriod; + sysCollection.update({ + shortName: item.shortName + }, { + $set: { + "active": active, + "callAvg": callAvg, + "lastActive": new Date() + } + }, { + upsert: true + }, function(err, objects) { + if (err) { + console.log("Shortname: " + item.shortName); + console.warn(err.message); + } + }); + } else { + sysCollection.update({ + shortName: item.shortName + }, { + $set: { + "active": false, + "callAvg": 0 + } + }, { + upsert: true + }, function(err, objects) { + if (err) { + console.log("Shortname: " + item.shortName); + console.warn(err.message); + } + }); } - - if (err) { - console.log(item); - console.log(err); - } - //console.log(); - - // set the Call Average and Active for the System in the DB - sysCollection.update({ - shortName: item.shortName - }, { - $set: { - "active": active, - "callAvg": callAvg - } - }, { - upsert: true - }, function(err, objects) { - if (err) { - console.log("Shortname: " + item.shortName); - console.warn(err.message); - } - //console.log(util.inspect(objects)); - }); - } }); }); diff --git a/frontend/src/Call/Calls.js b/frontend/src/Call/Calls.js index 3a2885e..c51f5a0 100644 --- a/frontend/src/Call/Calls.js +++ b/frontend/src/Call/Calls.js @@ -8,6 +8,7 @@ import { useSelector, useDispatch } from 'react-redux' import { setLive, setFilter, setDateFilter } from "../features/callPlayer/callPlayerSlice"; import { getCalls, addCall, getOlderCalls, getNewerCalls } from "../features/calls/callsSlice"; import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../features/api/apiSlice' +import { useGetSystemsQuery, } from "../features/api/apiSlice"; import { Container, @@ -24,10 +25,8 @@ import io from 'socket.io-client'; - const socket = io(process.env.REACT_APP_BACKEND_SERVER); - // ---------------------------------------------------- function Calls(props) { @@ -35,7 +34,6 @@ function Calls(props) { const { data: groupsData, isSuccess: isGroupsSuccess } = useGetGroupsQuery(shortName); const { loading: callsLoading, data: callsData } = useSelector((state) => state.calls); - const [autoPlay, setAutoPlay] = useState(true); const [currentCall, setCurrentCall] = useState(false); const [urlOptions, setUrlOptions] = useState(false); diff --git a/frontend/src/System/ListSystems.js b/frontend/src/System/ListSystems.js index de92381..f737043 100644 --- a/frontend/src/System/ListSystems.js +++ b/frontend/src/System/ListSystems.js @@ -1,6 +1,7 @@ import React, { Component } from "react"; -import { Link, useNavigate } from 'react-router-dom' +import { Link, useNavigate } from 'react-router-dom' import SystemCard from "./SystemCard"; +import { useSelector, useDispatch } from 'react-redux' import { Container, Header, @@ -9,32 +10,58 @@ import { Menu, Divider } from "semantic-ui-react"; -import NavBar from "../Common/NavBar" -import { selectAllSystems, selectActiveSystems, useGetSystemsQuery } from "../features/api/apiSlice"; - +import NavBar from "../Common/NavBar" +import { selectAllSystems, selectActiveSystems, } from "../features/systems/systemsSlice"; +import { useGetSystemsQuery, } from '../features/api/apiSlice' // ---------------------------------------------------- const ListSystems = (props) => { - - const {data:systems, isSuccess} = useGetSystemsQuery(); - const navigate = useNavigate(); - return ( -