GUACAMOLE-422: Implement client-side timezone detection.

This commit is contained in:
Nick Couchman
2018-06-02 21:04:01 -04:00
committed by Virtually Nick
parent 8b443dc9d5
commit ea913c98fe
7 changed files with 45 additions and 6 deletions

View File

@@ -493,6 +493,14 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- JSTZ for TimeZone Detection -->
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>jstz</artifactId>
<version>1.0.10</version>
</dependency>
</dependencies> </dependencies>

View File

@@ -38,6 +38,7 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
// Required services // Required services
var $translate = $injector.get('$translate'); var $translate = $injector.get('$translate');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var formService = $injector.get('formService');
var guacNotification = $injector.get('guacNotification'); var guacNotification = $injector.get('guacNotification');
var languageService = $injector.get('languageService'); var languageService = $injector.get('languageService');
var permissionService = $injector.get('permissionService'); var permissionService = $injector.get('permissionService');

View File

@@ -98,6 +98,17 @@ angular.module('settings').provider('preferenceService', ['$injector',
return language.replace(/-/g, '_'); return language.replace(/-/g, '_');
}; };
/**
* Return the timezone detected for the current browser session
* by the JSTZ timezone library.
*
* @returns String
* The name of the currently-detected timezone.
*/
var getDetectedTimezone = function getDetectedTimezone() {
return jstz.determine().name();
};
/** /**
* All currently-set preferences, as name/value pairs. Each property name * All currently-set preferences, as name/value pairs. Each property name
@@ -128,7 +139,13 @@ angular.module('settings').provider('preferenceService', ['$injector',
* *
* @type String * @type String
*/ */
language : getDefaultLanguageKey() language : getDefaultLanguageKey(),
/**
* The timezone set by the uesr.
* @type String
*/
timezone : getDetectedTimezone()
}; };

View File

@@ -18,7 +18,7 @@
*/ */
.preferences .update-password .form, .preferences .update-password .form,
.preferences .language .form { .preferences .locale .form {
padding-left: 0.5em; padding-left: 0.5em;
border-left: 3px solid rgba(0, 0, 0, 0.125); border-left: 3px solid rgba(0, 0, 0, 0.125);
} }

View File

@@ -1,8 +1,8 @@
<div class="preferences" ng-class="{loading: !isLoaded()}"> <div class="preferences" ng-class="{loading: !isLoaded()}">
<!-- Language settings --> <!-- Locale settings -->
<div class="settings section language"> <div class="settings section locale">
<p>{{'SETTINGS_PREFERENCES.HELP_LANGUAGE' | translate}}</p> <p>{{'SETTINGS_PREFERENCES.HELP_LOCALE' | translate}}</p>
<!-- Language selection --> <!-- Language selection -->
<div class="form"> <div class="form">
@@ -13,6 +13,15 @@
</tr> </tr>
</table> </table>
</div> </div>
<!-- Timezone selection -->
<div class="form">
<guac-form-field
field="{ 'type' : 'TIMEZONE', 'name' : 'timezone' }"
model="preferences.timezone"
namespace="'SETTINGS_PREFERENCES'">
</guac-form-field>
</div>
</div> </div>
<!-- Password update --> <!-- Password update -->

View File

@@ -85,6 +85,9 @@
<script type="text/javascript" src="webjars/angular-translate-interpolation-messageformat/2.16.0/angular-translate-interpolation-messageformat.min.js"></script> <script type="text/javascript" src="webjars/angular-translate-interpolation-messageformat/2.16.0/angular-translate-interpolation-messageformat.min.js"></script>
<script type="text/javascript" src="webjars/angular-translate-loader-static-files/2.16.0/angular-translate-loader-static-files.min.js"></script> <script type="text/javascript" src="webjars/angular-translate-loader-static-files/2.16.0/angular-translate-loader-static-files.min.js"></script>
<!-- JSTZ -->
<script type="text/javascript" src="webjars/jstz/1.0.10/dist/jstz.min.js"></script>
<!-- Polyfills for the "datalist" element, Blob and the FileSaver API --> <!-- Polyfills for the "datalist" element, Blob and the FileSaver API -->
<script type="text/javascript" src="webjars/blob-polyfill/1.0.20150320/Blob.js"></script> <script type="text/javascript" src="webjars/blob-polyfill/1.0.20150320/Blob.js"></script>
<script type="text/javascript" src="webjars/datalist-polyfill/1.14.0/datalist-polyfill.min.js"></script> <script type="text/javascript" src="webjars/datalist-polyfill/1.14.0/datalist-polyfill.min.js"></script>

View File

@@ -755,6 +755,7 @@
"FIELD_HEADER_PASSWORD_OLD" : "Current Password:", "FIELD_HEADER_PASSWORD_OLD" : "Current Password:",
"FIELD_HEADER_PASSWORD_NEW" : "New Password:", "FIELD_HEADER_PASSWORD_NEW" : "New Password:",
"FIELD_HEADER_PASSWORD_NEW_AGAIN" : "Confirm New Password:", "FIELD_HEADER_PASSWORD_NEW_AGAIN" : "Confirm New Password:",
"FIELD_HEADER_TIMEZONE" : "Timezone:",
"FIELD_HEADER_USERNAME" : "Username:", "FIELD_HEADER_USERNAME" : "Username:",
"HELP_DEFAULT_INPUT_METHOD" : "The default input method determines how keyboard events are received by Guacamole. Changing this setting may be necessary when using a mobile device, or when typing through an IME. This setting can be overridden on a per-connection basis within the Guacamole menu.", "HELP_DEFAULT_INPUT_METHOD" : "The default input method determines how keyboard events are received by Guacamole. Changing this setting may be necessary when using a mobile device, or when typing through an IME. This setting can be overridden on a per-connection basis within the Guacamole menu.",
@@ -762,7 +763,7 @@
"HELP_INPUT_METHOD_NONE" : "@:CLIENT.HELP_INPUT_METHOD_NONE", "HELP_INPUT_METHOD_NONE" : "@:CLIENT.HELP_INPUT_METHOD_NONE",
"HELP_INPUT_METHOD_OSK" : "@:CLIENT.HELP_INPUT_METHOD_OSK", "HELP_INPUT_METHOD_OSK" : "@:CLIENT.HELP_INPUT_METHOD_OSK",
"HELP_INPUT_METHOD_TEXT" : "@:CLIENT.HELP_INPUT_METHOD_TEXT", "HELP_INPUT_METHOD_TEXT" : "@:CLIENT.HELP_INPUT_METHOD_TEXT",
"HELP_LANGUAGE" : "Select a different language below to change the language of all text within Guacamole. Available choices will depend on which languages are installed.", "HELP_LOCALE" : "Options below are related to the locale of the user and will impact how various parts of the interface are displayed.",
"HELP_MOUSE_MODE_ABSOLUTE" : "@:CLIENT.HELP_MOUSE_MODE_ABSOLUTE", "HELP_MOUSE_MODE_ABSOLUTE" : "@:CLIENT.HELP_MOUSE_MODE_ABSOLUTE",
"HELP_MOUSE_MODE_RELATIVE" : "@:CLIENT.HELP_MOUSE_MODE_RELATIVE", "HELP_MOUSE_MODE_RELATIVE" : "@:CLIENT.HELP_MOUSE_MODE_RELATIVE",
"HELP_UPDATE_PASSWORD" : "If you wish to change your password, enter your current password and the desired new password below, and click \"Update Password\". The change will take effect immediately.", "HELP_UPDATE_PASSWORD" : "If you wish to change your password, enter your current password and the desired new password below, and click \"Update Password\". The change will take effect immediately.",