New Dash frontend for https://everyonecounts.de.
The dash webserver is run on an AWC EC2 instance. For setup and deploy scripts see this repo.
Important: Requires Dash 1.12. There is an issue with how callbacks are handled in Dash 1.13+ which makes it currently incompatible with this code.
Dashboard and widget functionality can be customized using config.json. Also, credentials are stored in this file. It is generated from config.json.tpl using Secrethub:
secrethub inject -i config.json.tpl -o config.json --identity-provider=aws
The parameters in the config file are:
influx_url: URL of the InfluxDBinflux_token: Token of the InfluxDB. Stored in Secrethub.influx_org: Organisation of the InlfuxDBdash_host: Host address for the Dash Webserver (e.g.localhost). Stored in Secrethub.TRENDWINDOW: Number of days to use for trend calculationDEBUG: Debug mode of the Dash webserver (boolean)measurements_dashboard: Names of the measurements that are displayed in the dashboardmeasurements_widget: Names of the measurements that can be used as widgets and are shown in the widget configuratorENABLE_CACHE: Enable caching of calls to the InfluxDB (boolean)CLEAR_CACHE_ON_STARTUP: Clear the cache upon webserver start (boolean)SLOW_CACHE_CONFIGandFAST_CACHE_CONFIG: Configuration for two different caches. The "slow" cache caches data for longer periods of time (e.g. for all dashboard stations data) while the "fast" cache has a shorter timeout (e.g. for widgets which should update more frequently). See the Flask-Caching documentation for details. The most relevant options are:CACHE_TYPE: Specifies which type of caching object to use (e.g.filesystem)CACHE_DIR: Directory to store cache. Used only for FileSystemCache.CACHE_THRESHOLD: The maximum number of items the cache will store before it starts deleting some. Used only for SimpleCache and FileSystemCacheCACHE_DEFAULT_TIMEOUT: The default timeout that is used if no timeout is specified. Unit of time is seconds. },
AUTO_REFRESH_SLOW_CACHE_ENABLE: Automatically repopulate the slow cache after it expires in the background (boolean).LOG_LEVEL: Logging level, e.g.DEBUG,BASE_URL: Base URL of the webserver, mostly used for the widgets. For example, this can behttp://localhost:8050in development andhttps:/everyonecounts.dein deployment.
Widgets are accesed on BASE_URL/widget and require some URL parameters. For ease of use, there is a configuration UI under BASE_URL/widget/configurator that generates the correct URLs and helps in determining the station ids.
Example URLs:
https://everyonecounts.de/widget?widgettype=timeline&station=hystreet$110&show_rolling=0&show_trend=0https://everyonecounts.de/widget?widgettype=fill&station=hystreet$110&max=5000&show_number=both
Parameters for all widget types:
station(required, c_id of the station)width(optional, width of the widget in pixels)
Possible widget types (widgettype=) and their parameters:
timeline(shows a timeline chart)show_trend(optional, 1 or 0)show_rolling(optional, 1 or 0)
fill(shows how filled a station is)max(optional)show_number(required, one of 'total', 'percentage' or 'both')trafficlight(if set to 1, display a traffic light next to the numbers)t1andt2(required only when trafficlight is set to 1, thresholds for green/yellow and yellow/red boundary)