Merge pull request #134 from glyptodon/dynamic-home-button

GUAC-1126: Only display NAVIGATE_HOME_ACTION if the home page is not the current page.
This commit is contained in:
James Muehlner
2015-04-06 22:14:47 -07:00

View File

@@ -34,6 +34,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
var $location = $injector.get('$location');
var guacClientManager = $injector.get('guacClientManager');
var guacNotification = $injector.get('guacNotification');
var userPageService = $injector.get('userPageService');
/**
* The minimum number of pixels a drag gesture must move to result in the
@@ -126,15 +127,27 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
};
/**
* Action which returns the user to the home screen.
* Action which returns the user to the home screen. If the home page has
* not yet been determined, this will be null.
*/
var NAVIGATE_HOME_ACTION = {
var NAVIGATE_HOME_ACTION = null;
// Assign home page action once user's home page has been determined
userPageService.getHomePage()
.then(function homePageRetrieved(homePage) {
// Define home action only if different from current location
if ($location.path() !== homePage.url) {
NAVIGATE_HOME_ACTION = {
name : "CLIENT.ACTION_NAVIGATE_HOME",
className : "home button",
callback : function navigateHomeCallback() {
$location.path('/');
$location.url(homePage.url);
}
};
}
});
/**
* Action which replaces the current client with a newly-connected client.
@@ -414,6 +427,13 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
if (!connectionState)
return;
// Build array of available actions
var actions;
if (NAVIGATE_HOME_ACTION)
actions = [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ];
else
actions = [ RECONNECT_ACTION ];
// Get any associated status code
var status = $scope.client.clientState.statusCode;
@@ -441,7 +461,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
title : "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
text : "CLIENT.ERROR_CLIENT_" + errorName,
countdown : countdown,
actions: [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ]
actions : actions
});
}
@@ -461,7 +481,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
title : "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
text : "CLIENT.ERROR_TUNNEL_" + errorName,
countdown : countdown,
actions: [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ]
actions : actions
});
}
@@ -471,7 +491,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
guacNotification.showStatus({
title : "CLIENT.DIALOG_HEADER_DISCONNECTED",
text : "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase(),
actions: [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ]
actions : actions
});
}