Skip to content

Commit

Permalink
feat(xo-6/host): add dashboard view
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierFL committed Mar 3, 2025
1 parent 39613ff commit 54a4f2f
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion @xen-orchestra/lite/src/components/RelativeTime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
</template>

<script lang="ts" setup>
import useRelativeTime from '@/composables/relative-time.composable'
import { parseDateTime } from '@/libs/utils'
import useRelativeTime from '@core/composables/relative-time.composable'
import { useNow } from '@vueuse/core'
import { computed } from 'vue'
Expand Down
18 changes: 18 additions & 0 deletions @xen-orchestra/web-core/lib/utils/time.util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { utcParse } from 'd3-time-format'

export function parseDateTime(dateTime: Date | string | number): number {
if (typeof dateTime === 'number') {
return dateTime
}

if (dateTime instanceof Date) {
return dateTime.getTime()
}

dateTime = dateTime.replace(/(-|\.\d{3})/g, '') // Allow toISOString() date-time format
const date = utcParse('%Y%m%dT%H:%M:%SZ')(dateTime)
if (date === null) {
throw new RangeError(`unable to parse XAPI datetime ${JSON.stringify(dateTime)}`)
}
return date.getTime()
}
4 changes: 3 additions & 1 deletion @xen-orchestra/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@
"@fortawesome/vue-fontawesome": "^3.0.5",
"@intlify/unplugin-vue-i18n": "^2.0.0",
"@tsconfig/node18": "^18.2.2",
"@types/d3-time-format": "^4.0.3",
"@types/lodash-es": "^4.17.12",
"@types/node": "^18.19.7",
"@vitejs/plugin-vue": "^5.1.4",
"@vue/tsconfig": "^0.5.1",
"@vueuse/core": "^10.7.1",
"@vueuse/integrations": "^10.7.1",
"@vueuse/math": "^10.7.1",
"@vueuse/shared": "^10.7.1",
"@vueuse/integrations": "^10.7.1",
"@xen-orchestra/web-core": "^0.16.0",
"d3-time-format": "^4.1.0",
"lodash-es": "^4.17.21",
"npm-run-all2": "^6.1.1",
"pinia": "^2.2.6",
Expand Down
15 changes: 15 additions & 0 deletions @xen-orchestra/web/src/types/xo/host.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,19 @@ export type XoHost = {
controlDomain: string
power_state: HOST_POWER_STATE
residentVms: XoVm['id'][]
startTime: number
version: string
bios_strings: {
'system-manufacturer': string
'system-product-name': string
}
cpus: {
cores: number
sockets: number
}
memory: {
usage: number
size: number
}
tags: string[]
}
4 changes: 4 additions & 0 deletions @xen-orchestra/web/src/types/xo/vm.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ export type XoVm = {
addresses: Record<string, string>
mainIpAddress: string
other: { disable_pv_vnc: string }
CPUs: {
max: number
number: number
}
}
5 changes: 3 additions & 2 deletions @xen-orchestra/web/src/utils/xo-api-definition.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ export const xoApiDefinition = {
host: {
type: 'collection',
path: 'hosts',
fields: 'id,name_label,name_description,power_state,controlDomain,residentVms,$pool,current_operations',
fields:
'id,name_label,name_description,power_state,controlDomain,residentVms,$pool,current_operations,address,startTime,version,bios_strings,cpus,memory,tags',
handler: (record: XoHost) => record,
},
vm: {
type: 'collection',
path: 'vms',
fields: 'id,name_label,name_description,power_state,$container,$pool,other,current_operations',
fields: 'id,name_label,name_description,power_state,$container,$pool,other,current_operations,CPUs',
handler: (record: XoVm) => record,
},
task: {
Expand Down

0 comments on commit 54a4f2f

Please sign in to comment.