diff options
Diffstat (limited to 'src/static/js')
-rw-r--r-- | src/static/js/workflows/book-a-pod.js | 35 | ||||
-rw-r--r-- | src/static/js/workflows/design-a-pod.js | 59 | ||||
-rw-r--r-- | src/static/js/workflows/workflow.js | 9 |
3 files changed, 57 insertions, 46 deletions
diff --git a/src/static/js/workflows/book-a-pod.js b/src/static/js/workflows/book-a-pod.js index d573342..3f83849 100644 --- a/src/static/js/workflows/book-a-pod.js +++ b/src/static/js/workflows/book-a-pod.js @@ -71,7 +71,7 @@ const steps = { } isValidCIFile(ci_file) { - // todo + // todo return true; } @@ -232,34 +232,37 @@ const steps = { return[passed, message, section]; } - onclickCancel() { - if (confirm("Are you sure you wish to discard this booking?")) { - location.reload(); - } - } + // onclickCancel() { + // if (confirm("Are you sure you wish to discard this booking?")) { + // location.reload(); + // } + // } /** Async / await is more infectious than I thought, so all functions that rely on an API call will need to be async */ async onclickConfirm() { const complete = this.isCompleteBookingInfo(); if (!complete[0]) { - alert(complete[1]); + showError(complete[1]); this.step = complete[2] document.getElementById(this.sections[complete[2]]).scrollIntoView({behavior: 'smooth'}); return } - if (confirm("Are you sure you would like to create this booking?")) { - const response = await LibLaaSAPI.makeBooking(this.bookingBlob); - if (response.bookingId) { - alert("The booking has been successfully created.") - window.location.href = "../../"; + + const response = await LibLaaSAPI.makeBooking(this.bookingBlob); + if (response.bookingId) { + showError("The booking has been successfully created.") + window.location.href = "../../"; + } else { + if (response.status == 406) { + showError("One or more collaborators is missing SSH keys or has not configured their IPA account.") } else { - alert("The booking could not be created at this time.") + showError("The booking could not be created at this time.") } } - } - - + // if (confirm("Are you sure you would like to create this booking?")) { + // } + } } diff --git a/src/static/js/workflows/design-a-pod.js b/src/static/js/workflows/design-a-pod.js index 7632537..58f8b85 100644 --- a/src/static/js/workflows/design-a-pod.js +++ b/src/static/js/workflows/design-a-pod.js @@ -110,13 +110,13 @@ class DesignWorkflow extends Workflow { this.step = steps.ADD_RESOURCES; if (this.templateBlob.lab_name == null) { - alert("Please select a lab before adding resources."); + showError("Please select a lab before adding resources."); this.goTo(steps.SELECT_LAB); return; } if (this.templateBlob.host_list.length >= 8) { - alert("You may not add more than 8 hosts to a single pod.") + showError("You may not add more than 8 hosts to a single pod.") return; } @@ -282,7 +282,7 @@ class DesignWorkflow extends Workflow { } } - alert("didnt remove"); + showError("didnt remove"); } @@ -297,13 +297,13 @@ class DesignWorkflow extends Workflow { this.step = steps.ADD_NETWORKS; if (this.templateBlob.lab_name == null) { - alert("Please select a lab before adding networks."); + showError("Please select a lab before adding networks."); this.goTo(steps.SELECT_LAB); return; } if (document.querySelector('#new_network_card') != null) { - alert("Please finish adding the current network before adding a new one."); + showError("Please finish adding the current network before adding a new one."); return; } @@ -377,7 +377,7 @@ class DesignWorkflow extends Workflow { } } - alert("didnt remove"); + showError("didnt remove"); } /** Rebuilds the list without the chosen template */ @@ -407,7 +407,7 @@ class DesignWorkflow extends Workflow { const host = this.templateBlob.findHost(hostname); if (!host) { - alert("host not found error"); + showError("host not found error"); } this.connectionTemp = new ConnectionTemp(host, this.templateBlob.networks, this.labFlavors.get(host.flavor).interfaces); @@ -440,11 +440,11 @@ class DesignWorkflow extends Workflow { setPodDetailEventListeners() { const pod_name_input = document.getElementById("pod-name-input"); const pod_desc_input = document.getElementById("pod-desc-input"); - const pod_public_input = document.getElementById("pod-public-input"); + // const pod_public_input = document.getElementById("pod-public-input"); pod_name_input.value = ""; pod_desc_input.value = ""; - pod_public_input.checked = false; + // pod_public_input.checked = false; pod_name_input.addEventListener('focusout', (event)=> { workflow.onFocusOutPodNameInput(pod_name_input); @@ -466,10 +466,10 @@ class DesignWorkflow extends Workflow { GUI.hidePodDetailsError(); }); - pod_public_input.addEventListener('focusout', (event)=> { - this.step = steps.POD_DETAILS; - workflow.onFocusOutPodPublicInput(pod_public_input); - }); + // pod_public_input.addEventListener('focusout', (event)=> { + // this.step = steps.POD_DETAILS; + // workflow.onFocusOutPodPublicInput(pod_public_input); + // }); } onFocusOutPodNameInput(element) { @@ -524,13 +524,13 @@ class DesignWorkflow extends Workflow { return [result, message] } - async onclickDiscardTemplate() { - this.step = steps.POD_SUMMARY; - if(confirm('Are you sure you wish to delete this Pod?')) { - await LibLaaSAPI.deleteTemplate(this.templateBlob); - location.reload(); - } - } + // async onclickDiscardTemplate() { + // this.step = steps.POD_SUMMARY; + // if(confirm('Are you sure you wish to delete this Pod?')) { + // await LibLaaSAPI.deleteTemplate(this.templateBlob); + // location.reload(); + // } + // } simpleStepValidation() { let passed = true; @@ -561,20 +561,21 @@ class DesignWorkflow extends Workflow { this.step = steps.POD_SUMMARY; const simpleValidation = this.simpleStepValidation(); if (!simpleValidation[0]) { - alert(simpleValidation[1]) + showError(simpleValidation[1]) this.goTo(simpleValidation[2]); return; } // todo - make sure each host has at least one connection on any network. - if (confirm("Are you sure you wish to create this pod?")) { - let success = await LibLaaSAPI.makeTemplate(this.templateBlob); - if (success) { - window.location.href = "../../accounts/my/resources/"; - } else { - alert("Could not create template.") - } + // if (confirm("Are you sure you wish to create this pod?")) { + + // } + let success = await LibLaaSAPI.makeTemplate(this.templateBlob); + if (success) { + window.location.href = "../../accounts/my/resources/"; + } else { + showError("Could not create template.") } } } @@ -1182,5 +1183,5 @@ class ConnectionTemp { } function todo() { - alert('todo'); + showError('todo'); }
\ No newline at end of file diff --git a/src/static/js/workflows/workflow.js b/src/static/js/workflows/workflow.js index 745a706..f3f39e9 100644 --- a/src/static/js/workflows/workflow.js +++ b/src/static/js/workflows/workflow.js @@ -242,5 +242,12 @@ class Workflow { } function apiError(info) { - alert("Unable to fetch " + info +". Please try again later or contact support.") + showError("Unable to fetch " + info +". Please try again later or contact support.") } + +function showError(message) { + const text = document.getElementById('alert_modal_message'); + + text.innerText = message; + $("#alert_modal").modal('show'); +} |