2014-12-22 11:17:04 -05:00
|
|
|
import { outputExportResult } from 'discourse/lib/export-result';
|
2014-12-06 23:15:22 -05:00
|
|
|
|
2014-07-22 23:20:45 -04:00
|
|
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
|
|
|
loading: false,
|
2014-07-25 13:02:46 -04:00
|
|
|
itemController: 'admin-log-screened-ip-address',
|
2015-02-10 13:38:59 -05:00
|
|
|
filter: null,
|
2014-07-22 23:20:45 -04:00
|
|
|
|
2015-02-10 13:38:59 -05:00
|
|
|
show: Discourse.debounce(function() {
|
2014-07-22 23:20:45 -04:00
|
|
|
var self = this;
|
2014-12-06 23:15:22 -05:00
|
|
|
self.set('loading', true);
|
2015-02-10 13:38:59 -05:00
|
|
|
Discourse.ScreenedIpAddress.findAll(this.get("filter")).then(function(result) {
|
2014-10-31 17:35:27 -04:00
|
|
|
self.set('model', result);
|
2014-07-22 23:20:45 -04:00
|
|
|
self.set('loading', false);
|
|
|
|
});
|
2015-02-10 13:38:59 -05:00
|
|
|
}, 250).observes("filter"),
|
2014-07-22 23:20:45 -04:00
|
|
|
|
|
|
|
actions: {
|
2015-02-10 17:20:16 -05:00
|
|
|
recordAdded(arg) {
|
2014-10-31 17:35:27 -04:00
|
|
|
this.get("model").unshiftObject(arg);
|
2014-11-24 11:25:48 -05:00
|
|
|
},
|
|
|
|
|
2015-02-10 17:20:16 -05:00
|
|
|
rollUp() {
|
|
|
|
const self = this;
|
2014-11-24 13:38:47 -05: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-10 17:20:16 -05:00
|
|
|
self.set("loading", true);
|
2014-11-27 13:29:30 -05:00
|
|
|
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-11-24 13:38:47 -05:00
|
|
|
});
|
|
|
|
}
|
2014-11-24 11:25:48 -05:00
|
|
|
});
|
2014-12-06 23:15:22 -05:00
|
|
|
},
|
|
|
|
|
2015-02-10 17:20:16 -05:00
|
|
|
exportScreenedIpList() {
|
2014-12-06 23:15:22 -05:00
|
|
|
Discourse.ExportCsv.exportScreenedIpList().then(outputExportResult);
|
2014-07-22 23:20:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|