From 1a67642b356c4bb2f38ab35251233ce089b81247 Mon Sep 17 00:00:00 2001 From: dexagod Date: Tue, 6 Oct 2020 13:30:52 +0200 Subject: [PATCH] added time stamping to proposals --- src/Components/InProgressViewerComponent.js | 17 +++++++++++++++-- src/Components/MarriageViewComponent.js | 2 +- src/Components/NotificationsViewerComponent.js | 9 +++++++-- src/hooks/useNotifications.js | 9 +++++++++ src/util/MarriageController.js | 3 ++- src/util/Util.js | 1 + 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/Components/InProgressViewerComponent.js b/src/Components/InProgressViewerComponent.js index 55802c8..808c426 100644 --- a/src/Components/InProgressViewerComponent.js +++ b/src/Components/InProgressViewerComponent.js @@ -4,7 +4,7 @@ import { Value } from '@solid/react'; import ns from "../util/NameSpaces" import useContracts from '../hooks/useContracts' -import { availableViews } from '../util/Util' +import { availableViews, formatDate } from '../util/Util' const InProgressViewerComponent = (props) => { @@ -22,6 +22,17 @@ const InProgressViewerComponent = (props) => { const split = status.split('/') return split[split.length - 1] } + + const getContractDate = (date) => { + if (!date) { + return "no date set" + } else { + return new Date(date).toLocaleString() + } + } + console.log('contracts', contracts) + + const sortedContracts = contracts.sort( (a, b) => { if(!b) { return a } else if (!a) { return b } else { return new Date(a.created) - new Date(b.created) }}) return (

Running Procedures

@@ -29,14 +40,16 @@ const InProgressViewerComponent = (props) => { + - {contracts.map(contract => { + {sortedContracts.map(contract => { return ( + diff --git a/src/Components/MarriageViewComponent.js b/src/Components/MarriageViewComponent.js index 5bc81fb..8a394cc 100644 --- a/src/Components/MarriageViewComponent.js +++ b/src/Components/MarriageViewComponent.js @@ -97,7 +97,7 @@ const MarriageViewComponent = (props) => { async function submitMarriageProposal() { // For demo purposes outside of the workshop also, we will have the user function as the official also if (! await validateOfficial()) return; - const submission = await submitProposal(props.webId, props.contractId, official) + const submission = submitProposal(props.webId, props.contractId, official) props.setview(availableViews.running) } diff --git a/src/Components/NotificationsViewerComponent.js b/src/Components/NotificationsViewerComponent.js index 3853bd8..091e132 100644 --- a/src/Components/NotificationsViewerComponent.js +++ b/src/Components/NotificationsViewerComponent.js @@ -8,6 +8,7 @@ import { Value } from '@solid/react'; import ns from "../util/NameSpaces" import { availableViews, getContractData } from '../util/Util' +import { deleteFile } from '../util/FileUtil'; const NotificationsViewerComponent = (props) => { @@ -19,7 +20,7 @@ const NotificationsViewerComponent = (props) => {

Notifications


- + @@ -66,7 +67,7 @@ const NotificationCard = (props) => { return (
- + @@ -98,4 +99,8 @@ const NotificationCard = (props) => { async function viewRejections() { props.setview(availableViews.running) } + + async function deleteNotification(notificationId) { + const result = await deleteFile(notificationId) + } } \ No newline at end of file diff --git a/src/hooks/useNotifications.js b/src/hooks/useNotifications.js index 3c501c4..cfd7112 100644 --- a/src/hooks/useNotifications.js +++ b/src/hooks/useNotifications.js @@ -8,6 +8,7 @@ const TIMEOUT = 10 * 1000 // const { default: data } = require('@solid/query-ldflex'); const useNotifications = function(webId) { + console.log('useNotifications') const [notifications, setNotifications] = useState([]); useEffect(() => { let mounted = true; @@ -29,10 +30,15 @@ const useNotifications = function(webId) { // TODO:: dont fetch notifications that have already been fetched async function updateNotifications(webId, currentNotifications){ + console.log('timing') if(webId){ + console.time("fetchnew") const newNotificationsMetadata = await checkNewNotifications(webId, currentNotifications.map(n => n.metadata.id)) + console.timeEnd("fetchnew") if(newNotificationsMetadata && newNotificationsMetadata.length) { + console.time("fetchNotifs") const newNotifications = (await fetchNotifications(newNotificationsMetadata)) || [] + console.timeEnd("fetchNotifs") fireUpdateEvents(newNotifications) return newNotifications } @@ -72,6 +78,7 @@ const useNotifications = function(webId) { * This should be placed somewhere else in the future */ async function fireUpdateEvents(updatedNotifications){ + console.time("update") const currentContracts = await getProfileContracts(webId) for (const notification of updatedNotifications) { const itemId = notification.type === ns.as('Announce') ? notification.object && notification.object.object : notification.target @@ -93,6 +100,8 @@ const useNotifications = function(webId) { } } } + + console.timeEnd("update") } async function checkContractSubmittedStatus(proposalId) { diff --git a/src/util/MarriageController.js b/src/util/MarriageController.js index eda94b5..bae4acb 100644 --- a/src/util/MarriageController.js +++ b/src/util/MarriageController.js @@ -272,7 +272,8 @@ const getCertificateName = () => { async function createMarriagePropsalBody(proposalData, creatorId){ const quadList = [ quad(namedNode(''), namedNode(ns.rdf('type')), namedNode(ns.demo('MarriageProposal'))), quad(namedNode(''), namedNode(ns.dct('creator')), namedNode(creatorId)), - quad(namedNode(''), namedNode(ns.demo('status')), namedNode(ns.demo('proposal'))),] + quad(namedNode(''), namedNode(ns.dct('created')), literal(new Date().toISOString(), namedNode(ns.xsd('dateTime')))), + quad(namedNode(''), namedNode(ns.demo('status')), namedNode(ns.demo('proposal'))) ] for (let spouse of proposalData.filter(e => e.type === 'spouse')) quadList.push(quad(namedNode(''), namedNode(ns.dbo('spouse')), namedNode(spouse.webId))) for (let witness of proposalData.filter(e => e.type === 'witness')) diff --git a/src/util/Util.js b/src/util/Util.js index 574e2ae..a0fbbd4 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -109,6 +109,7 @@ export async function getContractData(id) { id: id, type: getQuadObjVal(await datastore.getQuads(id, ns.rdf('type'))), creator: getQuadObjVal(await datastore.getQuads(id, ns.dct('creator'))), + created: getQuadObjVal(await datastore.getQuads(id, ns.dct('created'))), certified_by: getQuadObjVal(await datastore.getQuads(id, ns.demo('certified_by'))), status: getQuadObjVal(await datastore.getQuads(id, ns.demo('status'))), spouse: getQuadObjList(await datastore.getQuads(id, ns.dbo('spouse'))).map(e => {return({id: e})}),