diff --git a/omega-web/src/omega/app.coffee b/omega-web/src/omega/app.coffee index cc63941..4c0f734 100644 --- a/omega-web/src/omega/app.coffee +++ b/omega-web/src/omega/app.coffee @@ -24,8 +24,9 @@ angular.module('omega').config ($stateProvider, $urlRouterProvider, $animateProvider.classNameFilter(/angular-animate/) $urlRouterProvider.otherwise '/ui' + $urlRouterProvider.otherwise ($injector, $location) -> - if $location.path() == '' or $location.path() == '/' + if $location.path() == '' $injector.get('omegaTarget').lastUrl() else '/ui' diff --git a/omega-web/src/omega/controllers/master.coffee b/omega-web/src/omega/controllers/master.coffee index 4f01f9c..b9fb555 100644 --- a/omega-web/src/omega/controllers/master.coffee +++ b/omega-web/src/omega/controllers/master.coffee @@ -1,6 +1,6 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window, $modal, $state, builtinProfiles, profileColors, profileIcons, omegaTarget, $q, - $timeout, $location, $filter) -> + $timeout, $location, $filter, getAttachedName) -> tr = $filter('tr') @@ -136,7 +136,28 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window, scope: scope ).result.then (toName) -> if toName != fromName - omegaTarget.renameProfile(fromName, toName).then(-> + rename = omegaTarget.renameProfile(fromName, toName) + attachedName = getAttachedName(fromName) + if $rootScope.profileByName(attachedName) + toAttachedName = getAttachedName(toName) + defaultProfileName = undefined + if $rootScope.profileByName(toAttachedName) + defaultProfileName = profile.defaultProfileName + rename = rename.then -> + toAttachedKey = OmegaPac.Profiles.nameAsKey(toAttachedName) + profile = $rootScope.profileByName(toName) + profile.defaultProfileName = 'direct' + OmegaPac.Profiles.updateRevision(profile) + delete $rootScope.options[toAttachedKey] + $rootScope.applyOptions() + rename = rename.then -> + omegaTarget.renameProfile(attachedName, toAttachedName) + if defaultProfileName + rename = rename.then -> + profile = $rootScope.profileByName(toName) + profile.defaultProfileName = defaultProfileName + $rootScope.applyOptions() + rename.then(-> $state.go('profile', {name: toName}) ).catch (err) -> $rootScope.showAlert(