You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/08/17 19:36:01 UTC
[airavata-django-portal] 05/05: AIRAVATA-2727 Clean up Notification
api
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit f49ed31aef10279e8ba3af3cc96d318d1fde2e99
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Fri Aug 17 15:35:44 2018 -0400
AIRAVATA-2727 Clean up Notification api
---
.../js/errors/UnhandledError.js | 4 ----
.../common/js/components/NotificationsDisplay.vue | 25 ++++++----------------
.../static/common/js/notifications/Notification.js | 5 +++--
.../common/js/notifications/NotificationList.js | 9 --------
4 files changed, 9 insertions(+), 34 deletions(-)
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/errors/UnhandledError.js b/django_airavata/apps/api/static/django_airavata_api/js/errors/UnhandledError.js
index 33a80ae..53524c6 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/errors/UnhandledError.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/errors/UnhandledError.js
@@ -10,10 +10,6 @@ class UnhandledError {
this.suppressLogging = suppressLogging;
this.createdDate = new Date();
}
-
- get displayMessage() {
- return this.error && this.error.message ? this.error.message : this.message;
- }
}
export default UnhandledError;
diff --git a/django_airavata/static/common/js/components/NotificationsDisplay.vue b/django_airavata/static/common/js/components/NotificationsDisplay.vue
index d725d6c..425d25d 100644
--- a/django_airavata/static/common/js/components/NotificationsDisplay.vue
+++ b/django_airavata/static/common/js/components/NotificationsDisplay.vue
@@ -1,10 +1,10 @@
<template>
<div id="notifications-display">
<transition-group name="fade" tag="div">
- <b-alert v-for="error in errors"
- :variant="variant(error)" :key="error.id"
- show dismissible @dismissed="dismissedError(error)">
- {{ error.message }}
+ <b-alert v-for="unhandledError in unhandledErrors"
+ variant="danger" :key="unhandledError.id"
+ show dismissible @dismissed="dismissedUnhandledError(unhandledError)">
+ {{ unhandledError.message }}
</b-alert>
<b-alert v-for="notification in notifications"
:variant="variant(notification)" :key="notification.id"
@@ -29,25 +29,12 @@ export default {
unhandledErrors: errors.UnhandledErrorDisplayList.list,
}
},
- computed: {
- errors: function() {
-
- return this.unhandledErrors.map(unhandledError => {
- return new Notification("UNHANDLED-ERROR-" + unhandledError.id, {
- type: "ERROR",
- message: unhandledError.displayMessage,
- details: unhandledError,
- createdDate: unhandledError.createdDate,
- });
- })
- }
- },
methods: {
dismissedNotification: function(notification) {
NotificationList.remove(notification);
},
- dismissedError: function(error) {
- errors.UnhandledErrorDisplayList.remove(error.details);
+ dismissUnhandledError: function(unhandledError) {
+ errors.UnhandledErrorDisplayList.remove(unhandledError);
},
variant: function(notification) {
if (notification.type === "SUCCESS") {
diff --git a/django_airavata/static/common/js/notifications/Notification.js b/django_airavata/static/common/js/notifications/Notification.js
index 1b8864e..2a481e6 100644
--- a/django_airavata/static/common/js/notifications/Notification.js
+++ b/django_airavata/static/common/js/notifications/Notification.js
@@ -1,7 +1,8 @@
+let idSequence = 0;
class Notification {
- constructor(id, { type = "SUCCESS", message = null, details = null, dismissable = true, duration = 0, createdDate = null }) {
- this.id = id;
+ constructor({ type = "SUCCESS", message = null, details = null, dismissable = true, duration = 0, createdDate = null }) {
+ this.id = idSequence++;
this.type = type;
this.message = message;
this.details = details;
diff --git a/django_airavata/static/common/js/notifications/NotificationList.js b/django_airavata/static/common/js/notifications/NotificationList.js
index 09457a7..86c7b41 100644
--- a/django_airavata/static/common/js/notifications/NotificationList.js
+++ b/django_airavata/static/common/js/notifications/NotificationList.js
@@ -1,8 +1,3 @@
-import { errors } from 'django-airavata-api'
-
-import Notification from './Notification'
-
-let notificationIdSequence = 0;
class NotificationList {
@@ -22,10 +17,6 @@ class NotificationList {
get list() {
return this.notifications;
}
-
- getNextId() {
- return "NOTIFICATION-" + notificationIdSequence++;
- }
}
export default new NotificationList();