diff --git a/app/modules/settings/update/index.js b/app/modules/settings/update/index.js index 0d16ea918..b53bc62b8 100644 --- a/app/modules/settings/update/index.js +++ b/app/modules/settings/update/index.js @@ -41,6 +41,7 @@ export default angular.module('settings.update', [ this.updater.getConfiguration() .then(configuration => this.configuration = _assign({}, configuration)) + .then(() => this.withAuth = Boolean(this.configuration.proxyUser)) .catch(error => notify.error({ title: 'XOA Updater', message: error.message @@ -71,12 +72,19 @@ export default angular.module('settings.update', [ })) } - this.configure = (host, port) => { + this.configure = (host, port, username, password) => { const config = {} + if (!this.withAuth) { + username = null + password = null + } config.proxyHost = host && host.trim() || null config.proxyPort = port && port.trim() || null + config.proxyUser = username || null + config.proxyPassword = password || null return this.updater.configure(config) .then(configuration => this.configuration = _assign({}, configuration)) + .then(() => this.withAuth = Boolean(this.configuration.proxyUser)) .catch(error => notify.error({ title: 'XOA Updater', message: error.message diff --git a/app/modules/settings/update/view.jade b/app/modules/settings/update/view.jade index 112fa5961..56f7fcc9e 100644 --- a/app/modules/settings/update/view.jade +++ b/app/modules/settings/update/view.jade @@ -95,23 +95,33 @@ i.fa.fa-cogs | Settings .panel-body - form.form-inline(ng-submit = 'ctrl.configure(ctrl.configuration.proxyHost, ctrl.configuration.proxyPort)') + form(ng-submit = 'ctrl.configure(ctrl.configuration.proxyHost, ctrl.configuration.proxyPort, ctrl.configuration.proxyUser, ctrl.configuration.proxyPassword)') + h4 + i.fa.fa-globe + | Proxy settings + p + | If you need a proxy to access the Internet  + label + input(type = 'checkbox', ng-model = 'ctrl.withAuth') +  with authentication + fieldset.form-inline + .form-group + //- label.control-label Host:  + input.form-control(type = 'text', ng-model = 'ctrl.configuration.proxyHost', placeholder = 'Host (myproxy.example.org)') + |   + .form-group + //- label.control-label Port:  + input.form-control(type = 'text', ng-model = 'ctrl.configuration.proxyPort', placeholder = 'Port (3128 ?...)') + br + div(ng-hide = '!ctrl.withAuth') + fieldset.form-inline(ng-disabled = '!ctrl.withAuth') + .form-group + input.form-control(type = 'text', ng-model = 'ctrl.configuration.proxyUser', placeholder = 'User name', required) + |   + .form-group + input.form-control(type = 'password', ng-model = 'ctrl.configuration.proxyPassword', placeholder = 'Password') + br fieldset - h4 - i.fa.fa-globe - | Proxy settings - p If you need a proxy to access the Internet - .form-group - label.control-label Host:  - input.form-control(type = 'text', ng-model = 'ctrl.configuration.proxyHost', placeholder = 'myproxy.example.org') - |   - |   - .form-group - label.control-label Port:  - input.form-control(type = 'text', ng-model = 'ctrl.configuration.proxyPort', placeholder = '3128') - |   - |   - |   .form-group button.btn.btn-primary(type = 'submit') i.fa.fa-floppy-o