diff --git a/guacamole/src/main/webapp/app/navigation/services/userPageService.js b/guacamole/src/main/webapp/app/navigation/services/userPageService.js index b64556bf3..e9239d796 100644 --- a/guacamole/src/main/webapp/app/navigation/services/userPageService.js +++ b/guacamole/src/main/webapp/app/navigation/services/userPageService.js @@ -28,6 +28,7 @@ angular.module('navigation').factory('userPageService', ['$injector', // Get required types var ConnectionGroup = $injector.get('ConnectionGroup'); + var PageDefinition = $injector.get('PageDefinition'); var PermissionSet = $injector.get('PermissionSet'); // Get required services @@ -39,19 +40,16 @@ angular.module('navigation').factory('userPageService', ['$injector', var service = {}; /** - * Construct a new Page object with the given name and url. + * Construct a new PageDefinition object with the given name and url. + * * @constructor - * * @param {String} name * The i18n key for the name of the page. * * @param {String} url - * The url to the page. - * - * @returns {PageDefinition} - * The newly created PageDefinition object. + * The URL of the page. */ - var Page = function Page(name, url) { + var PageDefinition = function PageDefinition(name, url) { this.name = name; this.url = url; }; @@ -60,9 +58,9 @@ angular.module('navigation').factory('userPageService', ['$injector', * The home page to assign to a user if they can navigate to more than one * page. * - * @type Page + * @type PageDefinition */ - var SYSTEM_HOME_PAGE = new Page( + var SYSTEM_HOME_PAGE = new PageDefinition( 'USER_MENU.ACTION_NAVIGATE_HOME', '/' ); @@ -73,7 +71,7 @@ angular.module('navigation').factory('userPageService', ['$injector', * @param {ConnectionGroup} rootGroup * The root of the connection group tree for the current user. * - * @returns {Page} + * @returns {PageDefinition} * The user's home page. */ var generateHomePage = function generateHomePage(rootGroup) { @@ -91,7 +89,7 @@ angular.module('navigation').factory('userPageService', ['$injector', // Only one connection present, use as home page if (connection) { - return new Page( + return new PageDefinition( connection.name, '/client/c/' + connection.identifier ); @@ -102,7 +100,7 @@ angular.module('navigation').factory('userPageService', ['$injector', && connectionGroup.type === ConnectionGroup.Type.BALANCING && _.isEmpty(connectionGroup.childConnections) && _.isEmpty(connectionGroup.childConnectionGroups)) { - return new Page( + return new PageDefinition( connectionGroup.name, '/client/g/' + connectionGroup.identifier ); @@ -216,7 +214,7 @@ angular.module('navigation').factory('userPageService', ['$injector', // If user can manage sessions, add link to sessions management page if (canManageSessions) { - pages.push(new Page( + pages.push(new PageDefinition( 'USER_MENU.ACTION_MANAGE_SESSIONS', '/settings/sessions' )); @@ -224,7 +222,7 @@ angular.module('navigation').factory('userPageService', ['$injector', // If user can manage users, add link to user management page if (canManageUsers) { - pages.push(new Page( + pages.push(new PageDefinition( 'USER_MENU.ACTION_MANAGE_USERS', '/settings/users' )); @@ -232,14 +230,14 @@ angular.module('navigation').factory('userPageService', ['$injector', // If user can manage connections, add link to connections management page if (canManageConnections) { - pages.push(new Page( + pages.push(new PageDefinition( 'USER_MENU.ACTION_MANAGE_CONNECTIONS', '/settings/connections' )); } // Add link to user preferences (always accessible) - pages.push(new Page( + pages.push(new PageDefinition( 'USER_MENU.ACTION_MANAGE_PREFERENCES', '/settings/preferences' )); @@ -305,7 +303,7 @@ angular.module('navigation').factory('userPageService', ['$injector', // Add generic link to the first-available settings page if (settingsPages.length) { - pages.push(new Page( + pages.push(new PageDefinition( 'USER_MENU.ACTION_MANAGE_SETTINGS', settingsPages[0].url )); diff --git a/guacamole/src/main/webapp/app/navigation/types/PageDefinition.js b/guacamole/src/main/webapp/app/navigation/types/PageDefinition.js new file mode 100644 index 000000000..6b58849fd --- /dev/null +++ b/guacamole/src/main/webapp/app/navigation/types/PageDefinition.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2015 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * Provides the PageDefinition class definition. + */ +angular.module('navigation').factory('PageDefinition', [function definePageDefinition() { + + /** + * Creates a new PageDefinition object which pairs the URL of a page with + * an arbitrary, human-readable name. + * + * @constructor + * @param {String} name + * The the name of the page, which should be a translation table key. + * + * @param {String} url + * The URL of the page. + */ + var PageDefinition = function PageDefinition(name, url) { + + /** + * The the name of the page, which should be a translation table key. + * + * @type String + */ + this.name = name; + + /** + * The URL of the page. + * + * @type String + */ + this.url = url; + + }; + + return PageDefinition; + +}]);