2015-11-20 21:14:50 +08:00
|
|
|
const ScreenedIpAddress = Discourse.Model.extend({
|
2013-10-22 02:49:51 +08:00
|
|
|
actionName: function() {
|
2013-10-25 05:18:10 +08:00
|
|
|
return I18n.t("admin.logs.screened_ips.actions." + this.get('action_name'));
|
|
|
|
}.property('action_name'),
|
2013-10-23 04:30:30 +08:00
|
|
|
|
|
|
|
isBlocked: function() {
|
2013-10-25 05:18:10 +08:00
|
|
|
return (this.get('action_name') === 'block');
|
|
|
|
}.property('action_name'),
|
2013-10-23 04:30:30 +08:00
|
|
|
|
|
|
|
actionIcon: function() {
|
2015-05-12 01:16:44 +08:00
|
|
|
return (this.get('action_name') === 'block') ? 'ban' : 'check';
|
2013-10-25 05:18:10 +08:00
|
|
|
}.property('action_name'),
|
2013-10-23 04:30:30 +08:00
|
|
|
|
|
|
|
save: function() {
|
2013-10-25 05:18:10 +08:00
|
|
|
return Discourse.ajax("/admin/logs/screened_ip_addresses" + (this.id ? '/' + this.id : '') + ".json", {
|
|
|
|
type: this.id ? 'PUT' : 'POST',
|
|
|
|
data: {ip_address: this.get('ip_address'), action_name: this.get('action_name')}
|
2013-10-23 04:30:30 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
return Discourse.ajax("/admin/logs/screened_ip_addresses/" + this.get('id') + ".json", {type: 'DELETE'});
|
|
|
|
}
|
2013-10-22 02:49:51 +08:00
|
|
|
});
|
|
|
|
|
2015-11-20 21:14:50 +08:00
|
|
|
ScreenedIpAddress.reopenClass({
|
2015-02-11 02:38:59 +08:00
|
|
|
findAll: function(filter) {
|
|
|
|
return Discourse.ajax("/admin/logs/screened_ip_addresses.json", { data: { filter: filter } }).then(function(screened_ips) {
|
2013-10-22 02:49:51 +08:00
|
|
|
return screened_ips.map(function(b) {
|
2015-11-20 21:14:50 +08:00
|
|
|
return ScreenedIpAddress.create(b);
|
2013-10-22 02:49:51 +08:00
|
|
|
});
|
|
|
|
});
|
2014-11-25 00:25:48 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
rollUp: function() {
|
|
|
|
return Discourse.ajax("/admin/logs/screened_ip_addresses/roll_up", { type: "POST" });
|
2013-10-22 02:49:51 +08:00
|
|
|
}
|
|
|
|
});
|
2015-11-20 21:14:50 +08:00
|
|
|
|
|
|
|
export default ScreenedIpAddress;
|