diff --git a/sysutils/smart/src/opnsense/www/js/widgets/Smart.js b/sysutils/smart/src/opnsense/www/js/widgets/Smart.js index b46419e0c..3ae73ea70 100644 --- a/sysutils/smart/src/opnsense/www/js/widgets/Smart.js +++ b/sysutils/smart/src/opnsense/www/js/widgets/Smart.js @@ -41,31 +41,21 @@ export default class Smart extends BaseTableWidget { } async onWidgetTick() { - if (this.disks && this.disks.devices) { - for (const device of this.disks.devices) { + let disks = await ajaxCall(`/api/smart/service/list/detailed`, {}, null); + if (disks && disks.devices) { + const rows = []; + for (const device of disks.devices) { try { - const data = await this.ajaxCall('/api/smart/service/info', { type: "H", device }); - const health = data.output.includes("PASSED"); - $(`#${device}`).css({ color: health ? "green" : "red", fontSize: '150%' }); - $(`#${device}`).text(health ? "OK" : "FAILED"); + const health = device.state.smart_status.passed; + const text = health ? "OK" : "FAILED"; + const css = { color: health ? "green" : "red", fontSize: '150%' }; + const field = $(``).text(text).css(css).prop('outerHTML'); + rows.push([[device.device], field]); } catch (error) { - super.updateTable('smart-table', [[["Error"], $(`${this.translations.nosmart} ${device}: ${error}`).prop('outerHTML')]]); + super.updateTable('smart-table', [[["Error"], $(`${this.translations.nosmart} ${device.device}: ${error}`).prop('outerHTML')]]); } } - } - } - - async onMarkupRendered() { - try { - this.disks = await this.ajaxCall('/api/smart/service/list', {}); - const rows = []; - for (const device of this.disks.devices) { - const field = $(``).prop('outerHTML'); - rows.push([[device], field]); - } super.updateTable('smart-table', rows); - } catch (error) { - super.updateTable('smart-table', [[["Error"], $(`${this.translations.nodisk}: ${error}`).prop('outerHTML')]]); } } }