63396798d3d50ef7a0e9c22d252171d08e059a99
[osm/LW-UI.git] / projecthandler / template / project / projectlist.html
1 {% extends "base.html" %}
2 {% load get %}
3 {% load date_tag %}
4 {% load staticfiles %}
5
6 {% block head_block %}
7 {{ block.super }}
8
9 {% endblock %}
10 {% block title_header_big %}
11 {{ block.super }}
12 {% endblock %}
13 {% block left_sidebar %}
14
15 {% include 'left_sidebar_base.html' %}
16
17 {% endblock %}
18
19
20 {% block breadcrumb_body %}
21 {{ block.super }}
22 <li><a href="{% url 'projects:projects_list' %}">Projects</a></li>
23 {% endblock %}
24
25 {% block content_body %}
26 {{ block.super }}
27 {% csrf_token %}
28 <div class="row">
29 <div class="col-md-12">
30
31 <div class="box">
32 <div class="box-header with-border">
33 <h3 class="box-title">Projects</h3>
34 <div class="box-tools">
35 <button type="button" class="btn btn-default" data-container="body"
36 data-toggle="tooltip" data-placement="top" title="New Project"
37 onclick="javascript:showModalNewProject()">
38 <i class="fa fa-plus"></i> New Project</button>
39 </div>
40 </div>
41 <div class="box-body">
42 <table id="projects_table" class="table table-bordered table-striped">
43 <thead>
44 <tr>
45
46 <th>Name</th>
47
48 <th>Modification Date</th>
49 <th>Creation Date</th>
50
51
52 <th><i class="far fa-trash-alt"></i></th>
53 </tr>
54 </thead>
55 <tbody>
56 {% for p in projects %}
57 <tr>
58
59 <td>
60 <a href="javascript:openProject('{{ p.name }}')" >{{ p.name }}</a>
61 </td>
62
63 <td>{{ p|get_sub:"_admin,modified"|get_date}}</td>
64 <td>{{ p|get_sub:"_admin,created"|get_date}}</td>
65
66 <td><a href="javascript:deleteProject('{% url 'projects:delete_project' project_id=p|get:'_id' %}')"> Delete</a></td>
67
68 </tr>
69 {% endfor %}
70 </tbody>
71 </table>
72 </div>
73 </div>
74 </div>
75
76 </div>
77 {% include "modal/new_project.html" %}
78 {% endblock %}
79
80 {% block resource_block %}
81 {{ block.super }}
82 <script>
83 function showModalNewProject(){
84 $('#modal_new_project').modal('show');
85 }
86
87 function deleteProject(url) {
88 bootbox.confirm("Are you sure want to delete?", function (result) {
89 if (result) {
90 $.ajax({
91 url: url,
92 type: 'GET',
93 headers: {
94 "Accept": 'application/json'
95 },
96 contentType: false,
97 processData: false
98 }).done(function (response,textStatus, jqXHR) {
99
100 bootbox.alert({
101 title: "Result",
102 message: "Project deleted.",
103 callback: function () {
104 location.reload();
105 }
106 });
107 }).fail(function(result){
108 var data = result.responseJSON;
109 var title = "Error " + (data.code ? data.code: 'unknown');
110 var message = data.detail ? data.detail: 'No detail available.';
111 bootbox.alert({
112 title: title,
113 message: message
114 });
115 });
116 }
117 })
118 }
119
120 $(document).ready(function () {
121 $("#formNewProject").submit(function (event) {
122 event.preventDefault(); //prevent default action
123 var post_url = $(this).attr("action"); //get form action url
124 var request_method = $(this).attr("method"); //get form GET/POST method
125 var form_data = new FormData(this); //Encode form elements for submission
126 console.log(post_url);
127 $.ajax({
128 url: post_url,
129 type: request_method,
130 data: form_data,
131 headers: {
132 "Accept": 'application/json'
133 },
134 contentType: false,
135 processData: false
136 }).done(function (response,textStatus, jqXHR) {
137 bootbox.alert({
138 title: "Result",
139 message: "Project created.",
140 callback: function () {
141 location.reload();
142 }
143 });
144 }).fail(function(result){
145 var data = result.responseJSON;
146 var title = "Error " + (data.code ? data.code: 'unknown');
147 var message = data.detail ? data.detail: 'No detail available.';
148 bootbox.alert({
149 title: title,
150 message: message
151 });
152 });
153 });
154 });
155
156
157
158
159 </script>
160
161
162 {% endblock %}