Added error messages
This commit is contained in:
@@ -31,14 +31,18 @@ commit.ondblclick = async function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
alert(`Add unsuccessful. ${response.status}`);
|
||||||
throw new Error(`Response status: ${response.status}`);
|
throw new Error(`Response status: ${response.status}`);
|
||||||
} else {
|
} else {
|
||||||
this.style.backgroundColor = "blue";
|
this.style.backgroundColor = "blue";
|
||||||
window.location.href = "/app";
|
window.location.href = "/app";
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
alert(`Add unsuccessful. ${error.message}`);
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
alert("Sensor name can't be null.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ setEventListeners(remove, async () => {
|
|||||||
method: "DELETE"
|
method: "DELETE"
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
alert(`Remove unsuccessful. ${response.status}`);
|
||||||
throw new Error(`Response status: ${response.status}`);
|
throw new Error(`Response status: ${response.status}`);
|
||||||
} else {
|
} else {
|
||||||
window.location.href = "/app";
|
window.location.href = "/app";
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
alert(`Remove unsuccessful. ${error.message}`);
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -56,13 +58,17 @@ setEventListeners(commit, async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
alert(`Edit unsuccessful. ${response.status}`);
|
||||||
throw new Error(`Response status: ${response.status}`);
|
throw new Error(`Response status: ${response.status}`);
|
||||||
} else {
|
} else {
|
||||||
window.location.href = "/app";
|
window.location.href = "/app";
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
alert(`Edit unsuccessful. ${error.message}`);
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
alert("Nothing to commit.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,11 @@ setEventListeners(upload, async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
location.reload();
|
if (!response.ok) {
|
||||||
|
alert(`Upload unsuccessful. ${response.status}`);
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const onSelectFile = () => upload(input.files[0]);
|
const onSelectFile = () => upload(input.files[0]);
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ setEventListeners(upload, async () => {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
location.reload();
|
if (!response.ok) {
|
||||||
|
alert(`Upload unsuccessful. ${response.status}`);
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const onSelectFile = () => upload(input.files[0]);
|
const onSelectFile = () => upload(input.files[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user