Skip to main content

A trame package to manage and display alerts

Project description

trame-alerts

A trame package to manage and display alerts/notification while being agnostic of the widget framework you want to use. This can be use to report errors and let the user know about the completions of tasks.

demo

Installing

Install trame_alerts using pip

pip install trame_alerts

If you are planning on using the provided vuetify UI widgets to display the alerts run the following:

pip install trame_alerts[vuetify]

If you are planning on using the provided quasar UI widgets to display the alerts run the following:

pip install trame_alerts[quasar]

Usage

The core component to this library is the AlertsProvider widget. This widget manages a portion of the trame state where the status of the alerts is stored, and provides easy access to set of JavaScript variables and functions to any widgets that are its descendants.

from trame.app import get_server
from trame.widgets import html, alerts
from trame.ui.html import DivLayout

server = get_server(client_type="vue3")

with DivLayout(server) as layout:
    with alerts.AlertsProvider():
        html.Button(
            "Create Error",
            click="createErrorAlert({})",
        )

        html.Button(
            "Clear All",
            click="clearAlerts",
        )

        with html.P(v_for="alert in allAlerts", key="alert.id"):
            html.Span("[{{alert.id}}] {{alert.title}} - {{alert.text}}")
            html.Button("Remove", click="removeAlert(alert.id)")

server.start()

The following variables are be made available in JavaScript:

  • alerts: The raw content of the portion of the state where the alerts status is stored
  • allAlerts: An array containing all the alerts that exist in the state.
  • activeAlerts: An array containing the alerts that have not elapsed yet.
  • elapsedAlerts: An array containing the alerts that have elapsed.
  • createAlert: Function to create a generic alert. It takes an Alert object.
  • createSuccessAlert: Function to create a success alert. It takes an Alert object.
  • createWarningAlert: Function to create a warning alert. It takes an Alert object.
  • createErrorAlert: Function to create an error alert. It takes an Alert object.
  • createInfoAlert: Function to create an info alert. It takes an Alert object.
  • dismissAlert: Function to dismiss an alert. It takes an alert id.
  • removeAlert: Function to remove an alert. It takes an alert id.
  • clearAlerts: Function to remove all the alerts. It takes no arguments.

Examples

Refer to the examples folder for minimal complete applications that use the core library as well as the vuetify and quasar UI implementation.

Developing

Build and install the core Vue components

    cd vue-components/core
    npm i
    npm run build
    cd -

Build and install the vuetify Vue components

    cd vue-components/vuetify
    npm i
    npm run build
    cd -

Build and install the quasar Vue components

    cd vue-components/quasar
    npm i
    npm run build
    cd -

Install the library

pip install -e ".[dev,vuetify,quasar]"

License

trame-alerts is made available under the Apache License, Version 2.0. For more details, see LICENSE

Community

Trame | Discussions | Issues | RoadMap | Contact Us

Enjoying trame?

Share your experience with a testimonial or with a brand approval.

JavaScript dependency

This package optionally depends on trame-vuetify and trame-quasar, but does not bundle any specific external JavaScript library.

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

trame_alerts-0.1.0.tar.gz (159.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trame_alerts-0.1.0-py3-none-any.whl (162.5 kB view details)

Uploaded Python 3

File details

Details for the file trame_alerts-0.1.0.tar.gz.

File metadata

  • Download URL: trame_alerts-0.1.0.tar.gz
  • Upload date:
  • Size: 159.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for trame_alerts-0.1.0.tar.gz
Algorithm Hash digest
SHA256 715ad89442e29ddc121407d24ec1b71488e145d3f20c68b733da36adf5ba8ff6
MD5 de5faf17e39c41bc2abea8c4084ab258
BLAKE2b-256 9652a047632fc1e72697c0f6be23fefe56ad1febedbb54f1640026c00c011062

See more details on using hashes here.

Provenance

The following attestation bundles were made for trame_alerts-0.1.0.tar.gz:

Publisher: test_and_release.yml on Kitware/trame-alerts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trame_alerts-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: trame_alerts-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 162.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for trame_alerts-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3202feb401979557175b53aa272bf5d14f048dbd4ad171cc7a2ca302b18e07b0
MD5 20a44585b1132fd9685193cd3f0a2b42
BLAKE2b-256 a99335c8f86a487485e481d3be12767351e2627b6bf3f4fe36a2fd88b7030fa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for trame_alerts-0.1.0-py3-none-any.whl:

Publisher: test_and_release.yml on Kitware/trame-alerts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page