API & Client: refactor (rename mpwo to fittrackee)

This commit is contained in:
Sam 2018-06-07 14:45:43 +02:00
parent 1f36de74ba
commit f65d636f85
81 changed files with 99 additions and 98 deletions

View File

@ -28,7 +28,7 @@ before_install:
- sudo mv docker-compose /usr/local/bin
before_script:
- export DATABASE_TEST_URL=postgres://postgres:@localhost:5432/mpwo_test
- export DATABASE_TEST_URL=postgres://postgres:@localhost:5432/fittrackee_test
- export APP_SETTINGS=fittrackee_api.config.TestingConfig
- export REACT_APP_API_URL=http://127.0.0.1
- export NODE_ENV=development

View File

@ -22,5 +22,5 @@ PYTEST = $(VENV)/bin/py.test
COV = $(VENV)/bin/python-codacy-coverage
# Node env
NODE_MODULES = $(PWD)/mpwo_client/node_modules
NPM ?= yarn --modules-folder mpwo_client/node_modules/
NODE_MODULES = $(PWD)/fittrackee_client/node_modules
NPM ?= yarn --modules-folder fittrackee_client/node_modules/

View File

@ -2,8 +2,8 @@ version: '3.3'
services:
mpwo-db:
container_name: mpwo-db
fittrackee-db:
container_name: fittrackee-db
build: https://github.com/SamR1/mpwo.git#master:fittrackee_api/db
ports:
- 5435:5432
@ -11,36 +11,36 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
mpwo-api:
container_name: mpwo-api
fittrackee-api:
container_name: fittrackee-api
build: https://github.com/SamR1/mpwo.git#master:fittrackee_api
ports:
- 5001:5000
environment:
- DATABASE_URL=postgres://postgres:postgres@mpwo-db:5432/mpwo
- DATABASE_TEST_URL=postgres://postgres:postgres@mpwo-db:5432/mpwo_test
- DATABASE_URL=postgres://postgres:postgres@fittrackee-db:5432/fittrackee
- DATABASE_TEST_URL=postgres://postgres:postgres@fittrackee-db:5432/fittrackee_test
- FLASK_APP=server.py
- FLASK_DEBUG=1
- APP_SETTINGS=fittrackee_api.config.TestingConfig
depends_on:
- mpwo-db
- fittrackee-db
links:
- mpwo-db
- fittrackee-db
mpwo-client:
container_name: mpwo-client
fittrackee-client:
container_name: fittrackee-client
build:
context: https://github.com/SamR1/mpwo.git
dockerfile: ./mpwo_client/Dockerfile
dockerfile: ./fittrackee_client/Dockerfile
args:
- NODE_ENV=development
- REACT_APP_API_URL=${REACT_APP_API_URL}
ports:
- 3007:3000
depends_on:
- mpwo-api
- fittrackee-api
links:
- mpwo-api
- fittrackee-api
nginx:
container_name: nginx
@ -49,7 +49,7 @@ services:
ports:
- 80:80
depends_on:
- mpwo-api
- mpwo-client
- fittrackee-api
- fittrackee-client
links:
- mpwo-api
- fittrackee-api

View File

@ -2,8 +2,8 @@ version: '3.3'
services:
mpwo-db:
container_name: mpwo-db
fittrackee-db:
container_name: fittrackee-db
build: ./fittrackee_api/db
ports:
- 5435:5432
@ -11,36 +11,36 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
mpwo-api:
container_name: mpwo-api
fittrackee-api:
container_name: fittrackee-api
build: ./fittrackee_api
ports:
- 5001:5000
environment:
- DATABASE_URL=postgres://postgres:postgres@mpwo-db:5432/mpwo
- DATABASE_TEST_URL=postgres://postgres:postgres@mpwo-db:5432/mpwo_test
- DATABASE_URL=postgres://postgres:postgres@fittrackee-db:5432/fittrackee
- DATABASE_TEST_URL=postgres://postgres:postgres@fittrackee-db:5432/fittrackee_test
- FLASK_APP=server.py
- FLASK_DEBUG=1
- APP_SETTINGS=fittrackee_api.config.DevelopmentConfig
depends_on:
- mpwo-db
- fittrackee-db
links:
- mpwo-db
- fittrackee-db
mpwo-client:
container_name: mpwo-client
fittrackee-client:
container_name: fittrackee-client
build:
context: ./
dockerfile: ./mpwo_client/Dockerfile
dockerfile: ./fittrackee_client/Dockerfile
args:
- NODE_ENV=development
- REACT_APP_API_URL=${REACT_APP_API_URL}
ports:
- 3007:3000
depends_on:
- mpwo-api
- fittrackee-api
links:
- mpwo-api
- fittrackee-api
nginx:
container_name: nginx
@ -49,7 +49,7 @@ services:
ports:
- 80:80
depends_on:
- mpwo-api
- mpwo-client
- fittrackee-api
- fittrackee-client
links:
- mpwo-api
- fittrackee-api

View File

@ -0,0 +1,4 @@
{
"name": "fittrackee_client",
"version": "0.1.0"
}

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -27,7 +27,7 @@
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin=""
>
<title>mpwo</title>
<title>FitTrackee</title>
</head>
<body>
<noscript>

View File

@ -1,7 +1,7 @@
import { parse } from 'date-fns'
import mpwoGenericApi from '../mwpoApi'
import mpwoApi from '../mwpoApi/activities'
import FitTrackeeGenericApi from '../fitTrackeeApi'
import FitTrackeeApi from '../fitTrackeeApi/activities'
import { history } from '../index'
import { formatChartData } from '../utils'
import { setError, setLoading } from './index'
@ -27,7 +27,7 @@ export const setChartData = chartData => ({
chartData,
})
export const addActivity = form => dispatch => mpwoApi
export const addActivity = form => dispatch => FitTrackeeApi
.addActivity(form)
.then(ret => {
if (ret.status === 'created') {
@ -48,7 +48,7 @@ export const addActivity = form => dispatch => mpwoApi
.catch(error => dispatch(setError(`activities: ${error}`)))
export const addActivityWithoutGpx = form => dispatch => mpwoApi
export const addActivityWithoutGpx = form => dispatch => FitTrackeeApi
.addActivityWithoutGpx(form)
.then(ret => {
if (ret.status === 'created') {
@ -63,7 +63,7 @@ export const addActivityWithoutGpx = form => dispatch => mpwoApi
export const getActivityGpx = activityId => dispatch => {
if (activityId) {
return mpwoApi
return FitTrackeeApi
.getActivityGpx(activityId)
.then(ret => {
if (ret.status === 'success') {
@ -80,7 +80,7 @@ export const getActivityGpx = activityId => dispatch => {
export const getActivityChartData = activityId => dispatch => {
if (activityId) {
return mpwoApi
return FitTrackeeApi
.getActivityChartData(activityId)
.then(ret => {
if (ret.status === 'success') {
@ -95,7 +95,7 @@ export const getActivityChartData = activityId => dispatch => {
}
export const deleteActivity = id => dispatch => mpwoGenericApi
export const deleteActivity = id => dispatch => FitTrackeeGenericApi
.deleteData('activities', id)
.then(ret => {
if (ret.status === 204) {
@ -108,7 +108,7 @@ export const deleteActivity = id => dispatch => mpwoGenericApi
.catch(error => dispatch(setError(`activities: ${error}`)))
export const editActivity = form => dispatch => mpwoGenericApi
export const editActivity = form => dispatch => FitTrackeeGenericApi
.updateData('activities', form)
.then(ret => {
if (ret.status === 'success') {
@ -122,7 +122,7 @@ export const editActivity = form => dispatch => mpwoGenericApi
.catch(error => dispatch(setError(`activities: ${error}`)))
export const getMoreActivities = page => dispatch => mpwoGenericApi
export const getMoreActivities = page => dispatch => FitTrackeeGenericApi
.getData('activities', { page })
.then(ret => {
if (ret.status === 'success') {
@ -135,7 +135,8 @@ export const getMoreActivities = page => dispatch => mpwoGenericApi
})
.catch(error => dispatch(setError(`activities: ${error}`)))
export const getMonthActivities = (start, end) => dispatch => mpwoGenericApi
export const getMonthActivities = (start, end) => dispatch =>
FitTrackeeGenericApi
.getData('activities', { start, end, order: 'asc', per_page: 100 })
.then(ret => {
if (ret.status === 'success') {

View File

@ -1,4 +1,4 @@
import mpwoApi from '../mwpoApi/index'
import FitTrackeeApi from '../fitTrackeeApi/index'
import { history } from '../index'
@ -21,7 +21,7 @@ export const getData = (target, data) => dispatch => {
if (data && data.id && isNaN(data.id)) {
return dispatch(setError(target, `${target}: Incorrect id`))
}
return mpwoApi
return FitTrackeeApi
.getData(target, data)
.then(ret => {
if (ret.status === 'success') {
@ -33,7 +33,7 @@ export const getData = (target, data) => dispatch => {
.catch(error => dispatch(setError(`${target}: ${error}`)))
}
export const addData = (target, data) => dispatch => mpwoApi
export const addData = (target, data) => dispatch => FitTrackeeApi
.addData(target, data)
.then(ret => {
if (ret.status === 'created') {
@ -48,7 +48,7 @@ export const updateData = (target, data) => dispatch => {
if (isNaN(data.id)) {
return dispatch(setError(target, `${target}: Incorrect id`))
}
return mpwoApi
return FitTrackeeApi
.updateData(target, data)
.then(ret => {
if (ret.status === 'success') {
@ -64,7 +64,7 @@ export const deleteData = (target, id) => dispatch => {
if (isNaN(id)) {
return dispatch(setError(target, `${target}: Incorrect id`))
}
return mpwoApi
return FitTrackeeApi
.deleteData(target, id)
.then(ret => {
if (ret.status === 204) {

View File

@ -1,7 +1,7 @@
import mpwoApi from '../mwpoApi/stats'
import FitTrackeeApi from '../fitTrackeeApi/stats'
import { setData, setError } from './index'
export const getStats = (userId, type, data) => dispatch => mpwoApi
export const getStats = (userId, type, data) => dispatch => FitTrackeeApi
.getStats(userId, type, data)
.then(ret => {
if (ret.status === 'success') {

View File

@ -1,4 +1,4 @@
import mpwoApiUser from '../mwpoApi/user'
import FitTrackeeApi from '../fitTrackeeApi/user'
import { history } from '../index'
import { generateIds } from '../utils'
import { getData } from './index'
@ -36,7 +36,7 @@ export const updateProfileFormData = (target, value) => ({
value,
})
export const getProfile = () => dispatch => mpwoApiUser
export const getProfile = () => dispatch => FitTrackeeApi
.getProfile()
.then(ret => {
if (ret.status === 'success') {
@ -50,7 +50,7 @@ export const getProfile = () => dispatch => mpwoApiUser
})
export const register = formData => dispatch => mpwoApiUser
export const register = formData => dispatch => FitTrackeeApi
.register(
formData.username,
formData.email,
@ -68,7 +68,7 @@ export const register = formData => dispatch => mpwoApiUser
})
export const login = formData => dispatch => mpwoApiUser
export const login = formData => dispatch => FitTrackeeApi
.login(formData.email, formData.password)
.then(ret => {
if (ret.status === 'success') {
@ -137,7 +137,7 @@ export const handleProfileFormSubmit = event => (dispatch, getState) => {
'Password and password confirmation don\'t match.'
))
}
return mpwoApiUser
return FitTrackeeApi
.updateProfile(state.formProfile.formProfile)
.then(ret => {
if (ret.status === 'success') {
@ -156,7 +156,7 @@ export const uploadPicture = event => dispatch => {
const form = new FormData()
form.append('file', event.target.picture.files[0])
event.target.reset()
return mpwoApiUser
return FitTrackeeApi
.updatePicture(form)
.then(ret => {
if (ret.status === 'success') {
@ -169,7 +169,7 @@ export const uploadPicture = event => dispatch => {
})
}
export const deletePicture = () => dispatch => mpwoApiUser
export const deletePicture = () => dispatch => FitTrackeeApi
.deletePicture()
.then(ret => {
if (ret.status === 'success') {

View File

@ -27,7 +27,7 @@ class ActivityAddEdit extends React.Component {
return (
<div>
<Helmet>
<title>mpwo - {activity
<title>FitTrackee - {activity
? 'Edit a workout'
: 'Add a workout'}
</title>

View File

@ -45,7 +45,7 @@ class ActivityDisplay extends React.Component {
return (
<div className="activity-page">
<Helmet>
<title>mpwo - {title}</title>
<title>FitTrackee - {title}</title>
</Helmet>
{message ? (
<code>{message}</code>

View File

@ -13,7 +13,7 @@ function Activity () {
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
<title>FitTrackee - Admin</title>
</Helmet>
{isLoggedIn() ? (
<Switch>

View File

@ -6,7 +6,7 @@ export default function AdminMenu () {
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
<title>FitTrackee - Admin - Sports</title>
</Helmet>
<h1 className="page-title">Administration</h1>
<div className="container">

View File

@ -14,7 +14,7 @@ class AdminSportsAdd extends React.Component {
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
<title>FitTrackee - Admin - Add Sport</title>
</Helmet>
<h1 className="page-title">
Administration - Sport

View File

@ -28,7 +28,7 @@ class AdminDetail extends React.Component {
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
<title>FitTrackee - Admin</title>
</Helmet>
<h1 className="page-title">
Administration - {title}

View File

@ -20,7 +20,7 @@ export default function AdminPage(props) {
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
<title>FitTrackee - Admin</title>
</Helmet>
<h1 className="page-title">
Administration - {title}

View File

@ -16,7 +16,7 @@ function Admin (props) {
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
<title>FitTrackee - Admin</title>
</Helmet>
{isLoggedIn() ? (
user.isAdmin ? (

View File

@ -13,7 +13,7 @@ export default function UserStatistics (props) {
</div>
<div className="col-9 text-right">
<div className="huge">{user.nbActivities}</div>
<div>{`workout${user.nbActivities !== 1 && 's'}`}</div>
<div>{`workout${user.nbActivities === 1 ? '' : 's'}`}</div>
</div>
</div>
</div>

View File

@ -34,7 +34,7 @@ class DashBoard extends React.Component {
return (
<div>
<Helmet>
<title>mpwo - Dashboard</title>
<title>FitTrackee - Dashboard</title>
</Helmet>
{message ? (
<code>{message}</code>

View File

@ -10,7 +10,7 @@ function NavBar(props) {
<header>
<nav className="navbar navbar-expand-lg navbar-light bg-light">
<div className="container">
<span className="navbar-brand">mpwo</span>
<span className="navbar-brand">FitTrackee</span>
<button
className="navbar-toggler"
type="button"

View File

@ -5,7 +5,7 @@ export default function AccessDenied () {
return (
<div>
<Helmet>
<title>mpwo - Access denied</title>
<title>FitTrackee - Access denied</title>
</Helmet>
<h1 className="page-title">Access denied</h1>
<p className="App-center">

View File

@ -5,7 +5,7 @@ export default function NotFound () {
return (
<div>
<Helmet>
<title>mpwo - 404</title>
<title>fittrackee - 404</title>
</Helmet>
<h1 className="page-title">Page not found</h1>
</div>

View File

@ -5,7 +5,7 @@ export default function Form (props) {
return (
<div>
<Helmet>
<title>mpwo - {props.formType}</title>
<title>FitTrackee - {props.formType}</title>
</Helmet>
<h1 className="page-title">{props.formType}</h1>
<div className="container">

View File

@ -11,7 +11,7 @@ function Profile ({ message, onDeletePicture, onUploadPicture, user }) {
return (
<div>
<Helmet>
<title>mpwo - {user.username} - Profile</title>
<title>FitTrackee - {user.username} - Profile</title>
</Helmet>
{ message !== '' && (
<code>{message}</code>

View File

@ -24,7 +24,7 @@ class ProfileEdit extends React.Component {
return (
<div>
<Helmet>
<title>mpwo - {user.username} - Edit Profile</title>
<title>FitTrackee - {user.username} - Edit Profile</title>
</Helmet>
{ message !== '' && (
<code>{message}</code>

View File

@ -1,6 +1,6 @@
import { apiUrl, createRequest } from '../utils'
export default class MpwoApi {
export default class FitTrackeeApi {
static addActivity(formData) {
const params = {

View File

@ -1,6 +1,6 @@
import { apiUrl, createRequest } from '../utils'
export default class MpwoApi {
export default class FitTrackeeApi {
static getData(target,
data = {}) {

View File

@ -1,6 +1,6 @@
import { apiUrl, createRequest } from '../utils'
export default class MpwoApi {
export default class FitTrackeeApi {
static getStats(userID, type, data = {}) {
let url = `${apiUrl}stats/${userID}/${type}`

View File

@ -1,6 +1,6 @@
import { apiUrl, createRequest } from '../utils'
export default class MpwoApiUser {
export default class FitTrackeeApi {
static login(email, password) {
const params = {

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,4 +0,0 @@
{
"name": "mpwo_client",
"version": "0.1.0"
}

View File

@ -3,7 +3,7 @@ server {
listen 80;
location / {
proxy_pass http://mpwo-client:3000;
proxy_pass http://fittrackee-client:3000;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@ -12,7 +12,7 @@ server {
}
location /api {
proxy_pass http://mpwo-api:5000;
proxy_pass http://fittrackee-api:5000;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "mpwo_client",
"name": "fittrackee_client",
"version": "0.1.0",
"lockfileVersion": 1,
"requires": true,

View File

@ -1,5 +1,5 @@
{
"name": "mpwo_client",
"name": "fittrackee_client",
"version": "0.1.0",
"private": true,
"dependencies": {
@ -22,11 +22,11 @@
"redux-thunk": "^2.2.0"
},
"scripts": {
"start": "cd mpwo_client && react-scripts start",
"build": "cd mpwo_client && react-scripts build",
"test": "cd mpwo_client && testcafe firefox e2e",
"eject": "cd mpwo_client && react-scripts eject",
"lint": "eslint --cache --ext .jsx --ext .js mpwo_client/src"
"start": "cd fittrackee_client && react-scripts start",
"build": "cd fittrackee_client && react-scripts build",
"test": "cd fittrackee_client && testcafe firefox e2e",
"eject": "cd fittrackee_client && react-scripts eject",
"lint": "eslint --cache --ext .jsx --ext .js fittrackee_client/src"
},
"devDependencies": {
"babel-eslint": "^8.2.3",

View File

@ -1,2 +1,2 @@
[pytest]
norecursedirs = mpwo_api/venv
norecursedirs = fittrackee_api/venv

View File

@ -8,13 +8,13 @@ inspect() {
fi
}
docker-compose -f docker-compose-ci.yml run mpwo-api py.test mpwo_api
docker-compose -f docker-compose-ci.yml run fittrackee-api py.test fittrackee_api
inspect $? api
docker-compose -f docker-compose-ci.yml run mpwo-api flask db upgrade
docker-compose -f docker-compose-ci.yml run mpwo-api flask init_data
docker-compose -f docker-compose-ci.yml run fittrackee-api flask db upgrade
docker-compose -f docker-compose-ci.yml run fittrackee-api flask init_data
testcafe chrome mpwo_client/e2e
testcafe chrome fittrackee_client/e2e
inspect $? e2e
if [ -n "${fails}" ];