Skip to content

Commit

Permalink
Allow to configure notifications with context data (delete or not) (#33)
Browse files Browse the repository at this point in the history
* working towards iobroker centralized eslint config

* ignore files

* fix reoslution

* fix lint command

* fix build by using adapter dev 1.2.0

* added possibility to FE to also delete notifications if context data is present

* readme and changelog

* finished off backend logic
  • Loading branch information
foxriver76 authored Oct 10, 2024
1 parent 297c59f commit 98f87a2
Show file tree
Hide file tree
Showing 29 changed files with 4,604 additions and 491 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# No dot-directories except github/vscode
.*/
!.vscode/
!.github/

*.code-workspace
Expand Down
3 changes: 0 additions & 3 deletions .vscode/extensions.json

This file was deleted.

21 changes: 0 additions & 21 deletions .vscode/settings.json

This file was deleted.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Whenever a category is `active` but has not configured any specific settings yet
fallback settings. New categories are always `active` by default to ensure you will be notified. This means whenever a new `category`
is implemented by some adapter, the fallback settings for the given `severity` will be applied.

You can further define to just `suppress` a category. The `notification-manager` will then simply acknowledge the notification, so that is
does not appear in your system.

Since js-controller version 7, adapters have the possibility to add additional `contextData` to notifications. This is for example used
to display specific actions for the user in the Admin GUI. By default, the `notification-manager` will send you these notifications and will
__NOT__ delete them, so that these stay present for later user interactions. However, if you decide that you don't need such interactions
fort certain `category` you can disable them via the checkbox.

### Registering user-centric notifications
As a user you at best know, when you want to be notified about specific situations in your system.
Thus, the `notification-manager` provides you with an interface to register your own notifications inside
Expand Down Expand Up @@ -103,6 +111,10 @@ if the messaging adapter was able to deliver the notification, else it should re
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* (@foxriver76) by default we do not delete notifications with `contextData`
* (@foxriver76) added checkbox to also delete notifications with `contextData` for specific categories

### 1.2.1 (2024-08-29)
* (@foxriver76) fixed issue if host name contains `.`

Expand Down
29 changes: 14 additions & 15 deletions admin/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ Blockly.Translate =
lang = lang || systemLang;
if (Blockly.Words && Blockly.Words[word]) {
return Blockly.Words[word][lang] || Blockly.Words[word].en;
} else {
return word;
}
return word;
};

// --- SendTo Notification Manager --------------------------------------------------
Expand All @@ -29,7 +28,7 @@ Blockly.Words['notification-manager'] = {
es: 'Administrador de notificaciones',
pl: 'Menedżer powiadomień',
uk: 'Менеджер сповіщень',
'zh-cn': '通知管理器'
'zh-cn': '通知管理器',
};
Blockly.Words['notification-manager_message'] = {
en: 'Message text',
Expand All @@ -42,7 +41,7 @@ Blockly.Words['notification-manager_message'] = {
es: 'Texto del mensaje',
pl: 'Tekst wiadomości',
uk: 'Текст повідомлення',
'zh-cn': '信件文本'
'zh-cn': '信件文本',
};
Blockly.Words['notification-manager_category'] = {
en: 'Category',
Expand All @@ -55,7 +54,7 @@ Blockly.Words['notification-manager_category'] = {
es: 'Categoría',
pl: 'Kategoria',
uk: 'Категорії',
'zh-cn': '类别'
'zh-cn': '类别',
};
Blockly.Words['notification-manager_anyInstance'] = {
en: 'All instances',
Expand All @@ -68,7 +67,7 @@ Blockly.Words['notification-manager_anyInstance'] = {
es: 'Todas las instancias',
pl: 'Wszystkie instancje',
uk: 'Всі екземпляри',
'zh-cn': '所有案件'
'zh-cn': '所有案件',
};
Blockly.Words['notification-manager_informal'] = {
en: 'Informal',
Expand All @@ -81,7 +80,7 @@ Blockly.Words['notification-manager_informal'] = {
es: 'Consultas oficiosas',
pl: 'Nieformalne',
uk: 'Неформатний',
'zh-cn': '非正式'
'zh-cn': '非正式',
};
Blockly.Words['notification-manager_info'] = {
en: 'Important',
Expand All @@ -94,7 +93,7 @@ Blockly.Words['notification-manager_info'] = {
es: 'Importante',
pl: 'Ważne',
uk: 'Головна',
'zh-cn': '重要'
'zh-cn': '重要',
};
Blockly.Words['notification-manager_alert'] = {
en: 'Alarming',
Expand All @@ -107,11 +106,11 @@ Blockly.Words['notification-manager_alert'] = {
es: 'Alarma',
pl: 'Alarm',
uk: 'Розведення',
'zh-cn': '警报'
'zh-cn': '警报',
};
Blockly.Words['notification-manager_help'] = {
en: 'https://github.com/foxriver76/ioBroker.notification-manager/blob/main/README.md',
de: 'https://github.com/foxriver76/ioBroker.notification-manager/blob/main/README.md'
de: 'https://github.com/foxriver76/ioBroker.notification-manager/blob/main/README.md',
};

Blockly.Sendto.blocks['notification-manager'] =
Expand All @@ -134,14 +133,14 @@ Blockly.Blocks['notification-manager'] = {
const m = main.instances[i].match(/^system.adapter.notification-manager.(\d+)$/);
if (m) {
const n = parseInt(m[1], 10);
options.push(['notification-manager.' + n, '.' + n]);
options.push([`notification-manager.${n}`, `.${n}`]);
}
}
}

if (!options.length) {
for (let k = 0; k <= 4; k++) {
options.push(['notification-manager.' + k, '.' + k]);
options.push([`notification-manager.${k}`, `.${k}`]);
}
}

Expand All @@ -159,9 +158,9 @@ Blockly.Blocks['notification-manager'] = {
new Blockly.FieldDropdown([
[Blockly.Translate('notification-manager_informal'), 'notify'],
[Blockly.Translate('notification-manager_info'), 'info'],
[Blockly.Translate('notification-manager_alert'), 'alert']
[Blockly.Translate('notification-manager_alert'), 'alert'],
]),
'CATEGORY'
'CATEGORY',
);

this.setInputsInline(false);
Expand All @@ -170,7 +169,7 @@ Blockly.Blocks['notification-manager'] = {

this.setColour(Blockly.Sendto.HUE);
this.setHelpUrl(Blockly.Translate('notification-manager_help'));
}
},
};

Blockly.JavaScript['notification-manager'] = function (block) {
Expand Down
2,225 changes: 2,225 additions & 0 deletions admin/build/index.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions admin/build/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions admin/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { StyleRules } from '@material-ui/core/styles';
import type { AdapterNative } from './components/settings';

const styles = (_theme: Theme): StyleRules => ({
root: {}
root: {},
});

class App extends GenericApp {
Expand All @@ -29,9 +29,9 @@ class App extends GenericApp {
es: require('./i18n/es.json'),
pl: require('./i18n/pl.json'),
//uk: require('./i18n/uk.json'),
'zh-cn': require('./i18n/zh-cn.json')
'zh-cn': require('./i18n/zh-cn.json'),
/* eslint-enable @typescript-eslint/no-require-imports */
}
},
};

super(props, extendedProps);
Expand Down
Loading

0 comments on commit 98f87a2

Please sign in to comment.