Skip to content

Commit 26c2323

Browse files
feat: add petclinic app to the repo (#59)
* feat: add spring petclinic app Signed-off-by: Pranshu Srivastava <[email protected]> * fix: moved the port to 9966 Signed-off-by: Pranshu Srivastava <[email protected]> --------- Signed-off-by: Pranshu Srivastava <[email protected]>
1 parent 916db9e commit 26c2323

File tree

482 files changed

+119915
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

482 files changed

+119915
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": [
4+
"projects/**/*"
5+
],
6+
"overrides": [
7+
{
8+
"files": [
9+
"*.ts"
10+
],
11+
"parserOptions": {
12+
"project": [
13+
"tsconfig.json",
14+
"e2e/tsconfig.json"
15+
],
16+
"createDefaultProgram": true
17+
},
18+
"extends": [
19+
"plugin:@angular-eslint/recommended",
20+
"plugin:@angular-eslint/template/process-inline-templates"
21+
],
22+
"plugins": [
23+
"@typescript-eslint"
24+
],
25+
"rules": {
26+
"@angular-eslint/component-selector": [
27+
"error",
28+
{
29+
"prefix": "app",
30+
"style": "kebab-case",
31+
"type": "element"
32+
}
33+
],
34+
"@angular-eslint/directive-selector": [
35+
"error",
36+
{
37+
"prefix": "app",
38+
"style": "camelCase",
39+
"type": "attribute"
40+
}
41+
],
42+
// Note: you must disable the base rule as it can report incorrect errors
43+
"quotes": "off",
44+
"@typescript-eslint/quotes": [
45+
"error",
46+
"single",
47+
{
48+
"allowTemplateLiterals": true
49+
}
50+
],
51+
"@angular-eslint/no-empty-lifecycle-method": "off"
52+
}
53+
},
54+
{
55+
"files": [
56+
"*.html"
57+
],
58+
"extends": [
59+
"plugin:@angular-eslint/template/recommended"
60+
]
61+
}
62+
]
63+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
8+
# dependencies
9+
/node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.angular/cache
29+
/.sass-cache
30+
/connect.lock
31+
/coverage
32+
/libpeerconnection.log
33+
npm-debug.log
34+
testem.log
35+
/typings
36+
37+
# e2e
38+
/e2e/*.js
39+
/e2e/*.map
40+
41+
# System Files
42+
.DS_Store
43+
Thumbs.db
44+
*.iml
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
ARG DOCKER_HUB="docker.io"
2+
ARG NGINX_VERSION="1.17.6"
3+
ARG NODE_VERSION="16.3-alpine"
4+
5+
FROM $DOCKER_HUB/library/node:$NODE_VERSION as build
6+
7+
8+
COPY . /workspace/
9+
10+
ARG NPM_REGISTRY=" https://registry.npmjs.org"
11+
12+
RUN echo "registry = \"$NPM_REGISTRY\"" > /workspace/.npmrc && \
13+
cd /workspace/ && \
14+
npm install && \
15+
npm run build
16+
17+
FROM $DOCKER_HUB/library/nginx:$NGINX_VERSION AS runtime
18+
19+
20+
COPY --from=build /workspace/dist/ /usr/share/nginx/html/
21+
22+
RUN chmod a+rwx /var/cache/nginx /var/run /var/log/nginx && \
23+
sed -i.bak 's/listen\(.*\)80;/listen 8080;/' /etc/nginx/conf.d/default.conf && \
24+
sed -i.bak 's/^user/#user/' /etc/nginx/nginx.conf
25+
26+
27+
EXPOSE 8080
28+
29+
USER nginx
30+
31+
HEALTHCHECK CMD [ "service", "nginx", "status" ]
32+
33+
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Spring Petclinic Angular
2+
3+
[![Build Status](https://github.com/spring-petclinic/spring-petclinic-angular/actions/workflows/angular-ci.yml/badge.svg)](https://github.com/spring-petclinic/spring-petclinic-angular/actions/workflows/angular-ci.yml)
4+
5+
## Angular frontend for Spring Petclinic
6+
7+
Warning: **client only**.
8+
Use REST API from backend [spring-petclinic-rest project](https://github.com/spring-petclinic/spring-petclinic-rest)
9+
You need start backend server before start frontend application.
10+
11+
## Screenshot
12+
13+
![Screenshot of SPring Petclinic Angular](https://cloud.githubusercontent.com/assets/838318/23263243/f4509c4a-f9dd-11e6-951b-69d0ef72d8bd.png)
14+
15+
16+
## Installation
17+
18+
1. Update angular-cli to latest version (8.0.3 current)
19+
as described on [angular-cli github readme.md](https://github.com/angular/angular-cli#updating-angular-cli)
20+
21+
````
22+
npm uninstall -g angular-cli @angular/cli
23+
npm cache clean
24+
npm install -g @angular/cli@latest
25+
````
26+
Clone project from github
27+
````
28+
git clone https://github.com/spring-petclinic/spring-petclinic-angular.git
29+
````
30+
Install local project package
31+
````
32+
npm install --save-dev @angular/cli@latest
33+
if npm version > 5.0 delete package-lock.json file ( bug in npm 5.0 - this file prevent correct packages install)
34+
npm install
35+
````
36+
37+
Now project use Angular CLI v.8.0.3 and Angular v.8.0.1
38+
You can see current dependencies in [package.json](package.json) file.
39+
40+
## Development server
41+
42+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
43+
44+
## Code scaffolding
45+
46+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`.
47+
48+
## Build
49+
50+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
51+
52+
You can also build the application in a dedicated docker image using the provided `Dockerfile` as follows:
53+
54+
```
55+
docker build -t spring-petclinic-angular:latest .
56+
```
57+
58+
Then you will be able to use it as follows:
59+
60+
```
61+
docker run --rm -p 8080:8080 spring-petclinic-angular:latest
62+
```
63+
64+
## Documentation
65+
66+
The documentation of the Spring Petclinic Angular application is generated by the [compodoc](https://compodoc.app) tool.
67+
68+
Documentation URL: [https://spring-petclinic.github.io/spring-petclinic-angular/](https://spring-petclinic.github.io/spring-petclinic-angular/)
69+
70+
Regenerate the `docs` folder with [compodoc](https://compodoc.app):
71+
```
72+
compodoc -p src/tsconfig.app.json -d docs
73+
```
74+
75+
## Deploy on Web servers
76+
77+
### Deploy on Nginx (for Nginx CentOS installation):
78+
79+
1. Build Angular application:
80+
81+
ng build --prod --base-href=/petclinic/ --deploy-url=/petclinic/
82+
83+
2. Create sub-directory **/petclinic** in default nginx directory **/usr/share/nginx/html**
84+
85+
3. Copy **/dist** sub-directory from Angular appication to **/usr/share/nginx/html/petclinic**
86+
87+
4. Edit nginx config (nginx.conf file in /etc/nginx/ directory)
88+
89+
```
90+
server {
91+
listen 80 default_server;
92+
root /usr/share/nginx/html;
93+
index index.html;
94+
95+
location /petclinic/ {
96+
alias /usr/share/nginx/html/petclinic/dist/;
97+
try_files $uri$args $uri$args/ /petclinic/index.html;
98+
}
99+
}
100+
```
101+
102+
5. Reload nginx: **nginx -s reload**
103+
104+
6. Run app in brouser: http://server_name/petclinic/
105+
106+
### Deploy on Apache (for Apache CentOS installation):
107+
108+
1. Build Angular application:
109+
110+
ng build --prod --base-href=/petclinic/ --deploy-url=/petclinic/
111+
112+
2. Create sub-directory **/petclinic** in default Apache directory **/var/www/html**
113+
114+
3. Go into Angular appication **/dist** sub-directory and copy all files and sub-dirs from it to **/var/www/html/petclinic**
115+
116+
4. Edit Apache config (/etc/https/conf/httpd.conf):
117+
118+
sudo vi /etc/httpd/conf/httpd.conf
119+
120+
Find the Directory /var/www/html> section and change the AllowOverride directive from None to All:
121+
```
122+
/etc/httpd/conf/httpd.conf
123+
. . .
124+
<Directory /var/www/html>
125+
. . .
126+
#
127+
# AllowOverride controls what directives may be placed in .htaccess files.
128+
# It can be "All", "None", or any combination of the keywords:
129+
# Options FileInfo AuthConfig Limit
130+
#
131+
AllowOverride All
132+
. . .
133+
</Directory>
134+
. . .
135+
```
136+
5. Save and exit the file and then restart Apache to apply the change:
137+
138+
sudo systemctl restart httpd
139+
140+
6. Create a .htaccess file in the directory **/var/www/html/petclinic**
141+
142+
sudo vi /var/www/html/petclinic/.htaccess
143+
144+
Add the following line to the top of the file to activate the RewriteEngine, which instructs Apache to process any rules that follow:
145+
```
146+
RewriteEngine On
147+
# If an existing asset or directory is requested go to it as it is
148+
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
149+
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
150+
RewriteRule ^ - [L]
151+
152+
# If the requested resource doesn't exist, use index.html
153+
RewriteRule ^ index.html
154+
```
155+
7. Reload Apache:
156+
157+
sudo systemctl restart httpd
158+
159+
8. Run app in browser: http://server_name/petclinic/
160+
161+
## Running unit tests
162+
163+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
164+
165+
## Running end-to-end tests
166+
167+
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
168+
Before running the tests make sure you are serving the app via `ng serve`.
169+
170+
## Further help
171+
172+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

0 commit comments

Comments
 (0)