Skip to content

Commit

Permalink
add auth to training
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobasco99 committed Sep 24, 2024
1 parent a06b7f2 commit af88d05
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bot.manager.widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ class BotManagerWidget extends LitElement {
if (!endpoint) {
return;
}
const accessToken = localStorage.getItem("access_token");

fetch(endpoint + "/models/")
fetch(endpoint + "/models/", {
headers: {
"Authorization": `Bearer ${accessToken}`
}
})
.then((response) => {
if (
response.ok &&
Expand Down
15 changes: 15 additions & 0 deletions src/model-training.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ class ModelTraining extends LitElement {
markdownTrainingData: _this.editor.getText(),
}),
contentType: "application/json",
headers: {
"Authorization": "Bearer " + localStorage.getItem("access_token"),
},
success: function (data, textStatus, jqXHR) {
$(_this.htmlQuery("#trainingStatus")).text(data);
},
Expand Down Expand Up @@ -413,6 +416,9 @@ class ModelTraining extends LitElement {
type: "GET",
url: trainingStatusUrl,
contentType: "text/plain",
headers: {
"Authorization": "Bearer " + localStorage.getItem("access_token"),
},
success: function (data, textStatus, jqXHR) {
$(_this.htmlQuery("#trainingStatus")).text(data);
},
Expand All @@ -435,6 +441,9 @@ class ModelTraining extends LitElement {
$.ajax({
type: "POST",
url: trainingStatusUrl + name,
headers: {
"Authorization": "Bearer " + localStorage.getItem("access_token"),
},
data: trainingData,
contentType: "text/plain",
success: function (data, textStatus, jqXHR) {
Expand All @@ -460,6 +469,9 @@ class ModelTraining extends LitElement {
type: "GET",
url: trainingStatusUrl + name,
contentType: "text/plain",
headers: {
"Authorization": "Bearer " + localStorage.getItem("access_token"),
},
success: function (data, textStatus, jqXHR) {
$(_this.htmlQuery("#trainingStatus")).text("Data loaded.");
_this.editor.setText(data);
Expand All @@ -480,6 +492,9 @@ class ModelTraining extends LitElement {
type: "GET",
url: trainingStatusUrl + "/training/",
contentType: "application/json",
headers: {
"Authorization": "Bearer " + localStorage.getItem("access_token"),
},
success: function (data, textStatus, jqXHR) {
if (textStatus !== "success") {
return;
Expand Down

0 comments on commit af88d05

Please sign in to comment.