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_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";
const baseUrl = process.env.REVERSE_PROXY_API_URL + "/system";
const baseUrl = process.env.REVERSE_PROXY_API_URL;
const getSystemDateTime = () => get(`${baseUrl}/datetime`);
const getSystemVersion = () => get(`${baseUrl}/version`);
const getSystemDateTime = () => get(`${baseUrl}/system/datetime`);
const getSystemVersion = () => get(`${baseUrl}/system/version`);
const getActiveSession = () => get(`${baseUrl}/server/active-session`);
export default {
getSystemDateTime,
getSystemVersion
getSystemVersion,
getActiveSession
};

View File

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

View File

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