diff --git a/assets/config/default.config.ini b/assets/config/default.config.ini index 598a6c270..95040725f 100644 --- a/assets/config/default.config.ini +++ b/assets/config/default.config.ini @@ -173,7 +173,6 @@ developer::exceptionhandler = 0 ;Notification notify::status = 1 -notify::position = bottomCenter notify::timeout = 5 ;Api diff --git a/assets/config/dist/default.config.ini.dev b/assets/config/dist/default.config.ini.dev index b3db69a00..85950f24d 100644 --- a/assets/config/dist/default.config.ini.dev +++ b/assets/config/dist/default.config.ini.dev @@ -173,7 +173,6 @@ developer::exceptionhandler = 1 ;Notification notify::status = 1 -notify::position = bottomCenter notify::timeout = 5 ;Api diff --git a/assets/config/dist/default.config.ini.dist b/assets/config/dist/default.config.ini.dist index 598a6c270..95040725f 100644 --- a/assets/config/dist/default.config.ini.dist +++ b/assets/config/dist/default.config.ini.dist @@ -173,7 +173,6 @@ developer::exceptionhandler = 0 ;Notification notify::status = 1 -notify::position = bottomCenter notify::timeout = 5 ;Api diff --git a/assets/img/icon-error.png b/assets/img/icon-error.png new file mode 100644 index 000000000..8455a0766 Binary files /dev/null and b/assets/img/icon-error.png differ diff --git a/assets/js/desktop/utils.js b/assets/js/desktop/utils.js index 4840e878f..cb6405086 100644 --- a/assets/js/desktop/utils.js +++ b/assets/js/desktop/utils.js @@ -58,94 +58,56 @@ jQuery.fn.findAtDepth = function (selector, maxDepth) { }; /** - * Floating notification - * - * @param _title title of the notification - * @param _text text of the notification - * @param _class_name equivalent to the color of notification (success, warning, error, nextdom color) + * Show notification + * @param title Title of the notification + * @param message Message of the notification + * @param type Type of notification (success, error) */ -function notify(_title, _text, _class_name) { - if (typeof notify_status != 'undefined' && isset(notify_status) && notify_status == 1) { - var _backgroundColor = ""; - var _icon = ""; - - if (_title == "") { - _title = "Core"; - } - if (_text == "") { - _text = "Erreur inconnue"; - } - if (_class_name == "success") { - _backgroundColor = '#00a65a'; - _icon = 'far fa-check-circle fa-3x'; - } else if (_class_name == "warning") { - _backgroundColor = '#f39c12'; - _icon = 'fas fa-exclamation-triangle fa-3x'; - } else if (_class_name == "error") { - _backgroundColor = '#dd4b39'; - _icon = 'fas fa-times fa-3x'; - } else { - _backgroundColor = '#33B8CC'; - _icon = 'fas fa-info fa-3x'; - } +function showNotification(title, message, type) { + var icon = '/public/img/icon-256x256.png'; + if (type === 'error') { + icon = '/public/img/icon-error.png'; + } + var notification = new Notification(title, { + body: message.replace(/(<([^>]+)>)/ig, ''), + icon: icon + }); + if (typeof(notify_timeout) !== 'undefined') { + setTimeout(notification.close.bind(notification), notify_timeout); + } +} - iziToast.show({ - id: null, - class: '', - title: _title, - titleColor: 'white', - titleSize: '1.5em', - titleLineHeight: '30px', - message: _text, - messageColor: 'white', - messageSize: '', - messageLineHeight: '', - theme: 'dark', // dark - iconText: '', - backgroundColor: _backgroundColor, - icon: _icon, - iconColor: 'white', - iconUrl: null, - image: '', - imageWidth: 50, - maxWidth: jQuery(window).width() - 500, - zindex: null, - layout: 2, - balloon: false, - close: true, - closeOnEscape: false, - closeOnClick: false, - displayMode: 0, // once, replace - position: notify_position, // bottomRight, bottomLeft, topRight, topLeft, topCenter, bottomCenter, center - target: '', - targetFirst: true, - timeout: notify_timeout * 1000, - rtl: false, - animateInside: true, - drag: true, - pauseOnHover: true, - resetOnHover: false, - progressBar: true, - progressBarColor: '', - progressBarEasing: 'linear', - overlay: false, - overlayClose: false, - overlayColor: 'rgba(0, 0, 0, 0.6)', - transitionIn: 'fadeInUp', - transitionOut: 'fadeOut', - transitionInMobile: 'fadeInUp', - transitionOutMobile: 'fadeOutDown', - buttons: {}, - inputs: {}, - onOpening: function () { - }, - onOpened: function () { - }, - onClosing: function () { - }, - onClosed: function () { +/** + * Check notification permission and show if granted + * @param title Title of the notification + * @param message Message of the notification + * @param type Type of notification (success, error) + */ +function notify(title, message, type) { + var currentDate = new Date(); + if (!window.Notification) { + console.error('You\'re browser doesn\'t support notifications'); + } + else { + if (!(typeof(notify_status) !== 'undefined' && notify_status == 0)) { + if (Notification.permission === 'granted') { + showNotification(title, message, type); } - }); + else { + var lastRequest = parseInt(localStorage.getItem('notification')); + // 2 weeks + if (lastRequest + 1209600000 > currentDate.getTime()) { + Notification.requestPermission().then(function(result) { + if (result === 'granted') { + showNotification(title, message, type); + } + else { + localStorage.setItem('notification', currentDate.getTime().toString()); + } + }); + } + } + } } } @@ -235,7 +197,6 @@ function saveWidgetDisplay(_params){ } var cmds = []; var eqLogics = []; - var scenarios = []; $('.eqLogic-widget:not(.eqLogic_layout_table)').each(function(){ var eqLogic = $(this); order = 1; @@ -709,7 +670,7 @@ function passwordScore(password, progressbar=null, spanLevel=null) { /** * Decode HTML entities in string like é - * @param string message + * @param message Message to decode */ function decodeHtmlEntities(message) { diff --git a/package-lock.json b/package-lock.json index 2ce80a59c..b653cddfd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -911,11 +911,6 @@ "outlayer": "^2.1.0" } }, - "izitoast": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/izitoast/-/izitoast-1.4.0.tgz", - "integrity": "sha512-Oc1X2wiQtPp39i5VpIjf3GJf5sfCtHKXZ5szx7RareyEeFLUlcEW0FSfBni28+Ul6KNKZRKzhVuWzSP4Xngh0w==" - }, "jquery": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.0.tgz", diff --git a/package.json b/package.json index 694399ffc..36153cd0e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "highcharts": "^7.0.1", "inputmask": "^4.0.2", "isotope-layout": "^3.0.6", - "izitoast": "^1.4.0", "jquery-contextmenu": "^2.5.0", "jquery-cron": "^1.0.0", "jquery-datetimepicker": "^2.5.20", diff --git a/scripts/gen_assets.sh b/scripts/gen_assets.sh index d3b0e5da8..db69303ac 100755 --- a/scripts/gen_assets.sh +++ b/scripts/gen_assets.sh @@ -28,7 +28,7 @@ function gen_css { mkdir -p assets/css/builded # Build adminlte node vendor/node_modules/less/bin/lessc assets/css/compiled/AdminLTE.less assets/css/builded/AdminLTE.scss - # + # cat vendor/node_modules/bootstrap/dist/css/bootstrap.css \ vendor/node_modules/roboto-fontface/css/roboto/roboto-fontface.css \ vendor/node_modules/jquery-ui/themes/base/core.css \ @@ -58,12 +58,11 @@ function gen_css { vendor/node_modules/jquery-contextmenu/dist/jquery.contextMenu.css \ vendor/node_modules/tablesorter/dist/css/theme.bootstrap.min.css \ vendor/node_modules/codemirror/lib/codemirror.css \ - vendor/node_modules/izitoast/dist/css/iziToast.css \ vendor/node_modules/@fortawesome/fontawesome-free/css/all.css \ vendor/node_modules/font-awesome/css/font-awesome.css \ vendor/node_modules/jquery-datetimepicker/jquery.datetimepicker.css \ vendor/node_modules/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css \ - assets/icon/animal/style.css \ + assets/icon/animal/style.css \ assets/icon/divers/style.css \ assets/icon/fashion/style.css \ assets/icon/loisir/style.css \ @@ -116,7 +115,6 @@ function gen_js { vendor/node_modules/bootstrap/dist/js/bootstrap.min.js \ vendor/node_modules/pace-js/pace.min.js \ vendor/node_modules/admin-lte/dist/js/adminlte.min.js \ - vendor/node_modules/izitoast/dist/js/iziToast.min.js \ assets/3rdparty/jquery.utils/jquery.utils.js \ assets/3rdparty/jquery.at.caret/jquery.at.caret.min.js \ assets/3rdparty/jquery.multi-column-select/multi-column-select.js \ diff --git a/src/Controller/Pages/FirstUseController.php b/src/Controller/Pages/FirstUseController.php index d36f5e4ec..fb1a67e15 100644 --- a/src/Controller/Pages/FirstUseController.php +++ b/src/Controller/Pages/FirstUseController.php @@ -47,7 +47,6 @@ public static function get(&$pageData): string { $configs = ConfigManager::byKeys([ 'notify::status', - 'notify::position', 'notify::timeout', 'nextdom::firstUse']); if ($configs['nextdom::firstUse'] == 0) { @@ -59,7 +58,6 @@ public static function get(&$pageData): string $pageData[ControllerData::TITLE] = '1ère Connexion'; $pageData[ControllerData::JS_VARS] = [ 'notify_status' => $configs['notify::status'], - 'notify_position' => $configs['notify::position'], 'notify_timeout' => $configs['notify::timeout'], 'serverTZoffsetMin' => Utils::getTZoffsetMin(), 'serverDatetime' => Utils::getMicrotime() diff --git a/src/Helpers/PrepareView.php b/src/Helpers/PrepareView.php index 6f8fdf169..d13023074 100755 --- a/src/Helpers/PrepareView.php +++ b/src/Helpers/PrepareView.php @@ -55,7 +55,6 @@ public function initConfig() 'nextdom::firstUse', 'nextdom::Welcome', 'notify::status', - 'notify::position', 'notify::timeout', 'widget::size', 'widget::margin', @@ -139,7 +138,6 @@ private function initJsPool(&$pageData) $pageData[ControllerData::JS_POOL][] = '/vendor/node_modules/bootstrap/dist/js/bootstrap.min.js'; $pageData[ControllerData::JS_POOL][] = '/vendor/node_modules/admin-lte/dist/js/adminlte.min.js'; $pageData[ControllerData::JS_POOL][] = '/vendor/node_modules/pace-js/pace.min.js'; - $pageData[ControllerData::JS_POOL][] = '/vendor/node_modules/izitoast/dist/js/iziToast.min.js'; $pageData[ControllerData::JS_POOL][] = '/assets/3rdparty/jquery.utils/jquery.utils.js'; $pageData[ControllerData::JS_POOL][] = '/assets/3rdparty/jquery.at.caret/jquery.at.caret.min.js'; $pageData[ControllerData::JS_POOL][] = '/assets/3rdparty/jquery.multi-column-select/multi-column-select.js'; @@ -178,12 +176,12 @@ private function initJsPool(&$pageData) $pageData[ControllerData::JS_POOL][] = '/assets/js/core/jeedom.class.js'; // Then NextDom JS files - $pageData[ControllerData::JS_POOL][] = '/public/js/desktop/conflicts.js'; - $pageData[ControllerData::JS_POOL][] = '/public/js/desktop/loads.js'; - $pageData[ControllerData::JS_POOL][] = '/public/js/desktop/inits.js'; - $pageData[ControllerData::JS_POOL][] = '/public/js/desktop/gui.js'; - $pageData[ControllerData::JS_POOL][] = '/public/js/desktop/utils.js'; - $pageData[ControllerData::JS_POOL][] = '/public/js/desktop/search.js'; + $pageData[ControllerData::JS_POOL][] = '/assets/js/desktop/conflicts.js'; + $pageData[ControllerData::JS_POOL][] = '/assets/js/desktop/loads.js'; + $pageData[ControllerData::JS_POOL][] = '/assets/js/desktop/inits.js'; + $pageData[ControllerData::JS_POOL][] = '/assets/js/desktop/gui.js'; + $pageData[ControllerData::JS_POOL][] = '/assets/js/desktop/utils.js'; + $pageData[ControllerData::JS_POOL][] = '/assets/js/desktop/search.js'; $pageData[ControllerData::JS_POOL][] = '/assets/js/desktop/jeedomCompatibility.js'; // And libraries JS @@ -438,7 +436,6 @@ public function showContent() 'user_login' => UserManager::getStoredUser()->getLogin(), 'nextdom_Welcome' => $this->currentConfig['nextdom::Welcome'], 'notify_status' => $this->currentConfig['notify::status'], - 'notify_position' => $this->currentConfig['notify::position'], 'notify_timeout' => $this->currentConfig['notify::timeout'], 'widget_size' => $this->currentConfig['widget::size'], 'widget_margin' => $this->currentConfig['widget::margin'], diff --git a/views/desktop/params/profils.html.twig b/views/desktop/params/profils.html.twig index 71c32f29a..d6d5ac3d9 100644 --- a/views/desktop/params/profils.html.twig +++ b/views/desktop/params/profils.html.twig @@ -323,20 +323,6 @@