Make Alert and Pop on Event into localStorage options

axis-lock
Moe 2023-06-08 10:54:40 -07:00
parent df907208e7
commit 913d8e15a7
4 changed files with 35 additions and 9 deletions

View File

@ -4822,8 +4822,6 @@ module.exports = function(s,config,lang){
"name": "detail=audio_note", "name": "detail=audio_note",
"field": lang["Notification Sound"], "field": lang["Notification Sound"],
"description": lang["fieldTextAudioNote"], "description": lang["fieldTextAudioNote"],
"default": "",
"example": "",
"fieldType": "select", "fieldType": "select",
"possible": s.listOfAudioFiles "possible": s.listOfAudioFiles
}, },
@ -4831,8 +4829,6 @@ module.exports = function(s,config,lang){
"name": "detail=audio_alert", "name": "detail=audio_alert",
"field": lang["Alert Sound"], "field": lang["Alert Sound"],
"description": lang["fieldTextAudioAlert"], "description": lang["fieldTextAudioAlert"],
"default": "",
"example": "",
"fieldType": "select", "fieldType": "select",
"possible": s.listOfAudioFiles "possible": s.listOfAudioFiles
}, },
@ -4841,15 +4837,12 @@ module.exports = function(s,config,lang){
"field": lang["Alert Sound Delay"], "field": lang["Alert Sound Delay"],
"description": lang["fieldTextAudioDelay"], "description": lang["fieldTextAudioDelay"],
"default": "1", "default": "1",
"example": "",
"possible": ""
}, },
{ {
"name": "detail=event_mon_pop", "name": "detail=event_mon_pop",
"field": lang["Popout Monitor on Event"], "field": lang["Popout Monitor on Event"],
"description": lang["fieldTextEventMonPop"], "description": lang["fieldTextEventMonPop"],
"default": "en_CA", "default": "en_CA",
"example": "",
"fieldType": "select", "fieldType": "select",
"possible": [ "possible": [
{ {
@ -7690,6 +7683,18 @@ module.exports = function(s,config,lang){
attributes: 'shinobi-switch="dontShowDetection" ui-change-target=".dot" on-class="dot-green" off-class="dot-grey"', attributes: 'shinobi-switch="dontShowDetection" ui-change-target=".dot" on-class="dot-green" off-class="dot-grey"',
color: 'grey', color: 'grey',
}, },
{
label: lang[`Alert on Event`],
class: 'cursor-pointer',
attributes: 'shinobi-switch="alertOnEvent" ui-change-target=".dot" on-class="dot-green" off-class="dot-grey"',
color: 'grey',
},
{
label: lang[`Popout on Event`],
class: 'cursor-pointer',
attributes: 'shinobi-switch="popOnEvent" ui-change-target=".dot" on-class="dot-green" off-class="dot-grey"',
color: 'grey',
},
] ]
}, },
{ {

View File

@ -748,6 +748,8 @@
"Rotate": "Rotate", "Rotate": "Rotate",
"Trigger Event": "Trigger Event", "Trigger Event": "Trigger Event",
"Test": "Test", "Test": "Test",
"Popout on Event": "Popout on Event",
"Alert on Event": "Alert on Event",
"Add Marker": "Add Marker", "Add Marker": "Add Marker",
"Test Object Event": "Test Object Event", "Test Object Event": "Test Object Event",
"Test Motion Event": "Test Motion Event", "Test Motion Event": "Test Motion Event",

View File

@ -1273,7 +1273,7 @@ $(document).ready(function(e){
} }
playAudioAlert() playAudioAlert()
var monitorPop = monitorPops[monitorId] var monitorPop = monitorPops[monitorId]
if($user.details.event_mon_pop === '1' && (!monitorPop || monitorPop.closed === true)){ if(window.popLiveOnEvent && (!monitorPop || monitorPop.closed === true)){
popOutMonitor(monitorId) popOutMonitor(monitorId)
} }
// console.log({ // console.log({
@ -1321,12 +1321,28 @@ $(document).ready(function(e){
window.dontShowDetection = true window.dontShowDetection = true
} }
} }
dashboardSwitchCallbacks.alertOnEvent = function(toggleState){
// audio_alert
if(toggleState !== 1){
window.audioAlertOnEvent = false
}else{
window.audioAlertOnEvent = true
}
}
dashboardSwitchCallbacks.popOnEvent = function(toggleState){
if($user.details.event_mon_pop === '1'){
window.popLiveOnEvent = true
}else if(toggleState !== 1){
window.popLiveOnEvent = false
}else{
window.popLiveOnEvent = true
}
}
dashboardSwitchCallbacks.monitorMuteAudio = function(toggleState){ dashboardSwitchCallbacks.monitorMuteAudio = function(toggleState){
var monitorMutes = dashboardOptions().monitorMutes || {} var monitorMutes = dashboardOptions().monitorMutes || {}
$('.monitor_item video').each(function(n,vidEl){ $('.monitor_item video').each(function(n,vidEl){
var el = $(this) var el = $(this)
var monitorId = el.parents('[data-mid]').attr('data-mid') var monitorId = el.parents('[data-mid]').attr('data-mid')
console.log(monitorId,monitorMutes[monitorId])
if(toggleState === 1){ if(toggleState === 1){
vidEl.muted = true vidEl.muted = true
}else{ }else{

View File

@ -230,6 +230,9 @@ function toggleSubStream(monitorId,callback){
} }
function playAudioAlert(){ function playAudioAlert(){
var fileName = $user.details.audio_alert var fileName = $user.details.audio_alert
if(window.audioAlertOnEvent && !fileName){
fileName = `alert.mp3`
}
if(fileName && window.soundAlarmed !== true){ if(fileName && window.soundAlarmed !== true){
window.soundAlarmed = true window.soundAlarmed = true
var audio = new Audio(`libs/audio/${fileName}`) var audio = new Audio(`libs/audio/${fileName}`)