Implement a user notification system
Created by: SunilMohanAdapa
When users need to be reported of success of failure of an operation, currently Plinth shows a message immediately after the operation (such as when a form is submitted). However, there might be some scenarios where we may wish to give messages to the user:
- Intimation about checks performed periodically by the user. Such as when disk space is low. Some application needs configuration after installation.
- Showing progress of background tasks such as installation.
- Notification about progress of setup of FreedomBox.
Implement a generic notification mechanism that provides the following:
- Any module will be able to add a notification.
- Notifications persist across Plinth restarts, so they need to be stored in the sqlite3 database.
- Notifications can contain images and text and have a special layouts.
- Notifications may contain actions that when activated will result in POST method on a provided URL.
- Each notification shall have a unique ID provided by the entity creating the message. These IDs should be later referable by the entity creating the message. Unique ID is a string. IDs such as 'disks-root-disk-partition-full' are preferable. Also UUIDs and hashes of predictable data can be used if they can be reproduced later. For a message that is of type show and forget, UUIDs can be auto generated.
- Notification may be removed at any time using the unique ID provided during creation.
- Modules should be able to iterate through the list of messages they have created.
- Notification may be updated at any time using the unique ID provided during creation.
- Notifications may contain progress bars that can be updated as a task progresses. Unique ID provided during creation can be used to upgrade the progress.
- When notifications are available, they will show up on top right with a contrasting color. Clicking on the notification icon will show all available notifications as drop down.
- Notification on mobile phone should occupy entire width of the screen and appear closer to Android notification area.
- Each module page should show the notifications of the module automatically.
- Notifications should store information about when the notifications was first created and last updated.
- Answered or removed notifications should be kept for display in a log. Notifications log should be shown in the system tab.
- Notifications may be restricted to particular group of users. This is so that system level notifications related to health of the system may only be shown to administrators.
Edit: Added @JoKeyser' suggestions. Edit: Add limiting notifications to certain users.