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 %}
22 {% block head_block %}
24 <link rel=
"stylesheet" href=
"/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
27 {% block title_header_big %}
30 {% block left_sidebar %}
32 {% include 'osm/osm_project_left_sidebar.html' %}
37 {% block breadcrumb_body %}
39 {% if user.is_admin %}
40 <li><a href=
"{% url 'projects:projects_list' %}">Projects
</a></li>
42 <li><a href=
"#">Projects
</a></li>
46 {% block content_body %}
50 <div class=
"col-md-12">
52 <div class=
"box-header with-border">
53 <h3 class=
"box-title">Projects
</h3>
54 <div class=
"box-tools">
55 <button type=
"button" class=
"btn btn-default" data-container=
"body"
56 data-toggle=
"tooltip" data-placement=
"top" title=
"New Project"
57 onclick=
"javascript:showModalNewProject()">
58 <i class=
"fa fa-plus"></i> New Project
</button>
61 <div class=
"box-body">
62 <table id=
"projects_table" class=
"table table-bordered table-striped">
66 <th>Modification Date
</th>
67 <th>Creation Date
</th>
80 {% include
"modal/project_new.html" %}
81 {% include
"modal/project_edit.html" %}
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>
91 $(document).ready( function () {
92 table = $('#projects_table').DataTable({
95 "url":
"/projects/list",
96 "dataSrc": function (json) {
97 return json['projects'];
101 console.log(
"no auth");
102 moveToLogin(window.location.pathname);
105 "error": function (hxr, error, thrown) {
114 "render": function (data, type, row) {
115 return '
<a href=
"/projects/'+row['name']+'/switch/" >'+row['name']+'
</a>'
120 "render": function (data, type, row) {
121 return moment.unix(row[
"_admin"]['modified']).format('YYYY-MM-DD hh:mm:ss a');
126 "render": function (data, type, row) {
127 return moment.unix(row[
"_admin"]['created']).format('YYYY-MM-DD hh:mm:ss a');
132 "render": function (data, type, row) {
133 return '
<div class=
"btn-group">\n' +
134 '
<button type=
"button" class=
"btn btn-default dropdown-toggle"\n' +
135 '
data-toggle=
"dropdown" aria-expanded=
"false">Actions\n' +
136 '
<span class=
"fa fa-caret-down"></span></button>\n' +
137 '
<ul class=
"dropdown-menu">\n' +
138 '
<li><a href=
"#"\n' +
139 '
onclick=
"javascript:editProject(\''+ row['name']+'\')">\n' +
140 '
<i class=
"fa fa-edit"></i> Rename
</a></li>\n' +
142 '
<a href=
"#" onclick=
"javascript:deleteProject(\''+ row['name']+'\')" style=
"color:red">\n' +
143 '
<i class=
"fa fa-trash" ></i> Delete
</a>\n' +
154 setInterval(function () {
160 function showModalNewProject(){
161 $('#modal_new_project').modal('show');
164 function editProject(project_id){
165 var url =
"/projects/" + project_id+
"/edit";
166 $(
"#formEditProject").attr(
"action", url);
167 $('#modal_edit_project').modal('show');
170 function deleteProject(project_id) {
171 var url =
"/projects/" + project_id+
"/delete";
172 bootbox.confirm(
"Are you sure want to delete?", function (result) {
178 "Accept": 'application/json'
182 }).done(function (response,textStatus, jqXHR) {
185 message:
"Project deleted.",
186 callback: function () {
190 }).fail(function(result){
191 var data = result.responseJSON;
192 var title =
"Error " + (data.code ? data.code: 'unknown');
193 var message = data.detail ? data.detail: 'No detail available.';
203 $(document).ready(function () {
204 $(
"#formNewProject").submit(function (event) {
205 event.preventDefault(); //prevent default action
206 var post_url = $(this).attr(
"action"); //get form action url
207 var request_method = $(this).attr(
"method"); //get form GET/POST method
208 var form_data = new FormData(this); //Encode form elements for submission
209 console.log(post_url);
212 type: request_method,
215 "Accept": 'application/json'
219 }).done(function (response,textStatus, jqXHR) {
222 message:
"Project created.",
223 callback: function () {
225 $('#modal_new_project').modal('hide');
228 }).fail(function(result){
229 var data = result.responseJSON;
230 var title =
"Error " + (data.code ? data.code: 'unknown');
231 var message = data.detail ? data.detail: 'No detail available.';
239 $(
"#formEditProject").submit(function(event){
240 event.preventDefault(); //prevent default action
241 var post_url = $(this).attr(
"action"); //get form action url
242 var request_method = $(this).attr(
"method"); //get form GET/POST method
243 var form_data = new FormData(this); //Encode form elements for submission
244 console.log(post_url);
247 type: request_method,
250 "Accept": 'application/json'
254 }).done(function (response,textStatus, jqXHR) {
257 message:
"Project updated.",
258 callback: function () {
260 $('#modal_edit_project').modal('hide');
263 }).fail(function(result){
264 var data = result.responseJSON;
265 var title =
"Error " + (data.code ? data.code: 'unknown');
266 var message = data.detail ? data.detail: 'No detail available.';