refactor(contorller): update to consider iowa_2 and look at plant token vs server going forward

This commit is contained in:
2025-09-29 12:44:46 -05:00
parent 99e70fcafb
commit a5a67660e8
4 changed files with 214 additions and 93 deletions

View File

@@ -32,6 +32,28 @@
.error {
color: #f33;
}
#server-buttons {
display: grid;
grid-template-columns: repeat(4, 1fr); /* 4 equal columns */
gap: 0.75rem; /* roughly Tailwind gap-3 */
margin: 1rem 0;
}
#server-buttons button {
padding: 0.5rem 1rem;
font-family: monospace;
border: 1px solid #444;
background: #222;
color: #eee;
cursor: pointer;
border-radius: 4px;
transition: all 0.2s ease;
}
#server-buttons button:hover {
background: #333;
border-color: #888;
}
</style>
</head>
<body>
@@ -74,15 +96,9 @@
</div>
<div id="logWindow"></div>
<div>
<button id="USMCD1VMS036">USMCD1VMS036</button>
<button id="USBET1VMS006">USBET1VMS006</button>
<button id="USBOW1VMS006">USBOW1VMS006</button>
<button id="USKSC1VMS006">USKSC1VMS006</button>
<button id="USMCD1VMS006">USMCD1VMS006</button>
<button id="USSLC1VMS006">USSLC1VMS006</button>
<button id="USSTP1VMS006">USSTP1VMS006</button>
<button id="USDAY1VMS006">USDAY1VMS006</button>
<div id="controls">
<div id="server-buttons"></div>
<button id="btnAll">Copy to ALL</button>
</div>
<script>
@@ -98,6 +114,91 @@
transports: ["polling"],
});
const servers = [
{
name: "Test server",
server: "USMCD1VMS036",
location: "E$\\LST",
},
{
name: "Bethlehem",
server: "USBET1VMS006",
location: "E$\\LST",
},
{
name: "Bowling Green 1",
server: "USBOW1VMS006",
location: "E$\\LST",
},
{
name: "Bowling Green 2",
server: "USBOW2VMS006",
location: "E$\\LST",
},
{
name: "Flornece",
server: "USFLO1VMS006",
location: "E$\\LST",
},
{
name: "Kasnas City",
server: "USKSC1VMS006",
location: "E$\\LST",
},
{
name: "Marked Tree",
server: "USMAR1VMS006",
location: "E$\\LST",
},
{
name: "McDonough",
server: "USMCD1VMS006",
location: "E$\\LST",
},
{
name: "Salt Lake City",
server: "USSLC1VMS006",
location: "E$\\LST",
},
{
name: "St.Peters",
server: "USSTP1VMS006",
location: "D$\\LST",
},
{ name: "Dayton", server: "USDAY1VMS006", location: "E$\\LST" },
{ name: "Lima", server: "USLIM1VMS006", location: "E$\\LST" },
{
name: "Iowa - EBM",
server: "USIOW1VMS006",
location: "D$\\LST\\LST",
},
{
name: "Iowa - ISBM",
server: "USIOW1VMS006",
location: "D$\\LST\\LST_2",
},
{
name: "Houston",
server: "USHOU1VMS006",
location: "E$\\LST\\LST",
},
{
name: "Sherman",
server: "USSHE1VMS006",
location: "E$\\LST\\LST",
},
{
name: "West Bend",
server: "USWEB1VMS006",
location: "E$\\LST\\LST",
},
{
name: "Jerfferson City",
server: "USJCI1VMS006",
location: "E$\\LST\\LST",
},
];
// log window reference
const logWindow = document.getElementById("logWindow");
@@ -208,73 +309,89 @@
};
};
// all the server copy buttons
document.getElementById("USMCD1VMS036").onclick = () => {
socket.emit("update", {
action: "copy",
target: "USMCD1VMS036",
drive: "e",
}); // "frontend" = payload target
logMessage("info", "Copying to USMCD1VMS036");
const serverButtonsDiv = document.getElementById("server-buttons");
servers.forEach((srv) => {
const btn = document.createElement("button");
btn.textContent = srv.name;
btn.dataset.server = srv.server;
btn.dataset.drive = srv.drive;
btn.addEventListener("click", () => {
socket.emit("update", {
action: "copy",
target: srv.server,
location: srv.location,
});
logMessage(
"info",
`Copying to ${
srv.name
} (drive ${srv.drive.toUpperCase()})`
);
});
serverButtonsDiv.appendChild(btn);
});
let copyQueue = []; // Holds list of servers left
let currentServer = null; // Track which server is waiting confirmation
let isRunningAll = false;
document.getElementById("btnAll").onclick = () => {
if (isRunningAll) {
logMessage("info", "⚠️ Copy to ALL already running...");
return;
}
copyQueue = [...servers]; // fresh clone of the servers
isRunningAll = true;
logMessage(
"info",
"▶️ Starting sequential copy to ALL servers..."
);
runNextInQueue();
};
document.getElementById("USBET1VMS006").onclick = () => {
socket.emit("update", {
action: "copy",
target: "USBET1VMS006",
drive: "e",
}); // "frontend" = payload target
logMessage("info", "Copying to USBET1VMS006");
};
document.getElementById("USBOW1VMS006").onclick = () => {
socket.emit("update", {
action: "copy",
target: "USBOW1VMS006",
drive: "e",
}); // "frontend" = payload target
logMessage("info", "Copying to USBOW1VMS006");
};
document.getElementById("USSLC1VMS006").onclick = () => {
socket.emit("update", {
action: "copy",
target: "USSLC1VMS006",
drive: "e",
}); // "frontend" = payload target
logMessage("info", "Copying to USSLC1VMS006");
};
function runNextInQueue() {
if (copyQueue.length === 0) {
logMessage("info", "✅ Finished copying to ALL servers!");
isRunningAll = false;
currentServer = null;
return;
}
currentServer = copyQueue.shift();
logMessage(
"info",
`🚀 Copying to ${
currentServer.name
} (drive ${currentServer.drive.toUpperCase()})`
);
document.getElementById("USSTP1VMS006").onclick = () => {
socket.emit("update", {
action: "copy",
target: "USSTP1VMS006",
drive: "d",
}); // "frontend" = payload target
logMessage("info", "Copying to USSTP1VMS006");
};
document.getElementById("USKSC1VMS006").onclick = () => {
socket.emit("update", {
action: "copy",
target: "USksc1VMS006",
drive: "e",
}); // "frontend" = payload target
logMessage("info", "Copying to USKSC1VMS006");
};
document.getElementById("USDAY1VMS006").onclick = () => {
socket.emit("update", {
action: "copy",
target: "USDAY1VMS006",
drive: "e",
}); // "frontend" = payload target
logMessage("info", "Copying to USDAY1VMS006");
};
document.getElementById("USMCD1VMS006").onclick = () => {
socket.emit("update", {
action: "copy",
target: "USMCD1VMS006",
drive: "e",
}); // "frontend" = payload target
logMessage("info", "Copying to USMCD1VMS006");
};
target: currentServer.name,
drive: currentServer.drive,
});
}
socket.on("updateLogs", (msg) => {
//logMessage("update", msg);
// Only check queue progress if we're in All mode and have a currentServer
if (isRunningAll && currentServer) {
const expected = `✅ Copy to ${currentServer.name} successful`;
if (msg.includes(expected)) {
logMessage(
"info",
`✅ Confirmed: ${currentServer.name} done`
);
runNextInQueue(); // trigger the next server
}
}
});
socket.on("logs", (msg) => logMessage("logs", msg));
socket.on("errors", (msg) => logMessage("errors", msg));