ed8b5831c9a672bb0949ef07e56f03ee0ef04c2c
[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 'osm/osm_project_left_sidebar.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 <th>Actions</th>
51 </tr>
52 </thead>
53 <tbody>
54 {% for p in projects %}
55 <tr>
56
57 <td>
58 <a href="/projects/switch/{{ p.name }}" >{{ p.name }}</a>
59 </td>
60
61 <td>{{ p|get_sub:"_admin,modified"|get_date}}</td>
62 <td>{{ p|get_sub:"_admin,created"|get_date}}</td>
63
64 <td>
65 <div class="btn-group">
66 <button type="button" class="btn btn-default dropdown-toggle"
67 data-toggle="dropdown" aria-expanded="false">Actions
68 <span class="fa fa-caret-down"></span></button>
69 <ul class="dropdown-menu">
70 <li><a href="#"
71 onclick="javascript:editProject('{% url 'projects:edit_project' project_id=p.name %}')">
72 <i class="fa fa-edit"></i> Rename</a></li>
73 <li>
74 <a href="#" onclick="javascript:deleteProject('{% url 'projects:delete_project' project_id=p.name%}')" style="color:red">
75 <i class="fa fa-trash" ></i> Delete</a>
76 </li>
77 </ul>
78 </div>
79 </td>
80 </tr>
81 {% endfor %}
82 </tbody>
83 </table>
84 </div>
85 </div>
86 </div>
87
88 </div>
89 {% include "modal/project_new.html" %}
90 {% include "modal/project_edit.html" %}
91 {% endblock %}
92
93 {% block resource_block %}
94 {{ block.super }}
95 <script>
96 function showModalNewProject(){
97 $('#modal_new_project').modal('show');
98 }
99
100 function editProject(url){
101 $("#formEditProject").attr("action", url);
102 $('#modal_edit_project').modal('show');
103 }
104
105 function deleteProject(url) {
106 bootbox.confirm("Are you sure want to delete?", function (result) {
107 if (result) {
108 $.ajax({
109 url: url,
110 type: 'GET',
111 headers: {
112 "Accept": 'application/json'
113 },
114 contentType: false,
115 processData: false
116 }).done(function (response,textStatus, jqXHR) {
117
118 bootbox.alert({
119 title: "Result",
120 message: "Project deleted.",
121 callback: function () {
122 location.reload();
123 }
124 });
125 }).fail(function(result){
126 var data = result.responseJSON;
127 var title = "Error " + (data.code ? data.code: 'unknown');
128 var message = data.detail ? data.detail: 'No detail available.';
129 bootbox.alert({
130 title: title,
131 message: message
132 });
133 });
134 }
135 })
136 }
137
138 $(document).ready(function () {
139 $("#formNewProject").submit(function (event) {
140 event.preventDefault(); //prevent default action
141 var post_url = $(this).attr("action"); //get form action url
142 var request_method = $(this).attr("method"); //get form GET/POST method
143 var form_data = new FormData(this); //Encode form elements for submission
144 console.log(post_url);
145 $.ajax({
146 url: post_url,
147 type: request_method,
148 data: form_data,
149 headers: {
150 "Accept": 'application/json'
151 },
152 contentType: false,
153 processData: false
154 }).done(function (response,textStatus, jqXHR) {
155 bootbox.alert({
156 title: "Result",
157 message: "Project created.",
158 callback: function () {
159 location.reload();
160 }
161 });
162 }).fail(function(result){
163 var data = result.responseJSON;
164 var title = "Error " + (data.code ? data.code: 'unknown');
165 var message = data.detail ? data.detail: 'No detail available.';
166 bootbox.alert({
167 title: title,
168 message: message
169 });
170 });
171 });
172 });
173
174
175
176
177 </script>
178
179
180 {% endblock %}