Skip to content

Commit

Permalink
v1.0.7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kid1194 committed Jun 18, 2024
1 parent 3ceb488 commit 6947b49
Show file tree
Hide file tree
Showing 16 changed files with 441 additions and 129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
node_modules/

.gitignore
.ruff.toml
package-lock.json
package.json
eslint.config.mjs
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A small **Frappe** module that displays custom alerts to specific recipients after login.

![v1.0.6](https://img.shields.io/badge/v1.0.6-2024/06/12-green?style=plastic)
![v1.0.7](https://img.shields.io/badge/v1.0.7-2024/06/19-green?style=plastic)

**Apologies in advance for any problem or bug you face with this module.**
**Please report any problem or bug you face so it can be fixed.**
Expand Down Expand Up @@ -62,15 +62,11 @@ cd ~/frappe-bench

2. Get plugin from Github

*(Required only once)*

```
bench get-app https://github.com/kid1194/frappe_alerts
```

3. Build plugin

*(Required only once)*
3. Build plugin files

```
bench build --app alerts
Expand All @@ -82,7 +78,11 @@ bench build --app alerts
bench --site [sitename] install-app alerts
```

5. Check the [usage](#usage) section
5. Restart bench to clear cache

```
bench restart
```

#### Update
1. Go to app directory
Expand All @@ -97,13 +97,13 @@ cd ~/frappe-bench/apps/alerts
git pull
```

3. Go to bench directory
3. Go back to bench directory

```
cd ~/frappe-bench
```

4. Build plugin
4. Build plugin files

```
bench build --app alerts
Expand All @@ -115,7 +115,7 @@ bench build --app alerts
bench --site [sitename] migrate
```

6. (Optional) Restart bench
6. Restart bench to clear cache

```
bench restart
Expand All @@ -140,7 +140,7 @@ bench --site [sitename] uninstall-app alerts
bench remove-app alerts
```

4. (Optional) Restart bench
4. Restart bench to clear cache

```
bench restart
Expand All @@ -162,7 +162,7 @@ bench restart
- Select `None` to disable the `Display Sound`
- To customize the look of the alert:
- Change the `Background Color`, `Border Color`, `Title Color` and `Content Color` for both, **Light** and **Dark** themes
- Click on `Preview` to see how the custom style will look
- After saving form, click on `Preview` to see how the custom style will look

### Alert
- Go to `Alert` and create new entry
Expand Down
2 changes: 1 addition & 1 deletion alerts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@


__module__ = "Alerts"
__version__ = "1.0.6"
__version__ = "1.0.7"
__update_api__ = "https://api.github.com/repos/kid1194/frappe_alerts/releases/latest"
3 changes: 1 addition & 2 deletions alerts/alerts/doctype/alert/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ frappe.ui.form.on('Alert', {
}
},
after_save: function(frm) {
frm.events.setup_doc(frm);
frm.events.toggle_toolbar(frm);
},
on_submit: function(frm) {
Expand All @@ -129,7 +128,7 @@ frappe.ui.form.on('Alert', {
frm.events.toggle_toolbar(frm);
},
setup_doc: function(frm) {
var docstatus = !frm.is_new() ? cint(frm.doc.docstatus) : 0;
var docstatus = cint(frm.doc.docstatus);
frm._alert.is_draft = docstatus === 0;
frm._alert.is_submitted = docstatus === 1;
frm._alert.is_cancelled = docstatus === 2;
Expand Down
4 changes: 2 additions & 2 deletions alerts/alerts/doctype/alert/alert.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"allow_copy": 1,
"allow_import": 1,
"autoname": "format:ALERT-{YY}{MM}{DD}-{###}",
"creation": "2022-04-04 04:04:04.119400",
"creation": "2022-04-04 04:04:04",
"description": "Alert data for Alerts",
"doctype": "DocType",
"engine": "InnoDB",
Expand Down Expand Up @@ -178,7 +178,7 @@
],
"icon": "fa fa-bell",
"is_submittable": 1,
"modified": "2024-06-12 04:04:04.119400",
"modified": "2024-06-12 04:04:04",
"modified_by": "Administrator",
"module": "Alerts",
"name": "Alert",
Expand Down
10 changes: 10 additions & 0 deletions alerts/alerts/doctype/alert_type/alert_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ frappe.ui.form.on('Alert Type', {
};
},
refresh: function(frm) {
if (!frm.is_new() && !frm._type.setup) frm.events.setup_disable_note(frm);
if (!frm._type.toolbar) {
frm.events.toggle_toolbar(frm);
frm._type.toolbar = 1;
Expand All @@ -41,6 +42,15 @@ frappe.ui.form.on('Alert Type', {
after_save: function(frm) {
frm.events.toggle_toolbar(frm);
},
setup_disable_note: function(frm) {
frm._type.setup = 1;
frm.get_field('disable_note').$wrapper.empty().append('\
<h4 class="text-danger">' + __('Note') + ':</h4>\
<p class="text-danger">\
' + __('Disabling the alert type will prevent all linked alerts from being displayed.') + '\
</p>\
');
},
toggle_toolbar: function(frm) {
var label = __('Preview'),
del = frm.is_new() || cint(frm.doc.disabled) > 0;
Expand Down
52 changes: 24 additions & 28 deletions alerts/alerts/doctype/alert_type/alert_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"allow_copy": 1,
"allow_import": 1,
"autoname": "Prompt",
"creation": "2022-04-04 04:04:04.119400",
"creation": "2022-04-04 04:04:04",
"description": "Alert type for Alerts",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"main_section",
"disabled",
"main_column",
"disable_note",
"options_section",
"display_priority",
"display_timeout",
Expand Down Expand Up @@ -46,6 +47,12 @@
"fieldname": "main_column",
"fieldtype": "Column Break"
},
{
"fieldname": "disable_note",
"fieldtype": "HTML",
"label": "",
"read_only": 1
},
{
"fieldname": "options_section",
"fieldtype": "Section Break",
Expand All @@ -55,21 +62,19 @@
"fieldname": "display_priority",
"fieldtype": "Int",
"label": "Display Priority",
"description": "Alerts of types with higher priority gets displayed first.",
"description": "Alerts of higher priority types gets displayed first.",
"default": "0",
"non_negative": 1,
"in_list_view": 1,
"read_only_depends_on": "eval:doc.disabled"
"in_list_view": 1
},
{
"fieldname": "display_timeout",
"fieldtype": "Int",
"label": "Display Timeout (Seconds)",
"description": "Close alerts automatically after a specific time. Default: 0 - No Timeout",
"description": "Auto close alerts after a specific time. Default: 0 - No Timeout",
"default": "0",
"non_negative": 1,
"in_list_view": 1,
"read_only_depends_on": "eval:doc.disabled"
"in_list_view": 1
},
{
"fieldname": "options_column",
Expand All @@ -80,17 +85,16 @@
"fieldtype": "Select",
"label": "Display Sound",
"options": "None\nAlert\nError\nClick\nCancel\nSubmit\nCustom",
"default": "None",
"read_only_depends_on": "eval:doc.disabled"
"default": "None"
},
{
"fieldname": "custom_display_sound",
"fieldtype": "Attach",
"label": "Custom Display Sound",
"description": "A small and short audio file is recommended. Supported formats: MP3 (Best), WAV, OGG.",
"depends_on": "eval:doc.display_sound === 'Custom'",
"mandatory_depends_on": "eval:!doc.disabled && doc.display_sound === 'Custom'",
"read_only_depends_on": "eval:doc.disabled || doc.display_sound !== 'Custom'"
"mandatory_depends_on": "eval:doc.display_sound === 'Custom'",
"read_only_depends_on": "eval:doc.display_sound !== 'Custom'"
},
{
"fieldname": "style_section",
Expand All @@ -100,14 +104,12 @@
{
"fieldname": "background",
"fieldtype": "Color",
"label": "Background Color",
"read_only_depends_on": "eval:doc.disabled"
"label": "Background Color"
},
{
"fieldname": "border_color",
"fieldtype": "Color",
"label": "Border Color",
"read_only_depends_on": "eval:doc.disabled"
"label": "Border Color"
},
{
"fieldname": "style_column",
Expand All @@ -116,14 +118,12 @@
{
"fieldname": "title_color",
"fieldtype": "Color",
"label": "Title Color",
"read_only_depends_on": "eval:doc.disabled"
"label": "Title Color"
},
{
"fieldname": "content_color",
"fieldtype": "Color",
"label": "Content Color",
"read_only_depends_on": "eval:doc.disabled"
"label": "Content Color"
},
{
"fieldname": "dark_style_section",
Expand All @@ -133,14 +133,12 @@
{
"fieldname": "dark_background",
"fieldtype": "Color",
"label": "Background Color",
"read_only_depends_on": "eval:doc.disabled"
"label": "Background Color"
},
{
"fieldname": "dark_border_color",
"fieldtype": "Color",
"label": "Border Color",
"read_only_depends_on": "eval:doc.disabled"
"label": "Border Color"
},
{
"fieldname": "dark_style_column",
Expand All @@ -149,18 +147,16 @@
{
"fieldname": "dark_title_color",
"fieldtype": "Color",
"label": "Title Color",
"read_only_depends_on": "eval:doc.disabled"
"label": "Title Color"
},
{
"fieldname": "dark_content_color",
"fieldtype": "Color",
"label": "Content Color",
"read_only_depends_on": "eval:doc.disabled"
"label": "Content Color"
}
],
"icon": "fa fa-bell-o",
"modified": "2024-06-12 04:04:04.119400",
"modified": "2024-06-18 04:04:04",
"modified_by": "Administrator",
"module": "Alerts",
"name": "Alert Type",
Expand Down
4 changes: 4 additions & 0 deletions alerts/alerts/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Alerts © 2024
# Author: Ameen Ahmed
# Company: Level Up Marketing & Software Development Services
# Licence: Please refer to LICENSE file
4 changes: 4 additions & 0 deletions alerts/alerts/report/alert_report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Alerts © 2024
# Author: Ameen Ahmed
# Company: Level Up Marketing & Software Development Services
# Licence: Please refer to LICENSE file
56 changes: 56 additions & 0 deletions alerts/alerts/report/alert_report/alert_report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<h2 class="text-center">{%= __("Alert Report") %}</h2>

{% if (filters.alert_type) { %}
<h4 class="text-center">{%= filters.alert_type %}</h4>
{% } %}

{% if (filters.from_date || filters.until_date) { %}
<h5 class="text-center">
{%= __("From") %}:
{% if (filters.from_date) { %}
{%= frappe.datetime.str_to_user(filters.from_date) %}
{% } else { %}
{%= __("Beginning") %}
{% } %}

{%= __("Until") %}:
{% if (filters.until_date) { %}
{%= frappe.datetime.str_to_user(filters.until_date) %}
{% } else { %}
{%= __("Today") %}
{% } %}
</h5>
{% } %}

<hr>

<table class="table table-bordered">
<thead>
<tr>
<th style="width: 15%">{%= __("Alert") %}</th>
<th class="text-center" style="width: 15%">{%= __("Title") %}</th>
<th class="text-center" style="width: 15%">{%= __("Alert Type") %}</th>
<th class="text-center" style="width: 15%">{%= __("From Date") %}</th>
<th class="text-center" style="width: 15%">{%= __("Until Date") %}</th>
<th class="text-center" style="width: 5%">{%= __("Repeatable") %}</th>
<th class="text-center" style="width: 10%">{%= __("Reached") %}</th>
<th class="text-center" style="width: 10%">{%= __("Status") %}</th>
</tr>
</thead>
<tbody>
{% for(var i=0, l=data.length; i<l; i++) { %}
<tr>
<td><b>{%= frappe.format(data[i].alert, {fieldtype: "Link"}) || "&nbsp;" %}</b></td>
<td>{%= data[i].title || "&nbsp;" %}</td>
<td class="text-center">{%= frappe.format(data[i].alert_type, {fieldtype: "Link"}) || "&nbsp;" %}</td>
<td class="text-center">{%= frappe.datetime.str_to_user(data[i].from_date) %}</td>
<td class="text-center">{%= frappe.datetime.str_to_user(data[i].until_date) %}</td>
<td class="text-center">{%= data[i].is_repeatable || __("No") %}</td>
<td class="text-center">{%= format_number(data[i].reached || 0, null, 0) %}</td>
<td class="text-center">{%= data[i].status || "&nbsp;" %}</td>
</tr>
{% } %}
</tbody>
</table>

<p class="text-right text-muted">{%= __("Printed On") %}: {%= frappe.datetime.str_to_user(frappe.datetime.get_datetime_as_string()) %}</p>
Loading

0 comments on commit 6947b49

Please sign in to comment.