From 3af0e8fbdca5c7955c72a5006b26858a17694218 Mon Sep 17 00:00:00 2001 From: Wassim Gharbi Date: Mon, 10 Jun 2019 23:13:33 -0400 Subject: [PATCH 1/3] Added an automatic setup utility --- README.md | 9 ++++++--- makeconf.json | 25 +++++++++++++++++++++++++ package.json | 8 +++++--- server.js | 11 +++++------ 4 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 makeconf.json diff --git a/README.md b/README.md index e9ba2b9..6d9b7ed 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,14 @@ Use the demo website at [http://digitaldisplay.herokuapp.com](http://digitaldisp ### How to Run: -1. Set up a MongoDB installation locally and create a `digitaldisplay` database +1. Set up a MongoDB installation locally (or in the cloud) and create a `digitaldisplay` database -2. Rename the `.env.example` file to `.env` +2. Run the setup utility using -3. Change references to the database to link to your local database (usually `mongodb://localhost:27017/digitaldisplay`) +```bash +npm run setup +``` +and specify the URI to your database. 4. Install dependencies and run the program diff --git a/makeconf.json b/makeconf.json new file mode 100644 index 0000000..b357114 --- /dev/null +++ b/makeconf.json @@ -0,0 +1,25 @@ +{ + "format": ".env", + "file": ".env", + "config": { + "MONGODB_URI": { + "description": "Your MongoDB URI (remote or local)", + "required": true + }, + "PORT": { + "description": "Which port should the server run on?", + "default": "3001", + "required": true + }, + "ENVIRON": { + "description": "Environment (DEV or PROD)", + "default": "DEV", + "required": true + }, + "SESSION_SECRET": { + "description": "Session secret key (can be anything)", + "default": "3i2br082jrfdsufnsfk10", + "required": true + } + } +} diff --git a/package.json b/package.json index 73f732b..c3a6e75 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,11 @@ "description": "This is a user interface for a dynamic digital signage", "main": "index.js", "scripts": { - "dev": "cross-env NODE_ENV=dev node server.js", - "build": "next build", + "setup": "[ -f .env ] || makeconf", + "dev": "npm run setup && ENVIRON=DEV node server.js", + "build": "npm run setup && next build", "lint": "eslint --color ./ *.js", - "start": "NODE_ENV=production node server.js", + "start": "npm run setup && ENVIRON=PROD node server.js", "test": "echo \"No test specified yet.\" && exit 0", "heroku-postbuild": "next build" }, @@ -46,6 +47,7 @@ "isomorphic-unfetch": "^3.0.0", "js-cookie": "^2.2.0", "lodash": "^4.17.11", + "makeconf": "^1.4.4", "mongoose": "^5.4.19", "mongoose-crudify": "^0.2.0", "multer": "^1.4.1", diff --git a/server.js b/server.js index 308ac73..75e799d 100644 --- a/server.js +++ b/server.js @@ -8,14 +8,13 @@ const session = require('cookie-session') const bodyParser = require('body-parser') const socketIo = require('socket.io') -const dev = process.env.NODE_ENV !== 'production' -const port = process.env.PORT || 3000 +const Keys = require('./keys') + +const dev = Keys.ENVIRON !== 'PROD' const app = next({ dev }) const routes = require('./routes') const handle = routes.getRequestHandler(app) -const Keys = require('./keys') - const apiRoutes = require('./api/routes') const User = require('./api/models/User') @@ -80,10 +79,10 @@ app return handle(req, res) }) - const finalServer = server.listen(port, err => { + const finalServer = server.listen(Keys.PORT, err => { if (err) throw err // eslint-disable-next-line - console.log('> Ready on http://localhost:' + port) + console.log('> Ready on http://localhost:' + Keys.PORT) }) // Socket.io From 4584121d26b97a16b5313c505bc1d4741b3615cd Mon Sep 17 00:00:00 2001 From: Wassim Gharbi Date: Mon, 10 Jun 2019 23:28:37 -0400 Subject: [PATCH 2/3] Removed freeform editor for slides --- api/models/Slide.js | 2 +- components/Admin/SlideCard.js | 7 +-- components/Admin/SlideEditDialog.js | 11 +---- components/Form/Input.js | 3 -- package.json | 1 - widgets/slideshow/src/Slide/Freeform.js | 61 ------------------------- widgets/slideshow/src/Slideshow.js | 3 -- 7 files changed, 3 insertions(+), 85 deletions(-) delete mode 100644 widgets/slideshow/src/Slide/Freeform.js diff --git a/api/models/Slide.js b/api/models/Slide.js index 5eb6e38..280cbbd 100644 --- a/api/models/Slide.js +++ b/api/models/Slide.js @@ -6,7 +6,7 @@ const Slide = new Schema({ type: { type: String, default: 'photo', - enum: ['photo', 'web', 'youtube', 'video', 'freeform'] + enum: ['photo', 'web', 'youtube', 'video'] }, title: { type: String }, description: { type: String }, diff --git a/components/Admin/SlideCard.js b/components/Admin/SlideCard.js index 0353c71..57a989c 100644 --- a/components/Admin/SlideCard.js +++ b/components/Admin/SlideCard.js @@ -2,7 +2,7 @@ import { Component } from 'react' import React from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faClock } from '@fortawesome/free-regular-svg-icons' -import { faTrash, faEdit, faPlay, faGlobe, faShapes } from '@fortawesome/free-solid-svg-icons' +import { faTrash, faEdit, faPlay, faGlobe } from '@fortawesome/free-solid-svg-icons' import SlideEditDialog from './SlideEditDialog' @@ -34,8 +34,6 @@ class SlideCard extends Component { ? '#c23616' : value.type == 'web' ? '#0097e6' - : value.type == 'freeform' - ? '#E68300' : 'transparent' }} > @@ -45,9 +43,6 @@ class SlideCard extends Component { {value.type == 'web' && ( )} - {value.type == 'freeform' && ( - - )}
diff --git a/components/Admin/SlideEditDialog.js b/components/Admin/SlideEditDialog.js index 1eb9829..039522e 100644 --- a/components/Admin/SlideEditDialog.js +++ b/components/Admin/SlideEditDialog.js @@ -106,8 +106,7 @@ class SlideEditDialog extends React.Component { choices={[ { id: 'youtube', label: 'Youtube Video' }, { id: 'web', label: 'Web Page' }, - { id: 'photo', label: 'Photo' }, - { id: 'freeform', label: 'Freeform Editor' } + { id: 'photo', label: 'Photo' } ]} onChange={this.handleChange} /> @@ -120,14 +119,6 @@ class SlideEditDialog extends React.Component { onChange={this.handleChange} inline={true} /> - ) : type == 'freeform' || upload ? ( - ) : ( - ) : type == 'freeform' ? ( - ) : (