mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUACAMOLE-220: Move common protocol namespace/name retrieval to Protocol class.
This commit is contained in:
		| @@ -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: | ||||
|      * | ||||
|      * <code>PROTOCOL_NAME</code> | ||||
|      * | ||||
|      * where <code>NAME</code> 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: | ||||
|      * | ||||
|      * <code>NAMESPACE.NAME<code> | ||||
|      * | ||||
|      * where <code>NAMESPACE</code> 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 | ||||
|   | ||||
| @@ -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: | ||||
|      * | ||||
|      * <code>PROTOCOL_NAME</code> | ||||
|      * | ||||
|      * where <code>NAME</code> 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 | ||||
|   | ||||
| @@ -22,5 +22,6 @@ | ||||
|  * Guacamole web application. | ||||
|  */ | ||||
| angular.module('rest', [ | ||||
|     'auth' | ||||
|     'auth', | ||||
|     'locale' | ||||
| ]); | ||||
|   | ||||
| @@ -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: | ||||
|      * | ||||
|      * <code>PROTOCOL_NAME</code> | ||||
|      * | ||||
|      * where <code>NAME</code> 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: | ||||
|      * | ||||
|      * <code>NAMESPACE.NAME<code> | ||||
|      * | ||||
|      * where <code>NAMESPACE</code> 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; | ||||
|  | ||||
| }]); | ||||
		Reference in New Issue
	
	Block a user