Skip to content

Commit 9bb568e

Browse files
Merge branch 'release3' into task202_docker
2 parents 75cb666 + 32ea3f5 commit 9bb568e

19 files changed

Lines changed: 611 additions & 175 deletions

client/scripts/day_night_mode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function changeTheme() {
22
is_dark_theme = !is_dark_theme
3+
changeDigitsColorOnConnections()
34
const checkbox = document.getElementById("day-night-checkbox-id")
45
let root = document.documentElement.style
56
if (checkbox.checked) {

client/scripts/requests.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ async function deleteConnection(sending_object) {
127127
function uploadRequest() {
128128
if (data_upload.files.length == 0) return
129129
const file = data_upload.files[0]
130+
const button_wrapper = document.getElementById("train-button")
131+
const train_button = button_wrapper.children[0]
130132

131133
fetch(`http://${py_server_address}/${user_id}/${model_id}`, {
132134
method: "PATCH",
@@ -142,6 +144,8 @@ function uploadRequest() {
142144
timer: 1500,
143145
})
144146
console.error(`Failed to upload data for ${file.name}`)
147+
button_wrapper.setAttribute("disabled", true)
148+
train_button.setAttribute("disabled", true)
145149
return
146150
}
147151
Swal.fire({
@@ -151,29 +155,31 @@ function uploadRequest() {
151155
showConfirmButton: false,
152156
timer: 1500,
153157
})
158+
// allow user to press a train button from now on
159+
button_wrapper.removeAttribute("disabled")
160+
train_button.removeAttribute("disabled")
154161
})
155162
setModelView("irrelevant")
156-
// allow user to press a train button from now on
157-
button_wrapper = document.getElementById("train-button")
158-
button_wrapper.getElementsByTy
159-
train_button = button_wrapper.children[0]
160-
button_wrapper.removeAttribute("disabled")
161-
train_button.removeAttribute("disabled")
162163
}
163164

164165
function trainRequest() {
165166
fetch(`http://${py_server_address}/train/${user_id}/${model_id}/0`, {
166167
method: "PUT",
167168
mode: "cors",
168-
}).then(response => {
169-
showBuildNotification(response.ok)
170-
onTrainShowPredict(response.ok)
171-
if (response.ok) {
172-
setModelView("success")
173-
} else {
174-
setModelView("error")
175-
}
176169
})
170+
.then(response => {
171+
showBuildNotification(response.ok, response)
172+
onTrainShowPredict(response.ok)
173+
if (response.ok) {
174+
setModelView("success")
175+
} else {
176+
setModelView("error")
177+
}
178+
})
179+
.catch(reason => {
180+
showBuildNotification(false)
181+
setModelView("error")
182+
})
177183
}
178184

179185
async function predictRequest() {
@@ -219,5 +225,8 @@ async function predictRequest() {
219225
return
220226
}
221227
hideResult() // hide previous predict result
222-
onPredictShowResult(responseJson)
228+
const extension = file.name.split(".").pop()
229+
if (extension == "png")
230+
onPredictShowResult(responseJson == 0 ? "It's a cat!" : "It's a dog!")
231+
else onPredictShowResult(responseJson)
223232
}

0 commit comments

Comments
 (0)