diff options
Diffstat (limited to 'src/templates/base/account')
-rw-r--r-- | src/templates/base/account/booking_list.html | 146 | ||||
-rw-r--r-- | src/templates/base/account/configuration_list.html | 80 | ||||
-rw-r--r-- | src/templates/base/account/details.html | 9 | ||||
-rw-r--r-- | src/templates/base/account/image_list.html | 132 | ||||
-rw-r--r-- | src/templates/base/account/resource_list.html | 124 | ||||
-rw-r--r-- | src/templates/base/account/user_list.html | 55 | ||||
-rw-r--r-- | src/templates/base/account/userprofile_update_form.html | 31 |
7 files changed, 577 insertions, 0 deletions
diff --git a/src/templates/base/account/booking_list.html b/src/templates/base/account/booking_list.html new file mode 100644 index 0000000..f9234bc --- /dev/null +++ b/src/templates/base/account/booking_list.html @@ -0,0 +1,146 @@ +{% extends "base.html" %} +{% block content %} +<h2>Bookings I Own</h2> +<div class="row"> + {% for booking in bookings %} + <div class="col-12 col-md-6 col-lg-4 col-xl-3 mb-3"> + <div class="card h-100"> + <div class="card-header"> + <h3>Booking {{booking.id}}</h3> + </div> + <ul class="list-group list-group-flush h-100"> + <li class="list-group-item">id: {{booking.id}}</li> + <li class="list-group-item">lab: {{booking.lab}}</li> + <li class="list-group-item">resource: {{booking.resource.template.name}}</li> + <li class="list-group-item">start: {{booking.start}}</li> + <li class="list-group-item">end: {{booking.end}}</li> + <li class="list-group-item">purpose: {{booking.purpose}}</li> + </ul> + <div class="card-footer d-flex"> + <a class="btn btn-primary ml-auto mr-2" href="/booking/detail/{{booking.id}}/">Details</a> + <button + class="btn btn-danger" + onclick='cancel_booking({{booking.id}});' + data-toggle="modal" + data-target="#resModal" + >Cancel</button> + </div> + </div> + </div> + {% empty %} + <div class="col"> + <p>You don't have any bookings. You can create a booking by booking a pod.</p> + </div> + {% endfor %} +</div> + +<h2>Bookings I Collaborate On</h2> +<div class="row"> + + {% for booking in collab_bookings %} + <div class="col-12 col-md-6 col-lg-4 col-xl-3 mb-3"> + <div class="card h-100"> + <div class="card-header"> + <h3>Booking {{booking.id}}</h3> + </div> + <ul class="list-group list-group-flush h-100"> + <li class="list-group-item">id: {{booking.id}}</li> + <li class="list-group-item">lab: {{booking.lab}}</li> + <li class="list-group-item">resource: {{booking.resource.template.name}}</li> + <li class="list-group-item">start: {{booking.start}}</li> + <li class="list-group-item">end: {{booking.end}}</li> + <li class="list-group-item">purpose: {{booking.purpose}}</li> + </ul> + <div class="card-footer d-flex"> + <a class="btn btn-primary ml-auto" href="/booking/detail/{{booking.id}}/">Details</a> + </div> + </div> + </div> + {% empty %} + <div class="col"> + <p>There are no collaborative bookings.</p> + </div> + {% endfor %} +</div> + +<a href="#expired_bookings" data-toggle="collapse" class="h2 discrete-a"> + Expired Bookings + <i class="fas fa-angle-down rotate"></i> +</a> +<div id="expired_bookings" class="row collapse"> + {% for booking in expired_bookings %} + <div class="col-12 col-md-6 col-lg-4 col-xl-3 mb-3"> + <div class="card h-100"> + <div class="card-header"> + <h3>Booking {{booking.id}}</h3> + </div> + <ul class="list-group list-group-flush h-100"> + <li class="list-group-item">id: {{booking.id}}</li> + <li class="list-group-item">lab: {{booking.lab}}</li> + <li class="list-group-item">resource: {{booking.resource.template.name}}</li> + <li class="list-group-item">start: {{booking.start}}</li> + <li class="list-group-item">end: {{booking.end}}</li> + <li class="list-group-item">purpose: {{booking.purpose}}</li> + <li class="list-group-item">owner: {{booking.owner.userprofile.email_addr}}</li> + </ul> + <div class="card-footer d-flex"> + <a class="btn btn-primary ml-auto" href="/booking/detail/{{booking.id}}/">Details</a> + </div> + </div> + </div> + {% empty %} + <div class="col"> + <p>There are no expired bookings.</p> + </div> + {% endfor %} +</div> + +<script> + var current_booking_id = -1; + function cancel_booking(booking_id) { + current_booking_id = booking_id; + } + + function submit_cancel_form() { + var ajaxForm = $("#booking_cancel_form"); + var formData = ajaxForm.serialize(); + req = new XMLHttpRequest(); + var url = "cancel/" + current_booking_id; + req.open("POST", url, true); + req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + req.onerror = function() { alert("problem submitting form"); } + req.send(formData); + } +</script> + +<div class="modal fade" id="resModal" tabindex="-1" role="dialog" aria-hidden="true"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title d-inline float-left">Cancel Booking?</h4> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <form id="booking_cancel_form"> + {% csrf_token %} + </form> + <div class="modal-footer d-flex flex-column"> + <p>Everything on your machine(s) will be lost</p> + <div class="mb-2"> + <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button> + <button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#warning">Cancel Booking</button> + </div> + <div class="collapse w-100 text-center border-top" id="warning"> + <div class="p-4"> + <h3>Are You Sure?</h3> + <p>This cannot be undone</p> + <button class="btn btn-outline-secondary" data-dismiss="modal">Nevermind</button> + <button class="btn btn-danger" id="confirm_cancel_button" data-dismiss="modal" onclick="submit_cancel_form();">I'm Sure</button> + </div> + </div> + </div> + </div> + </div> +</div> +{% endblock %} diff --git a/src/templates/base/account/configuration_list.html b/src/templates/base/account/configuration_list.html new file mode 100644 index 0000000..206c203 --- /dev/null +++ b/src/templates/base/account/configuration_list.html @@ -0,0 +1,80 @@ +{% extends "base.html" %} +{% block content %} +<div class="row"> +{% for config in configurations %} + <div class="col-12 col-md-6 col-lg-4 col-xl-3 mb-3"> + <div class="card h-100"> + <div class="card-header"> + <h3>Configuration {{config.id}}</h3> + </div> + <ul class="list-group list-group-flush h-100"> + <li class="list-group-item">id: {{config.id}}</li> + <li class="list-group-item">name: {{config.name}}</li> + <li class="list-group-item">description: {{config.description}}</li> + <li class="list-group-item">resource: {{config.bundle}}</li> + </ul> + <div class="card-footer"> + <button + class="btn btn-danger w-100" + onclick='delete_config({{config.id}});' + data-toggle="modal" + data-target="#configModal" + >Delete</button> + </div> + </div> + </div> +{% empty %} + <div class="col"> + <p>You don't have any configurations. You can create a configuration by configuring a pod.</p> + </div> +{% endfor %} +</div> + +<script> + var current_config_id = -1; + function delete_config(config_id) { + current_config_id = config_id; + } + + function submit_delete_form() { + var ajaxForm = $("#config_delete_form"); + var formData = ajaxForm.serialize(); + req = new XMLHttpRequest(); + var url = "delete/" + current_config_id; + req.open("POST", url, true); + req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + req.onerror = function() { alert("problem submitting form"); } + req.send(formData); + } +</script> + +<div class="modal fade" id="configModal" tabindex="-1" role="dialog" aria-hidden="true"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title d-inline float-left">Delete Configuration?</h4> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <form id="config_delete_form"> + {% csrf_token %} + </form> + <div class="modal-footer d-flex flex-column"> + <div class="mb-2"> + <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button> + <button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#warning">Delete</button> + </div> + <div class="collapse w-100 text-center border-top" id="warning"> + <div class="p-4"> + <h3>Are You Sure?</h3> + <p>This cannot be undone</p> + <button class="btn btn-outline-secondary" data-dismiss="modal">Nevermind</button> + <button class="btn btn-danger" data-dismiss="modal" onclick="submit_delete_form();">I'm Sure</button> + </div> + </div> + </div> + </div> + </div> +</div> +{% endblock %} diff --git a/src/templates/base/account/details.html b/src/templates/base/account/details.html new file mode 100644 index 0000000..3092ad0 --- /dev/null +++ b/src/templates/base/account/details.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% load staticfiles %} +{% block content %} +<h1>Account Details</h1> +<a class="btn btn-primary" href="{% url 'account:my-resources' %}">My Resources</a> +<a class="btn btn-primary" href="{% url 'account:my-bookings' %}">My Bookings</a> +<a class="btn btn-primary" href="{% url 'account:my-configurations' %}">My Configurations</a> +<a class="btn btn-primary" href="{% url 'account:my-images' %}">My Snapshots</a> +{% endblock content %} diff --git a/src/templates/base/account/image_list.html b/src/templates/base/account/image_list.html new file mode 100644 index 0000000..6263016 --- /dev/null +++ b/src/templates/base/account/image_list.html @@ -0,0 +1,132 @@ +{% extends "base.html" %} +{% block content %} +<h2>Images I Own</h2> +<div class="row"> +{% for image in images %} + <div class="col-12 col-md-6 col-lg-4 col-xl-3 mb-3"> + <div class="card h-100"> + <div class="card-header"> + <h3>Image {{image.id}}</h3> + </div> + <ul class="list-group list-group-flush h-100"> + <li class="list-group-item">id: {{image.id}}</li> + <li class="list-group-item">lab: {{image.from_lab.name}}</li> + <li class="list-group-item">name: {{image.name}}</li> + <li class="list-group-item">description: {{image.description}}</li> + <li class="list-group-item">host profile: {{image.host_type.name}}</li> + </ul> + <div class="card-footer"> + <button class="btn btn-danger w-100" onclick='delete_image({{image.id}});' + data-toggle="modal" data-target="#imageModal"> + Delete + </button> + </div> + </div> + </div> +{% empty %} + <div class="col"> + <p>You don't have any images. You can create an image by creating a snapshot.</p> + </div> +{% endfor %} +</div> + +<h2>Public Images</h2> +<div class="row"> + {% for image in public_images %} + <div class="col-12 col-md-6 col-lg-4 col-xl-3 mb-3"> + <div class="card h-100"> + <div class="card-header"> + <h3>Image {{image.id}}</h3> + </div> + <ul class="list-group list-group-flush h-100"> + <li class="list-group-item">id: {{image.id}}</li> + <li class="list-group-item">lab: {{image.from_lab.name}}</li> + <li class="list-group-item">name: {{image.name}}</li> + <li class="list-group-item">description: {{image.description}}</li> + <li class="list-group-item">host profile: {{image.host_type.name}}</li> + </ul> + </div> + </div> + {% empty %} + <div class="col"> + <p>There are no public images.</p> + </div> + {% endfor %} +</div> + +<script> + var current_image_id = -1; + var used_images = {{used_images|safe|default:"{}"}}; + function delete_image(image_id) { + current_image_id = image_id; + var warning_header = document.getElementById("warning_header"); + var warning_text = document.getElementById("warning_text"); + var delete_image_button = document.getElementById("final_delete_b"); + clear(warning_header); + clear(warning_text); + if(used_images[image_id]) { + warning_header.appendChild( + document.createTextNode("Cannot Delete") + ); + warning_text.appendChild( + document.createTextNode("This snapshot is being used in a booking.") + ); + delete_image_button.disabled = true; + } else { + warning_header.appendChild( + document.createTextNode("Are You Sure?") + ); + warning_text.appendChild( + document.createTextNode("This cannot be undone") + ); + delete_image_button.removeAttribute("disabled"); + } + } + + function submit_delete_form() { + var ajaxForm = $("#image_delete_form"); + var formData = ajaxForm.serialize(); + req = new XMLHttpRequest(); + var url = "delete/" + current_image_id; + req.open("POST", url, true); + req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + req.onerror = function() { alert("problem submitting form"); } + req.send(formData); + } + + function clear(node) { + while(node.lastChild) { + node.removeChild(node.lastChild); + } + } +</script> +<div class="modal fade" id="imageModal" tabindex="-1" role="dialog" aria-hidden="true"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title d-inline float-left">Delete Configuration?</h4> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <form id="image_delete_form"> + {% csrf_token %} + </form> + <div class="modal-footer d-flex flex-column"> + <div class="mb-2"> + <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button> + <button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#warning">Delete</button> + </div> + <div class="collapse w-100 text-center border-top" id="warning"> + <div class="p-4"> + <h3 id="warning_header">Are You Sure?</h3> + <p id="warning_text">This cannot be undone</p> + <button class="btn btn-outline-secondary" data-dismiss="modal">Nevermind</button> + <button id="final_delete_b" class="btn btn-danger" data-dismiss="modal" onclick="submit_delete_form();">I'm Sure</button> + </div> + </div> + </div> + </div> + </div> +</div> +{% endblock %} diff --git a/src/templates/base/account/resource_list.html b/src/templates/base/account/resource_list.html new file mode 100644 index 0000000..65b46f1 --- /dev/null +++ b/src/templates/base/account/resource_list.html @@ -0,0 +1,124 @@ +{% extends "base.html" %} +{% block content %} +<div class="row"> +{% for resource in resources %} + <div class="col-12 col-md-6 col-lg-4 col-xl-3 mb-3"> + <div class="card h-100"> + <div class="card-header"> + <h3>Resource {{resource.id}}</h3> + </div> + <ul class="list-group list-group-flush h-100"> + <li class="list-group-item">id: {{resource.id}}</li> + <li class="list-group-item">name: {{resource.name}}</li> + <li class="list-group-item">description: {{resource.description}}</li> + </ul> + <div class="card-footer"> + <button + class="btn btn-danger w-100" + onclick='delete_resource({{resource.id}});' + data-toggle="modal" + data-target="#resModal" + >Delete</button> + </div> + </div> + </div> +{% empty %} + <div class="col"> + <p>You don't have any resources. You can create a resource by designing a pod.</p> + </div> +{% endfor %} +</div> +<script> + var grb_mapping = {{grb_mapping|safe|default:"{}"}}; + var booking_mapping = {{booking_mapping|safe|default:"{}"}}; + var current_resource_id = -1; + function delete_resource(resource_id) { + document.getElementById("confirm_delete_button").removeAttribute("disabled"); + var configs = grb_mapping[resource_id]; + var warning = document.createTextNode("Are You Sure?"); + var warning_subtext = document.createTextNode("This cannot be undone"); + if(booking_mapping[resource_id]){ + var warning = document.createTextNode("This resource is being used. It cannot be deleted."); + var warning_subtext = document.createTextNode("If your booking just ended, you may need to give us a few minutes to clean it up before this can be removed."); + + document.getElementById("confirm_delete_button").disabled = true; + } + else if(configs.length > 0) { + list_configs(configs); + warning_text = "Are You Sure? The following Configurations will also be deleted."; + warning = document.createTextNode(warning_text); + } + + current_resource_id = resource_id; + set_modal_text(warning, warning_subtext); + } + + function set_modal_text(title, text) { + var clear = function(node) { + while(node.lastChild) { + node.removeChild(node.lastChild); + } + } + var warning_title = document.getElementById("config_warning"); + var warning_text = document.getElementById("warning_subtext"); + + clear(warning_title); + clear(warning_text); + + warning_title.appendChild(title); + warning_text.appendChild(text); + } + + function list_configs(configs) { + var list = document.getElementById("config_list"); + for(var i=0; i<configs.length; i++){ + var str = configs[i].name; + var list_item = document.createElement("LI"); + list_item.appendChild(document.createTextNode(str)); + list.appendChild(list_item); + } + } + + function submit_delete_form() { + var ajaxForm = $("#res_delete_form"); + var formData = ajaxForm.serialize(); + req = new XMLHttpRequest(); + var url = "delete/" + current_resource_id; + req.open("POST", url, true); + req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + req.onerror = function() { alert("problem submitting form"); } + req.send(formData); + } +</script> +<div class="modal fade" id="resModal" tabindex="-1" role="dialog" aria-hidden="true"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title d-inline float-left">Delete Resource?</h4> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <form id="res_delete_form"> + {% csrf_token %} + </form> + <div class="modal-footer d-flex flex-column"> + <div class="mb-2"> + <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button> + <button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#warning">Delete</button> + </div> + <div class="collapse w-100 text-center border-top" id="warning"> + <div class="p-4"> + <h3 id="config_warning">Are You Sure?</h3> + <p id="warning_subtext">This cannot be undone</p> + <ul id="config_list"></ul> + <button class="btn btn-outline-secondary" data-dismiss="modal">Nevermind</button> + <button class="btn btn-danger" id="confirm_delete_button" data-dismiss="modal" onclick="submit_delete_form();">I'm Sure</button> + </div> + </div> + </div> + </div> + </div> +</div> + +{% endblock %} diff --git a/src/templates/base/account/user_list.html b/src/templates/base/account/user_list.html new file mode 100644 index 0000000..e564524 --- /dev/null +++ b/src/templates/base/account/user_list.html @@ -0,0 +1,55 @@ +{% extends "dashboard/table.html" %} +{% load staticfiles %} + +{% block table %} + <thead> + <tr> + <th>Username</th> + <th>Full Name</th> + <th>Email</th> + <th>Company</th> + <th>SSH Key</th> + <th>GPG Key</th> + </tr> + </thead> + <tbody> + {% for user in users %} + <tr> + <td> + {{ user.username }} + </td> + <td> + {{ user.userprofile.full_name }} + </td> + <td> + {{ user.userprofile.email_addr }} + </td> + <td> + {{ user.userprofile.company }} + </td> + <td> + {% if user.userprofile.ssh_public_key %} + <a href={{ user.userprofile.ssh_public_key.url }}>SSH</a> + {% endif %} + </td> + <td> + {% if user.userprofile.pgp_public_key %} + <a href={{ user.userprofile.pgp_public_key.url }}>GPG</a> + {% endif %} + </td> + </tr> + {% endfor %} + </tbody> +{% endblock table %} + + +{% block tablejs %} + <script type="text/javascript"> + $(document).ready(function () { + $('#table').DataTable({ + scrollX: true, + "order": [[0, "asc"]] + }); + }); + </script> +{% endblock tablejs %} diff --git a/src/templates/base/account/userprofile_update_form.html b/src/templates/base/account/userprofile_update_form.html new file mode 100644 index 0000000..16a8270 --- /dev/null +++ b/src/templates/base/account/userprofile_update_form.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} +{% load bootstrap4 %} + +{% block content %} +<div class="row"> + <div class="col-12 col-xl-6"> + {% bootstrap_messages %} + <div class="login-panel panel panel-default"> + <div class="panel-body"> + <form enctype="multipart/form-data" method="post"> + {% csrf_token %} + {% bootstrap_form form %} + <p><b>API Token</b> + <a href="{% url 'generate_token' %}" class="btn btn-primary"> + Generate + </a> + </p> + <p class="text-break">{{ token.key }}</p> + + <p></p> + {% buttons %} + <button type="submit" class="btn btn btn-success"> + Save Profile + </button> + {% endbuttons %} + </form> + </div> + </div> + </div> +</div> +{% endblock content %} |