diff --git a/src/js/client.js b/src/js/client.js index b9b56a542..bfa60a858 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -682,6 +682,22 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }); }; + Client.prototype.setRegistryConfig = function (rc, callback) { + post('/api/v1/settings/registry_config', rc, null, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + callback(null); + }); + }; + + Client.prototype.getRegistryConfig = function (callback) { + get('/api/v1/settings/registry_config', null, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + callback(null, data); + }); + }; + Client.prototype.getUpdateInfo = function (callback) { if (!this._userInfo.admin) return callback(new Error('Not allowed')); diff --git a/src/views/settings.html b/src/views/settings.html index 357557e9b..03ce45368 100644 --- a/src/views/settings.html +++ b/src/views/settings.html @@ -94,6 +94,43 @@ + + +
@@ -268,6 +305,41 @@
+
+

Private Docker Registry

+
+ +
+
+
+ Cloudron can pull and install apps from private docker registry. +
+
+
+
+
+ Server address +
+
+ {{ registryConfig.serverAddress || 'Not set' }} +
+
+
+
+ Username +
+
+ {{ registryConfig.username || 'Not set' }} +
+
+
+
+
+ +
+
+
+

Unstable App Listing

diff --git a/src/views/settings.js b/src/views/settings.js index 9da890fd5..04eb89ef1 100644 --- a/src/views/settings.js +++ b/src/views/settings.js @@ -308,6 +308,16 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca }); } + function getRegistryConfig() { + Client.getRegistryConfig(function (error, result) { + if (error) return console.error(error); + + $scope.registryConfig.serverAddress = result.serverAddress; + $scope.registryConfig.username = result.username; + $scope.registryConfig.password = result.password; + }); + } + function getSubscription() { $scope.subscriptionBusy = true; @@ -353,6 +363,50 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca fr.readAsDataURL(event.target.files[0]); }; + $scope.registryConfig = { + busy: false, + error: null, + serverAddress: '', + username: '', + password: '', + + reset: function () { + $scope.cloudronNameChange.busy = false; + $scope.registryConfig.error = null; + + $scope.registryConfigForm.$setUntouched(); + $scope.registryConfigForm.$setPristine(); + }, + + show: function () { + $scope.registryConfig.reset(); + $('#registryConfigModal').modal('show'); + }, + + submit: function () { + $scope.registryConfig.busy = true; + + var data = { + serverAddress: $scope.registryConfig.serverAddress, + username: $scope.registryConfig.username, + password: $scope.registryConfig.password + }; + + Client.setRegistryConfig(data, function (error) { + $scope.registryConfig.busy = false; + + if (error) { + $scope.registryConfig.error = error; + return; + } + + $('#registryConfigModal').modal('hide'); + + getRegistryConfig(); + }); + } + }; + $scope.unstableApps = { busy: false, enabled: false, @@ -425,6 +479,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca Client.onReady(function () { getAutoupdatePattern(); getUnstableAppsConfig(); + getRegistryConfig(); $scope.update.checkStatus();