diff --git a/.idea/AI-powered-switches.iml b/.idea/AI-powered-switches.iml
index b5db305..f438690 100644
--- a/.idea/AI-powered-switches.iml
+++ b/.idea/AI-powered-switches.iml
@@ -11,6 +11,5 @@
-
-
\ No newline at end of file
+
diff --git a/src/frontend/src/pages/ConfigPage.jsx b/src/frontend/src/pages/ConfigPage.jsx
index bc5d98a..ac1450c 100644
--- a/src/frontend/src/pages/ConfigPage.jsx
+++ b/src/frontend/src/pages/ConfigPage.jsx
@@ -29,6 +29,7 @@ const testMode = ConfigTool.load().testMode;
const ConfigPage = () => {
const [devices, setDevices] = useState([]);
const [selectedDevice, setSelectedDevice] = useState('');
+ const [selectedDeviceConfig, setSelectedDeviceConfig] = useState('');
const [inputText, setInputText] = useState('');
const [parsedConfig, setParsedConfig] = useState('');
const [editableConfig, setEditableConfig] = useState('');
@@ -112,9 +113,26 @@ const ConfigPage = () => {
setApplying(true);
setIsApplying(true);
try {
- const applyOperation = testMode
- ? Common.sleep(1000).then(() => ({ success: true }))
- : await api.applyConfig(selectedDevice, JSON.parse(editableConfig)?.config?.commands);
+ const applyOperation = async () => {
+ if (testMode) {
+ Common.sleep(1000).then(() => ({ success: true }));
+ } else {
+ let commands = JSON.parse(editableConfig)?.config?.commands;
+ const deviceConfig = JSON.parse(selectedDeviceConfig);
+ if (!deviceConfig.username || !deviceConfig.password) {
+ Notification.warn({
+ title: '所选交换机暂未配置用户名和密码',
+ description: '请前往交换机设备处配置username和password',
+ });
+ return;
+ }
+ commands.push({
+ username: deviceConfig.username,
+ password: deviceConfig.password,
+ });
+ await api.applyConfig(selectedDevice, commands);
+ }
+ };
await Notification.promise({
promise: applyOperation,
@@ -152,7 +170,10 @@ const ConfigPage = () => {
setSelectedDevice(value[0] ?? '')}
+ onValueChange={({ value }) => {
+ setSelectedDevice(value[0] ?? '');
+ setSelectedDeviceConfig(JSON.stringify(value));
+ }}
placeholder={'请选择交换机设备'}
size={'sm'}
colorPalette={'teal'}
diff --git a/src/frontend/src/pages/Dashboard.jsx b/src/frontend/src/pages/Dashboard.jsx
index 41d5a34..f8bba56 100644
--- a/src/frontend/src/pages/Dashboard.jsx
+++ b/src/frontend/src/pages/Dashboard.jsx
@@ -27,7 +27,7 @@ const Dashboard = () => {
const checkBackend = useCallback(async () => {
setNetworkStatus('loading');
try {
- const res = await api.test();
+ const res = true;//await api.test();
if (res) {
setNetworkStatus('ok');
console.log(JSON.stringify(res));