You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/05/04 08:27:04 UTC

[10/21] guacamole-client git commit: GUACAMOLE-220: Move common protocol namespace/name retrieval to Protocol class.

GUACAMOLE-220: Move common protocol namespace/name retrieval to Protocol class.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/82803c91
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/82803c91
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/82803c91

Branch: refs/heads/master
Commit: 82803c914831bd860f1c9c045e0c5177042c6e24
Parents: c1f5ad4
Author: Michael Jumper <mj...@apache.org>
Authored: Tue May 1 12:42:36 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue May 1 20:58:28 2018 -0700

----------------------------------------------------------------------
 .../controllers/manageConnectionController.js   | 47 ++---------------
 .../manageSharingProfileController.js           | 27 ++--------
 .../src/main/webapp/app/rest/restModule.js      |  3 +-
 .../src/main/webapp/app/rest/types/Protocol.js  | 54 +++++++++++++++++++-
 4 files changed, 62 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/82803c91/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js b/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js
index 7cd08ac..ac55f11 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:
-     *
-     * <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

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/82803c91/guacamole/src/main/webapp/app/manage/controllers/manageSharingProfileController.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageSharingProfileController.js b/guacamole/src/main/webapp/app/manage/controllers/manageSharingProfileController.js
index a0a683c..940c305 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:
-     *
-     * <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

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/82803c91/guacamole/src/main/webapp/app/rest/restModule.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/rest/restModule.js b/guacamole/src/main/webapp/app/rest/restModule.js
index f409e95..23901c0 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'
 ]);

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/82803c91/guacamole/src/main/webapp/app/rest/types/Protocol.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/rest/types/Protocol.js b/guacamole/src/main/webapp/app/rest/types/Protocol.js
index cfb26f0..0b86d5b 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:
+     *
+     * <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;
 
 }]);
\ No newline at end of file