mirror of
https://github.com/ced4568/ceds-noc.git
synced 2026-08-12 21:04:02 +00:00
Update positioning, remove IPs from cards, remove icons, update NOC content
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// ═══════════════════════════════════════════════
|
||||
// Ced's Portfolio — script.js
|
||||
// Ced's NOC script.js
|
||||
// NOC data loads from data/noc-status.json
|
||||
// Refreshes every 30s. Graceful fallback on fail.
|
||||
// ═══════════════════════════════════════════════
|
||||
@@ -34,8 +34,6 @@ async function loadNocStatus() {
|
||||
const fallback = document.getElementById("noc-fallback");
|
||||
|
||||
try {
|
||||
// Cache-bust to always get fresh data
|
||||
// Use absolute URL when on NOC subdomain, relative when on main portfolio
|
||||
const nocDataUrl = window.location.hostname === 'noc.chasedumphord.com'
|
||||
? `https://chasedumphord.com/data/noc-status.json?t=${Date.now()}`
|
||||
: `data/noc-status.json?t=${Date.now()}`;
|
||||
@@ -46,32 +44,25 @@ async function loadNocStatus() {
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
// Reset fail counter on success
|
||||
failCount = 0;
|
||||
|
||||
// ── Status bar ──
|
||||
if (dot) {
|
||||
dot.className = "status-dot live";
|
||||
}
|
||||
if (dot) dot.className = "status-dot live";
|
||||
|
||||
if (statusText) {
|
||||
const d = new Date(data.lastUpdated);
|
||||
const formatted = d.toLocaleString('en-US', { month: 'long', day: 'numeric', year: 'numeric', hour: 'numeric', minute: '2-digit', hour12: true });
|
||||
statusText.textContent = `${data.nocName} — ${data.status} — Last updated: ${formatted}`;
|
||||
}
|
||||
if (badge) {
|
||||
badge.textContent = `Auto-refresh: 30s`;
|
||||
}
|
||||
|
||||
// Hide fallback if it was showing
|
||||
if (badge) badge.textContent = `Auto-refresh: 30s`;
|
||||
|
||||
if (fallback) fallback.style.display = "none";
|
||||
|
||||
// ── Metrics ──
|
||||
if (nodes) animateMetric(nodes, data.summary.nodes);
|
||||
if (services) animateMetric(services, data.summary.services);
|
||||
if (vlans) animateMetric(vlans, data.summary.vlans);
|
||||
if (edge) animateMetric(edge, data.summary.edgeSystems);
|
||||
|
||||
// ── System cards ──
|
||||
if (grid) {
|
||||
grid.innerHTML = "";
|
||||
data.systems.forEach((system) => {
|
||||
@@ -95,7 +86,6 @@ async function loadNocStatus() {
|
||||
</div>
|
||||
<h3>${system.name}</h3>
|
||||
<p>${system.type}</p>
|
||||
<code>${system.address}</code>
|
||||
<div class="system-meta">
|
||||
<small>Status: ${system.status}</small>
|
||||
<small>Latency: ${system.latency || "N/A"}</small>
|
||||
@@ -107,14 +97,12 @@ async function loadNocStatus() {
|
||||
});
|
||||
}
|
||||
|
||||
// ── Alerts ──
|
||||
if (alertList) renderAlerts(data.systems, alertList);
|
||||
|
||||
} catch (err) {
|
||||
failCount++;
|
||||
console.warn(`[NOC] Fetch failed (${failCount}/${MAX_FAILS}):`, err.message);
|
||||
|
||||
// Update dot to error state
|
||||
if (dot) dot.className = "status-dot error";
|
||||
|
||||
if (statusText) {
|
||||
@@ -125,27 +113,23 @@ async function loadNocStatus() {
|
||||
|
||||
if (badge) badge.textContent = "";
|
||||
|
||||
// After MAX_FAILS attempts, show the fallback block
|
||||
if (failCount >= MAX_FAILS && fallback) {
|
||||
fallback.style.display = "block";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animate a number metric with a quick pop
|
||||
function animateMetric(el, value) {
|
||||
el.classList.remove("metric-pop");
|
||||
el.textContent = value;
|
||||
void el.offsetWidth; // force reflow
|
||||
void el.offsetWidth;
|
||||
el.classList.add("metric-pop");
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════
|
||||
// GitHub Repos — fetches public repos for ced4568
|
||||
// Sorted by last pushed, capped at 6 cards
|
||||
// GitHub Repos
|
||||
// ═══════════════════════════════════════════════
|
||||
|
||||
// Language → color map (subset of GitHub's palette)
|
||||
const LANG_COLORS = {
|
||||
Python: "#3572A5",
|
||||
JavaScript: "#f1e05a",
|
||||
@@ -170,8 +154,6 @@ async function loadGithubRepos() {
|
||||
if (!res.ok) throw new Error(`GitHub API ${res.status}`);
|
||||
|
||||
const repos = await res.json();
|
||||
|
||||
// Filter out forks for cleaner display
|
||||
const ownRepos = repos.filter((r) => !r.fork).slice(0, 6);
|
||||
|
||||
if (ownRepos.length === 0) {
|
||||
@@ -181,10 +163,7 @@ async function loadGithubRepos() {
|
||||
|
||||
container.innerHTML = ownRepos.map((repo) => {
|
||||
const langColor = LANG_COLORS[repo.language] || "var(--accent-2)";
|
||||
const desc = repo.description
|
||||
? repo.description
|
||||
: "No description provided.";
|
||||
|
||||
const desc = repo.description ? repo.description : "No description provided.";
|
||||
const updatedDate = new Date(repo.pushed_at).toLocaleDateString("en-US", {
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
@@ -203,9 +182,7 @@ async function loadGithubRepos() {
|
||||
>${repo.name}</a>
|
||||
<span class="repo-visibility">${repo.private ? "private" : "public"}</span>
|
||||
</div>
|
||||
|
||||
<p class="repo-desc">${desc}</p>
|
||||
|
||||
<div class="repo-meta">
|
||||
${repo.language
|
||||
? `<span>
|
||||
@@ -226,9 +203,9 @@ async function loadGithubRepos() {
|
||||
container.innerHTML = `
|
||||
<div class="repo-loading">
|
||||
<p class="noc-loading">
|
||||
Could not load repositories.
|
||||
Could not load repositories.
|
||||
<a href="https://github.com/ced4568" target="_blank" rel="noopener noreferrer">
|
||||
View on GitHub →
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
@@ -236,7 +213,7 @@ async function loadGithubRepos() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Build the alert panel from system data
|
||||
|
||||
function renderAlerts(systems, alertList) {
|
||||
const scored = systems
|
||||
.map((sys) => {
|
||||
|
||||
Reference in New Issue
Block a user