Fixed upload state in image uploads
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
class="image-upload-button ma-1"
|
class="image-upload-button ma-1"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:color="fileUploadError ? 'error' : undefined"
|
:color="fileUploadError ? 'error' : undefined"
|
||||||
:disabled="fileUploadInProgress"
|
:disabled="uploadingInProgress"
|
||||||
@click="$refs.hiddenFileInput.click()"
|
@click="$refs.hiddenFileInput.click()"
|
||||||
>
|
>
|
||||||
<v-icon left>
|
<v-icon left>
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
Upload Image
|
Upload Image
|
||||||
</template>
|
</template>
|
||||||
<v-progress-linear
|
<v-progress-linear
|
||||||
v-if="fileUploadInProgress"
|
v-if="uploadingInProgress"
|
||||||
:value="fileUploadProgress"
|
:value="uploadingInProgress"
|
||||||
:indeterminate="fileUploadIndeterminate"
|
:indeterminate="uploadIndeterminate"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
ref="hiddenFileInput"
|
ref="hiddenFileInput"
|
||||||
@@ -39,6 +39,7 @@ export default {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
file: undefined,
|
file: undefined,
|
||||||
uploadingInProgress: false,
|
uploadingInProgress: false,
|
||||||
|
fileUploadError: undefined,
|
||||||
}},
|
}},
|
||||||
watch: {
|
watch: {
|
||||||
file(file){
|
file(file){
|
||||||
@@ -50,41 +51,37 @@ export default {
|
|||||||
allowWebWorkers: true
|
allowWebWorkers: true
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
|
self.uploadingInProgress = true;
|
||||||
|
self.uploadIndeterminate = true;
|
||||||
|
|
||||||
uploadInstance.on('start', function () {
|
uploadInstance.on('start', function () {
|
||||||
console.log('Starting');
|
self.progress = 0;
|
||||||
this.uploadingInProgress = true;
|
self.uploadIndeterminate = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadInstance.on('end', function (error, fileObj) {
|
uploadInstance.on('end', function (error, fileObj) {
|
||||||
console.log('On end File Object: ', fileObj);
|
self.resetState();
|
||||||
this.uploadingInProgress = false;
|
|
||||||
self.$emit('uploaded', UserImages.link(fileObj));
|
self.$emit('uploaded', UserImages.link(fileObj));
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadInstance.on('uploaded', function (error, fileObj) {
|
uploadInstance.on('uploaded', function (error, fileObj) {
|
||||||
console.log('uploaded: ', fileObj);
|
|
||||||
|
|
||||||
// Remove the file from the input box
|
// Remove the file from the input box
|
||||||
self.file = undefined;
|
self.file = undefined;
|
||||||
|
self.resetState();
|
||||||
// Reset our state for the next file
|
|
||||||
self.uploadingInProgress = false;
|
|
||||||
self.progress = 0;
|
self.progress = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadInstance.on('error', function (error, fileObj) {
|
uploadInstance.on('error', function (error, fileObj) {
|
||||||
// Remove the file from the input box
|
// Remove the file from the input box
|
||||||
self.file = undefined;
|
self.file = undefined;
|
||||||
|
self.resetState();
|
||||||
// Reset our state for the next file
|
this.fileUploadError = error.reason || error.message || error.toString();
|
||||||
self.uploadingInProgress = false;
|
|
||||||
self.progress = 0;
|
|
||||||
console.log('Error during upload: ' + error, fileObj)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadInstance.on('progress', function (progress, fileObj) {
|
uploadInstance.on('progress', function (progress, fileObj) {
|
||||||
console.log('Upload Percentage: ' + progress, fileObj)
|
console.log('Upload Percentage: ' + progress, fileObj)
|
||||||
// Update our progress bar
|
// Update our progress bar with actual progress
|
||||||
|
self.uploadIndeterminate = false;
|
||||||
self.progress = progress;
|
self.progress = progress;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,7 +95,13 @@ export default {
|
|||||||
if (!selectedFiles) return;
|
if (!selectedFiles) return;
|
||||||
this.file = selectedFiles[0];
|
this.file = selectedFiles[0];
|
||||||
return;
|
return;
|
||||||
}
|
},
|
||||||
|
resetState() {
|
||||||
|
this.file = undefined;
|
||||||
|
this.uploadingInProgress = false;
|
||||||
|
this.progress = 0;
|
||||||
|
this.fileUploadError = undefined;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ export default {
|
|||||||
}
|
}
|
||||||
.image {
|
.image {
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
max-height: 400px;
|
max-height: 300px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
margin-bottom: -7px;
|
margin-bottom: -7px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ import ImageField from '/imports/client/ui/properties/viewers/shared/ImageField.
|
|||||||
import SmartImageInput from '/imports/client/ui/components/global/SmartImageInput.vue';
|
import SmartImageInput from '/imports/client/ui/components/global/SmartImageInput.vue';
|
||||||
|
|
||||||
// TODO Mark files that don't have versions.${version}.meta.pipePath set as broken links
|
// TODO Mark files that don't have versions.${version}.meta.pipePath set as broken links
|
||||||
|
// TODO show user images
|
||||||
|
// TODO delete, rename, etc. user images
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|||||||
Reference in New Issue
Block a user