Skip to content

Commit

Permalink
Update the PATh Application Questions
Browse files Browse the repository at this point in the history
  • Loading branch information
CannonLock committed Nov 8, 2022
1 parent eb478f4 commit 00a4650
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 34 deletions.
9 changes: 9 additions & 0 deletions portal/static/js/pages/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ let form = document.getElementById("consultation-form")

submitButton.addEventListener("click", (e) => submitForm(e, form, "/api/v1/freshdesk/ticket", callback))

let statusSelect = document.getElementById("status")
statusSelect.addEventListener("change", (e) => {
if(e.target.value == "awarded"){
document.getElementById("questions-for-the-awarded").hidden = false
} else {
document.getElementById("questions-for-the-awarded").hidden = true
}
})

let callback = (submissionSuccess, json) => {
if(submissionSuccess){
submissionSuccessCallback(json)
Expand Down
24 changes: 17 additions & 7 deletions portal/static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let validateForm = (form) => {

// Check that all input validity
for (const el of form.querySelectorAll("[required]")) {
if (!el.reportValidity()) {
if (isVisible(el) && !el.reportValidity()) {
errorNode.textContent = "Please fill out all elements in the form, if not applicable you can write 'NA'.";
errorNode.hidden = false;
return false;
Expand Down Expand Up @@ -82,25 +82,35 @@ let getFormData = (form) => {
const formDataAndDefaults = defaults.concat(Array.from(formData)) // Order important, defaults should be overwritten

let namesAndInputs = formDataAndDefaults.reduce((currentValue,[name, value]) => {
let component = {
currentValue[name] = {
name: name,
value: value
}

if(document.getElementById(name)){
component["label"] = document.getElementById(name).labels[0].textContent.trim()
}
let element = document.getElementById(name)

currentValue[name] = component
if(isVisible(element)){
currentValue[name]["label"] = document.getElementById(name).labels[0].textContent.trim()
}

return currentValue
}, {})

// Convert 'off' and 'on' check values to bools
Object.keys(namesAndInputs).forEach((k,i) => {
if(['off', 'on'].includes(namesAndInputs[k].value)){
namesAndInputs[k].value = namesAndInputs[k].value === "off" ? "False" : "True";
}
})

return namesAndInputs
}
}

let isVisible = (htmlElement) => {
try {
return htmlElement.offsetParent !== null
} catch (e) {
console.error(e)
return false
}
}
62 changes: 35 additions & 27 deletions portal/website/templates/application.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,40 @@
<div class="container-xxl py-4">
<div class="row justify-content-center">
<div class="col-12 col-xl-7 col-lg-8 col-md-10">
<h1>PATh User Application</h1>
<h1>PATh Facility User Application</h1>
<p>
On filling out the form below you will be emailed with a ticket # and link so that
we can follow up with you and a schedule consultation.
Please fill out the form below if you would like to begin using PATh Facility compute resources.
Once this form is complete, a Research Computing Facilitator will contact you within one business
day with next steps. Research Computing Facilitators are here to provide you with information on
submitting a PATh Facility credit allocation request to the National Science Foundation (NSF)
and assist you with using your credit allocations on PATh Facility resources.
</p>
<p>
On filling out the form below you will be emailed with a ticket number and link so that we can
follow up with you and a schedule consultation.
</p>
<p>
We are excited to meet with you and look forward to helping you scale up your research!
</p>
<h2>Request Form</h2>
<form id="consultation-form" name="consultation-form" method="post" action="">
<div>
<label for="status" class="form-label">Credit Allocation Status</label>
<select id="status" name="status" class="form-select" required>
<option selected disabled value="">-- Select a Researcher Application Status --</option>
<option value="awarded">I have been awarded a credit allocation by the NSF</option>
<option value="submitted">I have submitted a proposal for a credit allocation</option>
<option value="assistance">I would like assistance submitting a proposal for a credit allocation</option>
</select>
</div>
<div class="pt-3">
<label for="full-name" class="form-label">Full Name</label>
<input id="full-name" name="full-name" type="text" class="form-control" placeholder="First Last" required>
</div>
<div class="pt-3">
<label for="email" class="form-label">Email</label>
<input id="email" name="email" type="email" class="form-control" placeholder="[email protected]" required>
</div>
<div class="pt-3">
<label for="affiliation" class="form-label">Affiliation with an existing user/project/group</label>
<textarea id="affiliation" name="affiliation" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<label for="institution" class="form-label">Institution</label>
<textarea id="institution" name="institution" class="form-control" rows="4" required></textarea>
Expand All @@ -41,35 +53,31 @@ <h2>Request Form</h2>
<textarea id="pi-name" name="pi-name" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<label for="access-point" class="form-label">Access Point</label>
<textarea id="access-point" name="access-point" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<label for="cpu-credits" class="form-label">CPU Credits</label>
<textarea id="cpu-credits" name="cpu-credits" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<label for="gpu-credits" class="form-label">GPU Credits</label>
<textarea id="gpu-credits" name="gpu-credits" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<label for="name-and-email-of-path-user-to-report-usage" class="form-label">Name and Email address of PATh user to email with weekly credit usage reports (Typically Principal Investigator):</label>
<textarea id="name-and-email-of-path-user-to-report-usage" name="name-and-email-of-path-user-to-report-usage" class="form-control" rows="4" required></textarea>
<label for="affiliation" class="form-label">Affiliation with an existing user/project/group</label>
<textarea id="affiliation" name="affiliation" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<label for="meet-with-rcf" class="form-label">Would you like to meet with a Research Computing Facilitator to help you get started?</label>
<textarea id="meet-with-rcf" name="meet-with-rcf" class="form-control" rows="4" required></textarea>
</div>
<div hidden id="questions-for-the-awarded">
<div class="pt-3">
<label for="cpu-credits" class="form-label">CPU Credits Awarded by NSF</label>
<textarea id="cpu-credits" name="cpu-credits" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<label for="gpu-credits" class="form-label">GPU Credits Awarded by NSF</label>
<textarea id="gpu-credits" name="gpu-credits" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<label for="name-and-email-of-path-user-to-report-usage" class="form-label">Name and Email address of PATh user to email with weekly credit usage reports (Typically Principal Investigator)</label>
<textarea id="name-and-email-of-path-user-to-report-usage" name="name-and-email-of-path-user-to-report-usage" class="form-control" rows="4" required></textarea>
</div>
</div>
<div class="pt-3">
<label for="additional-info" class="form-label">Additional Information:</label>
<textarea id="additional-info" name="additional-info" class="form-control" rows="4" required></textarea>
</div>
<div class="pt-3">
<input class="form-check-input" name="been-awarded-allocation" type="checkbox" id="been-awarded-allocation">
<label class="form-check-label" for="been-awarded-allocation">
I have been awarded a PATh Facility Allocation
</label>
</div>
<div class="h-captcha mt-3" data-sitekey="deb6e053-975d-4c72-86be-6c91fdf4babf"></div>
<div id="form-error" class="alert alert-warning py-2 my-2" role="alert" hidden></div>
<button id="submit" type="submit" name="submit" class="form-control btn btn-primary mt-2 w-auto px-3">Submit</button>
Expand Down

0 comments on commit 00a4650

Please sign in to comment.