quasar-ui-danx 0.3.37 → 0.3.39
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/dist/danx.es.js +452 -449
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +4 -6
- package/dist/danx.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ActionTable/Form/Fields/FileUploadButton.vue +4 -0
- package/src/helpers/FileUpload.ts +36 -29
- package/src/helpers/download.ts +28 -37
package/package.json
CHANGED
@@ -60,6 +60,7 @@ function upload() {
|
|
60
60
|
* @returns {Promise<void>}
|
61
61
|
*/
|
62
62
|
async function onAttachFiles({ target: { files } }) {
|
63
|
+
console.log("files attached", files);
|
63
64
|
emit("uploading", files);
|
64
65
|
let fileUpload = new FileUpload(files)
|
65
66
|
.onProgress(({ file, progress }) => {
|
@@ -73,6 +74,9 @@ async function onAttachFiles({ target: { files } }) {
|
|
73
74
|
emit("complete", fileUpload.files);
|
74
75
|
});
|
75
76
|
|
77
|
+
console.log("created fileUpload", fileUpload);
|
78
|
+
|
79
|
+
debugger;
|
76
80
|
if (props.geolocation) {
|
77
81
|
await fileUpload.resolveLocation(props.locationWaitMessage);
|
78
82
|
}
|
@@ -270,36 +270,43 @@ export class FileUpload {
|
|
270
270
|
async upload() {
|
271
271
|
console.log && console.log("FileUploader@upload():", this.fileUploads, this.options);
|
272
272
|
for (const fileUpload of this.fileUploads) {
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
273
|
+
try {
|
274
|
+
const mimeType = fileUpload.file.mimeType || fileUpload.file.type;
|
275
|
+
const presignedUrl = this.options.presignedUploadUrl(this.options.directory, fileUpload.file.name, mimeType);
|
276
|
+
|
277
|
+
console.log("calling presigned URL", presignedUrl);
|
278
|
+
|
279
|
+
// Fetch presigned upload URL
|
280
|
+
const fileResource = await fetch(presignedUrl).then(r => r.json());
|
281
|
+
|
282
|
+
if (!fileResource.url) {
|
283
|
+
FlashMessages.error("Could not fetch presigned upload URL for file " + fileUpload.file.name);
|
284
|
+
continue;
|
285
|
+
}
|
286
|
+
|
287
|
+
const isS3Upload = !fileResource.url.match("upload-presigned-url-contents");
|
288
|
+
|
289
|
+
// We need the file resource ID to complete the presigned upload
|
290
|
+
fileUpload.file.resource_id = fileResource.id;
|
291
|
+
|
292
|
+
// Prepare XHR request
|
293
|
+
const xhr = new XMLHttpRequest();
|
294
|
+
|
295
|
+
// The XHR request is different based on weather we're sending to S3 or the platform server
|
296
|
+
if (isS3Upload) {
|
297
|
+
xhr.open("PUT", fileResource.url);
|
298
|
+
xhr.setRequestHeader("Content-Type", mimeType);
|
299
|
+
fileUpload.body = fileUpload.file;
|
300
|
+
} else {
|
301
|
+
xhr.open("POST", fileResource.url);
|
302
|
+
fileUpload.body = fileUpload.formData;
|
303
|
+
}
|
304
|
+
|
305
|
+
fileUpload.xhr = xhr;
|
306
|
+
} catch (error) {
|
307
|
+
console.error && console.error("FileUploader@upload():", "Failed to fetch presigned upload URL", error);
|
308
|
+
this.errorHandler(null, fileUpload.file, error);
|
300
309
|
}
|
301
|
-
|
302
|
-
fileUpload.xhr = xhr;
|
303
310
|
}
|
304
311
|
|
305
312
|
// Set all the callbacks on the XHR requests
|
package/src/helpers/download.ts
CHANGED
@@ -114,58 +114,49 @@ export function download(data, strFileName, strMimeType) {
|
|
114
114
|
}
|
115
115
|
|
116
116
|
function saver(url, winMode) {
|
117
|
+
// Detect Chrome on iPhone (or any iOS device using WebKit)
|
118
|
+
const isIOSChrome =
|
119
|
+
/CriOS/.test(navigator.userAgent) && /iP(hone|od|ad)/.test(navigator.platform);
|
120
|
+
|
121
|
+
if (isIOSChrome) {
|
122
|
+
window.open(url, "_blank");
|
123
|
+
|
124
|
+
return true;
|
125
|
+
}
|
126
|
+
|
117
127
|
if ("download" in anchor) {
|
118
|
-
//
|
128
|
+
// HTML5 A[download]
|
119
129
|
anchor.href = url;
|
120
130
|
anchor.setAttribute("download", fileName);
|
121
|
-
anchor.className = "download-js-link";
|
122
|
-
anchor.innerHTML = "downloading...";
|
123
131
|
anchor.style.display = "none";
|
124
|
-
anchor.target = "_blank";
|
125
132
|
document.body.appendChild(anchor);
|
126
|
-
|
133
|
+
|
134
|
+
setTimeout(() => {
|
127
135
|
anchor.click();
|
128
136
|
document.body.removeChild(anchor);
|
137
|
+
|
129
138
|
if (winMode === true) {
|
130
|
-
setTimeout(
|
131
|
-
|
139
|
+
setTimeout(() => {
|
140
|
+
URL.revokeObjectURL(anchor.href); // Release the Object URL
|
132
141
|
}, 250);
|
133
142
|
}
|
134
|
-
},
|
135
|
-
return true;
|
136
|
-
}
|
143
|
+
}, 0);
|
137
144
|
|
138
|
-
// handle non-a[download] safari as best we can:
|
139
|
-
if (
|
140
|
-
/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)
|
141
|
-
) {
|
142
|
-
url = url.replace(/^data:([\w/\-+]+)/, defaultMime);
|
143
|
-
if (!window.open(url)) {
|
144
|
-
// popup blocked, offer direct download:
|
145
|
-
if (
|
146
|
-
confirm(
|
147
|
-
"Displaying New Document\n\nUse Save As... to download, then click back to return to this page."
|
148
|
-
)
|
149
|
-
) {
|
150
|
-
location.href = url;
|
151
|
-
}
|
152
|
-
}
|
153
145
|
return true;
|
154
146
|
}
|
155
147
|
|
156
|
-
//
|
157
|
-
|
158
|
-
|
148
|
+
// General fallback for unsupported browsers
|
149
|
+
const fallbackIframe = document.createElement("iframe");
|
150
|
+
fallbackIframe.style.display = "none";
|
151
|
+
fallbackIframe.src = url;
|
152
|
+
document.body.appendChild(fallbackIframe);
|
159
153
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
document.body.removeChild(f);
|
167
|
-
}, 333);
|
168
|
-
} // end saver
|
154
|
+
setTimeout(() => {
|
155
|
+
document.body.removeChild(fallbackIframe);
|
156
|
+
}, 5000); // Clean up iframe after 5 seconds
|
157
|
+
|
158
|
+
return true;
|
159
|
+
}
|
169
160
|
|
170
161
|
// @ts-ignore
|
171
162
|
if (navigator.msSaveBlob) {
|