Browse Source

paginated unified feed for Home/Dashboard

master
Rob Colbert 3 months ago
parent
commit
b1cdfbed94
  1. 3
      src/app/controllers/home.ts
  2. 15
      src/app/views/components/page-sidebar.pug
  3. 11
      src/app/views/feed-item/components/headline-list.pug
  4. 4
      src/app/views/feed-item/components/headline-section.pug
  5. 9
      src/app/views/home-auth.pug
  6. 13
      src/app/views/home.pug
  7. 4
      src/app/views/user/settings.pug
  8. 2
      src/lib/web/server.ts

3
src/app/controllers/home.ts

@ -31,7 +31,8 @@ export class HomeController extends WebController {
async getHome (req: Request, res: Response, next: NextFunction) : Promise<void> { async getHome (req: Request, res: Response, next: NextFunction) : Promise<void> {
const feedService = this.getService<FeedService>("feed"); const feedService = this.getService<FeedService>("feed");
try { try {
res.locals.feedLibrary = await feedService.getUnifiedFeed({ p: 1, skip: 0, cpp: 20 }); res.locals.pagination = this.getPaginationParameters(req, 20);
res.locals.feedLibrary = await feedService.getUnifiedFeed(res.locals.pagination);
if (req.user) { if (req.user) {
return res.render('home-auth'); return res.render('home-auth');
} }

15
src/app/views/components/page-sidebar.pug

@ -31,18 +31,3 @@ mixin renderPageSidebar ( )
aria-label="Search", aria-label="Search",
).uk-search-input.uk-border-rounded ).uk-search-input.uk-border-rounded
.uk-margin-medium
+renderSectionTitle('Running Tests', { label: "See All", title: "View all tests", url: "/load-test" })
.sidebar-widget
if Array.isArray(tests.running) && (tests.running.length > 0)
pre= JSON.stringify(tests.running, null, 2)
else
div There are no live tests
.uk-margin-medium
+renderSectionTitle('Finished Tests', { label: "See All", title: "View all finished tests", url: "/load-test/finished" })
.sidebar-widget
if Array.isArray(tests.finished) && (tests.finished.length > 0)
pre= JSON.stringify(tests.finished, null, 2)
else
div There are no live tests

11
src/app/views/feed-item/components/headline-list.pug

@ -0,0 +1,11 @@
mixin renderFeedItemHeadlineList (feedLibrary)
if Array.isArray(feedLibrary.items) && (feedLibrary.items.length > 0)
ul.uk-list.uk-list-small.uk-list-divider
each feedItem in feedLibrary.items
li
a(href= feedItem.link, target="_blank").uk-link-reset.uk-display-block
p.uk-text-lead.uk-margin-remove= feedItem.title
div!= feedItem.summary
.uk-text-small.uk-text-muted Published #{dayjs(feedItem.created).format("MMMM DD, YYYY")}, at #{dayjs(feedItem.created).format("hh:mm a")}
else
div There are no feed items to display

4
src/app/views/feed-item/components/headline-section.pug

@ -0,0 +1,4 @@
include headline-list
section.uk-section.uk-section-secondary.uk-section-small
.uk-container
+renderFeedItemHeadlineList(feedLibrary)

9
src/app/views/home-auth.pug

@ -1,5 +1,10 @@
extends layouts/main-sidebar-wide extends layouts/main-sidebar-wide
block content block content
h1 Test Dashboard include feed-item/components/headline-list
p This view will soon have recent top-level test reports and other analytics. include components/pagination-bar
h1 News Dashboard
+renderFeedItemHeadlineList(feedLibrary)
+renderPaginationBar("/", feedLibrary.totalItemCount)

13
src/app/views/home.pug

@ -9,15 +9,4 @@ block content
.app-title= site.name .app-title= site.name
.app-description= site.description .app-description= site.description
section.uk-section.uk-section-secondary.uk-section-small include feed-item/components/headline-section
.uk-container
if Array.isArray(feedLibrary.items) && (feedLibrary.items.length > 0)
ul.uk-list.uk-list-small.uk-list-divider
each feedItem in feedLibrary.items
li
a(href= feedItem.link, target="_blank").uk-link-reset.uk-display-block
p.uk-text-lead.uk-margin-remove= feedItem.title
div!= feedItem.summary
.uk-text-small.uk-text-muted Published #{dayjs(feedItem.created).format("MMMM DD, YYYY")}, at #{dayjs(feedItem.created).format("hh:mm a")}
else
div There are no feed items to display

4
src/app/views/user/settings.pug

@ -71,8 +71,8 @@ block content
.uk-margin .uk-margin
label(for="theme").uk-form-label UI Theme label(for="theme").uk-form-label UI Theme
select(id="theme", name="theme").uk-select select(id="theme", name="theme").uk-select
option(value="dtp-light", selected= user ? userProfile.theme === 'dtp-light' : true) Light Mode option(value="newsroom-light", selected= user ? userProfile.theme === 'newsroom-light' : true) Light Mode
option(value="dtp-dark", selected= user ? userProfile.theme === 'dtp-dark' : false) Dark Mode option(value="newsroom-dark", selected= user ? userProfile.theme === 'newsroom-dark' : false) Dark Mode
div div
.uk-margin .uk-margin

2
src/lib/web/server.ts

@ -128,7 +128,7 @@ export class WebServer extends DtpBase {
return next(); return next();
} }
this.app.use(["/dist","/"], serviceWorkerAllowed, express.static(path.join(env.root, "dist", "client"))); this.app.use(["/dist", "/"], serviceWorkerAllowed, express.static(path.join(env.root, "dist", "client")));
this.app.use("/socket.io", cacheOneDay, express.static(path.join(env.root, "node_modules", "socket.io", "client-dist"))); this.app.use("/socket.io", cacheOneDay, express.static(path.join(env.root, "node_modules", "socket.io", "client-dist")));
this.app.use("/uikit", cacheOneDay, express.static(path.join(env.root, "node_modules", "uikit", "dist"))); this.app.use("/uikit", cacheOneDay, express.static(path.join(env.root, "node_modules", "uikit", "dist")));

Loading…
Cancel
Save