서버 관리
This commit is contained in:
+32
-26
@@ -1,26 +1,26 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { APIProvider, useAPI } from './providers/APIProvider';
|
||||
import { LoadTestProvider } from './providers/LoadTestProvider';
|
||||
import DialogManager from './components/shared/DialogManager';
|
||||
import { monacoConfig } from '@/config/monaco.js';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import {APIProvider, useAPI} from './providers/APIProvider';
|
||||
import {LoadTestProvider} from './providers/LoadTestProvider';
|
||||
import DialogManager from '@/components/shared/DialogManager';
|
||||
import {monacoConfig} from '@/config/monaco.js';
|
||||
import LoginDialog from '@/components/account/LoginDialog.jsx';
|
||||
import AppMenu from './components/app-menu/AppMenu';
|
||||
import { SCREENS } from './config/screenConfig';
|
||||
import {SCREENS} from './config/screenConfig';
|
||||
|
||||
window.MonacoEnvironment = monacoConfig;
|
||||
|
||||
const App = ({ options = { contextPath: '/' } }) => {
|
||||
const App = ({options = {contextPath: '/'}}) => {
|
||||
const [showLogin, setShowLogin] = useState(false);
|
||||
|
||||
return (
|
||||
<APIProvider contextPath={options.contextPath}>
|
||||
<AppContent options={options} showLogin={showLogin} setShowLogin={setShowLogin} />
|
||||
<AppContent options={options} showLogin={showLogin} setShowLogin={setShowLogin}/>
|
||||
</APIProvider>
|
||||
);
|
||||
};
|
||||
|
||||
const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
const { isAuthenticated, setIsAuthenticated, handleLogout } = useAPI();
|
||||
const AppContent = ({options, showLogin, setShowLogin}) => {
|
||||
const {isAuthenticated, setIsAuthenticated, handleLogout} = useAPI();
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
const [currentScreen, setCurrentScreen] = useState('api-tester');
|
||||
const [dialogState, setDialogState] = useState({
|
||||
@@ -33,7 +33,8 @@ const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
showQueueEdit: false,
|
||||
showUserEdit: false,
|
||||
showPasswordChange: false,
|
||||
selectedItem: null,
|
||||
showServerEdit: false,
|
||||
selectedItem: null
|
||||
});
|
||||
|
||||
const handleMenuClick = async (action, screen, item = null) => {
|
||||
@@ -50,41 +51,45 @@ const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
// Handle modal actions
|
||||
switch (action) {
|
||||
case 'request-add':
|
||||
setDialogState(prev => ({ ...prev, showAddApi: true }));
|
||||
setDialogState(prev => ({...prev, showAddApi: true}));
|
||||
break;
|
||||
case 'response-add':
|
||||
case 'response-edit':
|
||||
case 'response-clone':
|
||||
setDialogState(prev => ({...prev, showMockRouteEdit: true, selectedItem: item }));
|
||||
setDialogState(prev => ({...prev, showMockRouteEdit: true, selectedItem: item}));
|
||||
break;
|
||||
case 'queue-add':
|
||||
case 'queue-edit':
|
||||
setDialogState(prev => ({ ...prev, showQueueEdit: true , selectedItem: item}));
|
||||
setDialogState(prev => ({...prev, showQueueEdit: true, selectedItem: item}));
|
||||
break;
|
||||
case 'user-add':
|
||||
case 'user-edit':
|
||||
setDialogState(prev => ({ ...prev, showUserEdit: true , selectedItem: item}));
|
||||
setDialogState(prev => ({...prev, showUserEdit: true, selectedItem: item}));
|
||||
break;
|
||||
case 'socket-add':
|
||||
case 'socket-edit':
|
||||
setDialogState(prev => ({ ...prev, showTCPServerEdit: true , selectedItem: item}));
|
||||
setDialogState(prev => ({...prev, showTCPServerEdit: true, selectedItem: item}));
|
||||
break;
|
||||
case 'server-add':
|
||||
case 'server-edit':
|
||||
setDialogState(prev => ({...prev, showServerEdit: true, selectedItem: item}));
|
||||
break;
|
||||
case 'collection-add':
|
||||
setDialogState(prev => ({ ...prev, showAddCollection: true }));
|
||||
setDialogState(prev => ({...prev, showAddCollection: true}));
|
||||
break;
|
||||
case 'scenario-add':
|
||||
setDialogState(prev => ({ ...prev, showAddScenario: true }));
|
||||
setDialogState(prev => ({...prev, showAddScenario: true}));
|
||||
break;
|
||||
case 'variables-show':
|
||||
setDialogState(prev => ({ ...prev, showVariableModal: true }));
|
||||
setDialogState(prev => ({...prev, showVariableModal: true}));
|
||||
break;
|
||||
case 'change-password':
|
||||
setDialogState(prev => ({ ...prev, showPasswordChange: true }));
|
||||
setDialogState(prev => ({...prev, showPasswordChange: true}));
|
||||
break;
|
||||
case 'logout':
|
||||
const success = await handleLogout();
|
||||
if (success) {
|
||||
window.location.href = "/actionLogout.do";
|
||||
window.location.href = `${options.contextPath}/actionLogout.do`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -117,14 +122,14 @@ const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
setIsInitialized(true);
|
||||
checkAuth();
|
||||
}
|
||||
}, [isInitialized]);
|
||||
}, [isInitialized, checkAuth]);
|
||||
|
||||
const handleDialogChange = (dialogName, isOpen) => {
|
||||
setDialogState(prev => ({ ...prev, [dialogName]: isOpen }));
|
||||
setDialogState(prev => ({...prev, [dialogName]: isOpen}));
|
||||
};
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <LoginDialog open={showLogin} onOpenChange={setShowLogin} />;
|
||||
return <LoginDialog open={showLogin} onOpenChange={setShowLogin}/>;
|
||||
}
|
||||
|
||||
const CurrentScreenComponent = SCREENS[currentScreen] || SCREENS['api-tester'];
|
||||
@@ -132,7 +137,7 @@ const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
return (
|
||||
<LoadTestProvider contextPath={options.contextPath}>
|
||||
<div className="flex flex-col h-screen bg-background">
|
||||
<AppMenu onMenuClick={handleMenuClick} />
|
||||
<AppMenu onMenuClick={handleMenuClick}/>
|
||||
<DialogManager
|
||||
showAddApi={dialogState.showAddApi}
|
||||
showAddCollection={dialogState.showAddCollection}
|
||||
@@ -144,10 +149,11 @@ const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
showUserEdit={dialogState.showUserEdit}
|
||||
selectedItem={dialogState.selectedItem}
|
||||
showPasswordChange={dialogState.showPasswordChange}
|
||||
showServerEdit={dialogState.showServerEdit}
|
||||
onDialogChange={handleDialogChange}
|
||||
/>
|
||||
<div className="flex-1 mt-14">
|
||||
<CurrentScreenComponent onMenuClick={handleMenuClick} />
|
||||
<CurrentScreenComponent onMenuClick={handleMenuClick}/>
|
||||
</div>
|
||||
</div>
|
||||
</LoadTestProvider>
|
||||
|
||||
Reference in New Issue
Block a user