Merge branch 'dev' into 'master'

Holy Cannoli

See merge request Shinobi-Systems/Shinobi!441
fix-multi-trigger
Moe 2023-01-31 19:11:01 +00:00
commit e7f2b443c1
8 changed files with 50 additions and 41 deletions

View File

@ -27,7 +27,7 @@ module.exports = function(s,config){
{name: 'ip', type: 'string'}, {name: 'ip', type: 'string'},
{name: 'code', length: 100, type: 'string'}, {name: 'code', length: 100, type: 'string'},
{name: 'details', type: 'text'}, {name: 'details', type: 'text'},
{name: 'time', type: 'timestamp'}, {name: 'time', type: 'timestamp', defaultTo: currentTimestamp()},
]); ]);
await createTable('LoginTokens',[ await createTable('LoginTokens',[
isMySQL ? {name: 'utf8', type: 'charset'} : null, isMySQL ? {name: 'utf8', type: 'charset'} : null,
@ -50,7 +50,7 @@ module.exports = function(s,config){
{name: 'details', type: 'text'}, {name: 'details', type: 'text'},
{name: 'status', type: 'integer', length: 1, defaultTo: 0}, {name: 'status', type: 'integer', length: 1, defaultTo: 0},
{name: 'archive', type: 'tinyint', length: 1, defaultTo: 0}, {name: 'archive', type: 'tinyint', length: 1, defaultTo: 0},
{name: 'time', type: 'timestamp'}, {name: 'time', type: 'timestamp', defaultTo: currentTimestamp()},
]); ]);
await createTable('Videos',[ await createTable('Videos',[
isMySQL ? {name: 'utf8', type: 'charset'} : null, isMySQL ? {name: 'utf8', type: 'charset'} : null,
@ -63,8 +63,8 @@ module.exports = function(s,config){
{name: 'archive', type: 'tinyint', length: 1, defaultTo: 0}, {name: 'archive', type: 'tinyint', length: 1, defaultTo: 0},
{name: 'objects', length: 510, type: 'string'}, {name: 'objects', length: 510, type: 'string'},
{name: 'saveDir', length: 255, type: 'string'}, {name: 'saveDir', length: 255, type: 'string'},
{name: 'time', type: 'timestamp'}, {name: 'time', type: 'timestamp', defaultTo: currentTimestamp()},
{name: 'end', type: 'timestamp'}, {name: 'end', type: 'timestamp', defaultTo: currentTimestamp()},
{name: 'details', type: 'text'}, {name: 'details', type: 'text'},
// KEY `videos_index` (`time`) // KEY `videos_index` (`time`)
{name: ['time'], type: 'index', length: 'videos_index'}, {name: ['time'], type: 'index', length: 'videos_index'},
@ -80,8 +80,8 @@ module.exports = function(s,config){
{name: 'status', type: 'integer', length: 1, defaultTo: 0}, {name: 'status', type: 'integer', length: 1, defaultTo: 0},
{name: 'archive', type: 'tinyint', length: 1, defaultTo: 0}, {name: 'archive', type: 'tinyint', length: 1, defaultTo: 0},
{name: 'objects', length: 510, type: 'string'}, {name: 'objects', length: 510, type: 'string'},
{name: 'time', type: 'timestamp'}, {name: 'time', type: 'timestamp', defaultTo: currentTimestamp()},
{name: 'end', type: 'timestamp'}, {name: 'end', type: 'timestamp', defaultTo: currentTimestamp()},
]); ]);
await createTable('Events',[ await createTable('Events',[
isMySQL ? {name: 'utf8', type: 'charset'} : null, isMySQL ? {name: 'utf8', type: 'charset'} : null,
@ -90,7 +90,7 @@ module.exports = function(s,config){
{name: 'mid', length: 100, type: 'string'}, {name: 'mid', length: 100, type: 'string'},
{name: 'details', type: 'text'}, {name: 'details', type: 'text'},
{name: 'archive', type: 'tinyint', length: 1, defaultTo: 0}, {name: 'archive', type: 'tinyint', length: 1, defaultTo: 0},
{name: 'time', type: 'timestamp'}, {name: 'time', type: 'timestamp', defaultTo: currentTimestamp()},
// KEY `events_index` (`ke`,`mid`,`time`) // KEY `events_index` (`ke`,`mid`,`time`)
{name: ['ke', 'mid', 'time'], type: 'index', length: 'events_index'}, {name: ['ke', 'mid', 'time'], type: 'index', length: 'events_index'},
]); ]);
@ -102,8 +102,8 @@ module.exports = function(s,config){
{name: 'tag', length: 30, type: 'string'}, {name: 'tag', length: 30, type: 'string'},
{name: 'details', type: 'text'}, {name: 'details', type: 'text'},
{name: 'count', type: 'integer', length: 10, defaultTo: 1}, {name: 'count', type: 'integer', length: 10, defaultTo: 1},
{name: 'time', type: 'timestamp'}, {name: 'time', type: 'timestamp', defaultTo: currentTimestamp()},
{name: 'end', type: 'timestamp'}, {name: 'end', type: 'timestamp', defaultTo: currentTimestamp()},
]); ]);
await createTable('Timelapse Frames',[ await createTable('Timelapse Frames',[
isMySQL ? {name: 'utf8', type: 'charset'} : null, isMySQL ? {name: 'utf8', type: 'charset'} : null,
@ -111,7 +111,7 @@ module.exports = function(s,config){
{name: 'ke', length: 50, type: 'string'}, {name: 'ke', length: 50, type: 'string'},
{name: 'mid', length: 100, type: 'string'}, {name: 'mid', length: 100, type: 'string'},
{name: 'filename', length: 50, type: 'string'}, {name: 'filename', length: 50, type: 'string'},
{name: 'time', type: 'timestamp'}, {name: 'time', type: 'timestamp', defaultTo: currentTimestamp()},
{name: 'size', type: 'integer'}, {name: 'size', type: 'integer'},
{name: 'archive', length: 1, type: 'tinyint', defaultTo: 0}, {name: 'archive', length: 1, type: 'tinyint', defaultTo: 0},
{name: 'saveDir', length: 255, type: 'string'}, {name: 'saveDir', length: 255, type: 'string'},
@ -126,7 +126,7 @@ module.exports = function(s,config){
{name: 'mid', length: 100, type: 'string'}, {name: 'mid', length: 100, type: 'string'},
{name: 'href', type: 'text'}, {name: 'href', type: 'text'},
{name: 'filename', length: 50, type: 'string'}, {name: 'filename', length: 50, type: 'string'},
{name: 'time', type: 'timestamp'}, {name: 'time', type: 'timestamp', defaultTo: currentTimestamp()},
{name: 'size', type: 'integer'}, {name: 'size', type: 'integer'},
{name: 'details', type: 'text'}, {name: 'details', type: 'text'},
]); ]);

View File

@ -1,3 +1,4 @@
module.exports = function(s,config,lang){ module.exports = function(s,config,lang){
require('./events/onvif.js')(s,config,lang) require('./events/onvif.js')(s,config,lang)
require('./events/noEventsDetector.js')(s,config,lang)
} }

View File

@ -0,0 +1,15 @@
module.exports = function(s,config,lang){
const {
setNoEventsDetector,
} = require('../monitor/utils.js')(s,config,lang);
s.onEventTrigger((d,filter) => {
const groupKey = d.ke
const monitorId = d.mid || d.id
const monitorConfig = s.group[groupKey].rawMonitorConfigurations[monitorId]
const monitorDetails = monitorConfig.details
if(monitorDetails.detector === '1' && monitorDetails.detector_notrigger === '1'){
setNoEventsDetector(monitorConfig)
}
})
}

View File

@ -414,9 +414,6 @@ module.exports = (s,config,lang,app,io) => {
} }
}) })
} }
if(monitorDetails.detector === '1' && monitorDetails.detector_notrigger === '1'){
s.setNoEventsDetector(monitorConfig)
}
var detector_timeout var detector_timeout
if(!monitorDetails.detector_timeout||monitorDetails.detector_timeout===''){ if(!monitorDetails.detector_timeout||monitorDetails.detector_timeout===''){
detector_timeout = 10 detector_timeout = 10

View File

@ -110,11 +110,7 @@ module.exports = async (s,config,lang,onFinish) => {
console.log(data.toString()) console.log(data.toString())
}) })
} }
for (let i = 0; i < stdioPipes.length; i++) {
cameraProcess.stdio[i].once('data',(data) => {
completeResolve(cameraProcess) completeResolve(cameraProcess)
})
}
}catch(err){ }catch(err){
completeResolve(null) completeResolve(null)
s.systemLog(err) s.systemLog(err)

View File

@ -74,16 +74,14 @@ module.exports = function(s,config,lang){
s.getMonitorCpuUsage = function(e,callback){ s.getMonitorCpuUsage = function(e,callback){
if(s.group[e.ke].activeMonitors[e.mid] && s.group[e.ke].activeMonitors[e.mid].spawn){ if(s.group[e.ke].activeMonitors[e.mid] && s.group[e.ke].activeMonitors[e.mid].spawn){
const getUsage = function(callback2){ const getUsage = function(callback2){
s.readFile("/proc/" + s.group[e.ke].activeMonitors[e.mid].spawn.pid + "/stat", function(err, data){ fs.promises.readFile("/proc/" + s.group[e.ke].activeMonitors[e.mid].spawn.pid + "/stat").then((data) => {
if(!err){
const elems = data.toString().split(' '); const elems = data.toString().split(' ');
const utime = parseInt(elems[13]); const utime = parseInt(elems[13]);
const stime = parseInt(elems[14]); const stime = parseInt(elems[14]);
callback2(utime + stime); callback2(utime + stime);
}else{ }).catch((err) => {
s.debugLog(err)
clearInterval(0) clearInterval(0)
}
}) })
} }
getUsage(function(startTime){ getUsage(function(startTime){
@ -271,15 +269,13 @@ module.exports = function(s,config,lang){
} }
}) })
}else{ }else{
s.readFile(streamDir + 's.jpg',function(err,snapBuffer){ fs.promises.readFile(streamDir + 's.jpg').then(function(snapBuffer){
if(err){
sendTempImage()
}else{
resolve({ resolve({
screenShot: snapBuffer, screenShot: snapBuffer,
isStaticFile: true isStaticFile: true
}) })
} }).catch(() => {
sendTempImage()
}) })
} }
}) })

View File

@ -1010,7 +1010,7 @@ module.exports = (s,config,lang) => {
async function createCameraFfmpegProcess(e){ async function createCameraFfmpegProcess(e){
const groupKey = e.ke const groupKey = e.ke
const monitorId = e.mid || e.id const monitorId = e.mid || e.id
const activeMonitor = getActiveMonitor(groupKey,monitorId) var activeMonitor = getActiveMonitor(groupKey,monitorId)
//launch ffmpeg (main) //launch ffmpeg (main)
s.tx({ s.tx({
f: 'monitor_starting', f: 'monitor_starting',
@ -1022,7 +1022,7 @@ module.exports = (s,config,lang) => {
if(activeMonitor.spawn){ if(activeMonitor.spawn){
attachMainProcessHandlers(e,fatalError) attachMainProcessHandlers(e,fatalError)
}else{ }else{
s.debugLog(`Failed to Laucnh Monitor!`,) s.debugLog(`Failed to Launch Monitor!`)
} }
return activeMonitor.spawn return activeMonitor.spawn
} }

View File

@ -1437,7 +1437,11 @@ module.exports = function(s,config,lang,app,io){
s.streamMp4FileOverHttp(filePath,req,res,!!req.query.pureStream) s.streamMp4FileOverHttp(filePath,req,res,!!req.query.pureStream)
} }
}else{ }else{
res.end(user.lang['File Not Found in Filesystem']) s.closeJsonResponse(res,{
ok: false,
msg: lang['File Not Found in Filesystem'],
err: err
})
} }
}) })
} }