From 7081d7b7b42bffcb95ae0f9a745970d2873af564 Mon Sep 17 00:00:00 2001 From: rossdrew Date: Thu, 25 May 2023 16:42:45 +0100 Subject: [PATCH] Task debugging in the UI --- .../src/components/bufferedJournalEntries.js | 45 +++++++++++++++++-- journal-ui/src/components/journalEntryLink.js | 14 ++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 journal-ui/src/components/journalEntryLink.js diff --git a/journal-ui/src/components/bufferedJournalEntries.js b/journal-ui/src/components/bufferedJournalEntries.js index fa102b0..d524f7d 100644 --- a/journal-ui/src/components/bufferedJournalEntries.js +++ b/journal-ui/src/components/bufferedJournalEntries.js @@ -3,6 +3,7 @@ import HeaderControl from "./headerControl"; import JournalEntry from "./journalEntry"; import FootControl from "./footControl"; import SizedHeadTailLinkedList from "../utilities/SizedHeadTailLinkedList"; +import JournalEntryLink from "./journalEntryLink"; class BufferedJournalEntries extends Component { constructor() { @@ -15,6 +16,10 @@ class BufferedJournalEntries extends Component { entries: new SizedHeadTailLinkedList(20) }, + loadedTasks: { + tasks: [] + }, + entriesPagingHeader: { size: null, limit: null, @@ -131,6 +136,14 @@ class BufferedJournalEntries extends Component { .catch(console.log); } + getTasks(){ + let url = 'http://localhost:8080/tasks'; + + return fetch(url) + .then(res => res.json()) + .catch(console.log); + } + refresh(event) { if (event) { event.preventDefault() @@ -144,9 +157,9 @@ class BufferedJournalEntries extends Component { let updatedEntries = this.state.loadedEntries.entries.deepClone(); pagedEntries.data.forEach(entry => { updatedEntries.append(entry); - }); //XXX this wont always be an append + }); //XXX this won't always be an append operation - console.log(updatedEntries.getSize() + " entries loaded from server") + // console.log(updatedEntries.getSize() + " entries loaded from server") this.setState({ loadedEntries: { @@ -162,6 +175,25 @@ class BufferedJournalEntries extends Component { }) }).catch(console.log); + //XXX Why do I need to manually map from an array to an array + this.getTasks().then((responseTasks) => { + let intemediateTaskCollection = []; + responseTasks.data.forEach(entry => { + intemediateTaskCollection = intemediateTaskCollection.concat(entry); + }); + this.setState({ + loadedTasks: { + tasks: intemediateTaskCollection + } + }) + + console.log("TEST") + console.log(intemediateTaskCollection) + console.log(responseTasks.data) + console.log(this.state.loadedTasks.tasks) + console.log("TEST") + }) + this.setState({ activeFilter: this.state.containsFilter }) @@ -203,11 +235,12 @@ class BufferedJournalEntries extends Component { } + {/*Is there a better way to do this?*/}
{ this.state.loadedEntries.start > 0 ? "..." : ""}
- {/*{this.preview()}*/} + {this.preview()} {this.loadedEntrySet().map((entry, index) => ( ))} + {/* WIP WIP WIP WIP WIP WIP WIP WIP WIP */} + {/*
Task Debugging
{this.state.loadedTasks.tasks.length} Items...
*/} + {/*{this.state.loadedTasks.tasks.map( (task, index) =>*/} + {/* */} + {/*)}*/} +
{ this.appendableEntriesRemaining() ? "..." : "."}
diff --git a/journal-ui/src/components/journalEntryLink.js b/journal-ui/src/components/journalEntryLink.js new file mode 100644 index 0000000..5808c3f --- /dev/null +++ b/journal-ui/src/components/journalEntryLink.js @@ -0,0 +1,14 @@ +import React, { Component } from 'react' + +// Get a list of tasks outstanding +// For each pair, separate those on screen and those off, with directionality of link + +class JournalEntryLink extends Component { + render() { + return ( +
   [{this.props.index}] '{this.props.task.id}'
+ ) + } +} + +export default JournalEntryLink \ No newline at end of file