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';
|
2015-07-25 00:33:53 +08:00
|
|
|
import { exportEntity } from 'discourse/lib/export-csv';
|
2016-04-01 05:33:25 +08:00
|
|
|
import ScreenedIpAddress from 'admin/models/screened-ip-address';
|
2014-12-07 12:15:22 +08:00
|
|
|
|
2015-05-12 16:49:05 +08:00
|
|
|
export default Ember.ArrayController.extend({
|
2014-07-23 11:20:45 +08:00
|
|
|
loading: false,
|
2014-07-26 01:02:46 +08:00
|
|
|
itemController: 'admin-log-screened-ip-address',
|
2015-02-11 02:38:59 +08:00
|
|
|
filter: null,
|
2014-07-23 11:20:45 +08:00
|
|
|
|
2015-08-11 05:11:27 +08:00
|
|
|
show: debounce(function() {
|
2014-07-23 11:20:45 +08:00
|
|
|
var self = this;
|
2014-12-07 12:15:22 +08:00
|
|
|
self.set('loading', true);
|
2016-04-01 05:33:25 +08:00
|
|
|
ScreenedIpAddress.findAll(this.get("filter")).then(function(result) {
|
2014-11-01 05:35:27 +08:00
|
|
|
self.set('model', result);
|
2014-07-23 11:20:45 +08:00
|
|
|
self.set('loading', false);
|
|
|
|
});
|
2015-02-11 02:38:59 +08:00
|
|
|
}, 250).observes("filter"),
|
2014-07-23 11:20:45 +08:00
|
|
|
|
|
|
|
actions: {
|
2015-02-11 06:20:16 +08:00
|
|
|
recordAdded(arg) {
|
2014-11-01 05:35:27 +08:00
|
|
|
this.get("model").unshiftObject(arg);
|
2014-11-25 00:25:48 +08:00
|
|
|
},
|
|
|
|
|
2015-02-11 06:20:16 +08:00
|
|
|
rollUp() {
|
|
|
|
const self = this;
|
2014-11-25 02:38:47 +08:00
|
|
|
return bootbox.confirm(I18n.t("admin.logs.screened_ips.roll_up_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function (confirmed) {
|
|
|
|
if (confirmed) {
|
2015-02-11 06:20:16 +08:00
|
|
|
self.set("loading", true);
|
2016-04-01 05:33:25 +08:00
|
|
|
return ScreenedIpAddress.rollUp().then(function(results) {
|
2014-11-28 02:29:30 +08:00
|
|
|
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-11-25 02:38:47 +08:00
|
|
|
});
|
|
|
|
}
|
2014-11-25 00:25:48 +08:00
|
|
|
});
|
2014-12-07 12:15:22 +08:00
|
|
|
},
|
|
|
|
|
2015-02-11 06:20:16 +08:00
|
|
|
exportScreenedIpList() {
|
2015-07-25 00:33:53 +08:00
|
|
|
exportEntity('screened_ip').then(outputExportResult);
|
2014-07-23 11:20:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|