Compare commits

..

No commits in common. "1776a6bd2cd07a3c6e5b4fc71ccd133a1181141f" and "2980489b5bc2bc2c7d3840693f5ca78f5b052fe6" have entirely different histories.

5 changed files with 9 additions and 31 deletions

View File

@ -9,7 +9,8 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.11 (AI-powered-switches)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 3.13 interpreter library" level="application" />
</component>
</module>

2
.idea/misc.xml generated
View File

@ -3,5 +3,5 @@
<component name="Black">
<option name="sdkName" value="Python 3.13" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (AI-powered-switches)" project-jdk-type="Python SDK" />
</project>

View File

@ -29,7 +29,6 @@ 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('');
@ -113,26 +112,9 @@ const ConfigPage = () => {
setApplying(true);
setIsApplying(true);
try {
const applyOperation = async () => {
if (testMode) {
Common.sleep(1000).then(() => ({ success: true }));
} else {
let commands = JSON.parse(editableConfig)?.config?.commands;
console.log(`commands:${JSON.stringify(commands)}`);
const deviceConfig = JSON.parse(selectedDeviceConfig);
console.log(`deviceConfig:${JSON.stringify(deviceConfig)}`);
if (!deviceConfig.username || !deviceConfig.password) {
Notification.warn({
title: '所选交换机暂未配置用户名和密码',
description: '请前往交换机设备处配置username和password',
});
return false;
}
commands.push(`username=${deviceConfig.username.toString()}`);
commands.push(`password=${deviceConfig.password.toString()}`);
await api.applyConfig(selectedDevice, commands);
}
};
const applyOperation = testMode
? Common.sleep(1000).then(() => ({ success: true }))
: await api.applyConfig(selectedDevice, JSON.parse(editableConfig)?.config?.commands);
await Notification.promise({
promise: applyOperation,
@ -170,12 +152,7 @@ const ConfigPage = () => {
<Select.Root
collection={deviceCollection}
value={selectedDevice ? [selectedDevice] : []}
onValueChange={({ value }) => {
const selectedIp = value[0] ?? '';
setSelectedDevice(selectedIp);
const fullDeviceConfig = devices.find((device) => device.ip === selectedIp);
setSelectedDeviceConfig(JSON.stringify(fullDeviceConfig));
}}
onValueChange={({ value }) => setSelectedDevice(value[0] ?? '')}
placeholder={'请选择交换机设备'}
size={'sm'}
colorPalette={'teal'}

View File

@ -27,7 +27,7 @@ const Dashboard = () => {
const checkBackend = useCallback(async () => {
setNetworkStatus('loading');
try {
const res = true;//await api.test();
const res = await api.test();
if (res) {
setNetworkStatus('ok');
console.log(JSON.stringify(res));

View File

@ -50,7 +50,7 @@ export const api = {
* @returns {Promise<axios.AxiosResponse<any>>}
*/
applyConfig: (switch_ip, commands) =>
axios.post(buildUrl('/api/execute_cli_commands'), { switch_ip: switch_ip, commands: commands }),
axios.post(buildUrl('/api/execute_cli_commands'), { switch_ip, commands }),
/**
* 更新基础URL