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">
33 <div class=
"box-header with-border">
34 <h3 class=
"box-title">Projects
</h3>
35 <div class=
"box-tools">
36 <button type=
"button" class=
"btn btn-default" data-container=
"body"
37 data-toggle=
"tooltip" data-placement=
"top" title=
"New Project"
38 onclick=
"javascript:showModalNewProject()">
39 <i class=
"fa fa-plus"></i> New Project
</button>
42 <div class=
"box-body">
43 <table id=
"projects_table" class=
"table table-bordered table-striped">
49 <th>Modification Date
</th>
50 <th>Creation Date
</th>
63 {% include
"modal/project_new.html" %}
64 {% include
"modal/project_edit.html" %}
67 {% block resource_block %}
69 <script src=
"/static/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
70 <script src=
"/static/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
73 $(document).ready( function () {
74 var table = $('#projects_table').DataTable({
77 "url":
"/projects/list",
78 "dataSrc": function (json) {
79 return json['projects'];
83 console.log(
"no auth");
84 moveToLogin(window.location.pathname);
87 "error": function (hxr, error, thrown) {
96 "render": function (data, type, row) {
97 return '
<a href=
"/projects/switch/'+row['name']+'" >'+row['name']+'
</a>'
102 "render": function (data, type, row) {
103 return moment.unix(row[
"_admin"]['modified']).format('YYYY-MM-DD hh:mm:ss a');
108 "render": function (data, type, row) {
109 return moment.unix(row[
"_admin"]['created']).format('YYYY-MM-DD hh:mm:ss a');
114 "render": function (data, type, row) {
115 return '
<div class=
"btn-group">\n' +
116 '
<button type=
"button" class=
"btn btn-default dropdown-toggle"\n' +
117 '
data-toggle=
"dropdown" aria-expanded=
"false">Actions\n' +
118 '
<span class=
"fa fa-caret-down"></span></button>\n' +
119 '
<ul class=
"dropdown-menu">\n' +
120 '
<li><a href=
"#"\n' +
121 '
onclick=
"javascript:editProject(\''+ row['name']+'\')">\n' +
122 '
<i class=
"fa fa-edit"></i> Rename
</a></li>\n' +
124 '
<a href=
"#" onclick=
"javascript:deleteProject(\''+ row['name']+'\')" style=
"color:red">\n' +
125 '
<i class=
"fa fa-trash" ></i> Delete
</a>\n' +
135 setInterval(function () {
141 function showModalNewProject(){
142 $('#modal_new_project').modal('show');
145 function editProject(project_id){
146 var url =
"/projects/" + project_id+
"/edit";
147 $(
"#formEditProject").attr(
"action", url);
148 $('#modal_edit_project').modal('show');
151 function deleteProject(project_id) {
152 var url =
"/projects/" + project_id+
"/delete";
153 bootbox.confirm(
"Are you sure want to delete?", function (result) {
159 "Accept": 'application/json'
163 }).done(function (response,textStatus, jqXHR) {
167 message:
"Project deleted.",
168 callback: function () {
172 }).fail(function(result){
173 var data = result.responseJSON;
174 var title =
"Error " + (data.code ? data.code: 'unknown');
175 var message = data.detail ? data.detail: 'No detail available.';
185 $(document).ready(function () {
186 $(
"#formNewProject").submit(function (event) {
187 event.preventDefault(); //prevent default action
188 var post_url = $(this).attr(
"action"); //get form action url
189 var request_method = $(this).attr(
"method"); //get form GET/POST method
190 var form_data = new FormData(this); //Encode form elements for submission
191 console.log(post_url);
194 type: request_method,
197 "Accept": 'application/json'
201 }).done(function (response,textStatus, jqXHR) {
204 message:
"Project created.",
205 callback: function () {
209 }).fail(function(result){
210 var data = result.responseJSON;
211 var title =
"Error " + (data.code ? data.code: 'unknown');
212 var message = data.detail ? data.detail: 'No detail available.';