Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) ->
callBackgroundNoReply('applyProfile', name)
addTempRule: (domain, profileName, toggle) ->
callBackground('addTempRule', domain, profileName, toggle)
addCondition: (condition, profileName) ->
callBackground('addCondition', condition, profileName)
addCondition: (condition, profileName, addToBottom) ->
callBackground('addCondition', condition, profileName, addToBottom)
addProfile: (profile) ->
callBackground('addProfile', profile).then omegaTarget.refresh
setDefaultProfile: (profileName, defaultProfileName) ->
Expand Down
8 changes: 6 additions & 2 deletions omega-target-chromium-extension/src/js/omega_target_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ OmegaTargetPopup = {
callBackgroundNoReply('setDefaultProfile',
[profileName, defaultProfileName], cb);
},
addCondition: function(condition, profileName, cb){
callBackground('addCondition', [condition, profileName], cb)
addCondition: function(condition, profileName, addToBottom, cb){
if (typeof addToBottom == 'function') {
cb = addToBottom;
addToBottom = null;
}
callBackground('addCondition', [condition, profileName, addToBottom], cb)
},
getTempRules: function(cb){
callBackground('getTempRules', [], cb);
Expand Down
5 changes: 3 additions & 2 deletions omega-target/src/options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -998,9 +998,10 @@ class Options
# Add a condition to the current active switch profile.
# @param {Object.<String,{}>} cond The condition to add
# @param {string>} profileName The name of the result profile of the rule.
# @param {boolean=} addToBottom Whether to append the rule to the end.
# @returns {Promise} A promise which is fulfilled when the condition is saved.
###
addCondition: (condition, profileName) ->
addCondition: (condition, profileName, addToBottom) ->
@log.method('Options#addCondition', this, arguments)
return Promise.resolve() if not @_currentProfileName
profile = OmegaPac.Profiles.byName(@_currentProfileName, @_options)
Expand All @@ -1022,7 +1023,7 @@ class Options
break


if @_options['-addConditionsToBottom']
if addToBottom ? @_options['-addConditionsToBottom']
profile.rules.push({
condition: cond
profileName: profileName
Expand Down
4 changes: 2 additions & 2 deletions omega-web/src/coffee/popup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
refresh()

$scope.addCondition = (condition, profileName) ->
omegaTarget.addCondition(condition, profileName).then ->
omegaTarget.addCondition(condition, profileName, true).then ->
omegaTarget.state('lastProfileNameForCondition', profileName)
refresh()

Expand All @@ -174,7 +174,7 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
conditionType: 'HostWildcardCondition'
pattern: domain
})
omegaTarget.addCondition(conditions, profileName).then ->
omegaTarget.addCondition(conditions, profileName, true).then ->
omegaTarget.state('lastProfileNameForCondition', profileName)
refresh()

Expand Down
2 changes: 1 addition & 1 deletion omega-web/src/popup/network/js/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export const initUrlCellDetail = async (cell) => {
OmegaTargetPopup.addCondition([{
conditionType: 'HostWildcardCondition',
pattern
}], profileName, ()=>{
}], profileName, true, ()=>{
OmegaTargetPopup.setState('lastProfileNameForCondition', profileName, ()=>{
Toastify({
text: "Add condition success",
Expand Down