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.
17 {% extends
"base.html" %}
20 {% load staticfiles %}
23 {% block head_block %}
25 <link rel=
"stylesheet" href=
"/static/node_modules/select2/dist/css/select2.min.css">
26 <link rel=
"stylesheet" href=
"/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
28 {% block title_header_big %}
31 {% block left_sidebar %}
32 {% include 'osm/osm_project_left_sidebar.html' %}
36 {% block breadcrumb_body %}
38 <li><a href=
"#">Roles
</a></li>
41 {% block content_body %}
43 {% include 'modal/role_create.html' %}
44 {% include 'modal/role_edit.html' %}
48 <div class=
"col-md-12">
51 <div class=
"box-header with-border">
52 <h3 class=
"box-title">Roles
</h3>
53 <div class=
"box-tools">
54 <button type=
"button" class=
"btn btn-default" data-container=
"body"
55 onclick=
"javascript:openModalCreateRole()"
56 data-toggle=
"tooltip" data-placement=
"top" title=
"New role">
58 <i class=
"fa fa-plus"></i> Create role
63 <div class=
"box-body">
64 <table id=
"roles_table" class=
"table table-bordered table-striped">
84 {% block resource_block %}
86 <script src=
"/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
87 <script src=
"/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
88 <script src=
"/static/node_modules/select2/dist/js/select2.js"></script>
89 <script src=
"/static/src/rolehandler/role_list.js"></script>
93 $(document).ready(function () {
94 table = $('#roles_table').DataTable({
97 "url":
"/admin/roles/list",
98 "dataSrc": function (json) {
103 console.log(
"no auth");
104 moveToLogin(window.location.pathname);
107 "error": function (hxr, error, thrown) {
116 "render": function (data, type, row) {
123 "render": function (data, type, row) {
129 "render": function (data, type, row) {
130 return moment.unix(row[
"_admin"]['modified']).format('YYYY-MM-DD hh:mm:ss a');
135 "render": function (data, type, row) {
136 return moment.unix(row[
"_admin"]['created']).format('YYYY-MM-DD hh:mm:ss a');
141 "render": function (data, type, row) {
142 return '
<div class=
"btn-group">' +
143 '
<button type=
"button" class=
"btn btn-default dropdown-toggle"' +
144 '
data-toggle=
"dropdown" aria-expanded=
"false">Actions ' +
145 '
<span class=
"fa fa-caret-down"></span></button> ' +
146 '
<ul class=
"dropdown-menu">' +
147 '
<li> <a href=
"#" onclick=
"javascript:openModalEditRole({role_id:\'' + row['_id'] + '\'})">' +
148 '
<i class=
"fa fa-edit"></i> Edit
</a></li>' +
149 '
<li> <a href=
"#" onclick=
"javascript:deleteRole(\'' + row['_id'] + '\', \'' + row['name'] + '\')"' +
150 '
style=
"color:red"><i class=
"fa fa-trash"></i> Delete
</a></li> </ul></div>';
158 setInterval(function () {
162 $(
"#formCreateRole").submit(function (event) {
163 event.preventDefault(); //prevent default action
164 var post_url = $(this).attr(
"action"); //get form action url
165 var request_method = $(this).attr(
"method");
166 var form_data = new FormData(this); //Encode form elements for submission
170 type: request_method,
173 "Accept": 'application/json'
177 }).done(function (response, textStatus, jqXHR) {
178 $('#modal_new_role').modal('hide');
182 message:
"role successfully created."
185 }).fail(function (result) {
186 var data = result.responseJSON;
187 var title =
"Error " + (data.code ? data.code : 'unknown');
188 var message = data.detail ? data.detail : 'No detail available.';
196 $(
"#formEditRole").submit(function (event) {
197 event.preventDefault(); //prevent default action
198 var post_url = $(this).attr(
"action"); //get form action url
199 var request_method = $(this).attr(
"method");
200 var form_data = new FormData(this); //Encode form elements for submission
204 type: request_method,
207 "Accept": 'application/json'
211 }).done(function (response, textStatus, jqXHR) {
212 $('#modal_edit_role').modal('hide');
216 message:
"Role successfully modified."
219 }).fail(function (result) {
220 var data = result.responseJSON;
221 var title =
"Error " + (data.code ? data.code : 'unknown');
222 var message = data.detail ? data.detail : 'No detail available.';
237 {% include
"footer.html" %}