Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay monitors stopping for 15 seconds when hiding Montage, Watch, Zone, Zone edit page #4060

Merged
merged 4 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions web/skins/classic/views/js/montage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,15 @@ $j(window).on('load', () => initPage());

document.onvisibilitychange = () => {
if (document.visibilityState === "hidden") {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
TimerHideShow = clearTimeout(TimerHideShow);
TimerHideShow = setTimeout(function() {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
}, 15*1000);
} else {
TimerHideShow = clearTimeout(TimerHideShow);
//Start monitors when show page
for (let i = 0, length = monitorData.length; i < length; i++) {
if (!monitors[i].started) {
Expand All @@ -1119,6 +1123,7 @@ document.onvisibilitychange = () => {
}
};


/*
window.onbeforeunload = function(e) {
console.log('unload');
Expand Down
8 changes: 6 additions & 2 deletions web/skins/classic/views/js/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var coordinateMouse = {
};
var leftBtnStatus = {Down: false, UpAfterDown: false};
var updateScale = false; //Scale needs to be updated
var TimerHideShow;

/*
This is the format of the json object sent by bootstrap-table
Expand Down Expand Up @@ -1407,8 +1408,11 @@ $j( window ).on("load", initPage);

document.onvisibilitychange = () => {
if (document.visibilityState === "hidden") {
//Stop monitor when closing or hiding page
monitorStream.kill();
TimerHideShow = clearTimeout(TimerHideShow);
TimerHideShow = setTimeout(function() {
//Stop monitor when closing or hiding page
monitorStream.kill();
}, 15*1000);
} else {
//Start monitor when show page
if (!monitorStream.started) {
Expand Down
12 changes: 8 additions & 4 deletions web/skins/classic/views/js/zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var refreshBtn = $j('#refreshBtn');
var analyseBtn = $j('#analyseBtn');
var monitors = [];
var analyse_frames = true;
var TimerHideShow;

function validateForm( form ) {
var errors = [];
Expand Down Expand Up @@ -763,10 +764,13 @@ function Polygon_calcArea(coords) {

document.onvisibilitychange = () => {
if (document.visibilityState === "hidden") {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
TimerHideShow = clearTimeout(TimerHideShow);
TimerHideShow = setTimeout(function() {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
}, 15*1000);
} else {
//Start monitors when show page
for (let i = 0, length = monitorData.length; i < length; i++) {
Expand Down
12 changes: 8 additions & 4 deletions web/skins/classic/views/js/zones.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function AddNewZone(el) {
}

var monitors = new Array();
var TimerHideShow;

function initPage() {
for ( var i = 0, length = monitorData.length; i < length; i++ ) {
Expand Down Expand Up @@ -54,10 +55,13 @@ window.addEventListener('DOMContentLoaded', initPage);

document.onvisibilitychange = () => {
if (document.visibilityState === "hidden") {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
TimerHideShow = clearTimeout(TimerHideShow);
TimerHideShow = setTimeout(function() {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
}, 15*1000);
} else {
//Start monitors when show page
for (let i = 0, length = monitorData.length; i < length; i++) {
Expand Down
Loading