1 {% extends
"base.html" %}
8 <link rel=
"stylesheet" href=
"/static/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
11 {% block title_header_big %}
14 {% block left_sidebar %}
16 {% include 'osm/osm_project_left_sidebar.html' %}
21 {% block breadcrumb_body %}
23 <li><a href=
"{% url 'projects:projects_list' %}">Projects
</a></li>
26 {% block content_body %}
30 <div class=
"col-md-12">
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>
41 <div class=
"box-body">
42 <table id=
"projects_table" class=
"table table-bordered table-striped">
46 <th>Modification Date
</th>
47 <th>Creation Date
</th>
60 {% include
"modal/project_new.html" %}
61 {% include
"modal/project_edit.html" %}
64 {% block resource_block %}
66 <script src=
"/static/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
67 <script src=
"/static/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
71 $(document).ready( function () {
72 table = $('#projects_table').DataTable({
75 "url":
"/projects/list",
76 "dataSrc": function (json) {
77 return json['projects'];
81 console.log(
"no auth");
82 moveToLogin(window.location.pathname);
85 "error": function (hxr, error, thrown) {
94 "render": function (data, type, row) {
95 return '
<a href=
"/projects/'+row['name']+'/switch/" >'+row['name']+'
</a>'
100 "render": function (data, type, row) {
101 return moment.unix(row[
"_admin"]['modified']).format('YYYY-MM-DD hh:mm:ss a');
106 "render": function (data, type, row) {
107 return moment.unix(row[
"_admin"]['created']).format('YYYY-MM-DD hh:mm:ss a');
112 "render": function (data, type, row) {
113 return '
<div class=
"btn-group">\n' +
114 '
<button type=
"button" class=
"btn btn-default dropdown-toggle"\n' +
115 '
data-toggle=
"dropdown" aria-expanded=
"false">Actions\n' +
116 '
<span class=
"fa fa-caret-down"></span></button>\n' +
117 '
<ul class=
"dropdown-menu">\n' +
118 '
<li><a href=
"#"\n' +
119 '
onclick=
"javascript:editProject(\''+ row['name']+'\')">\n' +
120 '
<i class=
"fa fa-edit"></i> Rename
</a></li>\n' +
122 '
<a href=
"#" onclick=
"javascript:deleteProject(\''+ row['name']+'\')" style=
"color:red">\n' +
123 '
<i class=
"fa fa-trash" ></i> Delete
</a>\n' +
134 setInterval(function () {
140 function showModalNewProject(){
141 $('#modal_new_project').modal('show');
144 function editProject(project_id){
145 var url =
"/projects/" + project_id+
"/edit";
146 $(
"#formEditProject").attr(
"action", url);
147 $('#modal_edit_project').modal('show');
150 function deleteProject(project_id) {
151 var url =
"/projects/" + project_id+
"/delete";
152 bootbox.confirm(
"Are you sure want to delete?", function (result) {
158 "Accept": 'application/json'
162 }).done(function (response,textStatus, jqXHR) {
165 message:
"Project deleted.",
166 callback: function () {
170 }).fail(function(result){
171 var data = result.responseJSON;
172 var title =
"Error " + (data.code ? data.code: 'unknown');
173 var message = data.detail ? data.detail: 'No detail available.';
183 $(document).ready(function () {
184 $(
"#formNewProject").submit(function (event) {
185 event.preventDefault(); //prevent default action
186 var post_url = $(this).attr(
"action"); //get form action url
187 var request_method = $(this).attr(
"method"); //get form GET/POST method
188 var form_data = new FormData(this); //Encode form elements for submission
189 console.log(post_url);
192 type: request_method,
195 "Accept": 'application/json'
199 }).done(function (response,textStatus, jqXHR) {
202 message:
"Project created.",
203 callback: function () {
205 $('#modal_new_project').modal('hide');
208 }).fail(function(result){
209 var data = result.responseJSON;
210 var title =
"Error " + (data.code ? data.code: 'unknown');
211 var message = data.detail ? data.detail: 'No detail available.';
219 $(
"#formEditProject").submit(function(event){
220 event.preventDefault(); //prevent default action
221 var post_url = $(this).attr(
"action"); //get form action url
222 var request_method = $(this).attr(
"method"); //get form GET/POST method
223 var form_data = new FormData(this); //Encode form elements for submission
224 console.log(post_url);
227 type: request_method,
230 "Accept": 'application/json'
234 }).done(function (response,textStatus, jqXHR) {
237 message:
"Project updated.",
238 callback: function () {
240 $('#modal_edit_project').modal('hide');
243 }).fail(function(result){
244 var data = result.responseJSON;
245 var title =
"Error " + (data.code ? data.code: 'unknown');
246 var message = data.detail ? data.detail: 'No detail available.';