Skip to content

Commit

Permalink
webui: introduce storageResourceActionButtonsFormatter function
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed Mar 18, 2020
1 parent 5f466f7 commit 461657c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
22 changes: 3 additions & 19 deletions webui/module/Storage/view/storage/storage/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (c) 2013-2017 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (c) 2013-2020 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 @@ -91,20 +91,7 @@ $this->headTitle($title);

<script>

var storagedevices = null;

function storagedeviceActionButtonsFormatter(value, row, index) {

let deviceStatusButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/storage/status?storage='+row.name+'" title="<?php echo $this->translate("Status"); ?>" id="btn-1"><span class="glyphicon glyphicon-search"></span></a>';
let manageAutochangerButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath() . '/storage/details/'; ?>'+row.name+'" title="<?php echo $this->translate("Manage autochanger"); ?>" id="btn-1"><span class="glyphicon glyphicon-list-alt"></span></a>';

if(row.autochanger == "1") {
return devicesStatusButton + '&nbsp;' + manageAutochangerButton;
} else {
return deviceStatusButton;
}

}
var basePath = "<?php echo $this->basePath(); ?>";

function attachStorageDeviceTable() {
storagedevices = $('#storagedevices').bootstrapTable({
Expand Down Expand Up @@ -143,20 +130,17 @@ $this->headTitle($title);
{
field: 'action',
formatter: function(value, row, index) {
return storagedeviceActionButtonsFormatter(value, row, index);
return storageResourceActionButtonsFormatter(value, row, index, basePath);
}
}
]
});
}

$(document).ready(function() {

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

attachStorageDeviceTable();

});

</script>
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 @@ -703,3 +703,14 @@ function jobResourceActionButtonsFormatter(value, row, index, basePath) {
return runJobButton + '&nbsp;' + enableJobButton;
}
}

function storageResourceActionButtonsFormatter(value, row, index, basePath) {
let storageStatusButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="' + basePath + '/storage/status?storage=' + row.name + '" title="' + iJS._("Status") + '" id="btn-1"><span class="glyphicon glyphicon-search"></span></a>';
let manageAutochangerButton = '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="' + basePath + '/storage/details/' + row.name + '" title="' + iJS._("Manage autochanger") + '" id="btn-1"><span class="glyphicon glyphicon-list-alt"></span></a>';

if(row.autochanger == "1") {
return storageStatusButton + '&nbsp;' + manageAutochangerButton;
} else {
return storageStatusButton;
}
}

0 comments on commit 461657c

Please sign in to comment.