ryankert01 commented on code in PR #202:
URL: https://github.com/apache/yunikorn-web/pull/202#discussion_r1758338684
##########
src/app/utils/common.util.ts:
##########
@@ -81,10 +81,47 @@ export class CommonUtil {
return `${toValue.toLocaleString(undefined, { maximumFractionDigits: 2
})}${unit}`;
}
+ static absoluteUsedMemoryColumnFormatter(value: string | undefined): string {
+ if (!value) {
+ return '';
+ }
+ if (value === 'n/a') {
+ return '<strong>Memory:</strong> n/a';
+ }
+ let memory = value.split('%')[0] + '%';
+ return CommonUtil.queueResourceColumnFormatter(memory);
+ }
+
+ static absoluteUsedCPUColumnFormatter(value: string | undefined): string {
+ if (!value) {
+ return '';
+ }
+ if (value === 'n/a') {
+ return '<strong>CPU:</strong> n/a';
+ }
+ let cpu = value.split('%')[1] + '%';
+ cpu = cpu.replace(',', '');
Review Comment:
Maybe we can try catch, so whether or not `value` string in shape, it will
return something and not crash.
example:
```ts
try {
const parsed = parseResourceValue(value);
return `<strong>Memory:</strong>
${this.queueResourceColumnFormatter(parsed.memory)}`;
} catch (error) {
console.error("Error parsing memory value:", error);
return '<strong>Memory:</strong> Error';
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]