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. 68
      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) { async getLinkView (req, res, next) {
const { dashboard: dashboardService, link: linkService } = this.dtp.services; const { dashboard: dashboardService, link: linkService } = this.dtp.services;
try { try {
res.locals.linkVisitStats = await dashboardService.getLinkVisitStats(res.locals.link); res.locals.linkVisitStats = await dashboardService.getResourceVisitStats('Link', res.locals.link._id);
res.locals.linkCountryStats = await dashboardService.getLinkCountryStats(res.locals.link); res.locals.linkCountryStats = await dashboardService.getResourceCountryStats('Link', res.locals.link._id);
res.locals.linkCityStats = await dashboardService.getLinkCityStats(res.locals.link); res.locals.linkCityStats = await dashboardService.getResourceCityStats('Link', res.locals.link._id);
res.locals.userLinks = await linkService.getForUser(req.user); res.locals.userLinks = await linkService.getForUser(req.user);

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

@ -2,19 +2,29 @@ extends ../layouts/main
block content block content
section.uk-section.uk-section-default.links-dashboard section.uk-section.uk-section-default.links-dashboard
.uk-container.uk-container-expand .uk-container
.uk-margin .uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body .uk-card.uk-card-secondary.uk-card-small
.uk-card-header
div(uk-grid).uk-grid-small div(uk-grid).uk-grid-small
.uk-width-expand .uk-width-expand
h4.uk-card-title #{link.label} #[small.uk-text-muted past 7 days] h4.uk-card-title #{link.label} #[small.uk-text-muted past 7 days]
.uk-width-auto .uk-width-auto
a(href="/dashboard").uk-button.dtp-button-secondary.uk-button-small a(href="/dashboard").uk-button.dtp-button-secondary.uk-button-small
+renderButtonIcon('fa-chevron-left', 'Back to Dashboard') +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]
.uk-margin
canvas(id="link-visits").visit-graph canvas(id="link-visits").visit-graph
.uk-card-footer
div(class="uk-visible@m", uk-grid).uk-flex-between.uk-text-small div(class="uk-visible@m", uk-grid).uk-flex-between.uk-text-small
.uk-width-auto .uk-width-auto
.uk-margin .uk-margin
@ -29,39 +39,41 @@ block content
.uk-margin .uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body .uk-card.uk-card-secondary.uk-card-small.uk-card-body
h5.uk-card-title Top Countries h5.uk-card-title Top Countries
table.uk-table.uk-table-small .uk-text-italic Geography data unavailable.
thead //- table.uk-table.uk-table-small
tr //- thead
th Country //- tr
th Visits //- th Country
tbody //- th Visits
each entry in linkCountryStats.stats //- tbody
tr //- each entry in linkCountryStats.stats
td.uk-table-expand= entry.country ? entry.country : '--' //- tr
td= entry.count //- td.uk-table-expand= entry.country ? entry.country : '--'
//- td= entry.count
div(class="uk-width-1-1 uk-width-1-2@m") div(class="uk-width-1-1 uk-width-1-2@m")
.uk-margin .uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body .uk-card.uk-card-secondary.uk-card-small.uk-card-body
h5.uk-card-title Top Cities h5.uk-card-title Top Cities
table.uk-table.uk-table-small .uk-text-italic Geography data unavailable.
thead //- table.uk-table.uk-table-small
tr //- thead
th City //- tr
th(class="uk-visible@m") State //- th City
th Country //- th(class="uk-visible@m") State
th Visits //- th Country
tbody //- th Visits
each entry in linkCityStats.stats //- tbody
tr //- each entry in linkCityStats.stats
td= entry.city ? entry.city : '--' //- tr
td(class="uk-visible@m")= entry.region ? entry.region : '--' //- td= entry.city ? entry.city : '--'
td= entry.country ? entry.country : '--' //- td(class="uk-visible@m")= entry.region ? entry.region : '--'
td= entry.count //- td= entry.country ? entry.country : '--'
//- td= entry.count
block viewjs block viewjs
script(src="/chart.js/chart.min.js") script(src="/chart.js/chart.min.js")
script(src="/chartjs-adapter-moment/chartjs-adapter-moment.min.js") script(src="/chartjs-adapter-moment/chartjs-adapter-moment.min.js")
script. script.
window.addEventListener('dtp-load', ( ) => { 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-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body .uk-card.uk-card-secondary.uk-card-small.uk-card-body
h5.uk-card-title Top Countries h5.uk-card-title Top Countries
table.uk-table.uk-table-small .uk-text-italic Geography data unavailable.
thead //- table.uk-table.uk-table-small
tr //- thead
th Country //- tr
th Visits //- th Country
tbody //- th Visits
each entry in linkCountryStats.stats //- tbody
tr //- each entry in linkCountryStats.stats
td.uk-table-expand= entry.country ? entry.country : '--' //- tr
td= entry.count //- td.uk-table-expand= entry.country ? entry.country : '--'
//- td= entry.count
.uk-margin .uk-margin
.uk-card.uk-card-secondary.uk-card-small.uk-card-body .uk-card.uk-card-secondary.uk-card-small.uk-card-body
h5.uk-card-title Top Cities h5.uk-card-title Top Cities
table.uk-table.uk-table-small .uk-text-italic Geography data unavailable.
thead //- table.uk-table.uk-table-small
tr //- thead
th City //- tr
th(class="uk-visible@m") State //- th City
th Country //- th(class="uk-visible@m") State
th Visits //- th Country
tbody //- th Visits
each entry in linkCityStats.stats //- tbody
tr //- each entry in linkCityStats.stats
td= entry.city ? entry.city : '--' //- tr
td(class="uk-visible@m")= entry.region ? entry.region : '--' //- td= entry.city ? entry.city : '--'
td= entry.country ? entry.country : '--' //- td(class="uk-visible@m")= entry.region ? entry.region : '--'
td= entry.count //- td= entry.country ? entry.country : '--'
//- td= entry.count
block viewjs block viewjs
script(src="/chart.js/chart.min.js") 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 section.uk-section.uk-section-default.uk-section-xsmall
.uk-container .uk-container
h1 Well, That's Not Right!
.uk-text-large= message .uk-text-large= message
//- if error.stack //- if error.stack
//- pre= error.stack //- pre= error.stack
if error && error.status if error && error.status
div.uk-text-small.uk-text-muted status:#{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 a(href="/").uk-button.uk-button-default.uk-border-rounded
span.uk-margin-small-right span.uk-margin-small-right
i.fas.fa-home i.fas.fa-home
span Home span Back to #{site.name}
Loading…
Cancel
Save