Skip to content

Commit

Permalink
Merge pull request #77 from lywcc/main
Browse files Browse the repository at this point in the history
fix: change the field of resources display
  • Loading branch information
Carrotzpc authored Dec 13, 2023
2 parents 68dd6c8 + 9cb641d commit 3fd95f2
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/pages/ModelServiceDetail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class ModelServiceDetail$$Page extends React.Component {
getBaseInfo() {
const name = this.match.params?.name;
const type = this.history.query?.type;
const namespace = this.appHelper.utils.getAuthData().project || 'system-tce';
const namespace = this.appHelper.utils.getAuthData().project || 'abc';
return {
name,
type,
Expand Down Expand Up @@ -191,6 +191,26 @@ class ModelServiceDetail$$Page extends React.Component {
this.deleteModelServiceItemReq();
}

handleCpuData() {
const unit = '核';
let cpu = this.state.detail.resources?.cpu;
if (!cpu) {
cpu = '-';
}
if (typeof cpu === 'string') {
cpu = cpu.toLowerCase().includes('m') ? parseInt(cpu) / 1000 : cpu;
}
return `${cpu} ${unit}`;
}

handleMemoryData() {
const memory = this.state.detail.resources?.memory;
const reg = /m/i;
const val = isNaN(parseInt(memory)) ? '-' : parseInt(memory);
const unit = reg.test(memory) ? 'MiB' : 'GIB';
return memory ? `${val} ${unit}` : '- GiB';
}

testFunc() {
console.log('test aliLowcode func');
return <div className="test-aliLowcode-func">{this.state.test}</div>;
Expand Down Expand Up @@ -875,7 +895,7 @@ class ModelServiceDetail$$Page extends React.Component {
ellipsis={true}
__component_name="Typography.Text"
>
{__$$eval(() => `${this.state.detail.resources?.cpu || '-'} 颗`)}
{__$$eval(() => this.handleCpuData())}
</Typography.Text>
</Col>
</Row>
Expand Down Expand Up @@ -904,9 +924,7 @@ class ModelServiceDetail$$Page extends React.Component {
ellipsis={true}
__component_name="Typography.Text"
>
{__$$eval(
() => `${this.state.detail.resources?.memory || '-'} GiB`
)}
{__$$eval(() => this.handleMemoryData())}
</Typography.Text>
</Col>
</Row>
Expand Down

0 comments on commit 3fd95f2

Please sign in to comment.