Add time zone settings ui

This commit is contained in:
Johannes Zellner
2020-01-07 21:41:45 +01:00
parent 2328dd1d58
commit 1fef7130fb
5 changed files with 85 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
/* global angular:false */
/* global $:false */
/* global moment */
angular.module('Application').controller('SettingsController', ['$scope', '$location', '$rootScope', '$timeout', 'Client', function ($scope, $location, $rootScope, $timeout, Client) {
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
@@ -257,6 +258,31 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
return provider === 's3' || provider === 'minio' || provider === 's3-v4-compat' || provider === 'exoscale-sos' || provider === 'digitalocean-spaces';
};
$scope.timeZone = {
busy: false,
success: false,
error: '',
timeZone: '',
currentTimeZone: '',
availableTimeZones: moment.tz.names(),
submit: function () {
if ($scope.timeZone.timeZone === $scope.timeZone.currentTimeZone) return;
$scope.timeZone.error = '';
$scope.timeZone.busy = true;
$scope.timeZone.success = false;
Client.setTimeZone($scope.timeZone.timeZone, function (error) {
if (error) $scope.timeZone.error = error.message;
else $scope.timeZone.currentTimeZone = $scope.timeZone.timeZone;
$scope.timeZone.busy = false;
$scope.timeZone.success = true;
});
}
}
$scope.autoUpdate = {
busy: false,
success: false,
@@ -291,6 +317,15 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
}
};
function getTimeZone() {
Client.getTimeZone(function (error, timeZone) {
if (error) return console.error(error);
$scope.timeZone.currentTimeZone = timeZone;
$scope.timeZone.timeZone = timeZone;
});
}
function getAutoupdatePattern() {
Client.getAppAutoupdatePattern(function (error, result) {
if (error) return console.error(error);
@@ -458,6 +493,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
Client.onReady(function () {
getAutoupdatePattern();
getRegistryConfig();
getTimeZone();
$scope.update.checkStatus();