Skip to content

Commit

Permalink
Task debugging in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
rossdrew committed May 25, 2023
1 parent 5cf3419 commit 7081d7b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
45 changes: 42 additions & 3 deletions journal-ui/src/components/bufferedJournalEntries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -15,6 +16,10 @@ class BufferedJournalEntries extends Component {
entries: new SizedHeadTailLinkedList(20)
},

loadedTasks: {
tasks: []
},

entriesPagingHeader: {
size: null,
limit: null,
Expand Down Expand Up @@ -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()
Expand All @@ -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: {
Expand All @@ -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
})
Expand Down Expand Up @@ -203,11 +235,12 @@ class BufferedJournalEntries extends Component {
}
</sup>

{/*Is there a better way to do this?*/}
<div className="continue" id="infiniteScrollerPrepend">
{ this.state.loadedEntries.start > 0 ? "..." : ""}
</div>

{/*{this.preview()}*/}
{this.preview()}

{this.loadedEntrySet().map((entry, index) => (
<JournalEntry entry={entry}
Expand All @@ -216,6 +249,12 @@ class BufferedJournalEntries extends Component {
key={this.entryCardKeyPrefix + index} />
))}

{/* WIP WIP WIP WIP WIP WIP WIP WIP WIP */}
{/*<div class="debug"><b><u>Task Debugging</u></b><br/>{this.state.loadedTasks.tasks.length} Items...</div>*/}
{/*{this.state.loadedTasks.tasks.map( (task, index) =>*/}
{/* <JournalEntryLink task={task} entries={this.state.loadedEntries} index={index}/>*/}
{/*)}*/}

<div className="continue" id="infiniteScrollerAppend">
{ this.appendableEntriesRemaining() ? "..." : "."}
</div>
Expand Down
14 changes: 14 additions & 0 deletions journal-ui/src/components/journalEntryLink.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className="debug">&nbsp;&nbsp;&nbsp;[{this.props.index}] '{this.props.task.id}'</div>
)
}
}

export default JournalEntryLink

0 comments on commit 7081d7b

Please sign in to comment.