2014-07-07 16:18:18 -04:00
|
|
|
export default Ember.Component.extend({
|
|
|
|
classNames: ["ip-lookup"],
|
|
|
|
|
|
|
|
city: function () {
|
|
|
|
return [
|
|
|
|
this.get("location.city"),
|
|
|
|
this.get("location.region"),
|
|
|
|
this.get("location.country")
|
|
|
|
].filter(Boolean).join(", ");
|
2014-08-06 15:22:36 -04:00
|
|
|
}.property("location.{city,region,country}"),
|
2014-07-07 16:18:18 -04:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
lookup: function () {
|
|
|
|
var self = this;
|
|
|
|
this.set("show", true);
|
|
|
|
|
|
|
|
if (!this.get("location")) {
|
|
|
|
Discourse.ajax("/admin/users/ip-info.json", {
|
|
|
|
data: { ip: this.get("ip") }
|
|
|
|
}).then(function (location) {
|
|
|
|
self.set("location", Em.Object.create(location));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.get("other_accounts")) {
|
2014-11-17 12:17:24 -05:00
|
|
|
this.set("otherAccountsLoading", true);
|
2014-07-07 16:18:18 -04:00
|
|
|
Discourse.AdminUser.findAll("active", {
|
|
|
|
"ip": this.get("ip"),
|
2014-11-24 12:04:34 -05:00
|
|
|
"exclude": this.get("userId"),
|
2014-11-19 15:38:53 -05:00
|
|
|
"order": "trust_level DESC"
|
2014-07-07 16:18:18 -04:00
|
|
|
}).then(function (users) {
|
|
|
|
self.setProperties({
|
|
|
|
other_accounts: users,
|
2014-11-17 12:17:24 -05:00
|
|
|
otherAccountsLoading: false,
|
2014-07-07 16:18:18 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
hide: function () {
|
|
|
|
this.set("show", false);
|
2014-11-20 13:59:20 -05:00
|
|
|
},
|
|
|
|
|
2014-11-24 12:04:34 -05:00
|
|
|
deleteOtherAccounts: function() {
|
2014-11-20 13:59:20 -05:00
|
|
|
var self = this;
|
2014-11-20 18:31:22 -05:00
|
|
|
bootbox.confirm(I18n.t("ip_lookup.confirm_delete_other_accounts"), I18n.t("no_value"), I18n.t("yes_value"), function (confirmed) {
|
|
|
|
if (confirmed) {
|
|
|
|
self.setProperties({ other_accounts: null, otherAccountsLoading: true });
|
|
|
|
Discourse.ajax("/admin/users/delete-others-with-same-ip.json", {
|
|
|
|
type: "DELETE",
|
|
|
|
data: {
|
|
|
|
"ip": self.get("ip"),
|
2014-11-24 12:04:34 -05:00
|
|
|
"exclude": self.get("userId"),
|
2014-11-20 18:31:22 -05:00
|
|
|
"order": "trust_level DESC"
|
|
|
|
}
|
|
|
|
}).then(function() {
|
|
|
|
self.send("lookup");
|
|
|
|
});
|
2014-11-20 13:59:20 -05:00
|
|
|
}
|
|
|
|
});
|
2014-07-07 16:18:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|