allow selecting detector plugin per monitor

plugins-allow-selecting-specific-detector
Moe 2024-05-31 23:18:10 -07:00
parent 05df08b0fa
commit 1da9547a6b
5 changed files with 53 additions and 1 deletions

View File

@ -3142,6 +3142,14 @@ module.exports = function(s,config,lang){
}
]
},
{
"name": "detail=detector_chosen",
"field": lang["Chosen Plugin"],
"description": lang.fieldTextChosenPlugin,
"attribute": `multiple`,
"fieldType": "select",
"possible": []
},
{
"name": "detail=detector_object_ignore_not_move",
"field": lang["Ignore Non-Moving"],

View File

@ -18,6 +18,8 @@
"accountEditError": "Account Edit Error",
"Monitor Map": "Monitor Map",
"Geolocation": "Geolocation",
"Chosen Plugin": "Chosen Plugin",
"fieldTextChosenPlugin": "Detector Plugin to use. Select none to send to all. This field is inactive when Plugins are used in Cluster Mode.",
"fieldTextGeolocation": "The map coordinates of this camera in the real world. This will plot a point for your camera on the Monitor Map.",
"playUntilVideoEnd": "Play until video end",
"Monitor Saved": "Monitor Saved",

View File

@ -164,6 +164,18 @@ module.exports = function(s,config,lang,app,io){
})
}
}
function sendToSpecificDetector(data, chosenDetectorPlugins){
if(s.connectedPlugins[name]){
s.connectedPlugins[name].tx(data)
}else{
console.error('Plugin Not Connected',name, 'used by',data.id)
}
}
s.sendToSpecificDetectors = function(data, chosenDetectorPlugins){
chosenDetectorPlugins.forEach(function(name){
sendToSpecificDetector(data, name)
})
}
s.sendDetectorInfoToClient = function(data,txFunction){
s.detectorPluginArray.forEach(function(name){
var detectorData = Object.assign(data,{

21
libs/plugins/webPaths.js Normal file
View File

@ -0,0 +1,21 @@
module.exports = function(s,config,lang,app,io){
/**
* API : Get Available Plugins
*/
app.get(config.webPaths.apiPrefix+':auth/plugins/:ke',function (req,res){
var response = {ok: true};
res.setHeader('Content-Type', 'application/json');
s.auth(req.params,function(user){
response.plugins = [
...s.detectorPluginArray.map(item => {
return {
"name": item,
"value": item
}
})
];
res.end(s.prettyPrint(response));
},res,req);
})
}

View File

@ -700,6 +700,14 @@ function importIntoMonitorEditor(options){
theAction(monitorConfig)
})
}
function getAvailablePlugins(){
return new Promise((resolve) => {
$.get(getApiPrefix()+'/plugins/'+monitorConfig.ke+'/',function(data){
resolve(data)
})
})
}
//parse "Automatic" field in "Input" Section
monitorEditorWindow.on('change','.auto_host_fill input,.auto_host_fill select',function(e){
var theSwitch = monitorEditorWindow.find('[detail="auto_host_enable"]').val()
@ -1327,11 +1335,12 @@ editorForm.find('[name="type"]').change(function(e){
sideMenuCollapsePoint.collapse('show')
}
}
function onTabMove(){
async function onTabMove(){
var theSelected = `${monitorsList.val() || ''}`
drawMonitorListToSelector(monitorsList.find('optgroup'),false,'host')
monitorsList.val(theSelected)
checkToOpenSideMenu()
monitorEditorWindow.find('[detail="detector_chosen"]').val(await getAvailablePlugins())
}
addOnTabAway('monitorSettings', function(){
if(isSideBarMenuCollapsed()){