From a002fb1fe43258eeafc43f88d72a201c8c619f07 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 23 Jan 2023 10:02:47 -0500 Subject: [PATCH] baby steps --- backend/controllers/calls.js | 2 + frontend/src/Call/components/CallInfo.js | 51 ++-------- frontend/src/Call/components/CallInfoPane.js | 98 +++++++++++++++++++ .../src/Call/components/PlaylistBuilder.js | 2 +- frontend/src/Event/EventCallInfo.js | 28 ++++++ frontend/src/Event/EventPlayer.js | 4 +- frontend/src/Event/ViewEvent.js | 8 +- 7 files changed, 142 insertions(+), 51 deletions(-) create mode 100644 frontend/src/Call/components/CallInfoPane.js create mode 100644 frontend/src/Event/EventCallInfo.js diff --git a/backend/controllers/calls.js b/backend/controllers/calls.js index 248bbac..882c1a3 100644 --- a/backend/controllers/calls.js +++ b/backend/controllers/calls.js @@ -17,6 +17,7 @@ function get_calls(query, numResults, res) { var fields = { _id: true, talkgroupNum: true, + shortName: true, path: true, name: true, time: true, @@ -38,6 +39,7 @@ function get_calls(query, numResults, res) { if (item) { call = { _id: item._id.toHexString(), + shortName: item.shortName, talkgroupNum: item.talkgroupNum, url: item.url, filename: item.path + item.name, diff --git a/frontend/src/Call/components/CallInfo.js b/frontend/src/Call/components/CallInfo.js index a566028..74935d2 100644 --- a/frontend/src/Call/components/CallInfo.js +++ b/frontend/src/Call/components/CallInfo.js @@ -13,6 +13,7 @@ import { Tab } from "semantic-ui-react"; import PlaylistBuilder from "./PlaylistBuilder" +import CallInfoPane from "./CallInfoPane" // ---------------------------------------------------- function CallInfo(props) { const { shortName } = useParams(); @@ -51,56 +52,18 @@ function CallInfo(props) { const panes = [ { - menuItem: 'Call Info', render: () => { + menuItem: { key: 'info', icon: 'info', content: 'Call Info' }, render: () => { return ( -
- -
{header}
- - {srcList} - - - - Seconds - {callLength} - - - Talkgroup - {talkgroupNum} - - - - - - {callTime} - - - - - - {callDate} - - - - - - {callFreq} MHz - - - + + - - Tweet - Download - Link - -
+ ) } }, { - menuItem: 'Playlist', render: () => { + menuItem: { key: 'list', icon: 'list', content: 'Create Event' }, render: () => { return ( ) @@ -111,7 +74,7 @@ function CallInfo(props) { return (
- +
); } diff --git a/frontend/src/Call/components/CallInfoPane.js b/frontend/src/Call/components/CallInfoPane.js new file mode 100644 index 0000000..6d70c34 --- /dev/null +++ b/frontend/src/Call/components/CallInfoPane.js @@ -0,0 +1,98 @@ +import React, { useState } from "react"; +import { useCallLink } from "./CallLinks"; +import {skipToken} from '@reduxjs/toolkit/query' +import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../../features/api/apiSlice' +import { Link, useLocation, useParams, useNavigate } from 'react-router-dom'; +import { + Header, + Divider, + List, + Segment, + Statistic, + Icon, + Menu, + Tab +} from "semantic-ui-react"; +import PlaylistBuilder from "./PlaylistBuilder" +// ---------------------------------------------------- +function CallInfoPane(props) { + + + let srcList = ""; + let callLength = "-"; + let callFreq = "-"; + let callDate = "-"; + let callTime = "-"; + let talkgroupNum = "-"; + let header = "Call Info" + const currentCall = props.call?props.call:false; + + + + const { data: talkgroupsData, isSuccess: isTalkgroupsSuccess } = useGetTalkgroupsQuery(currentCall?currentCall.shortName:skipToken); + + if (currentCall) { + if ((talkgroupsData) && talkgroupsData.talkgroups[currentCall.talkgroupNum]) { + header = talkgroupsData.talkgroups[currentCall.talkgroupNum].description; + } + const time = new Date(currentCall.time); + callTime = time.toLocaleTimeString(); + callDate = time.toLocaleDateString(); + if (currentCall.freq) { + const freq = currentCall.freq / 1000000; + callFreq = Math.round(freq * 1000) / 1000; + } + srcList = currentCall.srcList.map((source, index) => {source.src}[{source.pos}]); + callLength = currentCall.len; + talkgroupNum = currentCall.talkgroupNum; + + } + const { callLink, callDownload, callTweet } = useCallLink(props.call) + + + return ( + <> +
{header}
+ + {srcList} + + + + Seconds + {callLength} + + + Talkgroup + {talkgroupNum} + + + + + + + {callTime} + + + + + + {callDate} + + + + + + {callFreq} MHz + + + + + + Download + Link + + + ); +} + +export default CallInfoPane; diff --git a/frontend/src/Call/components/PlaylistBuilder.js b/frontend/src/Call/components/PlaylistBuilder.js index b38ddeb..176365e 100644 --- a/frontend/src/Call/components/PlaylistBuilder.js +++ b/frontend/src/Call/components/PlaylistBuilder.js @@ -164,7 +164,7 @@ function PlaylistBuilder(props) { - + setPlaylist([])}>Clear Submit diff --git a/frontend/src/Event/EventCallInfo.js b/frontend/src/Event/EventCallInfo.js new file mode 100644 index 0000000..7be07c9 --- /dev/null +++ b/frontend/src/Event/EventCallInfo.js @@ -0,0 +1,28 @@ +import React, { useState } from "react"; +import { Link, useLocation, useParams, useNavigate } from 'react-router-dom'; +import { + Header, + Divider, + List, + Segment, + Statistic, + Icon, + Menu, + Tab +} from "semantic-ui-react"; +import CallInfoPane from "../Call/components/CallInfoPane" +// ---------------------------------------------------- +function EventCallInfo(props) { + + + + + return ( + + + + + ); +} + +export default EventCallInfo; diff --git a/frontend/src/Event/EventPlayer.js b/frontend/src/Event/EventPlayer.js index bd2c20a..de607d5 100644 --- a/frontend/src/Event/EventPlayer.js +++ b/frontend/src/Event/EventPlayer.js @@ -5,7 +5,7 @@ import MediaPlayer from "../Call/components/MediaPlayer"; import SupportModal from "../Call/components/SupportModal"; -import CallInfo from "../Call/components/CallInfo"; +import EventCallInfo from "./EventCallInfo"; import ListEventCalls from "./ListEventCalls"; import { useSelector, useDispatch } from 'react-redux' @@ -110,7 +110,7 @@ function EventPlayer(props) { - + diff --git a/frontend/src/Event/ViewEvent.js b/frontend/src/Event/ViewEvent.js index 3227744..97646e0 100644 --- a/frontend/src/Event/ViewEvent.js +++ b/frontend/src/Event/ViewEvent.js @@ -123,7 +123,7 @@ function ViewEvent(props) { - + {eventData && eventData.description} @@ -135,15 +135,15 @@ function ViewEvent(props) { - {eventData.numCalls} + {eventData && eventData.numCalls} Calls - + - + {eventData && } ); }