diff --git a/interface/hq-dashboard/app/utilities/page.jsx b/interface/hq-dashboard/app/utilities/page.jsx new file mode 100644 index 0000000..791b787 --- /dev/null +++ b/interface/hq-dashboard/app/utilities/page.jsx @@ -0,0 +1,140 @@ +"use client"; + +import React, { useState, useEffect } from "react"; + +export default function UtilitiesPage() { + const [firstEnergyUser, setFirstEnergyUser] = useState(""); + const [firstEnergyPass, setFirstEnergyPass] = useState(""); + const [peoplesGasUser, setPeoplesGasUser] = useState(""); + const [peoplesGasPass, setPeoplesGasPass] = useState(""); + const [status, setStatus] = useState(""); + + useEffect(() => { + fetch('/proxy/utility/api/credentials') + .then(r => r.json()) + .then(data => { + if (data.success) { + setFirstEnergyUser(data.firstEnergyUser || ""); + setPeoplesGasUser(data.peoplesGasUser || ""); + } + }) + .catch(console.error); + }, []); + + const handleSave = async (e) => { + e.preventDefault(); + setStatus("Saving..."); + try { + const res = await fetch('/proxy/utility/api/credentials', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + firstEnergyUser, + firstEnergyPass, + peoplesGasUser, + peoplesGasPass + }) + }); + const data = await res.json(); + if (data.success) { + setStatus("✅ Credentials saved securely."); + setFirstEnergyPass(""); + setPeoplesGasPass(""); + } else { + setStatus("❌ Failed to save."); + } + } catch (err) { + setStatus("❌ Network error."); + } + }; + + const handleRun = async () => { + setStatus("Starting scraper..."); + try { + await fetch('/proxy/utility/api/run', { method: 'POST' }); + setStatus("✅ Scraper triggered in background!"); + } catch (e) { + setStatus("❌ Failed to run scraper."); + } + }; + + return ( +
+

+ Utility Agent Configuration +

+

+ The Utility Agent securely automates retrieving your daily energy and gas usage data. It uses these credentials locally in your private cluster and sends a summary to your WhatsApp gateway. +

+ +
+ + {/* FirstEnergy */} +
+

+ FirstEnergy +

+
+ setFirstEnergyUser(e.target.value)} + style={{ width: "100%", padding: "12px 16px", borderRadius: "8px", border: "1px solid rgba(255,255,255,0.1)", background: "rgba(0,0,0,0.5)", color: "white", outline: "none", fontSize: "0.95rem" }} + /> + setFirstEnergyPass(e.target.value)} + style={{ width: "100%", padding: "12px 16px", borderRadius: "8px", border: "1px solid rgba(255,255,255,0.1)", background: "rgba(0,0,0,0.5)", color: "white", outline: "none", fontSize: "0.95rem" }} + /> +
+
+ +
+ + {/* Peoples Gas */} +
+

+ 🔥 Peoples Gas +

+
+ setPeoplesGasUser(e.target.value)} + style={{ width: "100%", padding: "12px 16px", borderRadius: "8px", border: "1px solid rgba(255,255,255,0.1)", background: "rgba(0,0,0,0.5)", color: "white", outline: "none", fontSize: "0.95rem" }} + /> + setPeoplesGasPass(e.target.value)} + style={{ width: "100%", padding: "12px 16px", borderRadius: "8px", border: "1px solid rgba(255,255,255,0.1)", background: "rgba(0,0,0,0.5)", color: "white", outline: "none", fontSize: "0.95rem" }} + /> +
+
+ + {status &&
{status}
} + +
+ + + +
+
+
+ ); +} diff --git a/interface/hq-dashboard/next.config.mjs b/interface/hq-dashboard/next.config.mjs index cee1c87..169c6d7 100644 --- a/interface/hq-dashboard/next.config.mjs +++ b/interface/hq-dashboard/next.config.mjs @@ -14,6 +14,10 @@ const nextConfig = { { source: '/proxy/gmail/:path*', destination: 'http://gmail-agent.ai-agents.svc.cluster.local:5002/:path*' + }, + { + source: '/proxy/utility/:path*', + destination: 'http://utility-agent.ai-agents.svc.cluster.local:5005/:path*' } ]; }