Skip to content

Commit 7fe2a8b

Browse files
Merge pull request #353 from community-scripts/fix/vm_detection
Add VM status check and UI improvements
2 parents f9af753 + 5274737 commit 7fe2a8b

File tree

3 files changed

+545
-225
lines changed

3 files changed

+545
-225
lines changed

src/app/_components/InstalledScriptsTab.tsx

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ interface InstalledScript {
4545
container_status?: 'running' | 'stopped' | 'unknown';
4646
web_ui_ip: string | null;
4747
web_ui_port: number | null;
48+
is_vm?: boolean;
4849
}
4950

5051
export function InstalledScriptsTab() {
@@ -1077,23 +1078,35 @@ export function InstalledScriptsTab() {
10771078
<h2 className="text-2xl font-bold text-foreground mb-4">Installed Scripts</h2>
10781079

10791080
{stats && (
1080-
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
1081+
<div className="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-5 gap-4 mb-6">
10811082
<div className="bg-info/10 border border-info/20 p-4 rounded-lg text-center">
10821083
<div className="text-2xl font-bold text-info">{stats.total}</div>
10831084
<div className="text-sm text-info/80">Total Installations</div>
10841085
</div>
10851086
<div className="bg-success/10 border border-success/20 p-4 rounded-lg text-center">
10861087
<div className="text-2xl font-bold text-success">
1087-
{scriptsWithStatus.filter(script => script.container_status === 'running').length}
1088+
{scriptsWithStatus.filter(script => script.container_status === 'running' && !script.is_vm).length}
10881089
</div>
10891090
<div className="text-sm text-success/80">Running LXC</div>
10901091
</div>
1092+
<div className="bg-success/10 border border-success/20 p-4 rounded-lg text-center">
1093+
<div className="text-2xl font-bold text-success">
1094+
{scriptsWithStatus.filter(script => script.container_status === 'running' && script.is_vm).length}
1095+
</div>
1096+
<div className="text-sm text-success/80">Running VMs</div>
1097+
</div>
10911098
<div className="bg-error/10 border border-error/20 p-4 rounded-lg text-center">
10921099
<div className="text-2xl font-bold text-error">
1093-
{scriptsWithStatus.filter(script => script.container_status === 'stopped').length}
1100+
{scriptsWithStatus.filter(script => script.container_status === 'stopped' && !script.is_vm).length}
10941101
</div>
10951102
<div className="text-sm text-error/80">Stopped LXC</div>
10961103
</div>
1104+
<div className="bg-error/10 border border-error/20 p-4 rounded-lg text-center">
1105+
<div className="text-2xl font-bold text-error">
1106+
{scriptsWithStatus.filter(script => script.container_status === 'stopped' && script.is_vm).length}
1107+
</div>
1108+
<div className="text-sm text-error/80">Stopped VMs</div>
1109+
</div>
10971110
</div>
10981111
)}
10991112

@@ -1527,7 +1540,18 @@ export function InstalledScriptsTab() {
15271540
</div>
15281541
) : (
15291542
<div>
1530-
<div className="text-sm font-medium text-foreground">{script.script_name}</div>
1543+
<div className="flex items-center gap-2">
1544+
{script.container_id && (
1545+
<span className={`text-xs px-2 py-0.5 rounded font-medium ${
1546+
script.is_vm
1547+
? 'bg-purple-500/20 text-purple-600 dark:text-purple-400 border border-purple-500/30'
1548+
: 'bg-blue-500/20 text-blue-600 dark:text-blue-400 border border-blue-500/30'
1549+
}`}>
1550+
{script.is_vm ? 'VM' : 'LXC'}
1551+
</span>
1552+
)}
1553+
<div className="text-sm font-medium text-foreground">{script.script_name}</div>
1554+
</div>
15311555
<div className="text-sm text-muted-foreground">{script.script_path}</div>
15321556
</div>
15331557
)}
@@ -1683,7 +1707,7 @@ export function InstalledScriptsTab() {
16831707
</Button>
16841708
</DropdownMenuTrigger>
16851709
<DropdownMenuContent className="w-48 bg-card border-border">
1686-
{script.container_id && (
1710+
{script.container_id && !script.is_vm && (
16871711
<DropdownMenuItem
16881712
onClick={() => handleUpdateScript(script)}
16891713
disabled={containerStatuses.get(script.id) === 'stopped'}
@@ -1701,7 +1725,7 @@ export function InstalledScriptsTab() {
17011725
Backup
17021726
</DropdownMenuItem>
17031727
)}
1704-
{script.container_id && script.execution_mode === 'ssh' && (
1728+
{script.container_id && script.execution_mode === 'ssh' && !script.is_vm && (
17051729
<DropdownMenuItem
17061730
onClick={() => handleOpenShell(script)}
17071731
disabled={containerStatuses.get(script.id) === 'stopped'}
@@ -1728,7 +1752,7 @@ export function InstalledScriptsTab() {
17281752
{autoDetectWebUIMutation.isPending ? 'Re-detect...' : 'Re-detect IP/Port'}
17291753
</DropdownMenuItem>
17301754
)}
1731-
{script.container_id && script.execution_mode === 'ssh' && (
1755+
{script.container_id && script.execution_mode === 'ssh' && !script.is_vm && (
17321756
<>
17331757
<DropdownMenuSeparator className="bg-border" />
17341758
<DropdownMenuItem
@@ -1739,6 +1763,11 @@ export function InstalledScriptsTab() {
17391763
LXC Settings
17401764
</DropdownMenuItem>
17411765
<DropdownMenuSeparator className="bg-border" />
1766+
</>
1767+
)}
1768+
{script.container_id && script.execution_mode === 'ssh' && (
1769+
<>
1770+
{script.is_vm && <DropdownMenuSeparator className="bg-border" />}
17421771
<DropdownMenuItem
17431772
onClick={() => handleStartStop(script, (containerStatuses.get(script.id) ?? 'unknown') === 'running' ? 'stop' : 'start')}
17441773
disabled={controllingScriptId === script.id || (containerStatuses.get(script.id) ?? 'unknown') === 'unknown'}

src/app/_components/ScriptInstallationCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface InstalledScript {
3333
container_status?: 'running' | 'stopped' | 'unknown';
3434
web_ui_ip: string | null;
3535
web_ui_port: number | null;
36+
is_vm?: boolean;
3637
}
3738

3839
interface ScriptInstallationCardProps {
@@ -300,7 +301,7 @@ export function ScriptInstallationCard({
300301
</Button>
301302
</DropdownMenuTrigger>
302303
<DropdownMenuContent className="w-48 bg-card border-border">
303-
{script.container_id && (
304+
{script.container_id && !script.is_vm && (
304305
<DropdownMenuItem
305306
onClick={onUpdate}
306307
disabled={containerStatus === 'stopped'}
@@ -318,7 +319,7 @@ export function ScriptInstallationCard({
318319
Backup
319320
</DropdownMenuItem>
320321
)}
321-
{script.container_id && script.execution_mode === 'ssh' && (
322+
{script.container_id && script.execution_mode === 'ssh' && !script.is_vm && (
322323
<DropdownMenuItem
323324
onClick={onShell}
324325
disabled={containerStatus === 'stopped'}

0 commit comments

Comments
 (0)