-
-
Notifications
You must be signed in to change notification settings - Fork 425
FE: Implement pause/resume functionality for automatic scans with API… #1753
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5c4aa85
FE: Implement pause/resume functionality for automatic scans with API…
jokob-sk 7a21bad
FE+BE: Pause/Resume scans #1754
jokob-sk 9eedaae
FE: ro session fields for dummy devices #1755
jokob-sk 4a31f83
DOCS: readme cleanup
jokob-sk 9989798
Merge pull request #1760 from netalertx/main
jokob-sk 474c357
feat(models): add initial models package with domain model descriptions
jokob-sk bf24e9f
Merge branch 'next_release' of github.com:netalertx/NetAlertX into ne…
jokob-sk 8000d9b
refactor(tests): improve module stubbing in ntfy custom header tests
jokob-sk 7cbdeb9
docs(tests): add guidelines for stubbing modules in standalone-capabl…
jokob-sk 7a8ea5d
feat(database): add cleanup for dangling parentMAC references and rel…
jokob-sk 26404bb
feat(ui): replace atob with safeAtob for decoding device icons
jokob-sk f9be6af
Merge branch 'next_release' of github.com:netalertx/NetAlertX into ne…
jokob-sk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| //-------------------------------------------------------------- | ||
| // Pause / Resume automatic scans button | ||
| // Default pause duration (minutes) used for the single-click header button | ||
| function renderPauseResumeButton(pauseUntil) { | ||
| const icon = document.getElementById('pause-resume-icon'); | ||
| const link = document.getElementById('pause-resume-button'); | ||
| if (!icon || !link) return; | ||
|
|
||
| const isPaused = !!pauseUntil; | ||
| icon.className = isPaused ? 'fa-solid fa-play' : 'fa-solid fa-pause'; | ||
| link.title = isPaused | ||
| ? getString('Header_ResumeScans_Tooltip') | ||
| : getString('Header_PauseScans_Tooltip'); | ||
| } | ||
|
|
||
| // Updated whenever the SSE state manager receives a state_update event (see sse_manager.js) | ||
| document.addEventListener('nax:pauseStateUpdate', (e) => { | ||
| renderPauseResumeButton(e.detail.pauseUntil); | ||
| }); | ||
|
|
||
| function togglePauseScans() { | ||
| const PAUSE_SCANS_DEFAULT_MINUTES = getSetting("UI_SCAN_PAUSE"); | ||
| const icon = document.getElementById('pause-resume-icon'); | ||
| const isPaused = icon && icon.classList.contains('fa-play'); | ||
| const apiBase = getApiBase(); | ||
| const apiToken = getSetting("API_TOKEN"); | ||
| const endpoint = isPaused ? '/scan/resume' : '/scan/pause'; | ||
| const success_msg = isPaused ? getString("Scans_Resumed") : getString("Scans_Paused"); | ||
| const payload = isPaused ? {} : { minutes: PAUSE_SCANS_DEFAULT_MINUTES }; | ||
|
|
||
| $.ajax({ | ||
| url: `${apiBase}${endpoint}`, | ||
| method: "POST", | ||
| contentType: "application/json", | ||
| headers: { "Authorization": `Bearer ${apiToken}` }, | ||
| data: JSON.stringify(payload), | ||
| error: function(xhr, status, error) { | ||
| console.error("[Header] Error toggling scan pause:", status, error); | ||
| showMessage(error, 5000, "modal_red"); | ||
| }, | ||
| success:function() { | ||
| showMessage(success_msg); | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: netalertx/NetAlertX
Length of output: 50376
🏁 Script executed:
Repository: netalertx/NetAlertX
Length of output: 11375
🏁 Script executed:
Repository: netalertx/NetAlertX
Length of output: 29208
🏁 Script executed:
Repository: netalertx/NetAlertX
Length of output: 21978
Add correctness coverage for the pause control.
Add tests or validation for paused and active rendering, pause and resume payloads, the
nax:pauseStateUpdateevent, and the AJAX error notification. Backend endpoint tests do not cover this JavaScript behavior.🤖 Prompt for AI Agents
Source: Coding guidelines