feat: Added Desktop Notifications While Minimized. This Will Send Notifications to the Desktop if a Host Status Changes While It’s Minimized to the System Tray. Closes #12.

This commit is contained in:
2026-10-09 11:44:39 -04:00
parent 8f8e77242b
commit 2ce736e10f
4 changed files with 43 additions and 3 deletions
+1
View File
@@ -3,6 +3,7 @@
### 🚀 Features ### 🚀 Features
- Added more themes - Added more themes
- Added Minimize to System Tray While Monitor Is Running. Closes #6.
## [0.3.0] - 2026-10-08 ## [0.3.0] - 2026-10-08
### 🚀 Features ### 🚀 Features
+2 -1
View File
@@ -8,6 +8,7 @@
"opener:default", "opener:default",
"dialog:default", "dialog:default",
"core:window:allow-set-always-on-top", "core:window:allow-set-always-on-top",
"notification:default" "notification:default",
"core:window:allow-is-visible"
] ]
} }
+1
View File
@@ -60,3 +60,4 @@ pub async fn run_traceroute(app: AppHandle, ip: String) -> Result<(), String> {
Ok(()) Ok(())
} }
+39 -2
View File
@@ -976,7 +976,6 @@ const monitorTab = (() => {
let running = false; let running = false;
let entries = {}; let entries = {};
var editingLabel = false; var editingLabel = false;
var els = { var els = {
input: () => document.getElementById('monitor-input'), input: () => document.getElementById('monitor-input'),
interval: () => document.getElementById('monitor-interval'), interval: () => document.getElementById('monitor-interval'),
@@ -987,6 +986,26 @@ const monitorTab = (() => {
body: () => document.getElementById('monitor-body'), body: () => document.getElementById('monitor-body'),
}; };
var reminderInterval = null;
async function notify(title, body) {
try {
var current = window.__TAURI__.window.getCurrentWindow();
var visible = await current.isVisible();
if (visible) return;
var notif = window.__TAURI__.notification;
var granted = await notif.isPermissionGranted();
if (!granted) {
var perm = await notif.requestPermission();
if (perm !== 'granted') return;
}
notif.sendNotification({ title: title, body: body });
} catch (e) {
console.log('Notification error:', e);
}
}
function setRunning(active) { function setRunning(active) {
running = active; running = active;
els.btnStart().disabled = active; els.btnStart().disabled = active;
@@ -1083,6 +1102,14 @@ const monitorTab = (() => {
try { try {
await invoke('monitor_start', { intervalMs: interval }); await invoke('monitor_start', { intervalMs: interval });
// Start 15-minute reminder
if (reminderInterval) clearInterval(reminderInterval);
reminderInterval = setInterval(function () {
var count = Object.keys(entries).length;
notify('Argus Monitor Active',
'The monitor is still running with ' + count + ' hosts. Close the monitor to stop pinging.');
}, 15 * 60 * 1000);
} catch (err) { } catch (err) {
console.error('Monitor start error:', err); console.error('Monitor start error:', err);
setRunning(false); setRunning(false);
@@ -1095,6 +1122,10 @@ const monitorTab = (() => {
} catch (err) { } catch (err) {
console.error('Monitor stop error:', err); console.error('Monitor stop error:', err);
} }
if (reminderInterval) {
clearInterval(reminderInterval);
reminderInterval = null;
}
setRunning(false); setRunning(false);
} }
@@ -1138,7 +1169,13 @@ const monitorTab = (() => {
await listen('monitor:state-change', function (e) { await listen('monitor:state-change', function (e) {
var data = e.payload; var data = e.payload;
console.log('State change:', data.ip, data.old, '->', data.new); console.log('State change:', data.ip, data.old, '->', data['new']);
var label = entries[data.ip] ? (entries[data.ip].label || data.ip) : data.ip;
if (data['new'] === 'Down') {
notify('Host Down', label + ' (' + data.ip + ') is no longer responding');
} else if (data['new'] === 'Up' && data.old === 'Down') {
notify('Host Recovered', label + ' (' + data.ip + ') is back online');
}
}); });
} }