mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-12 07:57:41 +00:00
GUACAMOLE-220: Move common protocol namespace/name retrieval to Protocol class.
This commit is contained in:
@@ -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