Use ng-options instead of options element in FixedProfile.

This commit is contained in:
FelisCatus 2017-07-05 15:59:00 -04:00
parent 852e811f5a
commit 788bfe7d4e
2 changed files with 19 additions and 8 deletions

View File

@ -1,4 +1,5 @@
angular.module('omega').controller 'FixedProfileCtrl', ($scope, $modal) ->
angular.module('omega').controller 'FixedProfileCtrl', ($scope, $modal,
trFilter) ->
$scope.urlSchemes = ['', 'http', 'https', 'ftp']
$scope.urlSchemeDefault = 'fallbackProxy'
proxyProperties =
@ -20,6 +21,21 @@ angular.module('omega').controller 'FixedProfileCtrl', ($scope, $modal) ->
$scope.showAdvanced = false
$scope.optionsForScheme = {}
for scheme in $scope.urlSchemes
defaultLabel =
if scheme
trFilter('options_protocol_useDefault')
else
trFilter('options_protocol_direct')
$scope.optionsForScheme[scheme] = [
{label: defaultLabel, value: undefined},
{label: 'HTTP', value: 'http'},
{label: 'HTTPS', value: 'https'},
{label: 'SOCKS4', value: 'socks4'},
{label: 'SOCKS5', value: 'socks5'},
]
$scope.proxyEditors = {}
$scope.authSupported = {"http": true, "https": true}

View File

@ -14,13 +14,8 @@ div(ng-controller='FixedProfileCtrl')
tr(ng-repeat='scheme in urlSchemes' ng-show='scheme == "" || showAdvanced')
td {{schemeDisp[scheme] || ('options_scheme_default' | tr)}}
td
select.form-control(ng-model='proxyEditors[scheme].scheme')
option(value='')
| {{(scheme ? 'options_protocol_useDefault' : 'options_protocol_direct') | tr}}
option(value='http') HTTP
option(value='https') HTTPS
option(value='socks4') SOCKS4
option(value='socks5') SOCKS5
select.form-control(ng-model='proxyEditors[scheme].scheme'
ng-options='opt.value as opt.label for opt in optionsForScheme[scheme]')
td(ng-if='proxyEditors[scheme].scheme')
input.form-control(type='text' ng-model='proxyEditors[scheme].host' required)
td(ng-if='!proxyEditors[scheme].scheme')