A responsive webcomponent for travelling times
- Mobility Traffic
Please, follow the example in src/index.html. You will need to include the web-component JS wile located in /build folder (either module or nomodule version):
<script type="module" src="/build/noi-mobility-traffic.esm.js"></script>
<script nomodule src="/build/noi-mobility-traffic.js"></script>Secondly, you'll need to include the component stylesheet:
<link rel="stylesheet" href="/build/noi-mobility-traffic.css">Now, define the web component like this:
<noi-mobility-traffic lang="it"></noi-mobility-traffic>We tried to comply as much as possible the HTML/CSS spec so the only attribute that is standard is lang which is passed as component attribute. The rest of the properties are declared as CSS custom properties and can be defined either inline or in css header. The default values are given below:
noi-mobility-traffic {
--noi-font-family: "Roboto", "Helvetica Neue", sans-serif;
--noi-width: 100%;
--noi-height: 100%;
--noi-primary: #0068B4;
--noi-primary-rgb: 0, 104, 180;
--noi-primary-contrast: #ffffff;
--noi-action: #339966;
--noi-action-rgb: 87, 173, 57;
--noi-action-contrast: #ffffff;
--noi-error: #B44C00;
--noi-error-rgb: 180,76,0;
--noi-error-contrast: #ffffff;
--noi-jam-none: #0068B4;
--noi-jam-strong: #B44C00;
--noi-jam-light: yellow;
}Main font that will be use across all the projects. Should comply to the css font-family property. Default is Roboto.
Width/Height of the web-component. Should comply the width/height css attribute. Can be fixed or percent (or any other valid css width value). Default is 100%
Primary color to be used all across the web-component and it's rgb representation (should correspond to the first value). Default is:
--noi-primary: #0068B4;
--noi-primary-rgb: 0, 104, 180;Primary contrast color color. Used to distinguish the text font on elements that have background: var(--noi-primary). Default is white.
--noi-primary-contrast: #000000;Action color to be used all across the web-component and it's rgb representation (should correspond to the first value). Default is:
--noi-action: #339966;
--noi-action-rgb: 87, 173, 57;Action contrast color color. Used to distinguish the text font on elements that have background: var(--noi-action). Default is white.
--noi-action-contrast: #000000;An error color to be used for all the error messages and it's rgb representation (should correspond to the first value). Default is:
--noi-action: red;
--noi-action-rgb: 255, 0, 0;Error contrast color color. Used to distinguish the text font on elements that have background: var(--noi-error). Default is white.
--noi-error-contrast: #000000;The value that will be used to color a segment path with heavy traffic on the map. Default is red.
--noi-jam-strong: red;The value that will be used to color a segment path with light traffic on the map. Default is yellow.
--noi-jam-strong: yellow;The value that will be used to color a segment path without any traffic. Default is blue.
--noi-jam-none: blue;The app uses following four json files to configure different thresholds and currently missing api data:
Inside the folder data:
geometries.json- provide missing geometry data for A22 pathjams.json- values to identify traffic jams on segmentstime-thresholds.json- thresholds to identify time values outlayersurban-segments.json- provide missing urban connections between two highway stations
Provide a json map (by LinkStation id) that should comply the following structure. Geometry attribute should be a valid GeoJSON object.
{
"1853-1854": {
"geometry": "",
"name":"BOLZANO NORD - BOLZANO SUD"
}
}Traffic jams map (by LinkStation id) that should comply the following structure. Supports both Urban and A22 segments. Each key should be an array of two velocity values - heavy traffic value and light traffic value. If actual segment velocity is lower than first value, the traffic considered to be heavy. If higher than first but lower than second, light traffic. Higher than second, no traffic. If value is missing the segment will have the default colour on the map. Example:
{
"1853->1854": [70, 95],
"Arginale_Palermo->Arginale_Resia": [40, 60]
}Time thresholds map. If historical value + thresholds < actual value, then the actual value will be considered an outlayer and a historical value will be used. Example:
{
"1853->1854": 120
}Contains the urban stations path (as an array of ids) that connect two highway
stations. The id should be a concatenation of start station id and end station
id with -> separator in-between (as in example below 1854->1853 LinkStation
connecting Bz Nord and Bz Süd). If no data is provided for given start/end,
urban path is considered to be absent.
{
"1854->1853": [
"Torricelli->siemens",
"siemens->Galilei_Palermo",
"Galilei_Palermo->Galilei_Lancia",
"Galilei_Lancia->Galilei_Virgolo",
"Galilei_Virgolo->Galleria_Virgolo",
"Galleria_Virgolo->P_Campiglio"
]
}These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Before building/starting the project one will need to add a .env file in the
root prj dir with following secrets:
CLIENT_SECRET=???
CLIENT_ID=it.bz.opendatahub.webcomponents.mobility-traffic
TOKEN_URL="https://auth.opendatahub.com/auth/realms/noi/protocol/openid-connect/token"
To build the project, the following prerequisites must be met:
- ToDo: Check the prerequisites
- Node 12 / NPM 6
For a ready to use Docker environment with all prerequisites already installed and prepared, you can check out the Docker environment section.
Get a copy of the repository:
ToDo: git clone https://github.com/noi-techpark/webcomp-mobility-traffic.gitChange directory:
ToDo: cd webcomp-mobility-traffic/Download all dependencies (please, do clean install (ci), to respect the package-lock.json):
npm ciBuild and start the project:
npm run startThe application will be served and can be accessed at http://localhost:3333.
The tests can be executed with the following command:
npm run testTo create the distributable files, execute the following command:
npm run build:cdnFor the project a Docker environment is already prepared and ready to use with all necessary prerequisites.
These Docker containers are the same as used by the continuous integration servers.
Install Docker (with Docker Compose) locally on your machine.
First, install all dependencies:
docker-compose run --rm app /bin/bash -c "npm ci"Before start working you have to start the Docker containers:
docker-compose up --build --detach
The application will be served and can be accessed at http://localhost:8999.
After finished working you can stop the Docker containers:
docker-compose stop
When the containers are running, you can execute any command inside the environment. Just replace the dots ... in the following example with the command you wish to execute:
docker-compose run --rm app /bin/bash -c "..."Some examples are:
docker-compose run --rm app /bin/bash -c "npm run test"For support, please contact help@opendatahub.com.
If you'd like to contribute, please follow the following instructions:
-
Fork the repository.
-
Checkout a topic branch from the
developmentbranch. -
Make sure the tests are passing.
-
Create a pull request against the
developmentbranch.
A more detailed description can be found here: https://github.com/noi-techpark/documentation/blob/master/contributors.md.
More documentation can be found at https://opendatahub.readthedocs.io/en/latest/index.html.
The project uses this boilerplate: https://github.com/noi-techpark/webcomp-boilerplate.
The code in this project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 license. See the LICENSE.md file for more information.
This project is REUSE compliant, more information about the usage of REUSE in NOI Techpark repositories can be found here.
Since the CI for this project checks for REUSE compliance you might find it useful to use a pre-commit hook checking for REUSE compliance locally. The pre-commit-config file in the repository root is already configured to check for REUSE compliance with help of the pre-commit tool.
Install the tool by running:
pip install pre-commitThen install the pre-commit hook via the config file by running:
pre-commit install