Skip to content

Commit

Permalink
Reduce machine learning table spacing when new home page enabled (#377)
Browse files Browse the repository at this point in the history
* Reduce machine learning table spacing

Signed-off-by: Lin Wang <[email protected]>

* Fix input overflow in new home page enabled

Signed-off-by: Lin Wang <[email protected]>

* Avoid refresh immediately after very large number input

Signed-off-by: Lin Wang <[email protected]>

* Addre PR comments

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>
  • Loading branch information
wanglam authored Sep 27, 2024
1 parent b6d9192 commit 801bb59
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
9 changes: 8 additions & 1 deletion public/components/common/refresh_interval.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const intervalUnitOptions = [
{ text: 'hours', value: 'h' },
];

const MAX_SIGNED_32_BIT_INTEGER = 2147483647;

export const RefreshInterval = ({
onRefresh,
onRefreshChange,
Expand Down Expand Up @@ -98,9 +100,14 @@ export const RefreshInterval = ({
}
} else {
if (interval !== null) {
/**
* According https://developer.mozilla.org/en-US/docs/Web/API/setInterval#return_value
* the max delayed value of setInterval is MAX_SIGNED_32_BIT_INTEGER, the inner function will be executed immediately
* if the delayed value is greater than MAX_SIGNED_32_BIT_INTEGER. Add a Math.min here to avoid been executed immediately.
**/
intervalId = window.setInterval(() => {
onRefresh();
}, interval);
}, Math.min(interval, MAX_SIGNED_32_BIT_INTEGER));
}
}

Expand Down
39 changes: 20 additions & 19 deletions public/components/monitoring/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,29 @@ export const Monitoring = (props: MonitoringProps) => {
/>
<EuiPanel>
{!useNewPageHeader && (
<EuiText size="s">
<h2>
<FormattedMessage
id="machineLearning.aiModels.table.header.title"
defaultMessage="Models {records}"
values={{
records:
pageStatus === 'normal' ? (
<EuiTextColor aria-label="total number of results" color="subdued">
({pagination?.totalRecords ?? 0})
</EuiTextColor>
) : undefined,
}}
/>
</h2>
</EuiText>
<>
<EuiText size="s">
<h2>
<FormattedMessage
id="machineLearning.aiModels.table.header.title"
defaultMessage="Models {records}"
values={{
records:
pageStatus === 'normal' ? (
<EuiTextColor aria-label="total number of results" color="subdued">
({pagination?.totalRecords ?? 0})
</EuiTextColor>
) : undefined,
}}
/>
</h2>
</EuiText>
<EuiSpacer size="m" />
</>
)}

<EuiSpacer size="m" />
{pageStatus !== 'empty' && (
<>
<EuiFlexGroup gutterSize="l">
<EuiFlexGroup gutterSize={useNewPageHeader ? 's' : 'l'}>
<EuiFlexItem>
<SearchBar inputRef={setInputRef} onSearch={searchByNameOrId} />
</EuiFlexItem>
Expand Down
6 changes: 5 additions & 1 deletion public/components/monitoring/monitoring_page_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export const MonitoringPageHeader = ({
if (useNewPageHeader) {
return [
{
renderComponent: <RefreshInterval onRefresh={onRefresh} />,
renderComponent: (
<div style={{ width: 227 }}>
<RefreshInterval onRefresh={onRefresh} />
</div>
),
},
];
}
Expand Down

0 comments on commit 801bb59

Please sign in to comment.