From 81f88d1df2be5af40e0075f857a8bb53aaff3ad7 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 19 Dec 2021 23:34:24 -0500 Subject: [PATCH] disable geoip displays; fix link analyzer service calls --- app/controllers/dashboard.js | 6 +- app/views/dashboard/link-analyzer.pug | 96 +++++++++++++++------------ app/views/dashboard/view.pug | 50 +++++++------- app/views/error.pug | 5 +- 4 files changed, 87 insertions(+), 70 deletions(-) diff --git a/app/controllers/dashboard.js b/app/controllers/dashboard.js index 08b02db..3a828f2 100644 --- a/app/controllers/dashboard.js +++ b/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); diff --git a/app/views/dashboard/link-analyzer.pug b/app/views/dashboard/link-analyzer.pug index 1ca1e91..e73dcb0 100644 --- a/app/views/dashboard/link-analyzer.pug +++ b/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)}); }); \ No newline at end of file diff --git a/app/views/dashboard/view.pug b/app/views/dashboard/view.pug index 175f551..10f7f14 100644 --- a/app/views/dashboard/view.pug +++ b/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") diff --git a/app/views/error.pug b/app/views/error.pug index 077adc4..ed21b2c 100644 --- a/app/views/error.pug +++ b/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 \ No newline at end of file + span Back to #{site.name} \ No newline at end of file