ngx-material-entity 15.3.0 → 16.0.0
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/classes/entity.model.d.ts +2 -2
- package/components/confirm-dialog/confirm-dialog-data.d.ts +1 -1
- package/components/edit-page/edit-page.component.d.ts +4 -2
- package/components/edit-page/page-edit-data.builder.d.ts +1 -1
- package/components/input/array/array-string-chips-input/array-string-chips-input.component.d.ts +1 -0
- package/components/input/array/array-table.class.d.ts +4 -2
- package/components/input/base-input.component.d.ts +5 -1
- package/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.d.ts +1 -1
- package/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.d.ts +1 -1
- package/components/input/file/file-default-input/file-default-input.component.d.ts +0 -2
- package/components/input/file/file-image-input/file-image-input.component.d.ts +3 -2
- package/components/input/file/file-input/file-input.component.d.ts +4 -2
- package/components/input/input.component.d.ts +9 -4
- package/components/input/input.module.d.ts +2 -1
- package/components/table/display-column-value/base-display-column-value.component.d.ts +1 -1
- package/components/table/display-column-value/display-column-value.component.d.ts +1 -1
- package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +3 -1
- package/components/table/table-data.builder.d.ts +1 -1
- package/components/table/table-data.d.ts +1 -1
- package/components/table/table.component.d.ts +1 -1
- package/decorators/base/decorator-types.enum.d.ts +1 -1
- package/decorators/base/property-decorator.data.d.ts +1 -1
- package/decorators/file/file-decorator.data.d.ts +1 -1
- package/decorators/number/number-decorator.data.d.ts +1 -1
- package/decorators/string/string-decorator.data.d.ts +1 -1
- package/encapsulation/jszip.utilities.d.ts +1 -1
- package/encapsulation/uuid.utilities.d.ts +11 -0
- package/esm2022/classes/base.builder.mjs +44 -0
- package/esm2022/classes/entity.model.mjs +26 -0
- package/esm2022/components/confirm-dialog/confirm-dialog-data.builder.mjs +58 -0
- package/esm2022/components/confirm-dialog/confirm-dialog.component.mjs +60 -0
- package/esm2022/components/edit-page/edit-page.component.mjs +291 -0
- package/esm2022/components/input/array/array-date-input/array-date-input.component.mjs +23 -0
- package/esm2022/components/input/array/array-date-range-input/array-date-range-input.component.mjs +49 -0
- package/esm2022/components/input/array/array-date-time-input/array-date-time-input.component.mjs +49 -0
- package/esm2022/components/input/array/array-string-autocomplete-chips/array-string-autocomplete-chips.component.mjs +50 -0
- package/esm2022/components/input/array/array-string-chips-input/array-string-chips-input.component.mjs +69 -0
- package/esm2022/components/input/array/array-table.class.mjs +100 -0
- package/esm2022/components/input/base-input.component.mjs +88 -0
- package/esm2022/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.mjs +21 -0
- package/esm2022/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.mjs +17 -0
- package/esm2022/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.mjs +21 -0
- package/esm2022/components/input/custom/custom.component.mjs +28 -0
- package/esm2022/components/input/date/date-input/date-input.component.mjs +19 -0
- package/esm2022/components/input/date/date-range-input/date-range-input.component.mjs +68 -0
- package/esm2022/components/input/date/date-time-input/date-time-input.component.mjs +69 -0
- package/esm2022/components/input/file/file-default-input/file-default-input.component.mjs +18 -0
- package/esm2022/components/input/file/file-image-input/file-image-input.component.mjs +101 -0
- package/esm2022/components/input/file/file-input/dragDrop.directive.mjs +62 -0
- package/esm2022/components/input/file/file-input/file-input.component.mjs +206 -0
- package/esm2022/components/input/input.component.mjs +849 -0
- package/esm2022/components/input/input.module.mjs +172 -0
- package/esm2022/components/input/number/number-dropdown-input/number-dropdown-input.component.mjs +23 -0
- package/esm2022/components/input/number/number-input/number-input.component.mjs +16 -0
- package/esm2022/components/input/number/number-slider-input/number-slider-input.component.mjs +17 -0
- package/esm2022/components/input/relations/references-many-input/references-many-input.component.mjs +102 -0
- package/esm2022/components/input/string/string-autocomplete-input/string-autocomplete-input.component.mjs +36 -0
- package/esm2022/components/input/string/string-dropdown-input/string-dropdown-input.component.mjs +23 -0
- package/esm2022/components/input/string/string-input/string-input.component.mjs +16 -0
- package/esm2022/components/input/string/string-password-input/string-password-input.component.mjs +39 -0
- package/esm2022/components/input/string/string-textbox-input/string-textbox-input.component.mjs +17 -0
- package/esm2022/components/table/create-dialog/create-dialog-data.builder.mjs +42 -0
- package/esm2022/components/table/create-dialog/create-entity-dialog-data.builder.mjs +32 -0
- package/esm2022/components/table/create-dialog/create-entity-dialog.component.mjs +107 -0
- package/esm2022/components/table/display-column-value/base-display-column-value.component.mjs +28 -0
- package/esm2022/components/table/display-column-value/display-column-value.component.mjs +37 -0
- package/esm2022/components/table/edit-dialog/edit-data.builder.mjs +106 -0
- package/esm2022/components/table/edit-dialog/edit-entity-dialog.component.mjs +209 -0
- package/esm2022/components/table/edit-dialog/edit-entity.builder.mjs +39 -0
- package/esm2022/components/table/table-data.builder.mjs +269 -0
- package/esm2022/components/table/table.component.mjs +348 -0
- package/esm2022/decorators/array/array-decorator-internal.data.mjs +286 -0
- package/esm2022/decorators/array/array-decorator.data.mjs +21 -0
- package/esm2022/decorators/base/property-decorator-internal.data.mjs +82 -0
- package/esm2022/decorators/base/property-decorator.data.mjs +56 -0
- package/esm2022/decorators/boolean/boolean-decorator-internal.data.mjs +43 -0
- package/esm2022/decorators/boolean/boolean-decorator.data.mjs +11 -0
- package/esm2022/decorators/custom/custom-decorator-internal.data.mjs +35 -0
- package/{esm2020 → esm2022}/decorators/date/date-decorator-internal.data.mjs +43 -1
- package/esm2022/decorators/date/date-decorator.data.mjs +11 -0
- package/esm2022/decorators/file/file-decorator-internal.data.mjs +143 -0
- package/esm2022/decorators/file/file-decorator.data.mjs +64 -0
- package/esm2022/decorators/has-many/has-many-decorator-internal.data.mjs +42 -0
- package/esm2022/decorators/number/number-decorator-internal.data.mjs +76 -0
- package/esm2022/decorators/number/number-decorator.data.mjs +11 -0
- package/esm2022/decorators/object/object-decorator-internal.data.mjs +20 -0
- package/esm2022/decorators/object/object-decorator.data.mjs +22 -0
- package/esm2022/decorators/references-many/references-many-decorator-internal.data.mjs +48 -0
- package/esm2022/decorators/references-one/references-one-decorator-internal.data.mjs +24 -0
- package/esm2022/decorators/string/string-decorator-internal.data.mjs +114 -0
- package/esm2022/decorators/string/string-decorator.data.mjs +11 -0
- package/esm2022/encapsulation/uuid.utilities.mjs +15 -0
- package/esm2022/services/entity.service.mjs +276 -0
- package/esm2022/utilities/date.utilities.mjs +159 -0
- package/esm2022/utilities/entity.utilities.mjs +905 -0
- package/esm2022/utilities/file.utilities.mjs +180 -0
- package/{fesm2020 → fesm2022}/ngx-material-entity.mjs +1355 -484
- package/fesm2022/ngx-material-entity.mjs.map +1 -0
- package/package.json +11 -17
- package/utilities/date.utilities.d.ts +1 -1
- package/utilities/entity.utilities.d.ts +7 -3
- package/utilities/file.utilities.d.ts +6 -2
- package/esm2020/classes/base.builder.mjs +0 -42
- package/esm2020/classes/entity.model.mjs +0 -22
- package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +0 -44
- package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +0 -57
- package/esm2020/components/edit-page/edit-page.component.mjs +0 -274
- package/esm2020/components/input/array/array-date-input/array-date-input.component.mjs +0 -26
- package/esm2020/components/input/array/array-date-range-input/array-date-range-input.component.mjs +0 -50
- package/esm2020/components/input/array/array-date-time-input/array-date-time-input.component.mjs +0 -49
- package/esm2020/components/input/array/array-string-autocomplete-chips/array-string-autocomplete-chips.component.mjs +0 -49
- package/esm2020/components/input/array/array-string-chips-input/array-string-chips-input.component.mjs +0 -70
- package/esm2020/components/input/array/array-table.class.mjs +0 -93
- package/esm2020/components/input/base-input.component.mjs +0 -64
- package/esm2020/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.mjs +0 -21
- package/esm2020/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.mjs +0 -17
- package/esm2020/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.mjs +0 -21
- package/esm2020/components/input/custom/custom.component.mjs +0 -26
- package/esm2020/components/input/date/date-input/date-input.component.mjs +0 -22
- package/esm2020/components/input/date/date-range-input/date-range-input.component.mjs +0 -71
- package/esm2020/components/input/date/date-time-input/date-time-input.component.mjs +0 -71
- package/esm2020/components/input/file/file-default-input/file-default-input.component.mjs +0 -23
- package/esm2020/components/input/file/file-image-input/file-image-input.component.mjs +0 -98
- package/esm2020/components/input/file/file-input/dragDrop.directive.mjs +0 -63
- package/esm2020/components/input/file/file-input/file-input.component.mjs +0 -195
- package/esm2020/components/input/input.component.mjs +0 -746
- package/esm2020/components/input/input.module.mjs +0 -169
- package/esm2020/components/input/number/number-dropdown-input/number-dropdown-input.component.mjs +0 -26
- package/esm2020/components/input/number/number-input/number-input.component.mjs +0 -16
- package/esm2020/components/input/number/number-slider-input/number-slider-input.component.mjs +0 -17
- package/esm2020/components/input/relations/references-many-input/references-many-input.component.mjs +0 -100
- package/esm2020/components/input/string/string-autocomplete-input/string-autocomplete-input.component.mjs +0 -34
- package/esm2020/components/input/string/string-dropdown-input/string-dropdown-input.component.mjs +0 -26
- package/esm2020/components/input/string/string-input/string-input.component.mjs +0 -16
- package/esm2020/components/input/string/string-password-input/string-password-input.component.mjs +0 -42
- package/esm2020/components/input/string/string-textbox-input/string-textbox-input.component.mjs +0 -17
- package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +0 -32
- package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +0 -26
- package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +0 -100
- package/esm2020/components/table/display-column-value/base-display-column-value.component.mjs +0 -27
- package/esm2020/components/table/display-column-value/display-column-value.component.mjs +0 -33
- package/esm2020/components/table/edit-dialog/edit-data.builder.mjs +0 -76
- package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +0 -195
- package/esm2020/components/table/edit-dialog/edit-entity.builder.mjs +0 -29
- package/esm2020/components/table/table-data.builder.mjs +0 -205
- package/esm2020/components/table/table.component.mjs +0 -333
- package/esm2020/decorators/array/array-decorator-internal.data.mjs +0 -150
- package/esm2020/decorators/array/array-decorator.data.mjs +0 -7
- package/esm2020/decorators/base/property-decorator-internal.data.mjs +0 -58
- package/esm2020/decorators/base/property-decorator.data.mjs +0 -6
- package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +0 -33
- package/esm2020/decorators/boolean/boolean-decorator.data.mjs +0 -7
- package/esm2020/decorators/custom/custom-decorator-internal.data.mjs +0 -27
- package/esm2020/decorators/date/date-decorator.data.mjs +0 -7
- package/esm2020/decorators/file/file-decorator-internal.data.mjs +0 -97
- package/esm2020/decorators/file/file-decorator.data.mjs +0 -7
- package/esm2020/decorators/has-many/has-many-decorator-internal.data.mjs +0 -32
- package/esm2020/decorators/number/number-decorator-internal.data.mjs +0 -54
- package/esm2020/decorators/number/number-decorator.data.mjs +0 -7
- package/esm2020/decorators/object/object-decorator-internal.data.mjs +0 -14
- package/esm2020/decorators/object/object-decorator.data.mjs +0 -7
- package/esm2020/decorators/references-many/references-many-decorator-internal.data.mjs +0 -30
- package/esm2020/decorators/references-one/references-one-decorator-internal.data.mjs +0 -16
- package/esm2020/decorators/string/string-decorator-internal.data.mjs +0 -72
- package/esm2020/decorators/string/string-decorator.data.mjs +0 -7
- package/esm2020/services/entity.service.mjs +0 -274
- package/esm2020/utilities/date.utilities.mjs +0 -159
- package/esm2020/utilities/entity.utilities.mjs +0 -896
- package/esm2020/utilities/file.utilities.mjs +0 -176
- package/fesm2015/ngx-material-entity.mjs +0 -6300
- package/fesm2015/ngx-material-entity.mjs.map +0 -1
- package/fesm2020/ngx-material-entity.mjs.map +0 -1
- /package/{esm2020 → esm2022}/components/confirm-dialog/confirm-dialog-data.mjs +0 -0
- /package/{esm2020 → esm2022}/components/edit-page/edit-data.route.mjs +0 -0
- /package/{esm2020 → esm2022}/components/edit-page/page-edit-data.builder.mjs +0 -0
- /package/{esm2020 → esm2022}/components/get-validation-error-message.function.mjs +0 -0
- /package/{esm2020 → esm2022}/components/table/create-dialog/create-entity-dialog-data.mjs +0 -0
- /package/{esm2020 → esm2022}/components/table/default.actions.mjs +0 -0
- /package/{esm2020 → esm2022}/components/table/edit-dialog/edit-entity-data.mjs +0 -0
- /package/{esm2020 → esm2022}/components/table/table-data.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/array/array.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/base/base-property.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/base/decorator-types.enum.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/base/dropdown-value.interface.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/boolean/boolean.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/custom/custom-decorator.data.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/custom/custom.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/date/date.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/file/file.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/has-many/has-many-decorator.data.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/has-many/has-many.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/number/number.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/object/object.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/references-many/references-many-decorator.data.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/references-many/references-many.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/references-one/references-one-decorator.data.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/references-one/references-one.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/decorators/string/string.decorator.mjs +0 -0
- /package/{esm2020 → esm2022}/encapsulation/js-2-xml.utilities.mjs +0 -0
- /package/{esm2020 → esm2022}/encapsulation/jszip.utilities.mjs +0 -0
- /package/{esm2020 → esm2022}/encapsulation/lodash.utilities.mjs +0 -0
- /package/{esm2020 → esm2022}/encapsulation/reflect.utilities.mjs +0 -0
- /package/{esm2020 → esm2022}/functions/default-false.function.mjs +0 -0
- /package/{esm2020 → esm2022}/functions/default-true.function.mjs +0 -0
- /package/{esm2020 → esm2022}/functions/is-async-function.function.mjs +0 -0
- /package/{esm2020 → esm2022}/mocks/placeholder-data.png.mjs +0 -0
- /package/{esm2020 → esm2022}/ngx-material-entity.mjs +0 -0
- /package/{esm2020 → esm2022}/public-api.mjs +0 -0
- /package/{esm2020 → esm2022}/services/unsaved-changes.guard.mjs +0 -0
- /package/{esm2020 → esm2022}/utilities/selection.utilities.mjs +0 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { firstValueFrom } from 'rxjs';
|
|
2
|
+
import { JSZipUtilities } from '../encapsulation/jszip.utilities';
|
|
3
|
+
import { LodashUtilities } from '../encapsulation/lodash.utilities';
|
|
4
|
+
/**
|
|
5
|
+
* Provides functionality regarding files.
|
|
6
|
+
*/
|
|
7
|
+
export class FileUtilities {
|
|
8
|
+
/**
|
|
9
|
+
* Gets the accept value for the html input.
|
|
10
|
+
*
|
|
11
|
+
* @param mimeTypes - The mimeTypes to get the accept string from.
|
|
12
|
+
* @returns A comma separated string of all the provided mime types.
|
|
13
|
+
*/
|
|
14
|
+
static getAcceptString(mimeTypes) {
|
|
15
|
+
if (!mimeTypes?.length) {
|
|
16
|
+
return '*';
|
|
17
|
+
}
|
|
18
|
+
return mimeTypes.join(', ');
|
|
19
|
+
}
|
|
20
|
+
// TODO: Find a way to use blobs with jest
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
/**
|
|
23
|
+
* Reads a url to display the given file.
|
|
24
|
+
*
|
|
25
|
+
* @param file - The file to get the url from.
|
|
26
|
+
* @returns A promise of the url. Undefined if no file was provided.
|
|
27
|
+
*/
|
|
28
|
+
static async getDataURLFromFile(file) {
|
|
29
|
+
if (!file) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const reader = new FileReader();
|
|
34
|
+
reader.onload = e => resolve(e.target?.result);
|
|
35
|
+
reader.onerror = e => reject(e);
|
|
36
|
+
reader.readAsDataURL(file);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// TODO: Find a way to use blobs with jest
|
|
40
|
+
/* istanbul ignore next */
|
|
41
|
+
/**
|
|
42
|
+
* Gets a file from the given url.
|
|
43
|
+
*
|
|
44
|
+
* @param url - The url to get the file from.
|
|
45
|
+
* @param http - The angular HttpClient. Used to fetch files.
|
|
46
|
+
* @returns A promise of the File.
|
|
47
|
+
*/
|
|
48
|
+
static async getFileFromUrl(url, http) {
|
|
49
|
+
try {
|
|
50
|
+
return await firstValueFrom(http.get(url, { responseType: 'blob' }));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error(`Error fetching the file from the url ${url}:\n ${error}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// TODO: Find a way to use blobs with jest
|
|
57
|
+
/* istanbul ignore next */
|
|
58
|
+
/**
|
|
59
|
+
* Gets the file data with the blob from the given File Data.
|
|
60
|
+
*
|
|
61
|
+
* @param data - The File Data to get the file data with blob from.
|
|
62
|
+
* @param http - The angular HttpClient. Used to fetch files.
|
|
63
|
+
* @returns FileDataWithFile.
|
|
64
|
+
*/
|
|
65
|
+
static async getFileData(data, http) {
|
|
66
|
+
if (data.file) {
|
|
67
|
+
return {
|
|
68
|
+
file: data.file,
|
|
69
|
+
name: data.name,
|
|
70
|
+
url: data.url,
|
|
71
|
+
type: data.type,
|
|
72
|
+
size: data.size
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return {
|
|
77
|
+
file: await FileUtilities.getFileFromUrl(data.url, http),
|
|
78
|
+
name: data.name,
|
|
79
|
+
url: data.url,
|
|
80
|
+
type: data.type,
|
|
81
|
+
size: data.size
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// TODO: Find a way to use blobs with jest
|
|
86
|
+
/* istanbul ignore next */
|
|
87
|
+
/**
|
|
88
|
+
* Downloads a single file from the given File Data.
|
|
89
|
+
*
|
|
90
|
+
* @param fileData - The file data. Needs to contain a blob.
|
|
91
|
+
*/
|
|
92
|
+
static downloadSingleFile(fileData) {
|
|
93
|
+
this.downLoadBlob(fileData.file, fileData.name);
|
|
94
|
+
}
|
|
95
|
+
// TODO: Find a way to use blobs with jest
|
|
96
|
+
/* istanbul ignore next */
|
|
97
|
+
/**
|
|
98
|
+
* Downloads a blob.
|
|
99
|
+
*
|
|
100
|
+
* @param blob - The blob to download.
|
|
101
|
+
* @param name - The name of the downloaded file.
|
|
102
|
+
*/
|
|
103
|
+
static downLoadBlob(blob, name) {
|
|
104
|
+
const a = document.createElement('a');
|
|
105
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
106
|
+
a.href = objectUrl;
|
|
107
|
+
if (name) {
|
|
108
|
+
a.download = name;
|
|
109
|
+
}
|
|
110
|
+
a.click();
|
|
111
|
+
URL.revokeObjectURL(objectUrl);
|
|
112
|
+
}
|
|
113
|
+
// TODO: Find a way to use blobs with jest
|
|
114
|
+
/* istanbul ignore next */
|
|
115
|
+
/**
|
|
116
|
+
* Downloads multiple files as a zip with the given name.
|
|
117
|
+
*
|
|
118
|
+
* @param name - The name of the zip file to generate.
|
|
119
|
+
* @param multiFileData - The file data array to put in the zip.
|
|
120
|
+
* @param http - The angular HttpClient. Used to fetch files.
|
|
121
|
+
*/
|
|
122
|
+
static async downloadMultipleFiles(name, multiFileData, http) {
|
|
123
|
+
const zip = JSZipUtilities.new();
|
|
124
|
+
for (let i = 0; i < multiFileData.length; i++) {
|
|
125
|
+
multiFileData[i] = await FileUtilities.getFileData(multiFileData[i], http);
|
|
126
|
+
zip.file(multiFileData[i].name, multiFileData[i].file);
|
|
127
|
+
}
|
|
128
|
+
const zipBlob = await zip.generateAsync({ type: 'blob' });
|
|
129
|
+
const fileData = {
|
|
130
|
+
name: name,
|
|
131
|
+
file: zipBlob,
|
|
132
|
+
type: 'application/zip',
|
|
133
|
+
size: zipBlob.size
|
|
134
|
+
};
|
|
135
|
+
FileUtilities.downloadSingleFile(fileData);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Checks if the given file has a valid mime type.
|
|
139
|
+
*
|
|
140
|
+
* @param type - The type of the file to check.
|
|
141
|
+
* @param allowedMimeTypes - The allowed mime types.
|
|
142
|
+
* @returns Whether or not the given file has a valid mime type.
|
|
143
|
+
*/
|
|
144
|
+
static isMimeTypeValid(type, allowedMimeTypes) {
|
|
145
|
+
if (allowedMimeTypes.includes('*')) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
for (const t of allowedMimeTypes) {
|
|
149
|
+
if (t === type) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (t.endsWith('*') && type.startsWith(t.split('*')[0])) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Transform the given value to Megabytes.
|
|
160
|
+
*
|
|
161
|
+
* @param value - The original value.
|
|
162
|
+
* @param unit - If the value is B, KB or GB.
|
|
163
|
+
* @returns The given value as bytes.
|
|
164
|
+
*/
|
|
165
|
+
static transformToMegaBytes(value, unit) {
|
|
166
|
+
const bytes = this.transformToBytes(LodashUtilities.cloneDeep(value), unit);
|
|
167
|
+
return bytes / 1000000;
|
|
168
|
+
}
|
|
169
|
+
static transformToBytes(value, unit) {
|
|
170
|
+
switch (unit) {
|
|
171
|
+
case 'B':
|
|
172
|
+
return value;
|
|
173
|
+
case 'KB':
|
|
174
|
+
return value * 1000;
|
|
175
|
+
case 'GB':
|
|
176
|
+
return value * 1000000000;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZS51dGlsaXRpZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9u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ICAqL1xuICAgIHN0YXRpYyBhc3luYyBnZXRGaWxlRGF0YShkYXRhOiBGaWxlRGF0YSwgaHR0cDogSHR0cENsaWVudCk6IFByb21pc2U8RmlsZURhdGFXaXRoRmlsZT4ge1xuICAgICAgICBpZiAoZGF0YS5maWxlKSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIGZpbGU6IGRhdGEuZmlsZSxcbiAgICAgICAgICAgICAgICBuYW1lOiBkYXRhLm5hbWUsXG4gICAgICAgICAgICAgICAgdXJsOiBkYXRhLnVybCxcbiAgICAgICAgICAgICAgICB0eXBlOiBkYXRhLnR5cGUsXG4gICAgICAgICAgICAgICAgc2l6ZTogZGF0YS5zaXplXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICBmaWxlOiBhd2FpdCBGaWxlVXRpbGl0aWVzLmdldEZpbGVGcm9tVXJsKGRhdGEudXJsIGFzIHN0cmluZywgaHR0cCksXG4gICAgICAgICAgICAgICAgbmFtZTogZGF0YS5uYW1lLFxuICAgICAgICAgICAgICAgIHVybDogZGF0YS51cmwsXG4gICAgICAgICAgICAgICAgdHlwZTogZGF0YS50eXBlLFxuICAgICAgICAgICAgICAgIHNpemU6IGRhdGEuc2l6ZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIC8vIFRPRE86IEZpbmQgYSB3YXkgdG8gdXNlIGJsb2JzIHdpdGggamVzdFxuICAgIC8qIGlzdGFuYnVsIGlnbm9yZSBuZXh0ICovXG4gICAgLyoqXG4gICAgICogRG93bmxvYWRzIGEgc2luZ2xlIGZpbGUgZnJvbSB0aGUgZ2l2ZW4gRmlsZSBEYXRhLlxuICAgICAqXG4gICAgICogQHBhcmFtIGZpbGVEYXRhIC0gVGhlIGZpbGUgZGF0YS4gTmVlZHMgdG8gY29udGFpbiBhIGJsb2IuXG4gICAg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