web: Client: Added loading portal settings

This commit is contained in:
Alexey Safronov 2019-08-15 15:46:53 +03:00
parent c11896b962
commit e1234d900c
4 changed files with 54 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import setAuthorizationToken from '../services/setAuthorizationToken';
export const LOGIN_POST = 'LOGIN_POST';
export const SET_CURRENT_USER = 'SET_CURRENT_USER';
export const SET_MODULES = 'SET_MODULES';
export const SET_SETTINGS = 'SET_SETTINGS';
export const SET_IS_LOADED = 'SET_IS_LOADED';
export const LOGOUT = 'LOGOUT';
@ -21,6 +22,13 @@ export function setModules(modules) {
};
};
export function setSettings(settings) {
return {
type: SET_SETTINGS,
settings
};
};
export function setIsLoaded(isLoaded) {
return {
type: SET_IS_LOADED,
@ -38,6 +46,8 @@ export function setLogout() {
export function getUserInfo(dispatch) {
return api.getUser()
.then((res) => dispatch(setCurrentUser(res.data.response)))
.then(() => api.getSettings())
.then(res => dispatch(setSettings(res.data.response)))
.then(api.getModulesList)
.then((res) => dispatch(setModules(res.data.response)))
.then(() => dispatch(setIsLoaded(true)));

View File

@ -1,11 +1,30 @@
import { SET_CURRENT_USER, SET_MODULES, SET_IS_LOADED, LOGOUT } from './actions';
import { SET_CURRENT_USER, SET_MODULES, SET_SETTINGS, SET_IS_LOADED, LOGOUT } from './actions';
import isEmpty from 'lodash/isEmpty';
import config from "../../../package.json";
const initialState = {
isAuthenticated: false,
isLoaded: false,
user: {},
modules: []
modules: [],
settings: {
currentProductId: "",
culture: "en-US",
trustedDomains: [],
trustedDomainsType: 1,
timezone: "UTC",
utcOffset: "00:00:00",
utcHoursOffset: 0,
homepage: config.homepage,
datePattern: "M/d/yyyy",
datePatternJQ: "00/00/0000",
dateTimePattern: "dddd, MMMM d, yyyy h:mm:ss tt",
datepicker: {
datePattern: "mm/dd/yy",
dateTimePattern: "DD, mm dd, yy h:mm:ss tt",
timePattern: "h:mm tt"
}
}
}
const authReducer = (state = initialState, action) => {
@ -19,6 +38,10 @@ const authReducer = (state = initialState, action) => {
return Object.assign({}, state, {
modules: action.modules
});
case SET_SETTINGS:
return Object.assign({}, state, {
settings: { ...state.settings, ...action.settings }
});
case SET_IS_LOADED:
return Object.assign({}, state, {
isLoaded: action.isLoaded

View File

@ -27,4 +27,10 @@ export function getModulesList() {
export function getUser() {
return IS_FAKE ? fakeApi.getUser() : axios.get(`${API_URL}/people/@self.json`);
};
export function getSettings() {
return IS_FAKE
? fakeApi.getSettings()
: axios.get(`${API_URL}/settings.json`);
};

View File

@ -87,5 +87,18 @@ export function getUser() {
"isSSO": false
}
return fakeResponse(data);
};
export function getSettings() {
const data = {
"timezone": "Russian Standard Time;180;(UTC+03:00) Moscow, St. Petersburg;Russia TZ 2 Standard Time;Russia TZ 2 Daylight Time;[01:01:0001;12:31:2010;60;[0;02:00:00;3;5;0;];[0;03:00:00;10;5;0;];][01:01:2011;12:31:2011;60;[0;02:00:00;3;5;0;];[0;00:00:00;1;1;6;];][01:01:2012;12:31:2012;0;[1;00:00:00;1;1;];[1;00:00:00.001;1;1;];60;][01:01:2013;12:31:2013;0;[1;00:00:00;1;1;];[1;00:00:00.001;1;1;];60;][01:01:2014;12:31:2014;60;[0;00:00:00;1;1;3;];[0;02:00:00;10;5;0;];];",
"trustedDomains": [],
"trustedDomainsType": 1,
"culture": "ru-RU",
"utcOffset": "03:00:00",
"utcHoursOffset": 3
};
return fakeResponse(data);
};