-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathpac_profile.coffee
More file actions
49 lines (43 loc) · 1.81 KB
/
Copy pathpac_profile.coffee
File metadata and controls
49 lines (43 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
angular.module('omega').controller 'PacProfileCtrl', ($scope, $uibModal) ->
# coffeelint: disable=max_line_length
# https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L13
$scope.urlRegex = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/
# With the file: scheme added to the pattern:
$scope.urlWithFile = /^(ftp|http|https|file):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/
# coffeelint: enable=max_line_length
$scope.isFileUrl = OmegaPac.Profiles.isFileUrl
$scope.pacUrlCtrl = {ctrl: null}
set = OmegaPac.Profiles.referencedBySet($scope.profile, $scope.options)
$scope.referenced = Object.keys(set).length > 0
oldPacUrl = null
oldLastUpdate = null
oldPacScript = null
onProfileChange = (profile, oldProfile) ->
return unless profile and oldProfile
if profile.pacUrl != oldProfile.pacUrl
if profile.lastUpdate
oldPacUrl = oldProfile.pacUrl
oldLastUpdate = profile.lastUpdate
oldPacScript = oldProfile.pacScript
profile.lastUpdate = null
else if oldPacUrl and profile.pacUrl == oldPacUrl
profile.lastUpdate = oldLastUpdate
profile.pacScript = oldPacScript
$scope.pacUrlIsFile = $scope.isFileUrl(profile.pacUrl)
$scope.$watch 'profile', onProfileChange, true
$scope.editProxyAuth = (scheme) ->
prop = 'all'
auth = $scope.profile.auth?[prop]
scope = $scope.$new('isolate')
scope.auth = auth && angular.copy(auth)
$uibModal.open(
templateUrl: 'partials/fixed_auth_edit.html'
scope: scope
size: 'sm'
).result.then (auth) ->
if not auth?.username
if $scope.profile.auth
$scope.profile.auth[prop] = undefined
else
$scope.profile.auth ?= {}
$scope.profile.auth[prop] = auth