mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 16:57:39 -05:00
initial commit
This commit is contained in:
@@ -62,7 +62,7 @@ exports.listUserSystems = async function (req,res,next) {
|
||||
for (let index = 0; index < users.length; index++) {
|
||||
let user = users[index].toObject();
|
||||
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;
|
||||
list.push(user);
|
||||
@@ -90,6 +90,7 @@ exports.listAllSystems = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -106,6 +107,7 @@ exports.listAllSystems = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -154,6 +156,7 @@ exports.listSystems = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -168,6 +171,7 @@ exports.listSystems = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -360,6 +364,7 @@ exports.updateSystem = async function (req, res, next) {
|
||||
res.locals.system.county = res.locals.county;
|
||||
res.locals.system.country = res.locals.country;
|
||||
res.locals.system.description = res.locals.description;
|
||||
res.locals.system.status = res.locals.status;
|
||||
res.locals.system.systemType = res.locals.systemType;
|
||||
res.locals.system.showScreenName = res.locals.showScreenName;
|
||||
res.locals.system.allowContact = res.locals.allowContact;
|
||||
@@ -378,6 +383,7 @@ exports.updateSystem = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -392,6 +398,7 @@ exports.updateSystem = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -429,7 +436,7 @@ exports.validateSystem = async function (req, res, next) {
|
||||
res.locals.name = req.body.name.replace(/[^\w\s\.\,\-\_]/gi, '');
|
||||
|
||||
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.json({
|
||||
success: false,
|
||||
@@ -437,7 +444,9 @@ exports.validateSystem = async function (req, res, next) {
|
||||
});
|
||||
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)) {
|
||||
console.error("ERROR: Validate System - req.body.shortName");
|
||||
@@ -547,6 +556,7 @@ exports.createSystem = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -559,6 +569,7 @@ exports.createSystem = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -585,6 +596,7 @@ exports.createSystem = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
@@ -599,6 +611,7 @@ exports.createSystem = async function (req, res, next) {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state,
|
||||
|
||||
@@ -11,6 +11,7 @@ var systemSchema = mongoose.Schema({
|
||||
city: String,
|
||||
state: String,
|
||||
description: String,
|
||||
status: String,
|
||||
showScreenName: Boolean,
|
||||
allowContact: {
|
||||
type: Boolean,
|
||||
|
||||
@@ -236,7 +236,6 @@ const System = () => {
|
||||
setGroupOrder(newOrder);
|
||||
}
|
||||
}, [groupsData])
|
||||
|
||||
useEffect(() => {
|
||||
if (isSystemsSuccess && systemsData.stats[shortName]) {
|
||||
processStatistics(systemsData.stats[shortName])
|
||||
@@ -328,7 +327,12 @@ const System = () => {
|
||||
<Header size="small">Description</Header>
|
||||
{system.description}
|
||||
</Segment>
|
||||
|
||||
{system.status.length>0 &&
|
||||
<Segment>
|
||||
<Header size="small">Status Message</Header>
|
||||
{system.status}
|
||||
</Segment>
|
||||
}
|
||||
<Segment clearing={true}>
|
||||
<Button
|
||||
color="red"
|
||||
|
||||
@@ -18,6 +18,8 @@ const SystemForm = (props) => {
|
||||
const [name, setName] = useState("");
|
||||
const [shortName, setShortName] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [status, setStatus] = useState("");
|
||||
const [showStatus, setShowStatus] = useState(false);
|
||||
const [systemType, setSystemType] = useState("state");
|
||||
const [systemState, setSystemState] = useState("");
|
||||
const [city, setCity] = useState("");
|
||||
@@ -29,6 +31,7 @@ const SystemForm = (props) => {
|
||||
const [nameError, setNameError] = useState(false);
|
||||
const [shortNameError, setShortNameError] = useState(false);
|
||||
const [descriptionError, setDescriptionError] = useState(false);
|
||||
const [statusError, setStatusError] = useState(false);
|
||||
const [systemStateError, setSystemStateError] = useState(false);
|
||||
const [cityError, setCityError] = useState(false);
|
||||
const [countyError, setCountyError] = useState(false);
|
||||
@@ -40,6 +43,8 @@ const SystemForm = (props) => {
|
||||
setName(props.system.name);
|
||||
setShortName(props.system.shortName);
|
||||
setDescription(props.system.description);
|
||||
setStatus(props.system.status);
|
||||
setShowStatus(props.system.status.length > 0);
|
||||
setSystemType(props.system.systemType);
|
||||
setCity(props.system.city);
|
||||
setSystemState(props.system.state)
|
||||
@@ -82,6 +87,14 @@ const SystemForm = (props) => {
|
||||
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 (
|
||||
systemType === "state" ||
|
||||
systemType === "city" ||
|
||||
@@ -130,12 +143,17 @@ const SystemForm = (props) => {
|
||||
return error;
|
||||
}
|
||||
|
||||
const handleShowStatusCheckboxChange = () => {
|
||||
if (showStatus) {
|
||||
setStatus("");
|
||||
}
|
||||
setShowStatus((current) => !current);
|
||||
}
|
||||
|
||||
const handleAllowContactCheckboxChange = () => {
|
||||
setAllowContact((current) => !current);
|
||||
}
|
||||
|
||||
|
||||
const handleScreenNameCheckboxChange = () => {
|
||||
setShowScreenName((current) => !current);
|
||||
}
|
||||
@@ -152,6 +170,7 @@ const SystemForm = (props) => {
|
||||
name,
|
||||
shortName,
|
||||
description,
|
||||
status,
|
||||
systemType,
|
||||
city,
|
||||
state: systemState,
|
||||
@@ -303,7 +322,24 @@ const SystemForm = (props) => {
|
||||
rows={2}
|
||||
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>
|
||||
<Form.Group inline>
|
||||
<label>System Type</label>
|
||||
|
||||
Reference in New Issue
Block a user