From 2ce736e10fede0ca87f86e7a3197608717c19fe7 Mon Sep 17 00:00:00 2001 From: mysticmomba Date: Fri, 9 Oct 2026 11:44:39 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20Added=20Desktop=20Notifications=20While?= =?UTF-8?q?=20Minimized.=20This=20Will=20Send=20Notifications=20to=20the?= =?UTF-8?q?=20Desktop=20if=20a=20Host=20Status=20Changes=20While=20It?= =?UTF-8?q?=E2=80=99s=20Minimized=20to=20the=20System=20Tray.=20Closes=20#?= =?UTF-8?q?12.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src-tauri/capabilities/default.json | 3 +- src-tauri/src/commands/traceroute.rs | 1 + src/main.js | 41 ++++++++++++++++++++++++++-- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c09218..9e40196 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 🚀 Features - Added more themes +- Added Minimize to System Tray While Monitor Is Running. Closes #6. ## [0.3.0] - 2026-10-08 ### 🚀 Features diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index c3f99b5..f591173 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -8,6 +8,7 @@ "opener:default", "dialog:default", "core:window:allow-set-always-on-top", - "notification:default" + "notification:default", + "core:window:allow-is-visible" ] } diff --git a/src-tauri/src/commands/traceroute.rs b/src-tauri/src/commands/traceroute.rs index dd43d7f..e08cf11 100644 --- a/src-tauri/src/commands/traceroute.rs +++ b/src-tauri/src/commands/traceroute.rs @@ -60,3 +60,4 @@ pub async fn run_traceroute(app: AppHandle, ip: String) -> Result<(), String> { Ok(()) } + diff --git a/src/main.js b/src/main.js index 864a02c..f4ef6d7 100644 --- a/src/main.js +++ b/src/main.js @@ -976,7 +976,6 @@ const monitorTab = (() => { let running = false; let entries = {}; var editingLabel = false; - var els = { input: () => document.getElementById('monitor-input'), interval: () => document.getElementById('monitor-interval'), @@ -987,6 +986,26 @@ const monitorTab = (() => { 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) { running = active; els.btnStart().disabled = active; @@ -1083,6 +1102,14 @@ const monitorTab = (() => { try { 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) { console.error('Monitor start error:', err); setRunning(false); @@ -1095,6 +1122,10 @@ const monitorTab = (() => { } catch (err) { console.error('Monitor stop error:', err); } + if (reminderInterval) { + clearInterval(reminderInterval); + reminderInterval = null; + } setRunning(false); } @@ -1138,7 +1169,13 @@ const monitorTab = (() => { await listen('monitor:state-change', function (e) { 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'); + } }); }