-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from City-of-Turku/develop
Release 1.0
- Loading branch information
Showing
55 changed files
with
7,413 additions
and
6,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-syntax-dynamic-import", | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
REACT_APP_API_BASE_URL=http://localhost:8000/v1 | ||
REACT_APP_API_TIMEOUT=30000 | ||
REACT_APP_BACKEND_IMAGES_BASE_URL=http://localhost:8000/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
{ | ||
"extends": "airbnb", | ||
"parser": "@babel/eslint-parser", | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:react/recommended" | ||
], | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
}, | ||
"rules": { | ||
"indent": ["error", 2], // Require 2-space indent | ||
"quotes": 0, // No specified quote style; the programmer should take care of using only one style | ||
"max-len": ["error", 120], // 120-character lines are fine | ||
"curly": ["error", "all"], // Always require curlys. | ||
"comma-dangle": ["error", "only-multiline"], // Require trailing commas in multi-line literals (such as this) | ||
"complexity": ["error", {"max": 20}] | ||
"indent": [ | ||
"error", | ||
2 | ||
], // Require 2-space indent | ||
"quotes": 0, // No specified quote style; the programmer should take care of using only one style | ||
"max-len": [ | ||
"error", | ||
120 | ||
], // 120-character lines are fine | ||
"curly": [ | ||
"error", | ||
"all" | ||
], // Always require curlys. | ||
"comma-dangle": [ | ||
"error", | ||
"only-multiline" | ||
], // Require trailing commas in multi-line literals (such as this) | ||
"complexity": [ | ||
"error", | ||
{ | ||
"max": 20 | ||
} | ||
] | ||
}, | ||
"env": { | ||
"browser": true, | ||
"mocha": true | ||
"mocha": true, | ||
"node": true, | ||
"es6": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,12 @@ | |
/coverage | ||
|
||
# production | ||
/dist | ||
/build | ||
|
||
# env | ||
.env | ||
|
||
# misc | ||
.DS_Store | ||
npm-debug.log* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,51 @@ | ||
The app is based on `create-react-app` script | ||
[https://github.com/facebookincubator/create-react-app](https://github.com/facebookincubator/create-react-app) | ||
# Living environment UI | ||
|
||
This is the frontend app for Living Environment platform built with React. | ||
|
||
## Clone the repo | ||
## Requirements | ||
|
||
`git clone https://github.com/City-of-Turku/living-environment-ui.git` | ||
Node.js version >= 20 and Yarn. | ||
|
||
## Configuration files | ||
## Installing | ||
|
||
In development app is reading the settings from `/src/config/config.dev.json`. For production mode, the settings from `/src/config/config.dev.json` are used.<br> | ||
|
||
`api/baseUrl` should point to backend API base url (for ex. http://localhost:8000/api)<br> | ||
`api/timeout` sets the request timeout given in milliseconds<br> | ||
`backendImages` points to the base address of the images<br> | ||
|
||
### `npm install` | ||
|
||
This command will install all app dependencies. | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.<br> | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.<br> | ||
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.<br> | ||
Your app is ready to be deployed! | ||
|
||
The command creates a `build` directory with a production build of your app.<br> | ||
|
||
### Static Server (testing the output of `build` command) | ||
|
||
For environments using [Node](https://nodejs.org/), the easiest way to handle this would be to install [serve](https://github.com/zeit/serve) and let it handle the rest: | ||
Clone the repo: | ||
``` | ||
git clone https://github.com/City-of-Turku/living-environment-ui.git | ||
``` | ||
|
||
```sh | ||
npm install -g serve | ||
serve -s build | ||
Go into the project directory: | ||
``` | ||
cd living-environment-ui | ||
``` | ||
|
||
The last command shown above will serve your static site on the port **5000**. Like many of [serve](https://github.com/zeit/serve)’s internal settings, the port can be adjusted using the `-p` or `--port` flags. | ||
Install dependencies: | ||
``` | ||
yarn install | ||
``` | ||
|
||
Run this command to get a full list of the options available: | ||
Create `.env` file based on `.env.example` file. | ||
|
||
```sh | ||
serve -h | ||
Start development server: | ||
``` | ||
yarn start | ||
``` | ||
|
||
# nginx server | ||
|
||
Install nginx server<br> | ||
## Production | ||
|
||
Copy the content of the build folder to the Nginx application folder<br> | ||
To build the project for production run: | ||
``` | ||
yarn build | ||
``` | ||
This command builds the project in `/dist` folder. | ||
|
||
```sh | ||
mkdir /var/www/app | ||
cp -a /path/to/living-environment-ui/build/. /var/www/app/ | ||
To preview the production version you can run: | ||
``` | ||
yarn preview | ||
``` | ||
|
||
Setup the nginx config | ||
## Testing | ||
|
||
```sh | ||
root /var/www/app | ||
location /api/ { | ||
proxy_pass http://django-rest:8000/api/; | ||
} | ||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
This project uses Jest and React Testing Library for unit tests. To run them use command: | ||
``` | ||
yarn test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.jsx?$': 'babel-jest', | ||
"^.+\\.js$": "babel-jest", | ||
".+\\.(svg|css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub" | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.