cleaned up some errors

This commit is contained in:
Luke Berndt
2023-01-17 20:50:47 -05:00
parent 0a5e88c652
commit 1d55a63f7f
8 changed files with 37 additions and 66 deletions

View File

@@ -1,4 +1,4 @@
import React, { Component } from "react"; import React from "react";
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Container, Header, Divider, Icon, Menu, Button } from "semantic-ui-react"; import { Container, Header, Divider, Icon, Menu, Button } from "semantic-ui-react";

View File

@@ -1,4 +1,4 @@
import React, { Component, useState } from "react"; import React, { useState } from "react";
import { import {
Modal, Modal,
Button, Button,
@@ -8,12 +8,10 @@ import "./CalendarModal.css";
import { setDateFilter } from "../features/callPlayer/callPlayerSlice"; import { setDateFilter } from "../features/callPlayer/callPlayerSlice";
import DatePicker from 'react-datepicker'; import DatePicker from 'react-datepicker';
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { setDate, subDays } from 'date-fns' import { subDays } from 'date-fns'
import 'react-datepicker/dist/react-datepicker.css'; import 'react-datepicker/dist/react-datepicker.css';
function CalendarModal(props) { function CalendarModal(props) {
const [open, setOpen] = useState(false);
const [startDate, setStartDate] = useState(new Date()); const [startDate, setStartDate] = useState(new Date());
const dispatch = useDispatch() const dispatch = useDispatch()
const onClose = props.onClose; const onClose = props.onClose;

View File

@@ -1,7 +1,6 @@
import React from "react"; import React from "react";
import { import {
Header, Header,
Button,
Divider, Divider,
List, List,
Segment, Segment,

View File

@@ -1,13 +1,12 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { import {
Table, Table,
Icon, Icon,
Label Label
} from "semantic-ui-react"; } from "semantic-ui-react";
import { connect } from "react-redux"
import { addStar, removeStar} from "../features/calls/callsSlice";
import { addStar, removeStar } from "../features/calls/callsSlice";
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
const CallItem = (props) => { const CallItem = (props) => {
@@ -22,7 +21,7 @@ const CallItem = (props) => {
const handleStarClicked = (e) => { const handleStarClicked = (e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
e.nativeEvent.stopImmediatePropagation(); e.nativeEvent.stopImmediatePropagation();
if (!starClicked) { if (!starClicked) {
setStarClicked(true); setStarClicked(true);
dispatch(addStar(props.call._id)); dispatch(addStar(props.call._id));
@@ -32,11 +31,11 @@ const CallItem = (props) => {
} }
} }
var rowSelected={}; var rowSelected = {};
let starButton; let starButton;
var starClickable = {}; var starClickable = {};
if (!starClicked) { if (!starClicked) {
starClickable = {link: true }; starClickable = { link: true };
} }
if (!call.star && starVisible) { if (!call.star && starVisible) {
starButton = <Icon name='star outline' /> starButton = <Icon name='star outline' />
@@ -47,32 +46,33 @@ const CallItem = (props) => {
} }
if (call.star && call.star > 1) { if (call.star && call.star > 1) {
starButton = (<Icon.Group > starButton = (<Icon.Group >
<Icon {...starClickable} name='star' /> <Icon {...starClickable} name='star' />
<Label circular color='red' size='mini' floating> <Label circular color='red' size='mini' floating>
{call.star} {call.star}
</Label> </Label>
</Icon.Group>) </Icon.Group>)
} }
if (activeCall) { if (activeCall) {
rowSelected={positive: true, rowSelected = {
positive: true,
color: "blue", color: "blue",
key: "blue", key: "blue",
inverted: "true" inverted: "true"
} }
} }
var talkgroup; var talkgroup;
if ((typeof props.talkgroups == 'undefined') || (typeof props.talkgroups[call.talkgroupNum] == 'undefined')) { if ((typeof props.talkgroups == 'undefined') || (typeof props.talkgroups[call.talkgroupNum] == 'undefined')) {
talkgroup = call.talkgroupNum; talkgroup = call.talkgroupNum;
} else { } else {
talkgroup = props.talkgroups[call.talkgroupNum].description; talkgroup = props.talkgroups[call.talkgroupNum].description;
} }
return ( return (
<Table.Row onClick={(e) => props.onClick({call: call}, e)} {...rowSelected}> <Table.Row onClick={(e) => props.onClick({ call: call }, e)} {...rowSelected}>
<Table.Cell> {call.len} </Table.Cell> <Table.Cell> {call.len} </Table.Cell>
<Table.Cell> {talkgroup} </Table.Cell> <Table.Cell> {talkgroup} </Table.Cell>
<Table.Cell> {time.toLocaleTimeString()} </Table.Cell> <Table.Cell> {time.toLocaleTimeString()} </Table.Cell>
<Table.Cell onMouseEnter={()=> setStarVisible(true)} onMouseLeave={() => setStarVisible(false)} onClick={handleStarClicked}>{starButton}</Table.Cell> <Table.Cell onMouseEnter={() => setStarVisible(true)} onMouseLeave={() => setStarVisible(false)} onClick={handleStarClicked}>{starButton}</Table.Cell>
</Table.Row> </Table.Row>

View File

@@ -9,7 +9,7 @@ import CalendarModal from "./CalendarModal";
import CallInfo from "./CallInfo"; import CallInfo from "./CallInfo";
import ListCalls from "./ListCalls"; import ListCalls from "./ListCalls";
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
import { setLive, setShortName, setFilter,setDateFilter } from "../features/callPlayer/callPlayerSlice"; import { setLive, setFilter,setDateFilter } from "../features/callPlayer/callPlayerSlice";
import { getCalls, getOlderCalls, getNewerCalls, addCall } from "../features/calls/callsSlice"; import { getCalls, getOlderCalls, getNewerCalls, addCall } from "../features/calls/callsSlice";
import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../features/api/apiSlice' import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../features/api/apiSlice'
import { useInView } from 'react-intersection-observer'; import { useInView } from 'react-intersection-observer';
@@ -20,8 +20,7 @@ import {
Sticky, Sticky,
Menu, Menu,
Icon, Icon,
Sidebar, Sidebar
Button
} from "semantic-ui-react"; } from "semantic-ui-react";
import "./CallPlayer.css"; import "./CallPlayer.css";
import queryString from '../query-string'; import queryString from '../query-string';
@@ -36,11 +35,11 @@ const socket = io(process.env.REACT_APP_BACKEND_SERVER);
function CallPlayer(props) { function CallPlayer(props) {
const { shortName } = useParams(); const { shortName } = useParams();
const { ref: loadOlderRef, inView: loadOlderInView, entry: loadOlderEntry } = useInView({ const { ref: loadOlderRef, inView: loadOlderInView } = useInView({
/* Optional options */ /* Optional options */
threshold: 0.5 threshold: 0.5
}); });
const { ref: loadNewerRef, inView: loadNewerInView, entry: loadNewerEntry } = useInView({ const { ref: loadNewerRef, inView: loadNewerInView } = useInView({
/* Optional options */ /* Optional options */
threshold: 0.5 threshold: 0.5
}); });
@@ -83,9 +82,6 @@ function CallPlayer(props) {
currentCallId = currentCall._id; currentCallId = currentCall._id;
} }
const handlePlayPause = (playing) => { const handlePlayPause = (playing) => {
setIsPlaying(playing); setIsPlaying(playing);
} }
@@ -151,7 +147,7 @@ function CallPlayer(props) {
const message = JSON.parse(data) const message = JSON.parse(data)
switch (message.type) { switch (message.type) {
case 'calls': case 'calls':
const ref = positionRef.current;
pageYOffset.current = positionRef.current.clientHeight; pageYOffset.current = positionRef.current.clientHeight;
if (shouldPlayAddCallRef.current) { if (shouldPlayAddCallRef.current) {
@@ -282,18 +278,11 @@ function CallPlayer(props) {
// is this just for one call? // is this just for one call?
if (uri.hasOwnProperty('call-id')) { if (uri.hasOwnProperty('call-id')) {
const _id = uri['call-id']; const _id = uri['call-id'];
const date = new Date(parseInt(uri['time']));
setLoadCallId(_id); setLoadCallId(_id);
setAutoPlay(false); setAutoPlay(false);
if (!urlOptions) setUrlOptions(true); if (!urlOptions) setUrlOptions(true);
//callActions.fetchCallInfo(_id);
//callActions.setCallTime(date);
} }
var filterType = "all";
var filterCode = "";
// is there a Filter set? // is there a Filter set?
if ((uri.hasOwnProperty('filter-code')) && (uri.hasOwnProperty('filter-type'))) { if ((uri.hasOwnProperty('filter-code')) && (uri.hasOwnProperty('filter-type'))) {
if (!urlOptions) setUrlOptions(true); if (!urlOptions) setUrlOptions(true);
@@ -302,8 +291,6 @@ function CallPlayer(props) {
if (uri['filter-type'] === "group") { if (uri['filter-type'] === "group") {
filter.filterType = 1; filter.filterType = 1;
filter.filterGroupId = uri["filter-code"]; filter.filterGroupId = uri["filter-code"];
filterType = "group";
filterCode = uri["filter-code"];
} }
// The Filter is talkgroups // The Filter is talkgroups
@@ -311,8 +298,6 @@ function CallPlayer(props) {
const tg = uri["filter-code"].split(',').map(Number); const tg = uri["filter-code"].split(',').map(Number);
filter.filterType = 2; filter.filterType = 2;
filter.filterTalkgroups = tg; filter.filterTalkgroups = tg;
filterType = "talkgroup";
filterCode = tg;
} }
} }

View File

@@ -1,4 +1,4 @@
import React, { Component, useState } from "react"; import React, { useState } from "react";
import { setGroupFilter, setTalkgroupFilter, setAllFilter, setStarredFilter } from "../features/callPlayer/callPlayerSlice"; import { setGroupFilter, setTalkgroupFilter, setAllFilter, setStarredFilter } from "../features/callPlayer/callPlayerSlice";
import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../features/api/apiSlice' import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../features/api/apiSlice'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
@@ -16,11 +16,9 @@ import "./FilterModal.css";
function FilterModal(props) { function FilterModal(props) {
const shortName = useSelector((state) => state.callPlayer.shortName);
const globalFilterStarred = useSelector((state) => state.callPlayer.filterStarred); const globalFilterStarred = useSelector((state) => state.callPlayer.filterStarred);
const { data:groupsData, isSuccess:isGroupsSuccess } = useGetGroupsQuery(props.shortName); const { data:groupsData, isSuccess:isGroupsSuccess } = useGetGroupsQuery(props.shortName);
const { data:talkgroupsData, isSuccess:isTalkgroupsSuccess } = useGetTalkgroupsQuery(props.shortName); const { data:talkgroupsData, isSuccess:isTalkgroupsSuccess } = useGetTalkgroupsQuery(props.shortName);
const [open, setOpen] = useState(false);
const [selectedTalkgroup, setSelectedTalkgroup] = useState([]); const [selectedTalkgroup, setSelectedTalkgroup] = useState([]);
const [selectedGroup, setSelectedGroup] = useState(false); const [selectedGroup, setSelectedGroup] = useState(false);
const [filterStarred, setFilterStarred] = useState(false); const [filterStarred, setFilterStarred] = useState(false);

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useLayoutEffect, useRef } from "react"; import React, { useEffect, useRef } from "react";
import CallItem from "./CallItem"; import CallItem from "./CallItem";
import { import {
Icon, Icon,

View File

@@ -1,4 +1,4 @@
import React, { Component, useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import { Link, useNavigate } from 'react-router-dom' import { Link, useNavigate } from 'react-router-dom'
import SystemCard from "../System/SystemCard"; import SystemCard from "../System/SystemCard";
import "./Main.css"; import "./Main.css";
@@ -17,8 +17,8 @@ import {
} from 'semantic-ui-react' } from 'semantic-ui-react'
import { useSelector, useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { selectAllSystems, selectActiveSystems, useGetSystemsQuery } from "../features/api/apiSlice"; import { useGetSystemsQuery } from "../features/api/apiSlice";
/* Responsive component was removed from Semantic UI. This is discussed here: https://github.com/Semantic-Org/Semantic-UI-React/pull/4008 */ /* Responsive component was removed from Semantic UI. This is discussed here: https://github.com/Semantic-Org/Semantic-UI-React/pull/4008 */
@@ -88,10 +88,8 @@ const DesktopContainer = (props) => {
const hideFixedMenu = () => setFixed(false) const hideFixedMenu = () => setFixed(false)
const showFixedMenu = () => setFixed(true) const showFixedMenu = () => setFixed(true)
const { children } = props const { children } = props
return ( return (
<Media greaterThanOrEqual="tablet"> <Media greaterThanOrEqual="tablet">
<div className="relative"> <div className="relative">
@@ -212,15 +210,10 @@ const ResponsiveContainer = ({ children }) => (
const Main = (props) => { const Main = (props) => {
const [visible, setVisible] = useState(true); const [visible, setVisible] = useState(true);
const [duration, setDuration] = useState(500);
const [currentSystem, setCurrentSystem] = useState(0); const [currentSystem, setCurrentSystem] = useState(0);
const navigate = useNavigate(); const navigate = useNavigate();
const dispatch = useDispatch();
const {data:systems, isSuccess} = useGetSystemsQuery(); //= selectAllSystems(); const {data:systems, isSuccess} = useGetSystemsQuery(); //= selectAllSystems();
function useInterval(callback, delay) { function useInterval(callback, delay) {
const savedCallback = useRef(); const savedCallback = useRef();
@@ -241,8 +234,6 @@ const Main = (props) => {
}, [delay]); }, [delay]);
} }
const handleVisibility = () => setVisible(!visible);
const advanceSystem = () => { const advanceSystem = () => {
if (isSuccess) { if (isSuccess) {
let nextSystem = currentSystem + 1; let nextSystem = currentSystem + 1;