mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-14 09:48:10 -05:00
Cleaned up Events
This commit is contained in:
@@ -194,7 +194,7 @@ Then switch to the scanner db: `use scanner`
|
|||||||
And then add an index:
|
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
|
### Upgrading MongoDB
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ exports.addNewEvent = async function (req, res, next) {
|
|||||||
calls = calls.sort(compareCalls);
|
calls = calls.sort(compareCalls);
|
||||||
event.startTime = new Date(calls[0].time);
|
event.startTime = new Date(calls[0].time);
|
||||||
event.endTime = new Date(calls[calls.length - 1].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) => {
|
calls.forEach((call) => {
|
||||||
if (event.shortNames.indexOf(call.shortName) === -1) {
|
if (event.shortNames.indexOf(call.shortName) === -1) {
|
||||||
event.shortNames.push(call.shortName);
|
event.shortNames.push(call.shortName);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
Message
|
Message
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import { useAddNewEventMutation, useGetTalkgroupsQuery } from '../../features/api/apiSlice'
|
import { useAddNewEventMutation, useGetTalkgroupsQuery } from '../../features/api/apiSlice'
|
||||||
|
import PlaylistItem from "./PlaylistItem"
|
||||||
|
|
||||||
function PlaylistBuilder(props) {
|
function PlaylistBuilder(props) {
|
||||||
const { shortName } = useParams();
|
const { shortName } = useParams();
|
||||||
@@ -75,6 +76,17 @@ function PlaylistBuilder(props) {
|
|||||||
console.log("Dropping: " + callId);
|
console.log("Dropping: " + callId);
|
||||||
addCall(callsData.entities[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 = "";
|
let listItems = "";
|
||||||
|
|
||||||
listItems = playlist.map((call, index) => {
|
listItems = playlist.map((call, index) => {
|
||||||
@@ -84,16 +96,7 @@ function PlaylistBuilder(props) {
|
|||||||
tgAlpha = talkgroup.alpha?talkgroup.alpha:tgAlpha;
|
tgAlpha = talkgroup.alpha?talkgroup.alpha:tgAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
const time = new Date(call.time);
|
return ( <PlaylistItem call={call} tgAlpha={tgAlpha} index={index} removeItem={removeItem}/> )
|
||||||
const callTime = time.toLocaleTimeString();
|
|
||||||
const callDate = time.toLocaleDateString();
|
|
||||||
|
|
||||||
return ( <Table.Row key={index}>
|
|
||||||
<Table.Cell>{call.len} </Table.Cell>
|
|
||||||
<Table.Cell>{tgAlpha}</Table.Cell>
|
|
||||||
<Table.Cell>{callTime}</Table.Cell>
|
|
||||||
</Table.Row>
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const submitPlaylist = () => {
|
const submitPlaylist = () => {
|
||||||
|
|||||||
53
frontend/src/Call/components/PlaylistItem.js
Normal file
53
frontend/src/Call/components/PlaylistItem.js
Normal file
@@ -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 = <Icon name='delete' color="red"/>
|
||||||
|
} else {
|
||||||
|
removeButton = <Icon name='delete' color="grey"/>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const time = new Date(call.time);
|
||||||
|
const callTime = time.toLocaleTimeString();
|
||||||
|
return (
|
||||||
|
<Table.Row key={index} onClick={(e) => props.onClick({ call: call }, e)}>
|
||||||
|
<Table.Cell>{call.len} </Table.Cell>
|
||||||
|
<Table.Cell>{tgAlpha}</Table.Cell>
|
||||||
|
<Table.Cell>{callTime}</Table.Cell>
|
||||||
|
<Table.Cell onMouseEnter={() => setRemoveVisible(true)} onMouseLeave={() => setRemoveVisible(false)} onClick={handleRemoveClicked}>{removeButton}</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PlaylistItem;
|
||||||
@@ -127,14 +127,14 @@ function ViewEvent(props) {
|
|||||||
<Grid style={{ paddingTop: '4em' }}>
|
<Grid style={{ paddingTop: '4em' }}>
|
||||||
<Grid.Column mobile={1} tablet={1} computer={1} ></Grid.Column>
|
<Grid.Column mobile={1} tablet={1} computer={1} ></Grid.Column>
|
||||||
<Grid.Column mobile={16} tablet={8} computer={4}>
|
<Grid.Column mobile={16} tablet={8} computer={4}>
|
||||||
<Container text >
|
|
||||||
{eventData&&
|
{eventData&&
|
||||||
<>
|
<>
|
||||||
<p>{eventData.description}</p>
|
<p>{eventData.description}</p>
|
||||||
<Header size='tiny'>Expires {expirationDate}</Header>
|
<Header size='tiny'>Expires {expirationDate}</Header>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
</Container>
|
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
<Grid.Column mobile={8} tablet={8} computer={4}>
|
<Grid.Column mobile={8} tablet={8} computer={4}>
|
||||||
<Header as="h2">{dates.part1} <br/>→ {dates.part2}</Header>
|
<Header as="h2">{dates.part1} <br/>→ {dates.part2}</Header>
|
||||||
|
|||||||
Reference in New Issue
Block a user