Skip to content

Commit 2bbea2b

Browse files
wip
1 parent b2b9505 commit 2bbea2b

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

client/src/components/Backup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div>
2+
<div class="relative" id="statamic-backup">
33
<div class="flex">
44
<div class="flex flex-col mb-4">
55
<h1>{{ __("statamic-backup::backup.title") }}</h1>

client/src/components/Upload.vue

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<template>
2-
<div v-if="canCreateBackups.isPermitted && canUpload.isPermitted && canUpload.isPossible" ref="dropzone" class="btn mr-3">
3-
<svg-icon name="upload" class="h-4 w-4 mr-2 text-current" />
4-
<span>{{ __("statamic-backup::backup.upload.label") }}</span>
2+
<div>
3+
<div class="drag-notification" :class="{ 'hidden': !isDragging }" ref="dropzone">
4+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="h-12 w-12 m-4">
5+
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M.752 2.251a1.5 1.5 0 0 1 1.5-1.5m0 22.5a1.5 1.5 0 0 1-1.5-1.5m22.5 0a1.5 1.5 0 0 1-1.5 1.5m0-22.5a1.5 1.5 0 0 1 1.5 1.5m0 15.75v-1.5m0-3.75v-1.5m0-3.75v-1.5m-22.5 12v-1.5m0-3.75v-1.5m0-3.75v-1.5m5.25-5.25h1.5m3.75 0h1.5m3.75 0h1.5m-12 22.5h1.5m3.75 0h1.5m3.75 0h1.5m-6-5.25v-12m4.5 4.5-4.5-4.5-4.5 4.5"></path>
6+
</svg>
7+
<span>Drop File to Upload</span>
8+
</div>
9+
<div v-if="canCreateBackups.isPermitted && canUpload.isPermitted && canUpload.isPossible" ref="browse" class="btn mr-3">
10+
<svg-icon name="upload" class="h-4 w-4 mr-2 text-current" />
11+
<span>{{ __("statamic-backup::backup.upload.label") }}</span>
12+
</div>
513
</div>
614
</template>
715
<script>
@@ -19,6 +27,7 @@ export default {
1927
resumable: null,
2028
confirming: false,
2129
loading: false,
30+
isDragging: false,
2231
};
2332
},
2433
computed: {
@@ -62,21 +71,24 @@ export default {
6271
// Resumable.js isn't supported, fall back on a different method
6372
if (!this.resumable.support) return alert("Your browser doesn't support chunked uploads. Get a better browser.");
6473
74+
const backupElement = document.getElementById("statamic-backup");
6575
6676
this.$watch(
6777
(state) => {
6878
return state.canCreateBackups.isPermitted && state.canUpload.isPermitted && state.canUpload.isPossible
6979
},
7080
(newValue) => {
7181
if (newValue) {
72-
if (this.$refs.dropzone) {
73-
this.resumable.assignBrowse(this.$refs.dropzone);
74-
this.resumable.assignDrop(this.$refs.dropzone);
82+
if (this.$refs.browse) {
83+
this.resumable.assignBrowse(this.$refs.browse);
84+
this.resumable.assignDrop(backupElement);
7585
}
7686
}
7787
}
7888
);
7989
90+
this.resumable.handleDropEvent = console.log;
91+
8092
// set up event listeners to feed into vues reactivity
8193
this.resumable.on("fileAdded", (file, event) => {
8294
file.hasUploaded = false;
@@ -111,6 +123,19 @@ export default {
111123
const progress = file.progress();
112124
if (progress > localFile.progress) localFile.progress = progress;
113125
});
126+
127+
backupElement.addEventListener("dragover", (event) => {
128+
event.preventDefault();
129+
this.isDragging = true;
130+
});
131+
backupElement.addEventListener("dragleave", (event) => {
132+
event.preventDefault();
133+
this.isDragging = false;
134+
});
135+
backupElement.addEventListener("drop", (event) => {
136+
event.preventDefault();
137+
this.isDragging = false;
138+
});
114139
},
115140
};
116141
</script>

0 commit comments

Comments
 (0)