Skip to content

Commit 102b25c

Browse files
committed
remove Device section & move Desktop section to start in HomeView
1 parent a512b49 commit 102b25c

1 file changed

Lines changed: 34 additions & 85 deletions

File tree

src/views/HomeView.vue

Lines changed: 34 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { ref, onMounted, watch } from 'vue'
33
import { useAuthStore } from '../stores/auth'
44
import { authService } from '../services/authService'
5-
import type { Organization, Device, Desktop } from '../types'
5+
import type { Organization, Desktop } from '../types'
66
77
const authStore = useAuthStore()
88
@@ -12,13 +12,6 @@ const desktops = ref<Desktop[]>([])
1212
const isLoadingOrgs = ref(true)
1313
const isLoadingDesktops = ref(true)
1414
15-
// Mock data for Devices
16-
const devices = ref<Device[]>([
17-
{ id: 'd1', name: 'MacBook Pro M3', type: 'Laptop', status: 'Online', icon: '💻' },
18-
{ id: 'd2', name: 'iPhone 15 Pro', type: 'Mobile', status: 'Offline', icon: '📱' },
19-
{ id: 'd3', name: 'iPad Air', type: 'Tablet', status: 'Online', icon: '平板' },
20-
])
21-
2215
// Modal State
2316
const showModal = ref(false)
2417
const newOrgName = ref('')
@@ -37,7 +30,7 @@ const fetchOrganizations = async () => {
3730
organizations.value = result.args.map((org: Organization) => ({
3831
...org,
3932
role: 'Member', // Default role for display
40-
icon: '🏢' // Default icon
33+
icon: '🏢', // Default icon
4134
}))
4235
} catch (err: unknown) {
4336
console.error('Failed to fetch organizations', err)
@@ -143,22 +136,19 @@ const handleCreateOrg = async () => {
143136
</div>
144137
</div>
145138

146-
<!-- Organizations Section -->
139+
<!-- Desktops Section -->
147140
<div class="row justify-content-center mb-5">
148141
<div class="col-lg-10">
149142
<div class="d-flex justify-content-between align-items-center mb-4">
150143
<h3 class="mb-0 d-flex align-items-center">
151-
<span class="badge bg-primary me-3 p-2">
152-
<i class="bi bi-building"></i>
144+
<span class="badge bg-secondary me-3 p-2">
145+
<i class="bi bi-pc-display"></i>
153146
</span>
154-
Organizations
147+
Desktops
155148
</h3>
156-
<button @click="handleOpenModal" class="btn btn-primary btn-sm rounded-pill px-3 shadow-none no-underline-hover">
157-
<i class="bi bi-plus-lg me-1"></i> Add New
158-
</button>
159149
</div>
160150

161-
<div v-if="isLoadingOrgs" class="row g-4">
151+
<div v-if="isLoadingDesktops" class="row g-4">
162152
<div v-for="i in 3" :key="i" class="col-md-4">
163153
<div class="card h-100 border-0 shadow-sm opacity-50">
164154
<div class="card-body p-4 text-center">
@@ -171,15 +161,14 @@ const handleCreateOrg = async () => {
171161
</div>
172162

173163
<div v-else class="row g-4">
174-
<div v-for="org in organizations" :key="org.id" class="col-md-4">
175-
<router-link :to="'/organizations/' + org.id" class="text-decoration-none">
164+
<div v-for="desktop in desktops" :key="desktop.realm" class="col-md-4">
165+
<router-link :to="'/desktops/' + desktop.realm" class="text-decoration-none">
176166
<div class="card h-100 border-0 shadow-sm card-hover">
177167
<div class="card-body p-4">
178168
<div class="d-flex align-items-center mb-3">
179-
<span class="fs-2 me-3">{{ org.icon }}</span>
169+
<span class="fs-2 me-3">{{ desktop.icon }}</span>
180170
<div>
181-
<h5 class="card-title mb-0 text-dark">{{ org.name }}</h5>
182-
<small class="text-muted">{{ org.role }}</small>
171+
<h5 class="card-title mb-0 text-dark">{{ desktop.name }}</h5>
183172
</div>
184173
</div>
185174
<div class="mt-auto d-flex justify-content-between align-items-center">
@@ -192,28 +181,31 @@ const handleCreateOrg = async () => {
192181
</div>
193182

194183
<!-- Empty State -->
195-
<div v-if="organizations.length === 0" class="col-12">
184+
<div v-if="desktops.length === 0" class="col-12">
196185
<div class="card border-dashed p-5 text-center bg-transparent">
197-
<p class="text-muted mb-0">No organizations found. Create your first one!</p>
186+
<p class="text-muted mb-0">No desktops found</p>
198187
</div>
199188
</div>
200189
</div>
201190
</div>
202191
</div>
203192

204-
<!-- Desktops Section -->
193+
<!-- Organizations Section -->
205194
<div class="row justify-content-center mb-5">
206195
<div class="col-lg-10">
207196
<div class="d-flex justify-content-between align-items-center mb-4">
208197
<h3 class="mb-0 d-flex align-items-center">
209-
<span class="badge bg-secondary me-3 p-2">
210-
<i class="bi bi-pc-display"></i>
198+
<span class="badge bg-primary me-3 p-2">
199+
<i class="bi bi-building"></i>
211200
</span>
212-
Desktops
201+
Organizations
213202
</h3>
203+
<button @click="handleOpenModal" class="btn btn-primary btn-sm rounded-pill px-3 shadow-none no-underline-hover">
204+
<i class="bi bi-plus-lg me-1"></i> Add New
205+
</button>
214206
</div>
215207

216-
<div v-if="isLoadingDesktops" class="row g-4">
208+
<div v-if="isLoadingOrgs" class="row g-4">
217209
<div v-for="i in 3" :key="i" class="col-md-4">
218210
<div class="card h-100 border-0 shadow-sm opacity-50">
219211
<div class="card-body p-4 text-center">
@@ -226,14 +218,15 @@ const handleCreateOrg = async () => {
226218
</div>
227219

228220
<div v-else class="row g-4">
229-
<div v-for="desktop in desktops" :key="desktop.realm" class="col-md-4">
230-
<router-link :to="'/desktops/' + desktop.realm" class="text-decoration-none">
221+
<div v-for="org in organizations" :key="org.id" class="col-md-4">
222+
<router-link :to="'/organizations/' + org.id" class="text-decoration-none">
231223
<div class="card h-100 border-0 shadow-sm card-hover">
232224
<div class="card-body p-4">
233225
<div class="d-flex align-items-center mb-3">
234-
<span class="fs-2 me-3">{{ desktop.icon }}</span>
226+
<span class="fs-2 me-3">{{ org.icon }}</span>
235227
<div>
236-
<h5 class="card-title mb-0 text-dark">{{ desktop.name }}</h5>
228+
<h5 class="card-title mb-0 text-dark">{{ org.name }}</h5>
229+
<small class="text-muted">{{ org.role }}</small>
237230
</div>
238231
</div>
239232
<div class="mt-auto d-flex justify-content-between align-items-center">
@@ -246,55 +239,9 @@ const handleCreateOrg = async () => {
246239
</div>
247240

248241
<!-- Empty State -->
249-
<div v-if="desktops.length === 0" class="col-12">
250-
<div class="card border-dashed p-5 text-center bg-transparent">
251-
<p class="text-muted mb-0">No desktops found</p>
252-
</div>
253-
</div>
254-
</div>
255-
</div>
256-
</div>
257-
258-
<!-- Devices Section -->
259-
<div class="row justify-content-center">
260-
<div class="col-lg-10">
261-
<div class="d-flex justify-content-between align-items-center mb-4">
262-
<h3 class="mb-0 d-flex align-items-center">
263-
<span class="badge bg-secondary me-3 p-2">
264-
<i class="bi bi-laptop"></i>
265-
</span>
266-
Devices
267-
</h3>
268-
</div>
269-
270-
<div class="row g-4">
271-
<div v-for="device in devices" :key="device.id" class="col-md-4">
272-
<div class="card h-100 border-0 shadow-sm">
273-
<div class="card-body p-4">
274-
<div class="d-flex align-items-center mb-3">
275-
<span class="fs-2 me-3">{{ device.icon }}</span>
276-
<div>
277-
<h5 class="card-title mb-0">{{ device.name }}</h5>
278-
<small class="text-muted">{{ device.type }}</small>
279-
</div>
280-
</div>
281-
<div class="d-flex align-items-center">
282-
<span
283-
class="status-indicator me-2"
284-
:class="device.status === 'Online' ? 'bg-success' : 'bg-danger'"
285-
></span>
286-
<small :class="device.status === 'Online' ? 'text-success' : 'text-danger'">
287-
{{ device.status }}
288-
</small>
289-
</div>
290-
</div>
291-
</div>
292-
</div>
293-
294-
<!-- Empty State -->
295-
<div v-if="devices.length === 0" class="col-12">
242+
<div v-if="organizations.length === 0" class="col-12">
296243
<div class="card border-dashed p-5 text-center bg-transparent">
297-
<p class="text-muted mb-0">No devices registered to this account.</p>
244+
<p class="text-muted mb-0">No organizations found. Create your first one!</p>
298245
</div>
299246
</div>
300247
</div>
@@ -319,22 +266,24 @@ const handleCreateOrg = async () => {
319266
placeholder="Enter organization name"
320267
@keyup.enter="handleCreateOrg"
321268
autofocus
322-
>
269+
/>
323270
</div>
324271
<div v-if="errorMessage" class="text-danger small mt-2 d-flex align-items-center">
325272
<i class="bi bi-exclamation-circle me-1"></i> {{ errorMessage }}
326273
</div>
327274
</div>
328275
<div class="modal-footer border-0 p-4 pt-0">
329-
<button type="button" class="btn btn-link text-muted text-decoration-none fw-semibold me-auto" @click="handleCancel">
276+
<button
277+
type="button"
278+
class="btn btn-link text-muted text-decoration-none fw-semibold me-auto"
279+
@click="handleCancel">
330280
Cancel
331281
</button>
332282
<button
333283
type="button"
334284
class="btn btn-theme-primary rounded-pill px-5 py-2 fw-bold"
335285
@click="handleCreateOrg"
336-
:disabled="!newOrgName.trim() || isCreating"
337-
>
286+
:disabled="!newOrgName.trim() || isCreating">
338287
<span v-if="isCreating" class="spinner-border spinner-border-sm me-2"></span>
339288
{{ isCreating ? 'Creating...' : 'Create' }}
340289
</button>

0 commit comments

Comments
 (0)