Show thing firmware status (#3158)

Refs #1427.

This adds a block to the thing information to provide the status of
firmware. It just shows if there are firmwares available, the current
firmware version and the status.

---------

Also-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
pull/2967/head
Chris Jackson 2025-04-20 21:43:34 +12:00 committed by GitHub
parent 57a7f1dae4
commit 0b6159401a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 52 additions and 22 deletions

View File

@ -26,12 +26,13 @@
<f7-block v-if="ready && thing.statusInfo" class="block-narrow" strong>
<f7-col class="padding-horizontal">
<div v-show="!error" class="float-right align-items-flex-start align-items-center">
<f7-link :icon-color="(thing.statusInfo.statusDetail === 'DISABLED') ? 'orange' : 'gray'" :tooltip="((thing.statusInfo.statusDetail === 'DISABLED') ? 'Enable' : 'Disable') + (($device.desktop) ? ' (Ctrl-D)' : '')" icon-ios="f7:pause_circle" icon-md="f7:pause_circle" icon-aurora="f7:pause_circle" icon-size="32" color="orange" @click="toggleDisabled" />
<f7-link :icon-color="(thing.statusInfo.statusDetail === 'DISABLED') ? 'orange' : 'gray'"
:tooltip="((thing.statusInfo.statusDetail === 'DISABLED') ? 'Enable' : 'Disable') + (($device.desktop) ? ' (Ctrl-D)' : '')"
icon-ios="f7:pause_circle" icon-md="f7:pause_circle" icon-aurora="f7:pause_circle" icon-size="32"
color="orange" @click="toggleDisabled" />
</div>
Status:
<f7-chip class="margin-left"
:text="thing.statusInfo.status"
:color="thingStatusBadgeColor(thing.statusInfo)" />
<f7-chip class="margin-left" :text="thing.statusInfo.status" :color="thingStatusBadgeColor(thing.statusInfo)" />
<div>
<strong>{{ (thing.statusInfo.statusDetail !== 'NONE') ? thing.statusInfo.statusDetail : '&nbsp;' }}</strong>
<br>
@ -66,15 +67,28 @@
<div class="margin" v-html="thingType.description" />
</f7-accordion-content>
</f7-list-item>
<f7-list-item accordion-item v-if="Object.keys(thing.properties).length > 0" title="Thing Properties" :badge="Object.keys(thing.properties).length">
<f7-list-item accordion-item v-if="Object.keys(thing.properties).length > 0" title="Thing Properties"
:badge="Object.keys(thing.properties).length">
<f7-accordion-content>
<f7-list>
<f7-list-item
class="thing-property"
v-for="(value, key) in thing.properties"
:key="key"
:title="key"
:after="value" />
<f7-list-item class="thing-property" v-for="(value, key) in thing.properties" :key="key"
:title="key" :after="value" />
</f7-list>
</f7-accordion-content>
</f7-list-item>
<f7-list-item v-if="thing.firmwareStatus" accordion-item title="Firmware" :badge="firmwares.length"
:badge-color="(thing.firmwareStatus.status === 'UPDATE_EXECUTABLE') ? 'green' : 'gray'">
<f7-accordion-content>
<f7-list>
<f7-list-item class="thing-property" title="Status" :after="thing.firmwareStatus.status" />
<f7-list-item class="thing-property" title="Current Version"
:after="thing.properties.firmwareVersion" />
<f7-list-item class="thing-property" v-for="firmware in firmwares" :key="firmware.version"
header="Version" :title="firmware.version" :after="firmware.description"
:footer="firmware.changelog">
<f7-icon v-if="firmware.version === thing.properties.firmwareVersion" f7="checkmark"
color="green" />
</f7-list-item>
</f7-list>
</f7-accordion-content>
</f7-list-item>
@ -97,8 +111,10 @@
Actions
</f7-block-title>
<f7-list class="margin-top" media-list>
<f7-list-item v-if="thingType?.UID?.startsWith('zwave:')" title="View Network Map" link="" @click="openZWaveNetworkPopup()" />
<f7-list-item v-for="action in thingActions" :key="action.name" :title="action.label" :footer="action.description" link="" @click="doThingAction(action)" />
<f7-list-item v-if="thingType?.UID?.startsWith('zwave:')" title="View Network Map" link=""
@click="openZWaveNetworkPopup()" />
<f7-list-item v-for="action in thingActions" :key="action.name" :title="action.label"
:footer="action.description" link="" @click="doThingAction(action)" />
</f7-list>
</template>
</f7-col>
@ -127,7 +143,8 @@
<div v-html="actionGroup.group.description" />
</f7-block-footer>
<f7-list>
<f7-list-button v-for="action in actionGroup.actions" :color="(action.verify) ? 'yellow' : 'blue'" :key="action.name" :title="action.label" @click="action.execute()" />
<f7-list-button v-for="action in actionGroup.actions" :color="(action.verify) ? 'yellow' : 'blue'"
:key="action.name" :title="action.label" @click="action.execute()" />
</f7-list>
</f7-col>
</f7-block>
@ -136,7 +153,8 @@
<f7-block class="block-narrow" v-if="ready">
<f7-col>
<f7-list>
<f7-list-button v-if="thing.statusInfo.statusDetail === 'HANDLER_MISSING_ERROR'" color="blue" title="Install Binding" @click="installBinding" />
<f7-list-button v-if="thing.statusInfo.statusDetail === 'HANDLER_MISSING_ERROR'" color="blue"
title="Install Binding" @click="installBinding" />
<f7-list-button v-if="!error" color="blue" title="Duplicate Thing" @click="duplicateThing" />
<f7-list-button v-if="!error" color="blue" title="Copy DSL Definition" @click="copyThingDsl" />
<f7-list-button v-if="editable" color="red" title="Remove Thing" @click="deleteThing" />
@ -151,19 +169,27 @@
@channels-updated="onChannelsUpdated" :context="context" />
<f7-col v-if="isExtensible || thing.channels.length > 0">
<f7-list>
<f7-list-button class="searchbar-ignore" color="blue" title="Add Channel" v-if="isExtensible && editable" @click="addChannel()" />
<f7-list-button class="searchbar-ignore" color="blue" title="Add Equipment to Model" @click="addToModel(true)" />
<f7-list-button class="searchbar-ignore" color="blue" title="Add Points to Model" @click="addToModel(false)" />
<f7-list-button class="searchbar-ignore" color="red" title="Unlink all Items" @click="unlinkAll(false)" />
<f7-list-button class="searchbar-ignore" color="red" title="Unlink all and Remove Items" @click="unlinkAll(true)" />
<f7-list-button class="searchbar-ignore" color="blue" title="Add Channel" v-if="isExtensible && editable"
@click="addChannel()" />
<f7-list-button class="searchbar-ignore" color="blue" title="Add Equipment to Model"
@click="addToModel(true)" />
<f7-list-button class="searchbar-ignore" color="blue" title="Add Points to Model"
@click="addToModel(false)" />
<f7-list-button class="searchbar-ignore" color="red" title="Unlink all Items"
@click="unlinkAll(false)" />
<f7-list-button class="searchbar-ignore" color="red" title="Unlink all and Remove Items"
@click="unlinkAll(true)" />
</f7-list>
</f7-col>
</f7-block>
</f7-tab>
<f7-tab id="code" :tab-active="currentTab === 'code'">
<f7-icon v-if="!editable" f7="lock" class="float-right margin" style="opacity:0.5; z-index: 4000; user-select: none;" size="50" color="gray" :tooltip="notEditableMsg" />
<editor v-if="ready" class="thing-code-editor" mode="application/vnd.openhab.thing+yaml" :value="thingYaml" :hint-context="{ thingType: thingType, channelTypes: channelTypes }" @input="onEditorInput" :read-only="!editable" />
<f7-icon v-if="!editable" f7="lock" class="float-right margin"
style="opacity:0.5; z-index: 4000; user-select: none;" size="50" color="gray" :tooltip="notEditableMsg" />
<editor v-if="ready" class="thing-code-editor" mode="application/vnd.openhab.thing+yaml" :value="thingYaml"
:hint-context="{ thingType: thingType, channelTypes: channelTypes }" @input="onEditorInput"
:read-only="!editable" />
<!-- <pre class="yaml-message padding-horizontal" :class="[yamlError === 'OK' ? 'text-color-green' : 'text-color-red']">{{yamlError}}</pre> -->
</f7-tab>
</f7-tabs>
@ -273,6 +299,7 @@ export default {
configDescriptions: {},
thingActions: [],
configStatusInfo: [],
firmwares: [],
/**
* @deprecated
*/
@ -442,6 +469,9 @@ export default {
this.$oh.api.get('/rest/things/' + this.thingId + '/config/status').then(statusData => {
this.configStatusInfo = statusData
})
this.$oh.api.get('/rest/things/' + this.thingId + '/firmwares').then(firmwareData => {
this.firmwares = firmwareData
})
}).catch((err) => {
console.warn('Cannot load the related info: ' + err)
this.error = true