-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ce8320
commit a93c93a
Showing
45 changed files
with
1,013 additions
and
113 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
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,59 @@ | ||
|
||
const PaperEventDAO = require('../daos/PaperEventDAO') | ||
|
||
module.exports = class PaperEventService { | ||
|
||
constructor(core) { | ||
this.core = core | ||
|
||
this.paperEventDAO = new PaperEventDAO(core) | ||
} | ||
|
||
async getActiveSubmissionId(paperId) { | ||
const results = await this.core.database.query(` | ||
SELECT journal_submissions.id | ||
FROM journal_submissions | ||
WHERE journal_submissions.status != 'published' | ||
AND journal_submissions.status != 'rejected' | ||
AND journal_submissions.status != 'retracted' | ||
AND journal_submissions.paper_id = $1 | ||
LIMIT 1 | ||
`, [ paperId ]) | ||
|
||
if ( results.rows.length <= 0 ) { | ||
return null | ||
} | ||
|
||
return results.rows[0].id | ||
} | ||
|
||
async getCurrentPaperVersion(paperId) { | ||
const versionResults = await this.core.database.query( | ||
`SELECT version FROM paper_versions WHERE paper_id = $1 ORDER BY version desc`, | ||
[ paperId ] | ||
) | ||
return versionResults.rows[0].version | ||
} | ||
|
||
async getEventVisibility(user, event) { | ||
return [ 'public' ] | ||
} | ||
|
||
async createEvent(user, event) { | ||
|
||
if ( ! event.submissionId ) { | ||
event.submissionId = await this.getActiveSubmissionId(event.paperId) | ||
} | ||
|
||
// If we don't have a version already, grab it from the database. | ||
if ( ! event.version ) { | ||
event.version = await this.getCurrentPaperVersion(event.paperId) | ||
} | ||
|
||
event.visibility = await this.getEventVisibility(user, event) | ||
|
||
console.log(event) | ||
await this.paperEventDAO.insertEvent(event) | ||
} | ||
|
||
} |
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
Empty file.
114 changes: 114 additions & 0 deletions
114
web-application/client/components/feeds/EditorEventFeed.js
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,114 @@ | ||
import React, { useState, useEffect } from 'react' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
|
||
import { getEditorFeed, cleanupRequest } from '/state/paperEvents' | ||
|
||
import { Timeline } from '/components/generic/timeline/Timeline' | ||
|
||
import FeedPaperReviewView from './events/FeedPaperReviewView' | ||
import FeedPaperVersionEvent from './events/FeedPaperVersionEvent' | ||
import PaperPreprintSubmissionEvent from '/components/papers/view/timeline/events/PaperPreprintSubmissionEvent' | ||
import FeedPaperJournalSubmissionEvent from './events/FeedPaperJournalSubmissionEvent' | ||
import FeedPaperSubmissionAssignmentEvent from './events/FeedPaperSubmissionAssignmentEvent' | ||
import PaperSubmissionStatusChange from '/components/papers/view/timeline/events/PaperSubmissionStatusChange' | ||
|
||
const EditorEventFeed = function({ }) { | ||
|
||
// ============ Request Tracking ========================================== | ||
|
||
const [ requestId, setRequestId ] = useState(null) | ||
const request = useSelector(function(state) { | ||
if ( state.paperEvents.requests[requestId] ) { | ||
return state.paperEvents.requests[requestId] | ||
} else { | ||
return null | ||
} | ||
}) | ||
|
||
// ============ Redux State =============================================== | ||
|
||
const currentUser = useSelector(function(state) { | ||
return state.authentication.currentUser | ||
}) | ||
|
||
const events = useSelector(function(state) { | ||
const results = [] | ||
const query = state.paperEvents.queries['EditorEventFeed'] | ||
if ( query ) { | ||
for ( const eventId of query.list) { | ||
results.push(state.paperEvents.dictionary[eventId]) | ||
} | ||
} | ||
return results | ||
}) | ||
|
||
// ============ Effect Handling =========================================== | ||
|
||
const dispatch = useDispatch() | ||
|
||
useEffect(function() { | ||
setRequestId(dispatch(getEditorFeed('EditorEventFeed', { relations: [ 'papers' ] }))) | ||
}, []) | ||
|
||
useEffect(function() { | ||
return function cleanup() { | ||
if ( requestId ) { | ||
dispatch(cleanupRequest({ requestId: requestId })) | ||
} | ||
} | ||
}, [ requestId ]) | ||
|
||
// ============ Render ==================================================== | ||
|
||
/** | ||
* Event Types | ||
* | ||
* 'version-uploaded', | ||
* 'preprint-posted', | ||
* 'review-posted', | ||
* 'review-comment-reply-posted', | ||
* 'comment-posted', | ||
* 'submitted-to-journal', | ||
* 'submission-status-changed', | ||
* 'reviewer-assigned', | ||
* 'reviewer-unassigned', | ||
* 'editor-assigned', | ||
* 'editor-unassigned' | ||
*/ | ||
const eventViews = [] | ||
for(const event of events) { | ||
if ( event.type == 'review-posted' ) { | ||
eventViews.push( | ||
<FeedPaperReviewView key={event.id} eventId={event.id} /> | ||
) | ||
} | ||
|
||
else if ( event.type =='version-uploaded' ) { | ||
eventViews.push( | ||
<FeedPaperVersionEvent key={event.id} eventId={event.id} /> | ||
) | ||
} | ||
|
||
else if ( event.type == 'submitted-to-journal') { | ||
eventViews.push( | ||
<FeedPaperJournalSubmissionEvent key={event.id} eventId={event.id} /> | ||
) | ||
} | ||
|
||
else if ( event.type == 'submission-status-changed' ) { | ||
eventViews.push( | ||
<PaperSubmissionStatusChange key={event.id} eventId={event.id} /> | ||
) | ||
} | ||
} | ||
|
||
return ( | ||
<div className="editor-event-feed"> | ||
<Timeline> | ||
{ eventViews } | ||
</Timeline> | ||
</div> | ||
) | ||
} | ||
|
||
export default EditorEventFeed |
9 changes: 9 additions & 0 deletions
9
web-application/client/components/feeds/events/FeedPaperJournalSubmissionEvent.css
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,9 @@ | ||
.feed-paper-journal-submission-event.timeline-item { | ||
margin: 20px 0; | ||
} | ||
.feed-paper-journal-submission-event .header { | ||
padding: 5px 0; | ||
} | ||
.feed-paper-journal-submission-event .event-body { | ||
border: thin solid var(--main-border-color); | ||
} |
54 changes: 54 additions & 0 deletions
54
web-application/client/components/feeds/events/FeedPaperJournalSubmissionEvent.js
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,54 @@ | ||
import React from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { Link } from 'react-router-dom' | ||
|
||
import { EyeIcon, InboxArrowDownIcon } from '@heroicons/react/24/outline' | ||
|
||
import { TimelineItem, TimelineIcon, TimelineItemWrapper } from '/components/generic/timeline/Timeline' | ||
import DateTag from '/components/DateTag' | ||
|
||
import UserTag from '/components/users/UserTag' | ||
import JournalTag from '/components/journals/JournalTag' | ||
|
||
import FeedEventPaperComponent from './components/FeedEventPaperComponent' | ||
import JournalSubmissionsListItem from '/components/journals/submissions/JournalSubmissionsListItem' | ||
|
||
import './FeedPaperJournalSubmissionEvent.css' | ||
|
||
const FeedPaperJournalSubmissionEvent = function({ eventId }) { | ||
|
||
// ================= Redux State ========================================== | ||
|
||
const event = useSelector(function(state) { | ||
return state.paperEvents.dictionary[eventId] | ||
}) | ||
|
||
const paper = useSelector(function(state) { | ||
return state.papers.dictionary[event.paperId] | ||
}) | ||
|
||
const submission = useSelector(function(state) { | ||
return state.journalSubmissions.dictionary[event.submissionId] | ||
}) | ||
|
||
// ================= Render =============================================== | ||
|
||
return ( | ||
<TimelineItem className="feed-paper-journal-submission-event"> | ||
<TimelineIcon> | ||
<InboxArrowDownIcon /> | ||
</TimelineIcon> | ||
<TimelineItemWrapper> | ||
<div className="header"> | ||
New submission to <JournalTag id={submission.journalId} /> -- <DateTag timestamp={event.eventDate} type="full" /> | ||
</div> | ||
<div className="event-body"> | ||
<JournalSubmissionsListItem submissionId={event.submissionId} /> | ||
</div> | ||
</TimelineItemWrapper> | ||
</TimelineItem> | ||
) | ||
|
||
} | ||
|
||
export default FeedPaperJournalSubmissionEvent |
Oops, something went wrong.