Skip to content

Commit 426d789

Browse files
committed
fixed admin panel, user panel, series online, info
1 parent 6460ea4 commit 426d789

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+902
-289
lines changed

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@
1717
"radium": "^0.19.6",
1818
"react": "^16.1.1",
1919
"react-bootstrap": "^0.31.5",
20+
"react-burger-menu": "^2.1.11",
2021
"react-cookies": "^0.1.0",
2122
"react-dom": "^16.1.1",
2223
"react-dropzone": "^4.2.3",
2324
"react-email-editor": "^0.5.0",
2425
"react-facebook-login": "^3.7.2",
2526
"react-images-upload": "^1.1.1",
2627
"react-infinite-scroller": "^1.1.1",
28+
"react-owl-carousel": "^2.2.0",
2729
"react-prism": "^4.3.1",
2830
"react-redux": "^5.0.6",
2931
"react-router": "^4.2.0",
3032
"react-router-dom": "^4.2.2",
3133
"react-scripts": "1.0.17",
34+
"react-toastify": "^3.2.1",
35+
"react-vk": "^1.0.2",
3236
"react-vk-login": "0.0.2",
3337
"react-xhr-uploader": "^0.4.4",
3438
"react-yandex-maps": "^2.1.4",

public/index.html

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
-->
1111
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
1212
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
13+
<!-- Latest compiled and minified CSS -->
14+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
15+
<!-- Optional theme -->
16+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css">
17+
1318
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
1419
<!--
1520
Notice the use of %PUBLIC_URL% in the tags above.

src/App.js

+9-143
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,17 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import { withStyles } from 'material-ui/styles';
4-
import Drawer from 'material-ui/Drawer';
5-
import AppBar from 'material-ui/AppBar';
6-
import Toolbar from 'material-ui/Toolbar';
7-
import List from 'material-ui/List';
8-
import Typography from 'material-ui/Typography';
9-
import IconButton from 'material-ui/IconButton';
10-
import Hidden from 'material-ui/Hidden';
11-
import Divider from 'material-ui/Divider';
12-
import MenuIcon from 'material-ui-icons/Menu';
13-
import * as cookie from "react-cookies";
14-
import {Link} from "react-router-dom";
15-
import {MenuItem, MenuList} from "material-ui";
1+
import React, { Component } from 'react';
2+
import { ToastContainer, toast } from 'react-toastify';
3+
import {ProgressBar} from "react-bootstrap";
164

17-
const drawerWidth = 240;
18-
19-
const styles = theme => ({
20-
root: {
21-
width: '100%',
22-
height: 430,
23-
marginTop: theme.spacing.unit * 3,
24-
zIndex: 1,
25-
overflow: 'hidden',
26-
},
27-
appFrame: {
28-
position: 'relative',
29-
display: 'flex',
30-
width: '100%',
31-
height: '100%',
32-
},
33-
appBar: {
34-
position: 'absolute',
35-
marginLeft: drawerWidth,
36-
[theme.breakpoints.up('md')]: {
37-
width: `calc(100% - ${drawerWidth}px)`,
38-
},
39-
},
40-
navIconHide: {
41-
[theme.breakpoints.up('md')]: {
42-
display: 'none',
43-
},
44-
},
45-
drawerHeader: theme.mixins.toolbar,
46-
drawerPaper: {
47-
width: 250,
48-
[theme.breakpoints.up('md')]: {
49-
width: drawerWidth,
50-
position: 'relative',
51-
height: '100%',
52-
},
53-
},
54-
content: {
55-
backgroundColor: theme.palette.background.default,
56-
width: '100%',
57-
padding: theme.spacing.unit * 3,
58-
height: 'calc(100% - 56px)',
59-
marginTop: 56,
60-
[theme.breakpoints.up('sm')]: {
61-
height: 'calc(100% - 64px)',
62-
marginTop: 64,
63-
},
64-
},
65-
});
66-
67-
class ResponsiveDrawer extends React.Component {
68-
state = {
69-
mobileOpen: false,
70-
};
71-
72-
handleDrawerToggle = () => {
73-
this.setState({ mobileOpen: !this.state.mobileOpen });
74-
};
75-
76-
render() {
77-
const { classes, theme } = this.props;
78-
79-
const drawer = (
80-
<div>
81-
<div className={classes.drawerHeader} />
82-
<MenuList className={classes.menu}>
83-
<MenuItem >
84-
Главная
85-
</MenuItem>
86-
<MenuItem>
87-
Новости
88-
</MenuItem>
89-
</MenuList>
90-
</div>
91-
);
5+
class App extends Component {
6+
notify = () => toast("Wow so easy !");
927

8+
render(){
939
return (
94-
<div className={classes.root}>
95-
<div className={classes.appFrame}>
96-
<AppBar className={classes.appBar}>
97-
<Toolbar>
98-
<IconButton
99-
color="contrast"
100-
aria-label="open drawer"
101-
onClick={this.handleDrawerToggle}
102-
className={classes.navIconHide}
103-
>
104-
<MenuIcon />
105-
</IconButton>
106-
<Typography type="title" color="inherit" noWrap>
107-
Responsive drawer
108-
</Typography>
109-
</Toolbar>
110-
</AppBar>
111-
<Hidden mdUp>
112-
<Drawer
113-
type="temporary"
114-
open={this.state.mobileOpen}
115-
classes={{
116-
paper: classes.drawerPaper,
117-
}}
118-
onRequestClose={this.handleDrawerToggle}
119-
ModalProps={{
120-
keepMounted: true, // Better open performance on mobile.
121-
}}
122-
>
123-
{drawer}
124-
</Drawer>
125-
</Hidden>
126-
<Hidden mdDown implementation="css">
127-
<Drawer
128-
type="permanent"
129-
open
130-
classes={{
131-
paper: classes.drawerPaper,
132-
}}
133-
>
134-
{drawer}
135-
</Drawer>
136-
</Hidden>
137-
<main className={classes.content}>
138-
<Typography noWrap>{'You think water moves fast? You should see ice.'}</Typography>
139-
</main>
140-
</div>
10+
<div>
11+
<ProgressBar active now={61} />
14112
</div>
14213
);
14314
}
14415
}
14516

146-
ResponsiveDrawer.propTypes = {
147-
classes: PropTypes.object.isRequired,
148-
theme: PropTypes.object.isRequired,
149-
};
150-
151-
export default withStyles(styles, { withTheme: true })(ResponsiveDrawer);
17+
export default App;

src/actions/action-types.js

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export const GET_FULL_SERIES_SUCCESS = 'GET_FULL_SERIES_SUCCESS';
2626
export const GET_MAP_LABEL_SUCCESS = 'GET_MAP_LABEL_SUCCESS';
2727

2828

29+
//USER
30+
31+
export const GET_USER_SUCCESS = 'GET_USER_SUCCESS';
32+
33+
2934
// ORGANIZATIONS
3035

3136
export const GET_ORGANIZATIONS_SUCCESS = 'GET_ORGANIZATIONS_SUCCESS';

src/actions/user-actions.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as types from './action-types';
2+
3+
export function getUserSuccess(user) {
4+
return {
5+
type: types.GET_USER_SUCCESS,
6+
user
7+
};
8+
}

src/api/series-api.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export function getSeason(num) {
2424
return response.data;
2525
});
2626
}
27+
export function getSeasonForUser(num, uid) {
28+
return axios.get(apiPrefix + ':' + serverPort + '/online/' + Date.now() + '?numOfSeason=' + num+'&uid=' + uid)
29+
.then(response => {
30+
store.dispatch(getSeriesSuccess(response.data));
31+
console.log('User: ' + JSON.stringify(response.data));
32+
return response.data;
33+
});
34+
}
2735

2836
export function getSeries(id) {
2937
return axios.get(apiPrefix + ':' + serverPort + '/online/' + Date.now() + '?id=' + id)
@@ -40,10 +48,25 @@ export function getSeriesForUser(id, uid) {
4048
return response.data;
4149
});
4250
}
51+
export function getAllSeriesForUser(uid) {
52+
return axios.get(apiPrefix + ':' + serverPort + '/online/' + Date.now() + '?uid=' + uid)
53+
.then(response => {
54+
store.dispatch(getSeriesSuccess(response.data));
55+
return response.data;
56+
});
57+
}
4358

44-
export function updateCurrentTime(id, uid, time) {
45-
return axios.get(apiPrefix + ':' + serverPort + '/online/' + Date.now() + '?id=' + id + "&uid=" + uid + "&time=" + time)
59+
export function updateCurrentTime(id, uid, time, fluid, duration) {
60+
return axios.get(apiPrefix + ':' + serverPort + '/online/' + Date.now() + '?id=' + id + "&uid=" + uid + "&time=" + time+ "&fluid=" + fluid+ "&duration=" + duration)
61+
.then(response => {
62+
console.log(response);
63+
return response.data;
64+
});
65+
}
66+
export function updateHaveSeen(id, uid) {
67+
return axios.get(apiPrefix + ':' + serverPort + '/online/' + Date.now() + '?id=' + id + "&uid=" + uid + "&haveSeen=" + true)
4668
.then(response => {
69+
console.log(response);
4770
return response.data;
4871
});
4972
}

src/api/user-api.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import store from "../store";
2+
import {apiPrefix, serverPort} from "../etc/config";
3+
import {getUserSuccess} from "../actions/user-actions";
4+
import axios from "axios/index";
5+
6+
7+
export function getUser() {
8+
return axios.get(apiPrefix + ':' + serverPort + '/user/' + Date.now(), {withCredentials: true})
9+
.then(response => {
10+
if(response.data!=="Permission denied"){
11+
store.dispatch(getUserSuccess(response.data));
12+
console.log(response.data);
13+
}else{
14+
console.log("Permission denied");
15+
}
16+
return response.data;
17+
});
18+
}

src/components/Admin/AdminPanel.js

+37-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@ import {Component} from "react";
22
import * as React from "react"
33
import axios from 'axios';
44
import {Button} from "material-ui";
5-
import {Link} from "react-router-dom";
5+
import {Link, Route} from "react-router-dom";
66
import {apiPrefix} from '../../etc/config.json';
77
import {serverPort} from '../../etc/config.json';
88
import * as cookie from "react-cookies";
9+
import AddNewsContainer from "./News/AddNewsContainer";
10+
import AdminNewsPanel from "./News/AdminNewsPanel";
11+
12+
13+
const RouteWithSubRoutes = (route) => (
14+
<Route path={route.path} render={props => (
15+
// pass the sub-routes down to keep nesting
16+
<route.component {...props} routes={route.routes}/>
17+
)}/>
18+
);
19+
920
export default class AdminPanel extends Component {
1021
state={
1122
show: false,
@@ -31,14 +42,33 @@ export default class AdminPanel extends Component {
3142

3243
}
3344
render () {
45+
let section;
46+
console.log(this.props.match);
47+
switch(this.props.match.params.section){
48+
case 'news':
49+
section=<AdminNewsPanel history={this.props.history}/>;
50+
break;
51+
}
52+
3453
console.log(this.state.show);
3554
return(
36-
<div>
37-
{this.state.show && <div >
38-
<Link to="/admin/news"><Button raised color="primary">Новости</Button></Link>
39-
<Link to="/admin/chars"><Button raised color="primary">Персонажи</Button></Link>
40-
<Link to="/admin/orgs"><Button raised color="primary">Организации</Button></Link>
41-
<Link to="/admin/online"><Button raised color="primary">Серии онлайн</Button></Link>
55+
<div style={{}}>
56+
{this.state.show && <div style={{display: 'flex'}} >
57+
<div style={{display: 'flex',flexDirection: 'column', marginRight: '15px', minWidth: '140px', marginTop: '10px', position: 'fixed'}}>
58+
<Link to="/admin/news"><Button raised color="primary" style={{minWidth: '140px'}}>Новости</Button></Link>
59+
<br/>
60+
<Link to="/admin/chars"><Button raised color="primary" style={{minWidth: '140px'}}>Персонажи</Button></Link>
61+
<br/>
62+
<Link to="/admin/orgs"><Button raised color="primary" style={{minWidth: '140px'}}>Организации</Button></Link>
63+
<br/>
64+
<Link to="/admin/online"><Button raised color="primary" style={{minWidth: '140px'}}>Серии онлайн</Button></Link>
65+
</div>
66+
<div style={{marginLeft: '160px'}}>
67+
{this.props.routes.map((route, i) => (
68+
<RouteWithSubRoutes key={i} {...route}/>
69+
))}
70+
71+
</div>
4272
</div> }
4373
</div>
4474
)

src/components/Admin/Characters/AdminCharsPanel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default class AdminCharsPanel extends Component {
77
render () {
88
return(
99
<div >
10-
<Button raised color="primary">Add chars</Button>
10+
<Link to={'/admin/chars/add'} ><Button raised color="primary">Добавить персонажа</Button></Link>
1111
<ListCharsForUpdateContainer/>
1212
</div>
1313
)

src/components/Admin/Characters/ListCharsForUpdateContainer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ListCharsForUpdateContainer extends Component {
2929

3030
render() {
3131
let key = this.state.items.length;
32-
this.state.items.push(<ShortChars link={'/admin/chars/update/'} charsList={this.props.charsList} key={key}/>);
32+
this.state.items.push(<ShortChars link={'/admin/updateChars/'} charsList={this.props.charsList} key={key}/>);
3333
return (
3434
<div>
3535
<InfiniteScroll

0 commit comments

Comments
 (0)