quasar-ui-danx 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +6 -1
- package/src/components/ActionTable/ActionTable.vue +49 -41
- package/src/components/ActionTable/BatchActionMenu.vue +20 -20
- package/src/components/ActionTable/EmptyTableState.vue +5 -5
- package/src/components/ActionTable/Filters/CollapsableFiltersSidebar.vue +11 -11
- package/src/components/ActionTable/Filters/FilterGroupItem.vue +7 -7
- package/src/components/ActionTable/Filters/FilterGroupList.vue +29 -29
- package/src/components/ActionTable/Filters/FilterListToggle.vue +15 -15
- package/src/components/ActionTable/Filters/FilterableField.vue +82 -80
- package/src/components/ActionTable/Filters/index.ts +5 -0
- package/src/components/ActionTable/Form/Fields/BooleanField.vue +13 -13
- package/src/components/ActionTable/Form/Fields/ConfirmPasswordField.vue +11 -11
- package/src/components/ActionTable/Form/Fields/DateField.vue +13 -13
- package/src/components/ActionTable/Form/Fields/DateRangeField.vue +25 -25
- package/src/components/ActionTable/Form/Fields/DateTimeField.vue +21 -21
- package/src/components/ActionTable/Form/Fields/DateTimePicker.vue +23 -23
- package/src/components/ActionTable/Form/Fields/FileUploadButton.vue +31 -31
- package/src/components/ActionTable/Form/Fields/InlineDateTimeField.vue +19 -19
- package/src/components/ActionTable/Form/Fields/IntegerField.vue +7 -7
- package/src/components/ActionTable/Form/Fields/LabelValueBlock.vue +22 -0
- package/src/components/ActionTable/Form/Fields/LabeledInput.vue +19 -19
- package/src/components/ActionTable/Form/Fields/MultiFileField.vue +40 -40
- package/src/components/ActionTable/Form/Fields/MultiKeywordField.vue +23 -23
- package/src/components/ActionTable/Form/Fields/NewPasswordField.vue +10 -10
- package/src/components/ActionTable/Form/Fields/NumberField.vue +29 -29
- package/src/components/ActionTable/Form/Fields/NumberRangeField.vue +33 -33
- package/src/components/ActionTable/Form/Fields/SelectDrawer.vue +36 -36
- package/src/components/ActionTable/Form/Fields/SelectField.vue +66 -66
- package/src/components/ActionTable/Form/Fields/SelectWithChildrenField.vue +23 -23
- package/src/components/ActionTable/Form/Fields/SingleFileField.vue +32 -32
- package/src/components/ActionTable/Form/Fields/TextField.vue +36 -36
- package/src/components/ActionTable/Form/Fields/WysiwygField.vue +16 -16
- package/src/components/ActionTable/Form/Fields/index.ts +23 -23
- package/src/components/ActionTable/Form/RenderedForm.vue +27 -25
- package/src/components/ActionTable/Form/index.ts +2 -0
- package/src/components/ActionTable/TableSummaryRow.vue +33 -33
- package/src/components/ActionTable/index.ts +8 -13
- package/src/components/ActionTable/listActions.ts +340 -339
- package/src/components/ActionTable/listHelpers.ts +74 -0
- package/src/components/ActionTable/tableColumns.ts +56 -56
- package/src/components/DragAndDrop/HandleDraggable.vue +29 -29
- package/src/components/DragAndDrop/ListItemDraggable.vue +10 -10
- package/src/components/DragAndDrop/index.ts +0 -1
- package/src/components/DragAndDrop/listDragAndDrop.ts +1 -1
- package/src/components/Utility/CollapsableSidebar.vue +35 -35
- package/src/components/Utility/ContentDrawer.vue +20 -20
- package/src/components/Utility/Dialogs/ConfirmDialog.vue +55 -55
- package/src/components/Utility/Dialogs/FullScreenDialog.vue +18 -18
- package/src/components/Utility/Dialogs/FullscreenCarouselDialog.vue +105 -0
- package/src/components/Utility/Dialogs/InfoDialog.vue +10 -10
- package/src/components/Utility/Dialogs/InputDialog.vue +13 -13
- package/src/components/Utility/ImagePreview.vue +192 -0
- package/src/components/Utility/Popover/PopoverMenu.vue +64 -0
- package/src/components/Utility/Transitions/StaggeredListTransition.vue +15 -15
- package/src/components/Utility/index.ts +11 -9
- package/src/components/index.ts +1 -1
- package/src/helpers/FileUpload.ts +274 -273
- package/src/helpers/compatibility.ts +45 -45
- package/src/helpers/date.ts +2 -2
- package/src/helpers/download.ts +166 -158
- package/src/helpers/downloadPdf.ts +48 -48
- package/src/helpers/files.ts +42 -42
- package/src/helpers/index.ts +2 -0
- package/src/helpers/multiFileUpload.ts +56 -56
- package/src/helpers/singleFileUpload.ts +49 -49
- package/src/index.esm.js +3 -4
- package/src/svg/FilterIcon.svg +7 -0
- package/src/svg/ImageIcon.svg +30 -0
- package/src/svg/PdfIcon.svg +21 -0
- package/src/svg/PercentIcon.svg +13 -0
- package/src/svg/TrashIcon.svg +15 -0
- package/src/svg/XIcon.svg +18 -0
- package/src/svg/index.ts +8 -0
- package/src/vendor/tinymce-config.ts +1 -0
- package/src/vue-plugin.js +7 -4
- package/tsconfig.json +14 -13
- package/src/components/ActionTable/tableHelpers.ts +0 -83
- package/src/components/DragAndDrop/Icons/index.ts +0 -2
- /package/src/{components/DragAndDrop/Icons → svg}/DragHandleDotsIcon.svg +0 -0
- /package/src/{components/DragAndDrop/Icons → svg}/DragHandleIcon.svg +0 -0
package/src/helpers/download.ts
CHANGED
@@ -9,184 +9,192 @@
|
|
9
9
|
|
10
10
|
/* eslint-disable */
|
11
11
|
export function download(data, strFileName, strMimeType) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
var defaultMime = "application/octet-stream";
|
16
|
-
// this default mime also triggers iframe downloads
|
17
|
-
|
18
|
-
var mimeType = strMimeType || defaultMime;
|
19
|
-
|
20
|
-
var payload = data;
|
21
|
-
|
22
|
-
var url = !strFileName && !strMimeType && payload;
|
23
|
-
|
24
|
-
var anchor = document.createElement("a");
|
25
|
-
|
26
|
-
var toString = function(a) {
|
27
|
-
return String(a);
|
28
|
-
};
|
29
|
-
|
30
|
-
var myBlob = self.Blob || self.MozBlob || self.WebKitBlob || toString;
|
31
|
-
|
32
|
-
var fileName = strFileName || "download";
|
33
|
-
|
34
|
-
var blob;
|
35
|
-
|
36
|
-
var reader;
|
37
|
-
myBlob = myBlob.call ? myBlob.bind(self) : Blob;
|
38
|
-
|
39
|
-
if (String(this) === "true") {
|
40
|
-
// reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
|
41
|
-
payload = [payload, mimeType];
|
42
|
-
mimeType = payload[0];
|
43
|
-
payload = payload[1];
|
44
|
-
}
|
45
|
-
|
46
|
-
if (url && url.length < 2048) {
|
47
|
-
// if no filename and no mime, assume a url was passed as the only argument
|
48
|
-
fileName = url.split("/").pop().split("?")[0];
|
49
|
-
anchor.href = url; // assign href prop to temp anchor
|
50
|
-
|
51
|
-
// if the browser determines that it's a potentially valid url path:
|
52
|
-
if (
|
53
|
-
anchor.href.indexOf(url) !== -1 ||
|
54
|
-
anchor.href.indexOf(encodeURI(url)) !== -1 ||
|
55
|
-
anchor.href === encodeURI(url)
|
56
|
-
) {
|
57
|
-
var ajax = new XMLHttpRequest();
|
58
|
-
ajax.open("GET", url + "?no-cache=" + Date.now(), true);
|
59
|
-
ajax.responseType = "blob";
|
60
|
-
ajax.onload = function(e) {
|
61
|
-
download(e.target.response, fileName, defaultMime);
|
62
|
-
};
|
63
|
-
ajax.onerror = function(e) {
|
64
|
-
// As a fallback, just open the request in a new tab
|
65
|
-
window.open(url, "_blank").focus();
|
66
|
-
};
|
67
|
-
setTimeout(function() {
|
68
|
-
ajax.send();
|
69
|
-
}, 0); // allows setting custom ajax headers using the return:
|
70
|
-
return ajax;
|
71
|
-
} else {
|
72
|
-
throw new Error("Invalid URL given, cannot download file: " + url);
|
73
|
-
}
|
74
|
-
} // end if url?
|
12
|
+
var self = window;
|
13
|
+
// this script is only for browsers anyway...
|
75
14
|
|
76
|
-
|
77
|
-
|
78
|
-
if (payload.length > 1024 * 1024 * 1.999 && myBlob !== toString) {
|
79
|
-
payload = dataUrlToBlob(payload);
|
80
|
-
mimeType = payload.type || defaultMime;
|
81
|
-
} else {
|
82
|
-
return navigator.msSaveBlob // IE10 can't do a[download], only Blobs:
|
83
|
-
? navigator.msSaveBlob(dataUrlToBlob(payload), fileName)
|
84
|
-
: saver(payload); // everyone else can save dataURLs un-processed
|
85
|
-
}
|
86
|
-
} // end if dataURL passed?
|
15
|
+
var defaultMime = "application/octet-stream";
|
16
|
+
// this default mime also triggers iframe downloads
|
87
17
|
|
88
|
-
|
89
|
-
payload instanceof myBlob
|
90
|
-
? payload
|
91
|
-
: new myBlob([payload], { type: mimeType });
|
18
|
+
var mimeType = strMimeType || defaultMime;
|
92
19
|
|
93
|
-
|
94
|
-
var parts = strUrl.split(/[:;,]/);
|
20
|
+
var payload = data;
|
95
21
|
|
96
|
-
var
|
22
|
+
var url = !strFileName && !strMimeType && payload;
|
97
23
|
|
98
|
-
var
|
24
|
+
var anchor = document.createElement("a");
|
99
25
|
|
100
|
-
var
|
26
|
+
var toString = function (a) {
|
27
|
+
return String(a);
|
28
|
+
};
|
29
|
+
|
30
|
+
// @ts-ignore
|
31
|
+
var myBlob = self.Blob || self.MozBlob || self.WebKitBlob || toString;
|
101
32
|
|
102
|
-
var
|
33
|
+
var fileName = strFileName || "download";
|
103
34
|
|
104
|
-
var
|
35
|
+
var blob;
|
105
36
|
|
106
|
-
var
|
37
|
+
var reader;
|
38
|
+
myBlob = myBlob.call ? myBlob.bind(self) : Blob;
|
107
39
|
|
108
|
-
|
40
|
+
if (String(this) === "true") {
|
41
|
+
// reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
|
42
|
+
payload = [payload, mimeType];
|
43
|
+
mimeType = payload[0];
|
44
|
+
payload = payload[1];
|
45
|
+
}
|
109
46
|
|
110
|
-
|
111
|
-
|
47
|
+
if (url && url.length < 2048) {
|
48
|
+
// if no filename and no mime, assume a url was passed as the only argument
|
49
|
+
fileName = url.split("/").pop().split("?")[0];
|
50
|
+
anchor.href = url; // assign href prop to temp anchor
|
112
51
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
52
|
+
// if the browser determines that it's a potentially valid url path:
|
53
|
+
if (
|
54
|
+
anchor.href.indexOf(url) !== -1 ||
|
55
|
+
anchor.href.indexOf(encodeURI(url)) !== -1 ||
|
56
|
+
anchor.href === encodeURI(url)
|
57
|
+
) {
|
58
|
+
var ajax = new XMLHttpRequest();
|
59
|
+
ajax.open("GET", url + "?no-cache=" + Date.now(), true);
|
60
|
+
ajax.responseType = "blob";
|
61
|
+
ajax.onload = function (e) {
|
62
|
+
// @ts-ignore
|
63
|
+
download(e.target.response, fileName, defaultMime);
|
64
|
+
};
|
65
|
+
ajax.onerror = function (e) {
|
66
|
+
// As a fallback, just open the request in a new tab
|
67
|
+
window.open(url, "_blank").focus();
|
68
|
+
};
|
69
|
+
setTimeout(function () {
|
70
|
+
ajax.send();
|
71
|
+
}, 0); // allows setting custom ajax headers using the return:
|
72
|
+
return ajax;
|
73
|
+
} else {
|
74
|
+
throw new Error("Invalid URL given, cannot download file: " + url);
|
75
|
+
}
|
76
|
+
} // end if url?
|
77
|
+
|
78
|
+
// go ahead and download dataURLs right away
|
79
|
+
if (/^data:[\w+-]+\/[\w+-]+[,;]/.test(payload)) {
|
80
|
+
if (payload.length > 1024 * 1024 * 1.999 && myBlob !== toString) {
|
81
|
+
payload = dataUrlToBlob(payload);
|
82
|
+
mimeType = payload.type || defaultMime;
|
83
|
+
} else {
|
84
|
+
// IE10 can't do a[download], only Blobs
|
85
|
+
// everyone else can save dataURLs un-processed
|
86
|
+
// @ts-ignore
|
87
|
+
return navigator.msSaveBlob ? navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : saver(payload);
|
129
88
|
}
|
130
|
-
|
131
|
-
|
89
|
+
} // end if dataURL passed?
|
90
|
+
|
91
|
+
blob =
|
92
|
+
payload instanceof myBlob
|
93
|
+
? payload
|
94
|
+
: new myBlob([payload], { type: mimeType });
|
95
|
+
|
96
|
+
function dataUrlToBlob(strUrl) {
|
97
|
+
var parts = strUrl.split(/[:;,]/);
|
98
|
+
|
99
|
+
var type = parts[1];
|
100
|
+
|
101
|
+
var decoder = parts[2] === "base64" ? atob : decodeURIComponent;
|
102
|
+
|
103
|
+
var binData = decoder(parts.pop());
|
104
|
+
|
105
|
+
var mx = binData.length;
|
106
|
+
|
107
|
+
var i = 0;
|
108
|
+
|
109
|
+
var uiArr = new Uint8Array(mx);
|
110
|
+
|
111
|
+
for (i; i < mx; ++i) uiArr[i] = binData.charCodeAt(i);
|
112
|
+
|
113
|
+
return new myBlob([uiArr], { type: type });
|
132
114
|
}
|
133
115
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
116
|
+
function saver(url, winMode) {
|
117
|
+
if ("download" in anchor) {
|
118
|
+
// html5 A[download]
|
119
|
+
anchor.href = url;
|
120
|
+
anchor.setAttribute("download", fileName);
|
121
|
+
anchor.className = "download-js-link";
|
122
|
+
anchor.innerHTML = "downloading...";
|
123
|
+
anchor.style.display = "none";
|
124
|
+
document.body.appendChild(anchor);
|
125
|
+
setTimeout(function () {
|
126
|
+
anchor.click();
|
127
|
+
document.body.removeChild(anchor);
|
128
|
+
if (winMode === true) {
|
129
|
+
setTimeout(function () {
|
130
|
+
self.URL.revokeObjectURL(anchor.href);
|
131
|
+
}, 250);
|
132
|
+
}
|
133
|
+
}, 66);
|
134
|
+
return true;
|
135
|
+
}
|
136
|
+
|
137
|
+
// handle non-a[download] safari as best we can:
|
141
138
|
if (
|
142
|
-
|
143
|
-
"Displaying New Document\n\nUse Save As... to download, then click back to return to this page."
|
144
|
-
)
|
139
|
+
/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)
|
145
140
|
) {
|
146
|
-
|
141
|
+
url = url.replace(/^data:([\w/\-+]+)/, defaultMime);
|
142
|
+
if (!window.open(url)) {
|
143
|
+
// popup blocked, offer direct download:
|
144
|
+
if (
|
145
|
+
confirm(
|
146
|
+
"Displaying New Document\n\nUse Save As... to download, then click back to return to this page."
|
147
|
+
)
|
148
|
+
) {
|
149
|
+
location.href = url;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
return true;
|
147
153
|
}
|
148
|
-
}
|
149
|
-
return true;
|
150
|
-
}
|
151
154
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
+
// do iframe dataURL download (old ch+FF):
|
156
|
+
var f = document.createElement("iframe");
|
157
|
+
document.body.appendChild(f);
|
155
158
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
if (self.URL) {
|
172
|
-
// simple fast and modern way using Blob and URL:
|
173
|
-
saver(self.URL.createObjectURL(blob), true);
|
174
|
-
} else {
|
175
|
-
// handle non-Blob()+non-URL browsers:
|
176
|
-
if (typeof blob === "string" || blob.constructor === toString) {
|
177
|
-
try {
|
178
|
-
return saver("data:" + mimeType + ";base64," + self.btoa(blob));
|
179
|
-
} catch (y) {
|
180
|
-
return saver("data:" + mimeType + "," + encodeURIComponent(blob));
|
181
|
-
}
|
159
|
+
if (!winMode) {
|
160
|
+
// force a mime that will download:
|
161
|
+
url = "data:" + url.replace(/^data:([\w/\-+]+)/, defaultMime);
|
162
|
+
}
|
163
|
+
f.src = url;
|
164
|
+
setTimeout(function () {
|
165
|
+
document.body.removeChild(f);
|
166
|
+
}, 333);
|
167
|
+
} // end saver
|
168
|
+
|
169
|
+
// @ts-ignore
|
170
|
+
if (navigator.msSaveBlob) {
|
171
|
+
// IE10+ : (has Blob, but not a[download] or URL)
|
172
|
+
// @ts-ignore
|
173
|
+
return navigator.msSaveBlob(blob, fileName);
|
182
174
|
}
|
183
175
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
176
|
+
if (self.URL) {
|
177
|
+
// simple fast and modern way using Blob and URL:
|
178
|
+
saver(self.URL.createObjectURL(blob), true);
|
179
|
+
} else {
|
180
|
+
// handle non-Blob()+non-URL browsers:
|
181
|
+
if (typeof blob === "string" || blob.constructor === toString) {
|
182
|
+
try {
|
183
|
+
// @ts-ignore
|
184
|
+
return saver("data:" + mimeType + ";base64," + self.btoa(blob));
|
185
|
+
} catch (y) {
|
186
|
+
// @ts-ignore
|
187
|
+
return saver("data:" + mimeType + "," + encodeURIComponent(blob));
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
// Blob but not URL support:
|
192
|
+
reader = new FileReader();
|
193
|
+
reader.onload = function (e) {
|
194
|
+
// @ts-ignore
|
195
|
+
saver(this.result);
|
196
|
+
};
|
197
|
+
reader.readAsDataURL(blob);
|
198
|
+
}
|
199
|
+
return true;
|
192
200
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { download } from "
|
1
|
+
import { download } from "@ui/helpers/download";
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Asynchronously load a file from the URL and trigger a download in the browser
|
@@ -9,42 +9,42 @@ import { download } from "danx/src/helpers/download";
|
|
9
9
|
* @returns {Promise<void>}
|
10
10
|
*/
|
11
11
|
export async function downloadFile(url, filename = "", postParams = null) {
|
12
|
-
|
12
|
+
let fetchOptions = undefined;
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
if (postParams) {
|
15
|
+
fetchOptions = {
|
16
|
+
method: "POST",
|
17
|
+
"Content-Type": "application/json",
|
18
|
+
body: JSON.stringify(postParams)
|
19
|
+
};
|
20
|
+
}
|
21
21
|
|
22
|
-
|
22
|
+
const response = await fetch(url, fetchOptions);
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
if (!response.ok) {
|
25
|
+
throw Error("File download failed: invalid response from server");
|
26
|
+
}
|
27
27
|
|
28
|
-
|
28
|
+
let errorMessage;
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
// Handle a JSON response (which indicates an error occurred)
|
31
|
+
try {
|
32
|
+
// @ts-expect-error data is defined on response
|
33
|
+
const jsonResponse = JSON.parse(new TextDecoder().decode(response.data));
|
34
|
+
console.error("Error downloading file:", jsonResponse);
|
35
|
+
errorMessage = jsonResponse.message;
|
36
|
+
if (jsonResponse.errors) {
|
37
|
+
errorMessage = jsonResponse.errors[0].message;
|
38
|
+
}
|
39
|
+
} catch (e) {
|
40
|
+
// we expect an error thrown for invalid JSON when the response is a file
|
38
41
|
}
|
39
|
-
} catch (e) {
|
40
|
-
// we expect an error thrown for invalid JSON when the response is a file
|
41
|
-
}
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
if (errorMessage) {
|
44
|
+
throw new Error("Failed to download file: " + errorMessage);
|
45
|
+
}
|
46
46
|
|
47
|
-
|
47
|
+
await downloadFileResponse(response, filename);
|
48
48
|
}
|
49
49
|
|
50
50
|
/**
|
@@ -54,24 +54,24 @@ export async function downloadFile(url, filename = "", postParams = null) {
|
|
54
54
|
* @param filename
|
55
55
|
*/
|
56
56
|
export async function downloadFileResponse(response, filename = "") {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
const contentDisposition = getResponseHeader(
|
58
|
+
response,
|
59
|
+
"content-disposition",
|
60
|
+
""
|
61
|
+
);
|
62
62
|
|
63
|
-
|
63
|
+
const contentType = getResponseHeader(response, "content-type", "");
|
64
64
|
|
65
|
-
|
65
|
+
const match = contentDisposition.match(/filename="([^"]+)"/);
|
66
66
|
|
67
|
-
|
67
|
+
filename = filename || (match && match[1]) || "download.pdf";
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
let data = response.data;
|
70
|
+
if (!data) {
|
71
|
+
data = await response.blob();
|
72
|
+
}
|
73
73
|
|
74
|
-
|
74
|
+
download(data, filename, contentType);
|
75
75
|
}
|
76
76
|
|
77
77
|
/**
|
@@ -82,11 +82,11 @@ export async function downloadFileResponse(response, filename = "") {
|
|
82
82
|
* @returns {*}
|
83
83
|
*/
|
84
84
|
export function getResponseHeader(response, header, defaultValue) {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
if (response.headers) {
|
86
|
+
if (typeof response.headers.get === "function") {
|
87
|
+
return response.headers.get(header) || defaultValue;
|
88
|
+
} else {
|
89
|
+
return response.headers[header] || defaultValue;
|
90
|
+
}
|
90
91
|
}
|
91
|
-
}
|
92
92
|
}
|
package/src/helpers/files.ts
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
import { FlashMessages, useCompatibility } from "
|
1
|
+
import { FlashMessages, useCompatibility } from "@ui/helpers";
|
2
2
|
import ExifReader from "exifreader";
|
3
3
|
|
4
4
|
export async function resolveFileLocation(file, waitMessage = null) {
|
5
|
-
|
6
|
-
|
7
|
-
}
|
8
|
-
|
9
|
-
try {
|
10
|
-
const tags = await ExifReader.load(file.blobUrl || file.url, {
|
11
|
-
expanded: true
|
12
|
-
});
|
13
|
-
if (tags.gps) {
|
14
|
-
return {
|
15
|
-
latitude: tags.gps.Latitude,
|
16
|
-
longitude: tags.gps.Longitude
|
17
|
-
};
|
5
|
+
if (file.location) {
|
6
|
+
return file.location;
|
18
7
|
}
|
19
8
|
|
20
|
-
|
9
|
+
try {
|
10
|
+
const tags = await ExifReader.load(file.blobUrl || file.url, {
|
11
|
+
expanded: true
|
12
|
+
});
|
13
|
+
if (tags.gps) {
|
14
|
+
return {
|
15
|
+
latitude: tags.gps.Latitude,
|
16
|
+
longitude: tags.gps.Longitude
|
17
|
+
};
|
18
|
+
}
|
19
|
+
|
20
|
+
const { waitForLocation, location } = useCompatibility();
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
// Show a waiting for location message if we have not returned within 1 second
|
23
|
+
if (waitMessage) {
|
24
|
+
setTimeout(() => {
|
25
|
+
if (!location.value && waitMessage) {
|
26
|
+
FlashMessages.warning(waitMessage);
|
27
|
+
}
|
28
|
+
}, 1000);
|
27
29
|
}
|
28
|
-
}, 1000);
|
29
|
-
}
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
// Wait for the browser to return the location (https only as http will not return a location)
|
32
|
+
if (window.location.protocol === "https:") {
|
33
|
+
await waitForLocation();
|
34
|
+
}
|
35
|
+
// Ignore the wait message if we already returned
|
36
|
+
waitMessage = false;
|
37
|
+
if (!location.value) {
|
38
|
+
return null;
|
39
|
+
}
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
41
|
+
return {
|
42
|
+
latitude: location.value.latitude,
|
43
|
+
longitude: location.value.longitude,
|
44
|
+
accuracy: location.value.accuracy,
|
45
|
+
altitude: location.value.altitude,
|
46
|
+
altitudeAccuracy: location.value.altitudeAccuracy
|
47
|
+
};
|
48
|
+
} catch (error) {
|
49
|
+
console.error(error);
|
50
|
+
return null;
|
51
|
+
}
|
52
52
|
}
|
package/src/helpers/index.ts
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
export * from "./array";
|
2
2
|
export * from "./compatibility";
|
3
|
+
export * from "./download";
|
3
4
|
export * from "./files";
|
4
5
|
export * from "./FileUpload";
|
5
6
|
export * from "./FlashMessages";
|
7
|
+
export * from "./formats";
|
6
8
|
export * from "./http";
|
7
9
|
export * from "./multiFileUpload";
|
8
10
|
export * from "./singleFileUpload";
|