From 0641da786c1705978ab6507ead96a3c3226b2e14 Mon Sep 17 00:00:00 2001 From: Fabrice Marsaud Date: Tue, 27 Oct 2015 16:05:31 +0100 Subject: [PATCH] Proxy auth for update panel --- app/modules/settings/update/index.js | 10 ++++++- app/modules/settings/update/view.jade | 42 +++++++++++++++++---------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/app/modules/settings/update/index.js b/app/modules/settings/update/index.js index abe2e2bc8..df871cbd3 100644 --- a/app/modules/settings/update/index.js +++ b/app/modules/settings/update/index.js @@ -45,6 +45,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 @@ -74,12 +75,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 e7321651c..aa2d2780a 100644 --- a/app/modules/settings/update/view.jade +++ b/app/modules/settings/update/view.jade @@ -88,23 +88,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