2 Copyright 2019 EveryUP srl
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 {% extends
"base.html" %}
19 {% load staticfiles %}
22 {% block head_block %}
24 <link rel=
"stylesheet" href=
"/static/node_modules/select2/dist/css/select2.min.css">
25 <link rel=
"stylesheet" href=
"/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
27 {% block title_header_big %}
30 {% block left_sidebar %}
31 {% include 'osm/osm_project_left_sidebar.html' %}
35 {% block breadcrumb_body %}
37 <li><a href=
"#">Users
</a></li>
40 {% block content_body %}
42 {% include 'modal/user_details.html' %}
43 {% include 'modal/user_create.html' %}
44 {% include 'modal/user_credentials_edit.html' %}
45 {% include 'modal/user_proj_role_edit.html' %}
50 <div class=
"col-md-12">
53 <div class=
"box-header with-border">
54 <h3 class=
"box-title">Users
</h3>
55 <div class=
"box-tools">
56 <button type=
"button" class=
"btn btn-default" data-container=
"body"
57 onclick=
"javascript:openModalCreateUser({'projects_list_url': '{% url "projects:projects_list
" %}', 'domains_list_url': '{% url "projects:domains_list
" %}'})"
58 data-toggle=
"tooltip" data-placement=
"top" title=
"New User">
60 <i class=
"fa fa-plus"></i> Create User
65 <div class=
"box-body">
66 <table id=
"users_table" class=
"table table-bordered table-striped">
86 {% block resource_block %}
88 <script src=
"/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
89 <script src=
"/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
90 <script src=
"/static/node_modules/select2/dist/js/select2.js"></script>
91 <script src=
"/static/src/userhandler/user_list.js"></script>
94 $(document).ready(function () {
95 table = $('#users_table').DataTable({
98 "url":
"/admin/users/list",
99 "dataSrc": function (json) {
100 return json['users'];
104 console.log(
"no auth");
105 moveToLogin(window.location.pathname);
108 "error": function (hxr, error, thrown) {
117 "render": function (data, type, row) {
118 return row[
"username"];
123 "render": function (data, type, row) {
130 "render": function (data, type, row) {
131 return moment.unix(row[
"_admin"]['modified']).format('YYYY-MM-DD hh:mm:ss a');
136 "render": function (data, type, row) {
137 return moment.unix(row[
"_admin"]['created']).format('YYYY-MM-DD hh:mm:ss a');
142 "render": function (data, type, row) {
143 return '
<div class=
"btn-group">' +
144 '
<button type=
"button" class=
"btn btn-default dropdown-toggle"' +
145 '
data-toggle=
"dropdown" aria-expanded=
"false">Actions ' +
146 '
<span class=
"fa fa-caret-down"></span></button> ' +
147 '
<ul class=
"dropdown-menu">' +
148 '
<li> <a href=
"#" onclick=
"javascript:openModalEditUserCredentials({user_id:\'' + row['_id'] + '\', usernarme:\'' + row['username'] + '\'})">' +
149 '
<i class=
"fa fa-lock"></i>Edit Credentials
</a></li>' +
150 '
<li> <a href=
"#" onclick=
"javascript:openModalEditUserRoleMap(\''+row['_id']+'\')">' +
151 '
<i class=
"fa fa-user-tag"></i>Projects-Roles
</a></li>' +
152 '
<li> <a href=
"#" onclick=
"javascript:deleteUser(\'' + row['_id'] + '\', \'' + row['username'] + '\')"' +
153 '
style=
"color:red"><i class=
"fa fa-trash"></i> Delete
</a></li> </ul></div>';
162 setInterval(function () {
166 $(
"#formCreateUser").submit(function (event) {
167 event.preventDefault(); //prevent default action
168 var post_url = $(this).attr(
"action"); //get form action url
169 var request_method = $(this).attr(
"method");
170 var form_data = new FormData(this); //Encode form elements for submission
174 type: request_method,
177 "Accept": 'application/json'
181 }).done(function (response, textStatus, jqXHR) {
182 $('#modal_new_user').modal('hide');
186 message:
"User successfully created."
189 }).fail(function (result) {
190 var data = result.responseJSON;
191 var title =
"Error " + (data.code ? data.code : 'unknown');
192 var message = data.detail ? data.detail : 'No detail available.';
200 $(
"#formEditUser").submit(function (event) {
201 event.preventDefault(); //prevent default action
202 var post_url = $(this).attr(
"action"); //get form action url
203 var request_method = $(this).attr(
"method");
204 var form_data = new FormData(this); //Encode form elements for submission
208 type: request_method,
211 "Accept": 'application/json'
215 }).done(function (response, textStatus, jqXHR) {
216 $('#modal_edit_user_credentials').modal('hide');
220 message:
"User successfully modified."
223 }).fail(function (result) {
224 var data = result.responseJSON;
225 var title =
"Error " + (data.code ? data.code : 'unknown');
226 var message = data.detail ? data.detail : 'No detail available.';
234 $(
"#password2").keyup(validatePswOnCreate);
235 $(
"#edit_password2").keyup(validatePswOnEdit);
237 $(document).on('click', '.proj-role-map-group-head .btn-add', addMapGroup);
238 $(document).on('click', '.proj-role-map-group .btn-remove', removeMapGroup);
246 {% include
"footer.html" %}