Format the smart data in the web ui the same way as curses output

This commit is contained in:
Drakarah 2026-01-03 07:33:09 +00:00
parent 0b141ff92d
commit c8b2a90f3b
1 changed files with 18 additions and 2 deletions

View File

@ -15,7 +15,7 @@
</tr>
<tr v-for="(metric, metricId) in drive.details" :key="metricId">
<td scope="row">{{ metric.name }}</td>
<td scope="row" class="text-end text-truncate">{{ metric.raw }}</td>
<td scope="row" class="text-end text-truncate">{{ formatted(metric) }}</td>
</tr>
</template>
</tbody>
@ -48,7 +48,23 @@ export default {
},
hasDrives() {
return this.drives.length > 0;
},
}
},
methods: {
formatted(metric) {
if(typeof metric.key === 'undefined')
return metric.raw;
if (this.requiresFormatting(metric.key)) {
return this.$filters.bytes(metric.raw);
}
return metric.raw;
},
requiresFormatting(key) {
const keysToFormat = ["bytesWritten", "bytesRead", "dataUnitsRead", "dataUnitsWritten", "hostReadCommands", "hostWriteCommands" ];
return keysToFormat.includes(key);
}
}
};
</script>