1 {% extends
"base.html" %}
9 <link rel=
"stylesheet" href=
"/static/node_modules/select2/dist/css/select2.min.css">
10 <link rel=
"stylesheet" href=
"/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
12 {% block title_header_big %}
15 {% block left_sidebar %}
16 {% include 'osm/osm_project_left_sidebar.html' %}
20 {% block breadcrumb_body %}
22 <li><a href=
"#">Roles
</a></li>
25 {% block content_body %}
27 {% include 'modal/role_create.html' %}
28 {% include 'modal/role_edit.html' %}
32 <div class=
"col-md-12">
35 <div class=
"box-header with-border">
36 <h3 class=
"box-title">Roles
</h3>
37 <div class=
"box-tools">
38 <button type=
"button" class=
"btn btn-default" data-container=
"body"
39 onclick=
"javascript:openModalCreateRole()"
40 data-toggle=
"tooltip" data-placement=
"top" title=
"New role">
42 <i class=
"fa fa-plus"></i> Create role
47 <div class=
"box-body">
48 <table id=
"roles_table" class=
"table table-bordered table-striped">
68 {% block resource_block %}
70 <script src=
"/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
71 <script src=
"/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
72 <script src=
"/static/node_modules/select2/dist/js/select2.js"></script>
73 <script src=
"/static/src/rolehandler/role_list.js"></script>
77 $(document).ready(function () {
78 table = $('#roles_table').DataTable({
81 "url":
"/admin/roles/list",
82 "dataSrc": function (json) {
87 console.log(
"no auth");
88 moveToLogin(window.location.pathname);
91 "error": function (hxr, error, thrown) {
100 "render": function (data, type, row) {
107 "render": function (data, type, row) {
113 "render": function (data, type, row) {
114 return moment.unix(row[
"_admin"]['modified']).format('YYYY-MM-DD hh:mm:ss a');
119 "render": function (data, type, row) {
120 return moment.unix(row[
"_admin"]['created']).format('YYYY-MM-DD hh:mm:ss a');
125 "render": function (data, type, row) {
126 return '
<div class=
"btn-group">' +
127 '
<button type=
"button" class=
"btn btn-default dropdown-toggle"' +
128 '
data-toggle=
"dropdown" aria-expanded=
"false">Actions ' +
129 '
<span class=
"fa fa-caret-down"></span></button> ' +
130 '
<ul class=
"dropdown-menu">' +
131 '
<li> <a href=
"#" onclick=
"javascript:openModalEditRole({role_id:\'' + row['_id'] + '\'})">' +
132 '
<i class=
"fa fa-edit"></i> Edit
</a></li>' +
133 '
<li> <a href=
"#" onclick=
"javascript:deleteRole(\'' + row['_id'] + '\', \'' + row['name'] + '\')"' +
134 '
style=
"color:red"><i class=
"fa fa-trash"></i> Delete
</a></li> </ul></div>';
142 setInterval(function () {
146 $(
"#formCreateRole").submit(function (event) {
147 event.preventDefault(); //prevent default action
148 var post_url = $(this).attr(
"action"); //get form action url
149 var request_method = $(this).attr(
"method");
150 var form_data = new FormData(this); //Encode form elements for submission
154 type: request_method,
157 "Accept": 'application/json'
161 }).done(function (response, textStatus, jqXHR) {
162 $('#modal_new_role').modal('hide');
166 message:
"role successfully created."
169 }).fail(function (result) {
170 var data = result.responseJSON;
171 var title =
"Error " + (data.code ? data.code : 'unknown');
172 var message = data.detail ? data.detail : 'No detail available.';
180 $(
"#formEditRole").submit(function (event) {
181 event.preventDefault(); //prevent default action
182 var post_url = $(this).attr(
"action"); //get form action url
183 var request_method = $(this).attr(
"method");
184 var form_data = new FormData(this); //Encode form elements for submission
188 type: request_method,
191 "Accept": 'application/json'
195 }).done(function (response, textStatus, jqXHR) {
196 $('#modal_edit_role').modal('hide');
200 message:
"Role successfully modified."
203 }).fail(function (result) {
204 var data = result.responseJSON;
205 var title =
"Error " + (data.code ? data.code : 'unknown');
206 var message = data.detail ? data.detail : 'No detail available.';
221 {% include
"footer.html" %}