aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/templates/admin/group_manager.html
blob: eedfe13820da152e20d595f88c04a44617c0f4bb (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
146
147
{% extends "base.html" %}
{% block title %}Group Manager{% endblock %}
{% block css %}
    <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" />
     <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}" />
    <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" />
{% endblock %}
{% block content %}
<!-- Start of body -->
    <div class="container">
        <div class="page-header">
            <h1>Manage Groups</h1>
            {% if admin_groups|length != 0 or member_groups|length != 0 %}
            <div style="display: inline;">
                <a href="{{ url_for('group_management.view_create_group_page') }}" target="_blank">
                    <button type="button" class="btn btn-primary">
                        Create Group
                    </button>
                </a>
                <button type="button" id="remove_groups" class="btn btn-primary"
                        data-url="{{ url_for('group_management.delete_groups') }}">
                    Remove Selected Groups
                </button>
            </div>
            {% endif %}
        </div>
        <form id="groups_form" action="/groups/manage" method="POST">
            <input type="hidden" name="selected_group_ids" value="">
            <div style="min-width: 800px; max-width: 1000px;">
                {% if admin_groups|length == 0 and member_groups|length == 0 %}
                <h4>You currently aren't a member or admin of any groups.</h4>
                <br>
                <a href="{{ url_for('group_management.view_create_group_page') }}" target="_blank">
                    <button type="button" class="btn btn-primary">
                        Create Group
                    </button>
                </a>
                {% else %}
                <div style="margin-top: 20px;"><h2>Admin Groups</h2></div>
                <hr>
                {% if admin_groups|length == 0 %}
                <h4>You currently aren't the administrator of any groups.</h4>
                {% else %}
                <table id="admin_groups" class="table-hover table-striped cell-border" style="float: left;">
                    <thead>
                        <tr>
                            <th></th>
                            <th>Index</th>
                            <th>Name</th>
                            <th># Members</th>
                            <th>Created</th>
                            <th>Last Changed</th>
                            <th>Group ID</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for group in admin_groups %}
                        <tr>
                            <td><input type="checkbox" name="group_id" value="{{ group.id }}"></td>
                            <td align="right">{{ loop.index }}</td>
                            {% set group_url = url_for('group_management.view_group', group_id=group.uuid) %}
                            <td><a href="{{ group_url  }}">{{ group.name }}</a></td>
                            <td align="right">{{ group.admins|length + group.members|length }}</td>
                            <td>{{ group.created_timestamp }}</td>
                            <td>{{ group.changed_timestamp }}</td>
                            <td>{{ group.uuid }}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
                {% endif %}
            </div>
            <hr>
            <div style="min-width: 800px; max-width: 1000px;">
                <div><h2>User Groups</h2></div>
                <hr>
                {% if member_groups|length == 0 %}
                <h4>You currently aren't a member of any groups.</h4>
                {% else %}
                <table id="member_groups" class="table-hover table-striped cell-border" style="float: left;">
                    <thead>
                        <tr>
                            <th></th>
                            <th>Index</th>
                            <th>Name</th>
                            <th># Members</th>
                            <th>Created</th>
                            <th>Last Changed</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for group in member_groups %}
                        <tr>
                            <td><input type="checkbox" name="read" value="{{ group.id }}"></td>
                            <td>{{ loop.index }}</td>
                            {% set group_url = url_for('group_management.view_group', group_id=group.uuid) %}
                            <td><a href="{{ group_url }}">{{ group.name }}</a></td>
                            <td>{{ group.admins|length + group.members|length }}</td>
                            <td>{{ group.created_timestamp }}</td>
                            <td>{{ group.changed_timestamp }}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
                {% endif %}
                {% endif %}
            </div>
        </form>
    </div>

<!-- End of body -->

{% endblock %}

{% block js %}
    <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script>

    <script type="text/javascript" charset="utf-8">
        $(document).ready( function () {
            {% if admin_groups|length != 0 %}
            $('#admin_groups').dataTable({
                'sDom': 'tr'
            });
            {% endif %}
            {% if member_groups|length != 0 %}
            $('#member_groups').dataTable({
                'sDom': 'tr'
            });
            {% endif %}
            submit_special = function(url) {
                $("#groups_form").attr("action", url);
                return $("#groups_form").submit();
            };

            $("#remove_groups").on("click", function() {
                url = $(this).data("url")
                groups = []
                $("input[name=group_id]:checked").each(function() {
                    groups.push($(this).val());
                });
                groups_string = groups.join(":")
                $("input[name=selected_group_ids]").val(groups_string)
                return submit_special(url)
            });
        });
    </script>
{% endblock %}