Skip to content

Commit

Permalink
fix: add limit of width to some columns and adjust ui of text if is o…
Browse files Browse the repository at this point in the history
…verflow, in table (#45)

Co-authored-by: yaojiping <[email protected]>
  • Loading branch information
yaojp123 and yaojiping authored Dec 17, 2024
1 parent 01c0bda commit b01a4e1
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 14 deletions.
3 changes: 3 additions & 0 deletions web/src/common.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.maxColumnWidth {
max-width: 200px;
}
24 changes: 15 additions & 9 deletions web/src/components/AutoTextEllipsis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,35 @@ export default (props) => {
});
});

if (textRef.current && showTooltip) {
if (textRef.current) {
resizeObserver.observe(textRef.current);
}

return () => {
if (textRef.current && showTooltip) {
if (textRef.current) {
resizeObserver.unobserve(textRef.current);
}
};
}, [showTooltip]);
}, []);

const ellipsisDom = (
<div style={{ position: 'absolute', left: 0, top: 0, overflow: 'hidden', height, width: '100%', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{children}
</div>
)

return (
<div style={{ position: 'relative', width, height }} onClick={(e) => e.stopPropagation()}>
<div ref={textRef} style={{ visibility: 'hidden'}}>
{children}
</div>
{
showTooltip && textHeight > height ? (
<Tooltip title={children} overlayStyle={{ maxWidth: 'unset !important'}}>
<div style={{ position: 'absolute', left: 0, top: 0, overflow: 'hidden', height, width: '100%', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{children}
</div>
</Tooltip>
textHeight > height ? (
showTooltip ? (
<Tooltip title={children} overlayStyle={{ maxWidth: 'unset !important'}}>
{ellipsisDom}
</Tooltip>
) : ellipsisDom
) : (
<div style={{ position: 'absolute', left: 0, top: 0 }}>
{children}
Expand Down
4 changes: 4 additions & 0 deletions web/src/pages/Agent/Instance/components/RowDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import Logs from "@/pages/Platform/Overview/Node/Detail/Logs";
import IconText from "@/components/infini/IconText";
import { SearchEngineIcon } from "@/lib/search_engines";
import { hasAuthority } from "@/utils/authority";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { TabPane } = Tabs;

Expand Down Expand Up @@ -190,6 +192,8 @@ export const AgentRowDetail = ({ agentID, t }) => {
{
title: "Home",
dataIndex: "node_info.settings.path.home",
render: (text) => <AutoTextEllipsis >{text}</AutoTextEllipsis>,
className: commonStyles.maxColumnWidth
},
{
title: "Status",
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Agent/Instance/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ const AgentList = (props) => {
columns={columns}
onChange={handleTableChange}
expandedRowRender={expandedRowRender}
scroll={{x: 1100 }}
scroll={{x: 'max-content' }}
/>
<Drawer
title={`Task Settings(${editState.editItem?.remote_ip})`}
Expand Down
2 changes: 2 additions & 0 deletions web/src/pages/DataManagement/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { hasAuthority } from "@/utils/authority";
import DeleteIndexModal from "./components/DeleteIndexModal";
import IconText from "@/components/infini/IconText";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { Search } = Input;

Expand Down Expand Up @@ -192,6 +193,7 @@ class Index extends PureComponent {
/>
),
sorter: (a, b) => sorter.string(a, b, "index"),
className: commonStyles.maxColumnWidth
},
{
title: formatMessage({ id: "indices.field.health" }),
Expand Down
9 changes: 8 additions & 1 deletion web/src/pages/Gateway/Queue/Consumer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import ReestOffsetModal from "./ResetOffsetModal";
import { encodeProxyPath } from "@/lib/util";
import { filterSearchValue, sorter } from "@/utils/utils";
import { hasAuthority } from "@/utils/authority";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { Search } = Input;

Expand All @@ -42,7 +44,12 @@ export default (props) => {
};

const columns = [
{ title: "Group", dataIndex: "group" },
{
title: "Group",
dataIndex: "group",
render: (text) => <AutoTextEllipsis >{text}</AutoTextEllipsis>,
className: commonStyles.maxColumnWidth
},
{
title: "LastActive",
dataIndex: "last_active",
Expand Down
13 changes: 11 additions & 2 deletions web/src/pages/Gateway/Queue/Persistent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { hasAuthority } from "@/utils/authority";
import IconText from "@/components/infini/IconText";
import Consumer from "./Consumer";
import QueueTypeIcon from "./QueueTypeIcon";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { Search } = Input;

Expand Down Expand Up @@ -107,7 +109,12 @@ export default (props) => {
text={
<Popover
content={consumerLabelRender(row?.metadata?.label)}
title={`ID:${row?.metadata?.id}`}
title={(
<>
<div>{`ID: ${row?.metadata?.id}`}</div>
<div>{`Name: ${name}`}</div>
</>
)}
>
<a
onClick={() => {
Expand All @@ -117,7 +124,7 @@ export default (props) => {
);
}}
>
{name}
<AutoTextEllipsis showTooltip={false}>{name}</AutoTextEllipsis>
</a>
</Popover>
}
Expand All @@ -126,6 +133,7 @@ export default (props) => {
</>
),
sorter: (a, b) => sorter.string(a, b, "name"),
className: commonStyles.maxColumnWidth
},
{
title: "Local Storage",
Expand Down Expand Up @@ -422,6 +430,7 @@ export default (props) => {
? "offset-normal"
: "";
}}
scroll={{ x: 'max-content' }}
/>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions web/src/pages/Platform/Overview/Cluster/Monitor/indices.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { filterSearchValue, sorter, formatUtcTimeToLocal } from "@/utils/utils";
import { formatTimeRange } from "@/lib/elasticsearch/util";
import IconText from "@/components/infini/IconText";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { Search } = Input;

Expand Down Expand Up @@ -114,6 +115,7 @@ const Indices = ({
/>
),
sorter: (a, b) => sorter.string(a, b, "index"),
className: commonStyles.maxColumnWidth
},
{
title: "Health",
Expand Down Expand Up @@ -272,6 +274,7 @@ const Indices = ({
dispatch({ type: "pageSizeChange", value: size });
},
}}
scroll={{x: 'max-content' }}
/>
</>
);
Expand Down
4 changes: 3 additions & 1 deletion web/src/pages/Platform/Overview/Cluster/Monitor/nodes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { formatTimeRange } from "@/lib/elasticsearch/util";
import moment from "moment";
import IconText from "@/components/infini/IconText";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { Search } = Input;
const InputGroup = Input.Group;
Expand Down Expand Up @@ -128,7 +129,7 @@ export default ({
</span>
),
sorter: (a, b) => sorter.string(a, b, "name"),
className: "verticalAlign",
className: `verticalAlign ${commonStyles.maxColumnWidth}`,
},
];
if (showRealtime) {
Expand Down Expand Up @@ -325,6 +326,7 @@ export default ({
dispatch({ type: "pageSizeChange", value: size });
},
}}
scroll={{x: 'max-content' }}
/>
</>
);
Expand Down
3 changes: 3 additions & 0 deletions web/src/pages/Platform/Overview/Indices/Monitor/shards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { filterSearchValue, sorter, formatUtcTimeToLocal } from "@/utils/utils";
import { formatTimeRange } from "@/lib/elasticsearch/util";
import IconText from "@/components/infini/IconText";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { Search } = Input;

Expand Down Expand Up @@ -155,6 +156,7 @@ export default ({
);
},
sorter: (a, b) => sorter.string(a, b, "node"),
className: commonStyles.maxColumnWidth
},
{
title: "State",
Expand Down Expand Up @@ -255,6 +257,7 @@ export default ({
dispatch({ type: "pageSizeChange", value: size });
},
}}
scroll={{x: 'max-content' }}
/>
</>
);
Expand Down
3 changes: 3 additions & 0 deletions web/src/pages/Platform/Overview/Node/Monitor/shards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { filterSearchValue, sorter, formatUtcTimeToLocal } from "@/utils/utils";
import { formatTimeRange } from "@/lib/elasticsearch/util";
import IconText from "@/components/infini/IconText";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { Search } = Input;

Expand Down Expand Up @@ -105,6 +106,7 @@ export default ({ clusterID, clusterName, nodeID, timeRange, bucketSize }) => {
);
},
sorter: (a, b) => sorter.string(a, b, "index"),
className: commonStyles.maxColumnWidth
},
{
title: "Shard",
Expand Down Expand Up @@ -257,6 +259,7 @@ export default ({ clusterID, clusterName, nodeID, timeRange, bucketSize }) => {
dispatch({ type: "pageSizeChange", value: size });
},
}}
scroll={{x: 'max-content' }}
/>
</>
);
Expand Down
4 changes: 4 additions & 0 deletions web/src/pages/System/Credential/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { formatESSearchResult } from "@/lib/elasticsearch/util";
import useFetch from "@/lib/hooks/use_fetch";
import CredentialForm from "./CredentialForm";
import { hasAuthority } from "@/utils/authority";
import AutoTextEllipsis from "@/components/AutoTextEllipsis";
import commonStyles from "@/common.less"

const { Search } = Input;

Expand Down Expand Up @@ -182,6 +184,8 @@ export default () => {
}),
dataIndex: "name",
key: "name",
render: (text) => <AutoTextEllipsis >{text}</AutoTextEllipsis>,
className: commonStyles.maxColumnWidth
},
{
title: formatMessage({
Expand Down

0 comments on commit b01a4e1

Please sign in to comment.