diff --git a/Message/Notification/App/AppNotification.js b/Message/Notification/App/AppNotification.js index 5b6b323..858704b 100644 --- a/Message/Notification/App/AppNotification.js +++ b/Message/Notification/App/AppNotification.js @@ -37,6 +37,15 @@ } let output = document.importNode(tpl.content, true); + output.querySelector('.log-msg').classList.add('log-msg-status-' + msg.status); + output.querySelector('.log-msg-title').innerHTML = msg.title; + output.querySelector('.log-msg-content').innerHTML = msg.message; + tpl.parentNode.appendChild(output); + + setTimeout(function () + { + document.getElementsByClassName('log-msg')[0].remove(); + }, 3000); }; }(window.jsOMS = window.jsOMS || {})); \ No newline at end of file diff --git a/Message/Notification/NotificationLevel.enum.js b/Message/Notification/NotificationLevel.enum.js new file mode 100644 index 0000000..0b93918 --- /dev/null +++ b/Message/Notification/NotificationLevel.enum.js @@ -0,0 +1,19 @@ +/** + * Notification data enum. + * + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @since 1.0.0 + */ +(function (jsOMS) { + "use strict"; + + /** @namespace jsOMS.Message.Notification */ + jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification'); + + jsOMS.Message.Notification.NotificationLevel = Object.freeze({ + OK: 'ok', + ERROR: 'error' + }); +}(window.jsOMS = window.jsOMS || {})); diff --git a/Message/Notification/NotificationMessage.js b/Message/Notification/NotificationMessage.js index a93ca5b..89ba7db 100644 --- a/Message/Notification/NotificationMessage.js +++ b/Message/Notification/NotificationMessage.js @@ -14,7 +14,7 @@ jsOMS.Message.Notification.NotificationMessage = function (status, title, message) { - this.status = 0; + this.status = status; this.title = title; this.message = message; }; diff --git a/UI/Component/Form.js b/UI/Component/Form.js index b6f6a4f..cd5cc3a 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -222,13 +222,17 @@ let tempResponse = null, success = null; - self.app.notifyManager.send( - new jsOMS.Message.Notification.NotificationMessage( - jsOMS.Message.Notification.NotificationLevel, - 'Success', - 'Successfully created object' - ), jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION - ); + if (typeof document.getElementById(form.getId()).dataset.msg !== 'undefined') { + let msg = JSON.parse(document.getElementById(form.getId()).dataset.msg); + + self.app.notifyManager.send( + new jsOMS.Message.Notification.NotificationMessage( + jsOMS.Message.Notification.NotificationLevel.OK, + msg.title, + msg.message + ), jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION + ); + } /* Handle responses (can be multiple response object) */ for (let k = 0; k < responseLength; ++k) { @@ -251,6 +255,17 @@ } }); + request.setResultCallback(0, function (xhr) + { + self.app.notifyManager.send( + new jsOMS.Message.Notification.NotificationMessage( + jsOMS.Message.Notification.NotificationLevel.ERROR, + 'Failure', + 'Some failure happend' + ), jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION + ); + }); + request.send(); };