inviton-powerduck 0.0.160 → 0.0.162
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.
|
@@ -2,14 +2,23 @@ import type { ImageResponse, OnUploadImageResponse } from '../../data/image';
|
|
|
2
2
|
import PowerduckState from '../../app/powerduck-state';
|
|
3
3
|
import { AppHttpProvider } from '../api-http';
|
|
4
4
|
import { BrowserImageCompression } from './broswer-image-compression';
|
|
5
|
+
import { isNullOrEmpty } from './is-null-or-empty';
|
|
5
6
|
import StringUtils from './string-utils';
|
|
6
7
|
|
|
8
|
+
export class UploadImageHelperConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The base path for uploaded files.
|
|
11
|
+
*/
|
|
12
|
+
static basePath: string = 'files';
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
export class UploadImageHelper {
|
|
8
16
|
static async postImage(
|
|
9
17
|
file: File,
|
|
10
18
|
attractionType: string,
|
|
11
|
-
disableCompression: boolean = false,
|
|
12
|
-
compressionMaxMb: number = 0.5,
|
|
19
|
+
disableCompression: boolean = false,
|
|
20
|
+
compressionMaxMb: number = 0.5,
|
|
21
|
+
url?: string,
|
|
13
22
|
): Promise<ImageResponse> {
|
|
14
23
|
if (!(disableCompression || file.type == 'image/svg+xml')) {
|
|
15
24
|
file = await BrowserImageCompression.compress(file, {
|
|
@@ -19,11 +28,12 @@ compressionMaxMb: number = 0.5,
|
|
|
19
28
|
|
|
20
29
|
const formData: FormData = new FormData();
|
|
21
30
|
const fileObj = new File([file], StringUtils.normalizeFileName(file.name));
|
|
31
|
+
url = !isNullOrEmpty(url) ? url : `${AppHttpProvider.enforceDomain}${UploadImageHelperConfig.basePath}`;
|
|
22
32
|
|
|
23
33
|
formData.append('pathToFolder', `photos/${attractionType}/`);
|
|
24
34
|
formData.append('file', fileObj);
|
|
25
35
|
|
|
26
|
-
const response = await fetch(
|
|
36
|
+
const response = await fetch(url, {
|
|
27
37
|
method: 'POST',
|
|
28
38
|
body: formData,
|
|
29
39
|
headers: {
|
|
@@ -1955,6 +1955,7 @@ import { utcEpochMilliseconds } from '../../../../common/extensions/temporal-ext
|
|
|
1955
1955
|
|
|
1956
1956
|
box.one('animationend', function () {
|
|
1957
1957
|
box.hide();
|
|
1958
|
+
afterAnim();
|
|
1958
1959
|
box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
|
|
1959
1960
|
});
|
|
1960
1961
|
}
|