mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-09 14:41:21 +00:00
GUAC-1053 New endpoint for listing languages, JS service for retrieving languages, and settings section for choosing language.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Glyptodon LLC
|
||||
* Copyright (C) 2015 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
|
||||
@@ -41,6 +41,13 @@ angular.module('rest').factory('cacheService', ['$injector',
|
||||
*/
|
||||
service.connections = $cacheFactory('API-CONNECTIONS');
|
||||
|
||||
/**
|
||||
* Cache used by languageService.
|
||||
*
|
||||
* @type $cacheFactory.Cache
|
||||
*/
|
||||
service.languages = $cacheFactory('API-LANGUAGES');
|
||||
|
||||
/**
|
||||
* Cache used by protocolService.
|
||||
*
|
||||
@@ -59,8 +66,9 @@ angular.module('rest').factory('cacheService', ['$injector',
|
||||
* Clear all caches defined in this service.
|
||||
*/
|
||||
service.clearCaches = function clearCaches() {
|
||||
service.protocols.removeAll();
|
||||
service.connections.removeAll();
|
||||
service.languages.removeAll();
|
||||
service.protocols.removeAll();
|
||||
service.users.removeAll();
|
||||
};
|
||||
|
||||
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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 language metadata via the REST API.
|
||||
*/
|
||||
angular.module('rest').factory('languageService', ['$injector',
|
||||
function languageService($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 languages, returning
|
||||
* a promise that provides a map of language names by language key if
|
||||
* successful.
|
||||
*
|
||||
* @returns {Promise.<Object.<String, String>>}
|
||||
* A promise which will resolve with a map of language names by
|
||||
* language key upon success.
|
||||
*/
|
||||
service.getLanguages = function getLanguages() {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
token : authenticationService.getCurrentToken()
|
||||
};
|
||||
|
||||
// Retrieve available protocols
|
||||
return $http({
|
||||
cache : cacheService.languages,
|
||||
method : 'GET',
|
||||
url : 'api/languages',
|
||||
params : httpParameters
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
return service;
|
||||
|
||||
}]);
|
Reference in New Issue
Block a user