Skip to content

Commit

Permalink
feat(xo-lite): improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
J0ris-K committed Dec 4, 2024
1 parent ca0fa38 commit 1b3ce98
Show file tree
Hide file tree
Showing 10 changed files with 343 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
</tr>
</thead>
<tbody>
<tr v-for="row of rows" :key="row.id">
<tr
v-for="row of rows"
:key="row.id"
:class="{ 'row-selected': selectedRowId === (row.value as XenApiNetwork).uuid }"
@click="selectRow(row.value)"
>
<td v-for="column of row.visibleColumns" :key="column.id" class="typo p2-regular">
<UiCheckbox v-if="column.id === 'checkbox'" v-model="selected" accent="info" :value="row.id" />
<!-- NEED TO REMOVE `as XenApiNetwork` -->
Expand Down Expand Up @@ -113,10 +118,21 @@ const props = defineProps<{
isReady: boolean
}>()
const emit = defineEmits<{
rowSelectHostInternalNetwork: [value: any]
}>()
const reactiveHostInternalNetworks = ref<XenApiNetwork[]>(props.hostInternalNetwork || [])
const searchQuery = ref('')
const selectedRowId = ref('')
const selectRow = (item: any) => {
selectedRowId.value = item.uuid
emit('rowSelectHostInternalNetwork', item)
}
const filteredNetworks = computed(() => {
return searchQuery.value
? reactiveHostInternalNetworks.value.filter(network =>
Expand Down Expand Up @@ -185,18 +201,14 @@ watchEffect(() => {
}
}
.row-selected {
background-color: var(--color-info-background-selected);
}
.checkbox,
.more {
width: 4.8rem;
}
}
@media (max-width: 1440px) {
.table {
table {
width: 160rem;
}
}
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
<template>
<UiPanel v-if="selectedNetwork">
<template #header>
<UiButton variant="tertiary" size="medium" accent="info" :left-icon="faEdit">{{ $t('edit') }}</UiButton>
<UiButton variant="tertiary" size="medium" accent="danger" :left-icon="faTrash">{{ $t('delete') }}</UiButton>
<UiButtonIcon accent="info" size="medium" :icon="faEllipsis" />
</template>
<UiCard v-if="selectedNetwork" class="card-container">
<div v-tooltip="{ placement: 'bottom-end' }" class="typo p1-medium text-ellipsis">
{{ (selectedNetwork as any)?.network.name_label }}
</div>
<div>
<div class="typo p3-regular content-details">
<div class="title">{{ $t('uuid') }}</div>
<div class="value text-ellipsis">{{ (selectedNetwork as any)?.network.uuid }}</div>
<UiButtonIcon
accent="info"
size="medium"
:icon="faCopy"
@click="copyToClipboard((selectedNetwork as any)?.network.uuid)"
/>
</div>
<div class="typo p3-regular content-details">
<div class="title">{{ $t('description') }}</div>
<div class="value">{{ (selectedNetwork as any)?.network.name_description }}</div>
<UiButtonIcon
accent="info"
size="medium"
:icon="faCopy"
@click="copyToClipboard((selectedNetwork as any)?.network.name_description)"
/>
</div>
<div v-if="(selectedNetwork as any)?.vlan" class="typo p3-regular content-details">
<div class="title">{{ $t('vlan') }}</div>
<div class="value">{{ (selectedNetwork as any)?.vlan }}</div>
<UiButtonIcon accent="info" size="medium" :icon="faCopy" />
</div>
<div class="typo p3-regular content-details">
<div class="title">{{ $t('mtu') }}</div>
<div class="value">{{ (selectedNetwork as any)?.network.MTU }}</div>
<UiButtonIcon
accent="info"
size="medium"
:icon="faCopy"
@click="copyToClipboard((selectedNetwork as any)?.network.MTU)"
/>
</div>
<div v-if="(selectedNetwork as any)?.network.purpose[0]" class="typo p3-regular content-details">
<div class="title">{{ $t('network-block-device') }}</div>
<div class="value">{{ (selectedNetwork as any)?.network.purpose[0] }}</div>
<UiButtonIcon
v-if="(selectedNetwork as any)?.network.purpose[0]"
accent="info"
size="medium"
:icon="faCopy"
@click="copyToClipboard((selectedNetwork as any)?.network.purpose[0])"
/>
</div>
<div class="typo p3-regular content-details">
<div class="title">{{ $t('locking-mode-default') }}</div>
<div class="value">{{ (selectedNetwork as any)?.network.default_locking_mode }}</div>
</div>
</div>
</UiCard>
<UiCard
v-if="
selectedNetwork.network &&
(selectedNetwork as any)?.network.PIFs &&
(selectedNetwork as any)?.network.PIFs.length > 0
"
class="card-container"
>
<div class="typo p1-medium">
{{ $t('pifs') }}
<UiCounter :value="selectedPIFsLength" variant="primary" size="small" accent="neutral" />
</div>
<table class="simple-table">
<thead>
<tr>
<th class="text-left typo p3-regular">
{{ $t('host') }}
</th>
<th class="text-left typo p3-regular">
{{ $t('device') }}
</th>
<th class="text-left typo p3-regular">
{{ $t('pifs-status') }}
</th>
<th />
</tr>
</thead>
<tbody>
<tr v-for="selected in selectedPifs" :key="selected.PIF.uuid">
<td class="typo p3-regular">
<UiObjectIcon :state="selected?.host?.hostStatus ? 'running' : 'disabled'" type="host" size="small" />
{{ selected?.host?.name_label }}
</td>
<td class="typo p3-regular">{{ selected.PIF.device }}</td>
<td class="typo p3-regular">
<UiInfo v-if="selected.PIF.currently_attached" accent="success"> {{ $t('connected') }}</UiInfo>
<UiInfo v-else-if="!selected.PIF.currently_attached" accent="danger"> {{ $t('disconnected') }}</UiInfo>
<UiInfo v-else accent="warning"> {{ $t('partially-connected') }}</UiInfo>
</td>
<td>
<UiButtonIcon size="small" accent="info" :icon="faAngleRight" />
</td>
</tr>
</tbody>
</table>
</UiCard>
</UiPanel>
</template>

<script setup lang="ts">
import type { XenApiNetwork, XenApiPif } from '@/libs/xen-api/xen-api.types'
import UiButton from '@core/components/ui/button/UiButton.vue'
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
import UiCard from '@core/components/ui/card/UiCard.vue'
import UiCounter from '@core/components/ui/counter/UiCounter.vue'
import UiInfo from '@core/components/ui/info/UiInfo.vue'
import UiObjectIcon from '@core/components/ui/object-icon/UiObjectIcon.vue'
import UiPanel from '@core/components/ui/panel/UiPanel.vue'
import { vTooltip } from '@core/directives/tooltip.directive'
import { faAngleRight, faCopy, faEdit, faEllipsis, faTrash } from '@fortawesome/free-solid-svg-icons'
import { computed } from 'vue'
const { selectedPifs, selectedNetwork } = defineProps<{
selectedNetwork?: {
network: XenApiNetwork
status?: string
selected?: boolean
vlan?: string
}
selectedPifs?: {
PIF: XenApiPif
host?: {
name_label?: string
hostStatus?: boolean
}
}[]
}>()
const selectedPIFsLength = computed(() => selectedPifs?.length.toString())
const copyToClipboard = (text: string | number) => {
const stringText = String(text)
navigator.clipboard.writeText(stringText)
}
</script>

<style scoped lang="postcss">
.card-container {
display: flex;
flex-direction: column;
gap: 1.6rem;
.content-details {
display: flex;
align-items: center;
gap: 0.8rem;
.title {
color: var(--color-neutral-txt-secondary);
min-width: 12rem;
}
.value {
color: var(--color-neutral-txt-primary);
width: 20rem;
}
}
.text-left {
text-align: left;
}
.simple-table {
tbody tr {
cursor: pointer;
&:hover {
background-color: var(--color-info-background-hover);
}
}
}
.simple-table {
thead tr th {
color: var(--color-neutral-txt-secondary);
}
tbody tr td {
color: var(--color-neutral-txt-primary);
}
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
</tr>
</thead>
<tbody>
<tr v-for="row of rows" :key="row.id">
<tr
v-for="row of rows"
:key="row.id"
:class="{ 'row-selected': selectedRowId === (row.value as any).network.uuid }"
@click="selectRow(row.value)"
>
<td v-for="column of row.visibleColumns" :key="column.id" class="typo p2-regular">
<div>
<UiCheckbox v-if="column.id === 'checkbox'" v-model="selected" accent="info" :value="row.id" />
Expand Down Expand Up @@ -127,8 +132,19 @@ const props = defineProps<{
isReady: boolean
}>()
const emit = defineEmits<{
rowSelectNetwork: [value: any]
}>()
const reactiveNetworksWithVLANs = ref(props.networks || [])
const selectedRowId = ref('')
const selectRow = (item: any) => {
selectedRowId.value = item.network.uuid
emit('rowSelectNetwork', item)
}
const searchQuery = ref('')
const filteredNetworks = computed(() => {
Expand Down Expand Up @@ -213,18 +229,14 @@ watchEffect(() => {
}
}
.row-selected {
background-color: var(--color-info-background-selected);
}
.checkbox,
.more {
width: 4.8rem;
}
}
@media (max-width: 1440px) {
.table {
table {
width: 160rem;
}
}
}
}
</style>
1 change: 1 addition & 0 deletions @xen-orchestra/lite/src/libs/xen-api/xen-api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type ObjectTypeToRecordMapping = {
host_metrics: XenApiHostMetrics
message: XenApiMessage<any>
network: XenApiNetwork
pif: XenApiPif
pool: XenApiPool
sr: XenApiSr
vm: XenApiVm
Expand Down
Loading

0 comments on commit 1b3ce98

Please sign in to comment.