This commit is contained in:
Pitchaya Boonsarngsuk
2019-07-05 16:54:32 +01:00
commit c3d3dcbff7
96 changed files with 32248 additions and 0 deletions

14
client/.dockerignore Normal file
View File

@@ -0,0 +1,14 @@
**/*.log
**/*.md
**/._*
**/.dockerignore
**/.DS_Store
**/.git/
**/.gitattributes
**/.gitignore
**/.gitmodules
**/Dockerfile*
**/Thumbs.db
.env*
build/
node_modules/

3
client/.env Normal file
View File

@@ -0,0 +1,3 @@
REACT_APP_API_ENTRYPOINT=https://localhost:8443
API_PLATFORM_CLIENT_GENERATOR_ENTRYPOINT=http://api
API_PLATFORM_CLIENT_GENERATOR_OUTPUT=src

20
client/.gitignore vendored Normal file
View File

@@ -0,0 +1,20 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
# production
/build
# misc
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

15
client/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM node:11.5-alpine
RUN mkdir -p /usr/src/client
WORKDIR /usr/src/client
RUN yarn global add @api-platform/client-generator
# Prevent the reinstallation of node modules at every changes in the source code
COPY package.json yarn.lock ./
RUN yarn install
COPY . ./
CMD yarn start

36
client/package.json Normal file
View File

@@ -0,0 +1,36 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"bootstrap": "^4.1.3",
"connected-react-router": "^5.0.1",
"font-awesome": "^4.7.0",
"jest-junit": "^5.2.0",
"lodash.get": "^4.4.2",
"lodash.has": "^4.5.2",
"lodash.mapvalues": "^4.6.0",
"prettier": "^1.14.3",
"prop-types": "^15.6.2",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-redux": "^5.1.0",
"react-router-dom": "^4.3.1",
"react-scripts": "^2.1.1",
"redux": "^4.0.1",
"redux-form": "^7.4.2",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}

BIN
client/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

40
client/public/index.html Normal file
View File

@@ -0,0 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Welcome to API Platform</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View File

@@ -0,0 +1,15 @@
{
"short_name": "API Platform",
"name": "Client",
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

1801
client/src/Welcome.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
export const ENTRYPOINT = process.env.REACT_APP_API_ENTRYPOINT;

46
client/src/index.js Normal file
View File

@@ -0,0 +1,46 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import { reducer as form } from 'redux-form';
import { Route, Switch } from 'react-router-dom';
import createBrowserHistory from 'history/createBrowserHistory';
import {
ConnectedRouter,
connectRouter,
routerMiddleware
} from 'connected-react-router';
import 'bootstrap/dist/css/bootstrap.css';
import 'font-awesome/css/font-awesome.css';
import * as serviceWorker from './serviceWorker';
// Import your reducers and routes here
import Welcome from './Welcome';
const history = createBrowserHistory();
const store = createStore(
combineReducers({
router: connectRouter(history),
form,
/* Add your reducers here */
}),
applyMiddleware(routerMiddleware(history), thunk)
);
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<Switch>
<Route path="/" component={Welcome} strict={true} exact={true}/>
{/* Add your routes here */}
<Route render={() => <h1>Not Found</h1>} />
</Switch>
</ConnectedRouter>
</Provider>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();

135
client/src/serviceWorker.js Normal file
View File

@@ -0,0 +1,135 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read http://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit http://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See http://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}

312
client/src/welcome.css Normal file
View File

@@ -0,0 +1,312 @@
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700|Roboto+Slab:300,700');
body {
margin: 0;
}
/***** GLOBAL *****/
.welcome {
height: 100vh;
width: 100vw;
text-align: center;
color: #1d1e1c;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
overflow: auto;
background-color: #ececec;
}
.welcome a {
text-decoration: none;
color: #38a9b4;
font-weight: bold;
}
.welcome h1 {
font-family: 'Roboto Slab', serif;
font-weight: 300;
font-size: 36px;
margin: 0 0 10px;
line-height: 30px;
}
.welcome h1 strong {
font-weight: 700;
color: #38a9b4;
}
.welcome h2 {
text-transform: uppercase;
font-size: 18px;
font-weight: bold;
margin: 25px 0 5px;
}
.welcome h3 {
text-transform: uppercase;
font-weight: 500;
color: #38a9b4;
font-size: 16px;
margin: 0 0 5px;
display: block;
}
/***** TOP *****/
.welcome__top {
background-color: #67cece;
padding-bottom: 40px;
}
.welcome__flag {
transform: rotate(30deg);
position: fixed;
right: -190px;
top: 65px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.2);
z-index: 5;
}
/***** MAIN *****/
.welcome__main {
box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14),
0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.3);
width: 80%;
max-width: 1100px;
margin-left: auto;
margin-right: auto;
transform: translateY(-50px);
background-color: white;
display: flex;
}
.main__aside {
background-color: #afe5e5;
width: 30%;
position: relative;
overflow: hidden;
}
.aside__circle,
.main__aside svg {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.aside__circle {
background-color: white;
border-radius: 50%;
width: 90%;
height: 0;
padding-bottom: 90%;
}
.aside__circle:after {
content: '';
width: 4px;
left: calc(50% - 5px);
top: -50%;
position: absolute;
height: 100%;
background-color: #1d1e1c;
}
.main__aside svg {
width: 100%;
}
.main__content {
padding: 30px;
text-align: left;
flex: auto;
}
.other__bloc {
display: inline-flex;
align-items: center;
border: 4px solid #afe5e5;
padding: 10px 20px;
margin: 10px 0;
height: 170px;
box-sizing: border-box;
text-align:left;
}
.other__bloc:not(:last-of-type) {
margin-right: 10px;
}
.other__bloc h3:not(:first-child) {
margin-top: 15px;
padding-top: 5px;
}
.other__circle {
width: 110px;
height: 110px;
background-color: #afe5e5;
border-radius: 50%;
margin-right:20px;
}
.other__circle svg{
width: 110px;
}
.buttons__group {
display: inline-flex;
vertical-align: center;
}
.buttons__group .buttons__or {
width: 4px;
position: relative;
text-align:center;
}
.buttons__group .buttons__or:before {
content: 'or';
font-size: 12px;
color: #aaa;
line-height: 18px;
position: absolute;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
width: 18px;
height: 18px;
}
.buttons__group .other__button:first-child {
border-radius: 5px 0 0 5px;
padding-right: 15px;
}
.buttons__group .other__button:last-child {
border-radius: 0 5px 5px 0;
padding-left: 15px;
}
a.other__button {
background-color: #e0e1e2;
font-size: 11px;
color: #686e63;
cursor: pointer;
padding: 5px 10px;
display: inline-block;
transition: all ease 0.2s;
text-transform: uppercase;
}
.other__button:hover {
background-color: #afe5e5;
color: #339ba5;
}
.main__button {
display: inline-block;
padding: 10px 50px 10px 10px;
border: 3px solid #339ba5;
font-size: 22px;
color: #339ba5;
text-transform: uppercase;
margin: 15px 0;
overflow: hidden;
transition: all ease 0.3s;
cursor: pointer;
position: relative;
}
.main__button svg {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
transition: transform ease 0.2s;
}
.main__button:hover {
background-color: #afe5e5;
}
.main__button:hover svg {
transform: translateY(-50%) rotate(35deg);
}
/***** HELP *****/
.welcome__help {
background-color: white;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.2);
padding: 10px;
position: fixed;
right: -5px;
top: 50%;
transform: translateY(-50%);
border-radius: 5px;
text-align: center;
}
.welcome__help h2 {
color: #aaa;
font-size: 12px;
margin: 10px 0;
}
.help__circle {
width: 36px;
height: 36px;
border-radius: 50%;
border: 2px solid #ccc;
display: block;
margin: 10px auto;
transition: all ease 0.2s;
position:relative;
}
.help__circle svg {
position:absolute;
left: 50%;
top: 50%;
transform:translate(-50%, -50%);
}
.help__circle:hover {
border-color: #67cece;
background-color: #afe5e5;
}
/***** MEDIAS *****/
@media (max-width: 1200px) {
.main__aside,
.welcome__help {
display: none;
}
.main__content {
width: 100%;
text-align: center;
padding: 20px;
}
}
@media (max-width: 600px) {
.welcome__main {
width: calc(100% - 40px);
}
.welcome h1 {
display: none;
}
.welcome__flag,
.main__other {
display: none;
}
.main__content {
padding: 10px;
}
}

10446
client/yarn.lock Normal file

File diff suppressed because it is too large Load Diff