seeder-st2110-components 1.2.6 → 1.2.8
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.css +1 -0
- package/dist/index.esm.js +490 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +496 -16
- package/dist/index.js.map +1 -1
- package/package.json +12 -2
- package/src/styles/index.less +113 -0
package/dist/index.js
CHANGED
|
@@ -50,6 +50,7 @@ const useHardwareWebSocket = socketUrl => {
|
|
|
50
50
|
ps_status: systemStatus
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
+
var useHardwareWebSocket$1 = useHardwareWebSocket;
|
|
53
54
|
|
|
54
55
|
const UsageItem = /*#__PURE__*/react.memo(_ref => {
|
|
55
56
|
let {
|
|
@@ -85,6 +86,7 @@ const UsageItem = /*#__PURE__*/react.memo(_ref => {
|
|
|
85
86
|
})]
|
|
86
87
|
});
|
|
87
88
|
});
|
|
89
|
+
var UsageItem$1 = UsageItem;
|
|
88
90
|
|
|
89
91
|
const getTemperature = (supermicro, sensors) => {
|
|
90
92
|
return supermicro?.cpu_temperature ?? sensors?.temperatures?.coretemp?.[0]?.current;
|
|
@@ -102,29 +104,29 @@ const useHardwareUsage = function (ps_status) {
|
|
|
102
104
|
} = ps_status;
|
|
103
105
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
104
106
|
className: "flex",
|
|
105
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs(UsageItem, {
|
|
107
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(UsageItem$1, {
|
|
106
108
|
text: "CPU Usage",
|
|
107
109
|
iconClass: "icon-CPU",
|
|
108
110
|
children: [cpu_percent, "%"]
|
|
109
|
-
}), /*#__PURE__*/jsxRuntime.jsxs(UsageItem, {
|
|
111
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(UsageItem$1, {
|
|
110
112
|
text: "CPU Temperature",
|
|
111
113
|
iconClass: "icon-wendu",
|
|
112
114
|
children: [getTemperature(supermicro, sensors_temperatures), "\u2103"]
|
|
113
|
-
}), mem && /*#__PURE__*/jsxRuntime.jsxs(UsageItem, {
|
|
115
|
+
}), mem && /*#__PURE__*/jsxRuntime.jsxs(UsageItem$1, {
|
|
114
116
|
text: "Memory Usage",
|
|
115
117
|
iconClass: "icon-shiyongshuai",
|
|
116
118
|
showRam: showRam,
|
|
117
119
|
ramValue: (mem.total / (1024 * 1024 * 1024)).toFixed(1),
|
|
118
120
|
children: [mem.percent, "%"]
|
|
119
|
-
}), supermicro?.nic_temperature && /*#__PURE__*/jsxRuntime.jsxs(UsageItem, {
|
|
121
|
+
}), supermicro?.nic_temperature && /*#__PURE__*/jsxRuntime.jsxs(UsageItem$1, {
|
|
120
122
|
text: "NIC Temperature",
|
|
121
123
|
iconClass: "icon-wuliwangka",
|
|
122
124
|
children: [supermicro.nic_temperature, "\u2103"]
|
|
123
|
-
}), gpu_stats?.length > 0 && /*#__PURE__*/jsxRuntime.jsx(UsageItem, {
|
|
125
|
+
}), gpu_stats?.length > 0 && /*#__PURE__*/jsxRuntime.jsx(UsageItem$1, {
|
|
124
126
|
text: "GPU Usage",
|
|
125
127
|
iconClass: "icon-gpufuwu",
|
|
126
128
|
children: gpu_stats[0]["utilization.gpu"]
|
|
127
|
-
}), supermicro?.gpu_temperature && /*#__PURE__*/jsxRuntime.jsxs(UsageItem, {
|
|
129
|
+
}), supermicro?.gpu_temperature && /*#__PURE__*/jsxRuntime.jsxs(UsageItem$1, {
|
|
128
130
|
text: "GPU Temperature",
|
|
129
131
|
iconClass: "icon-wendu",
|
|
130
132
|
children: [supermicro.gpu_temperature, "\u2103"]
|
|
@@ -132,6 +134,7 @@ const useHardwareUsage = function (ps_status) {
|
|
|
132
134
|
});
|
|
133
135
|
}, [ps_status]);
|
|
134
136
|
};
|
|
137
|
+
var useHardwareUsage$1 = useHardwareUsage;
|
|
135
138
|
|
|
136
139
|
const AuthorizationModal = _ref => {
|
|
137
140
|
let {
|
|
@@ -221,6 +224,7 @@ const AuthorizationModal = _ref => {
|
|
|
221
224
|
})
|
|
222
225
|
});
|
|
223
226
|
};
|
|
227
|
+
var AuthorizationModal$1 = AuthorizationModal;
|
|
224
228
|
|
|
225
229
|
const DEFAULT_AUTH = {
|
|
226
230
|
accredit_status: false,
|
|
@@ -294,7 +298,7 @@ const useAuth = options => {
|
|
|
294
298
|
}
|
|
295
299
|
};
|
|
296
300
|
const modal = showModal && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
297
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(AuthorizationModal, {
|
|
301
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(AuthorizationModal$1, {
|
|
298
302
|
onOk: auth,
|
|
299
303
|
onCancel: closeModal,
|
|
300
304
|
authData: authData
|
|
@@ -612,6 +616,7 @@ const useUpgrade = _ref => {
|
|
|
612
616
|
});
|
|
613
617
|
return [upgradeElement];
|
|
614
618
|
};
|
|
619
|
+
var useUpgrade$1 = useUpgrade;
|
|
615
620
|
|
|
616
621
|
const useSystemOperations = function () {
|
|
617
622
|
let {
|
|
@@ -667,6 +672,7 @@ const useSystemOperations = function () {
|
|
|
667
672
|
handleMenuClick
|
|
668
673
|
};
|
|
669
674
|
};
|
|
675
|
+
var useSystemOperations$1 = useSystemOperations;
|
|
670
676
|
|
|
671
677
|
const PopoverContent = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
672
678
|
let {
|
|
@@ -1232,6 +1238,7 @@ const useDirectoryTree = _ref => {
|
|
|
1232
1238
|
removeFile
|
|
1233
1239
|
};
|
|
1234
1240
|
};
|
|
1241
|
+
var useDirectoryTree$1 = useDirectoryTree;
|
|
1235
1242
|
|
|
1236
1243
|
const UpgradeManager = _ref => {
|
|
1237
1244
|
let {
|
|
@@ -1246,7 +1253,7 @@ const UpgradeManager = _ref => {
|
|
|
1246
1253
|
children,
|
|
1247
1254
|
...dropdownProps
|
|
1248
1255
|
} = _ref;
|
|
1249
|
-
const [upgradeElement] = useUpgrade({
|
|
1256
|
+
const [upgradeElement] = useUpgrade$1({
|
|
1250
1257
|
menuItems,
|
|
1251
1258
|
onMenuClick,
|
|
1252
1259
|
downloadFiles,
|
|
@@ -1276,6 +1283,7 @@ UpgradeManager.defaultProps = {
|
|
|
1276
1283
|
trigger: ["hover"],
|
|
1277
1284
|
placement: "bottomRight"
|
|
1278
1285
|
};
|
|
1286
|
+
var UpgradeManager$1 = UpgradeManager;
|
|
1279
1287
|
|
|
1280
1288
|
function getDefaultExportFromCjs (x) {
|
|
1281
1289
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -2553,6 +2561,7 @@ SystemOperations.propTypes = {
|
|
|
2553
2561
|
okText: PropTypes.string,
|
|
2554
2562
|
run: PropTypes.func
|
|
2555
2563
|
};
|
|
2564
|
+
var SystemOperations$1 = SystemOperations;
|
|
2556
2565
|
|
|
2557
2566
|
const defaultFieldConfigs = {
|
|
2558
2567
|
clock_class: {
|
|
@@ -3177,15 +3186,486 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
3177
3186
|
};
|
|
3178
3187
|
var NetworkSettingsModal$1 = /*#__PURE__*/react.memo(NetworkSettingsModal);
|
|
3179
3188
|
|
|
3180
|
-
|
|
3189
|
+
const LeftList = /*#__PURE__*/react.memo(_ref => {
|
|
3190
|
+
let {
|
|
3191
|
+
dataSource,
|
|
3192
|
+
selectedPresetId,
|
|
3193
|
+
onSelectPreset,
|
|
3194
|
+
onAddNew,
|
|
3195
|
+
onRemove,
|
|
3196
|
+
hasPresets = dataSource.length > 0,
|
|
3197
|
+
showDescription = false,
|
|
3198
|
+
texts = {
|
|
3199
|
+
newButton: "New Preset",
|
|
3200
|
+
removeButton: "Remove"
|
|
3201
|
+
}
|
|
3202
|
+
} = _ref;
|
|
3203
|
+
// 动态计算列布局
|
|
3204
|
+
const gridColumns = showDescription ? "grid-cols-3" : "grid-cols-2";
|
|
3205
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3206
|
+
className: "h-full left-list-wrapper",
|
|
3207
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3208
|
+
className: "list-container",
|
|
3209
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.List, {
|
|
3210
|
+
header: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3211
|
+
className: `grid ${gridColumns} w-full list-header`,
|
|
3212
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3213
|
+
children: "Name"
|
|
3214
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3215
|
+
children: "Create Time"
|
|
3216
|
+
}), showDescription && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3217
|
+
children: "Description"
|
|
3218
|
+
})]
|
|
3219
|
+
}),
|
|
3220
|
+
dataSource: dataSource,
|
|
3221
|
+
rowKey: "id",
|
|
3222
|
+
renderItem: item => /*#__PURE__*/jsxRuntime.jsx(antd.List.Item, {
|
|
3223
|
+
className: `list-item ${selectedPresetId === item.id ? 'selected' : ''}`,
|
|
3224
|
+
style: {
|
|
3225
|
+
padding: "9px 24px"
|
|
3226
|
+
},
|
|
3227
|
+
onClick: () => onSelectPreset(item),
|
|
3228
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3229
|
+
className: `grid ${gridColumns} w-full text-text-normal`,
|
|
3230
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3231
|
+
title: item.name,
|
|
3232
|
+
children: item.name || "Untitled Preset"
|
|
3233
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3234
|
+
children: item.create_time
|
|
3235
|
+
}), showDescription && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3236
|
+
children: item.description
|
|
3237
|
+
})]
|
|
3238
|
+
})
|
|
3239
|
+
}),
|
|
3240
|
+
locale: {
|
|
3241
|
+
emptyText: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3242
|
+
className: "p-8",
|
|
3243
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
|
|
3244
|
+
image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
|
|
3245
|
+
description: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
3246
|
+
className: "text-gray-400",
|
|
3247
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
3248
|
+
type: "link",
|
|
3249
|
+
onClick: onAddNew,
|
|
3250
|
+
className: "p-0 h-auto",
|
|
3251
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(icons.PlusOutlined, {}),
|
|
3252
|
+
children: "Create new preset"
|
|
3253
|
+
})
|
|
3254
|
+
})
|
|
3255
|
+
})
|
|
3256
|
+
})
|
|
3257
|
+
}
|
|
3258
|
+
})
|
|
3259
|
+
}), hasPresets && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3260
|
+
className: "p-4",
|
|
3261
|
+
style: {
|
|
3262
|
+
paddingInline: 24
|
|
3263
|
+
},
|
|
3264
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
|
|
3265
|
+
size: "middle",
|
|
3266
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
3267
|
+
type: "default",
|
|
3268
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(icons.PlusOutlined, {}),
|
|
3269
|
+
style: {
|
|
3270
|
+
padding: "20px 12px"
|
|
3271
|
+
},
|
|
3272
|
+
className: "btn-gray",
|
|
3273
|
+
onClick: onAddNew,
|
|
3274
|
+
children: texts.newButton
|
|
3275
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
3276
|
+
type: "default",
|
|
3277
|
+
style: {
|
|
3278
|
+
padding: "20px 12px"
|
|
3279
|
+
},
|
|
3280
|
+
className: "btn-gray",
|
|
3281
|
+
onClick: onRemove,
|
|
3282
|
+
children: texts.removeButton
|
|
3283
|
+
})]
|
|
3284
|
+
})
|
|
3285
|
+
})]
|
|
3286
|
+
});
|
|
3287
|
+
});
|
|
3288
|
+
const SubmitButton = _ref2 => {
|
|
3289
|
+
let {
|
|
3290
|
+
loading,
|
|
3291
|
+
action,
|
|
3292
|
+
children,
|
|
3293
|
+
disabled = false
|
|
3294
|
+
} = _ref2;
|
|
3295
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3296
|
+
className: "submit-btn-wrapper",
|
|
3297
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
3298
|
+
className: "btn-gray",
|
|
3299
|
+
loading: loading,
|
|
3300
|
+
onClick: action,
|
|
3301
|
+
disabled: disabled,
|
|
3302
|
+
children: children
|
|
3303
|
+
})
|
|
3304
|
+
});
|
|
3305
|
+
};
|
|
3306
|
+
const RightDetailForm = /*#__PURE__*/react.memo(_ref3 => {
|
|
3307
|
+
let {
|
|
3308
|
+
form,
|
|
3309
|
+
onSave,
|
|
3310
|
+
onLoad,
|
|
3311
|
+
isLoading,
|
|
3312
|
+
isEditing,
|
|
3313
|
+
fields = {
|
|
3314
|
+
name: {
|
|
3315
|
+
label: "Preset Name",
|
|
3316
|
+
placeholder: "Enter preset name",
|
|
3317
|
+
required: true
|
|
3318
|
+
}
|
|
3319
|
+
},
|
|
3320
|
+
texts = {
|
|
3321
|
+
loadButton: "Load",
|
|
3322
|
+
saveButton: "Save"
|
|
3323
|
+
},
|
|
3324
|
+
presetChanged
|
|
3325
|
+
} = _ref3;
|
|
3326
|
+
const [initialSelected, setInitialSelected] = react.useState([]);
|
|
3327
|
+
const currentSelected = antd.Form.useWatch('category_list', form) || [];
|
|
3328
|
+
|
|
3329
|
+
// 检查是否包含category_list字段
|
|
3330
|
+
const hasCategoryList = fields.category_list !== null && fields.category_list !== undefined;
|
|
3331
|
+
|
|
3332
|
+
// 初始化 category_list 的选择状态
|
|
3333
|
+
react.useEffect(() => {
|
|
3334
|
+
if (hasCategoryList) {
|
|
3335
|
+
const currentValue = form.getFieldValue('category_list') || [];
|
|
3336
|
+
setInitialSelected(currentValue);
|
|
3337
|
+
}
|
|
3338
|
+
}, [presetChanged, form, hasCategoryList]); // 当presetChanged变化时更新
|
|
3339
|
+
|
|
3340
|
+
// 动态生成 checkbox 选项
|
|
3341
|
+
const checkboxOptions = react.useMemo(() => {
|
|
3342
|
+
if (!hasCategoryList) return [];
|
|
3343
|
+
return fields.category_list.options.map(category => {
|
|
3344
|
+
const isInitiallySelected = initialSelected.includes(category.name);
|
|
3345
|
+
const shouldDisable = isEditing ? !isInitiallySelected : false;
|
|
3346
|
+
return {
|
|
3347
|
+
...category,
|
|
3348
|
+
disabled: shouldDisable
|
|
3349
|
+
};
|
|
3350
|
+
});
|
|
3351
|
+
}, [initialSelected, isEditing, hasCategoryList, fields.category_list]);
|
|
3352
|
+
return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
3353
|
+
vertical: true,
|
|
3354
|
+
className: "h-full",
|
|
3355
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Form, {
|
|
3356
|
+
form: form,
|
|
3357
|
+
layout: "vertical",
|
|
3358
|
+
autoComplete: "off",
|
|
3359
|
+
style: {
|
|
3360
|
+
flex: 1,
|
|
3361
|
+
overflowY: 'auto'
|
|
3362
|
+
},
|
|
3363
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
3364
|
+
name: "name",
|
|
3365
|
+
label: fields.name.label,
|
|
3366
|
+
rules: [{
|
|
3367
|
+
required: fields.name.required,
|
|
3368
|
+
validator: async (_, value) => {
|
|
3369
|
+
if (!value || value.trim() === '') {
|
|
3370
|
+
return Promise.reject(new Error('Preset name cannot be empty or spaces only'));
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
}],
|
|
3374
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
3375
|
+
placeholder: fields.name.placeholder,
|
|
3376
|
+
disabled: isEditing
|
|
3377
|
+
})
|
|
3378
|
+
}), hasCategoryList && /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
3379
|
+
name: "category_list",
|
|
3380
|
+
label: fields.category_list.label,
|
|
3381
|
+
rules: [{
|
|
3382
|
+
required: fields.category_list.required,
|
|
3383
|
+
message: 'Please select at least one category',
|
|
3384
|
+
validator: (_, value) => {
|
|
3385
|
+
if (value && value.length > 0) {
|
|
3386
|
+
return Promise.resolve();
|
|
3387
|
+
}
|
|
3388
|
+
return Promise.reject(new Error('Please select at least one category'));
|
|
3389
|
+
}
|
|
3390
|
+
}],
|
|
3391
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox.Group, {
|
|
3392
|
+
className: "grid grid-cols-2 gap-2",
|
|
3393
|
+
children: checkboxOptions.map(category => /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
|
|
3394
|
+
value: category.name,
|
|
3395
|
+
disabled: category.disabled,
|
|
3396
|
+
children: category.label
|
|
3397
|
+
}, category.name))
|
|
3398
|
+
})
|
|
3399
|
+
}), fields.description && /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
3400
|
+
name: "description",
|
|
3401
|
+
label: fields.description.label,
|
|
3402
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Input.TextArea, {
|
|
3403
|
+
rows: 4,
|
|
3404
|
+
placeholder: fields.description.placeholder,
|
|
3405
|
+
disabled: isEditing
|
|
3406
|
+
})
|
|
3407
|
+
})]
|
|
3408
|
+
}), isEditing ? /*#__PURE__*/jsxRuntime.jsx(SubmitButton, {
|
|
3409
|
+
action: onLoad,
|
|
3410
|
+
...(hasCategoryList && {
|
|
3411
|
+
disabled: !currentSelected.length
|
|
3412
|
+
}),
|
|
3413
|
+
children: texts.loadButton
|
|
3414
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(SubmitButton, {
|
|
3415
|
+
action: onSave,
|
|
3416
|
+
loading: isLoading,
|
|
3417
|
+
children: texts.saveButton
|
|
3418
|
+
})]
|
|
3419
|
+
});
|
|
3420
|
+
});
|
|
3421
|
+
|
|
3422
|
+
const Preset = _ref => {
|
|
3423
|
+
let {
|
|
3424
|
+
open,
|
|
3425
|
+
onClose,
|
|
3426
|
+
// API 方法通过 props 传入
|
|
3427
|
+
getPresetList,
|
|
3428
|
+
savePreset,
|
|
3429
|
+
removePreset,
|
|
3430
|
+
loadPreset,
|
|
3431
|
+
// 字段配置
|
|
3432
|
+
fields = {
|
|
3433
|
+
name: {
|
|
3434
|
+
label: "Preset Name",
|
|
3435
|
+
placeholder: "Enter preset name",
|
|
3436
|
+
required: true
|
|
3437
|
+
}
|
|
3438
|
+
},
|
|
3439
|
+
texts = {
|
|
3440
|
+
title: "Preset Management",
|
|
3441
|
+
emptyText: "Select a preset from the list to view details",
|
|
3442
|
+
deleteConfirm: "Are you sure to delete preset",
|
|
3443
|
+
loadText: "Loading...",
|
|
3444
|
+
successText: "Success",
|
|
3445
|
+
newButton: "New Preset",
|
|
3446
|
+
removeButton: "Remove",
|
|
3447
|
+
loadButton: "Load",
|
|
3448
|
+
saveButton: "Save"
|
|
3449
|
+
},
|
|
3450
|
+
// 样式定制
|
|
3451
|
+
width = 1000,
|
|
3452
|
+
height = 680,
|
|
3453
|
+
className = ""
|
|
3454
|
+
} = _ref;
|
|
3455
|
+
const {
|
|
3456
|
+
message: AntdMessage,
|
|
3457
|
+
modal: AntdModal
|
|
3458
|
+
} = antd.App.useApp();
|
|
3459
|
+
const [presetList, setPresetList] = react.useState([]);
|
|
3460
|
+
const [selectedPreset, setSelectedPreset] = react.useState(null);
|
|
3461
|
+
const [loading, setLoading] = react.useState(false);
|
|
3462
|
+
const [presetChanged, setPresetChanged] = react.useState(0);
|
|
3463
|
+
const [form] = antd.Form.useForm();
|
|
3464
|
+
|
|
3465
|
+
// 获取预设列表
|
|
3466
|
+
react.useEffect(() => {
|
|
3467
|
+
fetchPresetList();
|
|
3468
|
+
}, []);
|
|
3469
|
+
const fetchPresetList = react.useCallback(async () => {
|
|
3470
|
+
try {
|
|
3471
|
+
const data = await getPresetList();
|
|
3472
|
+
if (data?.preset_list) {
|
|
3473
|
+
setPresetList(data.preset_list);
|
|
3474
|
+
}
|
|
3475
|
+
} catch (error) {
|
|
3476
|
+
console.error('Failed to fetch preset list:', error);
|
|
3477
|
+
}
|
|
3478
|
+
}, [getPresetList]);
|
|
3479
|
+
const handleSelectPreset = react.useCallback(preset => {
|
|
3480
|
+
setSelectedPreset(preset);
|
|
3481
|
+
form.setFieldsValue(preset);
|
|
3482
|
+
// setPresetChanged(prev => prev + 1); // 触发更新
|
|
3483
|
+
}, [form]);
|
|
3484
|
+
const handleAddNew = react.useCallback(() => {
|
|
3485
|
+
const unsavedPreset = presetList.find(item => !item.id);
|
|
3486
|
+
if (unsavedPreset) {
|
|
3487
|
+
AntdMessage.warning('Existing unsaved preset detected.');
|
|
3488
|
+
return;
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
// 创建新的数据,包含所有配置的字段
|
|
3492
|
+
const newPreset = Object.keys(fields).reduce((acc, fieldName) => {
|
|
3493
|
+
acc[fieldName] = '';
|
|
3494
|
+
return acc;
|
|
3495
|
+
}, {});
|
|
3496
|
+
|
|
3497
|
+
// 特殊处理 category_list
|
|
3498
|
+
if (fields.category_list?.options) {
|
|
3499
|
+
newPreset.category_list = fields.category_list.options.map(item => item.name);
|
|
3500
|
+
}
|
|
3501
|
+
setPresetList([...presetList, newPreset]);
|
|
3502
|
+
setSelectedPreset(newPreset);
|
|
3503
|
+
form.setFieldsValue(newPreset);
|
|
3504
|
+
}, [form, presetList, AntdMessage]);
|
|
3505
|
+
const handleRemove = react.useCallback(async () => {
|
|
3506
|
+
if (!selectedPreset) return;
|
|
3507
|
+
|
|
3508
|
+
// 检查是否为新建的未保存数据(无id)
|
|
3509
|
+
const isUnsavedPreset = !selectedPreset.id;
|
|
3510
|
+
const presetName = selectedPreset.name || 'Untitled Preset';
|
|
3511
|
+
try {
|
|
3512
|
+
AntdModal.confirm({
|
|
3513
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(icons.ExclamationCircleFilled, {}),
|
|
3514
|
+
title: `${texts.deleteConfirm} "${presetName}"?`,
|
|
3515
|
+
cancelText: 'No',
|
|
3516
|
+
okText: 'Yes',
|
|
3517
|
+
onOk: async () => {
|
|
3518
|
+
if (!isUnsavedPreset) {
|
|
3519
|
+
await removePreset({
|
|
3520
|
+
id: selectedPreset.id
|
|
3521
|
+
});
|
|
3522
|
+
AntdMessage.success(texts.successText);
|
|
3523
|
+
// 刷新列表
|
|
3524
|
+
await fetchPresetList();
|
|
3525
|
+
} else {
|
|
3526
|
+
setPresetList(prev => prev.filter(item => !!item.id));
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
// 重置表单和选择状态
|
|
3530
|
+
setSelectedPreset(null);
|
|
3531
|
+
form.resetFields();
|
|
3532
|
+
}
|
|
3533
|
+
});
|
|
3534
|
+
} catch (error) {
|
|
3535
|
+
console.error('Failed to delete preset:', error);
|
|
3536
|
+
}
|
|
3537
|
+
}, [selectedPreset, form, AntdModal, AntdMessage, fetchPresetList, texts]);
|
|
3538
|
+
const handleLoadPreset = react.useCallback(async () => {
|
|
3539
|
+
if (!selectedPreset?.id) return;
|
|
3540
|
+
|
|
3541
|
+
// 显示加载模态框
|
|
3542
|
+
const modalInstance = antd.Modal.info({
|
|
3543
|
+
title: texts.loadText,
|
|
3544
|
+
content: /*#__PURE__*/jsxRuntime.jsx(antd.Spin, {
|
|
3545
|
+
size: "large",
|
|
3546
|
+
className: "block mx-auto"
|
|
3547
|
+
}),
|
|
3548
|
+
maskClosable: false,
|
|
3549
|
+
okButtonProps: {
|
|
3550
|
+
style: {
|
|
3551
|
+
display: 'none'
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
});
|
|
3555
|
+
try {
|
|
3556
|
+
await loadPreset({
|
|
3557
|
+
id: selectedPreset.id,
|
|
3558
|
+
...(selectedPreset.category_list && {
|
|
3559
|
+
category_list: selectedPreset.category_list
|
|
3560
|
+
})
|
|
3561
|
+
});
|
|
3562
|
+
// 成功时延迟关闭
|
|
3563
|
+
setTimeout(() => {
|
|
3564
|
+
modalInstance.destroy();
|
|
3565
|
+
AntdMessage.success(texts.successText);
|
|
3566
|
+
}, 1000);
|
|
3567
|
+
} catch (error) {
|
|
3568
|
+
console.error('Failed to load preset:', error);
|
|
3569
|
+
modalInstance.destroy();
|
|
3570
|
+
}
|
|
3571
|
+
}, [selectedPreset, loadPreset, texts, AntdMessage]);
|
|
3572
|
+
const handleSave = react.useCallback(async () => {
|
|
3573
|
+
setLoading(true);
|
|
3574
|
+
try {
|
|
3575
|
+
const values = await form.validateFields();
|
|
3576
|
+
console.log('Form values:', values);
|
|
3577
|
+
await savePreset(values);
|
|
3578
|
+
AntdMessage.success(texts.successText);
|
|
3579
|
+
// 刷新列表
|
|
3580
|
+
await fetchPresetList();
|
|
3581
|
+
|
|
3582
|
+
// 重置表单和选择状态
|
|
3583
|
+
setSelectedPreset(null);
|
|
3584
|
+
form.resetFields();
|
|
3585
|
+
} catch (error) {
|
|
3586
|
+
if (error.errorFields) {
|
|
3587
|
+
// 表单验证错误
|
|
3588
|
+
console.error('Form validation failed:', error.errorFields);
|
|
3589
|
+
} else {
|
|
3590
|
+
console.error('Failed to save preset:', error);
|
|
3591
|
+
}
|
|
3592
|
+
} finally {
|
|
3593
|
+
setLoading(false);
|
|
3594
|
+
}
|
|
3595
|
+
}, [form, AntdMessage, fetchPresetList, savePreset, texts]);
|
|
3596
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.Modal, {
|
|
3597
|
+
title: texts.title,
|
|
3598
|
+
width: width,
|
|
3599
|
+
open: open,
|
|
3600
|
+
wrapClassName: `preset-management ${className}`,
|
|
3601
|
+
footer: null,
|
|
3602
|
+
onCancel: onClose,
|
|
3603
|
+
centered: true,
|
|
3604
|
+
styles: {
|
|
3605
|
+
body: {
|
|
3606
|
+
height: `${height}px`
|
|
3607
|
+
}
|
|
3608
|
+
},
|
|
3609
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(antd.Row, {
|
|
3610
|
+
gutter: 0,
|
|
3611
|
+
className: "h-full w-full",
|
|
3612
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Col, {
|
|
3613
|
+
span: 14,
|
|
3614
|
+
className: "h-full",
|
|
3615
|
+
children: /*#__PURE__*/jsxRuntime.jsx(LeftList, {
|
|
3616
|
+
dataSource: presetList,
|
|
3617
|
+
selectedPresetId: selectedPreset?.id,
|
|
3618
|
+
onSelectPreset: handleSelectPreset,
|
|
3619
|
+
onAddNew: handleAddNew,
|
|
3620
|
+
onRemove: handleRemove,
|
|
3621
|
+
showDescription: !!fields.description // 根据 fields 判断是否显示 description
|
|
3622
|
+
,
|
|
3623
|
+
texts: {
|
|
3624
|
+
newButton: texts.newButton,
|
|
3625
|
+
removeButton: texts.removeButton
|
|
3626
|
+
}
|
|
3627
|
+
})
|
|
3628
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
|
|
3629
|
+
span: 10,
|
|
3630
|
+
className: "h-full p-6",
|
|
3631
|
+
children: selectedPreset ? /*#__PURE__*/jsxRuntime.jsx(RightDetailForm, {
|
|
3632
|
+
form: form,
|
|
3633
|
+
onSave: handleSave,
|
|
3634
|
+
onLoad: handleLoadPreset,
|
|
3635
|
+
isLoading: loading,
|
|
3636
|
+
isEditing: !!selectedPreset?.id,
|
|
3637
|
+
fields: fields,
|
|
3638
|
+
texts: {
|
|
3639
|
+
loadButton: texts.loadButton,
|
|
3640
|
+
saveButton: texts.saveButton
|
|
3641
|
+
},
|
|
3642
|
+
presetChanged: presetChanged
|
|
3643
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(antd.Flex, {
|
|
3644
|
+
vertical: true,
|
|
3645
|
+
justify: "center",
|
|
3646
|
+
align: "center",
|
|
3647
|
+
className: "h-full text-gray-400",
|
|
3648
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
|
|
3649
|
+
image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
|
|
3650
|
+
description: texts.emptyText
|
|
3651
|
+
})
|
|
3652
|
+
})
|
|
3653
|
+
})]
|
|
3654
|
+
})
|
|
3655
|
+
});
|
|
3656
|
+
};
|
|
3657
|
+
var PresetModal = /*#__PURE__*/react.memo(Preset);
|
|
3658
|
+
|
|
3659
|
+
exports.AuthorizationModal = AuthorizationModal$1;
|
|
3181
3660
|
exports.NetworkSettingsModal = NetworkSettingsModal$1;
|
|
3661
|
+
exports.PresetModal = PresetModal;
|
|
3182
3662
|
exports.PtpModal = PtpModal$1;
|
|
3183
|
-
exports.SystemOperations = SystemOperations;
|
|
3184
|
-
exports.UpgradeManager = UpgradeManager;
|
|
3663
|
+
exports.SystemOperations = SystemOperations$1;
|
|
3664
|
+
exports.UpgradeManager = UpgradeManager$1;
|
|
3185
3665
|
exports.useAuth = useAuth;
|
|
3186
|
-
exports.useDirectoryTree = useDirectoryTree;
|
|
3187
|
-
exports.useHardwareUsage = useHardwareUsage;
|
|
3188
|
-
exports.useHardwareWebSocket = useHardwareWebSocket;
|
|
3189
|
-
exports.useSystemOperations = useSystemOperations;
|
|
3190
|
-
exports.useUpgrade = useUpgrade;
|
|
3666
|
+
exports.useDirectoryTree = useDirectoryTree$1;
|
|
3667
|
+
exports.useHardwareUsage = useHardwareUsage$1;
|
|
3668
|
+
exports.useHardwareWebSocket = useHardwareWebSocket$1;
|
|
3669
|
+
exports.useSystemOperations = useSystemOperations$1;
|
|
3670
|
+
exports.useUpgrade = useUpgrade$1;
|
|
3191
3671
|
//# sourceMappingURL=index.js.map
|