diff --git a/src/@core/layouts/components/navbar/UserDropdown.js b/src/@core/layouts/components/navbar/UserDropdown.js index 2075d28a..4f7fe917 100644 --- a/src/@core/layouts/components/navbar/UserDropdown.js +++ b/src/@core/layouts/components/navbar/UserDropdown.js @@ -17,7 +17,7 @@ import { DropdownToggle, UncontrolledDropdown } from 'reactstrap'; -import * as Actions from '../../../../modules/account/login/actions'; +import * as Actions from '../../../../modules/account/auth/actions'; const UserDropdown = () => { // ** Store Vars diff --git a/src/components/account/login/AccountLogin.js b/src/components/account/login/AccountLogin.js index 056c809e..4271d8f1 100644 --- a/src/components/account/login/AccountLogin.js +++ b/src/components/account/login/AccountLogin.js @@ -12,7 +12,7 @@ import { Link } from 'react-router-dom'; import { useEffect, useState } from 'react'; import ErrorModal from '../../modal/ErrorModal'; import { useDispatch, useSelector } from 'react-redux'; -import * as Actions from '../../../modules/account/login/actions'; +import * as Actions from '../../../modules/account/auth/actions'; import '../../../assets/css/custom.css'; import kacLogo from '../../../assets/images/logo/kac_logo.svg'; diff --git a/src/components/account/mypage/AccountMypagePwForm.js b/src/components/account/mypage/AccountMypagePwForm.js index 21c95aea..70407ac6 100644 --- a/src/components/account/mypage/AccountMypagePwForm.js +++ b/src/components/account/mypage/AccountMypagePwForm.js @@ -17,7 +17,7 @@ import '../../../assets/css/custom.css'; import { pwUpdateAction, pwCheckAction -} from '../../../modules/account/login/actions'; +} from '../../../modules/account/auth/actions'; import { useHistory } from 'react-router-dom'; import ErrorModal from '../../modal/ErrorModal'; diff --git a/src/containers/account/mypage/AccountMypageContainer.js b/src/containers/account/mypage/AccountMypageContainer.js index 732deb89..3f70a487 100644 --- a/src/containers/account/mypage/AccountMypageContainer.js +++ b/src/containers/account/mypage/AccountMypageContainer.js @@ -22,7 +22,7 @@ import { userPageAction, userUpdateAction, userDeleteAction -} from '../../../modules/account/login/actions'; +} from '../../../modules/account/auth/actions'; import { MessageErrorModal } from '../../../components/message/MessageErrorModal'; import { MessageInfoModal } from '../../../components/message/MessageInfoModal'; diff --git a/src/containers/analysis/history/AnalysisHistoryContainer.js b/src/containers/analysis/history/AnalysisHistoryContainer.js index b09028b3..8e9cc4c5 100644 --- a/src/containers/analysis/history/AnalysisHistoryContainer.js +++ b/src/containers/analysis/history/AnalysisHistoryContainer.js @@ -5,7 +5,7 @@ import { Link } from 'react-router-dom'; import { AnalysisHistoryGrid } from '../../../components/analysis/history/AnalysisHistoryGrid'; import { AnalysisHistorySearch } from '../../../components/analysis/history/AnalysisHistorySearch'; import { CustomMainLayout } from '../../../components/layout/CustomMainLayout'; -import * as Actions from '../../../modules/analysis/history/actions/analysisHistoryAction'; +import * as Actions from '../../../modules/analysis/history'; import FlightPlanGroupGrid from '../../../components/basis/flight/plan/FlightPlanGroupGrid'; import { JOIN_LIST, GROUP_LIST } from '../../../modules/basis/group/actions'; import { diff --git a/src/containers/analysis/history/AnalysisHistoryDetailContainer.js b/src/containers/analysis/history/AnalysisHistoryDetailContainer.js index e1e890f1..89690887 100644 --- a/src/containers/analysis/history/AnalysisHistoryDetailContainer.js +++ b/src/containers/analysis/history/AnalysisHistoryDetailContainer.js @@ -5,7 +5,7 @@ import { useParams } from 'react-router-dom'; import { AnalysisHistoryDetailGrid } from '../../../components/analysis/history/AnalysisHistoryDetailGrid'; import { AnalysisHistoryDetailStatic } from '../../../components/analysis/history/AnalysisHistoryDetailStatic'; import { CustomDetailLayout } from '../../../components/layout/CustomDetailLayout'; -import * as Actions from '../../../modules/analysis/history/actions/analysisHistoryAction'; +import * as Actions from '../../../modules/analysis/history'; export const AnalysisHistoryDetailContainer = () => { // 비행이력 목록 diff --git a/src/containers/analysis/simulator/AnalysisSimulationContainer.js b/src/containers/analysis/simulator/AnalysisSimulationContainer.js index eea16048..f429e21d 100644 --- a/src/containers/analysis/simulator/AnalysisSimulationContainer.js +++ b/src/containers/analysis/simulator/AnalysisSimulationContainer.js @@ -8,8 +8,8 @@ import { AnalysisSimulationInfo } from '../../../components/analysis/simulation/ import { AnalysisSimulationMap } from '../../../components/analysis/simulation/AnalysisSimulationMap'; import { AnalysisSimulationPolyline } from '../../../components/analysis/simulation/AnalysisSimulationPolyline'; import { AnalysisSimulationMarker } from '../../../components/analysis/simulation/AnalysisSimulationMarker'; -import * as Actions from '../../../modules/analysis/simulation/actions/analysisSimulatorAction'; -import * as Action from '../../../modules/account/login/actions'; +import * as SmltActions from '../../../modules/analysis/simulation/actions'; +import * as AuthAction from '../../../modules/account/auth/actions'; let playCount = 0; let playCounts = 0; @@ -190,21 +190,24 @@ export const AnalysisSimulationContainer = props => { const handlerSearch = search1 => { setParams({ ...params, search1 }); dispatch( - Actions.list.request({ searchParams: { ...params, search1 }, page: 1 }) + SmltActions.list.request({ + searchParams: { ...params, search1 }, + page: 1 + }) ); }; const handlerDetailSearch = id => { - dispatch(Actions.detail.request(id)); + dispatch(SmltActions.detail.request(id)); }; const handlerLogSearch = id => { - dispatch(Actions.log.request(id)); + dispatch(SmltActions.log.request(id)); }; // const handlerStcsSearch = id => { - dispatch(Actions.stcs.request(id)); + dispatch(SmltActions.stcs.request(id)); }; // 검색 @@ -236,7 +239,7 @@ export const AnalysisSimulationContainer = props => { // 로그아웃 const handlerLogout = () => { - dispatch(Action.logout.request()); + dispatch(AuthAction.logout.request()); }; // 비행 시물레이션 데이터 닫기 @@ -247,7 +250,7 @@ export const AnalysisSimulationContainer = props => { // 비행 시물레이션 데이터 호출 const handlerPageList = useCallback(() => { dispatch( - Actions.list.request({ searchParams: { ...params }, page: page + 1 }) + SmltActions.list.request({ searchParams: { ...params }, page: page + 1 }) ); }, [params, list, page]); diff --git a/src/modules/account/login/actions/index.ts b/src/modules/account/auth/actions/index.ts similarity index 100% rename from src/modules/account/login/actions/index.ts rename to src/modules/account/auth/actions/index.ts diff --git a/src/modules/account/login/apis/index.ts b/src/modules/account/auth/apis/index.ts similarity index 100% rename from src/modules/account/login/apis/index.ts rename to src/modules/account/auth/apis/index.ts diff --git a/src/modules/account/login/index.ts b/src/modules/account/auth/index.ts similarity index 100% rename from src/modules/account/login/index.ts rename to src/modules/account/auth/index.ts diff --git a/src/modules/account/login/models/index.ts b/src/modules/account/auth/models/index.ts similarity index 100% rename from src/modules/account/login/models/index.ts rename to src/modules/account/auth/models/index.ts diff --git a/src/modules/account/login/reducers/index.ts b/src/modules/account/auth/reducers/index.ts similarity index 100% rename from src/modules/account/login/reducers/index.ts rename to src/modules/account/auth/reducers/index.ts diff --git a/src/modules/account/login/sagas/index.ts b/src/modules/account/auth/sagas/index.ts similarity index 100% rename from src/modules/account/login/sagas/index.ts rename to src/modules/account/auth/sagas/index.ts diff --git a/src/modules/account/login/service/cookie.ts b/src/modules/account/auth/service/cookie.ts similarity index 100% rename from src/modules/account/login/service/cookie.ts rename to src/modules/account/auth/service/cookie.ts diff --git a/src/modules/account/login/service/jwtTokenUtil.ts b/src/modules/account/auth/service/jwtTokenUtil.ts similarity index 100% rename from src/modules/account/login/service/jwtTokenUtil.ts rename to src/modules/account/auth/service/jwtTokenUtil.ts diff --git a/src/modules/analysis/history/actions/analysisHistoryAction.ts b/src/modules/analysis/history/actions/index.ts similarity index 89% rename from src/modules/analysis/history/actions/analysisHistoryAction.ts rename to src/modules/analysis/history/actions/index.ts index 144a9b7b..655513ea 100644 --- a/src/modules/analysis/history/actions/analysisHistoryAction.ts +++ b/src/modules/analysis/history/actions/index.ts @@ -4,21 +4,25 @@ import { AnalysisHistoryData, AnalysisHistoryLogData, AnalysisHistoryState -} from '../models/analysisHitoryModel'; +} from '../models'; +// 비행 이력 현황 목록 const LIST_REQUEST = 'anls/hstry/LIST_REQUEST'; const LIST_SUCCESS = 'anls/hstry/LIST_SUCCESS'; const LIST_FAILURE = 'anls/hstry/LIST_FAILURE'; +// 비행 이력 로그 const LOG_REQUEST = 'anls/hstry/LOG_REQUEST'; const LOG_SUCCESS = 'anls/hstry/LOG_SUCCESS'; const LOG_FAILURE = 'anls/hstry/LOG_FAILURE'; +// 비행 이력 상세 const DETAIL_REQUEST = 'anls/hstry/DETAIL_REQUEST'; const DETAIL_SUCCESS = 'anls/hstry/DETAIL_SUCCESS'; const DETAIL_FAILURE = 'anls/hstry/DETAIL_FAILURE'; -const DISPATCH_SEARCH = 'amls/hstry/DISPATCH_SEARCH'; +// 검색 +const DISPATCH_SEARCH = 'anls/hstry/DISPATCH_SEARCH'; const LIST_INIT = 'anls/hstry/LIST_INIT'; diff --git a/src/modules/analysis/history/apis/annalysisHistoryApi.ts b/src/modules/analysis/history/apis/index.ts similarity index 59% rename from src/modules/analysis/history/apis/annalysisHistoryApi.ts rename to src/modules/analysis/history/apis/index.ts index c315b341..721b1a18 100644 --- a/src/modules/analysis/history/apis/annalysisHistoryApi.ts +++ b/src/modules/analysis/history/apis/index.ts @@ -1,8 +1,5 @@ import axios from '../../../utils/customAxiosUtil'; - import qs from 'qs'; -import { AnalysisHistoryState } from '../models/analysisHitoryModel'; -// import { ReponseControlGpHistory } from '../models/controlGpModel'; export const analysisHistory = { list: async (data: string, page: number) => { @@ -20,14 +17,4 @@ export const analysisHistory = { log: async (id: string) => { return await axios.get(`/api/anls/hstry/log/${id}`); } - // getHistory: async (id: string) => { - // if (!id) { - - // return null; - // } - // const { data }: ReponseControlGpHistory = await axios.get( - // `api/ctr/cntrl/history/${id}` - // ); - // return data; - // } }; diff --git a/src/modules/analysis/history/index.ts b/src/modules/analysis/history/index.ts index a7117ff4..1405c5a7 100644 --- a/src/modules/analysis/history/index.ts +++ b/src/modules/analysis/history/index.ts @@ -1,4 +1,5 @@ -export * from './actions/analysisHistoryAction'; -export * from './models/analysisHitoryModel'; -export * from './reducers/analysisHitoryReducer'; -export * from './sagas/analysisHistorySaga'; +export * from './actions'; +export * from './apis'; +export * from './models'; +export * from './reducers'; +export * from './sagas'; diff --git a/src/modules/analysis/history/models/analysisHitoryModel.ts b/src/modules/analysis/history/models/index.ts similarity index 89% rename from src/modules/analysis/history/models/analysisHitoryModel.ts rename to src/modules/analysis/history/models/index.ts index 68dfe57d..e32f2717 100644 --- a/src/modules/analysis/history/models/analysisHitoryModel.ts +++ b/src/modules/analysis/history/models/index.ts @@ -15,12 +15,6 @@ export interface AnalysisHistoryDetailState { analysisHistoryDetail: AnalysisHistoryData | undefined; } -// export interface SearchAnalysisHistory { -// idntfNum: string; -// cntrlStDate: string; -// cntrlEndDate: string; -// } - export interface AnalysisHistoryData { cntrlId: string; idntfNum: string; @@ -69,7 +63,7 @@ export interface ReponseAnalysisHistoryData { count: number; } -export const initResponseAnalysisHistoryData = { +export const initResponseAnalysisHistoryData: AnalysisHistoryState = { data: undefined, detail: undefined, log: undefined, diff --git a/src/modules/analysis/history/reducers/analysisHitoryReducer.ts b/src/modules/analysis/history/reducers/index.ts similarity index 89% rename from src/modules/analysis/history/reducers/analysisHitoryReducer.ts rename to src/modules/analysis/history/reducers/index.ts index 2e23e383..54741334 100644 --- a/src/modules/analysis/history/reducers/analysisHitoryReducer.ts +++ b/src/modules/analysis/history/reducers/index.ts @@ -1,13 +1,11 @@ import { createReducer } from 'typesafe-actions'; import produce from 'immer'; -import * as Actions from '../actions/analysisHistoryAction'; +import * as Actions from '../actions'; import { initResponseAnalysisHistoryData, - AnalysisHistoryData, AnalysisHistoryState -} from '../models/analysisHitoryModel'; -import { controlGpSaga } from '../../../control/gp'; +} from '../models'; export const analysisHistoryReducer = createReducer< AnalysisHistoryState, diff --git a/src/modules/analysis/history/sagas/analysisHistorySaga.ts b/src/modules/analysis/history/sagas/index.ts similarity index 80% rename from src/modules/analysis/history/sagas/analysisHistorySaga.ts rename to src/modules/analysis/history/sagas/index.ts index 43a22577..764c7714 100644 --- a/src/modules/analysis/history/sagas/analysisHistorySaga.ts +++ b/src/modules/analysis/history/sagas/index.ts @@ -1,15 +1,8 @@ -import { - call, - put, - select, - takeEvery, - takeLatest -} from '@redux-saga/core/effects'; +import { call, put, takeEvery } from '@redux-saga/core/effects'; import { ActionType } from 'typesafe-actions'; -import * as Actions from '../actions/analysisHistoryAction'; -import * as Apis from '../apis/annalysisHistoryApi'; -import * as Models from '../models/analysisHitoryModel'; +import * as Actions from '../actions'; +import * as Apis from '../apis'; function* listSaga(action: ActionType) { try { @@ -28,7 +21,7 @@ function* listSaga(action: ActionType) { total }) ); - } catch (error) { + } catch (error: any) { yield put(Actions.list.failure(error)); } } @@ -44,7 +37,7 @@ function* detailSaga(action: ActionType) { detail: data }) ); - } catch (error) { + } catch (error: any) { yield put(Actions.detail.failure(error)); } } @@ -60,7 +53,7 @@ function* logSaga(action: ActionType) { log: data }) ); - } catch (error) { + } catch (error: any) { yield put(Actions.log.failure(error)); } } diff --git a/src/modules/analysis/simulation/actions/analysisSimulatorAction.ts b/src/modules/analysis/simulation/actions/analysisSimulatorAction.ts index ca8981e4..670aace5 100644 --- a/src/modules/analysis/simulation/actions/analysisSimulatorAction.ts +++ b/src/modules/analysis/simulation/actions/analysisSimulatorAction.ts @@ -5,27 +5,29 @@ import { AnalysisSimulatorLogData, AnalysisSimulatorState, AnalysisSimulatorStcsData -} from '../models/analysisSimulatorModel'; +} from '../models'; +// 시뮬레이션 목록 const LIST_REQUEST = 'anls/smlt/LIST_REQUEST'; const LIST_SUCCESS = 'anls/smlt/LIST_SUCCESS'; const LIST_FAILURE = 'anls/smlt/LIST_FAILURE'; +// 시뮬레이션 상세 로그 목록 const LOG_REQUEST = 'anls/smlt/LOG_REQUEST'; const LOG_SUCCESS = 'anls/smlt/LOG_SUCCESS'; const LOG_FAILURE = 'anls/smlt/LOG_FAILURE'; +// 시뮬레이션 상세 정보 const DETAIL_REQUEST = 'anls/smlt/DETAIL_REQUEST'; const DETAIL_SUCCESS = 'anls/smlt/DETAIL_SUCCESS'; const DETAIL_FAILURE = 'anls/smlt/DETAIL_FAILURE'; +// 시뮬레이션 분 단위 통계 정보 const STATICS_REQUEST = 'anls/smlt/STATICS_REQUEST'; const STATICS_SUCCESS = 'anls/smlt/STATICS_SUCCESS'; const STATICS_FAILURE = 'anls/smlt/STATICS_FAILURE'; -const DISPATCH_SEARCH = 'amls/smlt/DISPATCH_SEARCH'; - -const INIT_LIST = 'amls/smlt/INIT_LIST'; +const DISPATCH_SEARCH = 'anls/smlt/DISPATCH_SEARCH'; export const dispatchSearch = createAction(DISPATCH_SEARCH)<{ searchParams: string }>(); diff --git a/src/modules/analysis/simulation/actions/index.ts b/src/modules/analysis/simulation/actions/index.ts new file mode 100644 index 00000000..670aace5 --- /dev/null +++ b/src/modules/analysis/simulation/actions/index.ts @@ -0,0 +1,67 @@ +import { AxiosError } from 'axios'; +import { ActionType, createAction, createAsyncAction } from 'typesafe-actions'; +import { + AnalysisSimulatorData, + AnalysisSimulatorLogData, + AnalysisSimulatorState, + AnalysisSimulatorStcsData +} from '../models'; + +// 시뮬레이션 목록 +const LIST_REQUEST = 'anls/smlt/LIST_REQUEST'; +const LIST_SUCCESS = 'anls/smlt/LIST_SUCCESS'; +const LIST_FAILURE = 'anls/smlt/LIST_FAILURE'; + +// 시뮬레이션 상세 로그 목록 +const LOG_REQUEST = 'anls/smlt/LOG_REQUEST'; +const LOG_SUCCESS = 'anls/smlt/LOG_SUCCESS'; +const LOG_FAILURE = 'anls/smlt/LOG_FAILURE'; + +// 시뮬레이션 상세 정보 +const DETAIL_REQUEST = 'anls/smlt/DETAIL_REQUEST'; +const DETAIL_SUCCESS = 'anls/smlt/DETAIL_SUCCESS'; +const DETAIL_FAILURE = 'anls/smlt/DETAIL_FAILURE'; + +// 시뮬레이션 분 단위 통계 정보 +const STATICS_REQUEST = 'anls/smlt/STATICS_REQUEST'; +const STATICS_SUCCESS = 'anls/smlt/STATICS_SUCCESS'; +const STATICS_FAILURE = 'anls/smlt/STATICS_FAILURE'; + +const DISPATCH_SEARCH = 'anls/smlt/DISPATCH_SEARCH'; + +export const dispatchSearch = + createAction(DISPATCH_SEARCH)<{ searchParams: string }>(); + +export const list = createAsyncAction(LIST_REQUEST, LIST_SUCCESS, LIST_FAILURE)< + AnalysisSimulatorState, + { data: AnalysisSimulatorData[]; count: number; total: number; page: number }, + AxiosError +>(); + +export const log = createAsyncAction(LOG_REQUEST, LOG_SUCCESS, LOG_FAILURE)< + string, + { log: AnalysisSimulatorLogData[] }, + AxiosError +>(); + +export const detail = createAsyncAction( + DETAIL_REQUEST, + DETAIL_SUCCESS, + DETAIL_FAILURE +)(); + +export const stcs = createAsyncAction( + STATICS_REQUEST, + STATICS_SUCCESS, + STATICS_FAILURE +)(); + +const actions = { + list, + detail, + log, + stcs, + dispatchSearch +}; + +export type AnalysisSimulatorAction = ActionType; diff --git a/src/modules/analysis/simulation/apis/annalysisSimulatorApi.ts b/src/modules/analysis/simulation/apis/annalysisSimulatorApi.ts index ee9b2b32..1ab65d7a 100644 --- a/src/modules/analysis/simulation/apis/annalysisSimulatorApi.ts +++ b/src/modules/analysis/simulation/apis/annalysisSimulatorApi.ts @@ -1,8 +1,6 @@ import qs from 'qs'; import axios from '../../../utils/customAxiosUtil'; -// import { ReponseControlGpHistory } from '../models/controlGpModel'; - export const analysisSimulator = { //비행 현황 목록 list: async (data: string, page: number) => { diff --git a/src/modules/analysis/simulation/apis/index.ts b/src/modules/analysis/simulation/apis/index.ts new file mode 100644 index 00000000..1ab65d7a --- /dev/null +++ b/src/modules/analysis/simulation/apis/index.ts @@ -0,0 +1,28 @@ +import qs from 'qs'; +import axios from '../../../utils/customAxiosUtil'; + +export const analysisSimulator = { + //비행 현황 목록 + list: async (data: string, page: number) => { + const queryString = qs.stringify(data, { + addQueryPrefix: true, + arrayFormat: 'repeat' + }); + + return await axios.get(`/api/anls/smlt/list${queryString}&page=${page}`); + }, + // 비행 이력 데이터 조회 + logList: async (id: string) => { + return await axios.get(`/api/anls/smlt/hist/${id}`); + }, + + //비행 상세 데이터 조회 + detail: async (id: string) => { + return await axios.get(`/api/anls/smlt/detail/${id}`); + }, + + //비행 통계 데이터 조회 + stcsList: async (id: string) => { + return await axios.get(`/api/anls/smlt/stcs/${id}`); + } +}; diff --git a/src/modules/analysis/simulation/index.ts b/src/modules/analysis/simulation/index.ts index 1c1c9faa..1405c5a7 100644 --- a/src/modules/analysis/simulation/index.ts +++ b/src/modules/analysis/simulation/index.ts @@ -1,4 +1,5 @@ -export * from './actions/analysisSimulatorAction'; -export * from './models/analysisSimulatorModel'; -export * from './reducers/analysisSimulatorReducer'; -export * from './sagas/analysisSimulatorSaga'; +export * from './actions'; +export * from './apis'; +export * from './models'; +export * from './reducers'; +export * from './sagas'; diff --git a/src/modules/analysis/simulation/models/analysisSimulatorModel.ts b/src/modules/analysis/simulation/models/analysisSimulatorModel.ts index 295f499a..819e49e0 100644 --- a/src/modules/analysis/simulation/models/analysisSimulatorModel.ts +++ b/src/modules/analysis/simulation/models/analysisSimulatorModel.ts @@ -65,7 +65,7 @@ export interface AnalysisSimulatorStcsData { maxBttrLvl: number; } -export const initResponseAnalysisSimulatorData = { +export const initialState: AnalysisSimulatorState = { list: undefined, detail: undefined, count: 0, diff --git a/src/modules/analysis/simulation/models/index.ts b/src/modules/analysis/simulation/models/index.ts new file mode 100644 index 00000000..819e49e0 --- /dev/null +++ b/src/modules/analysis/simulation/models/index.ts @@ -0,0 +1,78 @@ +export interface AnalysisSimulatorState { + list: AnalysisSimulatorData[] | undefined; + detail: AnalysisSimulatorData | undefined; + count: number | 0; + log: AnalysisSimulatorLogData[] | undefined; + searchParams: string; + stcsList: AnalysisSimulatorStcsData[] | undefined; + stcsCount: number | 0; + page: number | 1; + total: number | 0; +} + +export interface AnalysisSimulatorData { + cntrlId: string; + idntfNum: string; + flghtStDt: Date; + flghtEndDt: Date; + cntrlStDt: Date; + cntrlEndDt: Date; + ttlTime: number; + ttlTimeType: string; + ttlDstnc: number; + ttlDstncType: string; + avrgSpeed: number; + avrgSpeedType: string; + bttrCnsmptn: number; + stArea: string; + endArea: string; + arcrftTypeCd: string; + prdctNum: string; + arcrftModelNm: string; + imageUrl: string; +} + +export interface AnalysisSimulatorLogData { + hstrySno: number; + cntrlId: string; + trmnlId: string; + mssgTypeCd: string; + statusCd: string; + lat: number; + lon: number; + speed: number; + speedType: string; + heading: number; + elev: number; + elevType: string; + mvDstnc: number; + bttrLvl: number; + bttrVltg: number; + trmnlRcvDt: string; + srvrRcvDt: string; +} + +export interface AnalysisSimulatorStcsData { + dateCd: string; + timeCd: string; + avrgSpeed: number; + speedType: string; + avrgElev: number; + elevType: string; + avrgMvDstnc: number; + mvDstncType: string; + minBttrLvl: number; + maxBttrLvl: number; +} + +export const initialState: AnalysisSimulatorState = { + list: undefined, + detail: undefined, + count: 0, + log: undefined, + searchParams: '', + stcsList: undefined, + stcsCount: 0, + page: 1, + total: 0 +}; diff --git a/src/modules/analysis/simulation/reducers/analysisSimulatorReducer.ts b/src/modules/analysis/simulation/reducers/analysisSimulatorReducer.ts index d952cc61..827ea3bc 100644 --- a/src/modules/analysis/simulation/reducers/analysisSimulatorReducer.ts +++ b/src/modules/analysis/simulation/reducers/analysisSimulatorReducer.ts @@ -1,29 +1,18 @@ import produce from 'immer'; import { createReducer } from 'typesafe-actions'; -import * as Actions from '../actions/analysisSimulatorAction'; -import { - AnalysisSimulatorState, - initResponseAnalysisSimulatorData -} from '../models/analysisSimulatorModel'; +import * as Actions from '../actions'; +import { AnalysisSimulatorState, initialState } from '../models'; export const analysisSimulatorReducer = createReducer< AnalysisSimulatorState, Actions.AnalysisSimulatorAction ->(initResponseAnalysisSimulatorData) +>(initialState) .handleAction(Actions.dispatchSearch, (state, action) => produce(state, draft => { const { searchParams } = action.payload; draft.searchParams = searchParams; }) ) - // .handleAction(Actions.list.request, (state, action) => - // produce(state, draft => { - // const { searchParams, page } = action.payload; - - // draft.searchParams = searchParams; - // draft.page = page; - // }) - // ) .handleAction(Actions.list.success, (state, action) => produce(state, draft => { const { data, count, total, page } = action.payload; diff --git a/src/modules/analysis/simulation/reducers/index.ts b/src/modules/analysis/simulation/reducers/index.ts new file mode 100644 index 00000000..827ea3bc --- /dev/null +++ b/src/modules/analysis/simulation/reducers/index.ts @@ -0,0 +1,59 @@ +import produce from 'immer'; +import { createReducer } from 'typesafe-actions'; +import * as Actions from '../actions'; +import { AnalysisSimulatorState, initialState } from '../models'; + +export const analysisSimulatorReducer = createReducer< + AnalysisSimulatorState, + Actions.AnalysisSimulatorAction +>(initialState) + .handleAction(Actions.dispatchSearch, (state, action) => + produce(state, draft => { + const { searchParams } = action.payload; + draft.searchParams = searchParams; + }) + ) + .handleAction(Actions.list.success, (state, action) => + produce(state, draft => { + const { data, count, total, page } = action.payload; + if (!state.list) { + draft.list = data; + } else { + if (page === 1) { + draft.list = data; + draft.page = page; + return; + } + draft.list = state.list?.concat(data); + } + + draft.page = page; + draft.count = count; + draft.total = total; + }) + ) + .handleAction(Actions.detail.success, (state, action) => + produce(state, draft => { + const { data } = action.payload; + draft.detail = data; + }) + ) + .handleAction(Actions.stcs.success, (state, action) => + produce(state, draft => { + const { data, count } = action.payload; + draft.stcsList = data; + draft.stcsCount = count; + }) + ) + + .handleAction(Actions.log.success, (state, action) => + produce(state, draft => { + const { log } = action.payload; + const data = log.sort((p: any, n: any): any => { + const a = p.srvrRcvDt.replace(/[^0-9\.]+/g, ''); + const b = n.srvrRcvDt.replace(/[^0-9\.]+/g, ''); + return a - b; + }); + draft.log = log; + }) + ); diff --git a/src/modules/analysis/simulation/sagas/analysisSimulatorSaga.ts b/src/modules/analysis/simulation/sagas/analysisSimulatorSaga.ts index 29e0c81e..2f0530fc 100644 --- a/src/modules/analysis/simulation/sagas/analysisSimulatorSaga.ts +++ b/src/modules/analysis/simulation/sagas/analysisSimulatorSaga.ts @@ -1,7 +1,7 @@ import { call, put, takeEvery } from '@redux-saga/core/effects'; import { ActionType } from 'typesafe-actions'; -import * as Actions from '../actions/analysisSimulatorAction'; -import * as Apis from '../apis/annalysisSimulatorApi'; +import * as Actions from '../actions'; +import * as Apis from '../apis'; function* listSaga(action: ActionType) { try { @@ -20,7 +20,7 @@ function* listSaga(action: ActionType) { page: res.data.page }) ); - } catch (error) { + } catch (error: any) { yield put(Actions.list.failure(error)); } } @@ -36,7 +36,7 @@ function* detailSaga(action: ActionType) { data: data }) ); - } catch (error) { + } catch (error: any) { yield put(Actions.detail.failure(error)); } } @@ -53,7 +53,7 @@ function* stcsSaga(action: ActionType) { count: count }) ); - } catch (error) { + } catch (error: any) { yield put(Actions.detail.failure(error)); } } @@ -69,7 +69,7 @@ function* logSaga(action: ActionType) { log: data }) ); - } catch (error) { + } catch (error: any) { yield put(Actions.log.failure(error)); } } diff --git a/src/modules/analysis/simulation/sagas/index.ts b/src/modules/analysis/simulation/sagas/index.ts new file mode 100644 index 00000000..2f0530fc --- /dev/null +++ b/src/modules/analysis/simulation/sagas/index.ts @@ -0,0 +1,82 @@ +import { call, put, takeEvery } from '@redux-saga/core/effects'; +import { ActionType } from 'typesafe-actions'; +import * as Actions from '../actions'; +import * as Apis from '../apis'; + +function* listSaga(action: ActionType) { + try { + const { searchParams, page } = action.payload; + const res = yield call(Apis.analysisSimulator.list, searchParams, page); + const { + data: { items, total }, + count + } = res; + + yield put( + Actions.list.success({ + data: items, + count: count, + total, + page: res.data.page + }) + ); + } catch (error: any) { + yield put(Actions.list.failure(error)); + } +} + +function* detailSaga(action: ActionType) { + try { + const id = action.payload; + const res = yield call(Apis.analysisSimulator.detail, id); + // yield put(Actions.log.request(id)); + const { data } = res; + yield put( + Actions.detail.success({ + data: data + }) + ); + } catch (error: any) { + yield put(Actions.detail.failure(error)); + } +} + +function* stcsSaga(action: ActionType) { + try { + const id = action.payload; + const res = yield call(Apis.analysisSimulator.stcsList, id); + // yield put(Actions.log.request(id)); + const { data, count } = res; + yield put( + Actions.stcs.success({ + data: data, + count: count + }) + ); + } catch (error: any) { + yield put(Actions.detail.failure(error)); + } +} + +function* logSaga(action: ActionType) { + try { + const id = action.payload; + const res = yield call(Apis.analysisSimulator.logList, id); + const { data } = res; + + yield put( + Actions.log.success({ + log: data + }) + ); + } catch (error: any) { + yield put(Actions.log.failure(error)); + } +} + +export function* analysisSimulatorSaga() { + yield takeEvery(Actions.list.request, listSaga); + yield takeEvery(Actions.detail.request, detailSaga); + yield takeEvery(Actions.stcs.request, stcsSaga); + yield takeEvery(Actions.log.request, logSaga); +} diff --git a/src/modules/control/gp/sagas/controlGpSaga.ts b/src/modules/control/gp/sagas/controlGpSaga.ts index 1b148172..eee228fb 100644 --- a/src/modules/control/gp/sagas/controlGpSaga.ts +++ b/src/modules/control/gp/sagas/controlGpSaga.ts @@ -1,16 +1,13 @@ import { call, put, select, takeEvery } from '@redux-saga/core/effects'; import { ActionType } from 'typesafe-actions'; -import { LoginData } from '../../../account/login/models'; +import { LoginData } from '../../../account/auth/models'; import { cookieStorage, COOKIE_ACCESS_TOKEN -} from '../../../account/login/service/cookie'; +} from '../../../account/auth/service/cookie'; import * as Actions from '../actions/controlGpAction'; import { controlGpApi } from '../apis/controlGpApi'; import decode from 'jwt-decode'; -import { ControlGpData } from '../models/controlGpModel'; -import { detail } from '../../../analysis/history/actions/analysisHistoryAction'; -import { useSelector } from 'react-redux'; const token = cookieStorage.getCookie(COOKIE_ACCESS_TOKEN); diff --git a/src/modules/utils/customAxiosUtil.ts b/src/modules/utils/customAxiosUtil.ts index e76be9e5..53fbdab6 100644 --- a/src/modules/utils/customAxiosUtil.ts +++ b/src/modules/utils/customAxiosUtil.ts @@ -1,6 +1,6 @@ import axios from 'axios'; import { HOST } from '../../configs/constants'; -import { getAccessToken } from '../account/login/service/jwtTokenUtil'; +import { getAccessToken } from '../account/auth/service/jwtTokenUtil'; import { store } from './../../redux/storeConfig/store'; import { GLOBAL_LOADED, GLOBAL_LOADING } from '../../redux/reducers/loading'; diff --git a/src/redux/reducers/rootReducer.ts b/src/redux/reducers/rootReducer.ts index ee346041..731b015c 100644 --- a/src/redux/reducers/rootReducer.ts +++ b/src/redux/reducers/rootReducer.ts @@ -13,7 +13,7 @@ import { authSaga, authReducer, mypageReducer -} from '../../modules/account/login'; +} from '../../modules/account/auth'; import { accountSaga, accountReducer } from '../../modules/account/register'; import { analysisHistorySaga, diff --git a/src/router/Router.js b/src/router/Router.js index ac2d1456..096372e0 100644 --- a/src/router/Router.js +++ b/src/router/Router.js @@ -13,7 +13,7 @@ import { Route, Switch } from 'react-router-dom'; -import * as Actions from '../modules/account/login/actions'; +import * as Actions from '../modules/account/auth/actions'; import { Routes } from './routes'; import { useCallback } from 'react'; diff --git a/src/views/control/main/ControlMain.js b/src/views/control/main/ControlMain.js index 5a85439c..5f56dee5 100644 --- a/src/views/control/main/ControlMain.js +++ b/src/views/control/main/ControlMain.js @@ -17,7 +17,7 @@ import { Card } from 'reactstrap'; import ControlSetting from '../setting/ControlSetting'; import WebsocketClient from '../../../components/websocket/WebsocketClient'; import { controlweatherAction } from '../../../modules/control/gp/actions/controlGpAction'; -import * as Actions from '../../../modules/account/login/actions'; +import * as Actions from '../../../modules/account/auth/actions'; import { objectUnClickAction } from '../../../modules/control/map/actions/controlMapActions'; import '../../../assets/css/custom.css'; import { ReactComponent as DroneMenuIcon } from '../../../assets/images/drone_menu_icon.svg';