Skip to content

Commit

Permalink
webui: move formatEnabledDisabledStatus to custom-functions.js
Browse files Browse the repository at this point in the history
Move the formatEnabledDisabledStatus function to custom-functions.js
and use it in all places.
  • Loading branch information
fbergkemper committed Mar 12, 2020
1 parent 07f4e18 commit 31d8a12
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
8 changes: 0 additions & 8 deletions webui/module/Client/view/client/client/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,6 @@ $this->headTitle($title);

var clients = null;

function formatEnabledDisabledStatus(value) {
if(value) {
return '<span class="label label-success"><?php echo $this->translate("Enabled"); ?></span>';
} else {
return '<span class="label label-danger"><?php echo $this->translate("Disabled"); ?></span>';
}
}

function formatUname(value) {
if(value.toLowerCase().search("suse") > -1) {
return '<img src="<?php echo $this->basePath('img/icons/os/suse.png'); ?>" id="icon-os" title="'+value+'" data-toggle="tooltip" data-placement="top">';
Expand Down
11 changes: 1 addition & 10 deletions webui/module/Job/view/job/job/actions.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,6 @@ $this->headTitle($title);
return '<a href="<?php echo $this->basePath() . '/job/index?jobname='; ?>'+value+'">'+value+'</a>';
}

function formatStatusClient(value) {
if(value) {
return '<span class="label label-success"><?php echo $this->translate("Enabled"); ?></span>';
}
else {
return '<span class="label label-danger"><?php echo $this->translate("Disabled"); ?></span>';
}
}

function attachJobActionsTable() {
jobactions = $('#jobactions').bootstrapTable({
locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
Expand Down Expand Up @@ -172,7 +163,7 @@ $this->headTitle($title);
field: 'enabled',
sortable: true,
formatter: function(value) {
return formatStatusClient(value);
return formatEnabledDisabledStatus(value);
}
},
{
Expand Down
7 changes: 1 addition & 6 deletions webui/module/Schedule/view/schedule/schedule/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,7 @@ $this->headTitle($title);
field: 'enabled',
sortable: true,
formatter: function(value) {
if(value) {
return '<span class="label label-success"><?php echo $this->translate("Enabled"); ?></span>';
}
else {
return '<span class="label label-danger"><?php echo $this->translate("Disabled"); ?></span>';
}
return formatEnabledDisabledStatus(value);
}
},
{
Expand Down
8 changes: 8 additions & 0 deletions webui/public/js/custom-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,11 @@ function formatJobStatus(data) {
return output;
}

function formatEnabledDisabledStatus(value) {
if(value) {
return '<span class="label label-success">' + iJS._("Enabled") + '</span>';
} else {
return '<span class="label label-danger">' + iJS._("Disabled") + '</span>';
}
}

0 comments on commit 31d8a12

Please sign in to comment.