Update Monitor Delete function
parent
624fb9e2ef
commit
13804c0ba9
|
|
@ -11,6 +11,8 @@
|
|||
"contactAdmin": "Contact the maintainer of your Shinobi installation.",
|
||||
"accountAdded": "Account Added",
|
||||
"accountAddedText": "Account has been added.",
|
||||
"monitorDeleted": "Monitor Deleted",
|
||||
"byUser": "by user",
|
||||
"accountDeleted": "Account Deleted",
|
||||
"accountDeletedText": "Account has been deleted.",
|
||||
"accountActionFailed": "Account Action Failed",
|
||||
|
|
@ -1547,7 +1549,7 @@
|
|||
"fieldTextStreamAcodecAac": "Used for MP4 video.",
|
||||
"fieldTextStreamAcodecAc3": "Used for MP4 video.",
|
||||
"fieldTextStreamAcodecCopy": "Used for MP4 video. Has very low CPU usage but some audio codecs need custom flags like <code>-strict 2</code> for aac.",
|
||||
"fieldTextHlsTime": "How long each video segment should be, in minutes. Each segment will be drawn by the client through an m3u8 file. Shorter segments take less space.",
|
||||
"fieldTextHlsTime": "How long each video segment should be, in seconds. Each segment will be drawn by the client through an m3u8 file. Shorter segments take less space.",
|
||||
"fieldTextHlsListSize": "The number of segments maximum before deleting old segments automatically.",
|
||||
"fieldTextPresetStream": "Preset flag for certain video encoders. If you find your camera is crashing every few seconds : try leaving it blank.",
|
||||
"fieldTextStreamQuality": "Low number means higher quality. Higher number means less quality.",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ const fs = require('fs');
|
|||
const treekill = require('tree-kill');
|
||||
const spawn = require('child_process').spawn;
|
||||
const events = require('events');
|
||||
const URL = require('url');
|
||||
const Mp4Frag = require('mp4frag');
|
||||
const streamViewerCountTimeouts = {}
|
||||
module.exports = (s,config,lang) => {
|
||||
|
|
@ -570,7 +571,86 @@ module.exports = (s,config,lang) => {
|
|||
await deleteFromTable('Files')
|
||||
await deletePath(binDir)
|
||||
}
|
||||
async function deleteMonitor(options){
|
||||
const response = { ok: true }
|
||||
try{
|
||||
const user = options.user
|
||||
const userId = user.uid
|
||||
const groupKey = options.ke
|
||||
const monitorId = options.id || options.mid
|
||||
const deleteFiles = options.deleteFiles === undefined ? true : options.deleteFiles
|
||||
s.userLog({
|
||||
ke: groupKey,
|
||||
mid: monitorId
|
||||
},{
|
||||
type: lang.monitorDeleted,
|
||||
msg: `${lang.byUser} : ${userId}`
|
||||
});
|
||||
s.camera('stop', {
|
||||
ke: groupKey,
|
||||
mid: monitorId,
|
||||
delete: 1,
|
||||
});
|
||||
s.tx({
|
||||
f: 'monitor_delete',
|
||||
uid: userId,
|
||||
mid: monitorId,
|
||||
ke: groupKey
|
||||
},`GRP_${groupKey}`);
|
||||
await s.knexQueryPromise({
|
||||
action: "delete",
|
||||
table: "Monitors",
|
||||
where: {
|
||||
ke: groupKey,
|
||||
mid: monitorId,
|
||||
}
|
||||
});
|
||||
if(deleteFiles){
|
||||
await deleteMonitorData(groupKey,monitorId)
|
||||
s.debugLog(`Deleted Monitor Data`,{
|
||||
ke: groupKey,
|
||||
mid: monitorId,
|
||||
});
|
||||
}
|
||||
response.msg = `${lang.monitorDeleted} ${lang.byUser} : ${userId}`
|
||||
}catch(err){
|
||||
response.ok = false
|
||||
response.err = err
|
||||
s.systemLog(err)
|
||||
}
|
||||
return response
|
||||
}
|
||||
function getUrlProtocol(urlString){
|
||||
let modifiedUrlString = `${urlString}`.split('://')
|
||||
const originalProtocol = `${modifiedUrlString[0]}`
|
||||
return originalProtocol
|
||||
}
|
||||
function modifyUrlProtocol(urlString,newProtocol){
|
||||
let modifiedUrlString = `${urlString}`.split('://')
|
||||
const originalProtocol = `${modifiedUrlString[0]}`
|
||||
modifiedUrlString[0] = newProtocol;
|
||||
modifiedUrlString = modifiedUrlString.join('://')
|
||||
return modifiedUrlString
|
||||
}
|
||||
function getUrlParts(urlString){
|
||||
const originalProtocol = getUrlProtocol(urlString)
|
||||
const modifiedUrlString = modifyUrlProtocol(urlString,'http')
|
||||
const url = URL.parse(modifiedUrlString)
|
||||
const data = {}
|
||||
Object.keys(url).forEach(function(key){
|
||||
const value = url[key];
|
||||
if(value && typeof value !== 'function')data[key] = url[key];
|
||||
});
|
||||
data.href = `${urlString}`
|
||||
data.origin = modifyUrlProtocol(data.origin,originalProtocol)
|
||||
data.protocol = `${originalProtocol}:`
|
||||
return data
|
||||
}
|
||||
return {
|
||||
getUrlProtocol,
|
||||
modifyUrlProtocol,
|
||||
getUrlParts,
|
||||
deleteMonitor,
|
||||
deleteMonitorData,
|
||||
cameraDestroy: cameraDestroy,
|
||||
createSnapshot: createSnapshot,
|
||||
|
|
|
|||
Loading…
Reference in New Issue