Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New sample based on chinook.db and React UI #185

Open
wants to merge 80 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e33a455
creating cds model of chinook db
dimaanj Sep 29, 2020
e7be207
add cli tool
dimaanj Sep 30, 2020
7a0e8fd
remove redundantt folder
dimaanj Oct 1, 2020
fc07f7e
remove redundantt folder
dimaanj Oct 1, 2020
e58ad84
add reorder for column names
dimaanj Oct 1, 2020
4783a57
add tests. add to many associations
dimaanj Oct 3, 2020
41da47a
adjast regex for omiting id from column name
dimaanj Oct 3, 2020
d796bf1
remove redundant args
dimaanj Oct 3, 2020
0f64445
return timeout for mocha runner
dimaanj Oct 3, 2020
bdbd9d4
add tracks main page. add get my tracks action
dimaanj Oct 8, 2020
99d4da3
adjust README.md with frontend repo link provided
Oct 8, 2020
a917dac
add getMyTracks option
dimaanj Oct 13, 2020
ae05e8a
remove compiled bundles from app
dimaanj Oct 13, 2020
937d9ca
add app bundles to medi-store
dimaanj Oct 13, 2020
49f6b8c
add mocked auth
dimaanj Oct 14, 2020
0690762
add invoice action
dimaanj Oct 17, 2020
30d5c78
add getUser method
dimaanj Oct 19, 2020
49b8f4e
reaname services
dimaanj Oct 23, 2020
9a63f40
rename person type
dimaanj Oct 23, 2020
52f00c6
add status to invoices
dimaanj Oct 27, 2020
a319199
add cancel invoice action
dimaanj Oct 29, 2020
bcfce87
add customer restriction when browsing invoices
dimaanj Oct 30, 2020
3cf02cb
refactor import usage. refactor invoices implementation
dimaanj Nov 3, 2020
70b0c85
add custom authentication checks
dimaanj Nov 4, 2020
34acef8
refactoring requests
dimaanj Nov 4, 2020
ecdc32b
replacing restriction conditions
dimaanj Nov 4, 2020
e08b1c6
refactoring code
dimaanj Nov 5, 2020
c932b48
add compositions for cascade delete
dimaanj Nov 6, 2020
3d1502d
return bool flag
Nov 9, 2020
fdd2a7a
providing initial data. replacing bycript with bycriptjs
dimaanj Nov 11, 2020
29fb47f
add dev only things
Nov 11, 2020
25bdc0a
refactor csv data
Nov 11, 2020
05550a1
add frontend code. add deploy config
Nov 14, 2020
7045914
add env vars. change db kind
dimaanj Nov 14, 2020
185e6b9
change invoiceDate impl
dimaanj Nov 16, 2020
d78e759
add hana kind
dimaanj Nov 16, 2020
4b4fe2d
refactoring user settings in the frontend
dimaanj Nov 16, 2020
76cbf7f
add flow when invalid credentials
dimaanj Nov 16, 2020
938abb6
add response interceptors for refreshTokens method
dimaanj Nov 23, 2020
3d17623
refactoring error page
dimaanj Nov 24, 2020
6454019
now create tracks method works properly
dimaanj Nov 24, 2020
58af187
clean up things
dimaanj Nov 24, 2020
fe0562f
edit person page. remove invoicedItems on logout
dimaanj Nov 25, 2020
f439119
change readme.md. clean up console.logs. add check for exsisting invo…
dimaanj Nov 25, 2020
d9b6079
changing logger
dimaanj Nov 25, 2020
029ba61
changing invoice request
Nov 25, 2020
a04cc0c
changing tests. removing importData func
dimaanj Nov 25, 2020
90fc300
add .mta files to gitignore
dimaanj Nov 25, 2020
0e86e1e
change token live time
Nov 25, 2020
dbe4b8a
moving front app to subfolder. add webpack config with watch and dev-…
dimaanj Nov 29, 2020
00474ed
add app to gitignore
dimaanj Nov 29, 2020
ee63541
change gitignore. change server.js
dimaanj Nov 29, 2020
64cc4ec
move xs-securiry.json
dimaanj Nov 29, 2020
723bd93
change readme.md
dimaanj Nov 30, 2020
de04a89
changing cds services
dimaanj Nov 30, 2020
d3d4b32
change readme.md. add folders description
dimaanj Nov 30, 2020
fcd1bf9
change words to lowwer case in readme.md
dimaanj Nov 30, 2020
bebc18a
changing endings
dimaanj Nov 30, 2020
4ebc20f
changing readme.md style
dimaanj Nov 30, 2020
1dd1863
changing webpack-dev-server-config
dimaanj Nov 30, 2020
09dd526
remove unnecessary assosiation. add /index.html route to main page
dimaanj Dec 3, 2020
b3ea0cc
add retry interceptor impl
dimaanj Dec 6, 2020
fc41981
resolve quotation mark error when searching
dimaanj Dec 6, 2020
72616ae
changing retry number. add readme.md point
dimaanj Dec 7, 2020
aeafb1d
change invoice action impl. changing .http sample file
dimaanj Dec 8, 2020
145becb
change retry count
dimaanj Dec 9, 2020
cb71e2e
update tests
dimaanj Dec 14, 2020
317d450
change tests
dimaanj Dec 15, 2020
ef0f5be
Cleanup folder layout
danjoa Dec 16, 2020
5cec82f
re-including app folder
danjoa Dec 16, 2020
69e510a
Moved to chinook + added .env
danjoa Dec 16, 2020
4fd0b74
change folders structure
dimaanj Dec 22, 2020
a45d79e
change tests
dimaanj Dec 23, 2020
9d28ca9
changing chinook sql kind property to sql
dimaanj Dec 23, 2020
9abeb67
returning subfolders names
dimaanj Dec 23, 2020
193e762
returning package.json dependencies
dimaanj Dec 23, 2020
1c9a244
change jest timeout. add @capire/chinook as dependency
dimaanj Dec 23, 2020
4816028
changing package.json scripts. adjusting mock datetime format
dimaanj Dec 24, 2020
fe52eec
add right datetime format
dimaanj Dec 24, 2020
67b845c
simplified setup
danjoa Jan 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions chinook/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# REVISIT: This is not a good practice -> don't do it that way, we just did it to save some time :)
ACCESS_TOKEN_SECRET=secret
REFRESH_TOKEN_SECRET=refresh-secret
35 changes: 35 additions & 0 deletions chinook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# CAP media-store
_out
*.db
connection.properties
default-*.json
gen/
node_modules/
target/
package-lock.json
app/build

# html5Deployer
app/deployers/html5Deployer/resources/

# Web IDE, App Studio
.che/
.gen/

# MTA
*_mta_build_tmp
*.mtar
*.mta
mta_archives/

# Other
.DS_Store
*.orig
*.log

*.iml
*.flattened-pom.xml

# IDEs
# .vscode
# .idea
20 changes: 20 additions & 0 deletions chinook/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
// >>>>>>>> Add CDS Editor here as soon it is available of vscode marketplace!,
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"mechatroner.rainbow-csv",
"humao.rest-client",
"alexcvzz.vscode-sqlite",
"hbenl.vscode-mocha-test-adapter",
"sdras.night-owl"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [

]
}
17 changes: 17 additions & 0 deletions chinook/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


{
"command": "cds run --with-mocks --in-memory?",
"name": "cds run",
"request": "launch",
"type": "node-terminal",
"skipFiles": ["<node_internals>/**"]
}
]
}
8 changes: 8 additions & 0 deletions chinook/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.exclude": {
"**/.gitignore": true,
"**/.git": true,
"**/.vscode": true
},
"files.watcherExclude": {}
}
25 changes: 25 additions & 0 deletions chinook/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cds watch",
"command": "cds",
"args": ["watch"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"type": "shell",
"label": "cds run",
"command": "cds",
"args": ["run", "--with-mocks", "--in-memory?"],
"problemMatcher": []
}
]
}
96 changes: 96 additions & 0 deletions chinook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Getting Started

Welcome to your new project.

It contains these folders and files, following our recommended project layout:

| File or Folder | Purpose |
| ---------------- | ------------------------------------ |
| `app/` | will contain compiled front bundles |
| `app/front/` | contains frontend app on react |
| `app/deployers/` | contains deployment stuff |
| `db/` | your domain models and data go here |
| `srv/` | your service models and code go here |
| `test/` | your services tests |
| `package.json` | project metadata and configuration |
| `mta.yaml` | deployment config |
| `readme.md` | this getting started guide |
| `server.js` | initial server set up |

## Development

- Start cds service on 4004 port in watch mode:

```json
cds watch
```

- Open `app/front` folder and run next commands. This will install dependencies and run frontend src files watcher. When you will change src files your bundles in app directory will re-compiled. Now you can enjoy development:

```json
npm install
npm run watch
```

> For better frontend development experience use below command instead of watcher. This will start frontend dev server on 3000 port. Now your bundles will be hot reloaded, this means you do not need reload the page to see changes:
>
> ```json
> npm run start
> ```

## Test

- Change package.json db section

```json
"db": {
"kind": "sql"
}
```

- Run tests

```json
npm run test
```

## Deployment

- Make sure you already have hana trial instance in your cockpit dashboard (SAP Cloud Platform).
Or if you are using hana instance - change it in mta.yaml config file from hanatrial to hana
- Change package.json db section

```json
"db": {
"kind": "hana"
}
```

- Authenticate to the Cloud Foundry:

```json
cf login
```

- Open `app/front` folder and run the following commands. This will create frontend production bundles in app subfolder:

```json
npm install
npm run build:prod
```

- Clean up app/deployers/html5Deployer/resources folder from the previous frontend build

- From root directory run:

```json
mbt build -t ./
cf deploy media-store_1.0.0.mtar
```

- Now your services should be deployed with hanatrial instance and filled with initial data

## Learn More

- [Learn more about CAP](https://cap.cloud.sap/docs/get-started/)
- [Deploying to Cloud Foundry](https://cap.cloud.sap/docs/advanced/deploy-to-cloud)
11 changes: 11 additions & 0 deletions chinook/app/deployers/approuter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "media-store-approuter",
"description": "Approuter",
"version": "1.0.0",
"dependencies": {
"@sap/approuter": "^6.8.2"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
}
}
17 changes: 17 additions & 0 deletions chinook/app/deployers/approuter/xs-app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"welcomeFile": "/index.html",
"authenticationMethod": "none",
"routes": [
{
"source": "/api/(.*)",
"target": "$1",
"destination": "srv-binding",
"authenticationType": "none"
},
{
"source": "^(.*)",
"target": "mediastore/$1",
"service": "html5-apps-repo-rt"
}
]
}
12 changes: 12 additions & 0 deletions chinook/app/deployers/html5Deployer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "media-store-html5deployer",
"engines": {
"node": ">=6.0.0"
},
"dependencies": {
"@sap/html5-app-deployer": "^2.0.0"
},
"scripts": {
"start": "node node_modules/@sap/html5-app-deployer/index.js"
}
}
7 changes: 7 additions & 0 deletions chinook/app/deployers/xs-security.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"xsappname": "media-store-xsuaa",
"tenant-mode": "dedicated",
"scopes": [],
"attributes": [],
"role-templates": []
}
5 changes: 5 additions & 0 deletions chinook/app/front/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": ["@babel/preset-react", "@babel/preset-env"],
"plugins": ["@babel/plugin-transform-runtime", "babel-plugin-syntax-dynamic-import"]
}

43 changes: 43 additions & 0 deletions chinook/app/front/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"env": {
"browser": true,
"es2020": true
},
"extends": ["plugin:react/recommended", "airbnb", "prettier"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": ["react", "prettier"],
"rules": {
"prettier/prettier": ["error", { "parser": "flow", "endOfLine": "auto" }],
"linebreak-style": [0, "error", "windows"],
"import/prefer-default-export": "off",
"no-shadow": "off",
"react/forbid-prop-types": "off",
"no-alert": "off",
"jsx-a11y/label-has-associated-control": [
"error",
{
"required": {
"some": ["nesting", "id"]
}
}
],
"jsx-a11y/label-has-for": [
"error",
{
"required": {
"some": ["nesting", "id"]
}
}
],
"react/jsx-props-no-spreading": "off", // props spreading,
"no-console": "off",
"consistent-return": "off",
"prefer-destructuring": "off"
}
}
23 changes: 23 additions & 0 deletions chinook/app/front/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
4 changes: 4 additions & 0 deletions chinook/app/front/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 100,
"singleQuote": true
}
13 changes: 13 additions & 0 deletions chinook/app/front/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

{
"version": "0.2.0",
"configurations": [
{
"name": "Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/src"
}
]
}
1 change: 1 addition & 0 deletions chinook/app/front/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"# Media store UI"
Loading