Skip to content

Commit

Permalink
changes for user study
Browse files Browse the repository at this point in the history
  • Loading branch information
cophilot committed Feb 15, 2024
1 parent a7fa091 commit 2aa9e5b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/components/CustomNuggetEditor/CustomNuggetEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function CustomNuggetEditor({ doc, docBase }: Props) {
);
return;
}
console.log('Selected Text:', text);

setSelectionStart(-1);
setSelectionEnd(-1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,33 @@ function InteractiveDocBaseViewer({ docBase }: Props) {

<div className="InteractiveDocBaseViewer">
<h1>Interactive Table Population Editor</h1>
<p
style={{
width: '50%',
}}
>
Here you can confirm the nuggets that should be used for the
DocBase. Below you can see what attribute is currently in
use. Click on all nuggets that are associated with the
attribute by clicking on the checkbox next to the nugget. Or
you can also select a custom nugget by clicking 'Select
custom nugget' and then highlighting the text with your
mouse and clicking 'Confirm Selection'.
</p>
<p
style={{
width: '50%',
}}
>
This process will take 3 minutes. You will not be able to
leave this page until the process is complete. After 3
minutes the process will be automatically completed. If you
have not finished confirming the nuggets, you will have to
start over.
</p>
<h2>
DocBase: <i>{docBase.name}</i>
</h2>

<h2>Documents</h2>
{docBase.docs.map((doc, index) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/NuggetText/NuggetText.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}

pre {
font-size: 1.2rem;
font-size: 1.5rem;
line-height: 2;
padding-left: 20px;
padding-right: 20px;
Expand Down
25 changes: 13 additions & 12 deletions src/components/NuggetText/NuggetText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Icon from '../Icon/Icon';
import Logger from '../../utils/Logger';
import DocBase from '../../types/DocBase';
import { useShowNotification } from '../../providers/NotificationProvider';
import APIService from '../../utils/ApiService';

interface Props {
docBase: DocBase;
Expand Down Expand Up @@ -67,7 +68,7 @@ function NuggetText({ doc, docBase, interactive = false }: Props) {

if (!interactive) return;
setTimeout(() => {
console.log('fetching ordered nuggets');
Logger.log('fetching ordered nuggets');
docBase.fetchOrderedNuggets();
}, 1000);
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -98,7 +99,7 @@ function NuggetText({ doc, docBase, interactive = false }: Props) {
Math.floor(Math.random() * 1000) + 1000
);

/* const interactiveTaskId = sessionStorage.getItem('docbaseId');
const interactiveTaskId = sessionStorage.getItem('docbaseId');
if (interactiveTaskId === null) {
Logger.error('No interactive task id found');
return;
Expand All @@ -114,11 +115,11 @@ function NuggetText({ doc, docBase, interactive = false }: Props) {
interactiveTaskId
).then((res) => {
if (res === undefined) {
showNotification('Error', 'Failed to confirm nugget');
//showNotification('Error', 'Failed to confirm nugget');
return;
}

const taskId = res;
/* const taskId = res;
const interval = setInterval(() => {
APIService.getTaskStatus(taskId).then((res) => {
Logger.log('Confirm nugget start*****' + interval);
Expand All @@ -128,19 +129,18 @@ function NuggetText({ doc, docBase, interactive = false }: Props) {
res == undefined ||
res.state.toUpperCase().trim() === 'FAILURE'
) {
showNotification('Error', 'Failed to confirm nugget');
// showNotification('Error', 'Failed to confirm nugget');
clearInterval(interval);
return;
} else if (res.state.toUpperCase().trim() === 'SUCCESS') {
// TODO
showNotification('Success', 'Nugget confirmed');
// showNotification('Success', 'Nugget confirmed');
setConfirmedNuggets([...confirmedNuggets, nugget.ID]);
clearInterval(interval);
}
});
}, 1000);
}); */
}, 1000); */
});
};

const finalHighlightedText = normalizedIntervals
Expand Down Expand Up @@ -169,17 +169,18 @@ function NuggetText({ doc, docBase, interactive = false }: Props) {
<Icon
style={{
color: 'black',
fontSize: '1.2rem',
fontSize: '1.5rem',
marginRight: '0px',
paddingRight: '5px',
verticalAlign: '-1px',
}}
cls={
'bi icon ml' +
(confirmedNuggets.includes(
doc.nuggets[index].getHash()
)
? ' bi-hand-thumbs-up-fill'
: ' bi-hand-thumbs-up')
? ' bi-check-circle-fill'
: ' bi-check-circle')
}
onClicked={() => {
Logger.log('Confirm Nugget');
Expand Down
29 changes: 29 additions & 0 deletions src/views/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@ function Home() {
Hi {username.slice(0, -2)}
<span className="db">{username.slice(-2)}</span> 👋
</h1>
<h2>
U<span className="db">se</span>r Study
</h2>
<p>
<b>
If you are from the user study, you can download
some sample documents{' '}
<a
href="https://github.com/cophilot/wannadb-sample-txt/archive/refs/heads/main.zip"
target="_blank"
>
here
</a>{' '}
to use them for the upload.
</b>
</p>
<p>
<i>
If the link does not download the file, please click{' '}
<a
href="https://github.com/cophilot/wannadb-sample-txt?tab=readme-ov-file#how-to-download"
target="_blank"
rel="noreferrer"
>
here
</a>{' '}
and download the file manually.
</i>
</p>
<h2>
T<span className="db">ip</span>
</h2>
Expand Down

0 comments on commit 2aa9e5b

Please sign in to comment.