Skip to content

Commit 8ffd6e4

Browse files
committed
merge with most recent dev
2 parents 4880f2d + 2496eb0 commit 8ffd6e4

File tree

12 files changed

+312
-210
lines changed

12 files changed

+312
-210
lines changed

app/src/Dashboard/NavbarDash.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const sortMethods = ['RATING', 'DATE', 'USER'];
4646
// Drop down menu button for SORT PROJECTS
4747
const StyledMenu = withStyles({
4848
paper: {
49-
border: '1px solid #d3d4d5'
49+
border: '1px solid #d3d4d5',
5050
}
5151
})(props => (
5252
<Menu

app/src/components/main/Canvas.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ function Canvas(props): JSX.Element {
131131

132132
const canvasStyle = combineStyles(defaultCanvasStyle, currentComponent.style);
133133
const darkCombinedCanvasStyle = combineStyles(darkCanvasStyle, currentComponent.style);
134-
console.log('canvas comp', currentComponent)
135134
return (
136135
<div className={'componentContainer'} ref={drop} style={!isDarkMode ? canvasStyle : darkCombinedCanvasStyle} onClick={onClickHandler}>
137136
{renderChildren(currentComponent.children)}

app/src/components/right/DeleteProjects.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export default function ProjectsFolder() {
109109
color="primary"
110110
onClick={handleClickOpen}
111111
endIcon={<DeleteRoundedIcon />}
112+
sx={{fontSize: '9px'}}
112113
>
113114
Delete Project
114115
</Button>

app/src/components/right/OpenProjects.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export default function ProjectsFolder(props) {
9999
id="openProject"
100100
onClick={handleClickOpen}
101101
endIcon={<FolderOpenIcon />}
102+
sx={{fontSize: '9px'}}
102103
>
103104
Open Project
104105
</Button>

app/src/components/right/SaveProjectButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const dispatch = useDispatch();
6464
<Button
6565
color="primary"
6666
onClick={handleClickOpen}
67-
endIcon={<SaveOutlinedIcon />}
67+
endIcon={<SaveOutlinedIcon />} sx={{fontSize: '9px'}}
6868
>
6969
SAVE PROJECT AS
7070
</Button>

app/src/components/top/NavBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const NavBar = (props) => {
2121
onMouseOver={()=>setDropMenu(true)}>
2222
<path d="M7.068.727c.243-.97 1.62-.97 1.864 0l.071.286a.96.96 0 0 0 1.622.434l.205-.211c.695-.719 1.888-.03 1.613.931l-.08.284a.96.96 0 0 0 1.187 1.187l.283-.081c.96-.275 1.65.918.931 1.613l-.211.205a.96.96 0 0 0 .434 1.622l.286.071c.97.243.97 1.62 0 1.864l-.286.071a.96.96 0 0 0-.434 1.622l.211.205c.719.695.03 1.888-.931 1.613l-.284-.08a.96.96 0 0 0-1.187 1.187l.081.283c.275.96-.918 1.65-1.613.931l-.205-.211a.96.96 0 0 0-1.622.434l-.071.286c-.243.97-1.62.97-1.864 0l-.071-.286a.96.96 0 0 0-1.622-.434l-.205.211c-.695.719-1.888.03-1.613-.931l.08-.284a.96.96 0 0 0-1.186-1.187l-.284.081c-.96.275-1.65-.918-.931-1.613l.211-.205a.96.96 0 0 0-.434-1.622l-.286-.071c-.97-.243-.97-1.62 0-1.864l.286-.071a.96.96 0 0 0 .434-1.622l-.211-.205c-.719-.695-.03-1.888.931-1.613l.284.08a.96.96 0 0 0 1.187-1.186l-.081-.284c-.275-.96.918-1.65 1.613-.931l.205.211a.96.96 0 0 0 1.622-.434l.071-.286zM12.973 8.5H8.25l-2.834 3.779A4.998 4.998 0 0 0 12.973 8.5zm0-1a4.998 4.998 0 0 0-7.557-3.779l2.834 3.78h4.723zM5.048 3.967c-.03.021-.058.043-.087.065l.087-.065zm-.431.355A4.984 4.984 0 0 0 3.002 8c0 1.455.622 2.765 1.615 3.678L7.375 8 4.617 4.322zm.344 7.646.087.065-.087-.065z"/>
2323
</svg>
24-
{dropMenu && <NavbarDropDown></NavbarDropDown>}
24+
<NavbarDropDown dropMenu={dropMenu}></NavbarDropDown>
2525
</div>
2626
</nav>
2727
)

app/src/components/top/NavBarButtons.js

Lines changed: 222 additions & 153 deletions
Large diffs are not rendered by default.

app/src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ let previousState = store.getState();
6565
// sending info to backend whenever the redux store changes
6666
const handleStoreChange = debounce(() => {
6767
const newState = store.getState();
68+
if (store.getState().roomCodeSlice.roomCode!==''){
69+
socket.emit('room-code', store.getState().roomCodeSlice.roomCode)
70+
}
6871
if (newState !== previousState){
6972
console.log('before sending to server: ', newState)
70-
socket.emit('custom-event', 'sent from front-end', JSON.stringify(newState))
73+
socket.emit('custom-event', 'sent from front-end', JSON.stringify(newState), store.getState().roomCodeSlice.roomCode)
7174
previousState = newState;
7275
}
7376
}, 100);

app/src/public/styles/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ NAVBAR
566566
top: 45px;
567567
padding-top: 5px;
568568
padding-bottom: 5px;
569+
display: hidden;
570+
}
571+
572+
.hideNavDropDown{
573+
display: none;
569574
}
570575

571576
.navDropDown button{
@@ -580,6 +585,10 @@ NAVBAR
580585
align-items: center;
581586
}
582587

588+
.navDropDown p{
589+
margin: 3px 5%;
590+
}
591+
583592
.navDropDown button:hover{
584593
cursor: pointer;
585594
background-color: #007ab8

app/src/redux/reducers/rootReducer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import codePreviewReducer from './slice/codePreviewSlice';
66
import contextReducer from './slice/contextReducer';
77
import appStateReducer from './slice/appStateSlice.ts';
88
import styleReducer from './slice/styleSlice';
9+
import roomCodeReducer from './slice/roomCodeSlice'
910

1011
const rootReducer = combineReducers({
1112
// Add desired slices here
@@ -14,7 +15,7 @@ const rootReducer = combineReducers({
1415
contextSlice: contextReducer,
1516
appState: appStateReducer,
1617
styleSlice: styleReducer,
17-
18+
roomCodeSlice: roomCodeReducer,
1819
});
1920

2021
export default rootReducer;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// With redux toolkit you can combine all the actions, action types, and reducers into one 'slice'
2+
import { createSlice } from '@reduxjs/toolkit';
3+
// Sets initial state to false
4+
const initialState = {
5+
roomCode: ''
6+
};
7+
8+
// Creates new slice with the name darkMode, initial state, and reducer function which toggles dark mode state between true and false
9+
const roomCodeSlice = createSlice({
10+
name: 'roomCode',
11+
initialState,
12+
reducers: {
13+
changeRoom: (state, action) => {
14+
state.roomCode = action.payload
15+
}
16+
}
17+
});
18+
19+
// Exports the action creator function to be used with useDispatch
20+
export const { changeRoom } = roomCodeSlice.actions;
21+
// Exports so we can combine in rootReducer
22+
export default roomCodeSlice.reducer;

server/server.mjs

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ApolloServer } from '@apollo/server';
44
import { expressMiddleware } from '@apollo/server/express4';
55
import cors from 'cors';
66
import bodyParser from 'body-parser';
7-
const {json, urlencoded} = bodyParser;
7+
const { json, urlencoded } = bodyParser;
88

99
//possibly redundant
1010
import { makeExecutableSchema } from '@graphql-tools/schema';
@@ -17,7 +17,6 @@ import DEV_PORT from '../config.js';
1717
// const path = require('path');
1818
import path from 'path';
1919

20-
2120
import userController from './controllers/userController.js';
2221
import cookieController from './controllers/cookieController.js';
2322
import sessionController from './controllers/sessionController.js';
@@ -27,7 +26,6 @@ import projectController from './controllers/projectController.js';
2726
import { fileURLToPath } from 'url';
2827
import { dirname } from 'path';
2928

30-
3129
// env file
3230
import dotenv from 'dotenv';
3331
dotenv.config();
@@ -68,51 +66,52 @@ app.use(
6866
// V.15 Team: Github Oauth and Google Oauth works! (starts here)
6967
// const passport = require('passport');
7068
import passport from 'passport';
71-
import passportSetup from './routers/passport-setup.js'
72-
import session from 'express-session'
73-
import authRoutes from './routers/auth.js'
69+
import passportSetup from './routers/passport-setup.js';
70+
import session from 'express-session';
71+
import authRoutes from './routers/auth.js';
7472

75-
app.use(session({
76-
secret: process.env.SESSION_SECRET,
77-
resave: false,
78-
saveUninitialized: true,
79-
cookie: { maxAge: 24*60*60*1000 }
80-
}))
73+
app.use(
74+
session({
75+
secret: process.env.SESSION_SECRET,
76+
resave: false,
77+
saveUninitialized: true,
78+
cookie: { maxAge: 24 * 60 * 60 * 1000 }
79+
})
80+
);
8181

8282
app.use(passport.initialize());
8383
app.use(passport.session());
8484

8585
// go to other files
8686
// 8080 only for the container
87-
app.use('/auth', authRoutes)
87+
app.use('/auth', authRoutes);
8888

89-
import { createServer } from 'http'
90-
import { Server } from 'socket.io'
89+
import { createServer } from 'http';
90+
import { Server } from 'socket.io';
9191

92-
const httpServer = createServer(app)
92+
const httpServer = createServer(app);
9393
const io = new Server(httpServer, {
9494
transports: ['websocket'],
9595
cors: {
9696
origin: ['http://localhost:5656', 'http://localhost:8080']
9797
}
98-
})
99-
100-
io.on('connection', socket => {
101-
console.log(socket.id)
102-
socket.on('custom-event', (string, redux_store) => {
103-
// console.log(string)
104-
// console.log(redux_store)
105-
socket.broadcast.emit('receive message', redux_store)
106-
});
98+
});
10799

108-
socket.on('error', (error) => {
109-
console.error(`Socket error: ${error}`);
100+
io.on('connection', (socket) => {
101+
console.log(socket.id);
102+
socket.on('custom-event', (string, redux_store, room) => {
103+
console.log(room);
104+
if (room) {
105+
socket.to(room).emit('receive message', redux_store);
106+
} else {
107+
socket.broadcast.emit('receive message', redux_store);
108+
}
110109
});
111-
})
112-
113-
114-
115-
110+
socket.on('room-code', (roomCode) => {
111+
console.log('joined room: ', roomCode);
112+
socket.join(roomCode);
113+
});
114+
});
116115

117116
/*
118117
GraphQl Router
@@ -131,33 +130,29 @@ const resolvers = {
131130
Mutation
132131
};
133132

134-
135-
136133
// Re-direct to route handlers:
137134
app.use('/user-styles', stylesRouter);
138135

139136
// schemas used for graphQL
140137

141138
import typeDefs from './graphQL/schema/typeDefs.js';
142139

143-
144140
// instantiate Apollo server and attach to Express server, mounted at 'http://localhost:PORT/graphql'
145141

146142
//use make exacutable schema to allow schema to be passed to new server
147-
const schema = makeExecutableSchema({typeDefs, resolvers});
148-
149-
const server = new ApolloServer({schema});
143+
const schema = makeExecutableSchema({ typeDefs, resolvers });
150144

145+
const server = new ApolloServer({ schema });
151146

152147
//v4 syntax
153-
await server.start()
148+
await server.start();
154149
app.use(
155150
'/graphql',
156151
cors(),
157152
json(),
158153
expressMiddleware(server, {
159-
context: async ({ req }) => ({ token: req.headers.token }),
160-
}),
154+
context: async ({ req }) => ({ token: req.headers.token })
155+
})
161156
);
162157

163158
/** ****************************************************************** */
@@ -201,11 +196,11 @@ app.delete(
201196
);
202197
// serve index.html on the route '/'
203198
const isDocker = process.env.IS_DOCKER === 'true';
204-
console.log('this is running on docker: ', isDocker)
199+
console.log('this is running on docker: ', isDocker);
205200

206201
//if in production mode, statically serve everything in the build folder on the route '/dist'
207-
if (process.env.NODE_ENV == 'production'){
208-
app.use('/dist', express.static(path.join(__dirname, '/app/dist')))
202+
if (process.env.NODE_ENV == 'production') {
203+
app.use('/dist', express.static(path.join(__dirname, '/app/dist')));
209204
}
210205

211206
app.get('/', (req, res) => {
@@ -217,26 +212,26 @@ app.get('/', (req, res) => {
217212

218213
app.get('/bundle.js', (req, res) => {
219214
return res.status(200).sendFile(path.join(process.cwd(), 'bundle.js'));
220-
})
215+
});
221216

222-
if (isDocker){
217+
if (isDocker) {
223218
app.get('/main.css', (req, res) => {
224219
return res.status(200).sendFile(path.join(process.cwd(), 'main.css'));
225-
})
220+
});
226221
}
227222

228223
app.get('/test', (req, res) => {
229224
res.send('test request is working');
230-
})
225+
});
231226

232227
// only for testing purposes in the dev environment
233228
// app.get('/', function(req, res) {
234229
// res.send('Houston, Caret is in orbit!');
235230
// });
236231

237232
app.use('http://localhost:8080/*', (req, res) => {
238-
res.status(404).send('not a valid page (404 page)')
239-
})
233+
res.status(404).send('not a valid page (404 page)');
234+
});
240235
// catch-all route handler
241236
app.use('/*', (req, res) => res.status(404).send('Page not found'));
242237

@@ -253,7 +248,9 @@ app.use((err, req, res, next) => {
253248
});
254249

255250
// starts server on PORT
256-
httpServer.listen(5656, () => console.log(`Server listening on port: ${PORT.DEV_PORT}`))
251+
httpServer.listen(5656, () =>
252+
console.log(`Server listening on port: ${PORT.DEV_PORT}`)
253+
);
257254

258255
if (isTest) module.exports = app;
259256
// export default app;

0 commit comments

Comments
 (0)