Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUGFIX: IP lookup wasn't working when using HTTPS
REFACTOR: the ip locator into a ip-lookup component
- Loading branch information
Showing
12 changed files
with
125 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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(", "); | ||
}.property("location.@{city,region,country}"), | ||
|
||
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")) { | ||
this.set("other_accounts_loading", true); | ||
Discourse.AdminUser.findAll("active", { | ||
"ip": this.get("ip"), | ||
"exclude": this.get("user_id") | ||
}).then(function (users) { | ||
self.setProperties({ | ||
other_accounts: users, | ||
other_accounts_loading: false, | ||
}); | ||
}); | ||
} | ||
}, | ||
|
||
hide: function () { | ||
this.set("show", false); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
app/assets/javascripts/admin/templates/ip_locator.js.handlebars
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/assets/javascripts/discourse/templates/components/ip-lookup.js.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{{#if ip}} | ||
<button class="btn" {{action lookup}}> | ||
<span class="fa fa-globe"></span> {{i18n admin.user.ip_lookup}} | ||
</button> | ||
{{/if}} | ||
{{#if show}} | ||
<div class="location-box"> | ||
<h4>{{i18n ip_lookup.title}}</h4> | ||
<dl> | ||
{{#if location}} | ||
{{#if location.hostname}} | ||
<dt>{{i18n ip_lookup.hostname}}</dt> | ||
<dd>{{location.hostname}}</dd> | ||
{{/if}} | ||
|
||
<dt>{{i18n ip_lookup.location}}</dt> | ||
<dd> | ||
{{#if location.loc}} | ||
<a href="https://maps.google.com/maps?q={{unbound location.loc}}" target="_blank">{{location.loc}}</a><br> | ||
{{city}} | ||
{{else}} | ||
{{i18n ip_lookup.location_not_found}} | ||
{{/if}} | ||
</dd> | ||
|
||
{{#if location.org}} | ||
<dt>{{i18n ip_lookup.organisation}}</dt> | ||
<dd>{{location.org}}</dd> | ||
{{/if}} | ||
|
||
{{#if location.phone}} | ||
<dt>{{i18n ip_lookup.phone}}</dt> | ||
<dd>{{location.phone}}</dd> | ||
{{/if}} | ||
{{else}} | ||
<div class="spinner">{{i18n loading}}</div> | ||
{{/if}} | ||
|
||
<dt>{{i18n ip_lookup.other_accounts}}</dt> | ||
<dd> | ||
{{#if other_accounts_loading}} | ||
<div class="spinner">{{i18n loading}}</div> | ||
{{else}} | ||
{{#each other_accounts}} | ||
{{#link-to "adminUser" this}}{{avatar this usernamePath="user.username" imageSize="small"}}{{/link-to}} | ||
{{else}} | ||
{{i18n ip_lookup.no_other_accounts}} | ||
{{/each}} | ||
{{/if}} | ||
<dd> | ||
</dl> | ||
<button class="btn close" {{action hide}}>{{i18n close}}</button> | ||
</div> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ td.flaggers td { | |
}; | ||
} | ||
|
||
.iplocator { | ||
.ip-lookup { | ||
position: relative; | ||
display: inline-block; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters