The following repo contains the source code for the client data-collection application.
Make sure the details of your application are correctly written in .env file:
cp .env_example .env
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Currently only supported in Google Chrome.
google-chrome --kiosk http://example.com/
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --kiosk --app=http://localhost:3000
Then open Google Chrome and go to localhost:3000.
–chrome-frame –kiosk “http://www.google.com”
More info can be found at the following link.
This section covers the folder strucure of the project.
FOLDER | PURPOSE |
---|---|
tests | 'Contains all the tests' |
actions | "Contains all the actions" |
components | "Contains all the React components |
containers | 'Contains all components' wrappers' |
hoc | "Higher-Order Components for question" |
reducers | "Contains all the React reducers" |
styles | "Contains all the component stylesheets" |
utils | "Constants and API calls to server" |
If you would like to modify the source coude, please have a look at the following design pattern:
Higher-Order Components: advanced technique in React for reusing component logic. Add a new component: Create the new component in /components folder, assign it a valid type in mapTypeToComponent object.
In docs/input.txt you can find an example of JSON data comming from the server. Similarly, output.txt contains an exanple of JSON data going to the server.
To modify or add css style:
- add style prop to a component ex. <Component style={{width: 100, height: 100}}/>
- add a css style file to
src/styles/
and import that file in the component that uses the style - import { makeStyles } from
@material/core/styles
. See example inImageCard
component insrc/components/questionTypes
To add a new question type, create a component and import it in src/hoc/createQuestion
in map structure: mapTypeToComponent
. Question objects, coming from the server with that specific type, will be rendered as the newly designed Component. All objects' fields are passed as props to the component.
Server communication configuration: src/utils/API.js
To set a new path, modify BASE_URL
Server requests: src/utils/requests
To start production server, run, in this order: npm install
/ npm build
/ node app.js
Open http://localhost:3000 to view it in the browser.
By default, PORT is set to 3000