mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-1378: Add service for communicating with the /api/patches REST endpoint.
This commit is contained in:
@@ -48,6 +48,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.
|
||||
*
|
||||
|
65
guacamole/src/main/webapp/app/rest/services/patchService.js
Normal file
65
guacamole/src/main/webapp/app/rest/services/patchService.js
Normal file
@@ -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;
|
||||
|
||||
}]);
|
Reference in New Issue
Block a user