Skip to content

Commit

Permalink
webui: move scheduleActionButtonsFormatter 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 a137133 commit 683ad85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
22 changes: 3 additions & 19 deletions webui/module/Schedule/view/schedule/schedule/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,11 @@ $this->headTitle($title);

<script>

var schedules = null;
var basePath = '<?php echo $this->basePath(); ?>';

function scheduleActionButtonsFormatter(value, row, index) {

let disableButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/schedule/index?action=disable&schedule='+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(); ?>/schedule/index?action=enable&schedule='+row.name+'" title="<?php echo $this->translate("Enable"); ?>" id="btn-1"><span class="glyphicon glyphicon-ok"></span></a>';

if(row.enabled) {
return disableButton;
} else {
return enableButton;
}

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

function attachSchedulesTable() {

schedules = $('#schedules').bootstrapTable({
$('#schedules').bootstrapTable({
locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
cookie: <?php echo $_SESSION['bareos']['dt_statesave']; ?>,
cookieIdTable: 'schedules_index',
Expand Down Expand Up @@ -165,7 +151,7 @@ $this->headTitle($title);
{
field: 'action',
formatter: function(value, row, index) {
return scheduleActionButtonsFormatter(value, row, index);
return scheduleActionButtonsFormatter(value, row, index, basePath);
}
}
]
Expand All @@ -177,8 +163,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
11 changes: 11 additions & 0 deletions webui/public/js/custom-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,17 @@ function clientsActionButtonsFormatter(value, row, index, basePath) {
}
}

function scheduleActionButtonsFormatter(value, row, index, basePath) {
let disableButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="' + basePath + '/schedule/index?action=disable&schedule=' + 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 + '/schedule/index?action=enable&schedule=' + row.name + '" title="' + iJS._("Enable") + '" id="btn-1"><span class="glyphicon glyphicon-ok"></span></a>';

if(row.enabled) {
return disableButton;
} else {
return enableButton;
}
}

function formatScheduleName(value, basePath) {
return '<a href="' + basePath + '/schedule/details?schedule=' + value + '">' + value + '</a>';
}
Expand Down

0 comments on commit 683ad85

Please sign in to comment.