From f2ccbc6f6c73786839acb6792c86043337e36ba3 Mon Sep 17 00:00:00 2001 From: Bjoern Gruening Date: Sat, 28 May 2016 20:18:32 +0200 Subject: [PATCH] style changes and only show the icon if the user has activated the communication app inside of user-preferences --- client/galaxy/scripts/layout/page.js | 50 +++++++++++++++------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/client/galaxy/scripts/layout/page.js b/client/galaxy/scripts/layout/page.js index 7fe2b634e27..85e7f19bac4 100644 --- a/client/galaxy/scripts/layout/page.js +++ b/client/galaxy/scripts/layout/page.js @@ -48,7 +48,7 @@ var PageLayoutView = Backbone.View.extend( BaseMVC.LoggableMixin ).extend({ this.renderMessageBox(); this.renderInactivityBox(); this.renderPanels(); - this._checkChatServerOnline(); + this._checkCommunicationServerOnline(); return this; }, @@ -134,28 +134,32 @@ var PageLayoutView = Backbone.View.extend( BaseMVC.LoggableMixin ).extend({ toString : function() { return 'PageLayoutView'; }, - /** Check if the chat server is online and show icon otherwise hide it chat */ - _checkChatServerOnline: function(){ - var host = window.Galaxy.config.communication_server_host, - port = window.Galaxy.config.communication_server_port, - $chat_icon_element = $( "#show-chat-online" ); - // ping the server whether it is online - $.ajax({ - url: host + ":" + port, - }) - .success( function( data ) { - // enable chat only when a user is logged in - if( window.Galaxy.user.id !== null ) { - if( $chat_icon_element.css( "visibility") === "hidden" ) { - $chat_icon_element.css( "visibility", "visible" ); - } - } - - }) - .error( function( data ) { - // makes the chat icon hidden if chat server is not up - $chat_icon_element.css( "visibility", "hidden" ); - }); + /** Check if the communication server is online and show the icon otherwise hide the icon */ + _checkCommunicationServerOnline: function(){ + /** Check if the user has deactivated the communication in it's personal settings */ + if (Galaxy.user.attributes.preferences.communication_server === '1') { + var host = window.Galaxy.config.communication_server_host, + port = window.Galaxy.config.communication_server_port, + $chat_icon_element = $( "#show-chat-online" ); + // See if the configured communication server is available + $.ajax({ + url: host + ":" + port, + }) + .success( function( data ) { + // enable chat only when a user is logged in + if( window.Galaxy.user.id !== null ) { + if( $chat_icon_element.css( "visibility") === "hidden" ) { + $chat_icon_element.css( "visibility", "visible" ); + } + } + }) + .error( function( data ) { + // hide the communication icon if the chat server is not available + $chat_icon_element.css( "visibility", "hidden" ); + }); + } else { + $chat_icon_element.css( "visibility", "hidden" ); + } }, });