This repository has been archived by the owner on Jan 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add validation errors to js Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * add users scripts to javascript file Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update things, channels and groups Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update entity dependency templates Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update formatting to 2 spaces Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update js formatting Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update bootstrap Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * split javascript files Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update endpoints returns Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * add clipboard js file Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * remove unused param Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> --------- Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>
- Loading branch information
1 parent
944914b
commit 512485f
Showing
40 changed files
with
6,657 additions
and
8,904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Abstract Machines | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export function displayErrorMessage(errorMessage, divName) { | ||
const errorDiv = document.getElementById(divName); | ||
errorDiv.style.display = "block"; | ||
errorDiv.innerHTML = errorMessage; | ||
} | ||
|
||
export function removeErrorMessage(divName) { | ||
const errorDiv = document.getElementById(divName); | ||
errorDiv.style.display = "none"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) Abstract Machines | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// config parameters are: formId, url, alertDiv, modal | ||
export function submitCreateForm(config) { | ||
const form = document.getElementById(config.formId); | ||
form.addEventListener("submit", function (event) { | ||
event.preventDefault(); | ||
const formData = new FormData(form); | ||
|
||
fetch(config.url, { | ||
method: "POST", | ||
body: formData, | ||
}) | ||
.then(function (response) { | ||
switch (response.status) { | ||
case 409: | ||
showAlert("entity already exists!", config.alertDiv); | ||
break; | ||
case 400: | ||
showAlert("invalid file contents!", config.alertDiv); | ||
break; | ||
case 415: | ||
showAlert("invalid file type!", config.alertDiv); | ||
break; | ||
default: | ||
form.reset(); | ||
config.modal.hide(); | ||
window.location.reload(); | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error("error submitting form: ", error); | ||
}); | ||
}); | ||
} | ||
|
||
export function submitUpdateForm(config) { | ||
fetch(config.url, { | ||
method: "POST", | ||
body: JSON.stringify(config.data), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}).then((response) => { | ||
switch (response.status) { | ||
case 409: | ||
showAlert("entity already exists!", config.alertDiv); | ||
break; | ||
default: | ||
window.location.reload(); | ||
} | ||
}); | ||
} | ||
|
||
function showAlert(errorMessage, alertDiv) { | ||
const alert = document.getElementById(alertDiv); | ||
alert.innerHTML = ` | ||
<div class="alert alert-danger alert-dismissable fade show d-flex flex-row justify-content-between" role="alert"> | ||
<div>${errorMessage}</div> | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="close"></button> | ||
</div> `; | ||
} |
Oops, something went wrong.