Embed Add Prospect form on the dashboard, styled to match
Input Interface's plain form (category/name/submitter, POSTs to their localhost:8507 backend) placed at the top of the Prospect Scout tab, above the methodology accordion. Restyled to match this dashboard's design system (--navy/--border/--surface tokens, .panel conventions) rather than leaving it as unstyled plain markup. Category options use & entities to match this file's existing convention (their raw markup had literal & characters). Kept their submit/validation logic as-is, just reworded the success message to be explicit that a new entry won't appear in the rendered grid until the next JSON merge runs (Input Interface flagged this gap directly; addressed it as a clearer status message rather than building live-sync, since periodic merge is the established pattern for this whole integration). Verified via jsdom: exact 6-category option match, button enable/disable logic, and the network-failure status path all work; no regression to the existing 73 rendered cards or the methodology accordion.
This commit is contained in:
1 parent
e9b8cd84d6
commit
b34b75224b
1 file changed
+86
-1
+86
-1
@@ -208,6 +208,12 @@
|
||||
.layout { flex-direction: column; }
|
||||
.sidebar { width: 100%; min-width: 0; height: auto; position: static; }
|
||||
}
|
||||
#ps-add-panel .ps-add-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }
|
||||
#ps-add-panel .ps-add-field { display: flex; flex-direction: column; gap: 5px; min-width: 180px; }
|
||||
#ps-add-panel label { font-size: 12px; font-weight: 800; color: var(--navy); text-transform: uppercase; letter-spacing: 0.04em; }
|
||||
#ps-add-panel select, #ps-add-panel input[type="text"] { padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: var(--sans); color: var(--txt); background: var(--surface); }
|
||||
#ps-add-panel button { padding: 10px 20px; border: none; border-radius: 6px; background: var(--navy); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
|
||||
#ps-add-panel button:disabled { background: var(--txt-m); cursor: not-allowed; opacity: 0.6; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -992,7 +998,42 @@
|
||||
<div class="sec-title">Prospect Scout</div>
|
||||
<div class="sec-sub">Worldwide sweep for companies and research groups matching TXproducts' 6 target categories</div>
|
||||
</div>
|
||||
<button class="acc-header acc-header-f" onclick="toggleAcc('prospect-scout-note-body', this)">
|
||||
|
||||
<div class="panel mt16" id="ps-add-panel">
|
||||
<div class="panel-title">Add a New Prospect</div>
|
||||
<div class="ps-add-row">
|
||||
<div class="ps-add-field">
|
||||
<label for="ps-category">Category</label>
|
||||
<select id="ps-category">
|
||||
<option value="">Choose…</option>
|
||||
<option value="Semiconductor Materials & Substrates (GaN/SiC)">Semiconductor Materials & Substrates (GaN/SiC)</option>
|
||||
<option value="Power Electronics (Devices)">Power Electronics (Devices)</option>
|
||||
<option value="WBG Device Manufacturer">WBG Device Manufacturer</option>
|
||||
<option value="Device Testing">Device Testing</option>
|
||||
<option value="Radiation Hardness">Radiation Hardness</option>
|
||||
<option value="Research & Collaborations">Research & Collaborations</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ps-add-field">
|
||||
<label for="ps-name">Name</label>
|
||||
<input type="text" id="ps-name" placeholder="Company or institution name">
|
||||
</div>
|
||||
<div class="ps-add-field">
|
||||
<label for="ps-submitter">Submitted by</label>
|
||||
<select id="ps-submitter">
|
||||
<option value="">Choose…</option>
|
||||
<option value="Peter">Peter</option>
|
||||
<option value="Mckinley">Mckinley</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ps-add-field">
|
||||
<button id="ps-submit" disabled>Add Prospect</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="note mt16" id="ps-status" style="min-height:16px;"></div>
|
||||
</div>
|
||||
|
||||
<button class="acc-header acc-header-f mt16" onclick="toggleAcc('prospect-scout-note-body', this)">
|
||||
<div class="acc-left"><span class="cat cat-f">Methodology / Verification Note</span><span class="cat-desc">Sourcing details, corrections, and limitations for this sweep — click to expand</span></div>
|
||||
<span class="acc-chevron">▾</span>
|
||||
</button>
|
||||
@@ -1992,6 +2033,50 @@ function renderProspectScout() {
|
||||
});
|
||||
}
|
||||
renderProspectScout();
|
||||
function initProspectAddForm() {
|
||||
var categoryEl = document.getElementById("ps-category");
|
||||
var nameEl = document.getElementById("ps-name");
|
||||
var submitterEl = document.getElementById("ps-submitter");
|
||||
var submitBtn = document.getElementById("ps-submit");
|
||||
var statusEl = document.getElementById("ps-status");
|
||||
if (!submitBtn) return;
|
||||
|
||||
function updateEnabled() {
|
||||
submitBtn.disabled = !(categoryEl.value && nameEl.value.trim() && submitterEl.value);
|
||||
}
|
||||
categoryEl.addEventListener("change", updateEnabled);
|
||||
nameEl.addEventListener("input", updateEnabled);
|
||||
submitterEl.addEventListener("change", updateEnabled);
|
||||
|
||||
submitBtn.addEventListener("click", function () {
|
||||
submitBtn.disabled = true;
|
||||
statusEl.textContent = "Adding…";
|
||||
|
||||
fetch("http://localhost:8507/prospect-scout/api/add", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ category: categoryEl.value, name: nameEl.value.trim(), submitter: submitterEl.value })
|
||||
})
|
||||
.then(function (r) { return r.json().then(function (data) { return { ok: r.ok, data: data }; }); })
|
||||
.then(function (result) {
|
||||
if (!result.ok) {
|
||||
statusEl.textContent = (result.data && result.data.error) || "Something went wrong.";
|
||||
updateEnabled();
|
||||
return;
|
||||
}
|
||||
statusEl.textContent = 'Added "' + nameEl.value.trim() + '" — it will appear on this dashboard the next time it is synced from prospect_scout.json, not immediately.';
|
||||
categoryEl.value = "";
|
||||
nameEl.value = "";
|
||||
submitterEl.value = "";
|
||||
updateEnabled();
|
||||
})
|
||||
.catch(function () {
|
||||
statusEl.textContent = "Couldn't reach the Input Interface backend (localhost:8507) — is it running?";
|
||||
updateEnabled();
|
||||
});
|
||||
});
|
||||
}
|
||||
initProspectAddForm();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user