-
Notifications
You must be signed in to change notification settings - Fork 2k
/
App.vue
130 lines (120 loc) · 3.1 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<script setup>
import { Dashboard, DashboardModal, DragDrop, ProgressBar } from '@uppy/vue'
</script>
<template>
<div id="app">
<!-- <HelloWorld msg="Welcome to Uppy Vue Demo"/> -->
<h1>Welcome to Uppy Vue Demo!</h1>
<h2>Inline Dashboard</h2>
<label>
<input
type="checkbox"
:checked="showInlineDashboard"
@change="(event) => {
showInlineDashboard = event.target.checked
}"
/>
Show Dashboard
</label>
<Dashboard
v-if="showInlineDashboard"
:uppy="uppy"
:props="{
metaFields: [{ id: 'name', name: 'Name', placeholder: 'File name' }]
}"
/>
<h2>Modal Dashboard</h2>
<div>
<button @click="open = true">Show Dashboard</button>
<DashboardModal
:uppy="uppy2"
:open="open"
:props="{
onRequestCloseModal: handleClose
}"
/>
</div>
<h2>Drag Drop Area</h2>
<DragDrop
:uppy="uppy"
:props="{
locale: {
strings: {
chooseFile: 'Boop a file',
orDragDrop: 'or yoink it here'
}
}
}"
/>
<h2>Progress Bar</h2>
<ProgressBar
:uppy="uppy"
:props="{
hideAfterFinish: false
}"
/>
</div>
</template>
<script>
import Uppy from '@uppy/core'
import Transloadit from '@uppy/transloadit'
import { defineComponent } from 'vue'
import generateSignatureIfSecret from './generateSignatureIfSecret.js'
const {
VITE_TRANSLOADIT_KEY : TRANSLOADIT_KEY,
// Your Transloadit secret SHALL NOT be accessible in your Vue file, this is
// there for illustration purposes only.
VITE_TRANSLOADIT_SECRET : TRANSLOADIT_SECRET,
VITE_TRANSLOADIT_TEMPLATE : TRANSLOADIT_TEMPLATE,
VITE_TRANSLOADIT_SERVICE_URL : TRANSLOADIT_SERVICE_URL,
} = import.meta.env
async function getAssemblyOptions () {
return generateSignatureIfSecret(TRANSLOADIT_SECRET, {
auth: {
key: TRANSLOADIT_KEY,
},
// It's more secure to use a template_id and enable
// Signature Authentication
template_id: TRANSLOADIT_TEMPLATE,
})
}
export default defineComponent({
computed: {
uppy: () => new Uppy({ id: 'uppy1', autoProceed: true, debug: true })
.use(Transloadit, {
service: TRANSLOADIT_SERVICE_URL,
waitForEncoding: true,
getAssemblyOptions,
}),
uppy2: () => new Uppy({ id: 'uppy2', autoProceed: false, debug: true })
.use(Transloadit, {
service: TRANSLOADIT_SERVICE_URL,
waitForEncoding: true,
getAssemblyOptions,
}),
},
data () {
return {
open: false,
showInlineDashboard: false
}
},
methods: {
handleClose() { this.open = false }
},
})
</script>
<style src='@uppy/core/dist/style.css'></style>
<style src='@uppy/dashboard/dist/style.css'></style>
<style src='@uppy/drag-drop/dist/style.css'></style>
<style src='@uppy/progress-bar/dist/style.css'></style>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>