aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srtgui/templates/users.html
blob: fd2c8c1803040e9e83d7878d247572b61f0f4044 (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 projecttags %}

{% block title %} Users - SRTool {% endblock %}

{% block pagecontent %}

<div class="row">
  <!-- Breadcrumbs -->
	<div class="col-md-12">
		<ul class="breadcrumb" id="breadcrumb">
			<li><a href="{% url 'landing' %}">Home</a></li><span class="divider">&rarr;</span>
			<li><a href="{% url 'manage' %}">Management</a></li><span class="divider">&rarr;</span>
			<li>Users</li>
		</ul>
	</div>
</div>

<!-- Begin container -->

<div class="row">
  <div class="col-md-12">
    <div class="page-header build-data">
        <h1>Users</h1>
    </div>
  </div>
</div>

<div class="row">
  <div class="col-md-6">
	<div>
		<h3>Access Levels</h3>
		<div style="padding-left: 25px;">
		<p><b>Reader</b>: User that can read the content (Field, TechPubs)</p>
		<p><b>Contributor</b>: Reader that can can add notes and attachements (Engineers, Test, Managers)</p>
		<p><b>Creator</b>: Contributor that can create Investiations and defect records </p>
		<p><b>Admin</b>: Creator that can manage users, data sources</p>
		</div>
	</div>
	<p/>
  </div>
</div>

<div class="row" style="padding-left: 25px;">
	<h3>User List
		<a class="btn btn-default navbar-btn " id="new-investigation-attachement" href="{% url 'edit_user' 0 %}">Add user</a>
	</h3>

	<table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
		<thead>
			<tr>
				<th>User</th>
				<th>First</th>
				<th>Last</th>
				<th>Email</th>
				<th>Role</th>
				<th>Group</th>
				<th>Manage</th>
			</tr>
		</thead>

		{% if object.all %}
		  {% for user in object.all %}
			<tr>
				<td>{{ user.username }} </td>
				<td>{{ user.first_name }} </td>
				<td>{{ user.last_name }} </td>
				<td>{{ user.email }} </td>
				<td>{{ user.role }} </td>
				<td>{{ user.get_groups }} </td>
				<td>
				  {% if user.is_superuser or not user.is_staff %}
					<span id="user_'+{{user.id}}+'" class="js-user-name"></span>
					<a href="{% url 'edit_user' user.id %}"><span class="glyphicon glyphicon-edit js-icon-pencil-config_var"></span></a>
					<span class="glyphicon glyphicon-trash trash-user" id="user_trash_'+{{user.id}}+'" x-data="{{user.username}}:{{user.id}}"></span>
				  {% else %}
				  Built-in
				  {% endif %}
				</td>

			</tr>
		  {% endfor %}
		{% else %}
			<tr>
				<td>No users found</td>
			</tr>
		{% endif %}

	</table>

</div>

<!-- Javascript support -->
<script>
	$(document).ready(function() {

	  function onCommitAjaxSuccess(data, textstatus) {
	    if (window.console && window.console.log) {
	      console.log("XHR returned:", data, "(" + textstatus + ")");
	    } else {
	      alert("NO CONSOLE:\n");
	      return;
	    }
	    if (data.error != "ok") {
	      alert("error on request:\n" + data.error);
	      return;
	    }
	    // reload the page with the updated tables
	    location.reload(true);
	  }

	  function onCommitAjaxError(jqXHR, textstatus, error) {
	    console.log("ERROR:"+error+"|"+textstatus);
	    alert("XHR errored1:\n" + error + "\n(" + textstatus + ")");
	  }

	  /* ensure cookie exists {% csrf_token %} */
	  function postCommitAjaxRequest(reqdata) {
		var ajax = $.ajax({
	      type:"POST",
	      data: reqdata,
	      url:"{% url 'xhr_user_commit' %}",
	      headers: { 'X-CSRFToken': $.cookie("csrftoken")},
	      success: onCommitAjaxSuccess,
	      error: onCommitAjaxError,
	    })
	  }

	  $('.trash-user').click(function() {
		var result = confirm("Are you sure you want to remove user '" + $(this).attr('x-data').split(':')[0] + "'?");
		if (result){
			postCommitAjaxRequest({
				"action" : 'submit-trashuser',
				"record_id" : $(this).attr('x-data').split(':')[1],
				});
		}
	  });

	});

</script>


{% endblock %}