Added processing of the action when the "delete" button is pressed Layout (montage.js)

pull/4014/head
IgorA100 2024-05-21 13:33:07 +03:00 committed by GitHub
parent 1a1c49f7e3
commit b5d96f2bef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 53 additions and 3 deletions

View File

@ -134,6 +134,7 @@ function selectLayout(new_layout_id) {
}
if (isPresetLayout(nameLayout)) { //PRESET
document.getElementById("btnDeleteLayout").setAttribute('disabled', '');
setSelected(document.getElementById("ratio"), getCookie('zmMontageRatioForAll'));
changeRatioForAll();
@ -155,6 +156,7 @@ function selectLayout(new_layout_id) {
}
initGridStack();
} else { //CUSTOM
document.getElementById("btnDeleteLayout").removeAttribute('disabled');
for (let i = 0, length = monitors.length; i < length; i++) {
const monitor = monitors[i];
// Need to clear the current positioning, and apply the new
@ -406,6 +408,7 @@ function save_layout(button) {
Positions['monitorRatio'][stringToNumber(this.id)] = getSelected(this);
});
form.Positions.value = JSON.stringify(Positions, null, ' ');
$j('#action').attr('value', 'Save');
form.submit();
} // end function save_layout
@ -433,6 +436,53 @@ function cancel_layout(button) {
selectLayout();
}
function delete_layout(button) {
if (!canEdit.System) {
enoperm();
return;
}
if (!document.getElementById('deleteConfirm')) {
// Load the delete confirmation modal into the DOM
// $j.getJSON(thisUrl + '?request=modal&modal=delconfirm')
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm', {
key: 'ConfirmDeleteLayout',
})
.done(function(data) {
insertModalHtml('deleteConfirm', data.html);
manageDelConfirmModalBtns();
$j('#deleteConfirm').modal('show');
})
.fail(function(jqXHR) {
console.log('error getting delconfirm', jqXHR);
logAjaxFail(jqXHR);
});
return;
} else {
$j('#deleteConfirm').modal('show');
}
} // end function delete_layout
// Manage the DELETE CONFIRMATION modal button
function manageDelConfirmModalBtns() {
document.getElementById('delConfirmBtn').addEventListener('click', function onDelConfirmClick(evt) {
document.getElementById('delConfirmBtn').disabled = true; // prevent double click
if (!canEdit.Monitors) {
enoperm();
return;
}
evt.preventDefault();
const form = $j('#btnDeleteLayout')[0].form;
$j('#action').attr('value', 'Delete');
form.submit();
});
// Manage the CANCEL modal button
document.getElementById('delCancelBtn').addEventListener('click', function onDelCancelClick(evt) {
$j('#deleteConfirm').modal('hide');
});
}
function reloadWebSite(ndx) {
document.getElementById('imageFeed'+ndx).innerHTML = document.getElementById('imageFeed'+ndx).innerHTML;
}
@ -653,9 +703,9 @@ function initPage() {
$j("#flipMontageHeader").slideToggle("fast");
$j("#hdrbutton").toggleClass('glyphicon-menu-down').toggleClass('glyphicon-menu-up');
}
if (getCookie('zmMontageLayout')) {
$j('#zmMontageLayout').val(getCookie('zmMontageLayout'));
}
// if (getCookie('zmMontageLayout')) { //This is implemented in montage.php And the cookies may contain the number of a non-existent Layouts!!!
// $j('#zmMontageLayout').val(getCookie('zmMontageLayout'));
// }
$j(".grid-monitor").hover(
//Displaying "Scale" and other buttons at the top of the monitor image