Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Client: Replace datatable with bootstrap-table-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed Jun 1, 2017
1 parent 862d079 commit 4ac48ca
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 303 deletions.
263 changes: 129 additions & 134 deletions module/Client/view/client/client/details.phtml
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos-webui for the canonical source repository
* @copyright Copyright (c) 2013-2015 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (c) 2013-2017 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -45,7 +45,7 @@ $this->headTitle($title);

<div class="panel-body">

<table class="table table-hover" id="tab-client">
<table class="table table-no-bordered table-hover" id="clientdetails">
<thead class="bg-primary">
<th><?php echo $this->translate("Name"); ?></th>
<th><?php echo $this->translate("Version"); ?></th>
Expand All @@ -71,7 +71,7 @@ $this->headTitle($title);

<div class="panel-body">

<table class="table table-hover" id="tab-backups">
<table class="table table-no-bordered table-hover" id="clientbackups">
<thead class="bg-primary">
<th><?php echo $this->translate("Job ID"); ?></th>
<th><?php echo $this->translate("Job name"); ?></th>
Expand All @@ -90,143 +90,138 @@ $this->headTitle($title);
</div>

<?php
echo $this->headScript()->prependFile($this->basePath() . '/js/datatables.plugins.js');
echo $this->headScript()->prependFile($this->basePath() . '/js/datatables.functions.js');
echo $this->headScript()->prependFile($this->basePath() . '/js/datatables.min.js');
echo $this->headLink()->prependStylesheet($this->basePath() . '/css/datatables.min.css');
echo $this->headLink()->prependStylesheet($this->basePath() . '/css/bootstrap-table.min.css');
echo $this->headScript()->prependFile($this->basePath() . '/js/bootstrap-table-locale-all.min.js');
echo $this->headScript()->prependFile($this->basePath() . '/js/bootstrap-table-cookie.min.js');
echo $this->headScript()->prependFile($this->basePath() . '/js/bootstrap-table.min.js');
?>

<script>

$(document).ready(function() {

setDtTextDomain('<?php echo $this->basePath() . '/js/locale'; ?>');
setDtLocale('<?php echo $_SESSION['bareos']['locale']; ?>');

$('#tab-client').DataTable( {
"ajax": {
"url": "<?php echo $this->url('client', array('action' => 'getData'), null) . '?data=details&client='.$this->client; ?>",
"dataSrc": ""
},
"language": {
"url": "<?php echo $this->basePath() . '/js/dataTables/language/'; ?>" + getLocale('<?php echo $_SESSION['bareos']['locale']; ?>')
},
"columns" : [
{ "data": "name" },
{ "data": "uname"},
{ "data": "autoprune" },
{ "data": "fileretention" },
{ "data": "jobretention" },
{ "data": "name" }
],
"paging": false,
"pagingType": "full_numbers",
"lengthMenu": [ <?php echo $_SESSION['bareos']['dt_lengthmenu']; ?> ],
"pageLength": <?php echo $_SESSION['bareos']['dt_pagelength']; ?>,
"stateSave": <?php echo $_SESSION['bareos']['dt_statesave']; ?>,
"ordering": false,
"info": false,
"bFilter": false,
"columnDefs": [
{
"targets": 2,
"render": function(data, type, full, meta) {
return formatAutoprune(data);
var clientdetails = null;
var clientbackups = null;

function getClientDetails() {
clientdetails = $('#clientdetails').bootstrapTable({
locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
cookie: <?php echo $_SESSION['bareos']['dt_statesave']; ?>,
cookieIdTable: 'dashboard_table_jobs_last_status',
url: '<?php echo $this->url('client', array('action' => 'getData'), null) . '?data=details&client='.$this->client; ?>',
method: 'get',
dataType: 'json',
columns: [
{
field: 'name',
},
{
field: 'uname',
},
{
field: 'autoprune',
formatter: function(value) {
return formatAutoprune(value);
}
},
{
field: 'fileretention',
formatter: function(value) {
return formatRetention(value);
}
},
{
field: 'jobretention',
formatter: function(value) {
return formatRetention(value);
}
},
{
field: 'action',
formatter: function(value) {
return '<a href="<?php echo $this->basePath() . '/restore/index?type=client&client='; ?>'+value+'"><button type="button" class="btn btn-default btn-xs" id="btn-1" data-toggle="tooltip" data-placement="top" title="<?php echo $this->translate("Restore"); ?>"><span class="glyphicon glyphicon-import"></span></button></a>&nbsp;<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/client/status?client='+value+'" title="<?php echo $this->translate("Status"); ?>" id="btn-1"><span class="glyphicon glyphicon-zoom-in"></span></a>';
}
}
},
{
"targets": 3,
"render": function(data, type, full, meta) {
return formatRetention(data);
]
});
}

function getClientBackups() {
clientbackups = $('#clientbackups').bootstrapTable({
locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
cookie: <?php echo $_SESSION['bareos']['dt_statesave']; ?>,
cookieIdTable: 'client_clientbackups',
url: '<?php echo $this->url('client', array('action' => 'getData'), null) . '?data=backups&client='.$this->client; ?>',
method: 'get',
dataType: 'json',
pagination : true,
sidePagination: 'client',
pageList: [ <?php echo $_SESSION['bareos']['dt_lengthmenu']; ?> ],
pageSize: <?php echo $_SESSION['bareos']['dt_pagelength']; ?>,
search: true,
showPaginationSwitch: true,
showColumns: true,
showRefresh: true,
sortName: 'jobid',
sortOrder: 'desc',
columns: [
{
field: 'jobid',
sortable: true,
formatter: function(value) {
return '<a href="<?php echo $this->basePath() . '/job/details/'; ?>'+value+'">'+value+'</a>';
}
},
{
field: 'name',
sortable: true,
formatter: function(value) {
return '<a href="<?php echo $this->basePath() . '/job/index?jobname='; ?>'+value+'">'+value+'</a>';
}
},
{
field: 'starttime',
sortable: true,
},
{
field: 'fileset',
sortable: true,
formatter: function(value, row, index) {
return '<a href="<?php echo $this->basePath(). '/fileset/details/'; ?>'+row.filesetid+'">'+row.fileset+'</a>';
}
},
{
field: 'level',
sortable: true,
formatter: function(value) {
return formatJobLevel(value);
}
},
{
field: 'jobfiles',
sortable: true,
},
{
field: 'jobbytes',
sortable: true,
formatter: function(value) {
return formatBytes(value);
}
},
{
field: 'action',
formatter: function(value, row, index) {
return '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/restore/?type=client&mergefilesets=1&mergejobs=1&client='+row.client+'&jobid='+row.jobid+'" title="<?php echo $this->translate("Show Files"); ?>" id="btn-1"><span class="glyphicon glyphicon-folder-open"></span></a>';
}
}
},
{
"targets": 4,
"render": function(data, type, full, meta) {
return formatRetention(data);
}
},
{
"targets": -1,
"render": function(data, type, full, meta) {
return '<a href="<?php echo $this->basePath() . '/restore/index?type=client&client='; ?>'+data+'"><button type="button" class="btn btn-default btn-xs" id="btn-1" data-toggle="tooltip" data-placement="top" title="<?php echo $this->translate("Restore"); ?>"><span class="glyphicon glyphicon-import"></span></button></a>&nbsp;<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/client/status?client='+data+'" title="<?php echo $this->translate("Status"); ?>" id="btn-1"><span class="glyphicon glyphicon-zoom-in"></span></a>';
}
}
]
} );

$('#tab-backups').DataTable( {
"ajax": {
"url": "<?php echo $this->url('client', array('action' => 'getData'), null) . '?data=backups&client='.$this->client; ?>",
"dataSrc": ""
},
"language": {
"url": "<?php echo $this->basePath() . '/js/dataTables/language/'; ?>" + getLocale('<?php echo $_SESSION['bareos']['locale']; ?>')
},
"columns" : [
{ "data": "jobid" },
{ "data": "name" },
{ "data": "starttime" },
{ "data": null },
{ "data": "level" },
{ "data": "jobfiles" },
{ "data": "jobbytes", "type": "file-size" },
{ "data": null },
],
"paging": true,
"ordering": true,
"info": true,
"pagingType": "full_numbers",
"stateSave": true,
"order": [[0, 'desc']],
"columnDefs": [
{
"targets": 0,
"render": function(data, type, full, meta) {
return '<a href="<?php echo $this->basePath() . '/job/details/'; ?>'+data+'">'+data+'</a>';
}
},
{
"targets": 1,
"render": function(data, type, full, meta) {
return '<a href="<?php echo $this->basePath() . '/job/index?jobname='; ?>'+data+'">'+data+'</a>';
}
},
{
"targets": 3,
"render": function(data, type, full, meta) {
return '<a href="<?php echo $this->basePath(). '/fileset/details/'; ?>'+data.filesetid+'">'+data.fileset+'</a>';
}
},
{
"targets": 4,
"render": function(data, type, full, meta) {
return formatJobLevel(data);
}
},
{
"targets": 6,
"render": function(data, type, full, meta) {
return formatBytes(data);
}
},
{
"targets": 7,
"render": function(data, type, full, meta) {
return '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/restore/?type=client&mergefilesets=1&mergejobs=1&client='+data.client+'&jobid='+data.jobid+'" title="<?php echo $this->translate("Show Files"); ?>" id="btn-1"><span class="glyphicon glyphicon-folder-open"></span></a>';
}
}
]
} );

$('#tab-client tbody').on('mouseover', '#btn-1', function () {
$('[data-toggle="tooltip"]').tooltip();
} );

$('#tab-backups tbody').on('mouseover', '#btn-1', function () {
$('[data-toggle="tooltip"]').tooltip();
} );

} );
]
});
}

$(document).ready(function() {
setDtTextDomain('<?php echo $this->basePath() . '/js/locale'; ?>');
setDtLocale('<?php echo $_SESSION['bareos']['locale']; ?>');
getClientDetails();
getClientBackups();
});

</script>

0 comments on commit 4ac48ca

Please sign in to comment.