source: uz/src/UploadTest.vue@ 4b96189

Last change on this file since 4b96189 was 4b96189, checked in by js29a <js29a@…>, 2 years ago

project files have been added

  • Property mode set to 100644
File size: 4.2 KB
Line 
1<script setup lang="ts">
2
3import { ref, getCurrentInstance } from 'vue'
4
5import UploadZone from './UploadZone.vue'
6
7const inst = getCurrentInstance()
8
9const auto_start = ref(false)
10const auto_reset = ref(false)
11const keep_going = ref(false)
12const max_jobs = ref(3)
13
14const reset = (): void => {
15 (inst as any).refs.uploader.reset()
16}
17
18const start = (): void => {
19 (inst as any).refs.uploader.start()
20}
21
22</script>
23
24<template>
25 <component class='uploader' :is='UploadZone' target='https://vite.js29a.usermd.net/upload.php'
26 :max-jobs='max_jobs' :auto-start='auto_start' :auto-reset='auto_reset'
27 :keep-going='keep_going' ref='uploader'>
28 <template #idle='{ pick }'>
29 <div class='idle'>
30 idle
31 <br />
32 <button @click='pick()'>pick</button>
33 </div>
34 </template>
35
36 <template #hover>
37 <div class='hover'>
38 hover
39 </div>
40 </template>
41
42 <template #wait='{ start, queue }'>
43 <div class='wait'>
44 wait
45 <br />
46 <button @click='pick()'>pick</button>
47 <br />
48 <button @click='start()'>start</button>
49 <br/>
50 <div v-for='file in queue'>{{ file.name }}</div>
51 </div>
52 </template>
53
54 <template #uploading='{ progress, current, queue, abort, errors }'>
55 <div class='uploading'>
56 uploading
57 <br />
58 <button @click='abort()'>abort</button>
59 <br />
60 {{ progress.length }} / {{ current.length }} / {{ queue.length }}
61 <br />
62 <button @click='abort()'>abort</button>
63 <b>errors:</b> <span v-for='error in errors'>{{ error.file.name }}</span>
64 <b>progress:</b> <div v-for='item in progress'>{{ item }}</div>
65 <b>current:</b>
66 <div v-for='item in current'>
67 {{ item.file.name }}: {{ item.current }} of {{ item.total }}
68 </div>
69 <b>remaining:</b>
70 <div v-for='file in queue'>{{ file.name }}</div>
71 </div>
72 </template>
73
74 <template #done='{ result, reset }'>
75 <div class='done'>
76 done
77 <br />
78 <button @click='reset()'>reset</button>
79 <br />
80 <div v-for='item in result'>{{ item }}</div>
81 </div>
82 </template>
83
84 <template #error='{ error, reset }'>
85 <div class='error'>
86 error
87 <br />
88 <button @click='reset()'>reset</button>
89 <div>{{ error }}</div>
90 </div>
91 </template>
92
93 <template #aborted='{ result, reset }'>
94 <div class='aborted'>
95 aborted
96 <br />
97 <button @click='reset()'>reset</button>
98 <div v-for='item in result'>{{ item }}</div>
99 </div>
100 </template>
101
102 <template #with-errors='{ result, errors }'>
103 <div class='with-errors'>
104 with errors
105 <br />
106 <b>errors(s):</b>
107 <div v-for='item in errors'>{{ item.file.name }} / {{ item.error }}</div>
108 <b>ok:</b>
109 <div v-for='item in result'>{{ item }}</div>
110 </div>
111 </template>
112 </component>
113</template>
114
115<style scoped>
116
117.uploader {
118 border: 3px dashed #fff;
119 width: 512px;
120 height: 384px;
121 position: absolute;
122 border-radius: 20px;
123 top: 50%;
124 left: 50%;
125 transform: translate(-50%, -50%);
126}
127
128.idle,
129.hover,
130.wait,
131.uploading,
132.done,
133.error,
134.aborted,
135.with-errors {
136 width: 100%;
137 height: 100%;
138 border: 1px solid #0ff;
139 padding: 5px;
140 overflow: auto;
141}
142
143.status {
144 width: 25%;
145 height: auto;
146 background-color: #555;
147 color: #fff;
148 position: absolute;
149 right: 0px;
150 bottom: 0px;
151 padding: 2px 2px 2px 2px;
152 text-align: center;
153 font-weight: bold;
154 border-radius: 10px 0px 0px 0px;
155 border: 1px solid #0ff;
156 opacity: 0.75;
157}
158
159.idle {
160 background-color: #088;
161 color: black;
162}
163
164.hover {
165 background-color: #088;
166 color: white;
167 cursor: copy;
168}
169
170.wait {
171 background-color: #880;
172 color: black;
173}
174
175.uploading {
176 background-color: #050;
177 color: white;
178}
179
180.done {
181 background-color: #00f;
182 color: white;
183}
184
185.error {
186 background-color: #800;
187 color: white;
188}
189
190.aborted {
191 background-color: #300;
192 color: white;
193}
194
195.with-errors {
196 background-color: #800;
197 color: white;
198}
199
200</style>
201
Note: See TracBrowser for help on using the repository browser.