mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -05:00
Remove attached profile on profile removal. Fix #38.
This commit is contained in:
parent
0a6a2d018b
commit
0ded79d403
@ -10,6 +10,15 @@ profileColorPalette = (colors.splice(0, 3) while colors.length)
|
||||
angular.module('omega').constant('profileColors', profileColors)
|
||||
angular.module('omega').constant('profileColorPalette', profileColorPalette)
|
||||
|
||||
attachedPrefix = '__ruleListOf_'
|
||||
angular.module('omega').constant 'getAttachedName', (name) ->
|
||||
attachedPrefix + name
|
||||
angular.module('omega').constant 'getParentName', (name) ->
|
||||
if name.indexOf(attachedPrefix) == 0
|
||||
name.substr(attachedPrefix.length)
|
||||
else
|
||||
undefined
|
||||
|
||||
angular.module('omega').config ($stateProvider, $urlRouterProvider,
|
||||
$httpProvider) ->
|
||||
$urlRouterProvider.otherwise '/ui'
|
||||
|
@ -1,5 +1,6 @@
|
||||
angular.module('omega').controller 'ProfileCtrl', ($scope, $stateParams,
|
||||
$location, $rootScope, $modal, $state, profileColorPalette) ->
|
||||
$location, $rootScope, $state, $modal, profileColorPalette, getAttachedName,
|
||||
getParentName) ->
|
||||
name = $stateParams.name
|
||||
profileTemplates =
|
||||
'FixedProfile': 'profile_fixed.html'
|
||||
@ -19,24 +20,36 @@ angular.module('omega').controller 'ProfileCtrl', ($scope, $stateParams,
|
||||
$scope.deleteProfile = ->
|
||||
profileName = $scope.profile.name
|
||||
refs = OmegaPac.Profiles.referencedBySet(profileName, $rootScope.options)
|
||||
refs = Object.keys(refs)
|
||||
|
||||
scope = $rootScope.$new('isolate')
|
||||
scope.profile = $scope.profile
|
||||
scope.profileIcons = $scope.profileIcons
|
||||
|
||||
if refs.length > 0
|
||||
scope.refs = refs.map (p) -> OmegaPac.Profiles.byKey(p,
|
||||
$rootScope.options)
|
||||
if Object.keys(refs).length > 0
|
||||
refSet = {}
|
||||
for own key, pname of refs
|
||||
parent = getParentName(pname)
|
||||
if parent
|
||||
key = OmegaPac.Profiles.nameAsKey(parent)
|
||||
pname = parent
|
||||
refSet[key] = pname
|
||||
|
||||
refProfiles = []
|
||||
for own key of refSet
|
||||
refProfiles.push(OmegaPac.Profiles.byKey(key, $rootScope.options))
|
||||
scope.refs = refProfiles
|
||||
$modal.open(
|
||||
templateUrl: 'partials/cannot_delete_profile.html'
|
||||
scope: scope
|
||||
)
|
||||
return
|
||||
else
|
||||
$modal.open(
|
||||
templateUrl: 'partials/delete_profile.html'
|
||||
scope: scope
|
||||
).result.then ->
|
||||
attachedName = getAttachedName(profileName)
|
||||
delete $rootScope.options[OmegaPac.Profiles.nameAsKey(attachedName)]
|
||||
delete $rootScope.options[OmegaPac.Profiles.nameAsKey(profileName)]
|
||||
if $rootScope.options['-startupProfileName'] == profileName
|
||||
$rootScope.options['-startupProfileName'] = ""
|
||||
|
@ -1,5 +1,5 @@
|
||||
angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $modal,
|
||||
profileIcons) ->
|
||||
profileIcons, getAttachedName) ->
|
||||
|
||||
$scope.conditionI18n =
|
||||
'HostWildcardCondition': 'condition_hostWildcard'
|
||||
@ -69,8 +69,8 @@ angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $modal,
|
||||
$scope.ruleListFormats = OmegaPac.Profiles.ruleListFormats
|
||||
|
||||
$scope.$watch 'profile.name', (name) ->
|
||||
$scope.attachedName = '__ruleListOf_' + name
|
||||
$scope.attachedKey = OmegaPac.Profiles.nameAsKey('__ruleListOf_' + name)
|
||||
$scope.attachedName = getAttachedName(name)
|
||||
$scope.attachedKey = OmegaPac.Profiles.nameAsKey($scope.attachedName)
|
||||
|
||||
$scope.$watch 'options[attachedKey]', (attached) ->
|
||||
$scope.attached = attached
|
||||
|
Loading…
Reference in New Issue
Block a user