When downloading events from the Events page. If the download file was deleted after downloading, we make the download link for the file inactive #4861
Conversation
…oad link for the file inactive. (export.js)
Added the DIR_EXPORTS_DOWNLOAD constant from PHP to JS Added a style for "#downloadModal a.disabled" on the Events page
|
Please verify. |
There was a problem hiding this comment.
Pull request overview
This PR extends the Events-page export/download workflow (from #4488) by polling the server for whether generated temporary download files still exist, and visually disabling download links in the modal once the files have been deleted.
Changes:
- Exposes
DIR_EXPORTS_DOWNLOADto the browser and uses it client-side to build file paths for polling. - Adds client-side polling in
export.jsto periodically check file existence and mark download links as disabled. - Adds a new AJAX action (
file_existence_check) to returnfile_exists()results, plus CSS styling for disabled download links.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| web/skins/classic/js/skin.js.php | Exposes DIR_EXPORTS_DOWNLOAD as a JS constant (server filesystem path). |
| web/skins/classic/js/export.js | Adds polling + UI disabling logic for download links after file deletion. |
| web/skins/classic/css/base/views/events.css | Styles disabled download links in the download modal. |
| web/ajax/event.php | Adds file_existence_check AJAX endpoint to check file presence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- When making an AJAX request, we pass an array of file paths relative to DIR_EXPORTS_DOWNLOAD , not absolute ones. - Check $fileName for a non-empty string. - Clear fileExistencePollingInterval if it exists before calling again. - More correctly retrieve parameters from the "el.href" string using "new URL(el.href)". - Disabled the cursor for "a.disabled".
|
Please recheck. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Please recheck. |
…tional file name validation. (event.php)
…revious one hasn't yet completed. (export.js) And also compare the full relative path (export_root/file, or just file when there's no export_root) against the server response entry.
Well, that's why you can't use curly braces for a single-line expression... Saves three times the space...
|
Please recheck. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
web/skins/classic/js/export.js:46
fileNameis inserted using$j(nodeCopy).html(...), which treats it as HTML. Since the filename can include monitor names/user-controlled characters, this can introduce an XSS vector in the download modal. Use.text(...)(or build DOM nodes) and insert the<br>as a separate element instead of concatenating HTML.
nodeCopy = downloadLink.cloneNode(true);
nodeCopy.id = 'downloadLink'+i;
downloadLink.parentNode.insertBefore(nodeCopy, downloadLink.nextSibling);
$j(nodeCopy).html('<br>' + (i+1) + '. Download ' + '"' + fileName + '"');
$j(nodeCopy).attr("href", thisUrl + file);
web/skins/classic/js/export.js:147
fileExistencePollingIntervalis only cleared when a newexportResponse()arrives. If the user clicks "Generate Download" again while the previous polling is still active (e.g., while the new export request is running), the old interval can keep polling and disabling links based on stale filenames. Clear the existing interval at the start ofexportEvent()to stop stale polling immediately.
function exportEvent() {
$j('#exportProgress').html('<span class="spinner-grow" role="status" aria-hidden="true"></span>Exporting...');
$j('#exportProgress').removeClass( 'text-success text-danger text-warning' );
$j('#exportProgress').addClass( 'text-warning invisible' );
$j('#downloadLink').html( '' );
This PR doesn't fix the algorithm. |
|
Ready for verification. |
In continuation: #4488