2021-03-12 22:28:05 +08:00
|
|
|
|
|
|
|
// Manage the DELETE CONFIRMATION modal button
|
|
|
|
function manageDelConfirmModalBtns() {
|
|
|
|
document.getElementById('delConfirmBtn').addEventListener('click', function onDelConfirmClick(evt) {
|
|
|
|
if ( !canEdit.Events ) {
|
|
|
|
enoperm();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
evt.preventDefault();
|
|
|
|
/*
|
|
|
|
$j.getJSON(thisUrl + '?request=events&task=delete&eids[]='+eventData.Id)
|
|
|
|
.done(function(data) {
|
|
|
|
streamNext(true);
|
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
*/
|
|
|
|
});
|
|
|
|
|
|
|
|
// Manage the CANCEL modal button
|
|
|
|
document.getElementById("delCancelBtn").addEventListener("click", function onDelCancelClick(evt) {
|
|
|
|
$j('#deleteConfirm').modal('hide');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-08-07 07:18:02 +08:00
|
|
|
function downloadResponse(respObj, respText) {
|
|
|
|
clearInterval(downloadTimer);
|
|
|
|
if (respObj.result != 'Ok' ) {
|
|
|
|
$j('#downloadProgressTicker').text(respObj.message);
|
2021-08-06 01:29:45 +08:00
|
|
|
} else {
|
2021-08-07 07:18:02 +08:00
|
|
|
$j('#downloadProgressTicker').text(downloadSucceededString);
|
2021-08-06 01:29:45 +08:00
|
|
|
setTimeout(startDownload, 1500, decodeURIComponent(respObj.exportFile));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
function startDownload(file) {
|
|
|
|
window.location.replace(file);
|
|
|
|
}
|
|
|
|
|
2021-08-07 07:18:02 +08:00
|
|
|
function downloadProgress() {
|
|
|
|
if (downloadTimer) {
|
|
|
|
var tickerText = $j('#downloadProgressTicker').text();
|
|
|
|
if (tickerText.length < 1 || tickerText.length > 4) {
|
|
|
|
$j('#downloadProgressTicker').text('.');
|
2021-08-06 01:29:45 +08:00
|
|
|
} else {
|
2021-08-07 07:18:02 +08:00
|
|
|
$j('#downloadProgressTicker').append('.');
|
2021-08-06 01:29:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-12 22:28:05 +08:00
|
|
|
function initPage() {
|
|
|
|
// enable or disable buttons based on current selection and user rights
|
|
|
|
/*
|
|
|
|
renameBtn.prop('disabled', !canEdit.Events);
|
|
|
|
archiveBtn.prop('disabled', !(!eventData.Archived && canEdit.Events));
|
|
|
|
unarchiveBtn.prop('disabled', !(eventData.Archived && canEdit.Events));
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Don't enable the back button if there is no previous zm page to go back to
|
2021-08-07 07:18:02 +08:00
|
|
|
$j('#backBtn').prop('disabled', !document.referrer.length);
|
2021-03-12 22:28:05 +08:00
|
|
|
|
|
|
|
// Manage the BACK button
|
|
|
|
bindButton('#backBtn', 'click', null, function onBackClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
window.history.back();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Manage the REFRESH Button
|
|
|
|
bindButton('#refreshBtn', 'click', null, function onRefreshClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
window.location.reload(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Manage the EDIT button
|
2021-08-07 07:18:02 +08:00
|
|
|
$j('#saveBtn').prop('disabled', !(canEdit.Events || (snapshot.CreatedBy == user.Id) ));
|
2021-03-12 22:28:05 +08:00
|
|
|
bindButton('#saveBtn', 'click', null, function onSaveClick(evt) {
|
|
|
|
/*
|
|
|
|
if ( ! canEdit.Events ) {
|
|
|
|
enoperm();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
evt.target.form.submit();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Manage the EXPORT button
|
2021-08-16 22:27:40 +08:00
|
|
|
$j('#downloadBtn').prop('disabled', !canView.Snapshots);
|
2021-08-07 07:18:02 +08:00
|
|
|
bindButton('#downloadBtn', 'click', null, function onDownloadClick(evt) {
|
2021-03-12 22:28:05 +08:00
|
|
|
evt.preventDefault();
|
2021-08-06 01:29:45 +08:00
|
|
|
formData = {
|
|
|
|
eids: snapshot.EventIds,
|
2021-08-07 01:18:31 +08:00
|
|
|
exportImages: 0,
|
2021-08-06 01:29:45 +08:00
|
|
|
exportVideo: 0,
|
|
|
|
exportFrames: 0,
|
|
|
|
exportDetail: 0,
|
2021-08-07 01:18:31 +08:00
|
|
|
exportMisc: 1,
|
2021-08-06 01:29:45 +08:00
|
|
|
exportFormat: 'zip',
|
|
|
|
exportCompress: 0,
|
2021-08-07 01:18:31 +08:00
|
|
|
exportStructure: 'flat',
|
2021-08-06 01:29:45 +08:00
|
|
|
exportFile: 'Snapshot'+snapshot.Id
|
|
|
|
};
|
|
|
|
$j.getJSON(thisUrl + '?view=event&request=event&action=export', formData)
|
2021-08-07 07:18:02 +08:00
|
|
|
.done(downloadResponse)
|
2021-08-06 01:29:45 +08:00
|
|
|
.fail(logAjaxFail);
|
|
|
|
|
2021-08-07 07:18:02 +08:00
|
|
|
$j('#downloadProgress').removeClass('hidden');
|
|
|
|
$j('#downloadProgress').addClass('warnText');
|
|
|
|
$j('#downloadProgress').text(downloadProgressString);
|
2021-08-06 01:29:45 +08:00
|
|
|
|
2021-08-07 07:18:02 +08:00
|
|
|
downloadTimer = setInterval(downloadProgress, 500);
|
|
|
|
});
|
2021-08-06 01:29:45 +08:00
|
|
|
|
2021-08-16 22:27:40 +08:00
|
|
|
$j('#exportBtn').prop('disabled', !canView.Snapshots);
|
2021-08-07 07:18:02 +08:00
|
|
|
bindButton('#exportBtn', 'click', null, function onExportClick(evt) {
|
|
|
|
console.log('export clicked');
|
|
|
|
evt.preventDefault();
|
|
|
|
window.location.assign('?view=export&eids[]='+snapshot.EventIds.join('&eids[]='));
|
2021-03-12 22:28:05 +08:00
|
|
|
});
|
|
|
|
|
2021-08-06 01:29:45 +08:00
|
|
|
/*
|
2021-03-12 22:28:05 +08:00
|
|
|
// Manage the DOWNLOAD VIDEO button
|
|
|
|
bindButton('#downloadBtn', 'click', null, function onDownloadClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
$j.getJSON(thisUrl + '?request=modal&modal=download&eids[]='+eventData.Id)
|
|
|
|
.done(function(data) {
|
|
|
|
insertModalHtml('downloadModal', data.html);
|
|
|
|
$j('#downloadModal').modal('show');
|
|
|
|
// Manage the GENERATE DOWNLOAD button
|
|
|
|
$j('#exportButton').click(exportEvent);
|
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
// Manage the DELETE button
|
2021-08-07 07:18:02 +08:00
|
|
|
$j('#deleteBtn').prop('disabled', !canEdit.Events);
|
2021-03-12 22:28:05 +08:00
|
|
|
bindButton('#deleteBtn', 'click', null, function onDeleteClick(evt) {
|
|
|
|
if ( !canEdit.Events ) {
|
|
|
|
enoperm();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
evt.preventDefault();
|
|
|
|
if ( ! $j('#deleteConfirm').length ) {
|
|
|
|
// Load the delete confirmation modal into the DOM
|
|
|
|
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm')
|
|
|
|
.done(function(data) {
|
|
|
|
insertModalHtml('deleteConfirm', data.html);
|
|
|
|
manageDelConfirmModalBtns();
|
|
|
|
$j('#deleteConfirm').modal('show');
|
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$j('#deleteConfirm').modal('show');
|
|
|
|
});
|
|
|
|
} // end initPage
|
|
|
|
|
|
|
|
// Kick everything off
|
|
|
|
$j(document).ready(initPage);
|