A supply nobody could read is unknown, not empty
This commit is contained in:
@@ -215,8 +215,14 @@
|
||||
<div v-for="supply in supplies" :key="supply.itemid || supply.name" class="supply-item">
|
||||
<div class="supply-header">
|
||||
<span class="supply-name">{{ supply.name }}</span>
|
||||
<span class="supply-level" :class="supply.status">
|
||||
{{ supply.level !== null ? `${supply.level}%` : 'N/A' }}
|
||||
<!-- N/A is not the same as 0%. A supply Zabbix has no usable
|
||||
reading for arrives with level null and status 'unknown';
|
||||
the title says which of the two reasons it is, because
|
||||
"no data" and "last seen three weeks ago" need different
|
||||
people to fix them. -->
|
||||
<span class="supply-level" :class="supply.status"
|
||||
:title="supply.status === 'unknown' ? unknownReason(supply) : null">
|
||||
{{ supply.level !== null && supply.level !== undefined ? `${supply.level}%` : 'N/A' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="supply-bar">
|
||||
@@ -227,7 +233,7 @@
|
||||
></div>
|
||||
</div>
|
||||
<div class="supply-meta">
|
||||
<span>{{ formatSupplyType(supply.supplytype) }}<template v-if="supply.iswaste"> ({{ supply.remaining }}% remaining)</template></span>
|
||||
<span>{{ formatSupplyType(supply.supplytype) }}<template v-if="supply.iswaste && supply.remaining !== null"> ({{ supply.remaining }}% remaining)</template></span>
|
||||
<span v-if="supply.partnumbers && supply.partnumbers.length" class="supply-parts">
|
||||
<span
|
||||
v-for="part in supply.partnumbers"
|
||||
@@ -363,6 +369,15 @@ function formatSupplyType(supplytype) {
|
||||
return supplytype.charAt(0).toUpperCase() + supplytype.slice(1)
|
||||
}
|
||||
|
||||
// Why a supply reads N/A. lastseen is the epoch of the newest reading Zabbix
|
||||
// holds: absent means the item has never collected, present means it has but
|
||||
// the reading is too old to present as current. Those are different faults and
|
||||
// the tooltip is the only place either one is stated.
|
||||
function unknownReason(supply) {
|
||||
if (!supply.lastseen) return 'Zabbix has no reading for this supply'
|
||||
return `No reading since ${new Date(supply.lastseen * 1000).toLocaleString()}`
|
||||
}
|
||||
|
||||
function formatDate(dateStr) {
|
||||
if (!dateStr) return '-'
|
||||
return new Date(dateStr).toLocaleString()
|
||||
@@ -414,6 +429,10 @@ function formatDate(dateStr) {
|
||||
.supply-level.ok { color: var(--success); }
|
||||
.supply-level.low { color: var(--warning); }
|
||||
.supply-level.critical { color: var(--danger); }
|
||||
/* Muted on purpose. An unknown level is not a severity - colouring it like one
|
||||
would put it in the same reading as critical, which is the confusion this
|
||||
whole change exists to end. The help cursor points at the tooltip. */
|
||||
.supply-level.unknown { color: var(--text-light); cursor: help; }
|
||||
|
||||
.supply-bar {
|
||||
height: 10px;
|
||||
|
||||
Reference in New Issue
Block a user