You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2016/03/20 03:22:14 UTC

[34/50] incubator-guacamole-client git commit: GUAC-1378: Add service for communicating with the /api/patches REST endpoint.

GUAC-1378: Add service for communicating with the /api/patches REST endpoint.

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

Branch: refs/heads/master
Commit: bda64a21081800b4fc8165006c7f96b35903a0e2
Parents: 4881e5c
Author: Michael Jumper <mi...@guac-dev.org>
Authored: Fri Feb 19 00:22:43 2016 -0800
Committer: Michael Jumper <mi...@guac-dev.org>
Committed: Fri Feb 19 00:22:43 2016 -0800

----------------------------------------------------------------------
 .../webapp/app/rest/services/cacheService.js    |  7 +++
 .../webapp/app/rest/services/patchService.js    | 65 ++++++++++++++++++++
 2 files changed, 72 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/bda64a21/guacamole/src/main/webapp/app/rest/services/cacheService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/rest/services/cacheService.js b/guacamole/src/main/webapp/app/rest/services/cacheService.js
index ef523dc..9fb9b44 100644
--- a/guacamole/src/main/webapp/app/rest/services/cacheService.js
+++ b/guacamole/src/main/webapp/app/rest/services/cacheService.js
@@ -49,6 +49,13 @@ angular.module('rest').factory('cacheService', ['$injector',
     service.languages = $cacheFactory('API-LANGUAGES');
 
     /**
+     * Cache used by patchService.
+     *
+     * @type $cacheFactory.Cache
+     */
+    service.patches = $cacheFactory('API-PATCHES');
+
+    /**
      * Cache used by schemaService.
      *
      * @type $cacheFactory.Cache

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/bda64a21/guacamole/src/main/webapp/app/rest/services/patchService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/rest/services/patchService.js b/guacamole/src/main/webapp/app/rest/services/patchService.js
new file mode 100644
index 0000000..b3db669
--- /dev/null
+++ b/guacamole/src/main/webapp/app/rest/services/patchService.js
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+/**
+ * Service for operating on HTML patches via the REST API.
+ */
+angular.module('rest').factory('patchService', ['$injector',
+        function patchService($injector) {
+
+    // Required services
+    var $http                 = $injector.get('$http');
+    var authenticationService = $injector.get('authenticationService');
+    var cacheService          = $injector.get('cacheService');
+
+    var service = {};
+    
+    /**
+     * Makes a request to the REST API to get the list of patches, returning
+     * a promise that provides the array of all applicable patches if
+     * successful. Each patch is a string of raw HTML with meta information
+     * describing the patch operation stored within meta tags.
+     *                          
+     * @returns {Promise.<String[]>}
+     *     A promise which will resolve with an array of HTML patches upon
+     *     success.
+     */
+    service.getPatches = function getPatches() {
+
+        // Build HTTP parameters set
+        var httpParameters = {
+            token : authenticationService.getCurrentToken()
+        };
+
+        // Retrieve all applicable HTML patches
+        return $http({
+            cache   : cacheService.patches,
+            method  : 'GET',
+            url     : 'api/patches',
+            params  : httpParameters
+        });
+
+    };
+    
+    return service;
+
+}]);