-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prototyping potential Digital Reader Library layouts
- Loading branch information
1 parent
d5ea441
commit 0e152ae
Showing
15 changed files
with
653 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const DigitalReaderStory = require('../../models/drStory'); | ||
//const User = require('../../models/user'); | ||
const mongoose = require('mongoose'); | ||
const {API404Error} = require('../../utils/APIError'); | ||
|
||
// get stories by owner (user) ID | ||
const handler = async (req, res) => { | ||
/*const user = await User.findOne({'_id': req.params.id}); | ||
if (!user) { | ||
throw new API404Error(`User with id ${req.params.id} not found.`); | ||
}*/ | ||
|
||
const digitalReaderStories = await DigitalReaderStory.find({'public': 'true'}).sort({$natural:-1}); | ||
|
||
if (!digitalReaderStories) { | ||
throw new API404Error(`No publicly available Digital Reader stories were found.`); | ||
} | ||
return res.status(200).json(digitalReaderStories); | ||
}; | ||
|
||
export = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const DigitalReaderStory = require('../../models/drStory'); | ||
//const User = require('../../models/user'); | ||
const mongoose = require('mongoose'); | ||
const {API404Error} = require('../../utils/APIError'); | ||
|
||
// get stories by owner (user) ID | ||
const handler = async (req, res) => { | ||
/*const user = await User.findOne({'_id': req.params.id}); | ||
if (!user) { | ||
throw new API404Error(`User with id ${req.params.id} not found.`); | ||
}*/ | ||
|
||
//const digitalReaderStories = await DigitalReaderStory.find({'public': 'true'}).sort({$natural:-1}); | ||
|
||
/*if (!digitalReaderStories) { | ||
throw new API404Error(`No publicly available Digital Reader stories were found.`); | ||
}*/ | ||
|
||
// Get all documents whose owners carry the ADMIN role | ||
const digitalReaderStories = await DigitalReaderStory.aggregate([ | ||
{$lookup: { | ||
from: 'users', | ||
localField: 'owner', | ||
foreignField: '_id', | ||
as: 'ownerDocArr' | ||
}}, | ||
{$project: { | ||
title: 1, | ||
ownerDoc: {$first: '$ownerDocArr'} | ||
}}, | ||
{$project: { | ||
title: 1, | ||
ownerRole: '$ownerDoc.role' | ||
}}, | ||
{$match: { | ||
ownerRole: "ADMIN" | ||
}} | ||
]) | ||
|
||
if (!digitalReaderStories) { | ||
throw new API404Error(`No An Scéalaí-verified Digital Reader stories were found.`); | ||
} | ||
|
||
return res.status(200).json(digitalReaderStories); | ||
}; | ||
|
||
export = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 75 additions & 3 deletions
78
ngapp/src/app/nav-bar/digital-reader-library/digital-reader-library.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
ngapp/src/app/nav-bar/dr-story-drawer/dr-story-drawer.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<div class="body"> | ||
<div *ngIf="storyList.length > 0"> | ||
<div class="myStories">{{ title }}</div> | ||
<!-- search bar --> | ||
<div class="form-group"> | ||
<input | ||
type="text" | ||
class="form-control searchBox" | ||
id="search-text" | ||
aria-describedby="search-text" | ||
[(ngModel)]="searchText" | ||
placeholder="{{ ts.l.search_story_title_or_content }}" | ||
/> | ||
</div> | ||
</div> | ||
<!-- list of stories --> | ||
<div class="storyList"> | ||
<div *ngFor="let story of storyList | appFilter : searchText; let i = index" (click)="openStory(story)" style="display: flex;"> | ||
<!-- story entry--> | ||
<div class="contentSection" [attr.id]="story._id"> | ||
<!-- date and menu icon--> | ||
<div class="contentsDate"> | ||
{{ story.updatedAt | date : "d/M/yy" }} | ||
|
||
<button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Options to delete or rename your story" > | ||
<mat-icon>more_vert</mat-icon> | ||
</button> | ||
<mat-menu #menu="matMenu"> | ||
<button mat-menu-item > | ||
<mat-icon>delete</mat-icon> | ||
<span>{{ ts.l.delete }}</span> | ||
</button> | ||
<button mat-menu-item > | ||
<mat-icon>create</mat-icon> | ||
<span>{{ ts.l.rename }}</span> | ||
</button> | ||
</mat-menu> | ||
</div> | ||
<!-- title container--> | ||
<div class="titleContainer"> | ||
<div class="contentsTitle" [attr.id]="i" (blur)="saveStoryTitle(i, story)" (keydown.enter)="saveStoryTitle(i, story)" > | ||
{{ story?.title }} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<mat-divider [vertical]="true" [inline]="true" style="height:85%;"></mat-divider> | ||
</div> | ||
</div> | ||
<!--<button mat-fab class="newStoryButton" (click)="createNewStory()"> | ||
<mat-icon>add</mat-icon> | ||
</button>--> | ||
</div> |
Oops, something went wrong.