Skip to content

Commit

Permalink
craft 5: initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
matfish3 committed Apr 13, 2024
1 parent 67ace5b commit e340cef
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes for Activity Log

## 2.0.0 - 2024-04-13
- Craft 5: Initial Release

## 1.7.0 - 2024-01-26
### Fixed
- Install Migration: Use dateTime()->notNull() instead of timestamp()
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"docs": "https://github.com/matfish2/craft-activity-log/blob/master/README.md"
},
"require": {
"craftcms/cms": "^4.0.0",
"craftcms/cms": "^5.0.0",
"ext-json": "*",
"nesbot/carbon": "^2.58"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function getCpNavItem(): ?array
$item['subnav'] = [
'logs' => ['label' => 'Logs', 'url' => 'activity-logs'],
'stats' => ['label' => 'Statistics', 'url' => 'activity-logs/stats'],
'actions' => ['label' => 'Actions', 'url' => 'activity-logs/actions']
// 'actions' => ['label' => 'Actions', 'url' => 'activity-logs/actions']
];

return $item;
Expand Down
29 changes: 25 additions & 4 deletions src/services/VueTablesActivityLogRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class VueTablesActivityLogRetriever
{
/**
* @throws \JsonException
*/
public function retrieve(): array
{
$req = \Craft::$app->request;
Expand All @@ -22,16 +25,34 @@ public function retrieve(): array
]);
$filters = $req->getQueryParam('query');
$createdAt = $req->getQueryParam('createdAt');
$createdAt = $createdAt ? json_decode($createdAt, true, 512, JSON_THROW_ON_ERROR) : null;

$filters = $filters ? json_decode($filters, true) : [];
if ($createdAt) {
if (is_string($createdAt)) {
$createdAt = json_decode($createdAt, true, 512, JSON_THROW_ON_ERROR);
}
} else {
$createdAt = null;
}


if ($filters) {
if (is_string($filters)) {
$filters = json_decode($filters, true, 512, JSON_THROW_ON_ERROR);
}
} else {
$filters = [];
}

$createdAtStart = $createdAt ? $createdAt['start'] : Carbon::today()->format('d/m/Y');
$createdAtEnd = $createdAt ? $createdAt['end'] : Carbon::today()->format('d/m/Y');
$start = Carbon::createFromFormat('d/m/Y', $createdAtStart)->startOfDay()->format('Y-m-d H:i:s');
$end = Carbon::createFromFormat('d/m/Y', $createdAtEnd)->endOfDay()->format('Y-m-d H:i:s');

$action = $req->getQueryParam('actionSegments');
$action = $action ? json_decode($action, true) : null;

if ($action && is_string($action)) {
$action = json_decode($action, true, 512, JSON_THROW_ON_ERROR);
}

$payload = $req->getQueryParam('payload');

Expand All @@ -51,7 +72,7 @@ public function retrieve(): array

foreach ($filters as $key => $value) {
if ($key === 'url') {
$q->andWhere("[[$key]] LIKE '%{$value}%' OR [[query]] LIKE '%{$value}%'");
$q = $q->andWhere("([[$key]] LIKE '%{$value}%' OR [[query]] LIKE '%{$value}%')");
} elseif ($key === 'responseCode') {
$valueEnd = $value + 99;
$q->andWhere("[[$key]]>=$value AND [[$key]]<=$valueEnd");
Expand Down
10 changes: 10 additions & 0 deletions src/templates/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,15 @@
<script>
window.cpTrigger = '{{ craft.app.config.general.cpTrigger }}';
</script>

<style>
/*Solves issue with actions dropdown being cut off*/
table.VueTables__table {
overflow:visible !important;
}
.table-responsive {
overflow:visible;
}
</style>
{% endblock %}

0 comments on commit e340cef

Please # to comment.