Added member's geographic location to admin

no issue

- added `geolocation` attribute to member model with json-string transform
- prevent geolocation from being sent back to the API in member serializer
- add "Location" column to members list
  - if country is "US" then display "{State}, US" otherwise show full country name such as "United Kingdom"
  - displays "-" if no geolocation data has been collected for the member
This commit is contained in:
Kevin Ansfield 2020-02-27 12:56:26 +00:00
parent 73ab00be1b
commit 89b10f69fa
4 changed files with 16 additions and 3 deletions

View File

@ -14,6 +14,7 @@ export default Model.extend(ValidationEngine, {
subscribed: attr('boolean', {defaultValue: true}),
labels: hasMany('label', {embedded: 'always', async: false}),
comped: attr('boolean', {defaultValue: false}),
geolocation: attr('json-string'),
ghostPaths: service(),
ajax: service(),

View File

@ -13,6 +13,7 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
// Properties that exist on the model but we don't want sent in the payload
delete json.stripe;
delete json.geolocation;
// Normalize properties
json.name = json.name || '';
json.note = json.note || '';

View File

@ -11,6 +11,18 @@
</div>
</LinkTo>
<LinkTo @route="member" @model={{@member}} title="Member details" class="gh-list-data gh-list-cellwidth-20 nowrap middarkgrey f8">
{{#if @member.geolocation}}
{{#if (eq @member.geolocation.country_code "US")
{{@member.geolocation.region}}, US
{{else}}
{{@member.geolocation.country}}
{{/if}}
{{else}}
-
{{/if}}
</LinkTo>
<LinkTo @route="member" @model={{@member}} title="Member details" class="gh-list-data gh-members-list-subscribed-at gh-list-cellwidth-20 nowrap middarkgrey f8 {{if (not @member.name) "gh-members-subscribed-noname"}}">
{{moment-format @member.createdAtUTC "MMM DD, YYYY"}} <span class="midgrey-l2">({{this.memberSince}})</span>
</LinkTo>

View File

@ -56,9 +56,8 @@
<ol class="members-list gh-list {{unless this.filteredMembers "no-posts"}}">
{{#if this.filteredMembers}}
<li class="gh-list-row header">
<div class="gh-list-header">
{{listHeader}}
</div>
<div class="gh-list-header">{{listHeader}}</div>
<div class="gh-list-header gh-list-cellwidth-20 nowrap">Location</div>
<div class="gh-list-header gh-list-cellwidth-20 nowrap">Created</div>
<div class="gh-list-header gh-list-cellwidth-chevron"></div>
</li>