Coder Social home page Coder Social logo

spring-petclinic / spring-petclinic-angular Goto Github PK

View Code? Open in Web Editor NEW
196.0 17.0 476.0 5.36 MB

Angular 16 version of the Spring Petclinic sample application (frontend)

TypeScript 66.44% JavaScript 0.72% CSS 5.08% HTML 24.00% Dockerfile 0.36% Less 3.40%
spring sample angular angular-cli frontend rest hacktoberfest angular16

spring-petclinic-angular's Introduction

Spring Petclinic Angular

Build Status

Angular frontend for Spring Petclinic

Warning: client only. Use REST API from backend spring-petclinic-rest project You need start backend server before start frontend application.

Screenshot

Screenshot of SPring Petclinic Angular

Installation

  1. Update angular-cli to latest version (8.0.3 current) as described on angular-cli github readme.md
npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli@latest

Clone project from github

git clone https://github.com/spring-petclinic/spring-petclinic-angular.git

Install local project package

npm install --save-dev @angular/cli@latest
if npm version > 5.0 delete package-lock.json file  ( bug in npm 5.0 - this file prevent correct packages install)
npm install

Now project use Angular CLI v.8.0.3 and Angular v.8.0.1 You can see current dependencies in package.json file.

Development server

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.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|module.

Build

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.

You can also build the application in a dedicated docker image using the provided Dockerfile as follows:

docker build -t spring-petclinic-angular:latest .

Then you will be able to use it as follows:

docker run --rm -p 8080:8080 spring-petclinic-angular:latest

Documentation

The documentation of the Spring Petclinic Angular application is generated by the compodoc tool.

Documentation URL: https://spring-petclinic.github.io/spring-petclinic-angular/

Regenerate the docs folder with compodoc:

compodoc -p src/tsconfig.app.json -d docs

Deploy on Web servers

Deploy on Nginx (for Nginx CentOS installation):

  1. Build Angular application:

ng build --prod --base-href=/petclinic/ --deploy-url=/petclinic/

  1. Create sub-directory /petclinic in default nginx directory /usr/share/nginx/html

  2. Copy /dist sub-directory from Angular appication to /usr/share/nginx/html/petclinic

  3. Edit nginx config (nginx.conf file in /etc/nginx/ directory)

server {
	listen       80 default_server;
        root         /usr/share/nginx/html;
        index index.html;

	location /petclinic/ {
                alias /usr/share/nginx/html/petclinic/dist/;
                try_files $uri$args $uri$args/ /petclinic/index.html;
        }
}
  1. Reload nginx: nginx -s reload

  2. Run app in brouser: http://server_name/petclinic/

Deploy on Apache (for Apache CentOS installation):

  1. Build Angular application:

ng build --prod --base-href=/petclinic/ --deploy-url=/petclinic/

  1. Create sub-directory /petclinic in default Apache directory /var/www/html

  2. Go into Angular appication /dist sub-directory and copy all files and sub-dirs from it to /var/www/html/petclinic

  3. Edit Apache config (/etc/https/conf/httpd.conf):

sudo vi /etc/httpd/conf/httpd.conf

Find the Directory /var/www/html> section and change the AllowOverride directive from None to All:

 /etc/httpd/conf/httpd.conf
 . . .
  <Directory /var/www/html>
 . . .
 # 
 # AllowOverride controls what directives may be placed in .htaccess files.
 # It can be "All", "None", or any combination of the keywords:
 # Options FileInfo AuthConfig Limit
 #
 AllowOverride All
 . . .
 </Directory>
 . . .
  1. Save and exit the file and then restart Apache to apply the change:

sudo systemctl restart httpd

  1. Create a .htaccess file in the directory /var/www/html/petclinic

sudo vi /var/www/html/petclinic/.htaccess

Add the following line to the top of the file to activate the RewriteEngine, which instructs Apache to process any rules that follow:

RewriteEngine On  
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]  
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d  
RewriteRule ^ - [L]

# If the requested resource doesn't exist, use index.html
RewriteRule ^ index.html  
  1. Reload Apache:

sudo systemctl restart httpd

  1. Run app in browser: http://server_name/petclinic/

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor. Before running the tests make sure you are serving the app via ng serve.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

spring-petclinic-angular's People

Contributors

angular-cli avatar arey avatar bondar-artem avatar cary205 avatar dariusdv avatar dependabot[bot] avatar fllaca avatar sdstolworthy avatar simrin051 avatar vfedoriv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-petclinic-angular's Issues

angular-cli with latest version (12.1.2) does not work

I followed the steps and after running "http://localhost:4200/", I got the error "Cannot GET /" with status "404 Not Found".
After I changed to angular-cli with version 8.0.3, the project run as expected.

Detailed error message:

Error: undefined:9274:12: @keyframes missing name

assets/less/petclinic.less - Error: assets/less/petclinic.less from Css Minimizer 
/home/projects/spring-petclinic-angular/assets/less/petclinic.less:162:37: Unknown word
You tried to parse Less with the standard CSS parser; try again with the postcss-less parser [assets/less/petclinic.less:162,37]
You tried to parse Less with the standard CSS parser; try again with the postcss-less parser
    at Input.error (/home/projects/spring-petclinic-angular/node_modules/postcss/lib/input.js:123:16)
    at Parser.unknownWord (/home/projects/spring-petclinic-angular/node_modules/postcss/lib/parser.js:518:22)
    at Parser.other (/home/projects/spring-petclinic-angular/node_modules/postcss/lib/parser.js:149:12)
    at Parser.parse (/home/projects/spring-petclinic-angular/node_modules/postcss/lib/parser.js:59:16)
    at parse (/home/projects/spring-petclinic-angular/node_modules/postcss/lib/parse.js:11:12)
    at new LazyResult (/home/projects/spring-petclinic-angular/node_modules/postcss/lib/lazy-result.js:133:16)
    at Processor.process (/home/projects/spring-petclinic-angular/node_modules/postcss/lib/processor.js:36:12)
    at cssnanoMinify (/home/projects/spring-petclinic-angular/node_modules/css-minimizer-webpack-plugin/dist/utils.js:58:61)
    at minify (/home/projects/spring-petclinic-angular/node_modules/css-minimizer-webpack-plugin/dist/minify.js:15:32)
    at /home/projects/spring-petclinic-angular/node_modules/css-minimizer-webpack-plugin/dist/index.js:262:128

Create a Vue.js fork

An Angular version and a React version of Spring Petclinic exist. We are looking some contributors to develop a Vue.js version. Please let me know.

Angular 11 upgrade

Upgrade from Angular 8 to Angular 11
Feel free to work on this enhancement then submit a Pull Request.

Angular 6 migration

With the last Angular CLI 6.1.5, the ng serve is failing:

Local workspace file ('angular.json') could not be found.

The migration to Angular CLI 6 and Angular 6 has some impact:

I began to work on this upgrade. You may check the feature/angular6 branch: https://github.com/arey/spring-petclinic-angular2/tree/feature/angular6

Images request doesn't take intro consideration base href

I have a problem when creating the bundle for it to be deployed on a HTTP server.

The index.html page is located at: http://localhost:63342/spring-petclinic-angular/dist/index.html
The request to all js files is sent relative to this url setting the base href to ./
The request to the images files is sent to
http://localhost:63342/assets/images/angular.png

Notice the relative path is not used.

To make the bundle I am using the following commands:
ng build --prod --base-href=./ --deploy-url=./

Security vulnerability in handlebars

Notification sent by GitHub:

Known moderate severity security vulnerability detected in handlebars < 4.0.0defined in package-lock.json.package-lock.json update suggested: handlebars ~> 4.0.0.Always verify the validity and compatibility of suggestions with your codebase. | Known moderate severity security vulnerability detected in handlebars < 4.0.0defined in package-lock.json. | package-lock.json update suggested: handlebars ~> 4.0.0. | Always verify the validity and compatibility of suggestions with your codebase.
Known moderate severity security vulnerability detected in handlebars < 4.0.0defined in package-lock.json.
package-lock.json update suggested: handlebars ~> 4.0.0.
Always verify the validity and compatibility of suggestions with your codebase.

Review vulnerable dependencies

Some tests not work

2 tests:
OwnerListComponent should call ngOnInit() method
OwnerListComponent should show full name after getOwners observable (async)
not work

ERROR in AppModule is not an NgModule

f:\Java\projects\learning\spring-petclinic-angular>npm ls typescript [email protected] f:\Java\projects\learning\spring-petclinic-angular +-- @angular/[email protected] -> f:\Java\projects\learning\spring-petclinic-angular\node_modules\_@[email protected]@@angular\cli | +-- @ngtools/[email protected] | | -- [email protected] extraneous
| -- [email protected] -- [email protected] -> f:\Java\projects\learning\spring-petclinic-angular\node_modules_typescript@2.3.3@typescript extraneous

npm ERR! extraneous: [email protected] f:\Java\projects\learning\spring-petclinic-angular\node_modules\typescript
npm ERR! extraneous: [email protected] f:\Java\projects\learning\spring-petclinic-angular\node_modules@ngtools\webpack\node_modules\typescript`

我需要把package.json里的dependencies的"typescript": "^2.2.2"改成"typescript": "~2.2.2"才可以

Exception Handling

Can any body let me know why the exceptions or Sucess messages from angular4 are not disaplyed from the Spring Boot back end. For example simple validations are not displaying the validations messages on the UI.

Angular navbar and list components enhancements

I would like to make some enhancements to the Angular project, mainly I would like to update the following:

  • add icons for all nav tabs
  • center the content inside the "welcome" component
  • make the footer fixed at the bottom of the page. This will improve the look of the website when the user is switching between different nab tabs. The footer will no longer jump up and down when the data for the tables is being fetched.
  • add some padding-left to the navbar brand
  • only show the "Home" and "Add" buttons on the list components after the data from the backend has been received. This will ensure that the "Home" and "Add" buttons will be displayed at their final position on the page, instead of jumping down after the table data has been fetched.

home_page

Upgrade to Angular 4

By the way, we may rename this repo to spring-petclinic-angular and spring-petclinic-angular1 to spring-petclinic-angularjs

Project build

In the root folder, after a git cloneand a npm install the command ng build triggers the following error:

You have to be inside an angular-cli project in order to use the build command.

Here are my angular-cli informations:

angular-cli: 1.0.0-beta.28.3
node: 7.5.0
os: darwin x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8

Align with new backend API

The PR spring-petclinic/spring-petclinic-rest#52 introduce some changes to the backend API:

  • date format have changed to RFC-3339
  • some bidirectional ids have been removed.
  • search by lastname API has changed
  • The /pets resource move to /owners/{ownerId}/pets

Thoses changes may be reported to the Angular frontend.

Can't checkout this repo

I am unable to successfully clone and checkout this repo. Here's what I'm seeing:

λ git clone https://github.com/spring-petclinic/spring-petclinic-angular.git
Cloning into 'spring-petclinic-angular'...
remote: Enumerating objects: 1025, done.
Receiving objects: 9remote: Total 1025 (delta 0), reused 0 (delta 0), pack-reused 10255% (974/1025)
Receiving objects: 100% (1025/1025), 838.67 KiB | 2.60 MiB/s, done.
Resolving deltas: 100% (758/758), done.
error: unable to create file [email protected]:: Invalid argument
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

Git status shows a whole lot of deleted files and a handful of untracked ones. If I retry the checkout, I get the following:

λ git checkout -f HEAD
error: unable to create file [email protected]:: Invalid argument
Your branch is up to date with 'origin/master'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.