This project contains the source code of the frontend of the smart city dashboard. The display can connect to the backend and shows different kinds of environmental and smart city related data. The dashboard contains three different pages: dashboard view, map view and an info page.
- Clone the repo
cd smart-city-dashboardcp .env.example .env- Change the env variable
REACT_APP_API_URLto the URL of the backend yarnornpm installyarn buildornpm build- Serve the
buildfolder with your favorite webserver
The same as "Running the Project" but instead of steps 6 and 7 do the following:
yarn startornpm start
This project was bootstrapped with Create React App.
The frontend is written in typescript and uses react. State management is done with redux and redux-saga. The page style and layout is done with bulma, while components are styled with styled-components. Data visualization on the dashboard is either custom written (e.g. parking) or visualized with apexcharts (e.g. charts).
We are using typescript for type safety. In order to have consistend formatting / styling of the code, we are using husky, lint-staged and prettier.
.vscodeSettings when developing with VSCodepublicStatic files that will be served as isscriptsScripts for maintaining the projectsrcSource code. This also includes the react entry point, service workers and typesactionsRedux actions (splitted for each data source)componentsReact ComponentspagesPages of the websitereducersRedux reducers (splitted for each data source)resourcesAssets that will be compiled (like icons, images etc)sagasredux sagas (Sagas are implemented using generator functions)viewsContainers that display data (splitted for each data source)
- Tile: Displaying numbers with units and titles in tiles / cards
- Progress: Visualizing progress which is here used to show the utilization of parking decks
- Line diagram: visualizing (multiple) lines in a diagram
If you want to add a new data source to the dashboard, there are multiple steps neccessary:
- Start in the
src/reducersfolder and create a new reducer similar to the existing ones. Here, you will also define the state for your particular dataset - Next one, create corresponding actions for your data in the
src/actionsfolder - After defining how the data should be stored and managed, we can take care of fething the data. Create a new saga in the
src/sagasfolder similar to the existing files. The generator functions will fetch data regularly based on the interval you can define
- The most labour will take place in
src/viewswhere you create a new container for your data. Here, you need to access the redux state and render different kinds of visualizations - You can now import your container in
pages/Hometo display it on the main page. You might need to adjust the overall page layout here
After creating a new file in the src directory, please run the license-header script to prepend a comment with license information to the file. You can simply run
yarn license-header # or npm run license-headerwhich automatically updates the file
Copyright (C) 2022 Reedu GmbH & Co. KG
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.