diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js b/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js index 7cd08ac01..ac55f11ca 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js @@ -29,6 +29,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i var HistoryEntryWrapper = $injector.get('HistoryEntryWrapper'); var ManagementPermissions = $injector.get('ManagementPermissions'); var PermissionSet = $injector.get('PermissionSet'); + var Protocol = $injector.get('Protocol'); // Required services var $location = $injector.get('$location'); @@ -41,7 +42,6 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i var permissionService = $injector.get('permissionService'); var requestService = $injector.get('requestService'); var schemaService = $injector.get('schemaService'); - var translationStringService = $injector.get('translationStringService'); /** * The unique identifier of the data source containing the connection being @@ -295,51 +295,14 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i }, angular.noop); /** - * Returns the translation string namespace for the protocol having the - * given name. The namespace will be of the form: - * - * PROTOCOL_NAME - * - * where NAME is the protocol name transformed via - * translationStringService.canonicalize(). - * - * @param {String} protocolName - * The name of the protocol. - * - * @returns {String} - * The translation namespace for the protocol specified, or null if no - * namespace could be generated. + * @borrows Protocol.getNamespace */ - $scope.getNamespace = function getNamespace(protocolName) { - - // Do not generate a namespace if no protocol is selected - if (!protocolName) - return null; - - return 'PROTOCOL_' + translationStringService.canonicalize(protocolName); - - }; + $scope.getNamespace = Protocol.getNamespace; /** - * Given the internal name of a protocol, produces the translation string - * for the localized version of that protocol's name. The translation - * string will be of the form: - * - * NAMESPACE.NAME - * - * where NAMESPACE is the namespace generated from - * $scope.getNamespace(). - * - * @param {String} protocolName - * The name of the protocol. - * - * @returns {String} - * The translation string which produces the localized name of the - * protocol specified. + * @borrows Protocol.getName */ - $scope.getProtocolName = function getProtocolName(protocolName) { - return $scope.getNamespace(protocolName) + '.NAME'; - }; + $scope.getProtocolName = Protocol.getName; /** * Cancels all pending edits, returning to the main list of connections diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageSharingProfileController.js b/guacamole/src/main/webapp/app/manage/controllers/manageSharingProfileController.js index a0a683c32..940c30509 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageSharingProfileController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageSharingProfileController.js @@ -27,6 +27,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope', var ManagementPermissions = $injector.get('ManagementPermissions'); var SharingProfile = $injector.get('SharingProfile'); var PermissionSet = $injector.get('PermissionSet'); + var Protocol = $injector.get('Protocol'); // Required services var $location = $injector.get('$location'); @@ -38,7 +39,6 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope', var requestService = $injector.get('requestService'); var schemaService = $injector.get('schemaService'); var sharingProfileService = $injector.get('sharingProfileService'); - var translationStringService = $injector.get('translationStringService'); /** * The unique identifier of the data source containing the sharing profile @@ -269,30 +269,9 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope', }, requestService.WARN); /** - * Returns the translation string namespace for the protocol having the - * given name. The namespace will be of the form: - * - * PROTOCOL_NAME - * - * where NAME is the protocol name transformed via - * translationStringService.canonicalize(). - * - * @param {String} protocolName - * The name of the protocol. - * - * @returns {String} - * The translation namespace for the protocol specified, or null if no - * namespace could be generated. + * @borrows Protocol.getNamespace */ - $scope.getNamespace = function getNamespace(protocolName) { - - // Do not generate a namespace if no protocol is selected - if (!protocolName) - return null; - - return 'PROTOCOL_' + translationStringService.canonicalize(protocolName); - - }; + $scope.getNamespace = Protocol.getNamespace; /** * Cancels all pending edits, returning to the main list of connections diff --git a/guacamole/src/main/webapp/app/rest/restModule.js b/guacamole/src/main/webapp/app/rest/restModule.js index f409e9545..23901c07c 100644 --- a/guacamole/src/main/webapp/app/rest/restModule.js +++ b/guacamole/src/main/webapp/app/rest/restModule.js @@ -22,5 +22,6 @@ * Guacamole web application. */ angular.module('rest', [ - 'auth' + 'auth', + 'locale' ]); diff --git a/guacamole/src/main/webapp/app/rest/types/Protocol.js b/guacamole/src/main/webapp/app/rest/types/Protocol.js index cfb26f02d..0b86d5b2d 100644 --- a/guacamole/src/main/webapp/app/rest/types/Protocol.js +++ b/guacamole/src/main/webapp/app/rest/types/Protocol.js @@ -20,8 +20,11 @@ /** * Service which defines the Protocol class. */ -angular.module('rest').factory('Protocol', [function defineProtocol() { - +angular.module('rest').factory('Protocol', ['$injector', function defineProtocol($injector) { + + // Required services + var translationStringService = $injector.get('translationStringService'); + /** * The object returned by REST API calls when representing the data * associated with a supported remote desktop protocol. @@ -64,6 +67,53 @@ angular.module('rest').factory('Protocol', [function defineProtocol() { }; + /** + * Returns the translation string namespace for the protocol having the + * given name. The namespace will be of the form: + * + * PROTOCOL_NAME + * + * where NAME is the protocol name transformed via + * translationStringService.canonicalize(). + * + * @param {String} protocolName + * The name of the protocol. + * + * @returns {String} + * The translation namespace for the protocol specified, or null if no + * namespace could be generated. + */ + Protocol.getNamespace = function getNamespace(protocolName) { + + // Do not generate a namespace if no protocol is selected + if (!protocolName) + return null; + + return 'PROTOCOL_' + translationStringService.canonicalize(protocolName); + + }; + + /** + * Given the internal name of a protocol, produces the translation string + * for the localized version of that protocol's name. The translation + * string will be of the form: + * + * NAMESPACE.NAME + * + * where NAMESPACE is the namespace generated from + * $scope.getNamespace(). + * + * @param {String} protocolName + * The name of the protocol. + * + * @returns {String} + * The translation string which produces the localized name of the + * protocol specified. + */ + Protocol.getName = function getProtocolName(protocolName) { + return Protocol.getNamespace(protocolName) + '.NAME'; + }; + return Protocol; }]); \ No newline at end of file