Félix Marty
add dana
3f268e5
<!--
/*
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<!DOCTYPE html>
<html lang="en">
<%- include('../head') %>
<body class="nav-md">
<div class="container body">
<div class="main_container">
<%- include('sidebar') %>
<!-- top navigation -->
<div class="top_nav navbar-fixed-top">
<div class="nav_menu">
<nav class="" role="navigation">
<div class="nav toggle">
<a id="menu_toggle">
<i class="fa fa-bars"></i>
</a>
</div>
<ul class="nav navbar-nav">
<h3 id='page-title' class="navbar-text">
View projects</h3>
</ul>
</nav>
</div>
</div>
<!-- page content -->
<div class="right_col" role="main" style="padding-top: 50px;">
<!-- /top tiles -->
<div class="">
<div class="clearfix"></div>
<style>
td namedic {
width: 100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<br>
<br>
<div id='rowProjects' class="row">
<div id='rowTable' class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Projects
</h2>
<ul class="nav navbar-right panel_toolbox">
<!-- <li class="dropdown">
<a href="#download"><i class="fa fa-download"></i></a>
</li> -->
<li>
<button id='btnAddOneProject' type="button" class="btn btn-primary btn-xs active">Add a new project</button>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div id="noProjectssContent" class="x_content" hidden>
<p>No projects to show</p>
</div>
<div id="projectsContent" class="x_content" hidden>
<table id="projectsDatatable" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th style="width: 30%">ProjectId</th>
<th>Description</th>
<th style="width: 60px" class="no-sort"></th>
</tr>
</thead>
<tbody id='table_content'></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
<%- include('../footer') %>
<!-- jQuery -->
<script src="/third_party/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="/third_party/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="/third_party/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="/third_party/nprogress/nprogress.js"></script>
<!-- Datatables -->
<script src="/third_party/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="/third_party/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="/third_party/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
<script src="/third_party/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
<script src="/third_party/datatables.net-buttons/js/buttons.flash.min.js"></script>
<script src="/third_party/datatables.net-buttons/js/buttons.html5.min.js"></script>
<script src="/third_party/datatables.net-buttons/js/buttons.print.min.js"></script>
<script src="/third_party/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
<script src="/third_party/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
<script src="/third_party/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
<script src="/third_party/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
<script src="/third_party/datatables.net-scroller/js/dataTables.scroller.min.js"></script>
<!-- socket.io -->
<script src="/socket.io/socket.io.js"></script>
<!-- Custom Theme Scripts -->
<script src="/third_party/gentelella/build/js/custom.js"></script>
<script>
var debug = true;
var projects;
var dataTableObject;
var defLength = 10;
function projectsStart() {
socket = io();
socket.on('receiveFileInfo', function(req) {
if (debug)
console.log('receiveFileInfo', req);
NProgress.inc();
if (req.fileId === 'projects')
projects = req.file;
iAmReadyToProcessData();
});
socket.on('serverError', function(req) {
if (debug)
console.log('serverError', req);
alert(req)
});
if (debug)
console.log('getProjects');
NProgress.start();
socket.emit('getFileInfo', {
projectId: 'admin',
fileId: 'projects'
});
}
function iAmReadyToProcessData() {
NProgress.done();
$('#btnAddOneProject').click(function() {
window.open("/admin/addProject", "_parent");
})
var k = Object.keys(projects);
if (k.length === 0) {
$('#noProjectsContent').show();
$('#rowTable').show();
return;
}
projectsShowTable();
$('#projectsContent').show();
$('#rowTable').show();
}
function projectsShowTable(mode) {
if (dataTableObject !== undefined) {
dataTableObject.destroy();
}
var h = '';
var k = Object.keys(projects);
for (var ii = 0; ii < k.length; ii++) {
var s = projects[k[ii]];
h += '<tr>';
h += '<td>';
h += k[ii];
h += '</td>';
h += '<td>';
h += s.description;
h += '</td>';
h += '<td><center>';
h += '<div class="btn-group">';
h += '<button type="button" onclick="openViewProject(\'' + k[ii] + '\')" class="btn btn-primary btn-xs"><i class="fa fa-eye" aria-hidden="true"></i></button>';
h += '<button type="button" onclick="openEditProject(\'' + k[ii] + '\')" class="btn btn-danger btn-xs"><i class="fa fa-pencil" aria-hidden="true"></i></button>';
h += '<button type="button" onclick="openDeleteProject(\'' + k[ii] + '\')" class="btn btn-danger btn-xs"><i class="fa fa-trash" aria-hidden="true"></i></button>';
h += '</div>';
h += '</center></td>';
h += '</tr>';
}
$('#table_content').html(h);
dataTableObject = $('#projectsDatatable').DataTable({
"language": {
"decimal": "."
},
paging: true, // paging: true if > to 10 entries
info: true,
"bFilter": true,
"columnDefs": [{
"targets": 'no-sort',
"orderable": false
}],
"order": [
[2, "desc"]
],
"pageLength": defLength,
"lengthMenu": [
[
10,
15,
20,
25,
50, -1
],
[
10,
15,
20,
25,
50,
"All"
]
]
});
$('#projectsDatatable').on('length.dt', function(e, s, l) {
defLength = l;
});
}
$(document).ready(function() {
projectsStart();
});
function openViewProject(projectId) {
console.log('openViewProject', projectId)
if (projects[projectId].defaultPage)
window.open("/" + projectId + '/' + projects[projectId].defaultPage, "_parent");
else
window.open("/" + projectId + '/statusSeries', "_parent");
}
function openEditProject(projectId) {
console.log('openEditProject', projectId)
window.open("/admin/editProject?" + projectId, "_parent");
}
function openDeleteProject(projectId) {
console.log('openDeleteProject', projectId)
window.open("/admin/deleteProject?" + projectId, "_parent");
}
</script>
</div>
</div>
</body>
</html>