mirror of
https://github.com/Jerryplusy/AI-powered-switches.git
synced 2025-10-14 09:49:19 +00:00
api适配用户名&密码
This commit is contained in:
parent
2980489b5b
commit
d6e8dfa13f
1
.idea/AI-powered-switches.iml
generated
1
.idea/AI-powered-switches.iml
generated
@ -11,6 +11,5 @@
|
||||
</content>
|
||||
<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>
|
@ -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 = () => {
|
||||
<Select.Root
|
||||
collection={deviceCollection}
|
||||
value={selectedDevice ? [selectedDevice] : []}
|
||||
onValueChange={({ value }) => setSelectedDevice(value[0] ?? '')}
|
||||
onValueChange={({ value }) => {
|
||||
setSelectedDevice(value[0] ?? '');
|
||||
setSelectedDeviceConfig(JSON.stringify(value));
|
||||
}}
|
||||
placeholder={'请选择交换机设备'}
|
||||
size={'sm'}
|
||||
colorPalette={'teal'}
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user