Skip to content

Commit 090b3fe

Browse files
committed
removed unused files, modified rightcontainer logic
1 parent 9ed0e78 commit 090b3fe

File tree

5 files changed

+98
-128
lines changed

5 files changed

+98
-128
lines changed

server/models/reactypeModels.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ const userSchema = new Schema({
2222
username: { type: String, required: true, unique: true },
2323
email: { type: String, required: false, unique: true },
2424
password: { type: String, required: true },
25-
projects: { type: Array, default: [] }
25+
projects: [
26+
{
27+
name: String,
28+
project: { type: Object }
29+
}
30+
]
2631
});
2732

2833
// salt will go through 10 rounds of hashing

server/models/sessionModel.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

server/models/userModel.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/components/login/SignIn.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ const useStyles = makeStyles(theme => ({
5353
marginTop: theme.spacing(1)
5454
},
5555
submit: {
56-
margin: theme.spacing(3, 0, 2)
56+
margin: theme.spacing(3, 0, 2),
57+
width: '240px',
58+
height: '60px'
5759
}
5860
}));
5961

@@ -141,9 +143,11 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
141143
>
142144
Sign In
143145
</Button>
146+
144147
<a href="https://localhost:8080/github">
145148
<img src="/images/githublogin.png" />
146149
</a>
150+
<br></br>
147151
<Grid container>
148152
<Grid item xs>
149153
<Link href="#" variant="body2">

src/containers/RightContainer.tsx

Lines changed: 87 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { Component } from 'react';
1+
import React, { Component, useState } from 'react';
22
import { connect } from 'react-redux';
33
import { withStyles, Theme } from '@material-ui/core/styles';
44
import HtmlAttr from '../components/bottom/HtmlAttr';
55
import { PropsInt, ApplicationStateInt } from '../interfaces/Interfaces';
6-
import Button from '@material-ui/core/Button';
6+
import { Button, TextField } from '@material-ui/core';
77
import { Link as RouteLink, withRouter } from 'react-router-dom';
88

99
// const mapDispatchToProps = (dispatch: any) => ({
@@ -33,95 +33,101 @@ interface BottomTabsPropsInt extends PropsInt {
3333
codeReadOnly: boolean;
3434
}
3535

36-
class RightContainer extends Component<BottomTabsPropsInt> {
37-
constructor(props: BottomTabsPropsInt) {
38-
super(props);
39-
}
36+
function saveProject(project: ApplicationStateInt, name: String) {
37+
console.log('Saving project to DB...');
38+
const body = JSON.stringify({ name, project });
39+
console.log('Project name is', name);
40+
fetch('https://localhost:8080/saveProject', {
41+
method: 'POST',
42+
headers: {
43+
'content-type': 'application/json'
44+
},
45+
credentials: 'include',
46+
body
47+
})
48+
.then(res => res.json())
49+
.then(data => console.log('Saved project is', data))
50+
.catch(err => console.log(err));
51+
}
52+
53+
function getProjects() {
54+
console.log("Loading user's projects...");
55+
fetch('https://localhost:8080/getProjects', {
56+
credentials: 'include'
57+
})
58+
.then(res => res.json())
59+
.then(data => console.log("User's projects are", data))
60+
.catch(err => console.log(err));
61+
}
62+
const RightContainer = (props: BottomTabsPropsInt) => {
63+
const { classes, components, focusComponent, focusChild } = props;
64+
// looks through the children of currently focused component (based on left bar) and finds the number of child html elements it has
65+
const htmlAttribCount = focusComponent.childrenArray.filter(
66+
child => child.childType === 'HTML'
67+
).length;
4068

41-
saveProject(project: ApplicationStateInt) {
42-
console.log('Saving project to DB...');
43-
const body = JSON.stringify(project);
44-
fetch('https://localhost:8080/saveProject', {
45-
method: 'POST',
46-
headers: {
47-
'content-type': 'application/json'
48-
},
49-
credentials: 'include',
50-
body
51-
})
52-
.then(res => res.json())
53-
.then(data => console.log('Saved project is', data))
54-
.catch(err => console.log(err));
55-
}
69+
const [projectName, setProjectName] = useState('');
5670

57-
getProjects() {
58-
console.log("Loading user's projects...");
59-
fetch('https://localhost:8080/getProjects', {
60-
credentials: 'include'
61-
})
62-
.then(res => res.json())
63-
.then(data => console.log("User's projects are", data))
64-
.catch(err => console.log(err));
65-
}
71+
const handleChange = e => {
72+
let newVal = e.target.value;
73+
setProjectName(newVal);
74+
};
6675

67-
render(): JSX.Element {
68-
const { classes, components, focusComponent, focusChild } = this.props;
69-
// looks through the children of currently focused component (based on left bar) and finds the number of child html elements it has
70-
const htmlAttribCount = focusComponent.childrenArray.filter(
71-
child => child.childType === 'HTML'
72-
).length;
76+
return (
77+
<div
78+
className="column right"
79+
style={{
80+
minWidth: '400px',
81+
color: 'white',
82+
textAlign: 'center',
83+
display: 'flex',
84+
flexDirection: 'column'
85+
}}
86+
>
87+
{/* <h3>This is the right column everyone!</h3> */}
7388

74-
return (
75-
<div
76-
className="column right"
77-
style={{
78-
minWidth: '400px',
79-
color: 'white',
80-
textAlign: 'center',
81-
display: 'flex',
82-
flexDirection: 'column'
89+
<h4>
90+
{/* mimic the bottom tab label that shows how many html elements there are */}
91+
HTML Element Attributes {htmlAttribCount ? `(${htmlAttribCount})` : ''}
92+
</h4>
93+
{/* conditional rendering based on which component/element is currently focused */}
94+
{focusChild.childType === 'HTML' && <HtmlAttr />}
95+
{focusChild.childType !== 'HTML' && (
96+
<p>Please select an HTML element to view attributes</p>
97+
)}
98+
99+
<TextField
100+
required
101+
name="projectName"
102+
label="projectName"
103+
value={projectName}
104+
onChange={handleChange}
105+
/>
106+
107+
<Button
108+
variant="contained"
109+
color="secondary"
110+
onClick={() => {
111+
saveProject(props.currentWorkspace, projectName);
112+
setProjectName('');
83113
}}
84114
>
85-
{/* <h3>This is the right column everyone!</h3> */}
86-
87-
<h4>
88-
{/* mimic the bottom tab label that shows how many html elements there are */}
89-
HTML Element Attributes{' '}
90-
{htmlAttribCount ? `(${htmlAttribCount})` : ''}
91-
</h4>
92-
{/* conditional rendering based on which component/element is currently focused */}
93-
{focusChild.childType === 'HTML' && <HtmlAttr />}
94-
{focusChild.childType !== 'HTML' && (
95-
<p>Please select an HTML element to view attributes</p>
96-
)}
115+
Save Current Project
116+
</Button>
117+
<Button variant="contained" color="secondary" onClick={getProjects}>
118+
Get My Projects
119+
</Button>
120+
<RouteLink to={`/`} style={{ textDecoration: 'none', margin: '5px' }}>
97121
<Button
98122
variant="contained"
99123
color="secondary"
100-
onClick={() => {
101-
this.saveProject(this.props.currentWorkspace);
102-
}}
124+
style={{ alignSelf: 'bottom' }}
103125
>
104-
Save Current Project
126+
Sign Out
105127
</Button>
106-
<Button
107-
variant="contained"
108-
color="secondary"
109-
onClick={this.getProjects}
110-
>
111-
Get My Projects
112-
</Button>
113-
<RouteLink to={`/`} style={{ textDecoration: 'none', margin: '5px' }}>
114-
<Button
115-
variant="contained"
116-
color="secondary"
117-
style={{ alignSelf: 'bottom' }}
118-
>
119-
Sign Out
120-
</Button>
121-
</RouteLink>
122-
</div>
123-
);
124-
}
125-
}
128+
</RouteLink>
129+
</div>
130+
);
131+
};
126132

127133
export default withRouter(connect(mapStateToProps)(RightContainer));

0 commit comments

Comments
 (0)