mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-21 13:15:51 -05:00
ignore unlisted TG
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -50,7 +50,8 @@ exports.listSystems = function (req, res, next) {
|
||||
country,
|
||||
userId,
|
||||
key,
|
||||
showScreenName
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup
|
||||
}) => ({
|
||||
name,
|
||||
shortName,
|
||||
@@ -62,7 +63,8 @@ exports.listSystems = function (req, res, next) {
|
||||
country,
|
||||
userId,
|
||||
key,
|
||||
showScreenName
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup
|
||||
}))(obj);
|
||||
if (obj.showScreenName) {
|
||||
rObj.screenName = req.user.screenName;
|
||||
@@ -203,11 +205,7 @@ exports.ownSystem = async function (req, res, next) {
|
||||
console.error("System: " + system.userId + " User: " + req.user._id);
|
||||
return;
|
||||
}
|
||||
|
||||
res.locals.test = "Yoho!"
|
||||
res.locals.system = system;
|
||||
console.log(system);
|
||||
console.log(res.locals);
|
||||
next();
|
||||
|
||||
} catch (err) {
|
||||
@@ -280,6 +278,7 @@ exports.updateSystem = async function (req, res, next) {
|
||||
res.locals.system.description = res.locals.description;
|
||||
res.locals.system.systemType = res.locals.systemType;
|
||||
res.locals.system.showScreenName = res.locals.showScreenName;
|
||||
res.locals.system.ignoreUnknownTalkgroup = res.locals.ignoreUnknownTalkgroup;
|
||||
|
||||
res.locals.system.save(function (err) {
|
||||
if (err) {
|
||||
@@ -300,7 +299,8 @@ exports.updateSystem = async function (req, res, next) {
|
||||
country,
|
||||
userId,
|
||||
key,
|
||||
showScreenName
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup
|
||||
}) => ({
|
||||
name,
|
||||
shortName,
|
||||
@@ -312,7 +312,8 @@ exports.updateSystem = async function (req, res, next) {
|
||||
country,
|
||||
userId,
|
||||
key,
|
||||
showScreenName
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup
|
||||
}))(res.locals.system);
|
||||
returnSys.id = res.locals.system._id;
|
||||
res.json({
|
||||
@@ -329,7 +330,7 @@ exports.updateSystem = async function (req, res, next) {
|
||||
exports.validateSystem = async function (req, res, next) {
|
||||
try {
|
||||
res.locals.showScreenName = req.body.showScreenName;
|
||||
|
||||
res.locals.ignoreUnknownTalkgroup = req.body.ignoreUnknownTalkgroup ;
|
||||
if (!req.body.name || (req.body.name.length < 2)) {
|
||||
console.error("ERROR: Validate System - req.body.name");
|
||||
res.json({
|
||||
@@ -456,7 +457,8 @@ exports.createSystem = async function (req, res, next) {
|
||||
state,
|
||||
county,
|
||||
country,
|
||||
showScreenName
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup
|
||||
}) => ({
|
||||
name,
|
||||
shortName,
|
||||
@@ -466,7 +468,8 @@ exports.createSystem = async function (req, res, next) {
|
||||
state,
|
||||
county,
|
||||
country,
|
||||
showScreenName
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup
|
||||
}))(res.locals);
|
||||
system.key = key;
|
||||
system.userId = mongoose.Types.ObjectId(req.user._id);
|
||||
@@ -490,6 +493,7 @@ exports.createSystem = async function (req, res, next) {
|
||||
country,
|
||||
userId,
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup ,
|
||||
key
|
||||
}) => ({
|
||||
name,
|
||||
@@ -502,6 +506,7 @@ exports.createSystem = async function (req, res, next) {
|
||||
country,
|
||||
userId,
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup ,
|
||||
key
|
||||
}))(newSys);
|
||||
returnSys.id = newSys._id;
|
||||
|
||||
@@ -11,6 +11,7 @@ var systemSchema = mongoose.Schema({
|
||||
state: String,
|
||||
description: String,
|
||||
showScreenName: Boolean,
|
||||
ignoreUnknownTalkgroup : Boolean,
|
||||
userId: mongoose.Schema.Types.ObjectId,
|
||||
key: String
|
||||
});
|
||||
|
||||
@@ -13,7 +13,8 @@ class SystemForm extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.handleInputChange = this.handleInputChange.bind(this);
|
||||
this.handleCheckboxChange = this.handleCheckboxChange.bind(this);
|
||||
this.handleScreenNameCheckboxChange = this.handleScreenNameCheckboxChange.bind(this);
|
||||
this.handleTalkgroupCheckboxChange = this.handleTalkgroupCheckboxChange.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
this.checkInputs = this.checkInputs.bind(this);
|
||||
this.render = this.render.bind(this);
|
||||
@@ -30,6 +31,7 @@ class SystemForm extends Component {
|
||||
county: "",
|
||||
country: "",
|
||||
showScreenName: false,
|
||||
ignoreUnknownTalkgroup: false,
|
||||
nameError: false,
|
||||
shortNameError: false,
|
||||
descriptionError: false,
|
||||
@@ -51,6 +53,7 @@ class SystemForm extends Component {
|
||||
this.state.county = this.props.system.county;
|
||||
this.state.country = this.props.system.country;
|
||||
this.state.showScreenName = this.props.system.showScreenName;
|
||||
this.state.ignoreUnknownTalkgroup = this.props.system.ignoreUnknownTalkgroup;
|
||||
}
|
||||
}
|
||||
// If we directly to an updating url, the system fetch will come back after the constructer, so we need to catch this and update the values
|
||||
@@ -66,6 +69,7 @@ class SystemForm extends Component {
|
||||
county: this.props.system.county,
|
||||
country: this.props.system.country,
|
||||
showScreenName: this.props.system.showScreenName,
|
||||
ignoreUnknownTalkgroup: this.props.system.ignoreUnknownTalkgroup,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -148,10 +152,13 @@ class SystemForm extends Component {
|
||||
}
|
||||
|
||||
handleInputChange = (e, { name, value }) => this.setState({ [name]: value });
|
||||
handleCheckboxChange() {
|
||||
handleScreenNameCheckboxChange() {
|
||||
this.setState({ showScreenName: !this.state.showScreenName });
|
||||
}
|
||||
|
||||
handleTalkgroupCheckboxChange() {
|
||||
this.setState({ ignoreUnknownTalkgroup: !this.state.ignoreUnknownTalkgroup });
|
||||
}
|
||||
handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
let inputError = this.checkInputs();
|
||||
@@ -166,7 +173,8 @@ class SystemForm extends Component {
|
||||
state,
|
||||
county,
|
||||
country,
|
||||
showScreenName
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup
|
||||
}) => ({
|
||||
name,
|
||||
shortName,
|
||||
@@ -176,7 +184,8 @@ class SystemForm extends Component {
|
||||
state,
|
||||
county,
|
||||
country,
|
||||
showScreenName
|
||||
showScreenName,
|
||||
ignoreUnknownTalkgroup
|
||||
}))(this.state);
|
||||
this.props.onSubmit(system);
|
||||
}
|
||||
@@ -294,13 +303,16 @@ class SystemForm extends Component {
|
||||
</Form.Group>
|
||||
<Divider horizontal />
|
||||
<Form.Field>
|
||||
|
||||
<p>Your Screen Name: {this.props.screenName}</p>
|
||||
<Checkbox
|
||||
onChange={this.handleCheckboxChange}
|
||||
onChange={this.handleScreenNameCheckboxChange}
|
||||
checked={this.state.showScreenName}
|
||||
label="Show in System Listing" />
|
||||
|
||||
label="Display Screen Name in System Listing" />
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Checkbox
|
||||
onChange={this.handleTalkgroupCheckboxChange}
|
||||
checked={this.state.ignoreUnknownTalkgroup}
|
||||
label="Ignore Unknown Talkgroups" />
|
||||
</Form.Field>
|
||||
<Divider horizontal />
|
||||
<Form.TextArea
|
||||
|
||||
@@ -71,7 +71,8 @@ const system = (
|
||||
key: action.data.key,
|
||||
userId: action.data.userId,
|
||||
id: action.data.id,
|
||||
showScreenName: action.data.showScreenName
|
||||
showScreenName: action.data.showScreenName,
|
||||
ignoreUnknownTalkgroup : action.data.ignoreUnknownTalkgroup
|
||||
});
|
||||
return Object.assign({}, state, { isWaiting: false,
|
||||
items: newItems});
|
||||
|
||||
@@ -64,9 +64,11 @@ process.nextTick(function() {
|
||||
var shortName = req.params.shortName.toLowerCase();
|
||||
var apiKey = req.body.api_key;
|
||||
|
||||
|
||||
|
||||
System.findOne({
|
||||
'shortName': shortName
|
||||
}, async function(err, item) {
|
||||
},["key", "ignoreUnknownTalkgroup"], async function(err, item) {
|
||||
|
||||
if (err) {
|
||||
console.warn("[" + req.params.shortName + "] Error /:shortName/upload - Error: " + err);
|
||||
@@ -98,6 +100,29 @@ process.nextTick(function() {
|
||||
var emergency = parseInt(req.body.emergency);
|
||||
|
||||
|
||||
if (item.ignoreUnknownTalkgroup == true) {
|
||||
console.log("ignore unknown talkgroup ");
|
||||
//await Talkgroup.findOne({ answer: 42 }).select({ _id: 1 }).lean().then(doc => !!doc)
|
||||
talkgroupExists = await Talkgroup.exists({
|
||||
'shortName': shortName,
|
||||
'num': talkgroupNum
|
||||
});
|
||||
console.log("In talkgroup: " + talkgroupExists);
|
||||
//talkgroupExists = await Talkgroup.findOne({ 'shortName': shortName, 'num': talkgroupNum }).select({ _id: 1 }).lean().then(doc => !!doc).exec();
|
||||
if (!talkgroupExists) {
|
||||
try {
|
||||
fs.unlinkSync(req.file.path)
|
||||
//file removed
|
||||
} catch(err) {
|
||||
console.log("[" + call.shortName + "] error deleting: " + req.file.path);
|
||||
}
|
||||
|
||||
res.status(500);
|
||||
res.send("Talkgroup does not exist, skipping.\n");
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
// Add in an API Key check
|
||||
|
||||
try {
|
||||
@@ -107,7 +132,6 @@ process.nextTick(function() {
|
||||
// Mongoose does not allow 'errors' to be used in the Schema for call. need to rename to error.
|
||||
var badFreqList = JSON.parse(req.body.freq_list);
|
||||
var freqList = badFreqList.map(obj =>{
|
||||
|
||||
obj.error = obj.errors;
|
||||
delete obj.errors;
|
||||
return obj;
|
||||
|
||||
@@ -64,7 +64,7 @@ const client = new Twitter({
|
||||
client
|
||||
.get("account/verify_credentials")
|
||||
.then(results => {
|
||||
console.log("results", results);
|
||||
console.log("Connected to Twitter");
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
@@ -304,11 +304,9 @@ function notify_clients(call) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sent > 0) {
|
||||
//console.log("[" + call.shortName.toLowerCase() + "] Sent call to " + sent + " clients");
|
||||
}
|
||||
@@ -353,10 +351,8 @@ io.sockets.on('connection', function (client) {
|
||||
console.warn("[" + data.shortName.toLowerCase() + "] Error - WebSocket Group ID not Found! Error: " + err + " Group ID: " + data.filterCode);
|
||||
delete clients[client.id];
|
||||
return;
|
||||
|
||||
} else {
|
||||
if (group && clients[client.id]) {
|
||||
|
||||
clients[client.id].talkgroupNums = group.talkgroups;
|
||||
} else {
|
||||
console.error("Error - Socket: Invalid group or Client: " + data.filterCode + " Shortname: " + data.shortName + " ClientID: " + client.id);
|
||||
@@ -368,7 +364,6 @@ io.sockets.on('connection', function (client) {
|
||||
});
|
||||
|
||||
} if ((data.filterType == "talkgroup") && Array.isArray(data.filterCode)) {
|
||||
|
||||
clients[client.id].talkgroupNums = data.filterCode;
|
||||
}
|
||||
//console.log("[" + data.shortName.toLowerCase() + "] WebSocket Updating - Client: " + client.id + " code set to: " + data.filterCode + " type set to: " + data.filterType + " TGS: " + clients[client.id].talkgroupNums);
|
||||
|
||||
@@ -14,6 +14,7 @@ var systemSchema = mongoose.Schema({
|
||||
showScreenName: Boolean,
|
||||
callAvg: Number,
|
||||
callCount: Number,
|
||||
ignoreUnknownTalkgroup : Boolean,
|
||||
active: {type: Boolean, default: false},
|
||||
planType: {type: Number, default: 0},
|
||||
userId: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var mongoose = require('mongoose');
|
||||
var bcrypt = require('bcrypt-nodejs');
|
||||
|
||||
var talkgroupSchema = mongoose.Schema({
|
||||
shortName: String,
|
||||
|
||||
2313
backend/package-lock.json
generated
2313
backend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@
|
||||
"get-folder-size": "^1.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mongodb": "2.2.36",
|
||||
"mongoose": "5.3.12",
|
||||
"mongoose": "5.12.3",
|
||||
"multer": "1.3.0",
|
||||
"node-ffprobe": "github:ListenerApproved/node-ffprobe",
|
||||
"node-schedule": "1.2.4",
|
||||
|
||||
1386
backend/yarn.lock
1386
backend/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user