mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-16 05:13:36 +00:00
feat: sidebar saves state across mobile swtich, guacd hosts not migraitng passwords, terminal wrong size
This commit is contained in:
@@ -1587,11 +1587,14 @@ router.get(
|
|||||||
vncPort: hosts.vncPort,
|
vncPort: hosts.vncPort,
|
||||||
telnetPort: hosts.telnetPort,
|
telnetPort: hosts.telnetPort,
|
||||||
rdpUser: hosts.rdpUser,
|
rdpUser: hosts.rdpUser,
|
||||||
|
rdpPassword: hosts.rdpPassword,
|
||||||
rdpDomain: hosts.rdpDomain,
|
rdpDomain: hosts.rdpDomain,
|
||||||
rdpSecurity: hosts.rdpSecurity,
|
rdpSecurity: hosts.rdpSecurity,
|
||||||
rdpIgnoreCert: hosts.rdpIgnoreCert,
|
rdpIgnoreCert: hosts.rdpIgnoreCert,
|
||||||
vncUser: hosts.vncUser,
|
vncUser: hosts.vncUser,
|
||||||
|
vncPassword: hosts.vncPassword,
|
||||||
telnetUser: hosts.telnetUser,
|
telnetUser: hosts.telnetUser,
|
||||||
|
telnetPassword: hosts.telnetPassword,
|
||||||
|
|
||||||
ownerId: hosts.userId,
|
ownerId: hosts.userId,
|
||||||
isShared: sql<boolean>`${hostAccess.id} IS NOT NULL AND ${hosts.userId} != ${userId}`,
|
isShared: sql<boolean>`${hostAccess.id} IS NOT NULL AND ${hosts.userId} != ${userId}`,
|
||||||
|
|||||||
+7
-2
@@ -146,9 +146,14 @@ export function AppShell({
|
|||||||
|
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
// Close the sidebar when switching to mobile (it becomes a sheet overlay)
|
const sidebarOpenBeforeMobile = useRef(sidebarOpen);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isMobile) setSidebarOpen(false);
|
if (isMobile) {
|
||||||
|
sidebarOpenBeforeMobile.current = sidebarOpen;
|
||||||
|
setSidebarOpen(false);
|
||||||
|
} else {
|
||||||
|
setSidebarOpen(sidebarOpenBeforeMobile.current);
|
||||||
|
}
|
||||||
}, [isMobile]);
|
}, [isMobile]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -2015,14 +2015,14 @@ const TerminalInner = forwardRef<TerminalHandle, SSHTerminalProps>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
fitAddonRef.current?.fit();
|
fitAddonRef.current?.fit();
|
||||||
if (terminal.cols < 10 || terminal.rows < 3) {
|
// Double-rAF ensures layout is fully settled (fonts, flexbox, etc.) before
|
||||||
|
// committing the fitted size, preventing the "terminal too short" glitch.
|
||||||
|
requestAnimationFrame(() => {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
fitAddonRef.current?.fit();
|
fitAddonRef.current?.fit();
|
||||||
setIsFitted(true);
|
setIsFitted(true);
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
setIsFitted(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
const element = xtermRef.current;
|
const element = xtermRef.current;
|
||||||
const handleContextMenu = (e: MouseEvent) => {
|
const handleContextMenu = (e: MouseEvent) => {
|
||||||
@@ -2475,26 +2475,16 @@ const TerminalInner = forwardRef<TerminalHandle, SSHTerminalProps>(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terminal.cols < 10 || terminal.rows < 3) {
|
setIsConnecting(true);
|
||||||
|
fitAddonRef.current?.fit();
|
||||||
|
requestAnimationFrame(() => {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
|
fitAddonRef.current?.fit();
|
||||||
if (terminal.cols > 0 && terminal.rows > 0) {
|
if (terminal.cols > 0 && terminal.rows > 0) {
|
||||||
setIsConnecting(true);
|
|
||||||
fitAddonRef.current?.fit();
|
|
||||||
scheduleNotify(terminal.cols, terminal.rows);
|
scheduleNotify(terminal.cols, terminal.rows);
|
||||||
connectToHost(terminal.cols, terminal.rows);
|
connectToHost(terminal.cols, terminal.rows);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsConnecting(true);
|
|
||||||
fitAddonRef.current?.fit();
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
fitAddonRef.current?.fit();
|
|
||||||
if (terminal.cols > 0 && terminal.rows > 0) {
|
|
||||||
scheduleNotify(terminal.cols, terminal.rows);
|
|
||||||
connectToHost(terminal.cols, terminal.rows);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [terminal, hostConfig.id, isVisible, isConnected, isConnecting]);
|
}, [terminal, hostConfig.id, isVisible, isConnected, isConnecting]);
|
||||||
|
|||||||
@@ -94,15 +94,13 @@ export function HostShareModal({
|
|||||||
return (
|
return (
|
||||||
<div className="absolute inset-0 z-20 flex flex-col bg-sidebar">
|
<div className="absolute inset-0 z-20 flex flex-col bg-sidebar">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-center gap-2 px-3 py-2 shrink-0 border-b border-border text-xs text-muted-foreground hover:text-foreground">
|
<button
|
||||||
<button
|
onClick={onClose}
|
||||||
onClick={onClose}
|
className="flex items-center gap-2 px-3 py-2 shrink-0 border-b border-border text-xs text-muted-foreground hover:text-foreground transition-colors w-full text-left"
|
||||||
className="flex items-center gap-2 hover:text-foreground transition-colors"
|
>
|
||||||
>
|
<ArrowLeft className="size-3.5 shrink-0" />
|
||||||
<ArrowLeft className="size-3.5 shrink-0" />
|
<span>{t("hosts.shareHostTitle", { name: host?.name ?? "" })}</span>
|
||||||
<span>{t("hosts.shareHostTitle", { name: host?.name ?? "" })}</span>
|
</button>
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Scrollable content */}
|
{/* Scrollable content */}
|
||||||
<div className="flex flex-col flex-1 min-h-0 overflow-y-auto p-3 gap-3">
|
<div className="flex flex-col flex-1 min-h-0 overflow-y-auto p-3 gap-3">
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useRef, useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Check,
|
Check,
|
||||||
@@ -344,10 +343,9 @@ export function HostItem({
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onOpenTab("rdp");
|
onOpenTab("rdp");
|
||||||
}}
|
}}
|
||||||
className="flex items-center gap-1.5 px-2.5 h-6 rounded text-xs font-medium text-muted-foreground/70 hover:text-foreground hover:bg-muted-foreground/10 transition-colors border border-border/40"
|
className="flex items-center justify-center size-7 rounded text-muted-foreground/50 hover:text-foreground hover:bg-muted-foreground/10 transition-colors"
|
||||||
>
|
>
|
||||||
<Monitor className="size-3" />
|
<Monitor className="size-3.5" />
|
||||||
RDP
|
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{host.enableVnc && (
|
{host.enableVnc && (
|
||||||
@@ -357,10 +355,9 @@ export function HostItem({
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onOpenTab("vnc");
|
onOpenTab("vnc");
|
||||||
}}
|
}}
|
||||||
className="flex items-center gap-1.5 px-2.5 h-6 rounded text-xs font-medium text-muted-foreground/70 hover:text-foreground hover:bg-muted-foreground/10 transition-colors border border-border/40"
|
className="flex items-center justify-center size-7 rounded text-muted-foreground/50 hover:text-foreground hover:bg-muted-foreground/10 transition-colors"
|
||||||
>
|
>
|
||||||
<Monitor className="size-3" />
|
<Monitor className="size-3.5" />
|
||||||
VNC
|
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{host.enableTelnet && (
|
{host.enableTelnet && (
|
||||||
@@ -370,10 +367,9 @@ export function HostItem({
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onOpenTab("telnet");
|
onOpenTab("telnet");
|
||||||
}}
|
}}
|
||||||
className="flex items-center gap-1.5 px-2.5 h-6 rounded text-xs font-medium text-muted-foreground/70 hover:text-foreground hover:bg-muted-foreground/10 transition-colors border border-border/40"
|
className="flex items-center justify-center size-7 rounded text-muted-foreground/50 hover:text-foreground hover:bg-muted-foreground/10 transition-colors"
|
||||||
>
|
>
|
||||||
<Terminal className="size-3" />
|
<Terminal className="size-3.5" />
|
||||||
Telnet
|
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{onEditHost && (
|
{onEditHost && (
|
||||||
@@ -582,7 +578,6 @@ export function HostItem({
|
|||||||
export function FolderItem({
|
export function FolderItem({
|
||||||
folder,
|
folder,
|
||||||
depth = 0,
|
depth = 0,
|
||||||
flat = false,
|
|
||||||
onOpenTab,
|
onOpenTab,
|
||||||
onEditHost,
|
onEditHost,
|
||||||
onShareHost,
|
onShareHost,
|
||||||
@@ -600,7 +595,6 @@ export function FolderItem({
|
|||||||
}: {
|
}: {
|
||||||
folder: HostFolder;
|
folder: HostFolder;
|
||||||
depth?: number;
|
depth?: number;
|
||||||
flat?: boolean;
|
|
||||||
onOpenTab: (host: Host, type: TabType) => void;
|
onOpenTab: (host: Host, type: TabType) => void;
|
||||||
onEditHost?: (host: Host) => void;
|
onEditHost?: (host: Host) => void;
|
||||||
onShareHost?: (host: Host) => void;
|
onShareHost?: (host: Host) => void;
|
||||||
@@ -645,8 +639,7 @@ export function FolderItem({
|
|||||||
<span className="text-muted-foreground/40">/{total}</span>
|
<span className="text-muted-foreground/40">/{total}</span>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{/* Children are rendered as separate virtual rows when flat=true */}
|
{isOpen && (
|
||||||
{!flat && isOpen && (
|
|
||||||
<div className="border-l border-border/40 ml-[30px]">
|
<div className="border-l border-border/40 ml-[30px]">
|
||||||
{folder.children.map((child, i) =>
|
{folder.children.map((child, i) =>
|
||||||
isFolder(child) ? (
|
isFolder(child) ? (
|
||||||
@@ -716,7 +709,6 @@ export function SidebarTree({
|
|||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
|
||||||
const [openFolders, setOpenFolders] = useState<Set<string>>(new Set());
|
const [openFolders, setOpenFolders] = useState<Set<string>>(new Set());
|
||||||
const [selectedHostIds, setSelectedHostIds] = useState<Set<string>>(
|
const [selectedHostIds, setSelectedHostIds] = useState<Set<string>>(
|
||||||
new Set(),
|
new Set(),
|
||||||
@@ -790,13 +782,6 @@ export function SidebarTree({
|
|||||||
visibleRows.map((r, i) => [r.item, i]),
|
visibleRows.map((r, i) => [r.item, i]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const virtualizer = useVirtualizer({
|
|
||||||
count: visibleRows.length,
|
|
||||||
getScrollElement: () => scrollRef.current,
|
|
||||||
estimateSize: () => 52,
|
|
||||||
overscan: 8,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<div className="relative flex flex-col flex-1 min-h-0">
|
<div className="relative flex flex-col flex-1 min-h-0">
|
||||||
@@ -824,7 +809,7 @@ export function SidebarTree({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative flex flex-col flex-1 min-h-0">
|
<div className="relative flex flex-col flex-1 min-h-0">
|
||||||
<div className="flex-1 min-h-0 overflow-y-auto" ref={scrollRef}>
|
<div className="flex-1 min-h-0 overflow-y-auto">
|
||||||
{visibleRows.length === 0 ? (
|
{visibleRows.length === 0 ? (
|
||||||
<div className="flex flex-col items-center justify-center py-12 text-center px-4">
|
<div className="flex flex-col items-center justify-center py-12 text-center px-4">
|
||||||
<Server className="size-8 text-muted-foreground/20 mb-2" />
|
<Server className="size-8 text-muted-foreground/20 mb-2" />
|
||||||
@@ -833,78 +818,47 @@ export function SidebarTree({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div
|
children.map((child, i) =>
|
||||||
style={{
|
isFolder(child) ? (
|
||||||
height: `${virtualizer.getTotalSize()}px`,
|
<FolderItem
|
||||||
position: "relative",
|
key={i}
|
||||||
}}
|
folder={child}
|
||||||
>
|
onOpenTab={onOpenTab}
|
||||||
{virtualizer.getVirtualItems().map((vItem) => {
|
onEditHost={onEditHost}
|
||||||
const { item, depth } = visibleRows[vItem.index];
|
onShareHost={onShareHost}
|
||||||
const stripeIndex = stripeMap.get(item) ?? 0;
|
onDeleteHost={handleDeleteHost}
|
||||||
const indentPx = depth * 16;
|
onDuplicateHost={handleDuplicateHost}
|
||||||
return (
|
query={query}
|
||||||
<div
|
stripeMap={stripeMap}
|
||||||
key={vItem.key}
|
openFolders={openFolders}
|
||||||
style={{
|
onToggleFolder={toggleFolder}
|
||||||
position: "absolute",
|
selectionMode={selectionMode}
|
||||||
top: 0,
|
selectedHostIds={selectedHostIds}
|
||||||
left: 0,
|
onToggleSelect={toggleSelect}
|
||||||
width: "100%",
|
openMenuHostId={openMenuHostId}
|
||||||
transform: `translateY(${vItem.start}px)`,
|
onMenuOpenChange={setOpenMenuHostId}
|
||||||
}}
|
/>
|
||||||
>
|
) : (
|
||||||
<div
|
<HostItem
|
||||||
style={
|
key={i}
|
||||||
depth > 0 ? { paddingLeft: `${indentPx}px` } : undefined
|
host={child}
|
||||||
}
|
onOpenTab={(type) => onOpenTab(child, type)}
|
||||||
>
|
onEditHost={() => onEditHost(child)}
|
||||||
{isFolder(item) ? (
|
onShareHost={onShareHost ? () => onShareHost(child) : undefined}
|
||||||
<FolderItem
|
onDelete={() => handleDeleteHost(child)}
|
||||||
folder={item}
|
onDuplicate={() => handleDuplicateHost(child)}
|
||||||
flat={true}
|
query={query}
|
||||||
depth={depth}
|
stripeIndex={stripeMap.get(child) ?? 0}
|
||||||
onOpenTab={onOpenTab}
|
selectionMode={selectionMode}
|
||||||
onEditHost={onEditHost}
|
selected={selectedHostIds.has(child.id)}
|
||||||
onShareHost={onShareHost}
|
onToggleSelect={() => toggleSelect(child.id)}
|
||||||
onDeleteHost={handleDeleteHost}
|
isMenuOpen={openMenuHostId === child.id}
|
||||||
onDuplicateHost={handleDuplicateHost}
|
onMenuOpenChange={(open) =>
|
||||||
query={query}
|
setOpenMenuHostId(open ? child.id : null)
|
||||||
stripeMap={stripeMap}
|
}
|
||||||
openFolders={openFolders}
|
/>
|
||||||
onToggleFolder={toggleFolder}
|
),
|
||||||
selectionMode={selectionMode}
|
)
|
||||||
selectedHostIds={selectedHostIds}
|
|
||||||
onToggleSelect={toggleSelect}
|
|
||||||
openMenuHostId={openMenuHostId}
|
|
||||||
onMenuOpenChange={setOpenMenuHostId}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<HostItem
|
|
||||||
host={item}
|
|
||||||
onOpenTab={(type) => onOpenTab(item, type)}
|
|
||||||
onEditHost={() => onEditHost(item)}
|
|
||||||
onShareHost={
|
|
||||||
onShareHost ? () => onShareHost(item) : undefined
|
|
||||||
}
|
|
||||||
onDelete={() => handleDeleteHost(item)}
|
|
||||||
onDuplicate={() => handleDuplicateHost(item)}
|
|
||||||
query={query}
|
|
||||||
stripeIndex={stripeIndex}
|
|
||||||
selectionMode={selectionMode}
|
|
||||||
selected={selectedHostIds.has(item.id)}
|
|
||||||
onToggleSelect={() => toggleSelect(item.id)}
|
|
||||||
isMenuOpen={openMenuHostId === item.id}
|
|
||||||
onMenuOpenChange={(open) =>
|
|
||||||
setOpenMenuHostId(open ? item.id : null)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user