From 4ecf03b0a8517a8323dd888fc74e371aab41ba67 Mon Sep 17 00:00:00 2001 From: Justin Choquette Date: Fri, 18 Aug 2023 15:50:38 -0400 Subject: minor status changes Change-Id: Ia29c2879ddea67bdb6b30c4e871d8cb97be38d41 Signed-off-by: Justin Choquette --- src/api/views.py | 2 +- src/booking/views.py | 2 +- src/static/js/workflows/book-a-pod.js | 32 ++---- src/static/js/workflows/design-a-pod.js | 42 ++++--- src/static/js/workflows/workflow.js | 41 ++----- src/templates/base/booking/booking_detail.html | 146 ++++++++++++++++++++----- src/templates/base/dashboard/lab_detail.html | 6 +- src/templates/base/dashboard/landing.html | 10 +- src/templates/base/workflow/book_a_pod.html | 18 ++- src/templates/base/workflow/design_a_pod.html | 28 +++-- 10 files changed, 199 insertions(+), 128 deletions(-) diff --git a/src/api/views.py b/src/api/views.py index dbe00e8..fab78ee 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -575,7 +575,7 @@ def get_booking_status(bookingObject): return json.loads(response.content) except: print("failed to get status") - return [] + return {} def liblaas_end_booking(aggregateId): liblaas_url = liblaas_base_url + "booking/" + str(aggregateId) + "/end" diff --git a/src/booking/views.py b/src/booking/views.py index 25cac43..c99e2c2 100644 --- a/src/booking/views.py +++ b/src/booking/views.py @@ -87,7 +87,7 @@ def booking_detail_view(request, booking_id): context = { 'title': 'Booking Details', 'booking': booking, - 'statuses': statuses, + 'status': statuses, 'collab_string': ', '.join(map(str, booking.collaborators.all())) } diff --git a/src/static/js/workflows/book-a-pod.js b/src/static/js/workflows/book-a-pod.js index ddea556..2396fdb 100644 --- a/src/static/js/workflows/book-a-pod.js +++ b/src/static/js/workflows/book-a-pod.js @@ -64,7 +64,7 @@ const steps = { } onclickSelectTemplate(templateCard, templateId) { - this.step = steps.SELECT_TEMPLATE + this.goTo(steps.SELECT_TEMPLATE) const oldHighlight = document.querySelector("#default_templates_list .selected_node") if (oldHighlight) { GUI.unhighlightCard(oldHighlight) @@ -90,12 +90,6 @@ const steps = { return[passed, message] } - if (!(project.match(/^[a-z0-9~@#$^*()_+=[\]{}|,.?': -]+$/i))) { - passed = false; - message = "Project field contains invalid characters" - return[passed, message] - } - return [passed, message] } @@ -109,12 +103,6 @@ const steps = { return[passed, message] } - if (!(purpose.match(/^[a-z0-9~@#$^*()_+=[\]{}|,.?': -]+$/i))) { - passed = false; - message = "Purpose field contains invalid characters" - return[passed, message] - } - return [passed, message] } @@ -129,7 +117,7 @@ const steps = { } onFocusInCIFile() { - this.step = steps.CLOUD_INIT + workflow.goTo(steps.CLOUD_INIT) const ci_textarea = document.getElementById('ci-textarea') GUI.unhighlightError(ci_textarea) } @@ -148,7 +136,7 @@ const steps = { } onFocusInPurpose() { - this.step = steps.BOOKING_DETAILS + workflow.goTo(steps.BOOKING_DETAILS) const input = document.getElementById('input_purpose'); GUI.hideDetailsError() GUI.unhighlightError(input) @@ -168,14 +156,14 @@ const steps = { } onFocusInProject() { - this.step = steps.BOOKING_DETAILS + workflow.goTo(steps.BOOKING_DETAILS) const input = document.getElementById('input_project'); GUI.hideDetailsError() GUI.unhighlightError(input) } onchangeDays() { - this.step = steps.BOOKING_DETAILS + workflow.goTo(steps.BOOKING_DETAILS) const counter = document.getElementById("booking_details_day_counter") const input = document.getElementById('input_length') workflow.bookingBlob.metadata.length = input.value @@ -184,8 +172,7 @@ const steps = { } add_collaborator(username) { - this.step = steps.ADD_COLLABS; - + workflow.goTo(steps.ADD_COLLABS) for (const c of this.bookingBlob.allowed_users) { if (c == username) { return; @@ -198,8 +185,7 @@ const steps = { remove_collaborator(username) { // Removes collab from collaborators list and updates summary - this.step = steps.ADD_COLLABS - + this.goTo(steps.ADD_COLLABS) const temp = []; for (const c of this.bookingBlob.allowed_users) { @@ -340,9 +326,9 @@ class GUI { let disabled = !isAvailable ? 'disabled = "true"' : ''; const col = document.createElement('div'); - col.classList.add('col-3', 'my-1'); + col.classList.add('col-12', 'col-md-6', 'col-xl-3', 'my-3', 'd-flex', 'flex-grow-1'); col.innerHTML= ` -
+

` + templateBlob.pod_name + `

diff --git a/src/static/js/workflows/design-a-pod.js b/src/static/js/workflows/design-a-pod.js index 2083f7d..efec093 100644 --- a/src/static/js/workflows/design-a-pod.js +++ b/src/static/js/workflows/design-a-pod.js @@ -68,7 +68,7 @@ class DesignWorkflow extends Workflow { /** Takes an HTML element */ async onclickSelectLab(lab_card) { - this.step = steps.SELECT_LAB; + this.goTo(steps.SELECT_LAB) if (this.templateBlob.lab_name == null) { // Lab has not been selected yet this.templateBlob.lab_name = lab_card.id; @@ -106,7 +106,7 @@ class DesignWorkflow extends Workflow { // Generate template cards // Show modal - this.step = steps.ADD_RESOURCES; + this.goTo(steps.ADD_RESOURCES) if (this.templateBlob.lab_name == null) { showError("Please select a lab before adding resources.", steps.SELECT_LAB); @@ -269,7 +269,7 @@ class DesignWorkflow extends Workflow { * @param {String} hostname */ onclickDeleteHost(hostname) { - this.step = steps.ADD_RESOURCES; + this.goTo(steps.ADD_RESOURCES); for (let existing_host of this.templateBlob.host_list) { if (hostname == existing_host.hostname) { this.removeHostFromTemplateBlob(existing_host); @@ -294,8 +294,7 @@ class DesignWorkflow extends Workflow { // Prerequisite step checks // GUI stuff - this.step = steps.ADD_NETWORKS; - + this.goTo(steps.ADD_NETWORKS) if (this.templateBlob.lab_name == null) { showError("Please select a lab before adding networks.", steps.SELECT_LAB); return; @@ -311,7 +310,7 @@ class DesignWorkflow extends Workflow { /** onclick handler for the adding_network_confirm button */ onclickConfirmNetwork() { - this.step = steps.ADD_NETWORKS; + this.goTo(steps.ADD_NETWORKS) // Add the network // call the GUI to make the card (refresh the whole view to make it easier) @@ -364,7 +363,7 @@ class DesignWorkflow extends Workflow { * Takes a network name as a parameter. */ onclickDeleteNetwork(network_name) { - this.step = steps.ADD_NETWORKS; + this.goTo(steps.ADD_NETWORKS) for (let existing_network of this.templateBlob.networks) { if (network_name == existing_network.name) { @@ -402,7 +401,7 @@ class DesignWorkflow extends Workflow { } onclickConfigureConnection(hostname) { - this.step = steps.CONFIGURE_CONNECTIONS; + this.goTo(steps.CONFIGURE_CONNECTIONS) const host = this.templateBlob.findHost(hostname); if (!host) { @@ -450,7 +449,7 @@ class DesignWorkflow extends Workflow { }); pod_name_input.addEventListener('focusin', (event)=> { - this.step = steps.POD_DETAILS; + this.goTo(steps.POD_DETAILS) GUI.unhighlightError(pod_name_input); GUI.hidePodDetailsError(); }); @@ -460,7 +459,7 @@ class DesignWorkflow extends Workflow { }); pod_desc_input.addEventListener('focusin', (event)=> { - this.step = steps.POD_DETAILS; + this.goTo(steps.POD_DETAILS) GUI.unhighlightError(pod_desc_input); GUI.hidePodDetailsError(); }); @@ -515,9 +514,6 @@ class DesignWorkflow extends Workflow { else if (input.length > maxCharCount) { message = form_name + ' cannot exceed ' + maxCharCount + ' characters.'; result = false; - } else if (!(input.match(/^[a-z0-9~@#$^*()_+=[\]{}|,.?': -!]+$/i))) { - message = form_name + ' contains invalid characters.'; - result = false; } return [result, message] @@ -557,7 +553,7 @@ class DesignWorkflow extends Workflow { } async onclickSubmitTemplate() { - this.step = steps.POD_SUMMARY; + this.goTo(steps.POD_SUMMARY) const simpleValidation = this.simpleStepValidation(); if (!simpleValidation[0]) { showError(simpleValidation[1], simpleValidation[2]) @@ -632,8 +628,10 @@ class GUI { */ static refreshAddHostModal(template_list, flavor_map) { document.getElementById('add_resource_modal_body').innerHTML = ` -

Resource

-
+

Select a resource, then configure the image, hostname and cloud-init (optional).

+

For multi-node resources, select a tab to modify each individual node.

+

Resource*

+
@@ -642,11 +640,11 @@ class GUI { -
+ + +
diff --git a/src/templates/base/dashboard/landing.html b/src/templates/base/dashboard/landing.html index 960ad39..7f97e4f 100644 --- a/src/templates/base/dashboard/landing.html +++ b/src/templates/base/dashboard/landing.html @@ -49,13 +49,15 @@ {% endif %} {% else %} {% block btnGrp %} -

To get started, book a server below:

- - Book a Pod - +

Select 'Design a Pod' to create a custom resource group.

+

Select 'Book a Pod' to reserve a custom pod or a single resource.

Design a Pod + + Book a Pod + + {% endblock btnGrp %} {% endif %}
diff --git a/src/templates/base/workflow/book_a_pod.html b/src/templates/base/workflow/book_a_pod.html index 8a0fb47..5c1a253 100644 --- a/src/templates/base/workflow/book_a_pod.html +++ b/src/templates/base/workflow/book_a_pod.html @@ -10,7 +10,7 @@
@@ -25,21 +25,14 @@

Book a Pod

Select Host Or Template*

-
- -
- -
-
    -
-
- +

Select the resource bundle that you would like to reserve. Then use the navigation arrows or scroll to advance the workflow. Configure your own resource here.

+
-

Global Cloud Init Override

+

Add a custom cloud init configuration to apply to all hosts in your booking (optional).

@@ -47,6 +40,7 @@

Booking Details*

+

Enter the project and purpose for your booking, as well as the duration (up to 21 days).

@@ -67,6 +61,7 @@

Add Collaborators:

+

Give SSH and booking overview access to other users. Collaborators must mark their profiles as public and have a linked IPA account.

{% bootstrap_field form.users label="Collaborators" %} @@ -76,6 +71,7 @@

Booking Summary

+

Review your booking information and click 'Book' to reserve your resources.

    diff --git a/src/templates/base/workflow/design_a_pod.html b/src/templates/base/workflow/design_a_pod.html index 32bd332..c23e5a8 100644 --- a/src/templates/base/workflow/design_a_pod.html +++ b/src/templates/base/workflow/design_a_pod.html @@ -14,7 +14,7 @@
    @@ -30,7 +30,8 @@
    -

    Design a Pod

    +

    Design a Pod

    +

    To get started, select a lab. Then use the navigation arrows or scroll to advance through the workflow.

    Select a Lab*

    @@ -39,6 +40,7 @@

    Add Resources*

    +

    Add up to 8 configurable resources to your pod, then use the navigation arrows to proceed to the next step.

    @@ -52,6 +54,7 @@

    Add Networks*

    +

    Define networks to use in your pod. A network may be set as public or private.

    @@ -65,6 +68,7 @@

    Configure Connections*

    +

    Configure the connections for each host in your pod to your defined networks.

    @@ -72,6 +76,7 @@

    Pod Details*

    +

    Add a pod name and description to refer to later.

    @@ -102,7 +107,8 @@
    -

    Pod Summary:

    +

    Pod Summary

    +

    Confirm the specifications below, and select 'create' to save this pod. Otherwise, navigate upwards and modify it as needed.

    @@ -143,8 +149,10 @@
-

Image

+

Image*

-

Hostname

+

Hostname*

Cloud Init

@@ -184,6 +192,12 @@
+
    +
  • Select an interface and a frame type to add a connection to a network.
  • +
  • An interface may send tagged or untagged frames on a single network, but not both.
  • +
  • Each interface may only be untagged on one network.
  • +
  • Reselect a connection to remove it.
  • +