Skip to content

Commit 2b4f529

Browse files
Fix fe to refetch list on upload and be to enfore max backups
1 parent 6222b76 commit 2b4f529

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

client/src/components/Actions.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="flex flex-col items-end w-full">
33
<div class="flex justify-end">
4-
<upload :files="files" v-on:uploaded="handleFileUploaded" />
4+
<upload :files="files" />
55

66
<button
77
v-if="canCreateBackups.isPermitted"
@@ -37,7 +37,11 @@ export default {
3737
upload: UploadButton,
3838
"upload-status": UploadStatus,
3939
},
40-
40+
mounted(){
41+
this.$root.$on("uploaded", (file) => {
42+
this.files = this.files.filter((item) => item.file.uniqueIdentifier !== file.uniqueIdentifier)
43+
});
44+
},
4145
data() {
4246
return {
4347
files: [],
@@ -57,9 +61,6 @@ export default {
5761
},
5862
},
5963
methods: {
60-
handleFileUploaded(file) {
61-
this.files = this.files.filter((item) => item.file.uniqueIdentifier !== file.uniqueIdentifier)
62-
},
6364
backup() {
6465
this.loading = true;
6566
this.confirming = false;

client/src/components/Listing.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export default {
9292
mixins: [Listing],
9393
9494
mounted() {
95-
this.$on("onDestroyed", this.request);
95+
this.$on("onDestroyed", this.request); // refetch backup list after destroy is completed
96+
this.$root.$on("uploaded", this.request); // refetch backup list after upload is completed
9697
},
9798
watch: {
9899
status(newStatus, oldStatus) {

client/src/components/Upload.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default {
8989
this.resumable.on("fileSuccess", (file, event) => {
9090
const data = JSON.parse(event);;
9191
this.$toast.success(data.message);
92-
this.$emit("uploaded", file);
92+
this.$root.$emit("uploaded", file);
9393
});
9494
9595
this.resumable.on("fileError", (file, event) => {

src/Backuper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private function resolveMetaFromZip(Zipper $zip): Collection
121121
/**
122122
* Remove oldest backups when max backups is exceeded if it's present.
123123
*/
124-
private function enforceMaxBackups(): void
124+
public function enforceMaxBackups(): void
125125
{
126126
$maxBackups = config('backup.max_backups', false);
127127
if (!$maxBackups) {

src/Http/Controllers/UploadController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Illuminate\Http\JsonResponse;
88
use Illuminate\Http\Request;
9+
use Itiden\Backup\Backuper;
910
use Itiden\Backup\Contracts\Repositories\BackupRepository;
1011
use Itiden\Backup\DataTransferObjects\ChunkyTestDto;
1112
use Itiden\Backup\DataTransferObjects\ChunkyUploadDto;
@@ -14,12 +15,14 @@
1415

1516
final readonly class UploadController
1617
{
17-
public function __invoke(ChunkyUploadRequest $request, BackupRepository $repo): JsonResponse
18+
public function __invoke(ChunkyUploadRequest $request, BackupRepository $repo, Backuper $backuper): JsonResponse
1819
{
1920
return Chunky::put(ChunkyUploadDto::fromRequest($request), onCompleted: function (string $completeFile) use (
2021
$repo,
22+
$backuper,
2123
): void {
2224
$repo->add($completeFile);
25+
$backuper->enforceMaxBackups();
2326
});
2427
}
2528

0 commit comments

Comments
 (0)