[Kimchi-devel] [PATCH][Wok] UI: Remove notification array and make notifications persistent

Lucio Correia luciojhc at linux.vnet.ibm.com
Mon May 30 14:14:43 UTC 2016


Reviewed-By: Lucio Correia <luciojhc at linux.vnet.ibm.com>

On 28-05-2016 18:14, Rodrigo Trujillo wrote:
> There is an issue in frontend that does not allow notification messages
> to be showed more than once if the problem happens again.
> When user clicks on message close ("X") button, the notification message
> is only removed from backend, but not from the UI array.
> This patch changes functions to not use the array anymore, instead, it
> checks if the message is being displayed by its message code, then shows
> if necessary.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   ui/js/src/wok.main.js  | 1 -
>   ui/js/src/wok.utils.js | 8 ++++----
>   2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/ui/js/src/wok.main.js b/ui/js/src/wok.main.js
> index 2146b3d..cf5b6a2 100644
> --- a/ui/js/src/wok.main.js
> +++ b/ui/js/src/wok.main.js
> @@ -19,7 +19,6 @@
>    */
>
>   wok.NOTIFICATION_INTERVAL = 5000
> -wok.postedNotifications = []
>   wok.tabMode = {};
>
>   wok.config = undefined;
> diff --git a/ui/js/src/wok.utils.js b/ui/js/src/wok.utils.js
> index 1fb3c9b..3759cbe 100644
> --- a/ui/js/src/wok.utils.js
> +++ b/ui/js/src/wok.utils.js
> @@ -209,12 +209,12 @@ wok.notificationsLoop = function notificationsLoop() {
>           function(notifications){
>               if(notifications && notifications.length > 0) {
>                   $.each(notifications, function(i, notif) {
> -                    if (wok.postedNotifications.indexOf(notif.message) == -1) {
> +                    // Check if notification is being displayed
> +                    if (($("#alert-container").contents().find("div:contains('" + notif.code + "')").length) == 0) {
Would it be better if we test by notif.message instead of notif.code? I 
ask it because there are some messages that use string templates to 
indicate on which vm the problem is, and it would be nice to show two 
messages in case we have the problem occurring in two vms.


>                           wok.message.notify(notif, '#message-container-area');
> -                        wok.postedNotifications.push(notif.message);
>                       }
> -                })
> -            };
> +                });
> +            }
>               setTimeout(notificationsLoop, wok.NOTIFICATION_INTERVAL);
>           },
>           function(data){
>


-- 
Lucio Correia
Software Engineer
IBM LTC Brazil




More information about the Kimchi-devel mailing list