Skip to content

Commit 652498f

Browse files
committed
feat: summarizer api integrate
1 parent 29f48f7 commit 652498f

3 files changed

Lines changed: 74 additions & 42 deletions

File tree

css/textEditor.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,13 @@ button:disabled {
145145
button:disabled:hover {
146146
background: #1b8045;
147147
}
148+
149+
#error {
150+
color: #d44444;
151+
font-size: 1rem;
152+
margin-top: 0;
153+
}
154+
155+
#duration {
156+
font-weight: normal;
157+
}

html/textEditor.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<h1>Meeting Conversation's Text</h1>
1717
<textarea
1818
id="meetingText"
19-
placeholder="(Meeting text should appear hear)"
19+
placeholder="(Meeting text will appear here)"
2020
></textarea>
2121
</div>
2222
<form id="submit-meeting-details" class="right-content">
@@ -30,16 +30,17 @@ <h1>Meeting Conversation's Text</h1>
3030
required
3131
/>
3232
</p>
33+
<p>Meeting's Duration: &nbsp;<span id="duration"></span></p>
3334
<p>Confidence Score: &nbsp;<span id="score"></span></p>
34-
<span style="color: #585858; margin-left: 10px"
35+
<span style="color: #585858; margin-left: 10px; font-size: 1rem"
3536
>(A confidence score is a value between 0-100, it tells us how
3637
effective our algorithms are working. The higher the score, the
3738
efficient the algorithms.)</span
3839
>
39-
<p>Meeting's Duration: &nbsp;<span id="duration"></span></p>
4040
<button type="submit" id="sendText">
4141
Generate Notes for the Meeting
4242
</button>
43+
<p id="error"></p>
4344
</form>
4445
</div>
4546
<div class="message">

javascript/textEditor.js

Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,67 @@ textarea.addEventListener('keyup', (e) => {
2222
meetingText = e.target.value;
2323
});
2424

25+
async function getSummarizedText() {
26+
const body = { email, text: meetingText, max_sentences: 2 };
27+
console.log(body);
28+
29+
const res = await fetch('http://standnote.herokuapp.com/summarizer/', {
30+
method: 'post',
31+
headers: {
32+
'Content-Type': 'application/json',
33+
},
34+
body: JSON.stringify(body),
35+
});
36+
const data = await res.json();
37+
console.log(data);
38+
39+
return data;
40+
}
41+
2542
document
2643
.getElementById('submit-meeting-details')
27-
.addEventListener('submit', (e) => {
28-
e.preventDefault();
29-
30-
document.getElementById('sendText').disabled = true;
31-
32-
title = document.getElementById('title').value;
33-
34-
const body = {
35-
email,
36-
duration: meetingDuration,
37-
title,
38-
content: meetingText,
39-
markdown: '',
40-
score: window.confidenceScore,
41-
};
42-
43-
console.log(body);
44-
45-
fetch('http://standnote.herokuapp.com/notes/', {
46-
method: 'post',
47-
headers: {
48-
'Content-Type': 'application/json',
49-
},
50-
body: JSON.stringify(body),
51-
})
52-
.then((res) => {
53-
if (res.ok) {
54-
return res.json();
55-
} else {
56-
throw new Error('Something went wrong');
57-
}
58-
})
59-
.then(() => {
60-
document.getElementsByClassName('content')[0].style.display = 'none';
61-
document.getElementsByClassName('message')[0].style.display = 'block';
62-
document.title = 'StandNote - Thanks for using StandNote';
63-
})
64-
.catch((err) => {
65-
document.getElementById('sendText').disabled = false;
44+
.addEventListener('submit', async (e) => {
45+
try {
46+
e.preventDefault();
47+
48+
document.getElementById('error').innerText = '';
49+
document.getElementById('sendText').disabled = true;
50+
51+
const data = await getSummarizedText();
52+
53+
title = document.getElementById('title').value;
54+
55+
const body = {
56+
email,
57+
duration: meetingDuration,
58+
title,
59+
content: meetingText,
60+
markdown: data.summerised_text,
61+
score: window.confidenceScore,
62+
};
63+
64+
const res = await fetch('http://standnote.herokuapp.com/notes/', {
65+
method: 'post',
66+
headers: {
67+
'Content-Type': 'application/json',
68+
},
69+
body: JSON.stringify(body),
6670
});
71+
72+
if (!res.ok) {
73+
throw new Error('Something went Wrong!');
74+
}
75+
76+
const resData = await res.json();
77+
78+
document.getElementsByClassName('content')[0].style.display = 'none';
79+
document.getElementsByClassName('message')[0].style.display = 'block';
80+
document.title = 'StandNote - Thanks for using StandNote';
81+
} catch (err) {
82+
console.log(err);
83+
document.getElementById('sendText').disabled = false;
84+
85+
document.getElementById('error').innerText =
86+
'Error while uploading the data!';
87+
}
6788
});

0 commit comments

Comments
 (0)