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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.3.37",
3
+ "version": "0.3.39",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -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
- const mimeType = fileUpload.file.mimeType || fileUpload.file.type;
274
- const presignedUrl = this.options.presignedUploadUrl(this.options.directory, fileUpload.file.name, mimeType);
275
-
276
- // Fetch presigned upload URL
277
- const fileResource = await fetch(presignedUrl).then(r => r.json());
278
-
279
- if (!fileResource.url) {
280
- FlashMessages.error("Could not fetch presigned upload URL for file " + fileUpload.file.name);
281
- continue;
282
- }
283
-
284
- const isS3Upload = !fileResource.url.match("upload-presigned-url-contents");
285
-
286
- // We need the file resource ID to complete the presigned upload
287
- fileUpload.file.resource_id = fileResource.id;
288
-
289
- // Prepare XHR request
290
- const xhr = new XMLHttpRequest();
291
-
292
- // The XHR request is different based on weather we're sending to S3 or the platform server
293
- if (isS3Upload) {
294
- xhr.open("PUT", fileResource.url);
295
- xhr.setRequestHeader("Content-Type", mimeType);
296
- fileUpload.body = fileUpload.file;
297
- } else {
298
- xhr.open("POST", fileResource.url);
299
- fileUpload.body = fileUpload.formData;
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
@@ -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
- // html5 A[download]
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
- setTimeout(function () {
133
+
134
+ setTimeout(() => {
127
135
  anchor.click();
128
136
  document.body.removeChild(anchor);
137
+
129
138
  if (winMode === true) {
130
- setTimeout(function () {
131
- self.URL.revokeObjectURL(anchor.href);
139
+ setTimeout(() => {
140
+ URL.revokeObjectURL(anchor.href); // Release the Object URL
132
141
  }, 250);
133
142
  }
134
- }, 66);
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
- // do iframe dataURL download (old ch+FF):
157
- var f = document.createElement("iframe");
158
- document.body.appendChild(f);
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
- if (!winMode) {
161
- // force a mime that will download:
162
- url = "data:" + url.replace(/^data:([\w/\-+]+)/, defaultMime);
163
- }
164
- f.src = url;
165
- setTimeout(function () {
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) {