From 03a804331192d07854affe5337e8cd7f3d637321 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 8 Oct 2018 06:16:31 +0200 Subject: [PATCH] BasketController: show details, content checksum --- application/controllers/BasketController.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/application/controllers/BasketController.php b/application/controllers/BasketController.php index d079390b..2b18e4d9 100644 --- a/application/controllers/BasketController.php +++ b/application/controllers/BasketController.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Controllers; use dipl\Html\Link; use dipl\Web\Widget\NameValueTable; use Exception; +use Icinga\Date\DateFormatter; use Icinga\Module\Director\ConfigDiff; use Icinga\Module\Director\Core\Json; use Icinga\Module\Director\Db; @@ -130,11 +131,12 @@ class BasketController extends ActionController 'basket_uuid' => $binUuid, 'ts_create' => $this->params->getRequired('ts'), ], $this->db()); + $snapSum = bin2hex($snapshot->get('content_checksum')); $this->addTitle( $this->translate('%s: %s (Snapshot)'), $basket->get('basket_name'), - substr($hexUuid, 0, 7) + substr($snapSum, 0, 7) ); $this->actions()->add([ @@ -152,6 +154,13 @@ class BasketController extends ActionController ) ]); + $properties = new NameValueTable(); + $properties->addNameValuePairs([ + $this->translate('Created') => DateFormatter::formatDateTime($snapshot->get('ts_create') / 1000), + $this->translate('Content Checksum') => bin2hex($snapshot->get('content_checksum')), + ]); + $this->content()->add($properties); + if ($this->params->get('action') === 'restore') { $form = new RestoreBasketForm(); $form @@ -272,12 +281,12 @@ class BasketController extends ActionController } else { $connection = Db::fromResourceName($targetDbName); } - $object = $objects->$type->$key; + $objectFromBasket = $objects->$type->$key; $current = BasketSnapshot::instanceByIdentifier($type, $key, $connection); $this->content()->add( ConfigDiff::create( - Json::encode($object, JSON_PRETTY_PRINT), - Json::encode($current->export(), JSON_PRETTY_PRINT) + Json::encode($current->export(), JSON_PRETTY_PRINT), + Json::encode($objectFromBasket, JSON_PRETTY_PRINT) )->setHtmlRenderer('Inline') ); }