diff --git a/README.md b/README.md index dc98aa7..83dccee 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ Then switch to the scanner db: `use scanner` And then add an index: ``` -db.calls.createIndex( {shortName: 1, time: -1, star: -1, talkgroupNum: 1}) +db.calls.createIndex( {shortName: 1, time: -1, talkgroupNum: 1}) ``` ### Upgrading MongoDB diff --git a/backend/controllers/events.js b/backend/controllers/events.js index c84421e..cc98de0 100644 --- a/backend/controllers/events.js +++ b/backend/controllers/events.js @@ -69,7 +69,8 @@ exports.addNewEvent = async function (req, res, next) { calls = calls.sort(compareCalls); event.startTime = new Date(calls[0].time); event.endTime = new Date(calls[calls.length - 1].time); - event.expireTime = event.startTime; + event.expireTime = new Date(); + event.expireTime.setDate(event.startTime.getDate() + 29); calls.forEach((call) => { if (event.shortNames.indexOf(call.shortName) === -1) { event.shortNames.push(call.shortName); diff --git a/frontend/src/Call/components/PlaylistBuilder.js b/frontend/src/Call/components/PlaylistBuilder.js index e62e8c9..92771c8 100644 --- a/frontend/src/Call/components/PlaylistBuilder.js +++ b/frontend/src/Call/components/PlaylistBuilder.js @@ -19,6 +19,7 @@ import { Message } from "semantic-ui-react"; import { useAddNewEventMutation, useGetTalkgroupsQuery } from '../../features/api/apiSlice' +import PlaylistItem from "./PlaylistItem" function PlaylistBuilder(props) { const { shortName } = useParams(); @@ -75,6 +76,17 @@ function PlaylistBuilder(props) { console.log("Dropping: " + callId); addCall(callsData.entities[callId]) } + +const removeItem = (call) => { + if (call) { + const found = playlist.findIndex(c => c._id == call._id); + if (found!=-1) { + playlist.splice(found,1) + setPlaylist([...playlist.sort(compareCalls)]) + } + } +} + let listItems = ""; listItems = playlist.map((call, index) => { @@ -84,16 +96,7 @@ function PlaylistBuilder(props) { tgAlpha = talkgroup.alpha?talkgroup.alpha:tgAlpha; } - const time = new Date(call.time); - const callTime = time.toLocaleTimeString(); - const callDate = time.toLocaleDateString(); - - return ( - {call.len} - {tgAlpha} - {callTime} - - ) + return ( ) }) const submitPlaylist = () => { diff --git a/frontend/src/Call/components/PlaylistItem.js b/frontend/src/Call/components/PlaylistItem.js new file mode 100644 index 0000000..61f444f --- /dev/null +++ b/frontend/src/Call/components/PlaylistItem.js @@ -0,0 +1,53 @@ +import React, { useState } from "react"; +import { + Table, + Icon, + Label +} from "semantic-ui-react"; + + + +const PlaylistItem = (props) => { + const call = props.call; + const tgAlpha = props.tgAlpha; + const removeItem = props.removeItem; + const index = props.index; + const [removeVisible, setRemoveVisible] = useState(false); + + + + const handleRemoveClicked = (e) => { + e.preventDefault(); + e.stopPropagation(); + e.nativeEvent.stopImmediatePropagation(); + removeItem(call); + } + + let removeButton; + + + + + if (removeVisible) { + removeButton = + } else { + removeButton = + } + + + + const time = new Date(call.time); + const callTime = time.toLocaleTimeString(); + return ( + props.onClick({ call: call }, e)}> + {call.len} + {tgAlpha} + {callTime} + setRemoveVisible(true)} onMouseLeave={() => setRemoveVisible(false)} onClick={handleRemoveClicked}>{removeButton} + + + + ); +} + +export default PlaylistItem; diff --git a/frontend/src/Event/ViewEvent.js b/frontend/src/Event/ViewEvent.js index f87d31f..7633b34 100644 --- a/frontend/src/Event/ViewEvent.js +++ b/frontend/src/Event/ViewEvent.js @@ -127,14 +127,14 @@ function ViewEvent(props) { - + {eventData&& <>

{eventData.description}

Expires {expirationDate}
} -
+
{dates.part1}
→ {dates.part2}