From 1206203050629a449f4a8d52d38807da22bb8fce Mon Sep 17 00:00:00 2001 From: ironAiken2 <51399982+ironAiken2@users.noreply.github.com> Date: Wed, 7 Aug 2024 07:03:43 +0000 Subject: [PATCH] fix: missed prefix function usage in resource panel (#2612) ### TL;DR Fixes an issue with the `_prefixFormat` method default parameter and optimizes CUDA GPU description formatting. ### What changed? - Fixed default parameter value in `_prefixFormat` method from `'0;'` to `'0'`. - Optimized the CUDA GPU description formatting using the `_prefixFormat` helper method. ### How to test? - Verify that the `_prefixFormat` method functions correctly with default and custom parameters. - Ensure that CUDA GPU descriptions are formatted as expected in the resource monitor component. ### Why make this change? The change corrects the default parameter value in the `_prefixFormat` method and streamlines the GPU description formatting for consistency and clarity. --- **Checklist:** (if applicable) - [ ] Mention to the original issue - [ ] Documentation - [ ] Minium required manager version - [ ] Specific setting for review (eg., KB link, endpoint or how to setup) - [ ] Minimum requirements to check during review - [ ] Test case(s) to demonstrate the difference of before/after --- src/components/backend-ai-resource-monitor.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/backend-ai-resource-monitor.ts b/src/components/backend-ai-resource-monitor.ts index 21647eafdd..a2ab175e11 100644 --- a/src/components/backend-ai-resource-monitor.ts +++ b/src/components/backend-ai-resource-monitor.ts @@ -599,7 +599,7 @@ export default class BackendAiResourceMonitor extends BackendAIPage { const number = typeof num === 'string' ? parseFloat(num) : num; return parseFloat(number.toFixed(fixed)).toString(); } - _prefixFormat(num: string | number = '0;', fixed: number) { + _prefixFormat(num: string | number = '0', fixed: number) { return typeof num === 'string' ? parseFloat(num)?.toFixed(fixed) : num?.toFixed(fixed); @@ -753,9 +753,11 @@ export default class BackendAiResourceMonitor extends BackendAIPage { class="start" progress="${this.used_resource_group_slot.cuda_device / this.total_resource_group_slot.cuda_device}" - description="${this.used_resource_group_slot.cuda_device.toFixed( + description="${this._prefixFormat( + this.used_resource_group_slot.cuda_device, 2, - )} / ${this.total_resource_group_slot.cuda_device.toFixed( + )} / ${this._prefixFormat( + this.total_resource_group_slot.cuda_device, 2, )} CUDA GPUs" >