This project was build upon the Angular framework as an frontend for the backend server. A knowledge of the Angular tutorial - Tour of the heroes - should be enough to make changes and improvements.
git clone https://github.com/fi-ksi/web-frontend-angular.git &&
cd web-frontend-angular &&
npm installTo start the development server, use npm run start.
To build for:
-
testing server:
npm run build.kyzikos -
production server:
npm run build.kleobis
Note: these builds are automatically performed when automatic deployment is used
All source code that is direct part of the final applications is to be found inside the src directory:
assets- images, fonts, icons and internalization texts in respective sub-directoriescgi-bin- auto-deployment scriptenvironemnts- see Angular docsroutes- see Localizationsrc/api- auto generated bygen-api.sh, more belowsrc/app- the source code of the web application itself
Sub-directories are named after the Angular structure, that they contain - components, pipes, services. These sub-directories are then structured by their Angular module. If the structure is to be used in more than one module, the shared module should be used. For easier refactoring, pipes and services should export everything by using index.ts.
The models sub-directory is for storing interfaces that are to be used across multiple other files.
The styles sub-directory contains following files:
colors.scss- color palette, only these colors are to be used in the application; all colors should be referenced by their nametheme.scss- here are defined theme-specific variables, see belowvars.scss- defines constants for unified design throughout the application - e.g. margin and padding sizesmixins.scss- frequently used styles between multiple components
The util/ sub-directory contains helper classes and functions - e. g. universal MappedFormControl (used in date input) and function for rewriting asset URL from the old frontend location.
Utilities are located inside the util/ directory, containing following files:
- executed by
npm run gen.api
gen-api.sh takes swagger.json produced by backend swagger project. Both projects need to be cloned to the same directory.
Based on the swagger definition, it generates API service and models inside the src/api/ folder.
A few automatics fixes to the generated code are then made by this util.
- executed by
npm run gen.changelog
gen-changelog.sh takes git's log and saves this information into src/assets/changelog/ directory. This is then used by the changelog modal inside the application.
executed by npm run gen.theme
gen-scss-theme.sh generates scss variables based on src/app/styles/theme.scss and saves them into the same file under AUTO-GENERATED section. for usage inside the application. SCSS variables are safer than regular css variables because the compiler throws error if used variable is undefined.
executed by npm run gen.icons
gen-icons.sh takes main .svg icon from src/assets/img/icon.svg and generates all required .png icons under src/assets/icons for PWA.
TL;DR: After merging PR to main, you can run following commands to start deployment on prod: git checkout main && git pull && git checkout prod-kleobis && git rebase main && git push && git checkout main.
Automatic deploy is executed based on which branch is pushed into. To see which branch deploys where, take a look inside the .github/workflows directory. Most important branches are:
prod-kleobisthat is deployed on the ksi.fi.muni.cz production environmentdev-kyzikosthat is deployed on the kyzikos.fi.muni.cz development environment (accessible only from FI network or VPN)
For the deployment to be successful, a script cgi-bin/dist-update.sh must already exist on the target server and be executable (after first successful deploy, this script is automatically updated). Following project secrets must exist (their real name differs by the used target server):
DEPLOY_USER- username for the HTTP authDEPLOY_PASSWORD- password for the HTTP authPROD_DEPLOY_URL- HTTP URL of thedist-update.shscript on the target server
Also, if the name or owner of the repository is changed, be sure to reflect this change inside the cgi-bin/dist-update.sh script by modifying its variables - GITHUB_OWNER and GITHUB_REPOSITORY.
The source code is written in English, but the web itself is in Czech. This is possible by using ngx-translate package. All texts (except a few exceptions) are saved inside src/assets/cs.json.
The routes are also translated by using fileReplacements inside angular.json file. Raw values can be found inside src/routes/.
You can find the logs of all HTTP requests (and other events like incorrect password, cheating) including the IP address and the ID of the user making the request in /var/log/gunicorn/naskoc-backend.log.