@webitel/ui-sdk 26.2.99 → 26.2.101
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/{index-tVqKxDM9.js → index-BDbIb0Wx.js} +1 -1
- package/dist/{index-C_UXGo2O.js → index-DMNVRM8G.js} +1 -1
- package/dist/{install-_y7woivq.js → install-BLg9stRY.js} +2792 -2782
- package/dist/{isObject-CoRQk242.js → isObject-CY0WNjjb.js} +1 -1
- package/dist/ui-sdk.js +1 -1
- package/dist/ui-sdk.umd.cjs +79 -71
- package/dist/{vidstack-Bq6c3Bam-7xeVs36h.js → vidstack-Bq6c3Bam-2NkVhSmW.js} +2 -2
- package/dist/{vidstack-D2pY00kU-CPvKC0f1.js → vidstack-D2pY00kU-CtXuBxWV.js} +2 -2
- package/dist/{vidstack-DDXt6fpN-BnvnWmCT.js → vidstack-DDXt6fpN-CL5Dvcz7.js} +1 -1
- package/dist/{vidstack-D_-9AA6_-DIpdAHJx.js → vidstack-D_-9AA6_-Dana1Lpy.js} +1 -1
- package/dist/{vidstack-DqAw8m9J-CH0RQZQL.js → vidstack-DqAw8m9J-BK43_AQm.js} +1 -1
- package/dist/{vidstack-audio-mp_TLPKd.js → vidstack-audio-DWO2584P.js} +2 -2
- package/dist/{vidstack-dash-CMBwvCZJ.js → vidstack-dash-DTrG0grK.js} +3 -3
- package/dist/{vidstack-google-cast-uwJe-HGB.js → vidstack-google-cast-sGI32dX8.js} +3 -3
- package/dist/{vidstack-hls-DcGqPWbm.js → vidstack-hls-DQ3qShXJ.js} +3 -3
- package/dist/{vidstack-video-DQ5_xt3a.js → vidstack-video-D89eBrqN.js} +2 -2
- package/dist/{vidstack-vimeo-DqlS9H2R.js → vidstack-vimeo-Ct9L3lAl.js} +3 -3
- package/dist/{vidstack-youtube-CxiaENCC.js → vidstack-youtube-DnbgfwSU.js} +2 -2
- package/dist/{wt-action-bar-1MxhyLn-.js → wt-action-bar-CTdZSsv7.js} +1 -1
- package/dist/{wt-button-select-CW1xth4d.js → wt-button-select-BvmOCtWx.js} +1 -1
- package/dist/{wt-chat-emoji-Bf1hgkVk.js → wt-chat-emoji-WgPCVYVS.js} +2 -2
- package/dist/{wt-confirm-dialog-aZddppXV.js → wt-confirm-dialog-La-YeMFe.js} +1 -1
- package/dist/{wt-context-menu-CXgEmDmT.js → wt-context-menu-C9hJexue.js} +1 -1
- package/dist/{wt-copy-action-B1Km_F3k.js → wt-copy-action-BL4xgL3O.js} +1 -1
- package/dist/{wt-datepicker-CfV3BU2N.js → wt-datepicker-DtPn45q_.js} +1 -1
- package/dist/{wt-display-chip-items-ZaqziG__.js → wt-display-chip-items-DA6Gd4Hv.js} +1 -1
- package/dist/{wt-dual-panel-DLkrW-CP.js → wt-dual-panel-3SD881nb.js} +1 -1
- package/dist/{wt-dummy-BERgAbeQ.js → wt-dummy-e8HAushu.js} +1 -1
- package/dist/{wt-error-page-BTkRNv7A.js → wt-error-page-C6tsGyC_.js} +1 -1
- package/dist/{wt-expansion-card-D94d6O9H.js → wt-expansion-card-D_ABmSPP.js} +1 -1
- package/dist/{wt-expansion-panel-syO-2wQd.js → wt-expansion-panel-eVLpkoIY.js} +1 -1
- package/dist/{wt-filters-panel-wrapper-9jasOA6m.js → wt-filters-panel-wrapper-DeEJMGrK.js} +1 -1
- package/dist/{wt-galleria-CxQZMXH5.js → wt-galleria-BNdh_lt0.js} +1 -1
- package/dist/{wt-navigation-menu-B3DayjkY.js → wt-navigation-menu-BOMeihtV.js} +1 -1
- package/dist/{wt-notifications-bar-dbz6DjG2.js → wt-notifications-bar-BpPBEdt6.js} +2 -2
- package/dist/{wt-page-header-DMOtSlJR.js → wt-page-header-BgcZ_Rcv.js} +1 -1
- package/dist/{wt-pagination-DRpxziCL.js → wt-pagination-DG4P_LiA.js} +1 -1
- package/dist/{wt-player-DOCoyz4Z.js → wt-player-g8VNgPag.js} +1 -1
- package/dist/{wt-search-bar-CNyBGfiT.js → wt-search-bar-DLG08mDV.js} +1 -1
- package/dist/{wt-selection-popup-9QPiIMkZ.js → wt-selection-popup-CSy9je5D.js} +1 -1
- package/dist/{wt-start-page-uqD_fS5n.js → wt-start-page-DqaU6Ht9.js} +1 -1
- package/dist/{wt-status-select-DkEXj7h-.js → wt-status-select-BxzMR9nZ.js} +1 -1
- package/dist/{wt-stepper-MIpi_L_N.js → wt-stepper-DZxBNQcf.js} +1 -1
- package/dist/{wt-table-C6lGg4F7.js → wt-table-C5keIxBl.js} +1 -1
- package/dist/{wt-table-actions-DzK2i1JI.js → wt-table-actions-ZNHYabhN.js} +1 -1
- package/dist/{wt-table-column-select-DaEMIgyq.js → wt-table-column-select-Bac8EQ9f.js} +2 -2
- package/dist/{wt-tabs-JCqwY4fT.js → wt-tabs-BFshmhdU.js} +1 -1
- package/dist/{wt-tags-input-CRImYcfm.js → wt-tags-input-DpbWEd4D.js} +2 -2
- package/dist/{wt-timepicker-gTRPVO-C.js → wt-timepicker-B7zqxTy-.js} +1 -1
- package/dist/{wt-tree-DzkJKfvR.js → wt-tree-B0Q5FzLQ.js} +2 -2
- package/dist/{wt-tree-table-DT74gPqB.js → wt-tree-table-k3Bchetx.js} +1 -1
- package/dist/{wt-type-extension-value-input-CSabKSkq.js → wt-type-extension-value-input-BGMBxpWA.js} +2 -2
- package/dist/{wt-vidstack-player-DusOo_yS.js → wt-vidstack-player-JXqjTkTY.js} +9 -9
- package/package.json +3 -3
- package/src/assets/icons/sprite/index.ts +4 -0
- package/src/assets/icons/sprite/violation--filled.svg +3 -0
- package/src/assets/icons/sprite/violation.svg +5 -0
- package/src/locale/en/en.js +2 -0
- package/src/locale/es/es.js +2 -0
- package/src/locale/kz/kz.js +2 -0
- package/src/locale/pl/pl.js +2 -0
- package/src/locale/ro/ro.js +2 -0
- package/src/locale/ru/ru.js +2 -0
- package/src/locale/uk/uk.js +2 -0
- package/src/locale/uz/uz.js +2 -0
- package/src/locale/vi/vi.js +2 -0
- package/src/modules/AuditForm/components/audit-form-question-read-wrapper.vue +45 -15
- package/src/modules/AuditForm/components/audit-form-question-write-wrapper.vue +42 -15
- package/src/modules/AuditForm/components/audit-form-question.vue +4 -1
- package/src/modules/AuditForm/components/audit-form.vue +5 -2
- package/src/modules/AuditForm/components/form-answers/answer-editing-info/audit-form-answer-editing-info.vue +1 -1
- package/src/modules/AuditForm/components/form-questions/options/audit-form-question-options.vue +5 -2
- package/src/modules/AuditForm/components/form-questions/score/audit-form-question-score.vue +4 -1
- package/src/modules/AuditForm/components/form-questions/yes/audit-form-question-yes.vue +61 -0
- package/src/modules/AuditForm/schemas/AuditFormQuestionOptionsSchema.ts +17 -0
- package/src/modules/AuditForm/schemas/AuditFormQuestionSchema.ts +12 -0
- package/src/modules/AuditForm/schemas/AuditFormQuestionScoreSchema.ts +8 -0
- package/src/modules/AuditForm/schemas/AuditFormQuestionYesSchema.ts +7 -0
- package/src/modules/FilesExport/{v2/composables → composables}/useFilesExport.ts +20 -4
- package/src/modules/FilesExport/{v2/index.ts → index.ts} +1 -0
- package/src/modules/FilesExport/{v2/types → types}/types.ts +2 -1
- package/types/locale/en/en.d.ts +2 -0
- package/types/locale/es/es.d.ts +3 -0
- package/types/locale/i18n.d.ts +18 -0
- package/types/locale/index.d.ts +18 -0
- package/types/locale/kz/kz.d.ts +3 -0
- package/types/locale/pl/pl.d.ts +3 -0
- package/types/locale/ro/ro.d.ts +3 -0
- package/types/locale/ru/ru.d.ts +3 -0
- package/types/locale/uk/uk.d.ts +3 -0
- package/types/locale/uz/uz.d.ts +3 -0
- package/types/locale/vi/vi.d.ts +3 -0
- package/types/modules/AuditForm/components/audit-form-question-read-wrapper.vue.d.ts +1 -1
- package/types/modules/AuditForm/components/audit-form-question-write-wrapper.vue.d.ts +1 -1
- package/types/modules/AuditForm/components/audit-form-question.vue.d.ts +1 -1
- package/types/modules/AuditForm/components/audit-form.vue.d.ts +1 -1
- package/types/modules/AuditForm/components/form-answers/answer-editing-info/audit-form-answer-editing-info.vue.d.ts +1 -1
- package/types/modules/AuditForm/components/form-questions/options/audit-form-question-options.vue.d.ts +1 -1
- package/types/modules/AuditForm/components/form-questions/score/audit-form-question-score.vue.d.ts +1 -1
- package/types/modules/AuditForm/components/form-questions/yes/audit-form-question-yes.vue.d.ts +18 -0
- package/types/modules/AuditForm/schemas/AuditFormQuestionOptionsSchema.d.ts +3 -12
- package/types/modules/AuditForm/schemas/AuditFormQuestionSchema.d.ts +3 -8
- package/types/modules/AuditForm/schemas/AuditFormQuestionScoreSchema.d.ts +2 -6
- package/types/modules/AuditForm/schemas/AuditFormQuestionYesSchema.d.ts +2 -0
- package/types/modules/FilesExport/{v2/composables → composables}/useFilesExport.d.ts +1 -1
- package/types/modules/FilesExport/{v2/index.d.ts → index.d.ts} +1 -0
- package/types/modules/FilesExport/{v2/types → types}/types.d.ts +2 -1
- package/src/modules/AuditForm/schemas/AuditFormQuestionOptionsSchema.js +0 -13
- package/src/modules/AuditForm/schemas/AuditFormQuestionSchema.js +0 -8
- package/src/modules/AuditForm/schemas/AuditFormQuestionScoreSchema.js +0 -8
- package/src/modules/FilesExport/FilesExport.js +0 -164
- package/src/modules/FilesExport/__tests__/FilesExport.spec.js +0 -113
- package/src/modules/FilesExport/mixins/exportFilesMixin.js +0 -71
- package/types/modules/FilesExport/FilesExport.d.ts +0 -31
- package/types/modules/FilesExport/__tests__/FilesExport.spec.d.ts +0 -1
- package/types/modules/FilesExport/mixins/exportFilesMixin.d.ts +0 -16
- /package/src/modules/FilesExport/{v2/utils → utils}/utils.ts +0 -0
- /package/types/modules/FilesExport/{v2/utils → utils}/utils.d.ts +0 -0
|
@@ -20,4 +20,4 @@ export declare const useFilesExportProgress: () => {
|
|
|
20
20
|
updateZippingStatus: (percent: number) => void;
|
|
21
21
|
reset: () => void;
|
|
22
22
|
};
|
|
23
|
-
export declare const useFilesExport: ({ getFileURL, fetch, filename, skipFilesWithError, }: UseFilesExportOptions) => UseFilesExportReturn;
|
|
23
|
+
export declare const useFilesExport: ({ getFileURL, getFileBlob, fetch, filename, skipFilesWithError, }: UseFilesExportOptions) => UseFilesExportReturn;
|
|
@@ -4,7 +4,8 @@ export type ExportedItem = {
|
|
|
4
4
|
mimeType?: string;
|
|
5
5
|
} & Record<string, unknown>;
|
|
6
6
|
export type UseFilesExportOptions = {
|
|
7
|
-
getFileURL
|
|
7
|
+
getFileURL?: (item: ExportedItem) => string;
|
|
8
|
+
getFileBlob?: (item: ExportedItem) => Promise<Blob>;
|
|
8
9
|
fetch: ({ page, size }: {
|
|
9
10
|
page: number;
|
|
10
11
|
size?: number;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { EngineAuditQuestionType } from 'webitel-sdk';
|
|
2
|
-
|
|
3
|
-
export const generateOption = () => ({
|
|
4
|
-
name: '',
|
|
5
|
-
score: 10,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export const generateQuestionOptionsSchema = () => ({
|
|
9
|
-
type: EngineAuditQuestionType.Option,
|
|
10
|
-
options: [
|
|
11
|
-
generateOption(),
|
|
12
|
-
],
|
|
13
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { generateQuestionScoreSchema } from './AuditFormQuestionScoreSchema.js';
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
4
|
-
export const generateQuestionSchema = ({ required = true } = {}) => ({
|
|
5
|
-
required,
|
|
6
|
-
question: '',
|
|
7
|
-
...generateQuestionScoreSchema(),
|
|
8
|
-
});
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { getCallMediaUrl } from '@webitel/api-services/api';
|
|
2
|
-
import { EngineCallFileType } from '@webitel/api-services/gen/models';
|
|
3
|
-
import { saveAs } from 'file-saver-es';
|
|
4
|
-
import JSZip from 'jszip';
|
|
5
|
-
import jszipUtils from 'jszip-utils';
|
|
6
|
-
import path from 'path-browserify';
|
|
7
|
-
|
|
8
|
-
import { _wtUiLog } from '../../scripts/logger.js';
|
|
9
|
-
|
|
10
|
-
export default class FilesExport {
|
|
11
|
-
filename = 'files';
|
|
12
|
-
|
|
13
|
-
fetchMethod = null;
|
|
14
|
-
|
|
15
|
-
isLoading = false;
|
|
16
|
-
|
|
17
|
-
skipFilesWithError = false;
|
|
18
|
-
|
|
19
|
-
downloadProgress = {
|
|
20
|
-
count: 0,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
zippingProgress = {
|
|
24
|
-
percent: 0,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
filesURL = getCallMediaUrl;
|
|
28
|
-
|
|
29
|
-
constructor({ fetchMethod, filename, filesURL, skipFilesWithError = false }) {
|
|
30
|
-
if (fetchMethod) this.fetchMethod = fetchMethod;
|
|
31
|
-
if (filename) this.filename = filename;
|
|
32
|
-
if (filesURL) this.filesURL = filesURL;
|
|
33
|
-
this.skipFilesWithError = skipFilesWithError;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
_fetchFileBinary(fileId) {
|
|
37
|
-
const url = this.filesURL(fileId);
|
|
38
|
-
return new Promise((resolve, reject) =>
|
|
39
|
-
jszipUtils.getBinaryContent(url, (err, data) => {
|
|
40
|
-
if (err) {
|
|
41
|
-
reject(err);
|
|
42
|
-
} else {
|
|
43
|
-
resolve(data);
|
|
44
|
-
}
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
resetProgress() {
|
|
50
|
-
this.downloadProgress = {
|
|
51
|
-
count: 0,
|
|
52
|
-
};
|
|
53
|
-
this.zippingProgress = {
|
|
54
|
-
percent: 0,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Recursively adds files to zip archive, filtering by fileType
|
|
59
|
-
// Supports FileTypeAudio, FileTypeVideo, FileTypeScreensharing (defaults to FileTypeAudio)
|
|
60
|
-
async _addFilesToZip(
|
|
61
|
-
items,
|
|
62
|
-
zip,
|
|
63
|
-
fileType = EngineCallFileType.FileTypeAudio,
|
|
64
|
-
) {
|
|
65
|
-
for (const item of items) {
|
|
66
|
-
if (item.files) {
|
|
67
|
-
// If item has nested files object, filter by fileType and recurse
|
|
68
|
-
if (item.files?.[fileType]) {
|
|
69
|
-
await this._addFilesToZip(item.files[fileType], zip, fileType);
|
|
70
|
-
} else continue;
|
|
71
|
-
} else {
|
|
72
|
-
try {
|
|
73
|
-
const binary = await this._fetchFileBinary(item.id);
|
|
74
|
-
const ext = item.mimeType.split('/').pop();
|
|
75
|
-
// itemName needed to remove extension from item.name https://stackoverflow.com/a/31615711
|
|
76
|
-
const itemName = path.parse(item.name).name;
|
|
77
|
-
zip.file(`${itemName}.${ext}`, binary);
|
|
78
|
-
this.downloadProgress.count += 1;
|
|
79
|
-
} catch (err) {
|
|
80
|
-
_wtUiLog.warn({
|
|
81
|
-
entity: 'script',
|
|
82
|
-
module: 'FilesExport',
|
|
83
|
-
})(`An error occurred while downloading a file id=${item.id}`, err);
|
|
84
|
-
if (!this.skipFilesWithError) {
|
|
85
|
-
throw err;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async _generateZip(zip) {
|
|
93
|
-
try {
|
|
94
|
-
return await zip.generateAsync(
|
|
95
|
-
{
|
|
96
|
-
type: 'blob',
|
|
97
|
-
},
|
|
98
|
-
(progress) => {
|
|
99
|
-
this.zippingProgress = progress;
|
|
100
|
-
},
|
|
101
|
-
);
|
|
102
|
-
} catch (err) {
|
|
103
|
-
throw new Error('Failed to generate zip file');
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async _saveZip(file) {
|
|
108
|
-
try {
|
|
109
|
-
saveAs(file, `${this.filename}.zip`);
|
|
110
|
-
} catch (err) {
|
|
111
|
-
throw new Error('Failed to save a file');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Fetches history items and adds files of specified type to zip
|
|
116
|
-
async _fetchAndZip(zip, requestParams, fileType) {
|
|
117
|
-
const params = {
|
|
118
|
-
from: 0,
|
|
119
|
-
size: 5000,
|
|
120
|
-
fields: [
|
|
121
|
-
'files',
|
|
122
|
-
],
|
|
123
|
-
...requestParams,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
let page = 1;
|
|
127
|
-
let isNext = false;
|
|
128
|
-
do {
|
|
129
|
-
const { items, next } = await this.fetchMethod({
|
|
130
|
-
...params,
|
|
131
|
-
page,
|
|
132
|
-
});
|
|
133
|
-
// Filter and add files of the specified type
|
|
134
|
-
await this._addFilesToZip(items, zip, fileType);
|
|
135
|
-
|
|
136
|
-
isNext = next;
|
|
137
|
-
page += 1;
|
|
138
|
-
} while (isNext);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Exports files to a zip archive
|
|
142
|
-
// fileType: FileTypeAudio (default), FileTypeVideo, or FileTypeScreensharing
|
|
143
|
-
async exportFiles(
|
|
144
|
-
files,
|
|
145
|
-
{ reqParams, fileType = EngineCallFileType.FileTypeAudio },
|
|
146
|
-
) {
|
|
147
|
-
try {
|
|
148
|
-
this.isLoading = true;
|
|
149
|
-
const zip = new JSZip();
|
|
150
|
-
// If files provided, use them; otherwise fetch from API with fileType filter
|
|
151
|
-
if (files?.length) await this._addFilesToZip(files, zip, fileType);
|
|
152
|
-
else {
|
|
153
|
-
await this._fetchAndZip(zip, reqParams, fileType);
|
|
154
|
-
}
|
|
155
|
-
const file = await this._generateZip(zip);
|
|
156
|
-
await this._saveZip(file);
|
|
157
|
-
this.resetProgress();
|
|
158
|
-
} catch (err) {
|
|
159
|
-
throw err;
|
|
160
|
-
} finally {
|
|
161
|
-
this.isLoading = false;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import '../../../../tests/mocks/localStorageMock';
|
|
2
|
-
|
|
3
|
-
import { shallowMount } from '@vue/test-utils';
|
|
4
|
-
import * as fileSaver from 'file-saver-es';
|
|
5
|
-
import jszip from 'jszip';
|
|
6
|
-
import jszipUtils from 'jszip-utils';
|
|
7
|
-
|
|
8
|
-
import FilesExportMixin from '../mixins/exportFilesMixin.js';
|
|
9
|
-
|
|
10
|
-
vi.mock('jszip');
|
|
11
|
-
vi.mock('jszip-utils');
|
|
12
|
-
vi.mock('file-saver-es', () => ({
|
|
13
|
-
saveAs: vi.fn(),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
const dataList = [
|
|
17
|
-
{
|
|
18
|
-
files: [
|
|
19
|
-
{
|
|
20
|
-
name: 'jest',
|
|
21
|
-
id: '1',
|
|
22
|
-
mimeType: 'mime/type',
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
const selectedDataList = [
|
|
28
|
-
{
|
|
29
|
-
_isSelected: true,
|
|
30
|
-
files: [
|
|
31
|
-
{
|
|
32
|
-
name: 'jest1',
|
|
33
|
-
id: '1',
|
|
34
|
-
mimeType: 'mime/type',
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
_isSelected: true,
|
|
40
|
-
files: [
|
|
41
|
-
{
|
|
42
|
-
name: 'jest2',
|
|
43
|
-
id: '2',
|
|
44
|
-
mimeType: 'mime/type',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
describe('File Export', () => {
|
|
51
|
-
jszipUtils.getBinaryContent.mockImplementation((url, callback) =>
|
|
52
|
-
callback(null, {}),
|
|
53
|
-
);
|
|
54
|
-
let wrapper;
|
|
55
|
-
const Component = {
|
|
56
|
-
render() {},
|
|
57
|
-
mixins: [
|
|
58
|
-
FilesExportMixin,
|
|
59
|
-
],
|
|
60
|
-
created() {
|
|
61
|
-
this.initFilesExport({
|
|
62
|
-
fetchMethod: () => ({
|
|
63
|
-
items: dataList,
|
|
64
|
-
}),
|
|
65
|
-
filename: 'jest',
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
data: () => ({
|
|
69
|
-
dataList,
|
|
70
|
-
}),
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
it('goes through all important steps to save file', async () => {
|
|
74
|
-
wrapper = shallowMount(Component);
|
|
75
|
-
await wrapper.vm.exportFiles();
|
|
76
|
-
expect(jszip).toHaveBeenCalled();
|
|
77
|
-
expect(jszipUtils.getBinaryContent).toHaveBeenCalled();
|
|
78
|
-
expect(fileSaver.saveAs).toHaveBeenCalled();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('mixin correctly computes empty export progress from class data', () => {
|
|
82
|
-
wrapper = shallowMount(Component);
|
|
83
|
-
expect(wrapper.vm.filesDownloadProgress).toBe(0);
|
|
84
|
-
expect(wrapper.vm.filesZippingProgress).toBe(0);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('mixin correctly computes selectedFiles()', () => {
|
|
88
|
-
wrapper = shallowMount(Component, {
|
|
89
|
-
computed: {
|
|
90
|
-
selectedItems() {
|
|
91
|
-
return selectedDataList;
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
expect(wrapper.vm.getSelectedFiles()).toEqual([
|
|
96
|
-
...selectedDataList[0].files,
|
|
97
|
-
...selectedDataList[1].files,
|
|
98
|
-
]);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('mixin catches export error and resets isFilesLoading on export error', async () => {
|
|
102
|
-
wrapper = shallowMount(Component);
|
|
103
|
-
wrapper.vm.FilesExport = null; // like FilesExport wasn't initialized
|
|
104
|
-
// wrapper.vm.FilesExport.exportFiles = function () { throw new Error(); };
|
|
105
|
-
// await expect(async () => Promise.reject(await wrapper.vm.exportFiles())).rejects.toThrowError();
|
|
106
|
-
try {
|
|
107
|
-
await wrapper.vm.exportFiles();
|
|
108
|
-
} catch (err) {
|
|
109
|
-
expect(err).toBeTruthy();
|
|
110
|
-
expect(wrapper.vm.isFilesLoading).toBeFalsy();
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { EngineCallFileType } from '@webitel/api-services/gen/models';
|
|
2
|
-
|
|
3
|
-
import FilesExport from '../FilesExport.js';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
data: () => ({
|
|
7
|
-
FilesExport: null,
|
|
8
|
-
}),
|
|
9
|
-
|
|
10
|
-
computed: {
|
|
11
|
-
isFilesLoading() {
|
|
12
|
-
return this.FilesExport?.isLoading;
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
filesDownloadProgress() {
|
|
16
|
-
return this.FilesExport ? this.FilesExport.downloadProgress.count : 0;
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
filesZippingProgress() {
|
|
20
|
-
return this.FilesExport
|
|
21
|
-
? Math.floor(this.FilesExport.zippingProgress.percent)
|
|
22
|
-
: 0;
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
methods: {
|
|
27
|
-
initFilesExport(options) {
|
|
28
|
-
this.FilesExport = new FilesExport(options);
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
// Gets selected files of a specific type from selectedItems
|
|
32
|
-
// fileType: FileTypeAudio (default), FileTypeVideo, or FileTypeScreensharing
|
|
33
|
-
getSelectedFiles(fileType = EngineCallFileType.FileTypeAudio) {
|
|
34
|
-
let files = null;
|
|
35
|
-
if (this.selectedItems?.length) {
|
|
36
|
-
files = this.selectedItems.reduce(
|
|
37
|
-
(filesAccumulator, next) =>
|
|
38
|
-
// Check if item has files and contains files of the specified type
|
|
39
|
-
next.files && next.files[fileType]
|
|
40
|
-
? [
|
|
41
|
-
...filesAccumulator,
|
|
42
|
-
...next.files[fileType],
|
|
43
|
-
]
|
|
44
|
-
: filesAccumulator,
|
|
45
|
-
[],
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
return files;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
// Exports files of a specific type to a zip archive
|
|
52
|
-
// fileType: FileTypeAudio (default), FileTypeVideo, or FileTypeScreensharing
|
|
53
|
-
async exportFiles(
|
|
54
|
-
files,
|
|
55
|
-
reqParams = {},
|
|
56
|
-
fileType = EngineCallFileType.FileTypeAudio,
|
|
57
|
-
) {
|
|
58
|
-
if (!this.FilesExport) throw new Error('FilesExport is not initialized');
|
|
59
|
-
// Use provided files or get from selectedItems filtered by fileType
|
|
60
|
-
const exportFiles = files || this.getSelectedFiles(fileType);
|
|
61
|
-
try {
|
|
62
|
-
await this.FilesExport.exportFiles(exportFiles, {
|
|
63
|
-
reqParams,
|
|
64
|
-
fileType,
|
|
65
|
-
});
|
|
66
|
-
} catch (err) {
|
|
67
|
-
throw err;
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default class FilesExport {
|
|
2
|
-
constructor({ fetchMethod, filename, filesURL, skipFilesWithError }: {
|
|
3
|
-
fetchMethod: any;
|
|
4
|
-
filename: any;
|
|
5
|
-
filesURL: any;
|
|
6
|
-
skipFilesWithError?: boolean;
|
|
7
|
-
});
|
|
8
|
-
filename: string;
|
|
9
|
-
fetchMethod: any;
|
|
10
|
-
isLoading: boolean;
|
|
11
|
-
skipFilesWithError: boolean;
|
|
12
|
-
downloadProgress: {
|
|
13
|
-
count: number;
|
|
14
|
-
};
|
|
15
|
-
zippingProgress: {
|
|
16
|
-
percent: number;
|
|
17
|
-
};
|
|
18
|
-
filesURL: (id: any, { download }?: {
|
|
19
|
-
download?: boolean;
|
|
20
|
-
}) => string;
|
|
21
|
-
_fetchFileBinary(fileId: any): Promise<any>;
|
|
22
|
-
resetProgress(): void;
|
|
23
|
-
_addFilesToZip(items: any, zip: any, fileType?: "file_type_audio"): Promise<void>;
|
|
24
|
-
_generateZip(zip: any): Promise<any>;
|
|
25
|
-
_saveZip(file: any): Promise<void>;
|
|
26
|
-
_fetchAndZip(zip: any, requestParams: any, fileType: any): Promise<void>;
|
|
27
|
-
exportFiles(files: any, { reqParams, fileType }: {
|
|
28
|
-
reqParams: any;
|
|
29
|
-
fileType?: "file_type_audio";
|
|
30
|
-
}): Promise<void>;
|
|
31
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
function data(): {
|
|
3
|
-
FilesExport: any;
|
|
4
|
-
};
|
|
5
|
-
namespace computed {
|
|
6
|
-
function isFilesLoading(): any;
|
|
7
|
-
function filesDownloadProgress(): any;
|
|
8
|
-
function filesZippingProgress(): number;
|
|
9
|
-
}
|
|
10
|
-
namespace methods {
|
|
11
|
-
function initFilesExport(options: any): void;
|
|
12
|
-
function getSelectedFiles(fileType?: "file_type_audio"): any;
|
|
13
|
-
function exportFiles(files: any, reqParams?: {}, fileType?: "file_type_audio"): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export default _default;
|
|
File without changes
|
|
File without changes
|