File tree Expand file tree Collapse file tree 5 files changed +14
-9
lines changed
Expand file tree Collapse file tree 5 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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 ) => {
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff line change 66
77use Illuminate \Http \JsonResponse ;
88use Illuminate \Http \Request ;
9+ use Itiden \Backup \Backuper ;
910use Itiden \Backup \Contracts \Repositories \BackupRepository ;
1011use Itiden \Backup \DataTransferObjects \ChunkyTestDto ;
1112use Itiden \Backup \DataTransferObjects \ChunkyUploadDto ;
1415
1516final 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
You can’t perform that action at this time.
0 commit comments