filtered out visited sites via pug page for index

This commit is contained in:
Sean Clarke 2020-01-07 13:55:05 -05:00
parent c260f206e0
commit eb9d8f78f7
4 changed files with 40 additions and 12 deletions

View File

@ -27,7 +27,7 @@ module.exports = {
getAll: function(req, res){
Site.getAll(function(err, sites){
if(err) throw err;
res.render('index', { title: "Home", sites: sites });
res.render('site-listing', { title: "All Sites", sites: sites });
});
},
UniqueSiteVisits: function(req, res){
@ -35,7 +35,7 @@ module.exports = {
if(err) throw err;
Site.findAllById(uniqueSites, function(err, uniqueSiteVisits){
if(err) throw err;
res.render('index', { title: "UniqueSiteVisits", sites: uniqueSiteVisits });
res.render('site-listing', { title: "UniqueSiteVisits", sites: uniqueSiteVisits });
});
});
}

View File

@ -3,10 +3,16 @@ extends layout
block content
h1= title
h2= "Sites Visited: " + visits.length + "/" + totalSites
h2= "Sites Visited: "
a(href="/visits") #{visits.length}
| /
a(href="/sites") #{totalSites}
- var sitesVisited = [];
h2= "Visits"
each visit in visits
- sitesVisited.push(visit.id);
h3= visit.site
//- Commmand list of all the states
h5
@ -15,16 +21,20 @@ block content
| #{states[i]}
if (i + 1 < states.length)
| ,
h2= "Remaining"
each site in sites
h3= site.site
//- Commmand list of all the states
h5
- var states = site.states.split(',')
- for (var i = 0; i < states.length; i++)
| #{states[i]}
if (i + 1 < states.length)
| ,
if !(sitesVisited.includes(site.id))
h3= site.site
//- Commmand list of all the states
h5
- var states = site.states.split(',')
- for (var i = 0; i < states.length; i++)
| #{states[i]}
if (i + 1 < states.length)
| ,
else
h3= "Removed!"
include footer.pug

18
views/site-listing.pug Normal file
View File

@ -0,0 +1,18 @@
extends layout
block content
h1= title
h2= "Sites: " + sites.length
each site in sites
h3= site.site
//- Commmand list of all the states
h5
- var states = site.states.split(',')
- for (var i = 0; i < states.length; i++)
| #{states[i]}
if (i + 1 < states.length)
| ,
include footer.pug

View File