Skip to content

Commit a8f7226

Browse files
authored
Merge pull request #14 from xconnio/improve-shell-experience
Improve shell experience
2 parents 437769a + e3e0807 commit a8f7226

4 files changed

Lines changed: 55 additions & 43 deletions

File tree

src/App.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<script setup lang="ts">
22
import { onMounted } from 'vue'
3-
import { RouterView, useRouter } from 'vue-router'
3+
import { RouterView, useRoute, useRouter } from 'vue-router'
44
import { useAuthStore } from './stores/auth'
55
66
const router = useRouter()
7+
const route = useRoute()
78
const authStore = useAuthStore()
89
910
const handleLogout = () => {
@@ -39,7 +40,7 @@ onMounted(async () => {
3940
<template>
4041
<div class="min-vh-100 d-flex flex-column bg-light">
4142
<!-- Header -->
42-
<header class="navbar navbar-expand-lg header-theme">
43+
<header v-if="!route.meta.hideNavbar" class="navbar navbar-expand-lg header-theme">
4344
<div class="container-fluid">
4445
<router-link to="/" class="navbar-brand mb-0 h1 fw-bold ps-3 text-dark text-decoration-none"
4546
>Deskconn</router-link

src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const router = createRouter({
5454
path: '/desktops/:realm',
5555
name: 'desktop-shell',
5656
component: () => import('../views/DesktopShellView.vue'),
57-
meta: { requiresAuth: true },
57+
meta: { requiresAuth: true, hideNavbar: true },
5858
},
5959
],
6060
})

src/views/DesktopShellView.vue

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,17 @@ const handleTerminalInput = (data: string) => {
6565
channel.push(new Progress([data], {}, { progress: true }))
6666
}
6767
68-
const closeShell = async (reason?: string) => {
68+
const closeShell = async () => {
6969
if (closed) return
7070
closed = true
7171
72-
try {
73-
// Stop sender loop safely
74-
channel?.push(new Progress([], {}, {}))
75-
} catch {}
76-
7772
window.removeEventListener('resize', handleResize)
7873
79-
try {
80-
await session?.leave()
81-
} catch (err) {
82-
console.error('Error leaving session:', err)
83-
}
74+
session = null
8475
85-
if (term) {
86-
if (reason) {
87-
term.writeln(`\r\n${reason}`)
88-
}
89-
term.writeln('\r\nSession closed.')
90-
}
76+
term?.dispose()
77+
78+
window.close()
9179
}
9280
9381
const startShell = async () => {
@@ -102,8 +90,8 @@ const startShell = async () => {
10290
if (args && args.length > 0 && term) {
10391
term.write(args[0])
10492
} else {
105-
channel!.push(new Progress([], {}, {}))
106-
await closeShell('Remote shell ended.')
93+
channel?.push(new Progress([], {}, {}))
94+
await closeShell()
10795
}
10896
},
10997
)
@@ -123,8 +111,9 @@ onMounted(async () => {
123111
124112
term = new Terminal({
125113
cursorBlink: true,
114+
cursorStyle: "block",
126115
convertEol: true,
127-
scrollback: 5000,
116+
scrollback: 10000,
128117
fontSize: 15,
129118
theme: { background: '#1e1e1e' },
130119
})
@@ -134,8 +123,7 @@ onMounted(async () => {
134123
135124
term.open(terminalRef.value)
136125
fitAddon.fit()
137-
138-
term.writeln('Starting shell ...')
126+
term.focus()
139127
140128
try {
141129
session = await authStore.shellWebRTC(realm)

src/views/HomeView.vue

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
<script setup lang="ts">
22
import { ref, onMounted, watch } from 'vue'
3+
import { useRouter } from 'vue-router'
4+
35
import { useAuthStore } from '../stores/auth'
46
import { authService } from '../services/authService'
57
import type { Organization, Desktop } from '../types'
68
79
const authStore = useAuthStore()
10+
const router = useRouter()
11+
12+
function openDesktop(realm: string) {
13+
const url = router.resolve(`/desktops/${realm}`).href
14+
15+
const width = 1000
16+
const height = 700
17+
18+
const left = window.screenX + (window.outerWidth - width) / 2
19+
const top = window.screenY + (window.outerHeight - height) / 2
20+
21+
window.open(
22+
url,
23+
'_blank',
24+
`width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`,
25+
)
26+
}
827
928
// State
1029
const organizations = ref<Organization[]>([])
@@ -162,28 +181,32 @@ const handleCreateOrg = async () => {
162181

163182
<div v-else class="row g-4">
164183
<div v-for="desktop in desktops" :key="desktop.realm" class="col-md-4">
165-
<router-link :to="'/desktops/' + desktop.realm" class="text-decoration-none">
166-
<div class="card h-100 border-0 shadow-sm card-hover">
167-
<div class="card-body p-4">
168-
<div class="d-flex align-items-center mb-3">
169-
<span class="fs-2 me-3">{{ desktop.icon }}</span>
170-
<div>
171-
<h5 class="card-title mb-0 text-dark">{{ desktop.name }}</h5>
172-
</div>
173-
</div>
174-
<div class="mt-auto d-flex justify-content-between align-items-center">
175-
<span class="badge bg-light text-primary rounded-pill">View Details</span>
176-
<i class="bi bi-chevron-right text-muted"></i>
184+
<div class="card h-100 border-0 shadow-sm">
185+
<div class="card-body p-4 d-flex flex-column">
186+
<div class="d-flex align-items-center mb-3">
187+
<span class="fs-2 me-3">{{ desktop.icon }}</span>
188+
<div>
189+
<h5 class="card-title mb-0 text-dark">{{ desktop.name }}</h5>
177190
</div>
178191
</div>
192+
193+
<div class="mt-auto d-flex justify-content-between align-items-center">
194+
<span class="badge bg-light text-secondary rounded-pill"> Desktop </span>
195+
<button
196+
class="btn btn-sm btn-outline-primary"
197+
@click="openDesktop(desktop.realm)"
198+
title="Open Terminal">
199+
<i class="bi bi-terminal"></i>
200+
</button>
201+
</div>
179202
</div>
180-
</router-link>
181-
</div>
203+
</div>
182204

183-
<!-- Empty State -->
184-
<div v-if="desktops.length === 0" class="col-12">
185-
<div class="card border-dashed p-5 text-center bg-transparent">
186-
<p class="text-muted mb-0">No desktops found</p>
205+
<!-- Empty State -->
206+
<div v-if="desktops.length === 0" class="col-12">
207+
<div class="card border-dashed p-5 text-center bg-transparent">
208+
<p class="text-muted mb-0">No desktops found</p>
209+
</div>
187210
</div>
188211
</div>
189212
</div>

0 commit comments

Comments
 (0)