Skip to content

Commit 9126a1a

Browse files
Merge pull request #88 from containerum/develop
Develop
2 parents 2a69e7d + 6e0c9f6 commit 9126a1a

File tree

15 files changed

+507
-17
lines changed

15 files changed

+507
-17
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
"react-google-recaptcha": "^0.9.9",
295295
"react-helmet": "^5.2.0",
296296
"react-hot-loader": "4.0.0-beta.18",
297+
"react-json-pretty": "^1.7.9",
297298
"react-markdown": "^3.3.0",
298299
"react-modal": "^3.1.12",
299300
"react-redux": "^5.0.6",
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* @flow */
2+
3+
import { push } from 'react-router-redux';
4+
import cookie from 'react-cookies';
5+
6+
import type { Dispatch, GetState, ThunkAction } from '../../types';
7+
import {
8+
GET_STATUS_REQUESTING,
9+
GET_STATUS_SUCCESS,
10+
GET_STATUS_FAILURE
11+
} from '../../constants/statusConstants/getStatus';
12+
import { webApi, routerLinks } from '../../config';
13+
14+
const getStatusRequest = () => ({
15+
type: GET_STATUS_REQUESTING,
16+
isFetching: true
17+
});
18+
19+
const getStatusSuccess = data => ({
20+
type: GET_STATUS_SUCCESS,
21+
isFetching: false,
22+
data
23+
});
24+
25+
const getStatusFailure = err => ({
26+
type: GET_STATUS_FAILURE,
27+
isFetching: false,
28+
err
29+
});
30+
31+
const getStatusInvalidToken = () => ({
32+
type: 'GET_INVALID_TOKEN'
33+
});
34+
35+
export const fetchGetStatus = (
36+
axios: any,
37+
URL: string = webApi
38+
): ThunkAction => async (dispatch: Dispatch) => {
39+
const browser = cookie.load('browser');
40+
const accessToken = cookie.load('accessToken');
41+
42+
dispatch(getStatusRequest());
43+
44+
const response = await axios.get(`${URL}/status`, {
45+
headers: {
46+
'User-Client': browser,
47+
'User-Token': accessToken
48+
},
49+
validateStatus: status => status >= 200 && status <= 505
50+
});
51+
52+
const { status, data } = response;
53+
switch (status) {
54+
case 200: {
55+
dispatch(getStatusSuccess(data));
56+
break;
57+
}
58+
case 400: {
59+
if (data.message === 'invalid token received') {
60+
dispatch(getStatusInvalidToken());
61+
} else if (data.message === 'invalid request body format') {
62+
dispatch(push(routerLinks.login));
63+
} else dispatch(getStatusFailure(data.message));
64+
break;
65+
}
66+
default: {
67+
dispatch(getStatusFailure(data.message));
68+
}
69+
}
70+
};
71+
72+
export const fetchGetStatusIfNeeded = (): ThunkAction => (
73+
dispatch: Dispatch,
74+
getState: GetState,
75+
axios: any
76+
) => dispatch(fetchGetStatus(axios));

src/components/ProfileSidebar/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,31 @@ const ProfileSidebar = ({ type }: Props) => (
114114
Settings
115115
</div>
116116
<Scrollspy
117-
items={['ips', 'storages']}
117+
items={['status', 'ips', 'storages']}
118118
style={{
119119
padding: '20px 0 0 20px'
120120
}}
121121
currentClassName={accountStyles.accountMenuNavActive}
122122
>
123+
<li className={`${accountStyles.navItem} nav-item`}>
124+
{type === 'settings' ? (
125+
<div
126+
className={`${accountStyles.navLink} nav-link`}
127+
onClick={() => scrollById('status')}
128+
onKeyPress={() => scrollById('status')}
129+
role="presentation"
130+
>
131+
Status
132+
</div>
133+
) : (
134+
<HashLink
135+
to={`${routerLinks.settings}#status`}
136+
className={`${accountStyles.navLink} nav-link`}
137+
>
138+
Status
139+
</HashLink>
140+
)}
141+
</li>
123142
<li className={`${accountStyles.navItem} nav-item`}>
124143
{type === 'settings' ? (
125144
<div

src/components/SettingsViewList/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const containerClassName = globalClass(
2525

2626
const SettingsViewList = ({ getDomainsReducer, handleDeleteIP }: Props) => (
2727
<div className={globalStyles.blockItem} id="settings">
28-
<div className={globalStyles.blockItemTitle}>Settings</div>
2928
<div className="row">
3029
<div className="col-md-10">
3130
<div className={globalStyles.textLight} style={{ fontSize: 20 }}>
@@ -96,7 +95,7 @@ const SettingsViewList = ({ getDomainsReducer, handleDeleteIP }: Props) => (
9695
>
9796
<button
9897
onClick={() =>
99-
handleDeleteIP(domain._id, domain.ip.join())
98+
handleDeleteIP(domain.ip[0], domain.ip.join())
10099
}
101100
className={`dropdown-item text-danger ${
102101
globalStyles.dropdownItem

src/components/SolutionsList/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ const SolutionsList = ({
4848
{data.map(solution => {
4949
const { name, url, limits } = solution;
5050
const { cpu, ram } = limits;
51-
const imageHref = `${url}/master/${url.substring(
52-
url.lastIndexOf('/') + 1
53-
)}.png`.replace('github.com', 'raw.githubusercontent.com');
51+
const imageHref = `${url}/master/${name}.png`.replace(
52+
'github.com',
53+
'raw.githubusercontent.com'
54+
);
5455
return (
5556
<div
5657
className="col-md-4"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const GET_STATUS_INVALID = 'GET_STATUS_INVALID';
2+
export const GET_STATUS_REQUESTING = 'GET_STATUS_REQUESTING';
3+
export const GET_STATUS_SUCCESS = 'GET_STATUS_SUCCESS';
4+
export const GET_STATUS_FAILURE = 'GET_STATUS_FAILURE';
3 Bytes
Binary file not shown.

src/containers/Pod/index.js

3 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)