Skip to content
Open
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
22 changes: 22 additions & 0 deletions webapp/frontend/src/app/data/mock/device/details/sdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ export const sdb = {
'power_on_hours': 1730,
'power_cycle_count': 9,
'attrs': {
'241': {
'attribute_id': 241,
'value': 100,
'thresh': 0,
'worst': 100,
'raw_value': 1953125000,
'raw_string': '1953125000',
'when_failed': '',
'transformed_value': 0,
'status': 0
},
'1': {
'attribute_id': 1,
'value': 100,
Expand Down Expand Up @@ -459,6 +470,17 @@ export const sdb = {
'when_failed': '',
'transformed_value': 0,
'status': 0
},
'241': {
'attribute_id': 241,
'value': 100,
'thresh': 0,
'worst': 100,
'raw_value': 1953125000,
'raw_string': '1953125000',
'when_failed': '',
'transformed_value': 0,
'status': 0
}
},
'Status': 0
Expand Down
9 changes: 8 additions & 1 deletion webapp/frontend/src/app/modules/detail/detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {SmartModel} from 'app/core/models/measurements/smart-model';
import {SmartAttributeModel} from 'app/core/models/measurements/smart-attribute-model';
import {AttributeMetadataModel} from 'app/core/models/thresholds/attribute-metadata-model';
import {DeviceStatusPipe} from 'app/shared/device-status.pipe';
import {FileSizePipe} from 'app/shared/file-size.pipe';

// from Constants.go - these must match
const AttributeStatusPassed = 0
Expand Down Expand Up @@ -204,8 +205,12 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
}
}

getAttributeValue(attributeData: SmartAttributeModel): number {
getAttributeValue(attributeData: SmartAttributeModel): number | string {
if (this.isAta()) {
if (attributeData.attribute_id === 241 || attributeData.attribute_id === 242) {
return `${attributeData.raw_value} [${new FileSizePipe().transform(attributeData.raw_value * 512, this.config?.file_size_si_units)}]`
}

const attributeMetadata = this.metadata[attributeData.attribute_id]
if (!attributeMetadata) {
return attributeData.value
Expand All @@ -216,6 +221,8 @@ export class DetailComponent implements OnInit, AfterViewInit, OnDestroy {
} else {
return attributeData.value
}
} else if (this.isNvme() && (attributeData.attribute_id === 'data_units_written' || attributeData.attribute_id === 'data_units_read')) {
return `${attributeData.value} [${new FileSizePipe().transform(attributeData.value * 1000 * 512, this.config?.file_size_si_units)}]`
} else {
return attributeData.value
}
Expand Down
Loading