From f27e25c199c3c5c9433463732b776ae9b4357cf8 Mon Sep 17 00:00:00 2001 From: Sawyer Bergeron Date: Fri, 14 Dec 2018 16:05:47 -0500 Subject: Implement Segmented Workflows A major source of bugs has been how we've approached inlining workflows. We no longer inline them as of this commit, and instead use a stack structure. This commits the result of workflows to the database before other workflows try to read them, so we don't have to maintain a code path for when something is or isn't committed to db. This patchset allows for workflows to pass limited information to preset selections Change-Id: I3d040c7f3024c7420017ae4ec66a23219303dcb6 Signed-off-by: Sawyer Bergeron --- src/templates/booking/steps/booking_meta.html | 1 - .../dashboard/searchable_select_multiple.html | 6 ++ src/templates/workflow/confirm.html | 4 +- src/templates/workflow/exit_redirect.html | 6 ++ src/templates/workflow/no_workflow.html | 10 +- src/templates/workflow/viewport-base.html | 119 +++++++++------------ 6 files changed, 70 insertions(+), 76 deletions(-) create mode 100644 src/templates/workflow/exit_redirect.html (limited to 'src/templates') diff --git a/src/templates/booking/steps/booking_meta.html b/src/templates/booking/steps/booking_meta.html index a42e158..e4881ae 100644 --- a/src/templates/booking/steps/booking_meta.html +++ b/src/templates/booking/steps/booking_meta.html @@ -58,7 +58,6 @@ {% block onleave %} var ajaxForm = $("#booking_meta_form"); var formData = ajaxForm.serialize(); -console.log(formData); req = new XMLHttpRequest(); req.open("POST", "/wf/workflow/", false); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); diff --git a/src/templates/dashboard/searchable_select_multiple.html b/src/templates/dashboard/searchable_select_multiple.html index e7128b0..ee460dd 100644 --- a/src/templates/dashboard/searchable_select_multiple.html +++ b/src/templates/dashboard/searchable_select_multiple.html @@ -1,6 +1,12 @@
+
+ {% if incompatible == "true" %} +

Warning: Incompatible Configuration

+

Please make a different selection, as the current config conflicts with the selected pod

+ {% endif %} +
diff --git a/src/templates/workflow/confirm.html b/src/templates/workflow/confirm.html index 4f2616e..277c305 100644 --- a/src/templates/workflow/confirm.html +++ b/src/templates/workflow/confirm.html @@ -66,7 +66,9 @@ req.open("POST", "/wf/workflow/finish/", false); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.onerror = function() { alert("problem with cleaning up session"); } - req.onreadystatechange = function() { if(req.readyState === 4 ) { parent.redirect_root(); } } + req.onreadystatechange = function() { if(req.readyState === 4 ) { + window.top.refresh_iframe(); + }} req.send(formData); } diff --git a/src/templates/workflow/exit_redirect.html b/src/templates/workflow/exit_redirect.html new file mode 100644 index 0000000..b08df78 --- /dev/null +++ b/src/templates/workflow/exit_redirect.html @@ -0,0 +1,6 @@ + + + + diff --git a/src/templates/workflow/no_workflow.html b/src/templates/workflow/no_workflow.html index ff8aab3..0ac6549 100644 --- a/src/templates/workflow/no_workflow.html +++ b/src/templates/workflow/no_workflow.html @@ -1,7 +1,3 @@ -{% extends "base.html" %} -{% load staticfiles %} - -{% block content %} -

If you would like to create a booking or a resource, please use the links on the sidebar or from the homepage

-Go Home -{% endblock content %} + diff --git a/src/templates/workflow/viewport-base.html b/src/templates/workflow/viewport-base.html index 37eff27..82c1324 100644 --- a/src/templates/workflow/viewport-base.html +++ b/src/templates/workflow/viewport-base.html @@ -71,7 +71,7 @@ .step_untouched { - background: #98B0AF; + background: #DDDDDD; } .step_invalid @@ -96,10 +96,12 @@
- +
- {% csrf_token %} @@ -206,6 +208,14 @@ { context_data = data; update_breadcrumbs(data); + if(data["workflow_count"] == 1) + { + document.getElementById("cancel_btn").innerText = "Exit Workflow"; + } + else + { + document.getElementById("cancel_btn").innerText = "Return to Parent"; + } } function update_breadcrumbs(meta_json) { @@ -240,60 +250,16 @@ while(container.firstChild){ container.removeChild(container.firstChild); } - //draw enough rows for all steps - var depth = meta_json['max_depth']; - for(var i=0; i<=depth; i++){ - var div = document.createElement("DIV"); - div.id = "row"+i; - if(i0){ - div.style['margin-top'] = "7px"; - } - container.appendChild(div); - } + draw_steps(meta_json); } function draw_steps(meta_json){ - var all_relations = meta_json['relations']; - var relations = []; - var active_steps = []; - var active_step = step; - while(active_step < meta_json['steps'].length){ - active_steps.push(active_step); - var index = meta_json['parents'][active_step]; - var relation = all_relations[index]; - relations.push(relation); - active_step = relation['parent']; - } - var child_index = meta_json['children'][step]; - var my_children = all_relations[child_index]; - if(my_children){ - relations.push(my_children); - } - draw_relations(relations, meta_json, active_steps); - } - - function draw_relations(relations, meta_json, active_steps){ - for(var i=0; i -1; - var step_button = create_step(meta_json['steps'][relation['children'][j]], active); - children_container.appendChild(step_button); - } - var parent_div = document.getElementById("row" + relation['depth']); - parent_div.appendChild(children_container); + for( var i = 0; i < meta_json["steps"].length; i++ ) + { + meta_json["steps"][i]["index"] = i; + var step_btn = create_step(meta_json["steps"][i], i == meta_json["active"]); + document.getElementById("breadcrumbs").appendChild(step_btn); } } @@ -301,7 +267,6 @@ var step_dom = document.createElement("DIV"); if(active){ step_dom.className = "step_active"; - console.log(step_json['message']); } else{ step_dom.className = "step"; @@ -333,30 +298,45 @@ { update_message(msg, stat); } + step_dom.classList.add("btn"); var step_number = step_json['index']; step_dom.onclick = function(){ go(step_number); } - //TODO: background color and other style return step_dom; } function cancel_wf(){ - $.ajax({ - type: "POST", - url: "/wf/manager/", - data: {"cancel":"",}, - beforeSend: function(request) { - request.setRequestHeader("X-CSRFToken", - $('input[name="csrfmiddlewaretoken"]').val() - ); - }, - success: redirect_root() - }); + var form = $("#workflow_pop_form"); + var formData = form.serialize(); + var req = new XMLHttpRequest(); + req.open("POST", "/wf/workflow/finish/", false); + req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + req.onerror = function() { alert("problem occurred while trying to cancel current workflow"); } + req.onreadystatechange = function() { if(req.readyState === 4){ + refresh_iframe(); + }}; + req.send(formData); + } + + function refresh_iframe() { + req = new XMLHttpRequest(); + url = "/wf/workflow/"; + req.open("GET", url, true); + req.onload = function(e) { + var doc = document.getElementById("viewport-iframe").contentWindow.document; + doc.open(); doc.write(this.responseText); doc.close(); + } + req.send(); + } + + function write_iframe(contents) + { + document.getElementById("viewport-iframe").contentWindow.document.innerHTML= contents; } function redirect_root() { - window.location.replace('/'); + window.location.replace('/wf/'); } function add_wf(type){ @@ -448,6 +428,11 @@
+ {% endblock content %} -- cgit 1.2.3-korg