FIX: screened IP addresses list wasn't working anymore - TAKE 2
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
export default Ember.Controller.extend({
|
||||
editing: false,
|
||||
savedIpAddress: null,
|
||||
|
||||
isRange: function() {
|
||||
return this.get("model.ip_address").indexOf("/") > 0;
|
||||
}.property("model.ip_address"),
|
||||
|
||||
actions: {
|
||||
allow: function(record) {
|
||||
record.set('action_name', 'do_nothing');
|
||||
this.send('save', record);
|
||||
},
|
||||
|
||||
block: function(record) {
|
||||
record.set('action_name', 'block');
|
||||
this.send('save', record);
|
||||
},
|
||||
|
||||
edit: function() {
|
||||
if (!this.get('editing')) {
|
||||
this.savedIpAddress = this.get('model.ip_address');
|
||||
}
|
||||
this.set('editing', true);
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
if (this.get('savedIpAddress') && this.get('editing')) {
|
||||
this.set('model.ip_address', this.get('savedIpAddress'));
|
||||
}
|
||||
this.set('editing', false);
|
||||
},
|
||||
|
||||
save: function(record) {
|
||||
var self = this;
|
||||
var wasEditing = this.get('editing');
|
||||
this.set('editing', false);
|
||||
record.save().then(function(saved){
|
||||
if (saved.success) {
|
||||
self.set('savedIpAddress', null);
|
||||
} else {
|
||||
bootbox.alert(saved.errors);
|
||||
if (wasEditing) self.set('editing', true);
|
||||
}
|
||||
}, function(e){
|
||||
if (e.responseJSON && e.responseJSON.errors) {
|
||||
bootbox.alert(I18n.t("generic_error_with_reason", {error: e.responseJSON.errors.join('. ')}));
|
||||
} else {
|
||||
bootbox.alert(I18n.t("generic_error"));
|
||||
}
|
||||
if (wasEditing) self.set('editing', true);
|
||||
});
|
||||
},
|
||||
|
||||
destroy: function(record) {
|
||||
var self = this;
|
||||
return bootbox.confirm(I18n.t("admin.logs.screened_ips.delete_confirm", {ip_address: record.get('ip_address')}), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
||||
if (result) {
|
||||
record.destroy().then(function(deleted) {
|
||||
if (deleted) {
|
||||
self.get("parentController.content").removeObject(record);
|
||||
} else {
|
||||
bootbox.alert(I18n.t("generic_error"));
|
||||
}
|
||||
}, function(e){
|
||||
bootbox.alert(I18n.t("generic_error_with_reason", {error: "http: " + e.status + " - " + e.body}));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -5,19 +5,85 @@ import ScreenedIpAddress from 'admin/models/screened-ip-address';
|
||||
|
||||
export default Ember.ArrayController.extend({
|
||||
loading: false,
|
||||
itemController: 'admin-log-screened-ip-address',
|
||||
filter: null,
|
||||
savedIpAddress: null,
|
||||
|
||||
show: debounce(function() {
|
||||
var self = this;
|
||||
self.set('loading', true);
|
||||
ScreenedIpAddress.findAll(this.get("filter")).then(function(result) {
|
||||
self.set('model', result);
|
||||
self.set('loading', false);
|
||||
});
|
||||
this.set('loading', true);
|
||||
ScreenedIpAddress.findAll(this.get("filter"))
|
||||
.then(result => {
|
||||
this.set('model', result);
|
||||
this.set('loading', false);
|
||||
});
|
||||
}, 250).observes("filter"),
|
||||
|
||||
actions: {
|
||||
allow(record) {
|
||||
record.set('action_name', 'do_nothing');
|
||||
record.save();
|
||||
},
|
||||
|
||||
block(record) {
|
||||
record.set('action_name', 'block');
|
||||
record.save();
|
||||
},
|
||||
|
||||
edit(record) {
|
||||
if (!record.get('editing')) {
|
||||
this.set("savedIpAddress", record.get('ip_address'));
|
||||
}
|
||||
record.set('editing', true);
|
||||
},
|
||||
|
||||
cancel(record) {
|
||||
if (this.get('savedIpAddress') && record.get('editing')) {
|
||||
record.set('ip_address', this.get('savedIpAddress'));
|
||||
}
|
||||
record.set('editing', false);
|
||||
},
|
||||
|
||||
save(record) {
|
||||
const wasEditing = record.get('editing');
|
||||
record.set('editing', false);
|
||||
record.save().then(saved => {
|
||||
if (saved.success) {
|
||||
this.set('savedIpAddress', null);
|
||||
} else {
|
||||
bootbox.alert(saved.errors);
|
||||
if (wasEditing) record.set('editing', true);
|
||||
}
|
||||
}).catch(e => {
|
||||
if (e.responseJSON && e.responseJSON.errors) {
|
||||
bootbox.alert(I18n.t("generic_error_with_reason", {error: e.responseJSON.errors.join('. ')}));
|
||||
} else {
|
||||
bootbox.alert(I18n.t("generic_error"));
|
||||
}
|
||||
if (wasEditing) record.set('editing', true);
|
||||
});
|
||||
},
|
||||
|
||||
destroy(record) {
|
||||
const self = this;
|
||||
return bootbox.confirm(
|
||||
I18n.t("admin.logs.screened_ips.delete_confirm", { ip_address: record.get('ip_address') }),
|
||||
I18n.t("no_value"),
|
||||
I18n.t("yes_value"),
|
||||
function (result) {
|
||||
if (result) {
|
||||
record.destroy().then(deleted => {
|
||||
if (deleted) {
|
||||
self.get("content").removeObject(record);
|
||||
} else {
|
||||
bootbox.alert(I18n.t("generic_error"));
|
||||
}
|
||||
}).catch(e => {
|
||||
bootbox.alert(I18n.t("generic_error_with_reason", {error: "http: " + e.status + " - " + e.body}));
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
recordAdded(arg) {
|
||||
this.get("model").unshiftObject(arg);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user