Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(controller): remote update adjustments #391

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,8 @@
"go_to_subscription": "Go to subscription",
"automatic_updates_enabled_message": "Automatic updates successfully enabled",
"automatic_updates_disabled_message": "Automatic updates successfully disabled",
"schedule_update": "Schedule update"
"schedule_update": "Schedule update",
"no_updates_available": "No updates available"
},
"storage": {
"title": "Storage",
Expand Down
14 changes: 12 additions & 2 deletions src/components/controller/units/ScheduleUpdateDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ watch(
fetchError.value = undefined
loading.value = true
checkUnitImageUpdate(_unit.value)
.then((response) => {
.then(async (response) => {
versionToUpdate.value = response.data.lastVersion
if (response.data.scheduledAt > 0) {
if (versionToUpdate.value == '') {
await unitsStore.getUnitInfo(_unit.value!.id)
await unitsStore.getUnits()
} else if (response.data.scheduledAt > 0) {
scheduledUpdate.value = new Date(response.data.scheduledAt * 1000)
updateMode.value = 'scheduled'
} else {
Expand Down Expand Up @@ -140,6 +143,13 @@ function close() {
{{ fetchError.toString() }}
</template>
</NeInlineNotification>
<div v-else-if="versionToUpdate == ''" class="flex flex-col gap-6">
<NeInlineNotification :title="t('standalone.update.no_updates_available')" kind="info" />
<hr />
<div class="flex flex-wrap justify-end">
<NeButton kind="primary" @click="emit('close')">{{ t('common.close') }}</NeButton>
</div>
</div>
<div v-else class="flex flex-col gap-6">
<NeInlineNotification
v-if="sendingError"
Expand Down
88 changes: 45 additions & 43 deletions src/components/controller/units/UnitsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function getKebabMenuItems(unit: Unit) {
icon: 'arrows-rotate',
iconStyle: 'fas',
action: () => emit('upgradeUnitPackages', unit),
disabled: !unit.connected
disabled: !unit.connected || unitsStore.unitUpdatingPackages.find((id) => id == unit.id)
},
{
id: 'refreshUnitInfo',
Expand Down Expand Up @@ -452,48 +452,50 @@ function showRemoveUnitModal(unit: Unit) {
<NeTableCell :data-label="t('controller.units.installed_version')">
<span v-if="item.info.version" class="flex flex-wrap items-center gap-2">
<span>{{ item.info.version }}</span>
<template v-if="item.info.scheduled_update > 0">
<NeTooltip>
<template #trigger>
<NeBadge
:icon="faClock"
:text="t('controller.units.scheduled_image_update')"
clickable
kind="info"
/>
</template>
<template #content>
<div>
{{
t('controller.units.scheduled_image_update_tooltip', {
version: item.info.version_update,
date: new Date(item.info.scheduled_update * 1000).toLocaleString()
})
}}
</div>
</template>
</NeTooltip>
</template>
<template v-else-if="item.info.version_update">
<NeTooltip>
<template #trigger>
<NeBadge
:icon="faWarning"
:text="t('controller.units.image_update_available')"
clickable
kind="warning"
/>
</template>
<template #content>
<div>
{{
t('controller.units.image_update_available_tooltip', {
version: item.info.version_update
})
}}
</div>
</template>
</NeTooltip>
<template v-if="item.connected">
<template v-if="item.info.scheduled_update > 0">
<NeTooltip>
<template #trigger>
<NeBadge
:icon="faClock"
:text="t('controller.units.scheduled_image_update')"
clickable
kind="info"
/>
</template>
<template #content>
<div>
{{
t('controller.units.scheduled_image_update_tooltip', {
version: item.info.version_update,
date: new Date(item.info.scheduled_update * 1000).toLocaleString()
})
}}
</div>
</template>
</NeTooltip>
</template>
<template v-else-if="item.info.version_update">
<NeTooltip>
<template #trigger>
<NeBadge
:icon="faWarning"
:text="t('controller.units.image_update_available')"
clickable
kind="warning"
/>
</template>
<template #content>
<div>
{{
t('controller.units.image_update_available_tooltip', {
version: item.info.version_update
})
}}
</div>
</template>
</NeTooltip>
</template>
</template>
</span>
<template v-else-if="item.connected">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ async function updateUnitPackages() {
name: _unit.value.info.unit_name
})
})
unitsStore.addUnitUpdating(_unit.value.id)
emit('close')
} catch (exception: any) {
error.value = exception
Expand Down
12 changes: 11 additions & 1 deletion src/stores/controller/units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const useUnitsStore = defineStore('units', () => {
const loadingListUnits = ref(false)
const errorListUnits = ref('')
const errorListUnitsDetails = ref('')
const unitUpdatingPackages = ref<string[]>([])

const getUnits = async () => {
loadingListUnits.value = true
Expand Down Expand Up @@ -212,6 +213,13 @@ export const useUnitsStore = defineStore('units', () => {
})
}

function addUnitUpdating(unitId: string) {
unitUpdatingPackages.value.push(unitId)
setTimeout(() => {
unitUpdatingPackages.value = unitUpdatingPackages.value.filter((unit) => unit !== unitId)
}, 10000)
}

return {
units,
getUnits,
Expand All @@ -224,6 +232,8 @@ export const useUnitsStore = defineStore('units', () => {
loadingListUnits,
errorListUnits,
errorListUnitsDetails,
getUnitInfo
getUnitInfo,
unitUpdatingPackages,
addUnitUpdating
}
})