@drax/media-vue 0.14.1 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.14.
|
|
6
|
+
"version": "0.14.2",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"vue-tsc": "^2.0.11",
|
|
62
62
|
"vuetify": "^3.7.1"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "6022bdf26c1775b837dc03e20aae732229eaebd4"
|
|
65
65
|
}
|
|
@@ -34,6 +34,9 @@ const {dir, readonly, timeout} = defineProps({
|
|
|
34
34
|
|
|
35
35
|
let fileInput = ref()
|
|
36
36
|
|
|
37
|
+
let loading = ref(false)
|
|
38
|
+
let errorMessage = ref()
|
|
39
|
+
|
|
37
40
|
function onFileClick() {
|
|
38
41
|
if(readonly){
|
|
39
42
|
return;
|
|
@@ -46,8 +49,20 @@ async function onFileChanged(e: Event) {
|
|
|
46
49
|
if (e.target && (e.target as HTMLInputElement).files) {
|
|
47
50
|
const files = (e.target as HTMLInputElement).files;
|
|
48
51
|
if (files && files[0]) {
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
try{
|
|
53
|
+
errorMessage.value = null
|
|
54
|
+
loading.value = true;
|
|
55
|
+
const file = await mediaSystem.uploadFile(files[0],dir, timeout);
|
|
56
|
+
valueModel.value = file.url;
|
|
57
|
+
}catch (error) {
|
|
58
|
+
console.error(error);
|
|
59
|
+
if(error instanceof Error){
|
|
60
|
+
errorMessage.value = error.message;
|
|
61
|
+
}
|
|
62
|
+
}finally {
|
|
63
|
+
loading.value = false;
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
}
|
|
52
67
|
}
|
|
53
68
|
}
|
|
@@ -91,6 +106,8 @@ defineEmits(['updateValue'])
|
|
|
91
106
|
@drop.prevent="handleDrop"
|
|
92
107
|
|
|
93
108
|
>
|
|
109
|
+
<v-alert v-if="errorMessage" type="error" closable>{{ errorMessage }}</v-alert>
|
|
110
|
+
|
|
94
111
|
<v-text-field
|
|
95
112
|
type="text"
|
|
96
113
|
:name="name"
|
|
@@ -110,6 +127,7 @@ defineEmits(['updateValue'])
|
|
|
110
127
|
:append-inner-icon="appendInnerIcon"
|
|
111
128
|
@update:modelValue="$emit('updateValue')"
|
|
112
129
|
@click:prepend-inner="onFileClick"
|
|
130
|
+
:loading="loading"
|
|
113
131
|
>
|
|
114
132
|
|
|
115
133
|
</v-text-field>
|
|
@@ -122,7 +140,7 @@ defineEmits(['updateValue'])
|
|
|
122
140
|
@change="onFileChanged"
|
|
123
141
|
>
|
|
124
142
|
|
|
125
|
-
<v-btn @click="onFileClick" density="compact" color="grey" variant="text">Click | Drag & Drop</v-btn>
|
|
143
|
+
<v-btn @click="onFileClick" :loading="loading" density="compact" color="grey" variant="text">Click | Drag & Drop</v-btn>
|
|
126
144
|
|
|
127
145
|
</div>
|
|
128
146
|
|
|
@@ -36,9 +36,11 @@ const {dir, readonly, timeout} = defineProps({
|
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
let fileInput = ref()
|
|
39
|
+
let loading = ref(false)
|
|
40
|
+
let errorMessage = ref()
|
|
39
41
|
|
|
40
42
|
function onFileClick() {
|
|
41
|
-
if(readonly){
|
|
43
|
+
if (readonly) {
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
46
|
fileInput.value.click();
|
|
@@ -51,15 +53,25 @@ async function onFileChanged(e: Event) {
|
|
|
51
53
|
if (e.target && (e.target as HTMLInputElement).files) {
|
|
52
54
|
const files = (e.target as HTMLInputElement).files;
|
|
53
55
|
if (files && files[0]) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
try {
|
|
57
|
+
errorMessage.value = null
|
|
58
|
+
loading.value = true;
|
|
59
|
+
const file = await mediaSystem.uploadFile(files[0], dir, timeout);
|
|
60
|
+
valueModel.value = file;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error(error);
|
|
63
|
+
if (error instanceof Error) {
|
|
64
|
+
errorMessage.value = error.message;
|
|
65
|
+
}
|
|
66
|
+
} finally {
|
|
67
|
+
loading.value = false;
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
71
|
}
|
|
60
72
|
|
|
61
73
|
const handleDrop = async (event: DragEvent) => {
|
|
62
|
-
if(readonly){
|
|
74
|
+
if (readonly) {
|
|
63
75
|
return;
|
|
64
76
|
}
|
|
65
77
|
isDragOver.value = false;
|
|
@@ -90,15 +102,15 @@ defineEmits(['updateValue'])
|
|
|
90
102
|
|
|
91
103
|
<template>
|
|
92
104
|
<div
|
|
93
|
-
|
|
94
105
|
:class="{ 'drop-zone': true, 'dragover': isDragOver }"
|
|
95
106
|
@dragenter.prevent="handleDragEnter"
|
|
96
107
|
@dragover.prevent="handleDragOver"
|
|
97
108
|
@dragleave.prevent="handleDragLeave"
|
|
98
109
|
@drop.prevent="handleDrop"
|
|
99
|
-
|
|
100
110
|
>
|
|
101
111
|
|
|
112
|
+
<v-alert v-if="errorMessage" type="error" closable>{{ errorMessage }}</v-alert>
|
|
113
|
+
|
|
102
114
|
<v-text-field
|
|
103
115
|
type="text"
|
|
104
116
|
:name="name"
|
|
@@ -118,6 +130,7 @@ defineEmits(['updateValue'])
|
|
|
118
130
|
:append-inner-icon="appendInnerIcon"
|
|
119
131
|
@update:modelValue="$emit('updateValue')"
|
|
120
132
|
@click:prepend-inner="onFileClick"
|
|
133
|
+
:loading="loading"
|
|
121
134
|
>
|
|
122
135
|
|
|
123
136
|
</v-text-field>
|
|
@@ -130,7 +143,7 @@ defineEmits(['updateValue'])
|
|
|
130
143
|
@change="onFileChanged"
|
|
131
144
|
>
|
|
132
145
|
|
|
133
|
-
<v-btn @click="onFileClick" density="compact" color="grey" variant="text">Click | Drag & Drop</v-btn>
|
|
146
|
+
<v-btn @click="onFileClick" :loading="loading" density="compact" color="grey" variant="text">Click | Drag & Drop</v-btn>
|
|
134
147
|
|
|
135
148
|
</div>
|
|
136
149
|
|