zoneminder/web/skins/classic/views/js/groups.js

79 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-09-28 01:16:04 +08:00
// Manage the NEW Group button
2017-05-19 01:50:56 +08:00
function newGroup() {
2020-09-28 01:12:01 +08:00
$j.getJSON(thisUrl + '?request=modal&modal=group')
.done(function(data) {
2020-10-15 04:58:39 +08:00
insertModalHtml('groupdModal', data.html);
2020-09-28 01:12:01 +08:00
$j('#groupModal').modal('show');
$j('.chosen').chosen("destroy");
$j('.chosen').chosen();
// Manage the Save button
$j('#grpModalSaveBtn').click(function(evt) {
evt.preventDefault();
$j('#groupForm').submit();
});
})
.fail(logAjaxFail);
}
function setGroup( element ) {
2017-05-19 01:50:56 +08:00
var form = element.form;
form.action.value = 'setgroup';
form.submit();
}
function editGroup( element ) {
var gid = element.getAttribute('data-group-id');
if ( !gid ) {
console.log('No group id found in editGroup');
} else {
2020-09-28 01:12:01 +08:00
$j.getJSON(thisUrl + '?request=modal&modal=group&gid=' + gid)
.done(function(data) {
2020-10-15 04:58:39 +08:00
insertModalHtml('groupModal', data.html);
2020-09-28 01:12:01 +08:00
$j('#groupModal').modal('show');
$j('.chosen').chosen("destroy");
$j('.chosen').chosen();
// Manage the Save button
$j('#grpModalSaveBtn').click(function(evt) {
evt.preventDefault();
$j('#groupForm').submit();
});
})
.fail(logAjaxFail);
}
}
2017-05-19 01:50:56 +08:00
function deleteGroup( element ) {
var form = element.form;
form.view.value = currentView;
form.action.value = 'delete';
form.submit();
}
2017-05-19 01:50:56 +08:00
function configureButtons( element ) {
if ( canEditGroups ) {
var form = element.form;
if ( element.checked ) {
form.deleteBtn.disabled = (element.value == 0);
}
2017-05-19 01:50:56 +08:00
}
}
2020-09-28 01:12:01 +08:00
function configModalBtns() {
var form = $j('#groupForm')[0];
if ( !form ) {
console.log("No groupForm found");
return;
}
if ( !canEditGroups ) {
console.log("Cannot edit groups");
form.elements['action'].disabled = disabled;
return;
}
var disabled = false;
if ( form.elements['newGroup[Name]'].value == '' ) {
disabled = true;
}
form.elements['action'].disabled = disabled;
}