2014-12-07 12:15:22 +08:00
|
|
|
import { outputExportResult } from 'admin/lib/export-result';
|
|
|
|
|
2014-07-23 11:20:45 +08:00
|
|
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
|
|
|
loading: false,
|
2014-07-26 01:02:46 +08:00
|
|
|
itemController: 'admin-log-screened-ip-address',
|
2014-07-23 11:20:45 +08:00
|
|
|
|
|
|
|
show: function() {
|
|
|
|
var self = this;
|
2014-12-07 12:15:22 +08:00
|
|
|
self.set('loading', true);
|
2014-07-23 11:20:45 +08:00
|
|
|
Discourse.ScreenedIpAddress.findAll().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);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
recordAdded: function(arg) {
|
2014-11-01 05:35:27 +08:00
|
|
|
this.get("model").unshiftObject(arg);
|
2014-11-25 00:25:48 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
rollUp: function() {
|
|
|
|
var 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) {
|
|
|
|
self.set("loading", true)
|
2014-11-28 02:29:30 +08: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-25 02:38:47 +08:00
|
|
|
});
|
|
|
|
}
|
2014-11-25 00:25:48 +08:00
|
|
|
});
|
2014-12-07 12:15:22 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
exportScreenedIpList: function(subject) {
|
|
|
|
Discourse.ExportCsv.exportScreenedIpList().then(outputExportResult);
|
2014-07-23 11:20:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|