From 764c6f69ae8e212e40c7e192f6a08f3123c5bf10 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Tue, 4 Apr 2017 11:37:51 +0200 Subject: [PATCH] Adds a modal for error messages into different places 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. --- module/Media/src/Media/Model/MediaModel.php | 22 +++++++++++---- module/Media/view/media/media/details.phtml | 26 ++++++++++++++++++ module/Media/view/media/media/index.phtml | 29 ++++++++++++++++++-- module/Pool/src/Pool/Model/PoolModel.php | 10 +++++-- module/Pool/view/pool/pool/details.phtml | 30 +++++++++++++++++++-- 5 files changed, 106 insertions(+), 11 deletions(-) diff --git a/module/Media/src/Media/Model/MediaModel.php b/module/Media/src/Media/Model/MediaModel.php index 9b25a6e5..c3ff332c 100644 --- a/module/Media/src/Media/Model/MediaModel.php +++ b/module/Media/src/Media/Model/MediaModel.php @@ -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 @@ -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.'); @@ -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.'); diff --git a/module/Media/view/media/media/details.phtml b/module/Media/view/media/media/details.phtml index d49d056d..de76d290 100644 --- a/module/Media/view/media/media/details.phtml +++ b/module/Media/view/media/media/details.phtml @@ -111,6 +111,26 @@ $this->headTitle($title); echo $this->headLink()->prependStylesheet($this->basePath() . '/css/datatables.min.css'); ?> + + + +