Skip to content

Commit

Permalink
webui: move clientsActionButtonsFormatter to custom-functions.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed Mar 12, 2020
1 parent 40eacee commit 3ebe742
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 31 deletions.
34 changes: 3 additions & 31 deletions webui/module/Client/view/client/client/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -123,36 +123,10 @@ $this->headTitle($title);
<script>

var basePath = "<?php echo $this->basePath(); ?>";
var clients = null;
function clientsActionButtonsFormatter(value, row, index) {

let restoreButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath() . '/restore/index?client='; ?>'+row.name+'" title="<?php echo $this->translate("Restore"); ?>" id="btn-1"><span class="glyphicon glyphicon-import"></span></a>';
let statusClientButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/client/status?client='+row.name+'" title="<?php echo $this->translate("Status"); ?>" id="btn-1"><span class="glyphicon glyphicon-search"></span></a>';
let disableButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/client/index?action=disable&client='+row.name+'" title="<?php echo $this->translate("Disable"); ?>" id="btn-1"><span class="glyphicon glyphicon-remove"></span></a>';
let enableButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/client/index?action=enable&client='+row.name+'" title="<?php echo $this->translate("Enable"); ?>" id="btn-1"><span class="glyphicon glyphicon-ok"></span></a>';
let downloadButton = '<a href="'+row.url_package+'" target="_blank"><button type="button" class="btn btn-default btn-xs" id="btn-1" data-toggle="tooltip" data-placement="top" title="Download update"><span class="glyphicon glyphicon-download-alt"></span></button></a>';

if(row.enabled) {
if(row.update_fd === true) {
return restoreButton + '&nbsp;' + statusClientButton + '&nbsp;' + disableButton + '&nbsp;' + downloadButton;
}
else {
return restoreButton + '&nbsp;' + statusClientButton + '&nbsp;' + disableButton;
}
}
else {
if(row.update_fd === true) {
return restoreButton + '&nbsp;' + statusClientButton + '&nbsp;' + enableButton + '&nbsp;' + downloadButton;
}
else {
return restoreButton + '&nbsp;' + statusClientButton + '&nbsp;' + enableButton;
}
}

}
var result = '<?php echo str_replace(array("\n","\r"), "", $this->result); ?>';

function attachClientsTable() {
clients = $('#clients').bootstrapTable({
$('#clients').bootstrapTable({
locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
cookie: <?php echo $_SESSION['bareos']['dt_statesave']; ?>,
cookieIdTable: 'client_clients',
Expand Down Expand Up @@ -199,7 +173,7 @@ $this->headTitle($title);
{
field: 'actions',
formatter: function(value, row, index) {
return clientsActionButtonsFormatter(value, row, index);
return clientsActionButtonsFormatter(value, row, index, basePath);
}
},
{
Expand All @@ -219,8 +193,6 @@ $this->headTitle($title);
setDtTextDomain('<?php echo $this->basePath() . '/js/locale'; ?>');
setDtLocale('<?php echo $_SESSION['bareos']['locale']; ?>');

var result = '<?php echo str_replace(array("\n","\r"), "", $this->result); ?>';

if(result.length > 0) {
$("#modal-001").modal();
}
Expand Down
25 changes: 25 additions & 0 deletions webui/public/js/custom-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,28 @@ function formatUpdateStatus(value, row, index) {
return '<span class="label label-success" id="label-fd-version" data-toggle="tooltip" data-placement="top" title="Up to date">'+row.installed_fd+'</span>';
}
}

function clientsActionButtonsFormatter(value, row, index, basePath) {
let restoreButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="' + basePath + '/restore/index?client=' + row.name + '" title="' + iJS._("Restore") + '" id="btn-1"><span class="glyphicon glyphicon-import"></span></a>';
let statusClientButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="' + basePath + '/client/status?client=' + row.name + '" title="' + iJS._("Status") + '" id="btn-1"><span class="glyphicon glyphicon-search"></span></a>';
let disableButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="' + basePath + '/client/index?action=disable&client=' + row.name + '" title="' + iJS._("Disable") + '" id="btn-1"><span class="glyphicon glyphicon-remove"></span></a>';
let enableButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="' + basePath + '/client/index?action=enable&client=' + row.name + '" title="' + iJS._("Enable") + '" id="btn-1"><span class="glyphicon glyphicon-ok"></span></a>';
let downloadButton = '<a href="' + row.url_package + '" target="_blank"><button type="button" class="btn btn-default btn-xs" id="btn-1" data-toggle="tooltip" data-placement="top" title="'+ iJS._("Download update") + '"><span class="glyphicon glyphicon-download-alt"></span></button></a>';

if(row.enabled) {
if(row.update_fd === true) {
return restoreButton + '&nbsp;' + statusClientButton + '&nbsp;' + disableButton + '&nbsp;' + downloadButton;
}
else {
return restoreButton + '&nbsp;' + statusClientButton + '&nbsp;' + disableButton;
}
}
else {
if(row.update_fd === true) {
return restoreButton + '&nbsp;' + statusClientButton + '&nbsp;' + enableButton + '&nbsp;' + downloadButton;
}
else {
return restoreButton + '&nbsp;' + statusClientButton + '&nbsp;' + enableButton;
}
}
}

0 comments on commit 3ebe742

Please sign in to comment.