1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { createSlice, PayloadAction } from '@reduxjs/toolkit'; 17import {ILog} from '../../models/logs'; 18 19interface IState { 20 compileOut: ILog[] 21 compileErr: ILog[] 22 runOut: ILog[] 23 runErr: ILog[] 24 disasmOut: ILog[] 25 disasmErr: ILog[] 26 out: ILog[] 27 err: ILog[] 28} 29 30const initialState: IState = { 31 compileOut: [], 32 compileErr: [], 33 runOut: [], 34 runErr: [], 35 disasmOut: [], 36 disasmErr: [], 37 out: [], 38 err: [] 39}; 40 41const logsSlice = createSlice({ 42 name: 'logsState', 43 initialState, 44 reducers: { 45 setCompileOutLogs(state, action: PayloadAction<ILog[]>) { 46 state.compileOut = action.payload; 47 }, 48 setCompileErrLogs(state, action: PayloadAction<ILog[]>) { 49 state.compileErr = action.payload; 50 }, 51 setRunOutLogs(state, action: PayloadAction<ILog[]>) { 52 state.runOut = action.payload; 53 }, 54 setRunErrLogs(state, action: PayloadAction<ILog[]>) { 55 state.runErr = action.payload; 56 }, 57 setDisasmOutLogs(state, action: PayloadAction<ILog[]>) { 58 state.disasmOut = action.payload; 59 }, 60 setDisasmErrLogs(state, action: PayloadAction<ILog[]>) { 61 state.disasmErr = action.payload; 62 }, 63 setOutLogs(state, action: PayloadAction<ILog[]>) { 64 state.out = action.payload; 65 }, 66 setErrLogs(state, action: PayloadAction<ILog[]>) { 67 state.err = action.payload; 68 }, 69 } 70}); 71 72export const { 73 setCompileOutLogs, 74 setCompileErrLogs, 75 setRunOutLogs, 76 setRunErrLogs, 77 setDisasmOutLogs, 78 setDisasmErrLogs, 79 setOutLogs, 80 setErrLogs 81} = logsSlice.actions; 82 83export default logsSlice.reducer; 84