Bert's Dashboard
Project description
Table of Contents generated with DocToc
- Overview
- Features
- Quick Start
- Building the app
- Building the installer
- Developing the app
- Configuration File
- Lessons
- WebTerminal
- Appendix
Bert's Dashboard
Overview
What is this and why did you make it?
This is my attempt at creating a sort of life dashboard for myself.
The aim is to make it as customizable as possible in as easy a way as possible.
This project is the successor to bert.bill.
As such, the interactive lesson features from that project have been ported over.
As with the previous project, the interactive lesson feature was inspired by Katacoda. And, as with the previous iteration of my work, instead of a website with learning examples, you have a web app that creates hands-on lessons from markdown-formatted, jina-templated documents, complete with a web terminal for interactive practice.
How did you make this?
- The UI
- ReactJS for the UI framework
- TailwindCSS for easier CSS
- Mosaic Lite Admin Dashboard for the UI layout
- React Redux for session state management
- The API
What's it look like?
Here's a screenshot of the dashboard:
Here's a screenshot of the Knowledgebase layout:
Here's a screenshot of an interactive lesson:
Features
- The dashboard cards can be configured via the dashboard configration file: etc/dashboard.yaml.
- The knowledgebase catalog is configured via the lessons configuration file: etc/lessons.yaml
- Web-based terminals via xtermjs component
See section on WebTerminal - Local Webterminal websocket is also available
- Utilizes spyder-terminal component
- You can practice the lesson material with your own OS/system
- Simply click on a command, and it will be executed in the underlying shell via web terminal!
- Default shell is bash (for now)
Quick Start
Step 1 - Install
Note You'll need a minimum python version of 3.7 for the app to work
You can install the app in any of the following ways:
- Install pip package from pypi.org:
pip install btdashboard
- Install pip package from locally cloned repo:
git clone -b ${REMOTE_BRANCH-main} https://github.com/berttejeda/bert.dashboard.git
cd bert.dashboard
nvm install
npm config set timeout 100000
npm install -g parcel yarn
yarn install --frozen-lockfile --network-timeout 100000
yarn compile:ui:dev
pip install .
- From the above, nvm is used to install nodejs, and we use yarn for installing package dependencies, and parcel for the web build.
- .nvmrc is set to use node v16.5.0
- To install from the locally cloned repo in development mode, do the same as above, but with
pip install -e .
instead - You can also install the pip package directly from git repo
pip install git+http://www.github.com/berttejeda/bert.dashboard.git
,
but you'll need to obtain the HTML assets and point the app to them, see the Appendix
Step 2 - Adjust your configuration files as needed
Under the etc directory, you'll find the following configuration files:
If not specified, the app will use the configuration files above.
TODO: Documentation on configuration file options.
Step 3 - Launch!
- If installed via pip, launch the app from your terminal:
btdashboard
- If installed via pip as a development instance, launch via python with
python ./btdashboard/app.py
Usage
Usage information can be obtained by invoking the executable with the --help
flag, as with: btdashboard --help
or python ./btdashboard/app.py --help
.
The help output should be similar to:
usage: btdashboard [-h] [--username USERNAME] [--password PASSWORD]
[--lesson-url LESSON_URL]
[--static-assets-folder STATIC_ASSETS_FOLDER] [--app-id APP_ID]
[--app-user APP_USER] [--app-config-file APP_CONFIG_FILE]
[--lessons-config-file LESSONS_CONFIG_FILE]
[--dashboard-config-file DASHBOARD_CONFIG_FILE]
[--sidebar-config-file SIDEBAR_CONFIG_FILE]
[--cors-origin CORS_ORIGIN] [--logfile-path LOGFILE_PATH]
[--host-address HOST_ADDRESS] [--port PORT]
[--webterminal-listen-host WEBTERMINAL_LISTEN_HOST]
[--webterminal-listen-port WEBTERMINAL_LISTEN_PORT]
[--webterminal-host WEBTERMINAL_HOST]
[--webterminal-shell WEBTERMINAL_SHELL]
[--webterminal-shell-command WEBTERMINAL_SHELL_COMMAND]
[--open-browser-delay OPEN_BROWSER_DELAY]
[--logfile-write-mode {a,w}] [--config-file-templatized]
[--api-only] [--webterminal-only] [--all-in-one] [--no-browser]
[--debug] [--no-verify-tls] [--no-render-markdown]
[run]
Bert's Dashboard
positional arguments:
run
optional arguments:
-h, --help show this help message and exit
--username USERNAME, -U USERNAME
Username, if the URL requires authentication
--password PASSWORD, -P PASSWORD
Password, if the URL requires authentication
--lesson-url LESSON_URL, -url LESSON_URL
The URL for the lesson definition
--static-assets-folder STATIC_ASSETS_FOLDER, -S STATIC_ASSETS_FOLDER
Explicity specify the folder for static HTML assets
--app-id APP_ID, -id APP_ID
Specify the App's Identifier
--app-user APP_USER, -iu APP_USER
Specify the App's User
--app-config-file APP_CONFIG_FILE, -cfa APP_CONFIG_FILE
Path to app configuration file
--lessons-config-file LESSONS_CONFIG_FILE, -cfl LESSONS_CONFIG_FILE
Path to lessons configuration file
--dashboard-config-file DASHBOARD_CONFIG_FILE, -cfd DASHBOARD_CONFIG_FILE
Path to dashboard configuration file
--sidebar-config-file SIDEBAR_CONFIG_FILE, -cfs SIDEBAR_CONFIG_FILE
Path to sidebar configuration file
--cors-origin CORS_ORIGIN, -o CORS_ORIGIN
Override CORS origin pattern
--logfile-path LOGFILE_PATH, -L LOGFILE_PATH
Path to logfile
--host-address HOST_ADDRESS, -l HOST_ADDRESS
Override default host address
--port PORT, -p PORT Override default listening port
--webterminal-listen-host WEBTERMINAL_LISTEN_HOST, -wlh WEBTERMINAL_LISTEN_HOST
Override default listening host address for the
webterminal socket
--webterminal-listen-port WEBTERMINAL_LISTEN_PORT, -wlp WEBTERMINAL_LISTEN_PORT
Override default listening port for the webterminal
socket
--webterminal-host WEBTERMINAL_HOST, -wh WEBTERMINAL_HOST
Override the webterminal socket address to which the
UI initially connects
--webterminal-shell WEBTERMINAL_SHELL, -wS WEBTERMINAL_SHELL
Override default shell for the webterminal session
--webterminal-shell-command WEBTERMINAL_SHELL_COMMAND, -wSc WEBTERMINAL_SHELL_COMMAND
Override default shell command for the webterminal
session
--open-browser-delay OPEN_BROWSER_DELAY, -bd OPEN_BROWSER_DELAY
Override default time in seconds to delay when opening
the system's web browser
--logfile-write-mode {a,w}, -w {a,w}
File mode when writing to log file, 'a' to append, 'w'
to overwrite
--config-file-templatized, -fT
Render configuration via jinja2 templating
--api-only Don't serve static assets, only start API
--webterminal-only Don't serve static assets or start API, only invoke
Webterminal Websocket
--all-in-one, -aio Run the shell websocket process alongside app
--no-browser, -nobrowser
If applicable, don't open the web browser
--debug
--no-verify-tls, -notls
Verify SSL cert when downloading web content
--no-render-markdown, -nomarkdown
Starting the development instance of the app
- Install Python 3.7+
- Install this project's required version of nodejs (v18.11.0):
nvm install
Note that this command implicitly reads the local .nvmrc - Install yarn & parcel:
npm install -g yarn parcel
- Install node modules:
yarn install --frozen-lockfile
- Install python prerequisites:
pip3 install -e .
- Launch the development instance of the UI:
yarn start:dev:ui
- Launch the api and local webterminal process:
yarn start:api
Under the hood, this launchespython btdashboard/app.py --debug --api-only -aio
, see package.json
Developing the app
Starting the development instance of the UI will cause it to reload whenever you make changes to any of the UI files under the src folder.
This functionality helps increase UI development velocity.
I have not yet implemented similar functionality for the API files under btdashboard, so you'll have to kill and reload the API whenever you make changes.
App Defaults
If no settings can be found, the app will resort to its defaults, see defaults.py
As such, the defaults settings call for the import of an external config, hosted in my bert.lessons repo:
see bert.lessons/lessons.yaml
This external config is where I am listing all of my (mostly) hand-crafted tutorials and learning materials.
Lessons
As already mentioned, lessons are Markdown-formatted files interpreted as jinja templates.
These are defined in the lessons.yaml configuration file.
You can override the location of this file via the appropriate cli parameter.
Review the --help
output for details.
TODO
Implement per-lesson credentials
Jinja Templating
To add to the templating goodies provided by the Jinja library, I've exposed the OS Environment via the environment key of a special variable named session.
This means you should be able to dynamically load any OS-level environment variable into your lesson material, e.g.
# Overview
{% set USERNAME = session['environment'].get('USER') or session['environment'].get('USERNAME') %}
Hello {{ USERNAME }}, welcome to Lesson 1
WebTerminal
Every lesson rendered through the app includes a web-based terminal emulator component that allows for practicing the lesson material.
These web terminals are embedded in the user interface, available at its footer.
As mentioned before, the underlying technology for these web terminals is xterm.js.
As such, the xterm.js component requires a websocket to a bash process.
By default, the bert.dashboard web app will attempt to connect to a local instance of the websocket via http://127.0.0.1:10001/.
You can get this websocket running either by:
- Installing btdashboard with
pip install btdashboard
and runningbtdashboard -aio
or by installing all requirements and runningpython btdashboard/app.py -aio
Doing so will launch a local websocket that forwards keystrokes to a bash process on your system
Appendix
Configuration files
Important note about the configuration files:
- Environment variable interpolation is supported, e.g.
user: ${USER}
,
You can see this in use in the app config file
Github Pages
If you want to publish the assets from your own fork of this repo:
- Fork this repo
- Configure Github Pages
- Run
yarn install
to initialize the project requirements - Run
yarn deploy
to publish the static assets to thegh-pages
branch
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file btdashboard-1.1.0.tar.gz
.
File metadata
- Download URL: btdashboard-1.1.0.tar.gz
- Upload date:
- Size: 22.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bc3cfdc808c2dc868de3e1cce89662cbc0dc6aa32707f3818038b54094a5033 |
|
MD5 | a9be35304461b3549c4b519e96707002 |
|
BLAKE2b-256 | 6936c0ff094e7afb4b326f8accc7519192369b539a263a2b4383fa0b06092028 |
File details
Details for the file btdashboard-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: btdashboard-1.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f41469780802294f289aedc14345ada5d6181c1908499db71d0ecbab3fddcb5 |
|
MD5 | fb380c5bafc4cc637c64f2778f2272ea |
|
BLAKE2b-256 | 99c12222ee12a2a031010763769eb8a00d32ae6be974cb7252c371bc4b868c37 |