aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/base/booking/booking_detail.html
blob: 33b04860de0bb0801ac8d1eacd93f8fbcca9ef3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{% extends "base.html" %}
{% load staticfiles %}
{% load bootstrap4 %}

{% block extrahead %}
    {{block.super}}
    <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?lang=yaml"></script>
{% endblock %}

<style>
code {
    overflow: scroll;
}
</style>

{% block content %}
<div class="row">
    <div class="col-12 col-lg-5">
        <div class="card mb-3">
            <div class="card-header d-flex">
                <h4 class="d-inline">Overview</h4>
                <!-- <button data-toggle="collapse" data-target="#panel_overview" class="btn btn-outline-secondary ml-auto">Expand</button> -->
            </div>
            <div class="collapse show" id="panel_overview">
                <table class="table m-0">
                    <tr>
                        <td>Owner</td>
                        <td>{{ booking.owner }}</td>
                    </tr>
                    <tr>
                        <td>Collaborators</td>
                        <td>
                            {{ collab_string}}
                        </td>
                    </tr>
                    <tr>
                        <td>Project</td>
                        <td>{{ booking.project }}</td>
                    </tr>
                    <tr>
                        <td>Purpose</td>
                        <td>{{ booking.purpose }}</td>
                    </tr>
                    <tr>
                        <td>Start Time</td>
                        <td>{{ booking.start }}</td>
                    </tr>
                    <tr>
                        <td>End Time</td>
                        <td>{{ booking.end }}</td>
                    </tr>
                    <tr>
                        <td>Lab Deployed At</td>
                        <td>{{ booking.lab }}</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <div class="col">
        <div class="card mb-3">
            <div class="card-header d-flex">
                <h4 class="d-inline">Deployment Progress</h4>
                <p class="mx-3">Your resources are being prepared. If this is taking a really long time, please contact us <a href="mailto:{{contact_email}}">here!</a></p>
                <!-- <button data-toggle="collapse" data-target="#panel_tasks" class="btn btn-outline-secondary ml-auto">Expand</button> -->
            </div>
            <div class="collapse show" id="panel_tasks">
                <table class="table m-0">
                    <tr>
                        <th></th>
                        <th>Resource</th>
                        <th>Status</th>
                    </tr>
                    {% for host in statuses %}
                    <tr>
                        <td>
                            {% if 'Success' in host.status  %}
                            <div class="rounded-circle bg-success square-20"></div>
                            {% elif 'Fail' in host.status %}
                            <div class="rounded-circle bg-danger square-20"></div>
                            {% else %}
                            <div class="spinner-border text-primary square-20"></div>
                            {% endif %}
                        </td>
                        <td>
                            {{ host.hostname }}
                        </td>
                        <td id="{{host.instance_id}}">
                            {{ host.status }}
                        </td>
                    </tr>
                    {% endfor %}
                </table>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-5">
        <div class="card mb-3">
            <div class="card-header d-flex">
                Diagnostic Information
            </div>
            <div>
                <table class="table m-0">
                    <tr>
                        <th></th>
                        <th>Aggregate ID</th>
                        <td>{{booking.aggregateId}}</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>

<script>
setInterval(function(){
   fetchBookingStatus();
}, 5000);


async function fetchBookingStatus() {
        req = new XMLHttpRequest();
        var url = "status";
        req.open("GET", url, true);
        req.onerror = function() { alert("oops"); }
        req.onreadystatechange = function() {
            if(req.readyState === 4) {
            statuses = JSON.parse(req.responseText)
            updateStatuses(statuses)
            }
        }
        req.send();
}

async function updateStatuses(statuses) {
    for (const s of statuses) {
        document.getElementById(s.instance_id).innerText = s.status
    }
}
</script>

{% endblock content %}