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/select2/dist/css/select2.min.css">
25 <link rel=
"stylesheet" href=
"/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
28 {% block title_header_big %}
31 {% block left_sidebar %}
33 {% include 'osm/osm_project_left_sidebar.html' %}
38 {% block breadcrumb_body %}
40 {% if user.is_admin %}
41 <li><a href=
"{% url 'projects:projects_list' %}">Projects
</a></li>
43 <li><a href=
"#">Projects
</a></li>
47 {% block content_body %}
51 <div class=
"col-md-12">
53 <div class=
"box-header with-border">
54 <h3 class=
"box-title">Projects
</h3>
55 <div class=
"box-tools">
56 <button type=
"button" class=
"btn btn-default" data-container=
"body"
57 data-toggle=
"tooltip" data-placement=
"top" title=
"New Project"
58 onclick=
"javascript:showModalNewProject({'domains_list_url': '{% url "projects:domains_list
" %}'})">
59 <i class=
"fa fa-plus"></i> New Project
</button>
62 <div class=
"box-body">
63 <table id=
"projects_table" class=
"table table-bordered table-striped">
67 <th>Modification Date
</th>
68 <th>Creation Date
</th>
81 {% include
"modal/project_new.html" %}
82 {% include
"modal/project_edit.html" %}
85 {% block resource_block %}
87 <script src=
"/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
88 <script src=
"/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
89 <script src=
"/static/node_modules/select2/dist/js/select2.js"></script>
93 $(document).ready( function () {
94 table = $('#projects_table').DataTable({
97 "url":
"/projects/list",
98 "dataSrc": function (json) {
99 return json['projects'];
103 console.log(
"no auth");
104 moveToLogin(window.location.pathname);
107 "error": function (hxr, error, thrown) {
116 "render": function (data, type, row) {
117 return '
<a href=
"/projects/'+row['name']+'/switch/" >'+row['name']+'
</a>'
122 "render": function (data, type, row) {
123 return moment.unix(row[
"_admin"]['modified']).format('YYYY-MM-DD hh:mm:ss a');
128 "render": function (data, type, row) {
129 return moment.unix(row[
"_admin"]['created']).format('YYYY-MM-DD hh:mm:ss a');
134 "render": function (data, type, row) {
135 return '
<div class=
"btn-group">\n' +
136 '
<button type=
"button" class=
"btn btn-default dropdown-toggle"\n' +
137 '
data-toggle=
"dropdown" aria-expanded=
"false">Actions\n' +
138 '
<span class=
"fa fa-caret-down"></span></button>\n' +
139 '
<ul class=
"dropdown-menu">\n' +
140 '
<li><a href=
"#"\n' +
141 '
onclick=
"javascript:editProject(\''+ row['name']+'\')">\n' +
142 '
<i class=
"fa fa-edit"></i> Rename
</a></li>\n' +
144 '
<a href=
"#" onclick=
"javascript:deleteProject(\''+ row['name']+'\')" style=
"color:red">\n' +
145 '
<i class=
"fa fa-trash" ></i> Delete
</a>\n' +
156 setInterval(function () {
162 function showModalNewProject(args){
163 select2_groups = $('#domain_name').select2({
164 placeholder: 'Select Domain',
167 url: args.domains_list_url,
169 processResults: function (data) {
171 if (data['domains']) {
172 for (d in data['domains']) {
173 var domain = data['domains'][d];
174 if( domain.endsWith(':ro') === false) {
175 domains_list.push({ id: domain, text: domain })
182 results: domains_list
187 $('#modal_new_project').modal('show');
190 function editProject(project_id){
191 var url =
"/projects/" + project_id+
"/edit";
192 $(
"#formEditProject").attr(
"action", url);
193 $('#modal_edit_project').modal('show');
196 function deleteProject(project_id) {
197 var url =
"/projects/" + project_id+
"/delete";
198 bootbox.confirm(
"Are you sure want to delete?", function (result) {
204 "Accept": 'application/json'
208 }).done(function (response,textStatus, jqXHR) {
211 message:
"Project deleted.",
212 callback: function () {
216 }).fail(function(result){
217 var data = result.responseJSON;
218 var title =
"Error " + (data.code ? data.code: 'unknown');
219 var message = data.detail ? data.detail: 'No detail available.';
229 $(document).ready(function () {
230 $(
"#formNewProject").submit(function (event) {
231 event.preventDefault(); //prevent default action
232 var post_url = $(this).attr(
"action"); //get form action url
233 var request_method = $(this).attr(
"method"); //get form GET/POST method
234 var form_data = new FormData(this); //Encode form elements for submission
235 console.log(post_url);
238 type: request_method,
241 "Accept": 'application/json'
245 }).done(function (response,textStatus, jqXHR) {
248 message:
"Project created.",
249 callback: function () {
251 $('#modal_new_project').modal('hide');
254 }).fail(function(result){
255 var data = result.responseJSON;
256 var title =
"Error " + (data.code ? data.code: 'unknown');
257 var message = data.detail ? data.detail: 'No detail available.';
265 $(
"#formEditProject").submit(function(event){
266 event.preventDefault(); //prevent default action
267 var post_url = $(this).attr(
"action"); //get form action url
268 var request_method = $(this).attr(
"method"); //get form GET/POST method
269 var form_data = new FormData(this); //Encode form elements for submission
270 console.log(post_url);
273 type: request_method,
276 "Accept": 'application/json'
280 }).done(function (response,textStatus, jqXHR) {
283 message:
"Project updated.",
284 callback: function () {
286 $('#modal_edit_project').modal('hide');
289 }).fail(function(result){
290 var data = result.responseJSON;
291 var title =
"Error " + (data.code ? data.code: 'unknown');
292 var message = data.detail ? data.detail: 'No detail available.';