Update public/terminal.html
Browse files- public/terminal.html +2 -123
public/terminal.html
CHANGED
|
@@ -4,48 +4,7 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Terminal</title>
|
| 7 |
-
<
|
| 8 |
-
body {
|
| 9 |
-
font-family: Arial, sans-serif;
|
| 10 |
-
background-color: #282c34;
|
| 11 |
-
color: #ffffff;
|
| 12 |
-
margin: 0;
|
| 13 |
-
display: flex;
|
| 14 |
-
flex-direction: column;
|
| 15 |
-
height: 100vh;
|
| 16 |
-
}
|
| 17 |
-
#terminal {
|
| 18 |
-
flex: 1;
|
| 19 |
-
overflow-y: auto;
|
| 20 |
-
padding: 10px;
|
| 21 |
-
background-color: #1e1e1e;
|
| 22 |
-
border: 1px solid #444;
|
| 23 |
-
}
|
| 24 |
-
#inputArea {
|
| 25 |
-
display: flex;
|
| 26 |
-
border-top: 1px solid #444;
|
| 27 |
-
padding: 10px;
|
| 28 |
-
}
|
| 29 |
-
input {
|
| 30 |
-
flex: 1;
|
| 31 |
-
background-color: #1e1e1e;
|
| 32 |
-
border: 1px solid #444;
|
| 33 |
-
color: white;
|
| 34 |
-
padding: 5px;
|
| 35 |
-
font-size: 14px;
|
| 36 |
-
}
|
| 37 |
-
button {
|
| 38 |
-
background-color: #444;
|
| 39 |
-
color: white;
|
| 40 |
-
border: none;
|
| 41 |
-
padding: 5px 10px;
|
| 42 |
-
margin-left: 5px;
|
| 43 |
-
cursor: pointer;
|
| 44 |
-
}
|
| 45 |
-
button:hover {
|
| 46 |
-
background-color: #555;
|
| 47 |
-
}
|
| 48 |
-
</style>
|
| 49 |
</head>
|
| 50 |
<body>
|
| 51 |
<div id="terminal"></div>
|
|
@@ -57,86 +16,6 @@
|
|
| 57 |
<button id="restart">Restart</button>
|
| 58 |
<button id="deploy">Deploy Kaizen</button>
|
| 59 |
</div>
|
| 60 |
-
|
| 61 |
-
<script>
|
| 62 |
-
const username = localStorage.getItem("username");
|
| 63 |
-
if (!username) {
|
| 64 |
-
alert("You need to log in first.");
|
| 65 |
-
window.location.href = "/";
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
const terminal = document.getElementById("terminal");
|
| 69 |
-
const commandInput = document.getElementById("command");
|
| 70 |
-
|
| 71 |
-
const appendToTerminal = (text) => {
|
| 72 |
-
const line = document.createElement("div");
|
| 73 |
-
line.textContent = text;
|
| 74 |
-
terminal.appendChild(line);
|
| 75 |
-
terminal.scrollTop = terminal.scrollHeight;
|
| 76 |
-
};
|
| 77 |
-
|
| 78 |
-
const fetchLogs = async () => {
|
| 79 |
-
const response = await fetch(`/logs?username=${username}`);
|
| 80 |
-
const logs = await response.text();
|
| 81 |
-
terminal.innerHTML = "";
|
| 82 |
-
logs.split("\n").forEach((line) => {
|
| 83 |
-
if (line.trim()) appendToTerminal(line);
|
| 84 |
-
});
|
| 85 |
-
};
|
| 86 |
-
|
| 87 |
-
const sendCommand = async (command) => {
|
| 88 |
-
appendToTerminal(`$ ${command}`);
|
| 89 |
-
const response = await fetch("/execute", {
|
| 90 |
-
method: "POST",
|
| 91 |
-
headers: { "Content-Type": "application/json" },
|
| 92 |
-
body: JSON.stringify({ username, command }),
|
| 93 |
-
});
|
| 94 |
-
if (response.ok) {
|
| 95 |
-
fetchLogs();
|
| 96 |
-
} else {
|
| 97 |
-
appendToTerminal("Error executing command.");
|
| 98 |
-
}
|
| 99 |
-
};
|
| 100 |
-
|
| 101 |
-
document.getElementById("send").addEventListener("click", () => {
|
| 102 |
-
const command = commandInput.value.trim();
|
| 103 |
-
if (command) {
|
| 104 |
-
sendCommand(command);
|
| 105 |
-
commandInput.value = "";
|
| 106 |
-
}
|
| 107 |
-
});
|
| 108 |
-
|
| 109 |
-
document.getElementById("start").addEventListener("click", () => {
|
| 110 |
-
sendCommand("yarn install && yarn start");
|
| 111 |
-
});
|
| 112 |
-
|
| 113 |
-
document.getElementById("stop").addEventListener("click", () => {
|
| 114 |
-
sendCommand("pkill -f node");
|
| 115 |
-
});
|
| 116 |
-
|
| 117 |
-
document.getElementById("restart").addEventListener("click", () => {
|
| 118 |
-
sendCommand("pkill -f node && yarn start");
|
| 119 |
-
});
|
| 120 |
-
|
| 121 |
-
document.getElementById("deploy").addEventListener("click", async () => {
|
| 122 |
-
const repoUrl = prompt("Enter the GitHub repository URL to deploy:");
|
| 123 |
-
if (repoUrl) {
|
| 124 |
-
const response = await fetch("/deploy", {
|
| 125 |
-
method: "POST",
|
| 126 |
-
headers: { "Content-Type": "application/json" },
|
| 127 |
-
body: JSON.stringify({ username, repoUrl }),
|
| 128 |
-
});
|
| 129 |
-
if (response.ok) {
|
| 130 |
-
appendToTerminal("Deployment started...");
|
| 131 |
-
fetchLogs();
|
| 132 |
-
} else {
|
| 133 |
-
appendToTerminal("Error starting deployment.");
|
| 134 |
-
}
|
| 135 |
-
}
|
| 136 |
-
});
|
| 137 |
-
|
| 138 |
-
// Fetch logs on load
|
| 139 |
-
fetchLogs();
|
| 140 |
-
</script>
|
| 141 |
</body>
|
| 142 |
</html>
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Terminal</title>
|
| 7 |
+
<link rel="stylesheet" href="terminal.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
</head>
|
| 9 |
<body>
|
| 10 |
<div id="terminal"></div>
|
|
|
|
| 16 |
<button id="restart">Restart</button>
|
| 17 |
<button id="deploy">Deploy Kaizen</button>
|
| 18 |
</div>
|
| 19 |
+
<script src="terminal.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
</body>
|
| 21 |
</html>
|