discourse/app/assets/javascripts/admin/controllers/admin-logs-screened-ip-addresses.js.es6

49 lines
1.5 KiB
Plaintext
Raw Normal View History

2015-08-11 05:11:27 +08:00
import debounce from 'discourse/lib/debounce';
2014-12-23 00:17:04 +08:00
import { outputExportResult } from 'discourse/lib/export-result';
import { exportEntity } from 'discourse/lib/export-csv';
2014-12-07 12:15:22 +08:00
export default Ember.ArrayController.extend({
loading: false,
itemController: 'admin-log-screened-ip-address',
2015-02-11 02:38:59 +08:00
filter: null,
2015-08-11 05:11:27 +08:00
show: debounce(function() {
var self = this;
2014-12-07 12:15:22 +08:00
self.set('loading', true);
2015-02-11 02:38:59 +08:00
Discourse.ScreenedIpAddress.findAll(this.get("filter")).then(function(result) {
2014-11-01 05:35:27 +08:00
self.set('model', result);
self.set('loading', false);
});
2015-02-11 02:38:59 +08:00
}, 250).observes("filter"),
actions: {
recordAdded(arg) {
2014-11-01 05:35:27 +08:00
this.get("model").unshiftObject(arg);
},
rollUp() {
const self = this;
return bootbox.confirm(I18n.t("admin.logs.screened_ips.roll_up_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function (confirmed) {
if (confirmed) {
self.set("loading", true);
return Discourse.ScreenedIpAddress.rollUp().then(function(results) {
if (results && results.subnets) {
if (results.subnets.length > 0) {
self.send("show");
bootbox.alert(I18n.t("admin.logs.screened_ips.rolled_up_some_subnets", { subnets: results.subnets.join(", ") }));
} else {
self.set("loading", false);
bootbox.alert(I18n.t("admin.logs.screened_ips.rolled_up_no_subnet"));
}
}
});
}
});
2014-12-07 12:15:22 +08:00
},
exportScreenedIpList() {
exportEntity('screened_ip').then(outputExportResult);
}
}
});