Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Created by .ignore support plugin (hsz.mobi)
### ZendFramework template
# Composer files
composer.phar
vendor/

# Local configs
config/autoload/*.local.php

# Binary gettext files
*.mo

# Data
data/logs/
data/cache/
data/sessions/
data/tmp/
temp/

#Doctrine 2
data/DoctrineORMModule/Proxy/
data/DoctrineORMModule/cache/

# Legacy ZF1
demos/
extras/documentation

#custom
.idea/

22 changes: 22 additions & 0 deletions Block/Adminhtml/ActivityLogListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/

namespace KiwiCommerce\AdminActivity\Block\Adminhtml;

use Magento\Backend\Block\Template;
Expand Down Expand Up @@ -88,4 +89,25 @@ public function getAdminDetails()
$logData['date'] = $activity->getUpdatedAt();
return $logData;
}

/**
* @param $newValue
* @param $oldValue
* @return int
*
* Legend of return values:
* 0: Old value was modified
* 1: Value was created
* 2: Value was deleted
*/
public function compareValues($newValue, $oldValue)
{
if ($oldValue === '' && $newValue !== null) {
return 1;
} else if ($oldValue !== null && $newValue === '') {
return 2;
} else {
return 0;
}
}
}
8 changes: 4 additions & 4 deletions view/adminhtml/templates/activity/js.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
if(revertable == 1) {
jQuery(".action-revert-activity").show();
}

this.modal.modal('openModal');
this.autoResize();
},
Expand Down Expand Up @@ -118,13 +119,12 @@
});
},
autoResize: function () {
jQuery.each(jQuery('textarea.value-container'), function() {
jQuery.each(jQuery('span.value-container'), function() {
var offset = this.offsetHeight - this.clientHeight;
var resizeTextarea = function(el) {
console.log('You clicked me!!');
var resizeSpan = function(el) {
jQuery(el).css('height', 'auto').css('height', el.scrollHeight + offset);
};
jQuery(this).unbind().on('click', function() { resizeTextarea(this); }).trigger('click');
jQuery(this).unbind().on('click', function() { resizeSpan(this); }).trigger('click');
});
}
};
Expand Down
89 changes: 55 additions & 34 deletions view/adminhtml/templates/log_listing.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* @copyright Copyright (C) 2018 Kiwi Commerce Ltd (https://kiwicommerce.co.uk/)
* @license https://kiwicommerce.co.uk/magento2-extension-license/
*/
$collection = $block->getLogListing();
$adminDetails = $block->getAdminDetails();
$collection = $block->getLogListing();
$adminDetails = $block->getAdminDetails();
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
Expand All @@ -22,31 +22,31 @@
<td width="10%" style="font-size: 16px;font-weight: 600;">Admin</td>
<td width="1%" style="font-size: 16px;font-weight: 600;">:</td>
<td><?php if (!empty($adminDetails['username'])) {
echo $adminDetails['username'];
if (!empty($adminDetails['name'])) {
echo " (". ucwords(strtolower($adminDetails['name'])) .") ";
echo $adminDetails['username'];
if (!empty($adminDetails['name'])) {
echo " (" . ucwords(strtolower($adminDetails['name'])) . ") ";
}
}
}
?></td>
?></td>
</tr>
<tr style="height: 35px;text-indent: 10px;">
<td style="font-size: 16px;font-weight: 600;">Module</td>
<td width="1%" style="font-size: 16px;font-weight: 600;">: </td>
<td width="1%" style="font-size: 16px;font-weight: 600;">:</td>
<td><?php echo $adminDetails['module']; ?></td>
</tr>
<tr style="height: 35px;text-indent: 10px;">
<td style="font-size: 16px;font-weight: 600;">Action</td>
<td width="1%" style="font-size: 16px;font-weight: 600;">: </td>
<td width="1%" style="font-size: 16px;font-weight: 600;">:</td>
<td><?php echo $adminDetails['fullaction']; ?> </td>
</tr>
<tr style="height: 35px;text-indent: 10px;">
<td style="font-size: 16px;font-weight: 600;">User Agent</td>
<td width="1%" style="font-size: 16px;font-weight: 600;">: </td>
<td width="1%" style="font-size: 16px;font-weight: 600;">:</td>
<td style="text-indent: 0px;padding-left: 10px;"><?php echo $adminDetails['browser']; ?></td>
</tr>
<tr style="height: 35px;text-indent: 10px;">
<td style="font-size: 16px;font-weight: 600;">Date</td>
<td width="1%" style="font-size: 16px;font-weight: 600;">: </td>
<td width="1%" style="font-size: 16px;font-weight: 600;">:</td>
<td><?php echo $adminDetails['date']; ?></td>
</tr>
</table>
Expand All @@ -56,29 +56,50 @@
<td style="height: 35px;"></td>
</tr>
<?php if (!empty($collection)) { ?>
<tr>
<td>
<table border="1" width="100%" cellspacing="1" cellpadding="1">
<tr style="font-size: 16px;height: 50px;">
<th width="20%">Field Name</th>
<th width="40%">Old Value</th>
<th width="40%">New Value</th>
</tr>
<?php foreach ($collection as $item) { ?>
<tr style="height:45px; text-indent:10px;">
<td>
<?php $name = str_replace('_',' ',$item["field_name"]); echo ucfirst($name); ?>
</td>
<td>
<textarea class="value-container" readonly><?php if (!$block->activityRepository->isFieldProtected($item['field_name'])) { echo $block->escapeHtml($item['old_value']); } ?></textarea>
</td>
<td>
<textarea class="value-container" readonly><?php if (!$block->activityRepository->isFieldProtected($item['field_name'])) { echo $block->escapeHtml($item['new_value']); } ?></textarea>
</td>
<tr>
<td>
<table border="1" width="100%" cellspacing="1" id="log-listing-table" cellpadding="1">
<tr style="font-size: 16px;height: 50px;">
<th width="20%">Field Name</th>
<th width="40%">Old Value</th>
<th width="40%">New Value</th>
</tr>
<?php } ?>
</table>
</td>
</tr>
<?php foreach ($collection as $item) { ?>
<?php $compareResult = $block->compareValues($item['new_value'], $item['old_value']); ?>
<tr style="height:45px; text-indent:10px;">
<td>
<?php $name = str_replace('_', ' ', $item["field_name"]);
echo ucfirst($name); ?>
</td>
<td>
<span class="value-container" id="value-container-old"
readonly><?php if (!$block->activityRepository->isFieldProtected($item['field_name'])) {
echo $block->escapeHtml($item['old_value']);
} ?>
</span>
</td>
<td class="
<?php switch ($compareResult) {
case 0:
echo 'modified';
break;
case 1:
echo 'created';
break;
case 2:
echo 'deleted';
} ?>">
<span class="value-container"
id="value-container-new"
readonly><?php if (!$block->activityRepository->isFieldProtected($item['field_name'])) {
echo $block->escapeHtml($item['new_value']);
} ?>
</span>
</td>
</tr>
<?php } ?>
</table>
</td>
</tr>
<?php } ?>
</table>
18 changes: 15 additions & 3 deletions view/adminhtml/web/css/activity-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ textarea.value-container {
box-shadow: none;
height: auto;
outline: none;
display:block;
overflow:hidden;
}
display: block;
overflow: hidden;
}

#log-listing-table tbody tr td.created {
background-color: green;
}

#log-listing-table tbody tr td.deleted {
background-color: red;
}

#log-listing-table tbody tr td.modified {
background-color: yellow;
}