initial commit

This commit is contained in:
Luke Berndt
2024-02-02 22:09:37 -05:00
parent 75cb239a6c
commit 85864f4b84
13 changed files with 421 additions and 289 deletions

View File

@@ -18,6 +18,7 @@ exports.getUserSystems = async function (_id) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -31,6 +32,7 @@ exports.getUserSystems = async function (_id) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,

View File

@@ -10,6 +10,7 @@ var systemSchema = mongoose.Schema({
city: String, city: String,
state: String, state: String,
description: String, description: String,
status: String,
showScreenName: Boolean, showScreenName: Boolean,
planType: {type: Number, default: 0}, planType: {type: Number, default: 0},
userId: mongoose.Schema.Types.ObjectId, userId: mongoose.Schema.Types.ObjectId,

View File

@@ -62,7 +62,7 @@ exports.listUserSystems = async function (req,res,next) {
for (let index = 0; index < users.length; index++) { for (let index = 0; index < users.length; index++) {
let user = users[index].toObject(); let user = users[index].toObject();
const userId = new mongoose.Types.ObjectId(user._id); const userId = new mongoose.Types.ObjectId(user._id);
const systems = await System.find({ userId: userId }, "name shortName description systemType city state county country lastActive"); const systems = await System.find({ userId: userId }, "name shortName description status systemType city state county country lastActive");
user["systems"] = systems; user["systems"] = systems;
list.push(user); list.push(user);
@@ -90,6 +90,7 @@ exports.listAllSystems = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -106,6 +107,7 @@ exports.listAllSystems = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -154,6 +156,7 @@ exports.listSystems = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -168,6 +171,7 @@ exports.listSystems = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -360,6 +364,7 @@ exports.updateSystem = async function (req, res, next) {
res.locals.system.county = res.locals.county; res.locals.system.county = res.locals.county;
res.locals.system.country = res.locals.country; res.locals.system.country = res.locals.country;
res.locals.system.description = res.locals.description; res.locals.system.description = res.locals.description;
res.locals.system.status = res.locals.status;
res.locals.system.systemType = res.locals.systemType; res.locals.system.systemType = res.locals.systemType;
res.locals.system.showScreenName = res.locals.showScreenName; res.locals.system.showScreenName = res.locals.showScreenName;
res.locals.system.allowContact = res.locals.allowContact; res.locals.system.allowContact = res.locals.allowContact;
@@ -378,6 +383,7 @@ exports.updateSystem = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -392,6 +398,7 @@ exports.updateSystem = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -429,7 +436,7 @@ exports.validateSystem = async function (req, res, next) {
res.locals.name = req.body.name.replace(/[^\w\s\.\,\-\_]/gi, ''); res.locals.name = req.body.name.replace(/[^\w\s\.\,\-\_]/gi, '');
if (!req.body.description || (req.body.description.length < 2)) { if (!req.body.description || (req.body.description.length < 2)) {
console.error("ERROR: Validate System - req.body.description"); console.error("ERROR: Validate System - req.body.description: " + req.body.description);
res.status(500) res.status(500)
res.json({ res.json({
success: false, success: false,
@@ -437,7 +444,9 @@ exports.validateSystem = async function (req, res, next) {
}); });
return; return;
} }
res.locals.description = req.body.description.replace(/[^\w\s\.\,\-\_]/gi, ''); res.locals.description = req.body.description.replace(/[^\w\s\.\,\-\_\(\)\'\"\!\?\*\&\^\%\$\#\@\r\n\t\`\~\[\]\/\\]/gi, '');
res.locals.status = req.body.status.replace(/[^\w\s\.\,\-\_\(\)\'\"\!\?\*\&\^\%\$\#\@\r\n\t\`\~\[\]\/\\]/gi, '');
if (!req.body.shortName || (req.body.shortName.length < 2)) { if (!req.body.shortName || (req.body.shortName.length < 2)) {
console.error("ERROR: Validate System - req.body.shortName"); console.error("ERROR: Validate System - req.body.shortName");
@@ -547,6 +556,7 @@ exports.createSystem = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -559,6 +569,7 @@ exports.createSystem = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -585,6 +596,7 @@ exports.createSystem = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,
@@ -599,6 +611,7 @@ exports.createSystem = async function (req, res, next) {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state, state,

View File

@@ -11,6 +11,7 @@ var systemSchema = mongoose.Schema({
city: String, city: String,
state: String, state: String,
description: String, description: String,
status: String,
showScreenName: Boolean, showScreenName: Boolean,
allowContact: { allowContact: {
type: Boolean, type: Boolean,

View File

@@ -236,7 +236,6 @@ const System = () => {
setGroupOrder(newOrder); setGroupOrder(newOrder);
} }
}, [groupsData]) }, [groupsData])
useEffect(() => { useEffect(() => {
if (isSystemsSuccess && systemsData.stats[shortName]) { if (isSystemsSuccess && systemsData.stats[shortName]) {
processStatistics(systemsData.stats[shortName]) processStatistics(systemsData.stats[shortName])
@@ -328,7 +327,12 @@ const System = () => {
<Header size="small">Description</Header> <Header size="small">Description</Header>
{system.description} {system.description}
</Segment> </Segment>
{system.status.length>0 &&
<Segment>
<Header size="small">Status Message</Header>
{system.status}
</Segment>
}
<Segment clearing={true}> <Segment clearing={true}>
<Button <Button
color="red" color="red"

View File

@@ -18,6 +18,8 @@ const SystemForm = (props) => {
const [name, setName] = useState(""); const [name, setName] = useState("");
const [shortName, setShortName] = useState(""); const [shortName, setShortName] = useState("");
const [description, setDescription] = useState(""); const [description, setDescription] = useState("");
const [status, setStatus] = useState("");
const [showStatus, setShowStatus] = useState(false);
const [systemType, setSystemType] = useState("state"); const [systemType, setSystemType] = useState("state");
const [systemState, setSystemState] = useState(""); const [systemState, setSystemState] = useState("");
const [city, setCity] = useState(""); const [city, setCity] = useState("");
@@ -29,6 +31,7 @@ const SystemForm = (props) => {
const [nameError, setNameError] = useState(false); const [nameError, setNameError] = useState(false);
const [shortNameError, setShortNameError] = useState(false); const [shortNameError, setShortNameError] = useState(false);
const [descriptionError, setDescriptionError] = useState(false); const [descriptionError, setDescriptionError] = useState(false);
const [statusError, setStatusError] = useState(false);
const [systemStateError, setSystemStateError] = useState(false); const [systemStateError, setSystemStateError] = useState(false);
const [cityError, setCityError] = useState(false); const [cityError, setCityError] = useState(false);
const [countyError, setCountyError] = useState(false); const [countyError, setCountyError] = useState(false);
@@ -40,6 +43,8 @@ const SystemForm = (props) => {
setName(props.system.name); setName(props.system.name);
setShortName(props.system.shortName); setShortName(props.system.shortName);
setDescription(props.system.description); setDescription(props.system.description);
setStatus(props.system.status);
setShowStatus(props.system.status.length > 0);
setSystemType(props.system.systemType); setSystemType(props.system.systemType);
setCity(props.system.city); setCity(props.system.city);
setSystemState(props.system.state) setSystemState(props.system.state)
@@ -82,6 +87,14 @@ const SystemForm = (props) => {
setDescriptionError(false); setDescriptionError(false);
} }
if (showStatus && status.length < 4) {
setStatusError(true);
messages.push("If showing a aStatus message it must be at least 4 characters");
error = true;
} else {
setStatusError(false);
}
if ( if (
systemType === "state" || systemType === "state" ||
systemType === "city" || systemType === "city" ||
@@ -130,12 +143,17 @@ const SystemForm = (props) => {
return error; return error;
} }
const handleShowStatusCheckboxChange = () => {
if (showStatus) {
setStatus("");
}
setShowStatus((current) => !current);
}
const handleAllowContactCheckboxChange = () => { const handleAllowContactCheckboxChange = () => {
setAllowContact((current) => !current); setAllowContact((current) => !current);
} }
const handleScreenNameCheckboxChange = () => { const handleScreenNameCheckboxChange = () => {
setShowScreenName((current) => !current); setShowScreenName((current) => !current);
} }
@@ -152,6 +170,7 @@ const SystemForm = (props) => {
name, name,
shortName, shortName,
description, description,
status,
systemType, systemType,
city, city,
state: systemState, state: systemState,
@@ -303,7 +322,24 @@ const SystemForm = (props) => {
rows={2} rows={2}
placeholder="Description of system..." placeholder="Description of system..."
/> />
<Divider horizontal> System Status </Divider>
<Form.Field>
<Checkbox
onChange={handleShowStatusCheckboxChange}
checked={showStatus}
label="Show Status Message" />
</Form.Field>
<Form.TextArea
label="Status Message"
name="status"
onChange={e => setStatus(e.target.value)}
error={statusError}
value={status}
disabled={!showStatus}
rows={1}
placeholder="System status..."
/>
Only needed if things are not working. Provide notification on maintenance or is you know if some channels are not available.
<Divider horizontal><Icon name="marker" />Location</Divider> <Divider horizontal><Icon name="marker" />Location</Divider>
<Form.Group inline> <Form.Group inline>
<label>System Type</label> <label>System Type</label>

View File

@@ -127,6 +127,7 @@ exports.get_systems = async function (req, res) {
lastActive: results[result].lastActive, lastActive: results[result].lastActive,
callAvg: results[result].callAvg, callAvg: results[result].callAvg,
description: results[result].description, description: results[result].description,
status: results[result].status,
allowContact: results[result].allowContact, allowContact: results[result].allowContact,
clientCount: clientCount clientCount: clientCount
} }

View File

@@ -11,6 +11,7 @@ var systemSchema = mongoose.Schema({
city: String, city: String,
state: String, state: String,
description: String, description: String,
status: String,
showScreenName: Boolean, showScreenName: Boolean,
allowContact: { allowContact: {
type: Boolean, type: Boolean,

View File

@@ -14,13 +14,16 @@ import {
Sticky, Sticky,
Menu, Menu,
Icon, Icon,
Sidebar Sidebar,
Message,
MessageHeader
} from "semantic-ui-react"; } from "semantic-ui-react";
import "./CallPlayer.css"; import "./CallPlayer.css";
import queryString from '../query-string'; import queryString from '../query-string';
import io from 'socket.io-client'; import io from 'socket.io-client';
import { useCallLink } from "./components/CallLinks"; import { useCallLink } from "./components/CallLinks";
import "./CallPlayer.css"; import "./CallPlayer.css";
import { set } from "date-fns";
const socket = io(process.env.REACT_APP_BACKEND_SERVER); const socket = io(process.env.REACT_APP_BACKEND_SERVER);
@@ -30,6 +33,7 @@ const socket = io(process.env.REACT_APP_BACKEND_SERVER);
function CallPlayer(props) { function CallPlayer(props) {
const { shortName } = useParams(); const { shortName } = useParams();
const system = props.system;
const selectCallId = props.selectCallId; const selectCallId = props.selectCallId;
const callsData = props.callsData; const callsData = props.callsData;
const handleNewer = props.handleNewer; const handleNewer = props.handleNewer;
@@ -45,6 +49,7 @@ function CallPlayer(props) {
const backgroundAutoplay = useSelector((state) => state.callPlayer.backgroundAutoplay); const backgroundAutoplay = useSelector((state) => state.callPlayer.backgroundAutoplay);
const { data: talkgroupsData, isSuccess: isTalkgroupsSuccess } = useGetTalkgroupsQuery(shortName); const { data: talkgroupsData, isSuccess: isTalkgroupsSuccess } = useGetTalkgroupsQuery(shortName);
const [statusVisible, setStatusVisible] = useState(false);
const [autoPlay, setAutoPlay] = useState(true); const [autoPlay, setAutoPlay] = useState(true);
const [currentCall, setCurrentCall] = useState(false); const [currentCall, setCurrentCall] = useState(false);
const [isPlaying, setIsPlaying] = useState(false); const [isPlaying, setIsPlaying] = useState(false);
@@ -160,15 +165,31 @@ useEffect(() => {
} }
}, [selectCallId]) }, [selectCallId])
useEffect(() => {
if (system.status && system.status.length > 0) {
setStatusVisible(true);
}
}, [system])
const handleStatusDismiss = () => {
setStatusVisible(false);
}
return ( return (
<div ref={positionRef}> <div ref={positionRef}>
<Container className="main" > <Container className="main" >
{statusVisible &&
<Sticky offset={60} context={positionRef}>
<Message floating onDismiss={handleStatusDismiss} warning> <MessageHeader>System Status</MessageHeader>{system.status}</Message>
</Sticky>
}
<Sidebar.Pushable> <Sidebar.Pushable>
<Sidebar.Pusher <Sidebar.Pusher
style={{ minHeight: '100vh' }} style={{ minHeight: '100vh' }}
> >
<div ref={loadNewerRef} /> <div ref={loadNewerRef} />
<ListCalls callsData={callsData} activeCallId={currentCallId} talkgroups={talkgroupsData ? talkgroupsData.talkgroups : false} playCall={playCall} /> <ListCalls callsData={callsData} activeCallId={currentCallId} talkgroups={talkgroupsData ? talkgroupsData.talkgroups : false} playCall={playCall} />
<div ref={loadOlderRef} style={{ height: 50 }} /> <div ref={loadOlderRef} style={{ height: 50 }} />
</Sidebar.Pusher> </Sidebar.Pusher>

View File

@@ -14,7 +14,9 @@ import {
Label, Label,
Menu, Menu,
Icon, Icon,
Sidebar Sidebar,
Message,
Sticky
} from "semantic-ui-react"; } from "semantic-ui-react";
import "./CallPlayer.css"; import "./CallPlayer.css";
import queryString from '../query-string'; import queryString from '../query-string';
@@ -447,9 +449,10 @@ function Calls(props) {
</Menu.Item> </Menu.Item>
</Menu.Menu> </Menu.Menu>
</Menu> </Menu>
{activityVisible {activityVisible
? <Activity navigate={handleActivityNavigate} /> ? <Activity navigate={handleActivityNavigate} />
: <CallPlayer callsData={callsData} selectCallId={selectCallId} initialCallId={initialCallId} handleNewer={handleNewer} handleOlder={handleOlder} /> : <CallPlayer system={system} callsData={callsData} selectCallId={selectCallId} initialCallId={initialCallId} handleNewer={handleNewer} handleOlder={handleOlder} />
} }
</div> </div>
); );

View File

@@ -5,6 +5,8 @@ import "./Main.css";
import { createMedia } from "@artsy/fresnel"; import { createMedia } from "@artsy/fresnel";
import { import {
Button, Button,
ButtonGroup,
ButtonContent,
Container, Container,
Divider, Divider,
Grid, Grid,
@@ -98,7 +100,8 @@ const DesktopContainer = (props) => {
</div> </div>
<Segment <Segment
textAlign='center' textAlign='center'
style={{ padding: '1em 0em', style={{
padding: '1em 0em',
borderBottom: '0px', borderBottom: '0px',
boxShadow: 'none', boxShadow: 'none',
height: '400px' height: '400px'
@@ -170,10 +173,12 @@ const MobileContainer = (props) => {
</div> </div>
<Segment <Segment
textAlign='center' textAlign='center'
style={{ minHeight: 350, padding: '1em 0em', style={{
minHeight: 350, padding: '1em 0em',
borderBottom: '0px', borderBottom: '0px',
boxShadow: 'none', boxShadow: 'none',
height: '300px'}} height: '300px'
}}
vertical vertical
> >
@@ -263,7 +268,7 @@ const Main = (props) => {
<style>{mediaStyles}</style> <style>{mediaStyles}</style>
<ResponsiveContainer> <ResponsiveContainer>
<div style={{ top: '-120px', position: 'relative' }}> <div style={{ top: '-120px', position: 'relative' }}>
<Segment style={{ padding: ' 0em', height: '350px', backgroudColor: '#FFF'}} vertical> <Segment style={{ padding: ' 0em', height: '350px', backgroudColor: '#FFF' }} vertical basic>
<Grid columns='equal' stackable textAlign='center' style={{ height: '350px', marginRight: '0px' }}> <Grid columns='equal' stackable textAlign='center' style={{ height: '350px', marginRight: '0px' }}>
<Grid.Row textAlign='center'> <Grid.Row textAlign='center'>
<Grid.Column style={{ paddingBottom: '4em', paddingTop: '2em', maxWidth: 450 }}> <Grid.Column style={{ paddingBottom: '4em', paddingTop: '2em', maxWidth: 450 }}>
@@ -285,6 +290,30 @@ const Main = (props) => {
</Grid.Row> </Grid.Row>
</Grid> </Grid>
</Segment> </Segment>
<Segment style={{ padding: '0em' }} vertical>
<Grid columns='equal' stackable textAlign='center' style={{ height: '150px', marginRight: '0px' }}>
<Grid.Row textAlign='center'>
<Grid.Column style={{ paddingBottom: '4em', paddingTop: '2em', maxWidth: 450 }}>
<ButtonGroup size='large'>
<Button color='red' animated='fade' href="https://patreon.com/OpenMHz">
<ButtonContent visible>
<Icon name='heart' /> Donate
</ButtonContent>
<ButtonContent hidden>Thank You</ButtonContent>
</Button>
<Button href="https://podcasts.apple.com/us/podcast/openmhz/id1675187518">
<Icon name='podcast' /> Events Podcast
</Button>
<Button href="https://apps.apple.com/us/app/openmhz/id6466666994">
<Icon name='app store ios' /> iOS App
</Button>
</ButtonGroup>
</Grid.Column>
</Grid.Row>
</Grid>
</Segment>
<Segment style={{ padding: '0em' }} vertical> <Segment style={{ padding: '0em' }} vertical>
<Grid celled='internally' columns='equal' stackable> <Grid celled='internally' columns='equal' stackable>

View File

@@ -3,7 +3,10 @@ import {
Card, Card,
Icon, Icon,
Label, Label,
Grid Grid,
Segment,
Popup,
Button
} from "semantic-ui-react"; } from "semantic-ui-react";
@@ -14,6 +17,15 @@ function SystemCard (props) {
var clientCount = ""; var clientCount = "";
var callAvg = ""; var callAvg = "";
let description = system.description; let description = system.description;
let statusMessage = "";
if (system.status && system.status.length > 0) {
statusMessage = system.status
if (statusMessage.length > 25) {
statusMessage = statusMessage.substring(0, 25) + "...";
}
}
@@ -29,6 +41,14 @@ function SystemCard (props) {
if (keepShort && (description.length > 100)) { if (keepShort && (description.length > 100)) {
description = description.substring(0, 96) + "..."; description = description.substring(0, 96) + "...";
} }
if (keepShort) {
statusMessage = "";
}
if (system.callAvg) { if (system.callAvg) {
callAvg = Math.round(system.callAvg * 10) / 10 + "/min" callAvg = Math.round(system.callAvg * 10) / 10 + "/min"
} }
@@ -103,6 +123,15 @@ function SystemCard (props) {
{description} {description}
</Grid.Column> </Grid.Column>
</Grid.Row> </Grid.Row>
{statusMessage.length &&
<Grid.Row>
<Grid.Column>
<Popup content={system.status} trigger={<Button icon labelPosition='left' size='mini'><Icon name="info"/>{statusMessage}</Button>} />
</Grid.Column>
</Grid.Row>
}
</Grid> </Grid>
</Card.Description> </Card.Description>
</Card.Content> </Card.Content>

View File

@@ -1,12 +1,3 @@
server {
listen 80;
server_name account.${DOMAIN_NAME} api.${DOMAIN_NAME} admin.${DOMAIN_NAME} www.${DOMAIN_NAME} ${DOMAIN_NAME};
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
}
server { server {
listen 80; listen 80;