diff --git a/src/js/client.js b/src/js/client.js index e262d911b..bf9cfe990 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -134,8 +134,6 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N this.apiOrigin = '<%= oauth.apiOrigin %>' || window.location.origin; this.avatar = ''; - this._refreshConfigTimer = null; - this.resetAvatar(); this.setToken(localStorage.token); @@ -283,9 +281,7 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N * Rest API wrappers */ Client.prototype.config = function (callback) { - var configRoute = this.hasScope('cloudron') ? '/api/v1/cloudron/config' : '/api/v1/user/cloudron_config'; - - get(configRoute).success(function(data, status) { + get('/api/v1/config').success(function(data, status) { if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data)); callback(null, data); }).error(defaultErrorHandler(callback)); @@ -497,6 +493,13 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N }).error(defaultErrorHandler(callback)); }; + Client.prototype.getUpdateInfo = function (callback) { + get('/api/v1/cloudron/update').success(function(data, status) { + if (status !== 200) return callback(new ClientError(status, data)); + callback(null, data); + }).error(defaultErrorHandler(callback)); + }; + Client.prototype.checkForUpdates = function (callback) { var that = this; @@ -550,6 +553,13 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N }).error(defaultErrorHandler(callback)); }; + Client.prototype.getCaasConfig = function (callback) { + get('/api/v1/caas/config').success(function(data, status) { + if (status !== 200) return callback(new ClientError(status, data)); + callback(null, data); + }).error(defaultErrorHandler(callback)); + }; + Client.prototype.addAuthorizedKey = function (key, callback) { put('/api/v1/cloudron/ssh/authorized_keys', { key: key }).success(function (data, status) { if (status !== 201) return callback(new ClientError(status, data)); @@ -971,6 +981,17 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N }).error(defaultErrorHandler(callback)); }; + Client.prototype.transferOwnership = function (oldOwnerId, newOwnerId, callback) { + var data = { + ownerId: newOwnerId + }; + + post('/api/v1/users/' + oldOwnerId + '/transfer', data).success(function (data, status) { + if (status !== 200) return callback(new ClientError(status, data)); + callback(null); + }).error(defaultErrorHandler(callback)); + }; + Client.prototype.removeUser = function (userId, password, callback) { var config = { data: { @@ -1058,9 +1079,12 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N this.config(function (error, result) { if (error) return callback(error); - that.setConfig(result); + that.getUpdateInfo(function (error, info) { // note: non-admin users may get access denied for this + if (!error) result.update = info.update; // attach update information to config object - callback(null); + that.setConfig(result); + callback(null); + }); }); }; diff --git a/src/views/settings.html b/src/views/settings.html index 5b4db186e..83018915e 100644 --- a/src/views/settings.html +++ b/src/views/settings.html @@ -168,7 +168,7 @@