diff --git a/.eslintrc.js b/.eslintrc.js index 6d328e765f..0536a49192 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -104,6 +104,8 @@ module.exports = { 'no-redeclare': 'off', // automatically checked by the TypeScript compiler 'no-dupe-class-members': 'off', // automatically checked by the TypeScript compiler 'no-undef': 'off', // automatically checked by the TypeScript compiler + 'no-use-before-define': 'off', // replaced with the rule below + '@typescript-eslint/no-use-before-define': ['error', { functions: false }], '@typescript-eslint/no-explicit-any': 'off', 'vue/multi-word-component-names': 'off', // Vue 3 - Strongly Recommended diff --git a/@xen-orchestra/lite/src/components/RemoteConsole.vue b/@xen-orchestra/lite/src/components/RemoteConsole.vue index 1aad045911..02b2effd78 100644 --- a/@xen-orchestra/lite/src/components/RemoteConsole.vue +++ b/@xen-orchestra/lite/src/components/RemoteConsole.vue @@ -32,7 +32,7 @@ const url = computed(() => { let vncClient: VncClient | undefined let nConnectionAttempts = 0 -const handleDisconnectionEvent = () => { +function handleDisconnectionEvent() { clearVncClient() if (props.isConsoleAvailable) { @@ -51,9 +51,12 @@ const handleDisconnectionEvent = () => { createVncConnection() } } -const handleConnectionEvent = () => (nConnectionAttempts = 0) -const clearVncClient = () => { +function handleConnectionEvent() { + nConnectionAttempts = 0 +} + +function clearVncClient() { if (vncClient === undefined) { return } @@ -66,7 +69,7 @@ const clearVncClient = () => { vncClient = undefined } -const createVncConnection = async () => { +async function createVncConnection() { if (nConnectionAttempts !== 0) { await promiseTimeout(FIBONACCI_MS_ARRAY[nConnectionAttempts - 1]) diff --git a/@xen-orchestra/lite/src/components/component-story/ComponentStory.vue b/@xen-orchestra/lite/src/components/component-story/ComponentStory.vue index c1ed888449..51304e0b88 100644 --- a/@xen-orchestra/lite/src/components/component-story/ComponentStory.vue +++ b/@xen-orchestra/lite/src/components/component-story/ComponentStory.vue @@ -109,6 +109,8 @@ enum TAB { SETTINGS, } +const selectedTab = ref(TAB.NONE) + const tab = (tab: TAB, params: Param[]) => reactive({ onClick: () => (selectedTab.value = tab), @@ -131,8 +133,6 @@ const eventParams = computed(() => [ const settingParams = computed(() => props.params.filter(isSettingParam)) const slotParams = computed(() => props.params.filter(isSlotParam)) -const selectedTab = ref(TAB.NONE) - onBeforeMount(() => { if (propParams.value.length !== 0) { selectedTab.value = TAB.PROPS diff --git a/@xen-orchestra/lite/src/components/pool/dashboard/PoolDashboardCpuProvisioning.vue b/@xen-orchestra/lite/src/components/pool/dashboard/PoolDashboardCpuProvisioning.vue index 0e87b5cc95..dca8044e83 100644 --- a/@xen-orchestra/lite/src/components/pool/dashboard/PoolDashboardCpuProvisioning.vue +++ b/@xen-orchestra/lite/src/components/pool/dashboard/PoolDashboardCpuProvisioning.vue @@ -60,6 +60,8 @@ const { hasError: vmStoreHasError, isReady: isVmStoreReady, records: vms } = use const { getByOpaqueRef: getVmMetrics, isReady: isVmMetricsStoreReady } = useVmMetricsStore().subscribe() +const isReady = logicAnd(isVmStoreReady, isHostStoreReady, isVmMetricsStoreReady) + const nPCpu = computed(() => runningHosts.value.reduce((total, host) => total + Number(host.cpu_info.cpu_count), 0)) const nVCpuInUse = computed(() => { @@ -75,7 +77,7 @@ const nVCpuInUse = computed(() => { const value = computed(() => Math.round(percent(nVCpuInUse.value, nPCpu.value))) const maxValue = computed(() => Math.ceil(value.value / 100) * 100) const state = computed(() => (value.value > 100 ? 'warning' : 'success')) -const isReady = logicAnd(isVmStoreReady, isHostStoreReady, isVmMetricsStoreReady) + const hasError = computed(() => hostStoreHasError.value || vmStoreHasError.value) diff --git a/@xen-orchestra/lite/src/libs/alarm.ts b/@xen-orchestra/lite/src/libs/alarm.ts index fe780972ef..5f80860e77 100644 --- a/@xen-orchestra/lite/src/libs/alarm.ts +++ b/@xen-orchestra/lite/src/libs/alarm.ts @@ -1,31 +1,6 @@ import type { RawObjectType, XenApiMessage } from '@/libs/xen-api/xen-api.types' import type { XenApiAlarm, XenApiAlarmType } from '@/types/xen-api' -export const messageToAlarm = ( - message: XenApiMessage | undefined -): XenApiAlarm | undefined => { - if (message === undefined || message.name !== 'ALARM') { - return - } - - return { - ...message, - ...parseAlarmBody(message.body), - } -} - -export const messagesToAlarms = (messages: XenApiMessage[]) => { - return messages.reduce((acc, message) => { - const alarm = messageToAlarm(message) - - if (alarm !== undefined) { - acc.push(alarm) - } - - return acc - }, [] as XenApiAlarm[]) -} - const parseXml = (xml: string) => { const parser = new DOMParser() const dom = parser.parseFromString(xml, 'text/xml') @@ -68,3 +43,28 @@ export const parseAlarmBody = (body: string): { level: number; type: XenApiAlarm triggerLevel: parseFloat(document.triggerLevel ?? '0'), } } + +export const messageToAlarm = ( + message: XenApiMessage | undefined +): XenApiAlarm | undefined => { + if (message === undefined || message.name !== 'ALARM') { + return + } + + return { + ...message, + ...parseAlarmBody(message.body), + } +} + +export const messagesToAlarms = (messages: XenApiMessage[]) => { + return messages.reduce((acc, message) => { + const alarm = messageToAlarm(message) + + if (alarm !== undefined) { + acc.push(alarm) + } + + return acc + }, [] as XenApiAlarm[]) +} diff --git a/@xen-orchestra/web-core/lib/components/console/RemoteConsole.vue b/@xen-orchestra/web-core/lib/components/console/RemoteConsole.vue index 924ae36040..6879118d9b 100644 --- a/@xen-orchestra/web-core/lib/components/console/RemoteConsole.vue +++ b/@xen-orchestra/web-core/lib/components/console/RemoteConsole.vue @@ -23,7 +23,7 @@ const consoleContainer = ref(null) let vncClient: VncClient | undefined let nConnectionAttempts = 0 -const handleDisconnectionEvent = () => { +function handleDisconnectionEvent() { clearVncClient() nConnectionAttempts++ @@ -41,9 +41,11 @@ const handleDisconnectionEvent = () => { createVncConnection() } -const handleConnectionEvent = () => (nConnectionAttempts = 0) +function handleConnectionEvent() { + nConnectionAttempts = 0 +} -const clearVncClient = () => { +function clearVncClient() { if (vncClient === undefined) { return } @@ -55,7 +57,7 @@ const clearVncClient = () => { vncClient = undefined } -const createVncConnection = async () => { +async function createVncConnection() { if (nConnectionAttempts !== 0) { await promiseTimeout(FIBONACCI_MS_ARRAY[nConnectionAttempts - 1]) diff --git a/@xen-orchestra/web-core/lib/components/table/ColumnTitle.vue b/@xen-orchestra/web-core/lib/components/table/ColumnTitle.vue index f5351a032f..a96a17e532 100644 --- a/@xen-orchestra/web-core/lib/components/table/ColumnTitle.vue +++ b/@xen-orchestra/web-core/lib/components/table/ColumnTitle.vue @@ -76,12 +76,12 @@ const interactions = computed(() => [ const tableName = inject('tableName') +const columnName = `${tableName}__${props.id}` + const currentInteraction = computed(() => interactions.value.find(interaction => router.currentRoute.value.query[columnName] === interaction.id) ) -const columnName = `${tableName}__${props.id}` - const updateInteraction = (interaction: Interaction) => { router.replace({ query: {