From 8cef8bd6271f8e5bd202221d52b3ef60d1f6a269 Mon Sep 17 00:00:00 2001 From: FelisCatus Date: Thu, 1 Jan 2015 21:55:33 +0800 Subject: [PATCH] Update profiles on options import. Fix #120. --- omega-web/src/omega/controllers/io.coffee | 15 ++++++++++----- omega-web/src/omega/controllers/master.coffee | 13 +++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/omega-web/src/omega/controllers/io.coffee b/omega-web/src/omega/controllers/io.coffee index 86834b38..b1d54ea4 100644 --- a/omega-web/src/omega/controllers/io.coffee +++ b/omega-web/src/omega/controllers/io.coffee @@ -6,13 +6,18 @@ angular.module('omega').controller 'IoCtrl', ($scope, $rootScope) -> blob = new Blob [content], {type: "text/plain;charset=utf-8"} saveAs(blob, "OmegaOptions.bak") + $scope.importSuccess = -> + $rootScope.showAlert( + type: 'success' + i18n: 'options_importSuccess' + message: 'Options imported.' + ) + $scope.restoreLocal = (content) -> $rootScope.resetOptions(content).then ( -> - $rootScope.showAlert( - type: 'success' - i18n: 'options_importSuccess' - message: 'Options imported.' - ) + $scope.importSuccess() + $rootScope.updateProfile().finally -> + $scope.importSuccess() ), -> $scope.restoreLocalError() $scope.restoreLocalError = -> $rootScope.showAlert( diff --git a/omega-web/src/omega/controllers/master.coffee b/omega-web/src/omega/controllers/master.coffee index 1c917f44..f79189e5 100644 --- a/omega-web/src/omega/controllers/master.coffee +++ b/omega-web/src/omega/controllers/master.coffee @@ -211,7 +211,13 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window, $rootScope.updateProfile = (name) -> $rootScope.applyOptionsConfirm().then(-> - $scope.updatingProfile[name] = true + if name? + $scope.updatingProfile[name] = true + else + OmegaPac.Profiles.each $scope.options, (key, profile) -> + if not profile.builtin + $scope.updatingProfile[profile.name] = true + omegaTarget.updateProfile(name).then((results) -> success = 0 error = 0 @@ -233,7 +239,10 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window, i18n: 'options_profileDownloadError' ) ).finally -> - $scope.updatingProfile[name] = false + if name? + $scope.updatingProfile[name] = false + else + $scope.updatingProfile = {} ) onOptionChange = (options, oldOptions) ->