mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Setting up node table row heights
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
1 parent
3dd3f08f56
commit
0d4bca1137
4 files changed
+21
-16
No files matched your search
@@ -6,6 +6,10 @@
|
|||||||
@import "nodes-mixins";
|
@import "nodes-mixins";
|
||||||
|
|
||||||
.Nodes {
|
.Nodes {
|
||||||
|
.TableRow {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.TableCell {
|
.TableCell {
|
||||||
&.name {
|
&.name {
|
||||||
flex: 2;
|
flex: 2;
|
||||||
@@ -23,18 +27,14 @@
|
|||||||
.metrics {
|
.metrics {
|
||||||
--metric-color: var(--blue);
|
--metric-color: var(--blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
.LineProgress {
|
|
||||||
color: var(--blue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.memory {
|
&.memory {
|
||||||
flex: 1.0;
|
flex: 1.0;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
|
|
||||||
.LineProgress {
|
.metrics {
|
||||||
color: var(--magenta);
|
--metric-color: var(--magenta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@
|
|||||||
flex: 1.0;
|
flex: 1.0;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
|
|
||||||
.LineProgress {
|
.metrics {
|
||||||
color: var(--golden);
|
--metric-color: var(--golden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { TabLayout } from "../layout/tab-layout-2";
|
|||||||
import { nodesStore } from "./nodes.store";
|
import { nodesStore } from "./nodes.store";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { formatNodeTaint, getMetricsForAllNodes, INodeMetrics, Node } from "../../../common/k8s-api/endpoints/nodes.api";
|
import { formatNodeTaint, getMetricsForAllNodes, INodeMetrics, Node } from "../../../common/k8s-api/endpoints/nodes.api";
|
||||||
import { LineProgress } from "../line-progress";
|
|
||||||
import { bytesToUnits } from "../../../common/utils/convertMemory";
|
import { bytesToUnits } from "../../../common/utils/convertMemory";
|
||||||
import { Tooltip, TooltipPosition } from "../tooltip";
|
import { Tooltip, TooltipPosition } from "../tooltip";
|
||||||
import kebabCase from "lodash/kebabCase";
|
import kebabCase from "lodash/kebabCase";
|
||||||
@@ -23,6 +22,7 @@ import { makeObservable, observable } from "mobx";
|
|||||||
import isEmpty from "lodash/isEmpty";
|
import isEmpty from "lodash/isEmpty";
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
import { MetricBar } from "../metric-bar";
|
import { MetricBar } from "../metric-bar";
|
||||||
|
import { VerticalBar } from "../vertical-bar";
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
name = "name",
|
name = "name",
|
||||||
@@ -50,6 +50,7 @@ interface UsageArgs {
|
|||||||
export class NodesRoute extends React.Component {
|
export class NodesRoute extends React.Component {
|
||||||
@observable.ref metrics: Partial<INodeMetrics> = {};
|
@observable.ref metrics: Partial<INodeMetrics> = {};
|
||||||
private metricsWatcher = interval(30, async () => this.metrics = await getMetricsForAllNodes());
|
private metricsWatcher = interval(30, async () => this.metrics = await getMetricsForAllNodes());
|
||||||
|
private metricBarHeight = 22;
|
||||||
|
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -91,7 +92,7 @@ export class NodesRoute extends React.Component {
|
|||||||
const metrics = this.getLastMetricValues(node, metricNames);
|
const metrics = this.getLastMetricValues(node, metricNames);
|
||||||
|
|
||||||
if (!metrics || metrics.length < 2) {
|
if (!metrics || metrics.length < 2) {
|
||||||
return <LineProgress value={0}/>;
|
return <VerticalBar value={0}/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [usage, capacity] = metrics;
|
const [usage, capacity] = metrics;
|
||||||
@@ -101,6 +102,7 @@ export class NodesRoute extends React.Component {
|
|||||||
className="metrics"
|
className="metrics"
|
||||||
max={capacity}
|
max={capacity}
|
||||||
value={usage}
|
value={usage}
|
||||||
|
height={this.metricBarHeight}
|
||||||
tooltip={{
|
tooltip={{
|
||||||
preferredPositions: TooltipPosition.BOTTOM,
|
preferredPositions: TooltipPosition.BOTTOM,
|
||||||
children: `${title}: ${formatters.map(formatter => formatter([usage, capacity])).join(", ")}`,
|
children: `${title}: ${formatters.map(formatter => formatter([usage, capacity])).join(", ")}`,
|
||||||
@@ -233,6 +235,11 @@ export class NodesRoute extends React.Component {
|
|||||||
this.renderConditions(node),
|
this.renderConditions(node),
|
||||||
];
|
];
|
||||||
}}
|
}}
|
||||||
|
tableProps={{
|
||||||
|
customRowHeights: (item, lineHeight, paddings) => {
|
||||||
|
return paddings + this.metricBarHeight;
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TabLayout>
|
</TabLayout>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,10 +9,6 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
label {
|
|
||||||
color: var(--textColorTertiary);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bar {
|
.bar {
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ interface BarProps extends HTMLAttributes<HTMLDivElement>, TooltipDecoratorProps
|
|||||||
value: number;
|
value: number;
|
||||||
max: number;
|
max: number;
|
||||||
min?: number;
|
min?: number;
|
||||||
|
height?: number;
|
||||||
showPercent?: ReactNode;
|
showPercent?: ReactNode;
|
||||||
changeColorOnWarning?: boolean;
|
changeColorOnWarning?: boolean;
|
||||||
warningPercentage?: number;
|
warningPercentage?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MetricBar = withTooltip((props: BarProps) => {
|
export const MetricBar = withTooltip((props: BarProps) => {
|
||||||
const { max, min = 0, showPercent = true, changeColorOnWarning = true, warningPercentage = 85, value } = props;
|
const { max, min = 0, showPercent = true, changeColorOnWarning = true, warningPercentage = 85, value, height } = props;
|
||||||
const percents = Math.min(100, value / (max - min) * 100);
|
const percents = Math.min(100, value / (max - min) * 100);
|
||||||
const percentsRounded = +percents.toFixed(2);
|
const percentsRounded = +percents.toFixed(2);
|
||||||
const warning = percents > warningPercentage;
|
const warning = percents > warningPercentage;
|
||||||
@@ -30,8 +31,9 @@ export const MetricBar = withTooltip((props: BarProps) => {
|
|||||||
<VerticalBar
|
<VerticalBar
|
||||||
value={percentsRounded}
|
value={percentsRounded}
|
||||||
className={cssNames(styles.bar, { [styles.warning]: warning && changeColorOnWarning })}
|
className={cssNames(styles.bar, { [styles.warning]: warning && changeColorOnWarning })}
|
||||||
|
style={{ blockSize: height }}
|
||||||
/>
|
/>
|
||||||
{showPercent && <label>{percentsRounded}%</label>}
|
{showPercent && <span>{percentsRounded}%</span>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user