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

Commit

Permalink
Adds a modal for error messages into different places
Browse files Browse the repository at this point in the history
This displays a bootstrap modal in case of any error happens while retrieving
e.g. volume/media data via the getVolumes() function, 'llist volumes all',
in our media model.

API 2 result errors e.g. could happen in environments with a large number of
volumes/media due to the fact that the director daemon currently has a
limitation to deliver really long result messages.

It displays also a modal with error message if any errors occur while data is
fetched for the media details view, e.g. in case there are too many jobs
to list on a specific volume.

In addition, if any error occurs while fetching volumes of a specific pool,
there is now also a modal with the error message displayed.
  • Loading branch information
fbergkemper committed Apr 4, 2017
1 parent 9705f55 commit 764c6f6
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 11 deletions.
22 changes: 17 additions & 5 deletions module/Media/src/Media/Model/MediaModel.php
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-2016 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 @@ -33,8 +33,14 @@ public function getVolumes(&$bsock=null)
if(isset($bsock)) {
$cmd = 'llist volumes all';
$result = $bsock->send_command($cmd, 2, null);
$volumes = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $volumes['result']['volumes'];
if(preg_match('/Failed to send result as json. Maybe result message to long?/', $result)) {
$error = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $error['result']['error'];
}
else {
$volumes = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $volumes['result']['volumes'];
}
}
else {
throw new \Exception('Missing argument.');
Expand All @@ -59,8 +65,14 @@ public function getVolumeJobs(&$bsock=null, $volume=null)
if(isset($bsock, $volume)) {
$cmd = 'llist jobs volume="'.$volume.'"';
$result = $bsock->send_command($cmd, 2, null);
$volume = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $volume['result']['jobs'];
if(preg_match('/Failed to send result as json. Maybe result message to long?/', $result)) {
$error = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $error['result']['error'];
}
else {
$volume = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $volume['result']['jobs'];
}
}
else {
throw new \Exception('Missing argument.');
Expand Down
26 changes: 26 additions & 0 deletions module/Media/view/media/media/details.phtml
Expand Up @@ -111,6 +111,26 @@ $this->headTitle($title);
echo $this->headLink()->prependStylesheet($this->basePath() . '/css/datatables.min.css');
?>

<!-- modal-001 start -->
<div id="modal-001" class="modal fade modal-001" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel"><?php echo $this->translate("Failed to retrieve data from Bareos director"); ?></h4>
</div>
<div class="modal-body">
<p><?php echo $this->translate("Error message received from director:"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe the result message is too long?"); ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $this->translate("Close"); ?></button>
</div>
</div>
</div>
</div>
<!-- modal-001 end -->

<style>

td.details-control:after {
Expand Down Expand Up @@ -418,6 +438,12 @@ $(document).ready(function() {
]
});

$.fn.dataTable.ext.errMode = 'throw';

$('#voljobs').on('error.dt', function(e, settings, techNote, message) {
$("#modal-001").modal();
} );

} );

</script>
Expand Down
29 changes: 27 additions & 2 deletions module/Media/view/media/media/index.phtml
Expand Up @@ -5,9 +5,8 @@
* 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/)
* @author Frank Bergkemper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -78,6 +77,26 @@ $this->headTitle($title);
echo $this->headLink()->prependStylesheet($this->basePath() . '/css/datatables.min.css');
?>

<!-- modal-001 start -->
<div id="modal-001" class="modal fade modal-001" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel"><?php echo $this->translate("Failed to retrieve data from Bareos director"); ?></h4>
</div>
<div class="modal-body">
<p><?php echo $this->translate("Error message received from director:"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe the result message is too long?"); ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $this->translate("Close"); ?></button>
</div>
</div>
</div>
</div>
<!-- modal-001 end -->

<style>

td.details-control:after {
Expand Down Expand Up @@ -237,6 +256,12 @@ $(document).ready(function() {
}
} );

$.fn.dataTable.ext.errMode = 'throw';

$('#volumes').on('error.dt', function(e, settings, techNote, message) {
$("#modal-001").modal();
} );

} );

</script>
Expand Down
10 changes: 8 additions & 2 deletions module/Pool/src/Pool/Model/PoolModel.php
Expand Up @@ -77,8 +77,14 @@ public function getPoolMedia(&$bsock=null, $pool=null)
if(isset($bsock, $pool)) {
$cmd = 'llist media pool="'.$pool.'"';
$result = $bsock->send_command($cmd, 2, null);
$media = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $media['result']['volumes'];
if(preg_match('/Failed to send result as json. Maybe result message to long?/', $result)) {
$error = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $error['result']['error'];
}
else {
$media = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $media['result']['volumes'];
}
}
else {
throw new \Exception('Missing argument.');
Expand Down
30 changes: 28 additions & 2 deletions module/Pool/view/pool/pool/details.phtml
Expand Up @@ -5,9 +5,8 @@
* 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/)
* @author Frank Bergkemper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -110,6 +109,26 @@ $this->headTitle($title);
echo $this->headLink()->prependStylesheet($this->basePath() . '/css/datatables.min.css');
?>

<!-- modal-001 start -->
<div id="modal-001" class="modal fade modal-001" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel"><?php echo $this->translate("Failed to retrieve data from Bareos director"); ?></h4>
</div>
<div class="modal-body">
<p><?php echo $this->translate("Error message received from director:"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe the result message is too long?"); ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $this->translate("Close"); ?></button>
</div>
</div>
</div>
</div>
<!-- modal-001 end -->

<style>

td.details-control:after {
Expand Down Expand Up @@ -284,6 +303,13 @@ $(document).ready(function() {
tr.addClass('shown');
}
} );

$.fn.dataTable.ext.errMode = 'throw';

$('#volumes').on('error.dt', function(e, settings, techNote, message) {
$("#modal-001").modal();
} );

} );

</script>
Expand Down

0 comments on commit 764c6f6

Please sign in to comment.