Browse Source

disable geoip displays; fix link analyzer service calls

pull/1/head
Rob Colbert 3 years ago
parent
commit
81f88d1df2
  1. 6
      app/controllers/dashboard.js
  2. 96
      app/views/dashboard/link-analyzer.pug
  3. 50
      app/views/dashboard/view.pug
  4. 5
      app/views/error.pug

6
app/controllers/dashboard.js

@ -62,9 +62,9 @@ class DashboardController extends SiteController {
async getLinkView (req, res, next) {
const { dashboard: dashboardService, link: linkService } = this.dtp.services;
try {
res.locals.linkVisitStats = await dashboardService.getLinkVisitStats(res.locals.link);
res.locals.linkCountryStats = await dashboardService.getLinkCountryStats(res.locals.link);
res.locals.linkCityStats = await dashboardService.getLinkCityStats(res.locals.link);
res.locals.linkVisitStats = await dashboardService.getResourceVisitStats('Link', res.locals.link._id);
res.locals.linkCountryStats = await dashboardService.getResourceCountryStats('Link', res.locals.link._id);
res.locals.linkCityStats = await dashboardService.getResourceCityStats('Link', res.locals.link._id);
res.locals.userLinks = await linkService.getForUser(req.user);

96
app/views/dashboard/link-analyzer.pug

@ -2,26 +2,36 @@ extends ../layouts/main
block content
section.uk-section.uk-section-default.links-dashboard
.uk-container.uk-container-expand
.uk-container
.uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body
div(uk-grid).uk-grid-small
.uk-width-expand
h4.uk-card-title #{link.label} #[small.uk-text-muted past 7 days]
.uk-width-auto
a(href="/dashboard").uk-button.dtp-button-secondary.uk-button-small
+renderButtonIcon('fa-chevron-left', 'Back to Dashboard')
.uk-card.uk-card-secondary.uk-card-small
.uk-card-header
div(uk-grid).uk-grid-small
.uk-width-expand
h4.uk-card-title #{link.label} #[small.uk-text-muted past 7 days]
.uk-width-auto
a(href="/dashboard").uk-button.dtp-button-secondary.uk-button-small
+renderButtonIcon('fa-chevron-left', 'Back to Dashboard')
.uk-card-body
.uk-margin
p #{link.label} has received #{formatCount(link.stats.uniqueVisitCount)} unique visits. It has received #{numeral(link.stats.totalVisitCount).format('0,0')} total visits since being posted #{moment(link.created).fromNow()}.
.uk-text-small.uk-card-meta
div Target URL: #[a(href= link.href, title=`Visit ${link.label}`)= link.href]
canvas(id="link-visits").visit-graph
.uk-margin
canvas(id="link-visits").visit-graph
div(class="uk-visible@m", uk-grid).uk-flex-between.uk-text-small
.uk-width-auto
.uk-margin
div= moment(linkVisitStats.start).format('MMM DD, YYYY h:mm:ss a')
.uk-width-auto
.uk-margin
div= moment(linkVisitStats.end).format('MMM DD, YYYY h:mm:ss a')
.uk-card-footer
div(class="uk-visible@m", uk-grid).uk-flex-between.uk-text-small
.uk-width-auto
.uk-margin
div= moment(linkVisitStats.start).format('MMM DD, YYYY h:mm:ss a')
.uk-width-auto
.uk-margin
div= moment(linkVisitStats.end).format('MMM DD, YYYY h:mm:ss a')
.uk-margin
div(uk-grid).uk-grid-small
@ -29,39 +39,41 @@ block content
.uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body
h5.uk-card-title Top Countries
table.uk-table.uk-table-small
thead
tr
th Country
th Visits
tbody
each entry in linkCountryStats.stats
tr
td.uk-table-expand= entry.country ? entry.country : '--'
td= entry.count
.uk-text-italic Geography data unavailable.
//- table.uk-table.uk-table-small
//- thead
//- tr
//- th Country
//- th Visits
//- tbody
//- each entry in linkCountryStats.stats
//- tr
//- td.uk-table-expand= entry.country ? entry.country : '--'
//- td= entry.count
div(class="uk-width-1-1 uk-width-1-2@m")
.uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body
h5.uk-card-title Top Cities
table.uk-table.uk-table-small
thead
tr
th City
th(class="uk-visible@m") State
th Country
th Visits
tbody
each entry in linkCityStats.stats
tr
td= entry.city ? entry.city : '--'
td(class="uk-visible@m")= entry.region ? entry.region : '--'
td= entry.country ? entry.country : '--'
td= entry.count
.uk-text-italic Geography data unavailable.
//- table.uk-table.uk-table-small
//- thead
//- tr
//- th City
//- th(class="uk-visible@m") State
//- th Country
//- th Visits
//- tbody
//- each entry in linkCityStats.stats
//- tr
//- td= entry.city ? entry.city : '--'
//- td(class="uk-visible@m")= entry.region ? entry.region : '--'
//- td= entry.country ? entry.country : '--'
//- td= entry.count
block viewjs
script(src="/chart.js/chart.min.js")
script(src="/chartjs-adapter-moment/chartjs-adapter-moment.min.js")
script.
window.addEventListener('dtp-load', ( ) => {
dtp.app.renderProfileStats('canvas#link-visits', !{JSON.stringify(linkVisitStats.stats)});
dtp.app.renderStatsGraph('canvas#link-visits', 'Link Visits', !{JSON.stringify(linkVisitStats.stats)});
});

50
app/views/dashboard/view.pug

@ -66,34 +66,36 @@ block content
.uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body
h5.uk-card-title Top Countries
table.uk-table.uk-table-small
thead
tr
th Country
th Visits
tbody
each entry in linkCountryStats.stats
tr
td.uk-table-expand= entry.country ? entry.country : '--'
td= entry.count
.uk-text-italic Geography data unavailable.
//- table.uk-table.uk-table-small
//- thead
//- tr
//- th Country
//- th Visits
//- tbody
//- each entry in linkCountryStats.stats
//- tr
//- td.uk-table-expand= entry.country ? entry.country : '--'
//- td= entry.count
.uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body
h5.uk-card-title Top Cities
table.uk-table.uk-table-small
thead
tr
th City
th(class="uk-visible@m") State
th Country
th Visits
tbody
each entry in linkCityStats.stats
tr
td= entry.city ? entry.city : '--'
td(class="uk-visible@m")= entry.region ? entry.region : '--'
td= entry.country ? entry.country : '--'
td= entry.count
.uk-text-italic Geography data unavailable.
//- table.uk-table.uk-table-small
//- thead
//- tr
//- th City
//- th(class="uk-visible@m") State
//- th Country
//- th Visits
//- tbody
//- each entry in linkCityStats.stats
//- tr
//- td= entry.city ? entry.city : '--'
//- td(class="uk-visible@m")= entry.region ? entry.region : '--'
//- td= entry.country ? entry.country : '--'
//- td= entry.count
block viewjs
script(src="/chart.js/chart.min.js")

5
app/views/error.pug

@ -3,9 +3,12 @@ block content
section.uk-section.uk-section-default.uk-section-xsmall
.uk-container
h1 Well, That's Not Right!
.uk-text-large= message
//- if error.stack
//- pre= error.stack
if error && error.status
div.uk-text-small.uk-text-muted status:#{error.status}
@ -14,4 +17,4 @@ block content
a(href="/").uk-button.uk-button-default.uk-border-rounded
span.uk-margin-small-right
i.fas.fa-home
span Home
span Back to #{site.name}
Loading…
Cancel
Save