Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c487a4e949 | |||
| b4f31aa0ab | |||
| 0d98e16f29 | |||
| db33658ffa | |||
| a38e3488e4 | |||
| 6539a7f2c4 | |||
| 790cfc581a | |||
| 053c9e8431 | |||
| 59d216f697 | |||
| d81136fe5e | |||
| e43c4a7f2a | |||
| 07c9da8a80 | |||
| 4bdd4c1d8a | |||
| 336334c7f5 | |||
| a502ae2687 | |||
| 782d8446d9 | |||
| 5b79f5fb4b | |||
| a0f84ec78e |
@@ -2,3 +2,4 @@ __pycache__/
|
|||||||
.env
|
.env
|
||||||
frontend/node_modules/
|
frontend/node_modules/
|
||||||
static/dist/
|
static/dist/
|
||||||
|
venv/
|
||||||
@@ -164,6 +164,13 @@ def init_db():
|
|||||||
CONSTRAINT fk_host_tags_tag FOREIGN KEY (tag_id)
|
CONSTRAINT fk_host_tags_tag FOREIGN KEY (tag_id)
|
||||||
REFERENCES ssh_tags(id) ON DELETE CASCADE
|
REFERENCES ssh_tags(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS ssh_snippets (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
label VARCHAR(255) NOT NULL,
|
||||||
|
command TEXT NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
"""
|
"""
|
||||||
with db_cursor() as (_, cur):
|
with db_cursor() as (_, cur):
|
||||||
for stmt in ddl.split(";"):
|
for stmt in ddl.split(";"):
|
||||||
@@ -876,7 +883,13 @@ def _connect_with_jump_chain(host_id: int) -> tuple[paramiko.SSHClient, paramiko
|
|||||||
raise RuntimeError("failed to build jump chain")
|
raise RuntimeError("failed to build jump chain")
|
||||||
|
|
||||||
|
|
||||||
|
def is_audit_log_enabled() -> bool:
|
||||||
|
return os.getenv("ENABLE_AUDIT_LOG", "true").lower() in ("1", "true", "yes")
|
||||||
|
|
||||||
|
|
||||||
def _insert_connection_audit(host_row: dict[str, Any]) -> int | None:
|
def _insert_connection_audit(host_row: dict[str, Any]) -> int | None:
|
||||||
|
if not is_audit_log_enabled():
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
with db_cursor() as (_, cur):
|
with db_cursor() as (_, cur):
|
||||||
cur.execute(
|
cur.execute(
|
||||||
@@ -957,9 +970,10 @@ def api_logout():
|
|||||||
@app.route("/api/me", methods=["GET"])
|
@app.route("/api/me", methods=["GET"])
|
||||||
def api_me():
|
def api_me():
|
||||||
version = app.config.get("VERSION", "unknown")
|
version = app.config.get("VERSION", "unknown")
|
||||||
|
audit_enabled = is_audit_log_enabled()
|
||||||
if session.get("logged_in"):
|
if session.get("logged_in"):
|
||||||
return jsonify({"logged_in": True, "app_version": version})
|
return jsonify({"logged_in": True, "app_version": version, "audit_log_enabled": audit_enabled})
|
||||||
return jsonify({"logged_in": False, "app_version": version})
|
return jsonify({"logged_in": False, "app_version": version, "audit_log_enabled": audit_enabled})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/identities", methods=["GET"])
|
@app.route("/api/identities", methods=["GET"])
|
||||||
@@ -1103,6 +1117,80 @@ def delete_identity(iid: int):
|
|||||||
return jsonify({"ok": True})
|
return jsonify({"ok": True})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/api/snippets", methods=["GET"])
|
||||||
|
@require_auth("read:hosts")
|
||||||
|
def list_snippets():
|
||||||
|
with db_cursor() as (_, cur):
|
||||||
|
cur.execute("SELECT id, label, command, created_at, updated_at FROM ssh_snippets ORDER BY label ASC")
|
||||||
|
rows = cur.fetchall()
|
||||||
|
return jsonify({"items": rows})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/api/snippets", methods=["POST"])
|
||||||
|
@require_auth("write:hosts")
|
||||||
|
def create_snippet():
|
||||||
|
req = request.get_json()
|
||||||
|
if not req:
|
||||||
|
return jsonify({"error": "invalid json"}), 400
|
||||||
|
label = (req.get("label") or "").strip()
|
||||||
|
command = req.get("command") or ""
|
||||||
|
if not label or not command:
|
||||||
|
return jsonify({"error": "label and command required"}), 400
|
||||||
|
with db_cursor() as (_, cur):
|
||||||
|
cur.execute(
|
||||||
|
"INSERT INTO ssh_snippets (label, command) VALUES (%s, %s)",
|
||||||
|
(label, command),
|
||||||
|
)
|
||||||
|
sid = cur.lastrowid
|
||||||
|
return jsonify({"id": sid}), 201
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/api/snippets/<int:sid>", methods=["PATCH"])
|
||||||
|
@require_auth("write:hosts")
|
||||||
|
def update_snippet(sid: int):
|
||||||
|
req = request.get_json()
|
||||||
|
if not req:
|
||||||
|
return jsonify({"error": "invalid json"}), 400
|
||||||
|
|
||||||
|
updates = []
|
||||||
|
args = []
|
||||||
|
if "label" in req:
|
||||||
|
label = (req["label"] or "").strip()
|
||||||
|
if not label:
|
||||||
|
return jsonify({"error": "label cannot be empty"}), 400
|
||||||
|
updates.append("label = %s")
|
||||||
|
args.append(label)
|
||||||
|
if "command" in req:
|
||||||
|
cmd = req["command"] or ""
|
||||||
|
if not cmd:
|
||||||
|
return jsonify({"error": "command cannot be empty"}), 400
|
||||||
|
updates.append("command = %s")
|
||||||
|
args.append(cmd)
|
||||||
|
|
||||||
|
if not updates:
|
||||||
|
return jsonify({"ok": True})
|
||||||
|
|
||||||
|
args.append(sid)
|
||||||
|
with db_cursor() as (_, cur):
|
||||||
|
cur.execute(
|
||||||
|
f"UPDATE ssh_snippets SET {', '.join(updates)} WHERE id = %s",
|
||||||
|
tuple(args),
|
||||||
|
)
|
||||||
|
if cur.rowcount == 0:
|
||||||
|
return jsonify({"error": "not found"}), 404
|
||||||
|
return jsonify({"ok": True})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/api/snippets/<int:sid>", methods=["DELETE"])
|
||||||
|
@require_auth("write:hosts")
|
||||||
|
def delete_snippet(sid: int):
|
||||||
|
with db_cursor() as (_, cur):
|
||||||
|
cur.execute("DELETE FROM ssh_snippets WHERE id = %s", (sid,))
|
||||||
|
if cur.rowcount == 0:
|
||||||
|
return jsonify({"error": "not found"}), 404
|
||||||
|
return jsonify({"ok": True})
|
||||||
|
|
||||||
|
|
||||||
def _host_select_sql(extra_where: str = "") -> str:
|
def _host_select_sql(extra_where: str = "") -> str:
|
||||||
return f"""
|
return f"""
|
||||||
SELECT h.id, h.folder_id, h.label, h.hostname, h.port, h.identity_id, h.jump_host_id,
|
SELECT h.id, h.folder_id, h.label, h.hostname, h.port, h.identity_id, h.jump_host_id,
|
||||||
@@ -1743,13 +1831,12 @@ def update_api_key(kid: int):
|
|||||||
|
|
||||||
@app.route("/api/api-keys/<int:kid>", methods=["DELETE"])
|
@app.route("/api/api-keys/<int:kid>", methods=["DELETE"])
|
||||||
@require_login
|
@require_login
|
||||||
def revoke_api_key(kid: int):
|
def delete_api_key(kid: int):
|
||||||
with db_cursor() as (_, cur):
|
with db_cursor() as (_, cur):
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""
|
"""
|
||||||
UPDATE api_keys
|
DELETE FROM api_keys
|
||||||
SET revoked_at = CURRENT_TIMESTAMP
|
WHERE id = %s
|
||||||
WHERE id = %s AND revoked_at IS NULL
|
|
||||||
""",
|
""",
|
||||||
(kid,),
|
(kid,),
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-3
@@ -8,15 +8,15 @@
|
|||||||
href="https://assets.jdbnet.co.uk/projects/ssh.png"
|
href="https://assets.jdbnet.co.uk/projects/ssh.png"
|
||||||
/>
|
/>
|
||||||
<link rel="manifest" href="/manifest.webmanifest" />
|
<link rel="manifest" href="/manifest.webmanifest" />
|
||||||
<meta name="theme-color" content="#0f1419" />
|
<meta name="theme-color" content="#0d1117" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link
|
<link
|
||||||
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap"
|
href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
/>
|
/>
|
||||||
<title>JDB-NET SSH</title>
|
<title>SSH</title>
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-surface text-slate-200 antialiased">
|
<body class="bg-surface text-slate-200 antialiased">
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
+278
-42
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, onUnmounted, ref } from "vue";
|
||||||
import { Folder, Pencil, Trash2 } from "lucide-vue-next";
|
import { Folder, Pencil, Trash2, Radio, ChevronDown } from "lucide-vue-next";
|
||||||
import {
|
import {
|
||||||
api,
|
api,
|
||||||
type HostRow,
|
type HostRow,
|
||||||
@@ -9,10 +9,12 @@ import {
|
|||||||
type ConnectionAuditRow,
|
type ConnectionAuditRow,
|
||||||
type ApiKeyRow,
|
type ApiKeyRow,
|
||||||
type ApiKeyScopeDef,
|
type ApiKeyScopeDef,
|
||||||
|
type SnippetRow,
|
||||||
} from "@/api";
|
} from "@/api";
|
||||||
import LoginForm from "@/components/LoginForm.vue";
|
import LoginForm from "@/components/LoginForm.vue";
|
||||||
import TabContent from "@/components/TabContent.vue";
|
import TabContent from "@/components/TabContent.vue";
|
||||||
import TagInput from "@/components/TagInput.vue";
|
import TagInput from "@/components/TagInput.vue";
|
||||||
|
import SnippetForm from "@/components/SnippetForm.vue";
|
||||||
|
|
||||||
interface TabItem {
|
interface TabItem {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -23,6 +25,7 @@ interface TabItem {
|
|||||||
const loggedIn = ref(false);
|
const loggedIn = ref(false);
|
||||||
const checking = ref(true);
|
const checking = ref(true);
|
||||||
const appVersion = ref("unknown");
|
const appVersion = ref("unknown");
|
||||||
|
const auditLogEnabled = ref(true);
|
||||||
const identities = ref<IdentityRow[]>([]);
|
const identities = ref<IdentityRow[]>([]);
|
||||||
const allHosts = ref<HostRow[]>([]);
|
const allHosts = ref<HostRow[]>([]);
|
||||||
const allFolders = ref<FolderRow[]>([]);
|
const allFolders = ref<FolderRow[]>([]);
|
||||||
@@ -33,8 +36,131 @@ const breadcrumb = ref<{ id: number; label: string }[]>([]);
|
|||||||
const searchActive = ref(false);
|
const searchActive = ref(false);
|
||||||
const currentFolderId = ref<number | null>(null);
|
const currentFolderId = ref<number | null>(null);
|
||||||
const searchQuery = ref("");
|
const searchQuery = ref("");
|
||||||
const tabs = ref<TabItem[]>([]);
|
const tabs = ref<{ id: string; hostId: number; label: string }[]>([]);
|
||||||
const activeTabId = ref<string | null>(null);
|
const activePanes = ref<string[]>([]);
|
||||||
|
const draggedTabId = ref<string | null>(null);
|
||||||
|
|
||||||
|
const broadcastMode = ref(false);
|
||||||
|
const tabRefs = ref<Record<string, any>>({});
|
||||||
|
function setTabRef(el: any, id: string) {
|
||||||
|
if (el) tabRefs.value[id] = el;
|
||||||
|
else delete tabRefs.value[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleBroadcast(data: string, sourceId: string) {
|
||||||
|
if (!broadcastMode.value) return;
|
||||||
|
for (const paneId of activePanes.value) {
|
||||||
|
if (paneId !== sourceId && tabRefs.value[paneId]) {
|
||||||
|
tabRefs.value[paneId].sendData(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const snippets = ref<SnippetRow[]>([]);
|
||||||
|
const showSnippetsMenu = ref(false);
|
||||||
|
const showSnippetForm = ref(false);
|
||||||
|
const editingSnippet = ref<SnippetRow | null>(null);
|
||||||
|
const snippetsButtonRef = ref<HTMLElement | null>(null);
|
||||||
|
const snippetsMenuRef = ref<HTMLElement | null>(null);
|
||||||
|
|
||||||
|
function closeSnippetsMenu(e: MouseEvent) {
|
||||||
|
if (
|
||||||
|
showSnippetsMenu.value &&
|
||||||
|
!snippetsButtonRef.value?.contains(e.target as Node) &&
|
||||||
|
!snippetsMenuRef.value?.contains(e.target as Node)
|
||||||
|
) {
|
||||||
|
showSnippetsMenu.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.addEventListener("click", closeSnippetsMenu);
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
document.removeEventListener("click", closeSnippetsMenu);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadSnippets() {
|
||||||
|
try {
|
||||||
|
snippets.value = await api.listSnippets();
|
||||||
|
} catch (err: any) {
|
||||||
|
loadErr.value = err.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runSnippet(command: string) {
|
||||||
|
showSnippetsMenu.value = false;
|
||||||
|
const targetPanes = broadcastMode.value ? activePanes.value : [activePanes.value[0]];
|
||||||
|
for (const paneId of targetPanes) {
|
||||||
|
if (paneId && tabRefs.value[paneId]) {
|
||||||
|
tabRefs.value[paneId].sendData(command + "\r");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveSnippet(data: { label: string; command: string }) {
|
||||||
|
try {
|
||||||
|
if (editingSnippet.value) {
|
||||||
|
await api.updateSnippet(editingSnippet.value.id, data);
|
||||||
|
} else {
|
||||||
|
await api.createSnippet(data);
|
||||||
|
}
|
||||||
|
showSnippetForm.value = false;
|
||||||
|
await loadSnippets();
|
||||||
|
} catch (err: any) {
|
||||||
|
alert(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteSnippet(id: number) {
|
||||||
|
if (!confirm("Are you sure you want to delete this snippet?")) return;
|
||||||
|
try {
|
||||||
|
await api.deleteSnippet(id);
|
||||||
|
await loadSnippets();
|
||||||
|
} catch (err: any) {
|
||||||
|
alert(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEditSnippet(s?: SnippetRow) {
|
||||||
|
showSnippetsMenu.value = false;
|
||||||
|
editingSnippet.value = s || null;
|
||||||
|
showSnippetForm.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTabDragStart(id: string) {
|
||||||
|
draggedTabId.value = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTabDrop(targetId: string) {
|
||||||
|
if (!draggedTabId.value || draggedTabId.value === targetId) return;
|
||||||
|
const from = tabs.value.findIndex((t) => t.id === draggedTabId.value);
|
||||||
|
const to = tabs.value.findIndex((t) => t.id === targetId);
|
||||||
|
if (from === -1 || to === -1) return;
|
||||||
|
const [t] = tabs.value.splice(from, 1);
|
||||||
|
tabs.value.splice(to, 0, t);
|
||||||
|
draggedTabId.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTabDragEnd() {
|
||||||
|
draggedTabId.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSplitDrop() {
|
||||||
|
if (!draggedTabId.value || activePanes.value.includes(draggedTabId.value)) {
|
||||||
|
draggedTabId.value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activePanes.value.length >= 2) {
|
||||||
|
activePanes.value = [activePanes.value[0], draggedTabId.value];
|
||||||
|
} else if (activePanes.value.length === 1) {
|
||||||
|
activePanes.value.push(draggedTabId.value);
|
||||||
|
} else {
|
||||||
|
activePanes.value = [draggedTabId.value];
|
||||||
|
}
|
||||||
|
draggedTabId.value = null;
|
||||||
|
}
|
||||||
const loadErr = ref("");
|
const loadErr = ref("");
|
||||||
const hostSortOrder = ref<"name" | "last_connected">("name");
|
const hostSortOrder = ref<"name" | "last_connected">("name");
|
||||||
/** Narrow viewports: slide-over hosts panel; md+ sidebar stays visible */
|
/** Narrow viewports: slide-over hosts panel; md+ sidebar stays visible */
|
||||||
@@ -49,6 +175,10 @@ const showFolderForm = ref(false);
|
|||||||
const showEditHost = ref(false);
|
const showEditHost = ref(false);
|
||||||
const showAuditLog = ref(false);
|
const showAuditLog = ref(false);
|
||||||
const showApiKeys = ref(false);
|
const showApiKeys = ref(false);
|
||||||
|
const showSftpPanel = ref(false);
|
||||||
|
function toggleSftp() {
|
||||||
|
showSftpPanel.value = !showSftpPanel.value;
|
||||||
|
}
|
||||||
const auditLoading = ref(false);
|
const auditLoading = ref(false);
|
||||||
const auditErr = ref("");
|
const auditErr = ref("");
|
||||||
const auditRows = ref<ConnectionAuditRow[]>([]);
|
const auditRows = ref<ConnectionAuditRow[]>([]);
|
||||||
@@ -201,6 +331,7 @@ async function refreshData() {
|
|||||||
allHosts.value = await api.listHosts();
|
allHosts.value = await api.listHosts();
|
||||||
allFolders.value = await api.listFoldersFlat();
|
allFolders.value = await api.listFoldersFlat();
|
||||||
allTags.value = await api.listTags();
|
allTags.value = await api.listTags();
|
||||||
|
await loadSnippets();
|
||||||
if (!hostForm.value.identity_id && identities.value.length) {
|
if (!hostForm.value.identity_id && identities.value.length) {
|
||||||
hostForm.value.identity_id = identities.value[0].id;
|
hostForm.value.identity_id = identities.value[0].id;
|
||||||
}
|
}
|
||||||
@@ -217,6 +348,9 @@ onMounted(async () => {
|
|||||||
if (m.app_version) {
|
if (m.app_version) {
|
||||||
appVersion.value = m.app_version;
|
appVersion.value = m.app_version;
|
||||||
}
|
}
|
||||||
|
if (m.audit_log_enabled !== undefined) {
|
||||||
|
auditLogEnabled.value = m.audit_log_enabled;
|
||||||
|
}
|
||||||
if (loggedIn.value) await refreshData();
|
if (loggedIn.value) await refreshData();
|
||||||
} catch {
|
} catch {
|
||||||
loggedIn.value = false;
|
loggedIn.value = false;
|
||||||
@@ -232,9 +366,10 @@ async function onLoggedIn() {
|
|||||||
|
|
||||||
async function logout() {
|
async function logout() {
|
||||||
await api.logout();
|
await api.logout();
|
||||||
tabs.value = [];
|
tabs.value = [];
|
||||||
activeTabId.value = null;
|
activePanes.value = [];
|
||||||
loggedIn.value = false;
|
allHosts.value = [];
|
||||||
|
loggedIn.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmtDate(ts: string | null): string {
|
function fmtDate(ts: string | null): string {
|
||||||
@@ -366,14 +501,14 @@ async function submitApiKey() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function revokeApiKey(id: number, label: string) {
|
async function deleteApiKey(id: number, label: string) {
|
||||||
if (!confirm(`Revoke API key "${label}"? This cannot be undone.`)) return;
|
if (!confirm(`Delete API key "${label}"? This cannot be undone.`)) return;
|
||||||
apiKeysErr.value = "";
|
apiKeysErr.value = "";
|
||||||
try {
|
try {
|
||||||
await api.revokeApiKey(id);
|
await api.deleteApiKey(id);
|
||||||
await refreshApiKeys();
|
await refreshApiKeys();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
apiKeysErr.value = e instanceof Error ? e.message : "Failed to revoke API key";
|
apiKeysErr.value = e instanceof Error ? e.message : "Failed to delete API key";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +534,7 @@ function fmtScopes(scopes: string[]): string {
|
|||||||
function openTab(h: HostRow) {
|
function openTab(h: HostRow) {
|
||||||
const id = crypto.randomUUID();
|
const id = crypto.randomUUID();
|
||||||
tabs.value.push({ id, hostId: h.id, label: h.label });
|
tabs.value.push({ id, hostId: h.id, label: h.label });
|
||||||
activeTabId.value = id;
|
activePanes.value = [id];
|
||||||
if (window.matchMedia("(max-width: 767px)").matches) {
|
if (window.matchMedia("(max-width: 767px)").matches) {
|
||||||
sidebarOpen.value = false;
|
sidebarOpen.value = false;
|
||||||
}
|
}
|
||||||
@@ -411,8 +546,9 @@ function toggleSidebar() {
|
|||||||
|
|
||||||
function closeTab(id: string) {
|
function closeTab(id: string) {
|
||||||
tabs.value = tabs.value.filter((t) => t.id !== id);
|
tabs.value = tabs.value.filter((t) => t.id !== id);
|
||||||
if (activeTabId.value === id) {
|
activePanes.value = activePanes.value.filter((p) => p !== id);
|
||||||
activeTabId.value = tabs.value.length ? tabs.value[tabs.value.length - 1].id : null;
|
if (activePanes.value.length === 0 && tabs.value.length) {
|
||||||
|
activePanes.value = [tabs.value[tabs.value.length - 1].id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,10 +773,9 @@ async function deleteHostRow(id: number) {
|
|||||||
await api.deleteHost(id);
|
await api.deleteHost(id);
|
||||||
allHosts.value = allHosts.value.filter((h) => h.id !== id);
|
allHosts.value = allHosts.value.filter((h) => h.id !== id);
|
||||||
tabs.value = tabs.value.filter((t) => t.hostId !== id);
|
tabs.value = tabs.value.filter((t) => t.hostId !== id);
|
||||||
if (!tabs.value.some((t) => t.id === activeTabId.value)) {
|
activePanes.value = activePanes.value.filter(p => tabs.value.some(t => t.id === p));
|
||||||
activeTabId.value = tabs.value.length
|
if (activePanes.value.length === 0 && tabs.value.length) {
|
||||||
? tabs.value[tabs.value.length - 1].id
|
activePanes.value = [tabs.value[tabs.value.length - 1].id];
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
await refreshBrowse();
|
await refreshBrowse();
|
||||||
}
|
}
|
||||||
@@ -692,27 +827,104 @@ async function deleteIdentityRow(id: number) {
|
|||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<a
|
<div class="flex items-center gap-2 truncate">
|
||||||
href="https://git.jdbnet.co.uk/jamie/ssh"
|
<span class="truncate text-sm font-semibold text-white">SSH</span>
|
||||||
target="_blank"
|
<a
|
||||||
rel="noopener noreferrer"
|
href="https://git.jdbnet.co.uk/jamie/ssh"
|
||||||
class="flex items-center gap-2 truncate"
|
target="_blank"
|
||||||
>
|
rel="noopener noreferrer"
|
||||||
<span class="truncate text-sm font-semibold text-white">JDB-NET SSH</span>
|
class="truncate text-xs text-slate-400 hover:text-slate-300"
|
||||||
<span class="truncate text-xs text-slate-400 hover:text-slate-300">{{ appVersion }}</span>
|
>
|
||||||
</a>
|
{{ appVersion }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<button
|
<button
|
||||||
|
v-if="activePanes.length > 1"
|
||||||
type="button"
|
type="button"
|
||||||
class="rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white"
|
class="hidden rounded-lg px-3 py-1.5 text-xs md:inline-flex border transition-colors"
|
||||||
|
:class="broadcastMode ? 'border-accent bg-accent/10 text-accent' : 'border-slate-800 text-slate-400 hover:border-slate-700 hover:text-white'"
|
||||||
|
@click="broadcastMode = !broadcastMode"
|
||||||
|
title="Broadcast input to all visible terminals"
|
||||||
|
>
|
||||||
|
<span class="flex items-center gap-2">
|
||||||
|
<Radio class="h-3.5 w-3.5" />
|
||||||
|
Broadcast
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<div class="relative hidden md:block">
|
||||||
|
<button
|
||||||
|
ref="snippetsButtonRef"
|
||||||
|
type="button"
|
||||||
|
class="rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white inline-flex items-center gap-1"
|
||||||
|
@click="showSnippetsMenu = !showSnippetsMenu"
|
||||||
|
>
|
||||||
|
Snippets
|
||||||
|
<ChevronDown class="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
v-if="showSnippetsMenu"
|
||||||
|
ref="snippetsMenuRef"
|
||||||
|
class="absolute right-0 top-full mt-2 w-64 rounded-xl border border-slate-700 bg-surface shadow-xl z-50 overflow-hidden"
|
||||||
|
>
|
||||||
|
<div class="max-h-64 overflow-y-auto p-1">
|
||||||
|
<div v-if="snippets.length === 0" class="p-3 text-center text-xs text-slate-500">
|
||||||
|
No snippets saved.
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="s in snippets"
|
||||||
|
:key="s.id"
|
||||||
|
class="flex items-center justify-between group rounded-lg px-2 py-1.5 hover:bg-slate-800"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex-1 text-left text-sm text-white truncate"
|
||||||
|
@click="runSnippet(s.command)"
|
||||||
|
:title="s.command"
|
||||||
|
>
|
||||||
|
{{ s.label }}
|
||||||
|
</button>
|
||||||
|
<div class="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||||
|
<button type="button" class="text-slate-400 hover:text-white p-1" @click="openEditSnippet(s)">
|
||||||
|
<Pencil class="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
<button type="button" class="text-red-400 hover:text-red-300 p-1" @click="deleteSnippet(s.id)">
|
||||||
|
<Trash2 class="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="border-t border-slate-700 p-1">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="w-full rounded-lg px-2 py-1.5 text-left text-xs text-slate-400 hover:bg-slate-800 hover:text-white"
|
||||||
|
@click="openEditSnippet()"
|
||||||
|
>
|
||||||
|
+ Add new snippet...
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="hidden rounded-lg px-3 py-1.5 text-xs md:inline-flex"
|
||||||
|
:class="showSftpPanel ? 'bg-slate-800 text-white' : 'text-slate-400 hover:bg-slate-800 hover:text-white'"
|
||||||
|
@click="toggleSftp"
|
||||||
|
>
|
||||||
|
SFTP
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="hidden rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white md:inline-flex"
|
||||||
@click="openApiKeys"
|
@click="openApiKeys"
|
||||||
>
|
>
|
||||||
API keys
|
API keys
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
v-if="auditLogEnabled"
|
||||||
type="button"
|
type="button"
|
||||||
class="rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white"
|
class="hidden rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white md:inline-flex"
|
||||||
@click="openAuditLog"
|
@click="openAuditLog"
|
||||||
>
|
>
|
||||||
Connection audit
|
Connection audit
|
||||||
@@ -989,13 +1201,19 @@ async function deleteIdentityRow(id: number) {
|
|||||||
v-for="t in tabs"
|
v-for="t in tabs"
|
||||||
:key="t.id"
|
:key="t.id"
|
||||||
type="button"
|
type="button"
|
||||||
class="flex items-center gap-2 rounded-t-lg border border-b-0 px-3 py-2 text-sm"
|
draggable="true"
|
||||||
:class="
|
@dragstart="onTabDragStart(t.id)"
|
||||||
t.id === activeTabId
|
@dragover.prevent
|
||||||
|
@drop="onTabDrop(t.id)"
|
||||||
|
@dragend="onTabDragEnd"
|
||||||
|
class="flex items-center gap-2 rounded-t-lg border border-b-0 px-3 py-2 text-sm transition-colors"
|
||||||
|
:class="[
|
||||||
|
activePanes.includes(t.id)
|
||||||
? 'border-slate-700 bg-surface text-white'
|
? 'border-slate-700 bg-surface text-white'
|
||||||
: 'border-transparent bg-transparent text-slate-400 hover:text-white'
|
: 'border-transparent bg-transparent text-slate-400 hover:text-white',
|
||||||
"
|
draggedTabId && draggedTabId !== t.id ? 'hover:bg-slate-800/50' : ''
|
||||||
@click="activeTabId = t.id"
|
]"
|
||||||
|
@click="activePanes = [t.id]"
|
||||||
>
|
>
|
||||||
{{ t.label }}
|
{{ t.label }}
|
||||||
<span
|
<span
|
||||||
@@ -1004,23 +1222,42 @@ async function deleteIdentityRow(id: number) {
|
|||||||
>×</span>
|
>×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="min-h-0 flex-1 p-2 md:p-3">
|
<div class="relative min-h-0 flex-1 flex flex-row gap-2 p-2 md:p-3">
|
||||||
<div
|
<div
|
||||||
v-for="t in tabs"
|
v-for="t in tabs"
|
||||||
v-show="t.id === activeTabId"
|
v-show="activePanes.includes(t.id)"
|
||||||
:key="t.id"
|
:key="t.id"
|
||||||
class="h-full min-h-0"
|
class="flex-1 min-w-0 h-full"
|
||||||
>
|
>
|
||||||
<TabContent
|
<TabContent
|
||||||
|
:ref="(el) => setTabRef(el, t.id)"
|
||||||
:host-id="t.hostId"
|
:host-id="t.hostId"
|
||||||
:visible="t.id === activeTabId"
|
:visible="activePanes.includes(t.id)"
|
||||||
|
:show-sftp="showSftpPanel"
|
||||||
|
@broadcast-data="(data: string) => handleBroadcast(data, t.id)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="draggedTabId && activePanes.length === 1 && !activePanes.includes(draggedTabId)"
|
||||||
|
class="absolute inset-y-2 right-2 md:inset-y-3 md:right-3 w-[calc(50%-0.25rem)] z-50 flex items-center justify-center rounded-lg border-2 border-dashed border-accent bg-accent/10 backdrop-blur-[2px] transition-all"
|
||||||
|
@dragover.prevent
|
||||||
|
@drop="onSplitDrop"
|
||||||
|
>
|
||||||
|
<span class="font-medium text-accent">Drop to split side-by-side</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SnippetForm
|
||||||
|
v-if="showSnippetForm"
|
||||||
|
:snippet="editingSnippet"
|
||||||
|
@save="saveSnippet"
|
||||||
|
@cancel="showSnippetForm = false"
|
||||||
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="showApiKeys"
|
v-if="showApiKeys"
|
||||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4"
|
class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4"
|
||||||
@@ -1139,12 +1376,11 @@ async function deleteIdentityRow(id: number) {
|
|||||||
<td class="px-2 py-2">{{ apiKeyStatus(row) }}</td>
|
<td class="px-2 py-2">{{ apiKeyStatus(row) }}</td>
|
||||||
<td class="px-2 py-2 text-right">
|
<td class="px-2 py-2 text-right">
|
||||||
<button
|
<button
|
||||||
v-if="row.active"
|
|
||||||
type="button"
|
type="button"
|
||||||
class="rounded px-2 py-1 text-red-400 hover:bg-slate-800"
|
class="rounded px-2 py-1 text-red-400 hover:bg-slate-800"
|
||||||
@click="revokeApiKey(row.id, row.label)"
|
@click="deleteApiKey(row.id, row.label)"
|
||||||
>
|
>
|
||||||
Revoke
|
Delete
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
+76
-8
@@ -21,7 +21,7 @@ function browseParams(folderId: number | null, q: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const api = {
|
export const api = {
|
||||||
async me(): Promise<{ logged_in: boolean; app_version?: string }> {
|
async me(): Promise<{ logged_in: boolean; app_version?: string; audit_log_enabled?: boolean }> {
|
||||||
const res = await fetch("/api/me", { credentials: "include" });
|
const res = await fetch("/api/me", { credentials: "include" });
|
||||||
return handle(res);
|
return handle(res);
|
||||||
},
|
},
|
||||||
@@ -188,6 +188,43 @@ export const api = {
|
|||||||
await handle(res);
|
await handle(res);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async listSnippets(): Promise<SnippetRow[]> {
|
||||||
|
const res = await fetch("/api/snippets", { credentials: "include" });
|
||||||
|
const d = await handle<{ items: SnippetRow[] }>(res);
|
||||||
|
return d.items;
|
||||||
|
},
|
||||||
|
|
||||||
|
async createSnippet(body: Record<string, unknown>): Promise<{ id: number }> {
|
||||||
|
const res = await fetch("/api/snippets", {
|
||||||
|
method: "POST",
|
||||||
|
credentials: "include",
|
||||||
|
headers: jsonHeaders,
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
});
|
||||||
|
return handle(res);
|
||||||
|
},
|
||||||
|
|
||||||
|
async updateSnippet(
|
||||||
|
id: number,
|
||||||
|
body: Partial<{ label: string; command: string }>,
|
||||||
|
): Promise<void> {
|
||||||
|
const res = await fetch(`/api/snippets/${id}`, {
|
||||||
|
method: "PATCH",
|
||||||
|
credentials: "include",
|
||||||
|
headers: jsonHeaders,
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
});
|
||||||
|
await handle(res);
|
||||||
|
},
|
||||||
|
|
||||||
|
async deleteSnippet(id: number): Promise<void> {
|
||||||
|
const res = await fetch(`/api/snippets/${id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
credentials: "include",
|
||||||
|
});
|
||||||
|
await handle(res);
|
||||||
|
},
|
||||||
|
|
||||||
async listConnectionAudit(limit = 200, daysBack?: number): Promise<ConnectionAuditRow[]> {
|
async listConnectionAudit(limit = 200, daysBack?: number): Promise<ConnectionAuditRow[]> {
|
||||||
const q = new URLSearchParams({ limit: String(limit) });
|
const q = new URLSearchParams({ limit: String(limit) });
|
||||||
if (daysBack !== undefined) {
|
if (daysBack !== undefined) {
|
||||||
@@ -226,7 +263,7 @@ export const api = {
|
|||||||
return handle(res);
|
return handle(res);
|
||||||
},
|
},
|
||||||
|
|
||||||
async revokeApiKey(id: number): Promise<void> {
|
async deleteApiKey(id: number): Promise<void> {
|
||||||
const res = await fetch(`/api/api-keys/${id}`, {
|
const res = await fetch(`/api/api-keys/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
@@ -281,16 +318,41 @@ export const api = {
|
|||||||
await handle(res);
|
await handle(res);
|
||||||
},
|
},
|
||||||
|
|
||||||
async sftpUpload(connId: string, path: string, file: File): Promise<void> {
|
async sftpUpload(
|
||||||
|
connId: string,
|
||||||
|
path: string,
|
||||||
|
file: File,
|
||||||
|
onProgress?: (loaded: number, total: number) => void
|
||||||
|
): Promise<void> {
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
fd.set("path", path);
|
fd.set("path", path);
|
||||||
fd.set("file", file);
|
fd.set("file", file);
|
||||||
const res = await fetch(`/api/sftp/${connId}/upload`, {
|
return new Promise((resolve, reject) => {
|
||||||
method: "POST",
|
const xhr = new XMLHttpRequest();
|
||||||
credentials: "include",
|
xhr.open("POST", `/api/sftp/${connId}/upload`);
|
||||||
body: fd,
|
xhr.withCredentials = true;
|
||||||
|
if (onProgress) {
|
||||||
|
xhr.upload.onprogress = (e) => {
|
||||||
|
if (e.lengthComputable) {
|
||||||
|
onProgress(e.loaded, e.total);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
xhr.onload = () => {
|
||||||
|
if (xhr.status === 401) return reject(new Error("unauthorized"));
|
||||||
|
let data: any = {};
|
||||||
|
try {
|
||||||
|
data = JSON.parse(xhr.responseText);
|
||||||
|
} catch (e) {}
|
||||||
|
if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
reject(new Error(data.error || xhr.statusText));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.onerror = () => reject(new Error("Network Error"));
|
||||||
|
xhr.send(fd);
|
||||||
});
|
});
|
||||||
await handle(res);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
sftpDownloadUrl(connId: string, path: string): string {
|
sftpDownloadUrl(connId: string, path: string): string {
|
||||||
@@ -327,6 +389,12 @@ export interface IdentityRow {
|
|||||||
auth_type: string;
|
auth_type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SnippetRow {
|
||||||
|
id: number;
|
||||||
|
label: string;
|
||||||
|
command: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface SftpEntry {
|
export interface SftpEntry {
|
||||||
filename: string;
|
filename: string;
|
||||||
st_mode: number;
|
st_mode: number;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ async function submit() {
|
|||||||
class="w-full max-w-md rounded-xl border border-slate-800 bg-surface-raised p-8 shadow-xl"
|
class="w-full max-w-md rounded-xl border border-slate-800 bg-surface-raised p-8 shadow-xl"
|
||||||
>
|
>
|
||||||
<h1 class="font-sans text-2xl font-semibold tracking-tight text-white">
|
<h1 class="font-sans text-2xl font-semibold tracking-tight text-white">
|
||||||
JDB-NET SSH
|
SSH
|
||||||
</h1>
|
</h1>
|
||||||
<p class="mt-1 text-sm text-slate-400">
|
<p class="mt-1 text-sm text-slate-400">
|
||||||
Sign in to manage connections and open terminals.
|
Sign in to manage connections and open terminals.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const err = ref("");
|
|||||||
const busy = ref(false);
|
const busy = ref(false);
|
||||||
const renameTarget = ref<SftpEntry | null>(null);
|
const renameTarget = ref<SftpEntry | null>(null);
|
||||||
const newName = ref("");
|
const newName = ref("");
|
||||||
|
const uploadProgress = ref<number | null>(null);
|
||||||
|
|
||||||
function isDir(m: number): boolean {
|
function isDir(m: number): boolean {
|
||||||
return (m & 0o170000) === 0o040000;
|
return (m & 0o170000) === 0o040000;
|
||||||
@@ -66,11 +67,16 @@ async function onUpload(ev: Event) {
|
|||||||
input.value = "";
|
input.value = "";
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
err.value = "";
|
err.value = "";
|
||||||
|
uploadProgress.value = 0;
|
||||||
try {
|
try {
|
||||||
await api.sftpUpload(props.connId, path.value, file);
|
await api.sftpUpload(props.connId, path.value, file, (loaded, total) => {
|
||||||
|
uploadProgress.value = Math.round((loaded / total) * 100);
|
||||||
|
});
|
||||||
await load();
|
await load();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
err.value = e instanceof Error ? e.message : "Upload failed";
|
err.value = e instanceof Error ? e.message : "Upload failed";
|
||||||
|
} finally {
|
||||||
|
uploadProgress.value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +192,19 @@ function fmtSize(n: number): string {
|
|||||||
</div>
|
</div>
|
||||||
<div class="min-h-0 flex-1 overflow-auto p-2">
|
<div class="min-h-0 flex-1 overflow-auto p-2">
|
||||||
<p v-if="err" class="mb-2 text-xs text-red-400">{{ err }}</p>
|
<p v-if="err" class="mb-2 text-xs text-red-400">{{ err }}</p>
|
||||||
<p v-if="busy" class="text-xs text-slate-500">Loading…</p>
|
<div v-if="uploadProgress !== null" class="mb-2 space-y-1">
|
||||||
|
<div class="flex justify-between text-[10px] text-slate-400">
|
||||||
|
<span>Uploading...</span>
|
||||||
|
<span>{{ uploadProgress }}%</span>
|
||||||
|
</div>
|
||||||
|
<div class="h-1.5 w-full overflow-hidden rounded-full bg-slate-800">
|
||||||
|
<div
|
||||||
|
class="h-full bg-accent transition-all duration-200"
|
||||||
|
:style="{ width: uploadProgress + '%' }"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p v-else-if="busy" class="text-xs text-slate-500">Loading…</p>
|
||||||
<ul v-else class="space-y-0.5">
|
<ul v-else class="space-y-0.5">
|
||||||
<li
|
<li
|
||||||
v-for="e in entries"
|
v-for="e in entries"
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from "vue";
|
||||||
|
import type { SnippetRow } from "@/api";
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
snippet?: SnippetRow | null;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: "save", data: { label: string; command: string }): void;
|
||||||
|
(e: "cancel"): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const label = ref(props.snippet?.label || "");
|
||||||
|
const command = ref(props.snippet?.command || "");
|
||||||
|
|
||||||
|
function submit() {
|
||||||
|
if (!label.value.trim() || !command.value.trim()) return;
|
||||||
|
emit("save", {
|
||||||
|
label: label.value.trim(),
|
||||||
|
command: command.value.trim(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4 backdrop-blur-sm"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="w-full max-w-md rounded-xl border border-slate-700 bg-surface shadow-2xl"
|
||||||
|
>
|
||||||
|
<div class="flex items-center justify-between border-b border-slate-800 p-4">
|
||||||
|
<h2 class="text-lg font-semibold text-white">
|
||||||
|
{{ snippet ? "Edit snippet" : "Add snippet" }}
|
||||||
|
</h2>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="text-slate-400 hover:text-white"
|
||||||
|
@click="emit('cancel')"
|
||||||
|
>
|
||||||
|
×
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form class="space-y-4 p-4" @submit.prevent="submit">
|
||||||
|
<div>
|
||||||
|
<label class="mb-1 block text-sm font-medium text-slate-300">
|
||||||
|
Label
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
v-model="label"
|
||||||
|
type="text"
|
||||||
|
required
|
||||||
|
class="w-full rounded-lg border border-slate-700 bg-surface-overlay px-3 py-2 text-sm text-white placeholder:text-slate-500 focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent"
|
||||||
|
placeholder="e.g. Docker logs"
|
||||||
|
autocomplete="off"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="mb-1 block text-sm font-medium text-slate-300">
|
||||||
|
Command
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
v-model="command"
|
||||||
|
required
|
||||||
|
rows="3"
|
||||||
|
class="w-full rounded-lg border border-slate-700 bg-surface-overlay px-3 py-2 text-sm font-mono text-white placeholder:text-slate-500 focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent"
|
||||||
|
placeholder="docker compose logs -f"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end gap-2 pt-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="rounded-lg px-4 py-2 text-sm font-medium text-slate-300 hover:text-white"
|
||||||
|
@click="emit('cancel')"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="rounded-lg bg-accent px-4 py-2 text-sm font-medium text-black hover:bg-[#16966b]"
|
||||||
|
>
|
||||||
|
Save snippet
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -14,8 +14,21 @@ import SftpPanel from "./SftpPanel.vue";
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
hostId: number;
|
hostId: number;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
showSftp: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'broadcast-data', data: string): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
sendData: (data: string) => {
|
||||||
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||||
|
ws.send(new TextEncoder().encode(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const termEl = ref<HTMLElement | null>(null);
|
const termEl = ref<HTMLElement | null>(null);
|
||||||
const status = ref("Connecting…");
|
const status = ref("Connecting…");
|
||||||
const connId = ref<string | null>(null);
|
const connId = ref<string | null>(null);
|
||||||
@@ -78,12 +91,13 @@ onMounted(async () => {
|
|||||||
|
|
||||||
term = new Terminal({
|
term = new Terminal({
|
||||||
cursorBlink: true,
|
cursorBlink: true,
|
||||||
fontFamily: "IBM Plex Mono, monospace",
|
fontFamily: "DM Mono, ui-monospace, monospace",
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
theme: {
|
theme: {
|
||||||
background: "#0a0e12",
|
background: "#0d1117",
|
||||||
foreground: "#e2e8f0",
|
foreground: "#e6edf3",
|
||||||
cursor: "#3d9aed",
|
cursor: "#1ebe8a",
|
||||||
|
selectionBackground: "rgba(30, 190, 138, 0.3)",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
fit = new FitAddon();
|
fit = new FitAddon();
|
||||||
@@ -95,6 +109,7 @@ onMounted(async () => {
|
|||||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||||
ws.send(new TextEncoder().encode(data));
|
ws.send(new TextEncoder().encode(data));
|
||||||
}
|
}
|
||||||
|
emit("broadcast-data", data);
|
||||||
});
|
});
|
||||||
|
|
||||||
term.onResize(({ cols, rows }) => {
|
term.onResize(({ cols, rows }) => {
|
||||||
@@ -184,20 +199,22 @@ watch(
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
ref="termEl"
|
ref="termEl"
|
||||||
class="h-full min-h-[320px] rounded-lg border border-slate-800 bg-[#0a0e12] p-1"
|
class="h-full min-h-[320px] rounded-lg border border-slate-800 bg-[#0d1117] p-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<template v-if="showSftp">
|
||||||
v-if="connId"
|
<div
|
||||||
class="hidden w-80 shrink-0 flex-col border-l border-slate-800 md:flex"
|
v-if="connId"
|
||||||
>
|
class="hidden w-80 shrink-0 flex-col border-l border-slate-800 md:flex"
|
||||||
<SftpPanel :conn-id="connId" />
|
>
|
||||||
</div>
|
<SftpPanel :conn-id="connId" />
|
||||||
<div
|
</div>
|
||||||
v-else
|
<div
|
||||||
class="hidden w-72 shrink-0 items-center justify-center border-l border-slate-800 bg-surface-raised text-xs text-slate-500 md:flex"
|
v-else
|
||||||
>
|
class="hidden w-72 shrink-0 items-center justify-center border-l border-slate-800 bg-surface-raised text-xs text-slate-500 md:flex"
|
||||||
SFTP unlocks when the shell session is ready.
|
>
|
||||||
</div>
|
SFTP unlocks when the shell session is ready.
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -5,18 +5,28 @@ export default {
|
|||||||
extend: {
|
extend: {
|
||||||
colors: {
|
colors: {
|
||||||
surface: {
|
surface: {
|
||||||
DEFAULT: "#0f1419",
|
DEFAULT: "#0d1117",
|
||||||
raised: "#151c24",
|
raised: "#161b22",
|
||||||
overlay: "#1a232e",
|
overlay: "#21262d",
|
||||||
},
|
},
|
||||||
accent: {
|
accent: {
|
||||||
DEFAULT: "#3d9aed",
|
DEFAULT: "#1ebe8a",
|
||||||
muted: "#2a6fa3",
|
muted: "#16966b",
|
||||||
|
},
|
||||||
|
slate: {
|
||||||
|
200: "#e6edf3",
|
||||||
|
300: "#c9d1d9",
|
||||||
|
400: "#8b949e",
|
||||||
|
500: "#6e7681",
|
||||||
|
600: "#484f58",
|
||||||
|
700: "#30363d",
|
||||||
|
800: "#21262d",
|
||||||
|
900: "#161b22",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fontFamily: {
|
fontFamily: {
|
||||||
sans: ["IBM Plex Sans", "system-ui", "sans-serif"],
|
sans: ["Space Grotesk", "system-ui", "sans-serif"],
|
||||||
mono: ["IBM Plex Mono", "ui-monospace", "monospace"],
|
mono: ["DM Mono", "ui-monospace", "monospace"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Generated
-6
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ssh",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -d "venv" ]; then
|
||||||
|
echo "Creating virtual environment in 'venv'..."
|
||||||
|
python3 -m venv venv
|
||||||
|
source venv/bin/activate
|
||||||
|
if [ -f "requirements.txt" ]; then
|
||||||
|
echo "Installing requirements..."
|
||||||
|
pip install -r requirements.txt
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
source venv/bin/activate
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building frontend..."
|
||||||
|
(
|
||||||
|
cd frontend
|
||||||
|
if [ ! -d "node_modules" ]; then
|
||||||
|
echo "Installing frontend dependencies..."
|
||||||
|
npm install
|
||||||
|
fi
|
||||||
|
npm run build
|
||||||
|
)
|
||||||
|
|
||||||
|
exec gunicorn --bind 0.0.0.0:5000 --workers 1 --worker-class geventwebsocket.gunicorn.workers.GeventWebSocketWorker app:app --log-level info
|
||||||
Reference in New Issue
Block a user