Skip to content

Commit

Permalink
added CodeMirror, container, fixed Webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenlabrie committed Feb 6, 2021
1 parent 065219d commit 9741e88
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 68 deletions.
14 changes: 10 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"dependencies": {
"ace-builds": "^1.4.12",
"codemirror": "^5.59.2",
"cors": "^2.8.5",
"electron-builder": "^22.9.1",
"electron-fetch": "^1.7.3",
Expand All @@ -59,6 +60,7 @@
"mongoose": "^5.11.14",
"react": "^17.0.1",
"react-ace": "^9.3.0",
"react-codemirror2": "^7.2.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"wait-on": "^5.2.1"
Expand Down
4 changes: 2 additions & 2 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ app.use(cors());
// Getting mongodb uri from Frontend
app.post("/getURI", mongoSchemaController.createMongoSchema, (req, res, next) => {
// Waiting for locals to be sent, then deleting schema.json file
setTimeout(() => {
setTimeout(() => {
console.log('this got deleted')
fs.unlinkSync(path.join(__dirname, '../schema.json'))
}, 2000)
Expand All @@ -32,7 +32,7 @@ const schema = require('./schema')
app.use('/graphql', graphqlHTTP({ schema, graphiql: true }))


// app.use('/dist', express.static(path.join(__dirname, '../dist')));
// app.use('/static', express.static(path.join(__dirname, '../src/public')));

// app.get('/', (req, res) => {
// res.status(200).sendFile(path.resolve(__dirname, '../public/index.html'));
Expand Down
8 changes: 5 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import React from 'react'
import MongoDBURI from './Components/MongoDBURI';
import DropDownMenu from './Components/DropDownMenu';
import Container from './containers/Container';
import './public/index.css'


// Create main App component
const App = () => (
<div>
<h1>Hello, Electron!</h1>
<p>Our Electron App is working!!!</p>
<MongoDBURI />
<img id="logo" src="https://i.ibb.co/KFmZK7N/qlens-logo.png" alt="qlens-logo" border="0" />
<Container />
</div>
)

Expand Down
1 change: 1 addition & 0 deletions src/Components/CheckBox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
// import MongoSchemaIDE from 'MongoSchemaIDE';

const CheckBox = (props) => {
return (
Expand Down
10 changes: 0 additions & 10 deletions src/Components/ConvertToProgrammaticButton.js
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
// import React from 'react'

// const ConvertToProgrammaticButton = () => {
// return (
// <div>
// </div>
// )
// }

// export default ConvertToProgrammaticButton;
10 changes: 0 additions & 10 deletions src/Components/DownloadSchemaButton.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/Components/DropDownMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const DropDownMenu = ({schemaData, uriData}) => {
//sending obj data to backend
let selectedSchemas = {};
for(let i = 0; i < clicked.length; i+=1) {
selectedSchemas[clicked[i]] = schemaData[clicked[i]];
selectedSchemas[clicked[i]] = schemaData[clicked[i]];
}
console.log('selectedSchemas is ', selectedSchemas)

// fetch to the backend
// fetch to the backend

fetch('http://localhost:3000/selectedSchemas', {
method: 'POST',
Expand Down Expand Up @@ -129,7 +129,7 @@ export default DropDownMenu;
// assign the value to be the current schema

// for (let i = 0; i < schemaNames.length; i+=1) {

// if (schemaNames[i].includes(clickedSchema) && e.target.checked === false) {
// console.log('hiiii')
// setClicked(clicked.filter((item) => {
Expand Down
36 changes: 4 additions & 32 deletions src/Components/MongoDBURI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,16 @@ import React, { useState, useEffect } from "react"; // userEffect to fetch inste
import DropDownMenu from "./DropDownMenu";

// input field for the mongoDB uri
const MongoDBURI = () => {
const [schemaData, setSchemaData] = useState({});
const [uriId, setUriId] = useState('');

const submit = (e) => {I
e.preventDefault()
console.log('submit worked')
fetch('http://localhost:3000/getURI', {
method: "POST",
headers: {
"Content-Type" : "application/json"
},
body: JSON.stringify({val: 'mongodb+srv://judy:hush@hush.u9hai.mongodb.net/chat?retryWrites=true&w=majority'})
})
.then(res => res.json())
.then((data) => {
console.log('data string from fetch', data)
setSchemaData(JSON.parse(data));
})
.catch(err => console.log(err))
}

//uriId = document.getElementById('uriInput').value;
const getUri = (e) => {
setUriId(e.target.value);
};

console.log("state is being set", schemaData);

const MongoDBURI = ({schemaData, uriData, submitbtn, geturi}) => {
return (
<div className="formContainer">
<div>
<form>
<input type="text" placeholder="enter MongoDBURI ..." onChange= {getUri}/>
<input className="URISubmitButton" type="submit" value="Submit" onClick={submit}/>
<input type="text" placeholder="enter MongoDBURI ..." onChange= {geturi}/>
<input className="URISubmitButton" type="submit" value="Submit" onClick={submitbtn}/>
</form>
</div>
<DropDownMenu schemaData={schemaData} uriData={uriId} />
<DropDownMenu schemaData={schemaData} uriData={uriData} />
</div>
)
}
Expand Down
42 changes: 42 additions & 0 deletions src/Components/MongoSchemaIDE.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import Codemirror from 'codemirror';
import {UnControlled as CodeMirror} from 'react-codemirror2';
require('codemirror/mode/javascript/javascript');
import '../public/codemirror.css';
// import '../public/material.css';
// require('../../node_modules/codemirror/lib/codemirror.css');
import '../../node_modules/codemirror/lib/codemirror.css';
import '../../node_modules/codemirror/theme/dracula.css';
// import '../../node_modules/codemirror/lib/codemirror.css';
// import '../../node_modules/codemirror/theme/dracula.css';

const MongoSchemaIDE = ({schemaData}) => {
console.log('from mongoIDE schemaData', schemaData)
return(

<div>
<div className="codebox">
<CodeMirror
value='<h1>hi</h1>'
options={{
mode: 'javascript',
theme: 'dracula',
lineNumbers: true
}}
/>
</div>
<div className="codebox2">
<CodeMirror
value='<h1>Judy with the BIGGGGGG booty! yasss queen! </h1>'
options={{
mode: 'javascript',
theme: 'dracula',
lineNumbers: true
}}
/>
</div>
</div>
)
}

export default MongoSchemaIDE;
43 changes: 43 additions & 0 deletions src/containers/Container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// import React from 'react'
import React, { useState, useEffect } from "react";
import MongoDBURI from '../Components/MongoDBURI';
import MongoSchemaIDE from '../Components/MongoSchemaIDE';

const Container = () => {
const [schemaData, setSchemaData] = useState({});
const [uriId, setUriId] = useState('');

const submit = (e) => {
e.preventDefault()
console.log('submit worked')
fetch('http://localhost:3000/getURI', {
method: "POST",
headers: {
"Content-Type" : "application/json"
},
body: JSON.stringify({val: 'mongodb+srv://judy:hush@hush.u9hai.mongodb.net/chat?retryWrites=true&w=majority'})
})
.then(res => res.json())
.then((data) => {
console.log('data string from fetch', data)
setSchemaData(JSON.parse(data));
})
.catch(err => console.log(err))
}

//uriId = document.getElementById('uriInput').value;
const getUri = (e) => {
setUriId(e.target.value);
};

console.log("state is being set", schemaData);

return(
<div>
<MongoDBURI schemaData={schemaData} uriData={uriId} geturi={getUri} submitbtn={submit} />
<MongoSchemaIDE schemaData={schemaData} />
</div>
)
}

export default Container;
11 changes: 11 additions & 0 deletions src/public/codemirror.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.codebox {
border: 1px solid black;
width: 40%;
display: inline-block;
}

.codebox2 {
border: 1px solid black;
width: 40%;
display: inline-block;
}
3 changes: 3 additions & 0 deletions src/public/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#logo {
width: 15%;
}
Empty file added src/public/material.css
Empty file.
8 changes: 5 additions & 3 deletions webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ const { spawn } = require('child_process')
const defaultInclude = path.resolve(__dirname, 'src')

module.exports = {

module: {
rules: [
{
test: /\.css$/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
include: defaultInclude
//use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
use: ["style-loader", "css-loader"],
include: [defaultInclude,
path.resolve(__dirname, 'node_modules/codemirror/lib/codemirror.css'), path.resolve(__dirname, 'node_modules/codemirror/theme/dracula.css')]
},
{
test: /\.jsx?$/,
Expand Down
4 changes: 3 additions & 1 deletion webpack2.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@
// "build:react": "NODE_ENV=production webpack --config webpack.react.config.js --mode production",
// "build": "npm run build:electron && npm run build:react",
// "pack": "electron-builder --dir",
// "dist": "electron-builder"
// "dist": "electron-builder"

// use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],

0 comments on commit 9741e88

Please sign in to comment.