add provider to registry config

this way there is a clear way to disable/remove config
This commit is contained in:
Girish Ramakrishnan
2021-02-09 14:29:40 -08:00
parent 419e1d65e4
commit eb7530b5fd
2 changed files with 37 additions and 14 deletions
+10 -2
View File
@@ -96,10 +96,17 @@
<h4 class="modal-title">{{ 'settings.privateDockerRegistryDialog.title' | tr }}</h4>
</div>
<div class="modal-body">
<p class="has-error text-center" ng-show="registryConfig.error">{{ registryConfig.error }}</p>
<div class="form-group">
<label class="control-label" for="registryConfigProvider">{{ 'settings.registryConfig.provider' | tr }} <sup><a ng-href="https://docs.cloudron.io/settings/#private-docker-registry" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></label>
<select class="form-control" id="registryConfigProvider" ng-model="registryConfig.provider" ng-options="a.value as a.name for a in registryConfigProviders"></select>
</div>
<div uib-collapse="registryConfig.provider === 'noop'">
<form name="registryConfigForm" role="form" novalidate ng-submit="registryConfig.submit()" autocomplete="off">
<fieldset>
<p class="has-error text-center" ng-show="registryConfig.error">{{ registryConfig.error }}</p>
<div class="form-group">
<label class="control-label" for="registryConfigServerAddress">{{ 'settings.privateDockerRegistry.server' | tr }}</label>
<input type="text" class="form-control" ng-model="registryConfig.serverAddress" id="registryConfigServerAddress" name="serveraddress" ng-disabled="registryConfig.busy" placeholder="docker.io" ng-required>
@@ -121,6 +128,7 @@
</div>
</fieldset>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'main.dialog.cancel' | tr }}</button>
+27 -12
View File
@@ -34,6 +34,18 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
{ name: '8 PM', value: 20 }, { name: '9 PM', value: 21 }, { name: '10 PM', value: 22 }, { name: '11 PM', value: 23 }
];
$scope.registryConfigProviders = [
{ name: 'AWS', value: 'aws' },
{ name: 'Digital Ocean', value: 'digitalocean' },
{ name: 'DockerHub', value: 'dockerhub' },
{ name: 'Google Cloud', value: 'google-cloud' },
{ name: 'Linode', value: 'linode' },
{ name: 'Other', value: 'other' },
{ name: 'Quay', value: 'quay' },
{ name: 'Treescale', value: 'treescale' },
{ name: 'Disabled', value: 'noop' }
];
$scope.openSubscriptionSetup = function () {
Client.openSubscriptionSetup($scope.subscription || {});
};
@@ -321,10 +333,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
Client.getRegistryConfig(function (error, result) {
if (error) return console.error(error);
$scope.registryConfig.currentConfig.serverAddress = result.serverAddress;
$scope.registryConfig.currentConfig.username = result.username || '';
$scope.registryConfig.currentConfig.email = result.email || '';
$scope.registryConfig.currentConfig.password = result.password;
$scope.registryConfig.currentConfig = result;
});
}
@@ -345,6 +354,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
busy: false,
error: null,
serverAddress: '',
provider: 'noop',
username: '',
password: '',
email: '',
@@ -354,10 +364,11 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
$scope.registryConfig.busy = false;
$scope.registryConfig.error = null;
$scope.registryConfig.serverAddress = $scope.registryConfig.currentConfig.serverAddress;
$scope.registryConfig.username = $scope.registryConfig.currentConfig.username;
$scope.registryConfig.email = $scope.registryConfig.currentConfig.email;
$scope.registryConfig.password = $scope.registryConfig.currentConfig.password;
$scope.registryConfig.provider = $scope.registryConfig.currentConfig.provider;
$scope.registryConfig.serverAddress = $scope.registryConfig.currentConfig.serverAddress || '';
$scope.registryConfig.username = $scope.registryConfig.currentConfig.username || '';
$scope.registryConfig.email = $scope.registryConfig.currentConfig.email || '';
$scope.registryConfig.password = $scope.registryConfig.currentConfig.password || '';
$scope.registryConfigForm.$setUntouched();
$scope.registryConfigForm.$setPristine();
@@ -372,12 +383,16 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
$scope.registryConfig.busy = true;
var data = {
serverAddress: $scope.registryConfig.serverAddress,
username: $scope.registryConfig.username || '',
password: $scope.registryConfig.password,
email: $scope.registryConfig.email || '',
provider: $scope.registryConfig.provider
};
if ($scope.registryConfig.provider !== 'noop') {
data.serverAddress = $scope.registryConfig.serverAddress;
data.username = $scope.registryConfig.username || '';
data.password = $scope.registryConfig.password;
data.email = $scope.registryConfig.email || '';
}
Client.setRegistryConfig(data, function (error) {
$scope.registryConfig.busy = false;