seeder-st2110-components 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +106 -57
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +102 -53
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -52,20 +52,28 @@ const useHardwareWebSocket = socketUrl => {
|
|
|
52
52
|
};
|
|
53
53
|
var useHardwareWebSocket$1 = useHardwareWebSocket;
|
|
54
54
|
|
|
55
|
+
const formatBytes = function (bytes) {
|
|
56
|
+
let decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
57
|
+
if (bytes === 0 || !bytes) return '0 Bytes';
|
|
58
|
+
const k = 1024;
|
|
59
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
60
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
61
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
62
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
63
|
+
};
|
|
55
64
|
const UsageItem = /*#__PURE__*/react.memo(_ref => {
|
|
56
65
|
let {
|
|
66
|
+
title,
|
|
57
67
|
iconClass,
|
|
58
|
-
text,
|
|
59
68
|
children,
|
|
60
|
-
|
|
61
|
-
ramValue
|
|
69
|
+
memTotal
|
|
62
70
|
} = _ref;
|
|
63
|
-
|
|
71
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
64
72
|
title: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
65
73
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
66
|
-
children:
|
|
67
|
-
}),
|
|
68
|
-
children: ["Total Memory: ",
|
|
74
|
+
children: title
|
|
75
|
+
}), title === 'Memory Usage' && memTotal !== undefined && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
76
|
+
children: ["Total Memory: ", formatBytes(memTotal)]
|
|
69
77
|
})]
|
|
70
78
|
}),
|
|
71
79
|
destroyOnHidden: false,
|
|
@@ -78,59 +86,100 @@ const UsageItem = /*#__PURE__*/react.memo(_ref => {
|
|
|
78
86
|
children: children
|
|
79
87
|
})]
|
|
80
88
|
})
|
|
81
|
-
}), [text, iconClass, children]);
|
|
82
|
-
return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
83
|
-
align: "center",
|
|
84
|
-
children: [tooltipContent, /*#__PURE__*/jsxRuntime.jsx(antd.Divider, {
|
|
85
|
-
type: "vertical"
|
|
86
|
-
})]
|
|
87
89
|
});
|
|
88
90
|
});
|
|
89
91
|
var UsageItem$1 = UsageItem;
|
|
90
92
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
+
const getMaxNicTemp = function (sensors) {
|
|
94
|
+
let priorityFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ["i350bb", "r8169_0_8300:00"];
|
|
95
|
+
const temps = priorityFields.flatMap(field => sensors?.[field]?.map(item => item.current) || []).filter(temp => typeof temp === 'number');
|
|
96
|
+
return temps.length ? Math.max(...temps) : null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// 获取数组类型传感器最高温度(如内存、硬盘)
|
|
100
|
+
const getMaxSensorTemp = sensorData => {
|
|
101
|
+
const temps = (sensorData || []).map(item => item.current).filter(temp => typeof temp === 'number');
|
|
102
|
+
return temps.length ? Math.max(...temps) : null;
|
|
103
|
+
};
|
|
104
|
+
const getDetail = function () {
|
|
105
|
+
let status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
106
|
+
const {
|
|
107
|
+
cpu_percent,
|
|
108
|
+
mem,
|
|
109
|
+
sensors_temperatures,
|
|
110
|
+
gpu_stats
|
|
111
|
+
} = status;
|
|
112
|
+
return {
|
|
113
|
+
cpu_usage: cpu_percent ?? null,
|
|
114
|
+
cpu_temp: sensors_temperatures?.coretemp?.[0]?.current ?? null,
|
|
115
|
+
mem_total: mem?.total ?? null,
|
|
116
|
+
mem_usage: mem?.percent ?? null,
|
|
117
|
+
mem_temp: getMaxSensorTemp(sensors_temperatures?.spd5118),
|
|
118
|
+
nic_temp: getMaxNicTemp(sensors_temperatures) ?? null,
|
|
119
|
+
hd_temp: getMaxSensorTemp(sensors_temperatures?.nvme),
|
|
120
|
+
gpu_usage: gpu_stats?.[0]?.["utilization.gpu"] ?? null,
|
|
121
|
+
gpu_temp: gpu_stats?.[0]?.["temperature.gpu"] ?? null
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// 提取公共逻辑
|
|
126
|
+
const createMetricItem = (title, iconClass, value, unit) => {
|
|
127
|
+
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
128
|
+
return {
|
|
129
|
+
title,
|
|
130
|
+
iconClass,
|
|
131
|
+
valueString: `${numValue}${unit}`,
|
|
132
|
+
value: numValue
|
|
133
|
+
};
|
|
93
134
|
};
|
|
94
|
-
const
|
|
95
|
-
|
|
135
|
+
const getItems = details => {
|
|
136
|
+
const items = [];
|
|
137
|
+
if (details.cpu_usage !== null && details.cpu_usage !== undefined) {
|
|
138
|
+
items.push(createMetricItem('CPU Usage', 'icon-CPU', details.cpu_usage, '%'));
|
|
139
|
+
}
|
|
140
|
+
if (details.cpu_temp !== null && details.cpu_temp !== undefined) {
|
|
141
|
+
items.push(createMetricItem('CPU Temperature', 'icon-CPUwendu', details.cpu_temp, '℃'));
|
|
142
|
+
}
|
|
143
|
+
if (details.mem_usage !== null && details.mem_usage !== undefined) {
|
|
144
|
+
items.push({
|
|
145
|
+
...createMetricItem('Memory Usage', 'icon-shiyongshuai', details.mem_usage, '%'),
|
|
146
|
+
memTotal: details.mem_total
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (details.mem_temp !== null && details.mem_temp !== undefined) {
|
|
150
|
+
items.push(createMetricItem('Memory Temperature', 'icon-wendu', details.mem_temp, '℃'));
|
|
151
|
+
}
|
|
152
|
+
if (details.nic_temp !== null && details.nic_temp !== undefined) {
|
|
153
|
+
items.push(createMetricItem('NIC Temperature', 'icon-wuliwangka', details.nic_temp, '℃'));
|
|
154
|
+
}
|
|
155
|
+
if (details.hd_temp !== null && details.hd_temp !== undefined) {
|
|
156
|
+
items.push(createMetricItem('HD Temperature', 'icon-yingpan', details.hd_temp, '℃'));
|
|
157
|
+
}
|
|
158
|
+
if (details.gpu_usage !== null && details.gpu_usage !== undefined) {
|
|
159
|
+
items.push(createMetricItem('GPU Usage', 'icon-gpufuwu', details.gpu_usage, '%'));
|
|
160
|
+
}
|
|
161
|
+
if (details.gpu_temp !== null && details.gpu_temp !== undefined) {
|
|
162
|
+
items.push(createMetricItem('GPU Temperature', 'icon-CPUwendu', details.gpu_temp, '℃'));
|
|
163
|
+
}
|
|
164
|
+
return items;
|
|
165
|
+
};
|
|
166
|
+
const useHardwareUsage = ps_status => {
|
|
96
167
|
return react.useMemo(() => {
|
|
97
168
|
if (!ps_status || typeof ps_status !== 'object') return null;
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
sensors_temperatures,
|
|
101
|
-
mem,
|
|
102
|
-
gpu_stats,
|
|
103
|
-
supermicro
|
|
104
|
-
} = ps_status;
|
|
105
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
169
|
+
const statusItems = getItems(getDetail(ps_status));
|
|
170
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
106
171
|
className: "flex",
|
|
107
|
-
children:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
showRam: showRam,
|
|
119
|
-
ramValue: (mem.total / (1024 * 1024 * 1024)).toFixed(1),
|
|
120
|
-
children: [mem.percent, "%"]
|
|
121
|
-
}), supermicro?.nic_temperature && /*#__PURE__*/jsxRuntime.jsxs(UsageItem$1, {
|
|
122
|
-
text: "NIC Temperature",
|
|
123
|
-
iconClass: "icon-wuliwangka",
|
|
124
|
-
children: [supermicro.nic_temperature, "\u2103"]
|
|
125
|
-
}), gpu_stats?.length > 0 && /*#__PURE__*/jsxRuntime.jsx(UsageItem$1, {
|
|
126
|
-
text: "GPU Usage",
|
|
127
|
-
iconClass: "icon-gpufuwu",
|
|
128
|
-
children: gpu_stats[0]["utilization.gpu"]
|
|
129
|
-
}), supermicro?.gpu_temperature && /*#__PURE__*/jsxRuntime.jsxs(UsageItem$1, {
|
|
130
|
-
text: "GPU Temperature",
|
|
131
|
-
iconClass: "icon-wendu",
|
|
132
|
-
children: [supermicro.gpu_temperature, "\u2103"]
|
|
133
|
-
})]
|
|
172
|
+
children: statusItems.map((item, index) => /*#__PURE__*/jsxRuntime.jsxs(Flex, {
|
|
173
|
+
align: "center",
|
|
174
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(UsageItem$1, {
|
|
175
|
+
title: item.title,
|
|
176
|
+
iconClass: item.iconClass,
|
|
177
|
+
memTotal: item.memTotal,
|
|
178
|
+
children: item.valueString
|
|
179
|
+
}), index < statusItems.length - 1 && /*#__PURE__*/jsxRuntime.jsx(antd.Divider, {
|
|
180
|
+
type: "vertical"
|
|
181
|
+
})]
|
|
182
|
+
}, item.title))
|
|
134
183
|
});
|
|
135
184
|
}, [ps_status]);
|
|
136
185
|
};
|
|
@@ -842,7 +891,7 @@ const TreeTitleNode = _ref2 => {
|
|
|
842
891
|
className: "iconfont icon-bianji"
|
|
843
892
|
})
|
|
844
893
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Popconfirm, {
|
|
845
|
-
title: "Confirm
|
|
894
|
+
title: "Confirm deletion?",
|
|
846
895
|
onConfirm: () => handleDel(nodeData),
|
|
847
896
|
okText: "Yes",
|
|
848
897
|
cancelText: "No",
|