You need at least a running Edu-Sharing instance to use the frontend. See https://github.com/edu-sharing/Edu-Sharing/.
app
api
: Auto-generated API service for REST communication to Edu-Sharing.wlo-search
: Basically the complete application. Everything that does not necessarily have to go to the actual root component. This was meant for including the application as lazy-loaded route into another app, but we don't do that at the moment.core
: The parts of the application that stay alive throughout the application lifetime, including header- and footer components and services.preferences
: User-preferences pages, barely used at the moment.search
: Search- and details pages, the heart of the application.details-page
search-page
shared
: Shared components of search- and details page.
- shared: Modules, pipes, and directives that are used application-wide.
Setup
$ git submodule update --init
$ npm install
The dev server will serve the application on http://localhost:4200/ and reload automatically if you change any of the source files.
Either
-
start the dev server:
$ npm start
-
or start the dev server with German translations:
$ npm run start-de
For deployment, the application is packaged as Docker image.
To locally build the image and serve it on http://localhost:8080, run:
$ npm run build
$ npm run docker-build
$ npm run docker-run
Local dev configuration is done via the file src/env.js
. Copy src/env.sample.js
for an initial version.
When started as Docker container, the file src/env.js
will be populated with the respective environment variables
The following variables are available:
Variable | Description | Default value (dev) | Default value (prod) |
---|---|---|---|
EDU_SHARING_API_URL | URL of the Edu-Sharing API to connect to. | /edu-sharing-api' |
/edu-sharing-api' |
WORDPRESS_URL | Base URL of the corresponding WLO Wordpress page. | https://dev.wirlernenonline.de |
https://wirlernenonline.de |
SHOW_EXPERIMENTS | Display a link to experimental-feature toggles in the frontend. | true |
false |
ANALYTICS_URL | URL of the analytics backend to connect to. | (undefined ) |
/analytics' |
For example, to run your locally built Docker image against the staging environment of WirLernenOnline, run
docker run --name oeh-search-frontend --rm -ti -p 8080:80 -e EDU_SHARING_API_URL=https://redaktion-staging.openeduhub.net/edu-sharing/rest openeduhub/oeh-search-frontend:local
Pointing the browser to a different backend as described above might fail due to missing CORS
headers. In order to point a dev environment to a production backend, copy .env.sample
to .env
and set the URL there.
Run ng test
to execute the unit tests via Karma.
See https://docs.cypress.io/guides/overview/why-cypress.html.
All of the following commands must be run from e2e-cypress
as working directory:
$ cd e2e-cypress
Install dependencies using
$ npm install
- Install dependencies and submodules and run the dev server using
npm run start-de
(see section Build). - Start the elasticsearch-relay on port 3000 (see https://github.com/openeduhub/oeh-search-elasticsearch-relay).
Single run:
$ npm run cypress:local:run
Open GUI:
$ npm run cypress:local:open
Test https://staging.wirlernenonline.de, single run:
$ npm run cypress:stage:run
Test https://staging.wirlernenonline.de, open GUI:
$ npm run cypress:stage:open
Test https://suche.wirlernenonline.de, single run:
$ npm run cypress:prod:run
Test https://suche.wirlernenonline.de, open GUI:
$ npm run cypress:prod:open
This project uses husky and link-staged for automatic code checking and formatting before commits.
Run npm run format
to format all source files via Prettier.
Run ng lint
to check all source files via ESLint.
Internationalization is provided with i18n.
Localization files are stored in src/locale
.
To create / update translation files, run
npm run extract-i18n
This will generate the source file messages.xlf
in src/locale
.
Copy (or update) missing blocks from messages.xlf
to target translation files in src/locale
and
write missing translations in the target
tags of translation files.
The following files are relevant:
angular.json
nginx.page.conf
To choose a non-default locale, a configuration has to be provided in angular.json
. It can be
activated like this:
ng serve --configuration=de
When built with ng build --localize
, angular creates a directory for each language in dist
. The
Dockerfile
configures an Nginx to serve the browser's preferred language by redirecting into one
of these directories.
Start elasticsearch-relay
as dev server and install apollographql.vscode-apollo
to get IDE
features for GraphQL queries in VSCode.
ext install apollographql.vscode-apollo
Run
npm run build:web-components
and copy all data from the folder dist/web-components/de
in the corresponding wordpress folder (/wp-content/themes/wir-lernen-online/src/assets/js/angular/detail_view
)
- Enable strict type checking
- Enable stricter budgets:
"budgets": [ { "type": "initial", "maximumWarning": "500kb", "maximumError": "1mb" }, { "type": "anyComponentStyle", "maximumWarning": "2kb", "maximumError": "4kb" } ]