diff --git a/definitions/base.js b/definitions/base.js index 48f021cd..cf94ac10 100644 --- a/definitions/base.js +++ b/definitions/base.js @@ -2784,7 +2784,7 @@ module.exports = function(s,config,lang){ { hidden: true, "name": "detail=det_trigger_tags", - "field": lang['Trigger Group to Record'], + "field": lang['Trigger Monitors with Tags'], "form-group-class": "h_det_input h_det_1", }, { @@ -4020,25 +4020,6 @@ module.exports = function(s,config,lang){ }, ] }, - "Grouping": { - id: "monSectionGrouping", - "name": lang.Grouping, - "headerTitle": lang['Grouping'] + ' Add groups in Settings', - "color": "purple", - isSection: true, - isAdvanced: true, - "info": [ - { - "fieldType": 'div', - "id": "monitor_groups", - "class": "mdl-list" - }, - { - hidden: true, - "name": "detail=groups", - }, - ], - }, "Copy Settings": { id: "monSectionCopying", "name": lang['Copy Settings'], diff --git a/languages/en_CA.json b/languages/en_CA.json index af0fc507..f39fdf3b 100644 --- a/languages/en_CA.json +++ b/languages/en_CA.json @@ -194,6 +194,7 @@ "Global Detector Settings": "Global Detector Settings", "Detector Settings": "Detector Settings", "Trigger Group to Record": "Trigger Group to Record", + "Trigger Monitors with Tags": "Trigger Monitors with Tags", "triggerGroupRecordFieldText": "Add the names of an existing tag that was added to a Monitor previously or is pending to be added to this monitor that is currently being edited.", "Trigger Camera Groups": "Trigger Camera Groups", "Motion Detection": "Motion Detection", @@ -544,6 +545,8 @@ "updateNotice1": "Updating Shinobi means overwriting files. If you have modified any files yourself you should update Shinobi manually. Your configurations and video files will not be modified.", "Update to Master": "Update to Master", "Update to Development": "Update to Development", + "Continue?": "Continue?", + "Undo current changes?": "Undo current changes?", "Filters Updated": "Filters Updated", "FiltersUpdatedText": "Your changes have been saved and applied.", "Settings Changed": "Settings Changed", @@ -1298,6 +1301,7 @@ "Test Starting": "Test Starting...", "Test Running": "Test Running...", "Test Complete": "Test Complete!", + "Load Test Set": "Load Test Set", "Passed": "Passed", "Failed": "Failed", "UseCount": "UseCount", diff --git a/libs/events.js b/libs/events.js index 38b9ea14..45896315 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1,4 +1,22 @@ module.exports = function(s,config,lang){ require('./events/onvif.js')(s,config,lang) require('./events/noEventsDetector.js')(s,config,lang) + const { bindTagLegendForMonitors } = require('./events/utils.js')(s,config,lang) + s.onAccountSave(function(theGroup,formDetails,user){ + const groupKey = user.ke + bindTagLegendForMonitors(groupKey) + }) + s.onMonitorSave(function(monitorConfig){ + const groupKey = monitorConfig.ke + bindTagLegendForMonitors(groupKey) + }) + s.onMonitorStop(function(monitorConfig){ + const groupKey = monitorConfig.ke + bindTagLegendForMonitors(groupKey) + }) + s.onProcessReady(function(){ + Object.keys(s.group).forEach((groupKey) => { + bindTagLegendForMonitors(groupKey) + }) + }) } diff --git a/libs/events/tracking.js b/libs/events/tracking.js index b0bdff2c..4f3f9ac4 100644 --- a/libs/events/tracking.js +++ b/libs/events/tracking.js @@ -1,5 +1,5 @@ const movingThings = require('shinobi-node-moving-things-tracker').Tracker -module.exports = (s,config,lang,app,io) => { +module.exports = (s,config,lang) => { const objectTrackers = {} const objectTrackerTimeouts = {} function resetObjectTracker(trackerId,matrices){ diff --git a/libs/events/utils.js b/libs/events/utils.js index 16994645..199025f3 100644 --- a/libs/events/utils.js +++ b/libs/events/utils.js @@ -10,7 +10,7 @@ const V = SAT.Vector; const P = SAT.Polygon; const B = SAT.Box; // Matrix In Region Libs /> -module.exports = (s,config,lang,app,io) => { +module.exports = (s,config,lang) => { // Event Filters > const acceptableOperators = ['indexOf','!indexOf','===','!==','>=','>','<','<='] // Event Filters /> @@ -29,7 +29,7 @@ module.exports = (s,config,lang,app,io) => { setLastTracked, trackObjectWithTimeout, getAllMatricesThatMoved, - } = require('./tracking.js')(s,config,lang,app,io) + } = require('./tracking.js')(s,config,lang) const { isEven, fetchTimeout, @@ -330,8 +330,8 @@ module.exports = (s,config,lang,app,io) => { } return true } - const runMultiEventBasedRecord = (monitorConfig, triggerTags, eventTime) => { - triggerTags.forEach(function(monitorId){ + const runMultiEventBasedRecord = (monitorConfig, monitorIdsToTrigger, eventTime) => { + monitorIdsToTrigger.forEach(function(monitorId){ const groupKey = monitorConfig.ke const monitor = s.group[groupKey].rawMonitorConfigurations[monitorId] if(monitorId !== monitorConfig.mid && monitor){ @@ -347,7 +347,34 @@ module.exports = (s,config,lang,app,io) => { } }) } + function bindTagLegendForMonitors(groupKey){ + const newTagLegend = {} + const theGroup = s.group[groupKey] + const monitorIds = Object.keys(theGroup.rawMonitorConfigurations) + monitorIds.forEach((monitorId) => { + const monitorConfig = theGroup.rawMonitorConfigurations[monitorId] + const theTags = (monitorConfig.tags || '').split(',') + theTags.forEach((tag) => { + if(!tag)return; + if(!newTagLegend[tag])newTagLegend[tag] = [] + if(newTagLegend[tag].indexOf(monitorId) === -1)newTagLegend[tag].push(monitorId) + }) + }) + theGroup.tagLegend = newTagLegend + } + function findMonitorsAssociatedToTags(groupKey,triggerTags){ + const monitorsToTrigger = [] + const theGroup = s.group[groupKey] + triggerTags.forEach((tag) => { + const monitorIds = theGroup.tagLegend[tag] + monitorIds.forEach((monitorId) => { + if(monitorsToTrigger.indexOf(monitorId) === -1)monitorsToTrigger.push(monitorId) + }) + }) + return monitorsToTrigger + } const runEventExecutions = async (eventTime,monitorConfig,eventDetails,forceSave,filter,d, triggerEvent) => { + const groupKey = monitorConfig.ke const monitorDetails = monitorConfig.details const detailString = JSON.stringify(eventDetails) if(monitorDetails.detector_ptz_follow === '1'){ @@ -355,7 +382,8 @@ module.exports = (s,config,lang,app,io) => { } if(monitorDetails.det_trigger_tags){ const triggerTags = monitorDetails.det_trigger_tags.split(',') - runMultiEventBasedRecord(monitorConfig, triggerTags, eventTime) + const monitorIds = findMonitorsAssociatedToTags(groupKey, triggerTags) + runMultiEventBasedRecord(monitorConfig, monitorIds, eventTime) } //save this detection result in SQL, only coords. not image. if(d.frame){ @@ -779,7 +807,8 @@ module.exports = (s,config,lang,app,io) => { hasMatrices: hasMatrices, checkEventFilters: checkEventFilters, checkMotionLock: checkMotionLock, - runMultiEventBasedRecord: runMultiEventBasedRecord, + bindTagLegendForMonitors, + runMultiEventBasedRecord, runEventExecutions: runEventExecutions, createEventBasedRecording: createEventBasedRecording, closeEventBasedRecording: closeEventBasedRecording,