Skip to content

dmadunic/geodata-ng

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geodata Angular frontend App

GeodataNgApp CI/CD

This application was generated using JHipster 7.4.0, you can find documentation and help at https://www.jhipster.tech/documentation-archive/v7.4.0.

Component Version
Jhipster 7.4.0
Angular 12.2.12
Bootstrap ?

Development

Before you can build this project, you must install and configure the following dependencies on your machine:

  1. Node.js: We use Node to run a development web server and build the project. Depending on your system, you can install Node either from source or as a pre-packaged bundle.

After installing Node, you should be able to run the following command to install development tools. You will only need to run this command when dependencies change in package.json.

npm install

We use npm scripts and Angular CLI with Webpack as our build system.

Run the following commands in two separate terminals to create a blissful development experience where your browser auto-refreshes when files change on your hard drive.

./gradlew -x webapp
npm start

Npm is also used to manage CSS and JavaScript dependencies used in this application. You can upgrade dependencies by specifying a newer version in package.json. You can also run npm update and npm install to manage dependencies. Add the help flag on any command to see how you can use it. For example, npm help update.

The npm run command will list all of the scripts available to run for this project.

PWA Support

JHipster ships with PWA (Progressive Web App) support, and it's turned off by default. One of the main components of a PWA is a service worker.

The service worker initialization code is disabled by default. To enable it, uncomment the following code in src/main/webapp/app/app.module.ts:

ServiceWorkerModule.register('ngsw-worker.js', { enabled: false }),

Managing dependencies

For example, to add Leaflet library as a runtime dependency of your application, you would run following command:

npm install --save --save-exact leaflet

To benefit from TypeScript type definitions from DefinitelyTyped repository in development, you would run following command:

npm install --save-dev --save-exact @types/leaflet

Then you would import the JS and CSS files specified in library's installation instructions so that Webpack knows about them: Edit src/main/webapp/app/app.module.ts file:

import 'leaflet/dist/leaflet.js';

Edit src/main/webapp/content/scss/vendor.scss file:

@import '~leaflet/dist/leaflet.css';

Note: There are still a few other things remaining to do for Leaflet that we won't detail here.

For further instructions on how to develop with JHipster, have a look at Using JHipster in development.

Using Angular CLI

You can also use Angular CLI to generate some custom client code.

For example, the following command:

ng generate component my-component

will generate few files:

create src/main/webapp/app/my-component/my-component.component.html
create src/main/webapp/app/my-component/my-component.component.ts
update src/main/webapp/app/app.module.ts

Building docker image

To build this application as docker image perform the following steps.

1. Perform standard application build for production environment

Inside root project folder execute:

npm install
npm run webapp:prod

2. Build local docker image

docker build -t ag04/geodata-ng:latest -f ./Dockerfile .

Optionally you can replace "latest" with the active project version from package.json

Using docker image

Geodata angular frontend app docker image requiers several environment variables to be configured:

Environment variable Description
GEODATA_API_URL Url of the Geodata rest API (ie. http://host.docker.internal:8080/api)
GEODATA_MNGMT_URL Url of actuator management endpoint (ie. http://host.docker.internal:8080/management)
GEODATA_SWAGGER_URL Url of the generated Swagger API (ie. http://host.docker.internal:8080/swagger-resources)
GEODATA_AUTH_URL Url of the ? (ie. http://host.docker.internal:8080/auth)

For an example how to use this image see the docker-docompose file: docker/app.yml

version: '2'
services:
  nginx:
    image: ag04/geodata-ng:latest
    environment:
      - GEODATA_API_URL=http://host.docker.internal:8080/api
      - GEODATA_MNGMT_URL=http://host.docker.internal:8080/management
      - GEODATA_SWAGGER_URL=http://host.docker.internal:8080/swagger-resources
      - GEODATA_AUTH_URL=http://host.docker.internal:8081/auth
    # On macOSX and Windows env comment the following two lines, they are linux workaround
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
    - "9000:80"

Client tests

Unit tests are run by Jest. They're located in src/test/javascript/ and can be run with:

npm test

For more information, refer to the Running tests page.

Continuous Integration (optional)

To configure CI for your project, run the ci-cd sub-generator (jhipster ci-cd), this will let you generate configuration files for a number of Continuous Integration systems. Consult the Setting up Continuous Integration page for more information.