Compare commits

...
Author SHA1 Message Date
haylanandClaude-Bot 5a482b49bb feat(dump): add date-range filter, sortable columns, and native date formatting to admin list
- Wires the backend from/to filter into the UI via sw-filter-panel with
  a hand-built date-filter config (no DAL entity needed — sw-filter-panel's
  only external dependency, filterService, persists through the generic
  user_config entity, not one for the filtered resource).
- Makes the datetime and sizeBytes columns sortable (ascending/descending)
  using the same Mixin.getByName('listing') core list pages use, which
  also persists sort state in the URL query string.
- Replaces the ad hoc `new Date(value).toLocaleString()` with
  Shopware.Utils.format.date, matching the existing fileSize formatting
  and respecting the admin's locale/timezone.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 12:39:23 +02:00
haylanandClaude-Bot 6094b6f49c test(dump): replace @dataProvider annotations with #[DataProvider] attributes
The installed PHPUnit (12.x, ahead of this plugin's ^10.0 dev
constraint) no longer parses the @dataProvider PHPDoc annotation,
so both tests silently ran their data-provider method with zero
arguments and failed with ArgumentCountError.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 12:39:08 +02:00
haylanandClaude-Bot e5c3a5b28f fix(dump): normalize date-filter bounds to the app timezone before applying day boundary
The admin date filter can send a naive local date string for "from" but
a UTC Z-suffixed instant for "to" (sw-date-filter widens it client-side
via Date#toISOString()). Comparing those directly against dump
timestamps (parsed in PHP's default timezone) shifted the effective
cutoff by the timezone offset. Re-express both bounds in the app's
default timezone before applying the day boundary.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 12:38:54 +02:00
haylan f967ef7544 feat(dump): filter admin dump list by from/to date range
Adds optional from/to query params to the dumps list endpoint and
DumpLister::list(), and bumps the plugin version to 0.0.2.
2026-09-17 12:38:39 +02:00
haylan 20492e8c80 chore(dump): removed cahche git ignored files 2026-09-15 06:23:40 +02:00
haylan 2c7a105332 chore(dump): removed cahche git ignored files 2026-09-15 06:21:44 +02:00
haylan 0401859227 feat(dump): update .gitignore for frontend assets and add changelog 2026-09-15 06:19:45 +02:00
haylan 2683792fee feat(dump): add download functionality for dumps and improve UI interactions 2026-09-14 23:54:57 +02:00
14 changed files with 392 additions and 87 deletions
+5
View File
@@ -12,6 +12,11 @@ composer.phar
/custom/ /custom/
/src/Shopware/Platform /src/Shopware/Platform
# Frontend
*.vite/
**/public/administration/js/
**/public/static/js/
# Environment # Environment
.env .env
.env.local .env.local
+3
View File
@@ -20,3 +20,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
creation runs synchronously. creation runs synchronously.
- ACL-gated (`aeon_dump_manager.viewer`/`.creator`/`.deleter`), enforced both client-side and - ACL-gated (`aeon_dump_manager.viewer`/`.creator`/`.deleter`), enforced both client-side and
server-side. server-side.
- Filter the dump list by a from/to date range, and sort the `datetime`/`sizeBytes` columns
ascending or descending. Dates are formatted with Shopware's locale/timezone-aware
`Shopware.Utils.format.date`, matching the existing `fileSize` formatting.
+1 -1
View File
@@ -3,7 +3,7 @@
"description": "Export database dumps for Shopware 6 environments.", "description": "Export database dumps for Shopware 6 environments.",
"type": "shopware-platform-plugin", "type": "shopware-platform-plugin",
"license": "MIT", "license": "MIT",
"version": "0.0.1", "version": "0.0.2",
"keywords": [ "keywords": [
"shopware", "shopware",
"shopware6", "shopware6",
+62 -2
View File
@@ -9,8 +9,12 @@ use AeonDumpManager\Service\DumpService;
use AeonDumpManager\Service\Exception\DumpNotFoundException; use AeonDumpManager\Service\Exception\DumpNotFoundException;
use Shopware\Core\Framework\Routing\ApiRouteScope; use Shopware\Core\Framework\Routing\ApiRouteScope;
use Shopware\Core\PlatformRequest; use Shopware\Core\PlatformRequest;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
@@ -36,16 +40,46 @@ class DumpController
defaults: [PlatformRequest::ATTRIBUTE_ACL => ['aeon_dump_manager.viewer']], defaults: [PlatformRequest::ATTRIBUTE_ACL => ['aeon_dump_manager.viewer']],
methods: ['GET'] methods: ['GET']
)] )]
public function list(): JsonResponse public function list(Request $request): JsonResponse
{ {
$dumps = array_map( $dumps = array_map(
static fn ($dumpFile) => $dumpFile->jsonSerialize(), static fn ($dumpFile) => $dumpFile->jsonSerialize(),
$this->dumpLister->list() $this->dumpLister->list(
$this->parseBoundDate($request->query->get('from'), false),
$this->parseBoundDate($request->query->get('to'), true),
)
); );
return new JsonResponse(['dumps' => $dumps]); return new JsonResponse(['dumps' => $dumps]);
} }
/**
* The admin's date filter sends mixed shapes: the "from" bound is a naive local
* date string with no timezone marker (e.g. "2026-03-01T00:00:00"), while
* sw-date-filter widens "to" to end-of-day client-side via `Date#toISOString()`,
* which is always UTC (e.g. "2026-03-01T23:59:59.000Z"). Re-expressing both in
* PHP's default timezone (the same one DumpFilenameParser uses) before applying
* our own day-boundary keeps the calendar day the user actually picked, regardless
* of which shape arrived. An empty bound (no date set) stays null so the range is
* open on that side.
*/
private function parseBoundDate(?string $value, bool $endOfDay): ?\DateTimeImmutable
{
if ($value === null || trim($value) === '') {
return null;
}
try {
$dateTime = (new \DateTimeImmutable($value))->setTimezone(new \DateTimeZone(date_default_timezone_get()));
} catch (\Exception) {
return null;
}
return $endOfDay
? $dateTime->setTime(23, 59, 59)
: $dateTime->setTime(0, 0, 0);
}
#[Route( #[Route(
path: '/api/_action/aeon-dump-manager/dumps', path: '/api/_action/aeon-dump-manager/dumps',
name: 'api.action.aeon_dump_manager.dumps.create', name: 'api.action.aeon_dump_manager.dumps.create',
@@ -77,6 +111,32 @@ class DumpController
return new JsonResponse(null, Response::HTTP_NO_CONTENT); return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} }
#[Route(
path: '/api/_action/aeon-dump-manager/dumps/{filename}/download',
name: 'api.action.aeon_dump_manager.dumps.download',
defaults: [PlatformRequest::ATTRIBUTE_ACL => ['aeon_dump_manager.viewer']],
methods: ['GET']
)]
public function download(string $filename): StreamedResponse
{
try {
$stream = $this->dumpService->readStream($filename);
} catch (DumpNotFoundException $exception) {
throw new NotFoundHttpException($exception->getMessage());
}
$response = new StreamedResponse(static function () use ($stream): void {
fpassthru($stream);
});
$response->headers->set('Content-Type', 'application/gzip');
$response->headers->set(
'Content-Disposition',
HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $filename)
);
return $response;
}
#[Route( #[Route(
path: '/api/_action/aeon-dump-manager/dumps/jobs/{jobId}', path: '/api/_action/aeon-dump-manager/dumps/jobs/{jobId}',
name: 'api.action.aeon_dump_manager.dumps.jobs.status', name: 'api.action.aeon_dump_manager.dumps.jobs.status',
@@ -4,6 +4,7 @@
<sw-button <sw-button
v-if="acl.can('aeon_dump_manager.creator')" v-if="acl.can('aeon_dump_manager.creator')"
variant="primary" variant="primary"
:is-loading="pendingJob !== null"
:disabled="pendingJob !== null" :disabled="pendingJob !== null"
@click="onCreate" @click="onCreate"
> >
@@ -12,54 +13,109 @@
</template> </template>
<template #content> <template #content>
<sw-card-view> <div class="aeon-dump-manager-list__content">
<sw-card> <sw-filter-panel
<sw-data-grid :filters="listFilters"
:data-source="dumps" :defaults="defaultFilters"
:columns="columns" :store-key="storeKey"
:is-loading="isLoading" @criteria-changed="onCriteriaChanged"
:show-selection="false" />
identifier="filename"
>
<template #before-item-list>
<tr v-if="pendingJob !== null" class="aeon-dump-manager-list__pending-row">
<td colspan="3">
<span>{{ $tc('aeon-dump-manager.list.creating') }}</span>
<sw-progress-bar :max-value="100" :value="pendingJob.percent || 0" />
</td>
</tr>
</template>
<template #column-datetime="{ item }"> <sw-data-grid
{{ formatDatetime(item.datetime) }} :data-source="sortedDumps"
</template> :columns="columns"
:is-loading="isLoading"
:show-selection="acl.can('aeon_dump_manager.deleter')"
:full-page="true"
:sort-by="sortBy"
:sort-direction="sortDirection"
identifier="filename"
@selection-change="onSelectionChange"
@column-sort="onSortColumn"
>
<template #bulk>
<a
v-if="acl.can('aeon_dump_manager.deleter')"
class="link link-danger aeon-dump-manager-list__bulk-delete"
role="button"
tabindex="0"
@click="onRequestBulkDelete"
@keydown.enter="onRequestBulkDelete"
>
{{ $tc('aeon-dump-manager.list.bulkDeleteButton', 0, { count: selectionCount }) }}
</a>
</template>
<template #column-sizeBytes="{ item }"> <template #column-datetime="{ item }">
{{ formatSize(item.sizeBytes) }} {{ formatDatetime(item.datetime) }}
</template> </template>
<template #actions="{ item }"> <template #column-sizeBytes="{ item }">
<sw-context-menu-item {{ formatSize(item.sizeBytes) }}
v-if="acl.can('aeon_dump_manager.deleter')" </template>
variant="danger"
@click="onRequestDelete(item.filename)"
>
{{ $tc('aeon-dump-manager.list.buttonDelete') }}
</sw-context-menu-item>
</template>
<template #empty-state> <template #actions="{ item }">
{{ $tc('aeon-dump-manager.list.empty') }} <sw-context-menu-item
</template> v-if="acl.can('aeon_dump_manager.viewer')"
</sw-data-grid> @click="onDownload(item.filename)"
</sw-card> >
</sw-card-view> {{ $tc('aeon-dump-manager.list.buttonDownload') }}
</sw-context-menu-item>
<sw-context-menu-item
v-if="acl.can('aeon_dump_manager.deleter')"
variant="danger"
@click="onRequestDelete(item.filename)"
>
{{ $tc('aeon-dump-manager.list.buttonDelete') }}
</sw-context-menu-item>
</template>
<template #empty-state>
{{ $tc('aeon-dump-manager.list.empty') }}
</template>
</sw-data-grid>
</div>
</template> </template>
{% block aeon_dump_manager_list_progress_modal %}
<sw-modal
v-if="pendingJob !== null"
:title="$tc('aeon-dump-manager.list.progressTitle')"
variant="small"
class="aeon-dump-manager-list__progress-modal"
@modal-close="onCloseProgressModal"
>
<div class="aeon-dump-manager-list__progress-wrapper">
<template v-if="pendingJob.status === 'done'">
<sw-alert variant="success">
{{ $tc('aeon-dump-manager.list.createSuccess') }}
</sw-alert>
</template>
<template v-else-if="pendingJob.status === 'failed'">
<sw-alert variant="error">
{{ $tc('aeon-dump-manager.list.createFailed', 0, { error: pendingJob.errorMessage || '' }) }}
</sw-alert>
</template>
<template v-else>
<sw-progress-bar
:value="pendingJob.percent || 0"
:max-value="100"
/>
<span class="aeon-dump-manager-list__progress-text">
{{ $tc('aeon-dump-manager.list.progressText') }}
</span>
</template>
</div>
</sw-modal>
{% endblock %}
<sw-confirm-modal <sw-confirm-modal
v-if="deleteFilename !== null" v-if="deleteFilenames !== null"
:title="$tc('aeon-dump-manager.list.confirmDeleteTitle')" :title="$tc('aeon-dump-manager.list.confirmDeleteTitle')"
:text="$tc('aeon-dump-manager.list.confirmDeleteText', 0, { filename: deleteFilename })" :text="deleteFilenames.length > 1
? $tc('aeon-dump-manager.list.confirmDeleteTextMultiple', 0, { count: deleteFilenames.length })
: $tc('aeon-dump-manager.list.confirmDeleteText', 0, { filename: deleteFilenames[0] })"
type="delete"
@confirm="onConfirmDelete" @confirm="onConfirmDelete"
@cancel="onCancelDelete" @cancel="onCancelDelete"
@close="onCancelDelete" @close="onCancelDelete"
@@ -1,7 +1,7 @@
import template from './aeon-dump-manager-list.html.twig'; import template from './aeon-dump-manager-list.html.twig';
import type DumpApiService, { DumpFile, DumpJob } from '../../../../service/dump-api.service'; import type DumpApiService, { DumpFile, DumpJob } from '../../../../service/dump-api.service';
const { Component } = Shopware; const { Component, Mixin } = Shopware;
interface PendingJob { interface PendingJob {
status: string; status: string;
@@ -9,12 +9,27 @@ interface PendingJob {
errorMessage?: string | null; errorMessage?: string | null;
} }
const CREATE_MODAL_AUTO_CLOSE_MS = 1500;
interface DateRangeCriteria {
type: string;
field: string;
parameters?: { gte?: string; lte?: string };
}
interface ComponentData { interface ComponentData {
dumps: DumpFile[]; dumps: DumpFile[];
isLoading: boolean; isLoading: boolean;
pendingJob: PendingJob | null; pendingJob: PendingJob | null;
deleteFilename: string | null; deleteFilenames: string[] | null;
selection: Record<string, DumpFile>;
pollTimer: number | null; pollTimer: number | null;
dateFrom: string | null;
dateTo: string | null;
sortBy: string;
sortDirection: string;
storeKey: string;
defaultFilters: string[];
} }
interface ComponentInstance extends ComponentData { interface ComponentInstance extends ComponentData {
@@ -22,14 +37,26 @@ interface ComponentInstance extends ComponentData {
$tc: (key: string, count?: number, values?: Record<string, unknown>) => string; $tc: (key: string, count?: number, values?: Record<string, unknown>) => string;
createNotificationError: (options: { message: string }) => void; createNotificationError: (options: { message: string }) => void;
createNotificationSuccess: (options: { message: string }) => void; createNotificationSuccess: (options: { message: string }) => void;
loadList: () => Promise<void>; getList: () => Promise<void>;
stopPolling: () => void; stopPolling: () => void;
pollJobStatus: (jobId: string) => void; pollJobStatus: (jobId: string) => void;
selectionCount: number;
sortedDumps: DumpFile[];
listFilters: Record<string, unknown>[];
} }
Component.register('aeon-dump-manager-list', { Component.register('aeon-dump-manager-list', {
template, template,
mixins: [
// Provides createNotificationSuccess/createNotificationError, used below.
Mixin.getByName('notification'),
// Provides sortBy/sortDirection state, onSortColumn(), and route-query
// persistence for them (same mixin sw-product-list etc. use) — our own
// data() below overrides the defaults to keep "newest first".
Mixin.getByName('listing'),
],
inject: ['aeonDumpManagerApiService', 'acl'], inject: ['aeonDumpManagerApiService', 'acl'],
data(): ComponentData { data(): ComponentData {
@@ -37,36 +64,87 @@ Component.register('aeon-dump-manager-list', {
dumps: [], dumps: [],
isLoading: false, isLoading: false,
pendingJob: null, pendingJob: null,
deleteFilename: null, deleteFilenames: null,
selection: {},
pollTimer: null, pollTimer: null,
dateFrom: null,
dateTo: null,
sortBy: 'datetime',
sortDirection: 'DESC',
storeKey: 'grid.filter.aeon-dump-manager',
defaultFilters: ['datetime'],
}; };
}, },
computed: { computed: {
listFilters(this: ComponentInstance) {
return [
{
name: 'datetime',
type: 'date-filter',
property: 'datetime',
label: this.$tc('aeon-dump-manager.list.columnDatetime'),
dateType: 'date',
fromFieldLabel: this.$tc('aeon-dump-manager.list.filterFromLabel'),
toFieldLabel: this.$tc('aeon-dump-manager.list.filterToLabel'),
fromPlaceholder: this.$tc('aeon-dump-manager.list.filterFromPlaceholder'),
toPlaceholder: this.$tc('aeon-dump-manager.list.filterToPlaceholder'),
showTimeframe: false,
},
];
},
columns() { columns() {
return [ return [
{ {
property: 'datetime', property: 'datetime',
dataIndex: 'datetime',
label: this.$tc('aeon-dump-manager.list.columnDatetime'), label: this.$tc('aeon-dump-manager.list.columnDatetime'),
allowResize: true, allowResize: true,
sortable: true,
}, },
{ {
property: 'filename', property: 'filename',
dataIndex: 'filename',
label: this.$tc('aeon-dump-manager.list.columnFilename'), label: this.$tc('aeon-dump-manager.list.columnFilename'),
allowResize: true, allowResize: true,
sortable: true,
}, },
{ {
property: 'sizeBytes', property: 'sizeBytes',
dataIndex: 'sizeBytes',
label: this.$tc('aeon-dump-manager.list.columnSize'), label: this.$tc('aeon-dump-manager.list.columnSize'),
align: 'right', align: 'right',
allowResize: true, allowResize: true,
sortable: true,
}, },
]; ];
}, },
},
created(this: ComponentInstance) { selectionCount(this: ComponentInstance): number {
this.loadList(); return Object.keys(this.selection).length;
},
sortedDumps(this: ComponentInstance): DumpFile[] {
const direction = this.sortDirection === 'ASC' ? 1 : -1;
return [...this.dumps].sort((a, b) => {
let compareVal: number;
switch (this.sortBy) {
case 'sizeBytes':
compareVal = a.sizeBytes - b.sizeBytes;
break;
case 'datetime':
compareVal = new Date(a.datetime).getTime() - new Date(b.datetime).getTime();
break;
default:
compareVal = a.filename.localeCompare(b.filename, undefined, { numeric: true });
}
return compareVal * direction;
});
},
}, },
beforeDestroy(this: ComponentInstance) { beforeDestroy(this: ComponentInstance) {
@@ -74,10 +152,10 @@ Component.register('aeon-dump-manager-list', {
}, },
methods: { methods: {
loadList(this: ComponentInstance): Promise<void> { getList(this: ComponentInstance): Promise<void> {
this.isLoading = true; this.isLoading = true;
return this.aeonDumpManagerApiService.getList() return this.aeonDumpManagerApiService.getList({ from: this.dateFrom, to: this.dateTo })
.then((response) => { .then((response) => {
this.dumps = response.dumps; this.dumps = response.dumps;
}) })
@@ -87,13 +165,25 @@ Component.register('aeon-dump-manager-list', {
}, },
formatDatetime(value: string): string { formatDatetime(value: string): string {
return new Date(value).toLocaleString(); return Shopware.Utils.format.date(value);
},
onCriteriaChanged(this: ComponentInstance, criteria: DateRangeCriteria[]) {
const range = criteria.find((filter) => filter.type === 'range' && filter.field === 'datetime');
this.dateFrom = range?.parameters?.gte ?? null;
this.dateTo = range?.parameters?.lte ?? null;
this.getList();
}, },
formatSize(bytes: number): string { formatSize(bytes: number): string {
return Shopware.Utils.format.fileSize(bytes); return Shopware.Utils.format.fileSize(bytes);
}, },
onSelectionChange(this: ComponentInstance, selection: Record<string, DumpFile>) {
this.selection = selection;
},
onCreate(this: ComponentInstance) { onCreate(this: ComponentInstance) {
this.pendingJob = { percent: 0, status: 'pending' }; this.pendingJob = { percent: 0, status: 'pending' };
@@ -102,10 +192,9 @@ Component.register('aeon-dump-manager-list', {
this.pollJobStatus(response.jobId); this.pollJobStatus(response.jobId);
}) })
.catch((error: Error) => { .catch((error: Error) => {
this.pendingJob = null; // Shown in the progress modal itself, not a notification —
this.createNotificationError({ // stays open so the user can actually read what went wrong.
message: this.$tc('aeon-dump-manager.list.createFailed', 0, { error: error.message }), this.pendingJob = { status: 'failed', percent: null, errorMessage: error.message };
});
}); });
}, },
@@ -114,24 +203,20 @@ Component.register('aeon-dump-manager-list', {
this.pollTimer = window.setInterval(() => { this.pollTimer = window.setInterval(() => {
this.aeonDumpManagerApiService.getJobStatus(jobId).then((job: DumpJob) => { this.aeonDumpManagerApiService.getJobStatus(jobId).then((job: DumpJob) => {
this.pendingJob = job;
if (job.status === 'done') { if (job.status === 'done') {
this.stopPolling(); this.stopPolling();
this.pendingJob = null; this.getList();
this.createNotificationSuccess({ message: this.$tc('aeon-dump-manager.list.createSuccess') }); window.setTimeout(() => {
this.loadList(); this.pendingJob = null;
}, CREATE_MODAL_AUTO_CLOSE_MS);
return; return;
} }
if (job.status === 'failed') { if (job.status === 'failed') {
this.stopPolling(); this.stopPolling();
this.pendingJob = null;
this.createNotificationError({
message: this.$tc('aeon-dump-manager.list.createFailed', 0, { error: job.errorMessage ?? '' }),
});
return;
} }
this.pendingJob = job;
}); });
}, 2000); }, 2000);
}, },
@@ -143,20 +228,62 @@ Component.register('aeon-dump-manager-list', {
} }
}, },
onCloseProgressModal(this: ComponentInstance) {
this.stopPolling();
this.pendingJob = null;
},
onDownload(this: ComponentInstance, filename: string) {
this.aeonDumpManagerApiService.download(filename)
.then((blob) => {
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
})
.catch((error: Error) => {
this.createNotificationError({
message: this.$tc('aeon-dump-manager.list.downloadFailed', 0, { error: error.message }),
});
});
},
onRequestDelete(this: ComponentInstance, filename: string) { onRequestDelete(this: ComponentInstance, filename: string) {
this.deleteFilename = filename; this.deleteFilenames = [filename];
},
onRequestBulkDelete(this: ComponentInstance) {
this.deleteFilenames = Object.keys(this.selection);
}, },
onCancelDelete(this: ComponentInstance) { onCancelDelete(this: ComponentInstance) {
this.deleteFilename = null; this.deleteFilenames = null;
}, },
onConfirmDelete(this: ComponentInstance): Promise<void> { onConfirmDelete(this: ComponentInstance): Promise<void> {
const filename = this.deleteFilename as string; const filenames = this.deleteFilenames as string[];
this.deleteFilename = null; this.deleteFilenames = null;
return this.aeonDumpManagerApiService.remove(filename) // Optimistic UI update: pull the rows out immediately rather than
.then(() => this.loadList()); // waiting on a full reload, so the grid never looks stale even if
// getList() is slow or a later delete in the batch fails.
this.dumps = this.dumps.filter((dumpFile) => !filenames.includes(dumpFile.filename));
this.selection = {};
return Promise.all(filenames.map((filename) => this.aeonDumpManagerApiService.remove(filename)))
.then(() => this.getList())
.catch((error: Error) => {
this.createNotificationError({
message: this.$tc('aeon-dump-manager.list.deleteFailed', 0, { error: error.message }),
});
// A delete failed after the optimistic removal — reload to
// show the real state rather than leave a wrong guess on screen.
return this.getList();
});
}, },
}, },
}); });
@@ -8,14 +8,24 @@
"columnFilename": "Name", "columnFilename": "Name",
"columnDatetime": "Erstellt am", "columnDatetime": "Erstellt am",
"columnSize": "Größe", "columnSize": "Größe",
"filterFromLabel": "Von",
"filterFromPlaceholder": "Startdatum auswählen...",
"filterToLabel": "Bis",
"filterToPlaceholder": "Enddatum auswählen...",
"buttonCreate": "Dump erstellen", "buttonCreate": "Dump erstellen",
"buttonDownload": "Herunterladen",
"buttonDelete": "Löschen", "buttonDelete": "Löschen",
"bulkDeleteButton": "Auswahl löschen ({count})",
"confirmDeleteTitle": "Dump löschen?", "confirmDeleteTitle": "Dump löschen?",
"confirmDeleteText": "Möchten Sie \"{filename}\" wirklich löschen? Dies kann nicht rückgängig gemacht werden.", "confirmDeleteText": "Möchten Sie \"{filename}\" wirklich löschen? Dies kann nicht rückgängig gemacht werden.",
"confirmDeleteTextMultiple": "Möchten Sie {count} Dumps wirklich löschen? Dies kann nicht rückgängig gemacht werden.",
"empty": "Keine Dumps gefunden.", "empty": "Keine Dumps gefunden.",
"creating": "Dump wird erstellt", "progressTitle": "Dump wird erstellt",
"progressText": "Dump wird erstellt…",
"createFailed": "Dump konnte nicht erstellt werden: {error}", "createFailed": "Dump konnte nicht erstellt werden: {error}",
"createSuccess": "Dump erstellt." "createSuccess": "Dump erstellt.",
"deleteFailed": "Dump konnte nicht gelöscht werden: {error}",
"downloadFailed": "Dump konnte nicht heruntergeladen werden: {error}"
} }
} }
} }
@@ -8,14 +8,24 @@
"columnFilename": "Name", "columnFilename": "Name",
"columnDatetime": "Created at", "columnDatetime": "Created at",
"columnSize": "Size", "columnSize": "Size",
"filterFromLabel": "From",
"filterFromPlaceholder": "Select start date...",
"filterToLabel": "To",
"filterToPlaceholder": "Select end date...",
"buttonCreate": "Create dump", "buttonCreate": "Create dump",
"buttonDownload": "Download",
"buttonDelete": "Delete", "buttonDelete": "Delete",
"bulkDeleteButton": "Delete selected ({count})",
"confirmDeleteTitle": "Delete dump?", "confirmDeleteTitle": "Delete dump?",
"confirmDeleteText": "Are you sure you want to delete \"{filename}\"? This cannot be undone.", "confirmDeleteText": "Are you sure you want to delete \"{filename}\"? This cannot be undone.",
"confirmDeleteTextMultiple": "Are you sure you want to delete {count} dumps? This cannot be undone.",
"empty": "No dumps found.", "empty": "No dumps found.",
"creating": "Creating dump", "progressTitle": "Creating dump",
"progressText": "Creating dump…",
"createFailed": "Could not create dump: {error}", "createFailed": "Could not create dump: {error}",
"createSuccess": "Dump created." "createSuccess": "Dump created.",
"deleteFailed": "Could not delete dump: {error}",
"downloadFailed": "Could not download dump: {error}"
} }
} }
} }
@@ -43,9 +43,12 @@ export default class DumpApiService extends ApiService {
super(httpClient, loginService, apiEndpoint); super(httpClient, loginService, apiEndpoint);
} }
getList(): Promise<DumpList> { getList(filter: { from?: string | null; to?: string | null } = {}): Promise<DumpList> {
return this.httpClient return this.httpClient
.get('/_action/aeon-dump-manager/dumps', { headers: this.getBasicHeaders() }) .get('/_action/aeon-dump-manager/dumps', {
headers: this.getBasicHeaders(),
params: { from: filter.from ?? undefined, to: filter.to ?? undefined },
})
.then((response: unknown) => ApiService.handleResponse(response)); .then((response: unknown) => ApiService.handleResponse(response));
} }
@@ -66,4 +69,13 @@ export default class DumpApiService extends ApiService {
.get(`/_action/aeon-dump-manager/dumps/jobs/${encodeURIComponent(jobId)}`, { headers: this.getBasicHeaders() }) .get(`/_action/aeon-dump-manager/dumps/jobs/${encodeURIComponent(jobId)}`, { headers: this.getBasicHeaders() })
.then((response: unknown) => ApiService.handleResponse(response)); .then((response: unknown) => ApiService.handleResponse(response));
} }
download(filename: string): Promise<Blob> {
return this.httpClient
.get(`/_action/aeon-dump-manager/dumps/${encodeURIComponent(filename)}/download`, {
headers: this.getBasicHeaders(),
responseType: 'blob',
})
.then((response: unknown) => ApiService.handleResponse(response) as Blob);
}
} }
File diff suppressed because one or more lines are too long
+9 -1
View File
@@ -18,7 +18,7 @@ class DumpLister
/** /**
* @return DumpFile[] newest first * @return DumpFile[] newest first
*/ */
public function list(): array public function list(?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): array
{ {
$dumps = []; $dumps = [];
@@ -33,6 +33,14 @@ class DumpLister
continue; continue;
} }
if ($from !== null && $datetime < $from) {
continue;
}
if ($to !== null && $datetime > $to) {
continue;
}
$dumps[] = new DumpFile($filename, $datetime, $item->fileSize()); $dumps[] = new DumpFile($filename, $datetime, $item->fileSize());
} }
+17
View File
@@ -71,6 +71,23 @@ class DumpService
$this->aeonDumpManagerFilesystemPrivate->delete($path); $this->aeonDumpManagerFilesystemPrivate->delete($path);
} }
/**
* @return resource
*/
public function readStream(string $filename)
{
if (!$this->filenameParser->isValid($filename)) {
throw DumpNotFoundException::create($filename);
}
$path = DumpLister::path($filename);
if (!$this->aeonDumpManagerFilesystemPrivate->fileExists($path)) {
throw DumpNotFoundException::create($filename);
}
return $this->aeonDumpManagerFilesystemPrivate->readStream($path);
}
public function enforceMaxDumps(): void public function enforceMaxDumps(): void
{ {
$maxDumps = $this->systemConfigService->getInt('AeonDumpManager.config.maxDumps'); $maxDumps = $this->systemConfigService->getInt('AeonDumpManager.config.maxDumps');
+2 -3
View File
@@ -3,6 +3,7 @@
namespace AeonDumpManager\Tests\Service; namespace AeonDumpManager\Tests\Service;
use AeonDumpManager\Service\DumpFilenameParser; use AeonDumpManager\Service\DumpFilenameParser;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class DumpFilenameParserTest extends TestCase class DumpFilenameParserTest extends TestCase
@@ -29,9 +30,7 @@ class DumpFilenameParserTest extends TestCase
self::assertEquals($dateTime, $this->parser->parse($filename)); self::assertEquals($dateTime, $this->parser->parse($filename));
} }
/** #[DataProvider('invalidFilenameProvider')]
* @dataProvider invalidFilenameProvider
*/
public function testParseRejectsInvalidFilenames(string $filename): void public function testParseRejectsInvalidFilenames(string $filename): void
{ {
self::assertNull($this->parser->parse($filename)); self::assertNull($this->parser->parse($filename));
+2 -3
View File
@@ -3,13 +3,12 @@
namespace AeonDumpManager\Tests\Service; namespace AeonDumpManager\Tests\Service;
use AeonDumpManager\Service\MySqlVariant; use AeonDumpManager\Service\MySqlVariant;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class MySqlVariantTest extends TestCase class MySqlVariantTest extends TestCase
{ {
/** #[DataProvider('versionProvider')]
* @dataProvider versionProvider
*/
public function testIsMariaDb(string $version, bool $expected): void public function testIsMariaDb(string $version, bool $expected): void
{ {
self::assertSame($expected, MySqlVariant::isMariaDb($version)); self::assertSame($expected, MySqlVariant::isMariaDb($version));