aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/account/configuration_list.html
blob: 6f7844a3db495a1cc1455031ac90d30fc2470e1f (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
{% extends "base.html" %}
{% block content %}
<div class="card_container">
{% for config in configurations %}
    <div class="card">
        <div class="card-header">
            <h3>Configuration {{config.id}}</h3>
        </div>
        <div class="card-body">
            <ul class="list-group">
                <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>
        <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>
{% endfor %}
</div>
<script>
    var current_config_id = -1;
    function delete_config(config_id) {
        current_config_id = config_id;
        document.getElementById('modal_warning').style['max-height'] = '0px';
    }

    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-labelledby="my_modal" aria-hidden="true">
    <div class="modal-dialog" style="width: 450px;" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="my_modal" style="display: inline; float: left;">Delete Configuration?</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="config_delete_form">
                {% csrf_token %}
            </form>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" onclick="document.getElementById('modal_warning').style['max-height'] = '500px';">Delete</button>
            </div>
            <div id="modal_warning" class="modal-footer" style="max-height:0px;" >
                <div style="text-align:center; margin: 5px">
                    <h3>Are You Sure?</h3>
                    <p>This cannot be undone</p>
                    <button class="btn" onclick="document.getElementById('modal_warning').style['max-height'] = '0px';">Nevermind</button>
                    <button class="btn btn-danger" data-dismiss="modal" onclick="submit_delete_form();">I'm Sure</button>
                </div>
        </div>
    </div>
</div>
{% endblock %}