aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/templates/admin/manage_resource.html
blob: 63ec17c03a05a13732c6aa7e8d3ac1c280900c64 (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
{% extends "base.html" %}
{% block title %}Resource Manager{% endblock %}
{% block content %}
<!-- Start of body -->
<div class="container">
    <section>
    {{ flash_me() }}
    {% set DATA_ACCESS = access_role.get('data') %}
    {% set METADATA_ACCESS = access_role.get('metadata') %}
    {% set ADMIN_STATUS = access_role.get('admin') %}
    {% set ADMIN_STATUS = access_role.get('admin') %}
    <h1>Resource Manager</h1>
    {% if resource_info.get('owner_id') %}
    {% set user_details = resource_info.get('owner_details') %}
    <h3>
        Current Owner: {{ user_details.get('full_name') }}
    </h3>
    {% if user_details.get('organization') %}
    <h3>
        Organization: {{ user_details.get('organization')}}
    </h3>
    {% endif %}
    {% endif %}
    {% if DATA_ACCESS > DataRole.VIEW and ADMIN_STATUS > AdminRole.NOT_ADMIN %}
    <a class="btn btn-danger" target="_blank"
       href="/resource-management/resources/{{ resource_info.get('resource_id') }}/change-owner">
        Change Owner
    </a>
    {% endif %}
        </section>

    <section class="container" style="margin-top: 2em;">
        <form class="container-fluid" action="/resource-management/resources/{{ resource_info.get('resource_id') }}/make-public" method="POST">
            <input type="hidden" name="resource_id" value="{{ resource_info.get('resource_id') }}">
            <div>
                <fieldset>
                    <div class="form-horizontal" style="width: 900px; margin-bottom: 50px;">
                        <div class="form-group" style="padding-left: 20px;">
                            <label for="group_name" class="col-xs-3" style="float: left; font-size: 18px;">Resource Name:</label>
                            <div class="controls input-append col-xs-9" style="display: flex; padding-left: 20px; float: left;">
                                {{ resource_info.get('name') }}
                            </div>
                        </div>
                        {% if DATA_ACCESS > DataRole.VIEW and ADMIN_STATUS > AdminRole.NOT_ADMIN %}
                        {% set is_open_to_public = DataRole(resource_info.get('default_mask').get('data')) > DataRole.NO_ACCESS %}
                        <div class="form-group" style="padding-left: 20px;">
                            <label for="user_email" class="col-xs-3" style="float: left; font-size: 18px;">Open to Public:</label>
                            <div class="controls input-append col-xs-9" style="display: flex; padding-left: 20px; float: left;">
                                <label class="radio-inline">
                                    <input type="radio" name="open_to_public" value="True" {{ 'checked' if is_open_to_public }}>
                                    Yes
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="open_to_public" value="False" {{ 'checked' if not is_open_to_public }}>
                                    No
                                </label>
                            </div>
                        </div>
                        <div class="form-group" style="padding-left: 20px;">
                            <label class="col-xs-3" style="float: left; font-size: 18px;"></label>
                            <div class="controls input-append col-xs-9" style="display: flex; padding-left: 20px; float: left;">
                                <button id="save_changes" class="btn btn-primary" data-url="/resource-management/resources/change_default_privileges">Save Changes</button>
                            </div>
                        </div>
                        {% endif %}
                    </div>
                </fieldset>
            </div>
            {% if ADMIN_STATUS > AdminRole.NOT_ADMIN %}
            <div style="min-width: 600px; max-width: 800px;">
                <hr>
                <button id="add_group_to_resource" class="btn btn-primary" style="margin-bottom: 30px;" data-url="/resources/add_group">Add Group</button>
                <br>
                {% if resource_info.get('group_masks', [])|length > 0 %}
                <h2>Current Group Permissions</h2>
                <hr>
                <table id="groups_table" class="table table-hover table-striped cell-border">
                    <thead>
                        <tr>
                            <th>Id</th>
                            <th>Name</th>
                            <th>Data</th>
                            <th>Metadata</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for key, value in resource_info.get('group_masks').items() %}
                        <tr>
                            <td>{{ key }}</td>
                            <td>{{ value.group_name}}</td>
                            <td>{{ value.data }}</td>
                            <td>{{ value.metadata }}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
                {% else %}
                <h3>No groups are currently added to this resource.</h3>
                {% endif %}
            </div>
            {% endif %}
        </form>
        </section>

    <!-- 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">
     $('#add_group_to_resource, #save_changes, #change_owner').click(function(){
         url = $(this).data("url");
         $('#manage_resource').attr("action", url)
         $('#manage_resource').submit()
     })

     {% if group_masks|length > 0 %}
     $('#groups_table').dataTable({
         'sDom': 'tr',
     });
     {% endif %}
    </script>
    {% endblock %}