mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-16 18:57:47 -05:00
added stars and new calls
This commit is contained in:
@@ -241,7 +241,39 @@ function package_call(item) {
|
|||||||
return call;
|
return call;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.remove_star = function(req, res, next) {
|
||||||
|
var objectId = req.params.id;
|
||||||
|
try {
|
||||||
|
var o_id = ObjectID.createFromHexString(objectId);
|
||||||
|
} catch (err) {
|
||||||
|
console.warn("[" + req.params.shortName + "] Error - /:shortName/call/:id generating ObjectID " + err);
|
||||||
|
res.status(500);
|
||||||
|
res.send(JSON.stringify({
|
||||||
|
success: false,
|
||||||
|
message: err,
|
||||||
|
"_id": objectId
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Call.findOneAndUpdate({ _id: objectId }, { $inc: { star: -1 } }, {new: true },function(err, item) {
|
||||||
|
if (err) {
|
||||||
|
res.status(500);
|
||||||
|
res.send(JSON.stringify({
|
||||||
|
success: false,
|
||||||
|
message: err,
|
||||||
|
"_id": objectId
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
var call = package_call(item);
|
||||||
|
req.call = call;
|
||||||
|
res.send(JSON.stringify({
|
||||||
|
success: true,
|
||||||
|
call: call
|
||||||
|
}));
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
exports.add_star = function(req, res, next) {
|
exports.add_star = function(req, res, next) {
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ app.get('/:shortName/calls/older', calls.get_older_calls);
|
|||||||
app.get('/:shortName/calls/:time/older', calls.get_iphone_calls);
|
app.get('/:shortName/calls/:time/older', calls.get_iphone_calls);
|
||||||
app.get('/:shortName/calls', calls.get_calls);
|
app.get('/:shortName/calls', calls.get_calls);
|
||||||
app.post('/:shortName/star/:id', calls.add_star);
|
app.post('/:shortName/star/:id', calls.add_star);
|
||||||
|
app.post('/:shortName/removeStar/:id', calls.remove_star);
|
||||||
|
|
||||||
/*------ UPLOADS ---------- upload.single('call'), uploads.upload,*/
|
/*------ UPLOADS ---------- upload.single('call'), uploads.upload,*/
|
||||||
app.post('/:shortName/upload', upload.single('call'), uploads.upload, async function (req, res) {
|
app.post('/:shortName/upload', upload.single('call'), uploads.upload, async function (req, res) {
|
||||||
|
|||||||
@@ -1,88 +1,44 @@
|
|||||||
|
|
||||||
import React, { Component } 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 { connect } from "react-redux"
|
||||||
import { bindActionCreators } from 'redux'
|
|
||||||
import * as callActionCreators from "./call-actions"
|
|
||||||
|
|
||||||
|
import { addStar, removeStar} from "../features/calls/callsSlice";
|
||||||
|
import { useDispatch } from 'react-redux'
|
||||||
|
|
||||||
function mapStateToProps(state, props) {
|
const CallItem = (props) => {
|
||||||
return {
|
|
||||||
shortName: props.shortName
|
|
||||||
|
|
||||||
}
|
const [starVisible, setStarVisible] = useState(false);
|
||||||
}
|
const [starClicked, setStarClicked] = useState(false);
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const call = props.call;
|
||||||
|
const time = new Date(call.time);
|
||||||
|
const activeCall = props.activeCall;
|
||||||
|
|
||||||
function mapDispatchToProps(dispatch) {
|
const handleStarClicked = (e) => {
|
||||||
return {
|
|
||||||
callActions: bindActionCreators(callActionCreators, dispatch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class CallItem extends Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.hideStar = this.hideStar.bind(this);
|
|
||||||
this.showStar = this.showStar.bind(this);
|
|
||||||
this.addStar = this.addStar.bind(this);
|
|
||||||
this.state = {
|
|
||||||
starVisible: false,
|
|
||||||
starClicked: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceString(call) {
|
|
||||||
var srcString = "";
|
|
||||||
if (call.srcList) {
|
|
||||||
for (var src in call.srcList) {
|
|
||||||
/* srcNum = call.srcList[src].src;
|
|
||||||
if (sources.hasOwnProperty(srcNum)) {
|
|
||||||
srcString = srcString + sources[srcNum].codeName + ", ";
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return srcString;
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate(){
|
|
||||||
if (this.props.activeCall) {
|
|
||||||
console.log("Active call mounted")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addStar(e) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.nativeEvent.stopImmediatePropagation();
|
e.nativeEvent.stopImmediatePropagation();
|
||||||
if (!this.state.starClicked) {
|
if (!starClicked) {
|
||||||
|
setStarClicked(true);
|
||||||
this.props.callActions.addStar(this.props.call._id);
|
dispatch(addStar(props.call._id));
|
||||||
this.setState({starClicked: true});
|
} else {
|
||||||
|
setStarClicked(false);
|
||||||
|
dispatch(removeStar(props.call._id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hideStar() {
|
|
||||||
this.setState({ starVisible: false })
|
|
||||||
}
|
|
||||||
|
|
||||||
showStar() {
|
|
||||||
this.setState({ starVisible: true })
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const call = this.props.call;
|
|
||||||
const time = new Date(call.time);
|
|
||||||
var rowSelected={};
|
var rowSelected={};
|
||||||
let starButton;
|
let starButton;
|
||||||
var starClickable = {};
|
var starClickable = {};
|
||||||
if (!this.state.starClicked) {
|
if (!starClicked) {
|
||||||
starClickable = {link: true };
|
starClickable = {link: true };
|
||||||
}
|
}
|
||||||
if (!call.star && this.state.starVisible) {
|
if (!call.star && starVisible) {
|
||||||
starButton = <Icon name='star outline' />
|
starButton = <Icon name='star outline' />
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +54,7 @@ render() {
|
|||||||
</Icon.Group>)
|
</Icon.Group>)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.activeCall) {
|
if (activeCall) {
|
||||||
rowSelected={positive: true,
|
rowSelected={positive: true,
|
||||||
color: "blue",
|
color: "blue",
|
||||||
key: "blue",
|
key: "blue",
|
||||||
@@ -106,26 +62,21 @@ render() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var talkgroup;
|
var talkgroup;
|
||||||
if ((typeof this.props.talkgroups == 'undefined') || (typeof this.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 = this.props.talkgroups[call.talkgroupNum].description;
|
talkgroup = props.talkgroups[call.talkgroupNum].description;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Table.Row onClick={(e) => this.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={this.showStar} onMouseLeave={this.hideStar} onClick={this.addStar}>{starButton}</Table.Cell>
|
<Table.Cell onMouseEnter={()=> setStarVisible(true)} onMouseLeave={() => setStarVisible(false)} onClick={handleStarClicked}>{starButton}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(
|
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps
|
|
||||||
)(CallItem)
|
|
||||||
|
|
||||||
|
export default CallItem;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ 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 } from "../features/callPlayer/callPlayerSlice";
|
import { setLive, setShortName, setFilter } from "../features/callPlayer/callPlayerSlice";
|
||||||
import { getCalls, getOlderCalls, getNewerCalls} 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';
|
||||||
import {
|
import {
|
||||||
@@ -24,7 +24,6 @@ import {
|
|||||||
Button
|
Button
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import "./CallPlayer.css";
|
import "./CallPlayer.css";
|
||||||
//import setupSocket from '../socket/SetupSocket.js'
|
|
||||||
import queryString from '../query-string';
|
import queryString from '../query-string';
|
||||||
import io from 'socket.io-client';
|
import io from 'socket.io-client';
|
||||||
import { setDateFilter } from "./call-actions";
|
import { setDateFilter } from "./call-actions";
|
||||||
@@ -59,7 +58,6 @@ function CallPlayer (props) {
|
|||||||
const [prevScrollHeight, setPrevScrollHeight] = useState(0);
|
const [prevScrollHeight, setPrevScrollHeight] = useState(0);
|
||||||
const [playTime, setPlayTime] = useState(0);
|
const [playTime, setPlayTime] = useState(0);
|
||||||
const [selectLoadCall, setSelectLoadCall] = useState(false);
|
const [selectLoadCall, setSelectLoadCall] = useState(false);
|
||||||
const [callSelect, setCallSelect] = useState(false);
|
|
||||||
const [urlOptions, setUrlOptions] = useState(false);
|
const [urlOptions, setUrlOptions] = useState(false);
|
||||||
const [isPlaying, setIsPlaying] = useState(false);
|
const [isPlaying, setIsPlaying] = useState(false);
|
||||||
const [sidebarOpened, setSidebarOpened] = useState(false);
|
const [sidebarOpened, setSidebarOpened] = useState(false);
|
||||||
@@ -126,11 +124,6 @@ function CallPlayer (props) {
|
|||||||
console.log("Somehow called, callEnded() but callsData was false");
|
console.log("Somehow called, callEnded() but callsData was false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*const changeUrl = url => callActions.changeUrl(url)
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
const getFilterDescription = () => {
|
const getFilterDescription = () => {
|
||||||
|
|
||||||
@@ -155,13 +148,14 @@ const getFilterDescription = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const addCall = (data) =>{
|
const handleSocketMessage = (data) => {
|
||||||
const message = JSON.parse(data)
|
const message = JSON.parse(data)
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case 'calls':
|
case 'calls':
|
||||||
const ref = positionRef;
|
const ref = positionRef;
|
||||||
setPrevScrollHeight(positionRef.clientHeight);
|
setPrevScrollHeight(positionRef.clientHeight);
|
||||||
setAddCallScroll(true);
|
setAddCallScroll(true);
|
||||||
|
dispatch(addCall(message))
|
||||||
/*const refs = this.refs.current;
|
/*const refs = this.refs.current;
|
||||||
callActions.addCall(message);
|
callActions.addCall(message);
|
||||||
const newCall = callsById[callsAllIds[0]];
|
const newCall = callsById[callsAllIds[0]];
|
||||||
@@ -181,32 +175,6 @@ const getFilterDescription = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
socket.on('connect', () => {
|
|
||||||
setIsConnected(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('disconnect', () => {
|
|
||||||
setIsConnected(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('reconnect', (attempts) => {
|
|
||||||
console.log("Socket Reconnected after attempts: " + attempts); // true
|
|
||||||
|
|
||||||
if (live) {
|
|
||||||
this.startSocket();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
socket.on("new message", addCall);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
socket.off('connect');
|
|
||||||
socket.off('disconnect');
|
|
||||||
socket.off('pong');
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const startSocket = () => {
|
const startSocket = () => {
|
||||||
const filter = getFilterDescription();
|
const filter = getFilterDescription();
|
||||||
socket.emit("start", {
|
socket.emit("start", {
|
||||||
@@ -313,8 +281,7 @@ const updateUri = () => {
|
|||||||
if (uri.hasOwnProperty('starred')) {
|
if (uri.hasOwnProperty('starred')) {
|
||||||
const starred = uri['starred'];
|
const starred = uri['starred'];
|
||||||
filter.filterStarred = starred === 'true' ? true : false;
|
filter.filterStarred = starred === 'true' ? true : false;
|
||||||
|
if (!urlOptions) setUrlOptions(true);
|
||||||
this.setState({ urlOptions: true });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// is there a time based filter?
|
// is there a time based filter?
|
||||||
@@ -322,7 +289,7 @@ const updateUri = () => {
|
|||||||
const date = new Date(parseInt(uri['time']));
|
const date = new Date(parseInt(uri['time']));
|
||||||
filter.filterDate = date.getTime();
|
filter.filterDate = date.getTime();
|
||||||
filter.live = false;
|
filter.live = false;
|
||||||
this.setState({ urlOptions: true });
|
if (!urlOptions) setUrlOptions(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// is this just for one call?
|
// is this just for one call?
|
||||||
@@ -332,13 +299,7 @@ const updateUri = () => {
|
|||||||
setLoadCallId(_id);
|
setLoadCallId(_id);
|
||||||
setSelectLoadCall(true);
|
setSelectLoadCall(true);
|
||||||
setAutoPlay(false);
|
setAutoPlay(false);
|
||||||
this.setState({
|
if (!urlOptions) setUrlOptions(true);
|
||||||
callId: _id,
|
|
||||||
urlOptions: true,
|
|
||||||
autoPlay: false,
|
|
||||||
callScroll: true,
|
|
||||||
callSelect: true
|
|
||||||
});
|
|
||||||
//callActions.fetchCallInfo(_id);
|
//callActions.fetchCallInfo(_id);
|
||||||
//callActions.setCallTime(date);
|
//callActions.setCallTime(date);
|
||||||
}
|
}
|
||||||
@@ -349,7 +310,7 @@ const updateUri = () => {
|
|||||||
|
|
||||||
// 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'))) {
|
||||||
this.setState({ urlOptions: true });
|
if (!urlOptions) setUrlOptions(true);
|
||||||
|
|
||||||
// The Filter is a group
|
// The Filter is a group
|
||||||
if (uri['filter-type'] === "group") {
|
if (uri['filter-type'] === "group") {
|
||||||
@@ -402,43 +363,51 @@ const updateUri = () => {
|
|||||||
}, [callsData])
|
}, [callsData])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// When a time/date is provided in the URL, it will be added to the filter
|
|
||||||
// When fetchCalls is called it will selected calls that are older
|
|
||||||
//callActions.fetchCalls();
|
|
||||||
//talkgroupActions.fetchTalkgroups(shortName);
|
|
||||||
//groupActions.fetchGroups(shortName);
|
|
||||||
//systemActions.fetchSystems();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setStateFromUri();
|
setStateFromUri();
|
||||||
//console.log("Setting short name to: " + shortName)
|
|
||||||
//dispatch(setShortName(shortName));
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
//this.endSocket();
|
stopSocket();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
socket.on('connect', () => {
|
||||||
|
setIsConnected(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('disconnect', () => {
|
||||||
|
setIsConnected(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('reconnect', (attempts) => {
|
||||||
|
console.log("Socket Reconnected after attempts: " + attempts); // true
|
||||||
|
|
||||||
|
if (live) {
|
||||||
|
this.startSocket();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
socket.on("new message", handleSocketMessage);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
socket.off('connect');
|
||||||
|
socket.off('disconnect');
|
||||||
|
socket.off('pong');
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateUri();
|
|
||||||
dispatch(getCalls({}));
|
dispatch(getCalls({}));
|
||||||
if (live) {
|
if (live) {
|
||||||
startSocket();
|
startSocket();
|
||||||
}
|
}
|
||||||
//dispatch(getOlderCalls());
|
|
||||||
}, [shortName, filterGroupId, filterTalkgroups, filterType, filterDate, filterStarred])
|
}, [shortName, filterGroupId, filterTalkgroups, filterType, filterDate, filterStarred])
|
||||||
|
|
||||||
|
|
||||||
|
// Update the Browser URI when any relevant values change
|
||||||
|
useEffect(() => {
|
||||||
|
updateUri();
|
||||||
|
}, [filterGroupId, filterTalkgroups, filterType, filterDate, filterStarred, loadCallId])
|
||||||
|
|
||||||
const compareArray = (a1, a2) => {
|
|
||||||
var i = a1.length;
|
|
||||||
while (i--) {
|
|
||||||
if (a1[i] !== a2[i])
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!urlOptions && groupsData && (groupsData.length > 0)) {
|
if (!urlOptions && groupsData && (groupsData.length > 0)) {
|
||||||
@@ -446,83 +415,14 @@ const updateUri = () => {
|
|||||||
}
|
}
|
||||||
}, [groupsData])
|
}, [groupsData])
|
||||||
|
|
||||||
/*
|
|
||||||
componentWillUpdate(nextProps, nextState) {
|
|
||||||
|
|
||||||
|
|
||||||
const callsChanged = nextProps.callsAllIds[0] !== callsAllIds[0];
|
|
||||||
if (callsChanged) {
|
|
||||||
const { contextRef } = this.state;
|
|
||||||
this.scrollPos = contextRef.scrollTop;
|
|
||||||
this.prevHeight = contextRef.clientHeight;
|
|
||||||
this.autoScroll = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (callId && !callUrl) {
|
|
||||||
const call = callsById[callId];
|
|
||||||
if (call) {
|
|
||||||
this.setState({ callUrl: call.url });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
|
||||||
const { contextRef } = this.state
|
|
||||||
//console.log( contextRef.clientHeight - this.prevHeight );
|
|
||||||
if (this.autoScroll) {
|
|
||||||
this.autoScroll = false;
|
|
||||||
window.scrollBy(0, contextRef.clientHeight - this.prevHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
// scroll to a call once the calls have loaded
|
|
||||||
if (callScroll && (callsAllIds.length > prevProps.callsAllIds.length)) {
|
|
||||||
const call = callsById[callId];
|
|
||||||
if (call) {
|
|
||||||
this.setState({ callScroll: false });
|
|
||||||
if (this.currentCallRef.current) {
|
|
||||||
this.currentCallRef.current.scrollIntoView({
|
|
||||||
behavior: "auto",
|
|
||||||
block: "center",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.scrollPos = contextRef.scrollTop;
|
|
||||||
this.prevHeight = contextRef.clientHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callSelect) {
|
|
||||||
const call = callsById[callId];
|
|
||||||
if (call) {
|
|
||||||
const audio = this.audioRef.current;
|
|
||||||
var callUrl = call.url;
|
|
||||||
this.setState({
|
|
||||||
callUrl: callUrl,
|
|
||||||
isPlaying: true,
|
|
||||||
callSelect: false
|
|
||||||
}, () => { audio.playSource(callUrl); }); //scrollToComponent(this.currentCallRef.current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//https://stackoverflow.com/questions/36559661/how-can-i-dispatch-from-child-components-in-react-redux
|
|
||||||
//https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter
|
|
||||||
|
|
||||||
//const { contextRef } = this.state
|
|
||||||
|
|
||||||
var archiveLabel = "";
|
var archiveLabel = "";
|
||||||
if (filterDate) {
|
if (filterDate) {
|
||||||
const filterDate = new Date(filterDate);
|
const filterDateObj = new Date(filterDate);
|
||||||
archiveLabel = filterDate.toLocaleDateString() + " " + filterDate.toLocaleTimeString()
|
archiveLabel = filterDateObj.toLocaleDateString() + " " + filterDateObj.toLocaleTimeString()
|
||||||
}
|
}
|
||||||
|
|
||||||
var callInfoHeader = "Call Info";
|
var callInfoHeader = "Call Info";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var callsAllIds = [];
|
|
||||||
var callsById = false;
|
|
||||||
var callLink = ""
|
var callLink = ""
|
||||||
var callDownload = ""
|
var callDownload = ""
|
||||||
if (currentCall) {
|
if (currentCall) {
|
||||||
@@ -530,10 +430,25 @@ const updateUri = () => {
|
|||||||
callInfoHeader = talkgroupsData[currentCall.talkgroupNum].description;
|
callInfoHeader = talkgroupsData[currentCall.talkgroupNum].description;
|
||||||
}
|
}
|
||||||
const callDate = new Date(currentCall.time);
|
const callDate = new Date(currentCall.time);
|
||||||
callLink = "/system/" + shortName + "?call-id=" + currentCall._id + "&time=" + (callDate.getTime() + 1);
|
var search = ""
|
||||||
|
switch (filterType) {
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
search = `filter-type=group&filter-code=${filterGroupId}&`;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
search = `filter-type=talkgroup&filter-code=${filterTalkgroups}&`;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
callLink = "/system/" + shortName + "?" + search + "call-id=" + currentCall._id + "&time=" + (callDate.getTime() + 1);
|
||||||
callDownload = currentCall.url;
|
callDownload = currentCall.url;
|
||||||
}
|
}
|
||||||
var archive = process.env.REACT_APP_ARCHIVE_DAYS
|
|
||||||
|
const archive = process.env.REACT_APP_ARCHIVE_DAYS
|
||||||
|
|
||||||
var filterLabel = "All"
|
var filterLabel = "All"
|
||||||
switch (filterType) {
|
switch (filterType) {
|
||||||
@@ -548,12 +463,6 @@ const updateUri = () => {
|
|||||||
case 0:
|
case 0:
|
||||||
filterLabel = "All"
|
filterLabel = "All"
|
||||||
}
|
}
|
||||||
/* if (calls) {
|
|
||||||
var callRows = calls.map((call) =>
|
|
||||||
<CallItem call={call} key={call.shortName}/>
|
|
||||||
))
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={positionRef}>
|
<div ref={positionRef}>
|
||||||
@@ -599,9 +508,6 @@ const updateUri = () => {
|
|||||||
</Menu.Menu>
|
</Menu.Menu>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Container className="main">
|
<Container className="main">
|
||||||
<Sidebar.Pushable>
|
<Sidebar.Pushable>
|
||||||
<Sidebar.Pusher
|
<Sidebar.Pusher
|
||||||
@@ -633,11 +539,6 @@ const updateUri = () => {
|
|||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,44 @@ const initialState = {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const addStar = createAsyncThunk(
|
||||||
|
'calls/addStar',
|
||||||
|
async(callId,{getState, requestIdleCallback}) => {
|
||||||
|
const {shortName} = getState().callPlayer;
|
||||||
|
const url = process.env.REACT_APP_BACKEND_SERVER + "/" + shortName.toLowerCase() + "/star/" + callId
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
|
body: "{}"
|
||||||
|
|
||||||
|
}).then(
|
||||||
|
(data) => data.json()
|
||||||
|
)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export const removeStar = createAsyncThunk(
|
||||||
|
'calls/removeStar',
|
||||||
|
async(callId,{getState, requestIdleCallback}) => {
|
||||||
|
const {shortName} = getState().callPlayer;
|
||||||
|
const url = process.env.REACT_APP_BACKEND_SERVER + "/" + shortName.toLowerCase() + "/removeStar/" + callId
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
|
body: "{}"
|
||||||
|
|
||||||
|
}).then(
|
||||||
|
(data) => data.json()
|
||||||
|
)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
export const getCalls = createAsyncThunk(
|
export const getCalls = createAsyncThunk(
|
||||||
'calls/getCalls',
|
'calls/getCalls',
|
||||||
async({},{getState, requestId}) => {
|
async({},{getState, requestId}) => {
|
||||||
@@ -162,7 +200,12 @@ export const getCalls = createAsyncThunk(
|
|||||||
export const callsSlice = createSlice({
|
export const callsSlice = createSlice({
|
||||||
name: 'calls',
|
name: 'calls',
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {},
|
reducers: {
|
||||||
|
|
||||||
|
addCall: (call) => {
|
||||||
|
state.data = callsAdapter.addOne(state.data, call)
|
||||||
|
},
|
||||||
|
},
|
||||||
extraReducers: {
|
extraReducers: {
|
||||||
[getCalls.pending]: (state) => {
|
[getCalls.pending]: (state) => {
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
@@ -218,6 +261,12 @@ export const callsSlice = createSlice({
|
|||||||
state.oldestCallTime = new Date(lastTime)
|
state.oldestCallTime = new Date(lastTime)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
[addStar.fulfilled]: (state, {payload}) => {
|
||||||
|
state.data.entities[payload.call._id] = payload.call;
|
||||||
|
},
|
||||||
|
[removeStar.fulfilled]: (state, {payload}) => {
|
||||||
|
state.data.entities[payload.call._id] = payload.call;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user