style changes and only show the icon if the user has activated the communication app inside of user-preferences

This commit is contained in:
Bjoern Gruening
2016-05-28 20:18:32 +02:00
parent 233c752a0b
commit f2ccbc6f6c
+27 -23
View File
@@ -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" );
}
},
});