From 350c83c259834b857af4755420c22b56e168bc5a Mon Sep 17 00:00:00 2001 From: Tad Smith Date: Fri, 13 Dec 2024 20:46:06 +0000 Subject: [PATCH] Save patch infomation for calls. --- backend/controllers/calls.js | 2 ++ backend/controllers/uploads.js | 14 ++++++++++++++ backend/models/callSchema.js | 1 + frontend/src/Call/components/CallInfoPane.js | 17 ++++++++++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/backend/controllers/calls.js b/backend/controllers/calls.js index 573a829..6c0696d 100644 --- a/backend/controllers/calls.js +++ b/backend/controllers/calls.js @@ -20,6 +20,7 @@ const build_call_list = (items) => { srcList: item.srcList, star: item.star, freq: item.freq, + patches: item.patches, len: Math.round(item.len) }; calls.push(call); @@ -38,6 +39,7 @@ async function get_calls(query, numResults, middleDate, res) { time: true, srcList: true, freq: true, + patches: true, star: true, len: true, url: true diff --git a/backend/controllers/uploads.js b/backend/controllers/uploads.js index 2a2ef74..3f051f6 100644 --- a/backend/controllers/uploads.js +++ b/backend/controllers/uploads.js @@ -108,6 +108,19 @@ exports.upload = async function (req, res, next) { return; } + patches = []; + + let req_patches; + req_patches = req.body.patch_list; + + if(typeof req_patches != "undefined"){ + var split_patches = req_patches.replace("[","").replace("]","").split(","); + + for (var patch in split_patches){ + patches.push(split_patches[patch]); + } + } + let item = null; await tracer.startActiveSpan('validate_system', { parent: trace.getActiveSpan(context.active()) }, async (validateSpan) => { @@ -178,6 +191,7 @@ exports.upload = async function (req, res, next) { url, emergency, path: local_path, + patches: patches, srcList, len: req.body.call_length ? parseFloat(req.body.call_length) : (stopTime - time) / 1000, }); diff --git a/backend/models/callSchema.js b/backend/models/callSchema.js index 6dbcebf..c0e6559 100644 --- a/backend/models/callSchema.js +++ b/backend/models/callSchema.js @@ -17,6 +17,7 @@ const callSchema = mongoose.Schema({ emergency: Boolean, path: String, len: Number, + patches: [Number], star: { type: Number, default: 0 diff --git a/frontend/src/Call/components/CallInfoPane.js b/frontend/src/Call/components/CallInfoPane.js index 4ad2bde..fdb581b 100644 --- a/frontend/src/Call/components/CallInfoPane.js +++ b/frontend/src/Call/components/CallInfoPane.js @@ -22,6 +22,8 @@ function CallInfoPane(props) { let callDate = "-"; let callTime = "-"; let talkgroupNum = "-"; + let patches = []; + let patchString = ""; let header = "Call Info" let title = "" const currentCall = props.call ? props.call : false; @@ -51,6 +53,14 @@ function CallInfoPane(props) { srcList = currentCall.srcList.map((source, index) => {source.src}[{source.pos}]); callLength = currentCall.len; talkgroupNum = currentCall.talkgroupNum; + patches = currentCall.patches; + + if(patches.length > 1) { + patchString = patches.join(", "); + } + else{ + patchString = "No Patches"; + } } let system = false; @@ -102,7 +112,6 @@ function CallInfoPane(props) { Talkgroup {talkgroupNum} - @@ -122,6 +131,12 @@ function CallInfoPane(props) { {callFreq} MHz + + + + {patchString} + +