loadActiveSession

master
Tudor Stanciu 2020-05-15 01:15:40 +03:00
parent 6a7f600fd3
commit e24b88eda4
5 changed files with 32 additions and 6 deletions

View File

@ -23,3 +23,14 @@ export function loadSystemVersion() {
} }
}; };
} }
export function loadActiveSession() {
return async function (dispatch) {
try {
const data = await dispatch(sendHttpRequest(api.getActiveSession()));
dispatch({ type: types.LOAD_ACTIVE_SESSION_SUCCESS, payload: data });
} catch (error) {
throw error;
}
};
}

View File

@ -1,2 +1,3 @@
export const LOAD_SYSTEM_DATETIME_SUCCESS = "LOAD_SYSTEM_DATETIME_SUCCESS"; export const LOAD_SYSTEM_DATETIME_SUCCESS = "LOAD_SYSTEM_DATETIME_SUCCESS";
export const LOAD_SYSTEM_VERSION_SUCCESS = "LOAD_SYSTEM_VERSION_SUCCESS"; export const LOAD_SYSTEM_VERSION_SUCCESS = "LOAD_SYSTEM_VERSION_SUCCESS";
export const LOAD_ACTIVE_SESSION_SUCCESS = "LOAD_ACTIVE_SESSION_SUCCESS";

View File

@ -1,10 +1,12 @@
import { get } from "../../api/axiosApi"; import { get } from "../../api/axiosApi";
const baseUrl = process.env.REVERSE_PROXY_API_URL + "/system"; const baseUrl = process.env.REVERSE_PROXY_API_URL;
const getSystemDateTime = () => get(`${baseUrl}/datetime`); const getSystemDateTime = () => get(`${baseUrl}/system/datetime`);
const getSystemVersion = () => get(`${baseUrl}/version`); const getSystemVersion = () => get(`${baseUrl}/system/version`);
const getActiveSession = () => get(`${baseUrl}/server/active-session`);
export default { export default {
getSystemDateTime, getSystemDateTime,
getSystemVersion getSystemVersion,
getActiveSession
}; };

View File

@ -2,7 +2,11 @@ import React, { useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { bindActionCreators } from "redux"; import { bindActionCreators } from "redux";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { loadSystemDateTime, loadSystemVersion } from "../actionCreators"; import {
loadSystemDateTime,
loadSystemVersion,
loadActiveSession
} from "../actionCreators";
import ServerComponent from "./ServerComponent"; import ServerComponent from "./ServerComponent";
import ActiveSessionComponent from "./ActiveSessionComponent"; import ActiveSessionComponent from "./ActiveSessionComponent";
@ -10,6 +14,7 @@ const ServerContainer = ({ actions }) => {
useEffect(() => { useEffect(() => {
actions.loadSystemDateTime(); actions.loadSystemDateTime();
actions.loadSystemVersion(); actions.loadSystemVersion();
actions.loadActiveSession();
}, []); }, []);
return ( return (
@ -36,7 +41,7 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {
return { return {
actions: bindActionCreators( actions: bindActionCreators(
{ loadSystemDateTime, loadSystemVersion }, { loadSystemDateTime, loadSystemVersion, loadActiveSession },
dispatch dispatch
) )
}; };

View File

@ -14,6 +14,13 @@ export default function serverReducer(state = initialState.server, action) {
...state, ...state,
...action.payload ...action.payload
}; };
case types.LOAD_ACTIVE_SESSION_SUCCESS:
return {
...state,
activeSession: action.payload
};
default: default:
return state; return state;
} }