From beec21470a63015e9219fa6790d6aea37b8e7f01 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 28 Jan 2023 13:16:16 -0500 Subject: [PATCH] better Systems List --- frontend/src/Call/CallPlayer.js | 10 ++--- frontend/src/Main/Main.js | 1 + frontend/src/System/ListSystems.js | 71 ++++++++++++++++++++++++------ 3 files changed, 64 insertions(+), 18 deletions(-) diff --git a/frontend/src/Call/CallPlayer.js b/frontend/src/Call/CallPlayer.js index bc635d7..e3cfb77 100644 --- a/frontend/src/Call/CallPlayer.js +++ b/frontend/src/Call/CallPlayer.js @@ -41,20 +41,20 @@ function CallPlayer(props) { /* Optional options */ threshold: 0.5 }); - + const { data: talkgroupsData, isSuccess: isTalkgroupsSuccess } = useGetTalkgroupsQuery(shortName); const [autoPlay, setAutoPlay] = useState(true); const [currentCall, setCurrentCall] = useState(false); const [isPlaying, setIsPlaying] = useState(false); - const {callLink,callDownload,callTweet} = useCallLink(currentCall) + const { callLink, callDownload, callTweet } = useCallLink(currentCall) const dispatch = useDispatch(); const stickyRef = useRef(); // lets us get the Y Scroll offset for the Call List const positionRef = useRef(); // lets us get the Y Scroll offset for the Call List const shouldPlayAddCallRef = useRef(); // we need to do this to make the current value of isPlaying available in the socket message callback const live = useSelector((state) => state.callPlayer.live); - shouldPlayAddCallRef.current = (!isPlaying && autoPlay)?true:false; + shouldPlayAddCallRef.current = (!isPlaying && autoPlay) ? true : false; let currentCallId = false; @@ -112,7 +112,7 @@ function CallPlayer(props) { // we should only set the selectCallId to be the current call when AutoPlay is selected // and when there isn't another call already playing useEffect(() => { - if ( selectCallId && callsData && !isPlaying && autoPlay) { + if (selectCallId && callsData && !isPlaying && autoPlay) { const call = callsData.entities[selectCallId]; if (call) { setCurrentCall(call); @@ -129,7 +129,7 @@ function CallPlayer(props) { style={{ minHeight: '100vh' }} >
- +
diff --git a/frontend/src/Main/Main.js b/frontend/src/Main/Main.js index 52801ab..feb5e5d 100644 --- a/frontend/src/Main/Main.js +++ b/frontend/src/Main/Main.js @@ -117,6 +117,7 @@ const DesktopContainer = (props) => {
{process.env.REACT_APP_SITE_NAME}
Listen + Events About
diff --git a/frontend/src/System/ListSystems.js b/frontend/src/System/ListSystems.js index 06f4ec9..fb76803 100644 --- a/frontend/src/System/ListSystems.js +++ b/frontend/src/System/ListSystems.js @@ -1,4 +1,4 @@ -import React, { Component } from "react"; +import React, { Component, useRef } from "react"; import { Link, useNavigate } from 'react-router-dom' import SystemCard from "./SystemCard"; import { useSelector, useDispatch } from 'react-redux' @@ -8,7 +8,12 @@ import { Card, Icon, Menu, - Divider + Divider, + List, + Segment, + Sticky, + Rail, + Grid } from "semantic-ui-react"; import NavBar from "../Common/NavBar" import { selectAllSystems, selectActiveSystems, } from "../features/systems/systemsSlice"; @@ -19,6 +24,7 @@ const ListSystems = (props) => { const { data: allSystems, isSuccess } = useGetSystemsQuery(); const systems = useSelector(selectActiveSystems) + const contextRef = useRef(); let states = {}; let other = [] for (var i = 0; i < systems.length; i++) { @@ -33,17 +39,32 @@ const ListSystems = (props) => { } } - - let systemsByState = []; let keys = Object.keys(states); keys.sort(); - for(var i=0; i{state})) + + let stateList = []; + for (var i = 0; i < keys.length; ++i) { + const state = keys[i]; + stateList.push(( + + + + {state} + + + + )) + } + + let systemsByState = []; + + for (var i = 0; i < keys.length; ++i) { + const state = keys[i]; + + systemsByState.push((
{state}
)) systemsByState.push(( - {states[state]&& + {states[state] && states[state].map((system) => { return navigate("/system/" + system.shortName)} /> })} @@ -51,10 +72,10 @@ const ListSystems = (props) => { )) } let international = []; - international.push((
International
)) + international.push((
International
)) international.push(( - - {other&& + + {other && other.map((system) => { return navigate("/system/" + system.shortName)} /> })} @@ -62,12 +83,36 @@ const ListSystems = (props) => { )) const navigate = useNavigate(); return ( -
+
+
Radio Systems
+ + + + + {stateList} + + + International + + + {systemsByState} {international} + + + + + + + {stateList} + + + + +
);