add ability to set cloudron language for admins

This commit is contained in:
Johannes Zellner
2020-11-18 00:28:10 +01:00
parent fd8077d9f5
commit 15b9ce0ee3
4 changed files with 38 additions and 25 deletions
+18 -9
View File
@@ -338,6 +338,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
// window.location fallback for websocket connections which do not have relative uris
this.apiOrigin = '<%= apiOrigin %>' || window.location.origin;
this.avatar = '';
this._availableLanguages = ['en'];
this._appstoreAppCache = [];
this.resetAvatar();
@@ -498,6 +499,10 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
return this._config;
};
Client.prototype.getAvailableLanguages = function () {
return this._availableLanguages;
};
Client.prototype.setToken = function (accessToken) {
if (!accessToken) localStorage.removeItem('token');
else localStorage.token = accessToken;
@@ -988,15 +993,6 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
Client.prototype.getAvailableLanguages = function (callback) {
get('/api/v1/settings/language', null, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data.language);
});
};
Client.prototype.getRemoteSupport = function (callback) {
get('/api/v1/support/remote_support', null, function (error, data, status) {
if (error) return callback(error);
@@ -1863,6 +1859,19 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
Client.prototype.refreshAvailableLanguages = function (callback) {
var that = this;
get('/api/v1/cloudron/languages', null, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
angular.copy(data.languages, that._availableLanguages);
callback(null, data.languages);
});
};
Client.prototype._appPostProcess = function (app) {
// calculate the icon paths
app.iconUrl = app.iconUrl ? (this.apiOrigin + app.iconUrl + '?access_token=' + token + '&' + app.manifest.version) : null;
+15 -11
View File
@@ -122,24 +122,28 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
Client.refreshConfig(function (error) {
if (error) return Client.initError(error, init);
Client.refreshInstalledApps(function (error) {
Client.refreshAvailableLanguages(function (error) {
if (error) return Client.initError(error, init);
// now mark the Client to be ready
Client.setReady();
Client.refreshInstalledApps(function (error) {
if (error) return Client.initError(error, init);
$scope.config = Client.getConfig();
// now mark the Client to be ready
Client.setReady();
$scope.initialized = true;
$scope.config = Client.getConfig();
if (Client.getConfig().mandatory2FA && !Client.getUserInfo().twoFactorAuthenticationEnabled) {
$location.path('/profile').search({ setup2fa: true });
return;
}
$scope.initialized = true;
refreshNotifications(true);
if (Client.getConfig().mandatory2FA && !Client.getUserInfo().twoFactorAuthenticationEnabled) {
$location.path('/profile').search({ setup2fa: true });
return;
}
$scope.updateSubscriptionStatus();
refreshNotifications(true);
$scope.updateSubscriptionStatus();
});
});
});
});