mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-586: Make PageDefinition class public.
This commit is contained in:
@@ -28,6 +28,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
|||||||
|
|
||||||
// Get required types
|
// Get required types
|
||||||
var ConnectionGroup = $injector.get('ConnectionGroup');
|
var ConnectionGroup = $injector.get('ConnectionGroup');
|
||||||
|
var PageDefinition = $injector.get('PageDefinition');
|
||||||
var PermissionSet = $injector.get('PermissionSet');
|
var PermissionSet = $injector.get('PermissionSet');
|
||||||
|
|
||||||
// Get required services
|
// Get required services
|
||||||
@@ -39,19 +40,16 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
|||||||
var service = {};
|
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
|
* @constructor
|
||||||
*
|
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
* The i18n key for the name of the page.
|
* The i18n key for the name of the page.
|
||||||
*
|
*
|
||||||
* @param {String} url
|
* @param {String} url
|
||||||
* The url to the page.
|
* The URL of the page.
|
||||||
*
|
|
||||||
* @returns {PageDefinition}
|
|
||||||
* The newly created PageDefinition object.
|
|
||||||
*/
|
*/
|
||||||
var Page = function Page(name, url) {
|
var PageDefinition = function PageDefinition(name, url) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.url = url;
|
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
|
* The home page to assign to a user if they can navigate to more than one
|
||||||
* page.
|
* page.
|
||||||
*
|
*
|
||||||
* @type Page
|
* @type PageDefinition
|
||||||
*/
|
*/
|
||||||
var SYSTEM_HOME_PAGE = new Page(
|
var SYSTEM_HOME_PAGE = new PageDefinition(
|
||||||
'USER_MENU.ACTION_NAVIGATE_HOME',
|
'USER_MENU.ACTION_NAVIGATE_HOME',
|
||||||
'/'
|
'/'
|
||||||
);
|
);
|
||||||
@@ -73,7 +71,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
|||||||
* @param {ConnectionGroup} rootGroup
|
* @param {ConnectionGroup} rootGroup
|
||||||
* The root of the connection group tree for the current user.
|
* The root of the connection group tree for the current user.
|
||||||
*
|
*
|
||||||
* @returns {Page}
|
* @returns {PageDefinition}
|
||||||
* The user's home page.
|
* The user's home page.
|
||||||
*/
|
*/
|
||||||
var generateHomePage = function generateHomePage(rootGroup) {
|
var generateHomePage = function generateHomePage(rootGroup) {
|
||||||
@@ -91,7 +89,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
|||||||
|
|
||||||
// Only one connection present, use as home page
|
// Only one connection present, use as home page
|
||||||
if (connection) {
|
if (connection) {
|
||||||
return new Page(
|
return new PageDefinition(
|
||||||
connection.name,
|
connection.name,
|
||||||
'/client/c/' + connection.identifier
|
'/client/c/' + connection.identifier
|
||||||
);
|
);
|
||||||
@@ -102,7 +100,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
|||||||
&& connectionGroup.type === ConnectionGroup.Type.BALANCING
|
&& connectionGroup.type === ConnectionGroup.Type.BALANCING
|
||||||
&& _.isEmpty(connectionGroup.childConnections)
|
&& _.isEmpty(connectionGroup.childConnections)
|
||||||
&& _.isEmpty(connectionGroup.childConnectionGroups)) {
|
&& _.isEmpty(connectionGroup.childConnectionGroups)) {
|
||||||
return new Page(
|
return new PageDefinition(
|
||||||
connectionGroup.name,
|
connectionGroup.name,
|
||||||
'/client/g/' + connectionGroup.identifier
|
'/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 user can manage sessions, add link to sessions management page
|
||||||
if (canManageSessions) {
|
if (canManageSessions) {
|
||||||
pages.push(new Page(
|
pages.push(new PageDefinition(
|
||||||
'USER_MENU.ACTION_MANAGE_SESSIONS',
|
'USER_MENU.ACTION_MANAGE_SESSIONS',
|
||||||
'/settings/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 user can manage users, add link to user management page
|
||||||
if (canManageUsers) {
|
if (canManageUsers) {
|
||||||
pages.push(new Page(
|
pages.push(new PageDefinition(
|
||||||
'USER_MENU.ACTION_MANAGE_USERS',
|
'USER_MENU.ACTION_MANAGE_USERS',
|
||||||
'/settings/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 user can manage connections, add link to connections management page
|
||||||
if (canManageConnections) {
|
if (canManageConnections) {
|
||||||
pages.push(new Page(
|
pages.push(new PageDefinition(
|
||||||
'USER_MENU.ACTION_MANAGE_CONNECTIONS',
|
'USER_MENU.ACTION_MANAGE_CONNECTIONS',
|
||||||
'/settings/connections'
|
'/settings/connections'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add link to user preferences (always accessible)
|
// Add link to user preferences (always accessible)
|
||||||
pages.push(new Page(
|
pages.push(new PageDefinition(
|
||||||
'USER_MENU.ACTION_MANAGE_PREFERENCES',
|
'USER_MENU.ACTION_MANAGE_PREFERENCES',
|
||||||
'/settings/preferences'
|
'/settings/preferences'
|
||||||
));
|
));
|
||||||
@@ -305,7 +303,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
|||||||
|
|
||||||
// Add generic link to the first-available settings page
|
// Add generic link to the first-available settings page
|
||||||
if (settingsPages.length) {
|
if (settingsPages.length) {
|
||||||
pages.push(new Page(
|
pages.push(new PageDefinition(
|
||||||
'USER_MENU.ACTION_MANAGE_SETTINGS',
|
'USER_MENU.ACTION_MANAGE_SETTINGS',
|
||||||
settingsPages[0].url
|
settingsPages[0].url
|
||||||
));
|
));
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
}]);
|
Reference in New Issue
Block a user