@progress/kendo-angular-upload 21.4.1-develop.1 → 22.0.0-develop.1
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/common/base.d.ts +1 -1
- package/dropzone-base.d.ts +1 -1
- package/fesm2022/progress-kendo-angular-upload.mjs +89 -89
- package/localization/messages.d.ts +1 -1
- package/package.json +13 -21
- package/rendering/file-list-item-base.d.ts +1 -1
- package/schematics/ngAdd/index.js +3 -3
- package/esm2022/common/action-buttons-layout.mjs +0 -5
- package/esm2022/common/base.mjs +0 -280
- package/esm2022/common/fileselect-settings.mjs +0 -5
- package/esm2022/common/util.mjs +0 -253
- package/esm2022/common/validation-util.mjs +0 -60
- package/esm2022/directives.mjs +0 -89
- package/esm2022/dropzone-base.mjs +0 -69
- package/esm2022/dropzone-external.directive.mjs +0 -111
- package/esm2022/dropzone-internal.directive.mjs +0 -109
- package/esm2022/dropzone.component.mjs +0 -169
- package/esm2022/dropzone.service.mjs +0 -37
- package/esm2022/events/cancel-event.mjs +0 -35
- package/esm2022/events/clear-event.mjs +0 -29
- package/esm2022/events/error-event.mjs +0 -48
- package/esm2022/events/pause-event.mjs +0 -38
- package/esm2022/events/preventable-event.mjs +0 -25
- package/esm2022/events/remove-event.mjs +0 -49
- package/esm2022/events/resume-event.mjs +0 -38
- package/esm2022/events/select-event.mjs +0 -37
- package/esm2022/events/success-event.mjs +0 -49
- package/esm2022/events/upload-event.mjs +0 -49
- package/esm2022/events/upload-progress-event.mjs +0 -41
- package/esm2022/events.mjs +0 -14
- package/esm2022/file-select.directive.mjs +0 -136
- package/esm2022/fileselect.component.mjs +0 -452
- package/esm2022/fileselect.module.mjs +0 -41
- package/esm2022/index.mjs +0 -31
- package/esm2022/localization/custom-messages.component.mjs +0 -70
- package/esm2022/localization/localized-messages.directive.mjs +0 -43
- package/esm2022/localization/messages.mjs +0 -185
- package/esm2022/navigation.service.mjs +0 -151
- package/esm2022/package-metadata.mjs +0 -16
- package/esm2022/progress-kendo-angular-upload.mjs +0 -8
- package/esm2022/rendering/file-list-item-action-button.component.mjs +0 -230
- package/esm2022/rendering/file-list-item-base.mjs +0 -52
- package/esm2022/rendering/file-list-item.mjs +0 -115
- package/esm2022/rendering/file-list-multiple-items.component.mjs +0 -201
- package/esm2022/rendering/file-list-single-item.component.mjs +0 -181
- package/esm2022/rendering/file-list.component.mjs +0 -189
- package/esm2022/rendering/upload-action-buttons.component.mjs +0 -126
- package/esm2022/rendering/upload-status-total.component.mjs +0 -97
- package/esm2022/templates/file-info-template.directive.mjs +0 -39
- package/esm2022/templates/file-template.directive.mjs +0 -39
- package/esm2022/types/async-settings.mjs +0 -5
- package/esm2022/types/chunk-info.mjs +0 -5
- package/esm2022/types/chunk-map.mjs +0 -35
- package/esm2022/types/chunk-metadata.mjs +0 -5
- package/esm2022/types/chunk-settings.mjs +0 -5
- package/esm2022/types/direction.mjs +0 -5
- package/esm2022/types/file-groups.mjs +0 -60
- package/esm2022/types/file-info.mjs +0 -5
- package/esm2022/types/file-map.mjs +0 -144
- package/esm2022/types/file-restrictions.mjs +0 -5
- package/esm2022/types/file-state.mjs +0 -34
- package/esm2022/types/operation-type.mjs +0 -5
- package/esm2022/types.mjs +0 -6
- package/esm2022/upload.component.mjs +0 -901
- package/esm2022/upload.module.mjs +0 -43
- package/esm2022/upload.service.mjs +0 -431
- package/esm2022/uploads.module.mjs +0 -66
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { NgModule } from '@angular/core';
|
|
6
|
-
import { KENDO_UPLOAD } from './directives';
|
|
7
|
-
import { IconsService } from '@progress/kendo-angular-icons';
|
|
8
|
-
import { ResizeBatchService } from '@progress/kendo-angular-common';
|
|
9
|
-
import { PopupService } from '@progress/kendo-angular-popup';
|
|
10
|
-
import * as i0 from "@angular/core";
|
|
11
|
-
import * as i1 from "./upload.component";
|
|
12
|
-
import * as i2 from "./rendering/upload-action-buttons.component";
|
|
13
|
-
import * as i3 from "./rendering/upload-status-total.component";
|
|
14
|
-
import * as i4 from "./templates/file-template.directive";
|
|
15
|
-
import * as i5 from "./templates/file-info-template.directive";
|
|
16
|
-
import * as i6 from "./localization/custom-messages.component";
|
|
17
|
-
import * as i7 from "./dropzone-external.directive";
|
|
18
|
-
import * as i8 from "./dropzone.component";
|
|
19
|
-
// IMPORTANT: NgModule export kept for backwards compatibility
|
|
20
|
-
/**
|
|
21
|
-
* Represents the [NgModule](https://angular.io/api/core/NgModule) definition for the Upload component.
|
|
22
|
-
*/
|
|
23
|
-
export class UploadModule {
|
|
24
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
25
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: UploadModule, imports: [i1.UploadComponent, i2.UploadActionButtonsComponent, i3.UploadStatusTotalComponent, i4.FileTemplateDirective, i5.FileInfoTemplateDirective, i6.CustomMessagesComponent, i7.UploadDropZoneDirective, i8.UploadDropZoneComponent], exports: [i1.UploadComponent, i2.UploadActionButtonsComponent, i3.UploadStatusTotalComponent, i4.FileTemplateDirective, i5.FileInfoTemplateDirective, i6.CustomMessagesComponent, i7.UploadDropZoneDirective, i8.UploadDropZoneComponent] });
|
|
26
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadModule, providers: [
|
|
27
|
-
IconsService,
|
|
28
|
-
PopupService,
|
|
29
|
-
ResizeBatchService
|
|
30
|
-
], imports: [i1.UploadComponent, i3.UploadStatusTotalComponent, i8.UploadDropZoneComponent] });
|
|
31
|
-
}
|
|
32
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadModule, decorators: [{
|
|
33
|
-
type: NgModule,
|
|
34
|
-
args: [{
|
|
35
|
-
exports: [...KENDO_UPLOAD],
|
|
36
|
-
imports: [...KENDO_UPLOAD],
|
|
37
|
-
providers: [
|
|
38
|
-
IconsService,
|
|
39
|
-
PopupService,
|
|
40
|
-
ResizeBatchService
|
|
41
|
-
]
|
|
42
|
-
}]
|
|
43
|
-
}] });
|
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { HttpClient, HttpEventType, HttpHeaders, HttpRequest, HttpResponse } from '@angular/common/http';
|
|
6
|
-
import { EventEmitter, Injectable } from '@angular/core';
|
|
7
|
-
import { FileState } from './types';
|
|
8
|
-
import { FileMap } from './types/file-map';
|
|
9
|
-
import { CancelEvent, ClearEvent, ErrorEvent, PauseEvent, RemoveEvent, ResumeEvent, SelectEvent, SuccessEvent, UploadEvent, UploadProgressEvent } from './events';
|
|
10
|
-
import { getInitialFileInfo, convertFileToFileInfo } from './common/util';
|
|
11
|
-
import { ChunkMap } from './types/chunk-map';
|
|
12
|
-
import * as i0 from "@angular/core";
|
|
13
|
-
import * as i1 from "@angular/common/http";
|
|
14
|
-
/**
|
|
15
|
-
* @hidden
|
|
16
|
-
*/
|
|
17
|
-
export class UploadService {
|
|
18
|
-
http;
|
|
19
|
-
cancelEvent = new EventEmitter();
|
|
20
|
-
clearEvent = new EventEmitter();
|
|
21
|
-
completeEvent = new EventEmitter();
|
|
22
|
-
errorEvent = new EventEmitter();
|
|
23
|
-
pauseEvent = new EventEmitter();
|
|
24
|
-
removeEvent = new EventEmitter();
|
|
25
|
-
resumeEvent = new EventEmitter();
|
|
26
|
-
selectEvent = new EventEmitter();
|
|
27
|
-
successEvent = new EventEmitter();
|
|
28
|
-
uploadEvent = new EventEmitter();
|
|
29
|
-
uploadProgressEvent = new EventEmitter();
|
|
30
|
-
/**
|
|
31
|
-
* Required for the `ControlValueAccessor` integration
|
|
32
|
-
*/
|
|
33
|
-
changeEvent = new EventEmitter();
|
|
34
|
-
/**
|
|
35
|
-
* Default async settings
|
|
36
|
-
*/
|
|
37
|
-
async = {
|
|
38
|
-
autoUpload: true,
|
|
39
|
-
batch: false,
|
|
40
|
-
chunk: false,
|
|
41
|
-
concurrent: true,
|
|
42
|
-
removeField: "fileNames",
|
|
43
|
-
removeHeaders: new HttpHeaders(),
|
|
44
|
-
removeMethod: "POST",
|
|
45
|
-
removeUrl: "",
|
|
46
|
-
responseType: "json",
|
|
47
|
-
saveField: "files",
|
|
48
|
-
saveHeaders: new HttpHeaders(),
|
|
49
|
-
saveMethod: "POST",
|
|
50
|
-
saveUrl: "",
|
|
51
|
-
withCredentials: true
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Default chunk settings
|
|
55
|
-
*/
|
|
56
|
-
chunk = {
|
|
57
|
-
autoRetryAfter: 100,
|
|
58
|
-
size: 1024 * 1024,
|
|
59
|
-
maxAutoRetries: 1,
|
|
60
|
-
resumable: true
|
|
61
|
-
};
|
|
62
|
-
component = 'Upload';
|
|
63
|
-
chunkMap = new ChunkMap();
|
|
64
|
-
fileList = new FileMap();
|
|
65
|
-
constructor(http) {
|
|
66
|
-
this.http = http;
|
|
67
|
-
}
|
|
68
|
-
get files() {
|
|
69
|
-
return this.fileList;
|
|
70
|
-
}
|
|
71
|
-
setChunkSettings(settings) {
|
|
72
|
-
if (settings !== false) {
|
|
73
|
-
this.async.chunk = true;
|
|
74
|
-
if (typeof settings === "object") {
|
|
75
|
-
this.chunk = Object.assign({}, this.chunk, settings);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
onChange() {
|
|
80
|
-
const files = this.fileList.filesFlat.filter((file) => {
|
|
81
|
-
return file.state === FileState.Initial ||
|
|
82
|
-
file.state === FileState.Uploaded;
|
|
83
|
-
});
|
|
84
|
-
this.changeEvent.emit(files.length > 0 ? files : null);
|
|
85
|
-
}
|
|
86
|
-
addFiles(files) {
|
|
87
|
-
const selectEventArgs = new SelectEvent(files);
|
|
88
|
-
this.selectEvent.emit(selectEventArgs);
|
|
89
|
-
if (!selectEventArgs.isDefaultPrevented()) {
|
|
90
|
-
for (const file of files) {
|
|
91
|
-
this.fileList.add(file);
|
|
92
|
-
}
|
|
93
|
-
if (this.async.autoUpload) {
|
|
94
|
-
this.uploadFiles();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (this.component === 'FileSelect') {
|
|
98
|
-
const flatFiles = this.fileList.filesFlat;
|
|
99
|
-
this.changeEvent.emit(flatFiles.length > 0 ? flatFiles : null);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
addInitialFiles(initialFiles) {
|
|
103
|
-
this.fileList.clear();
|
|
104
|
-
initialFiles.forEach((file) => {
|
|
105
|
-
const fakeFile = getInitialFileInfo(file);
|
|
106
|
-
this.fileList.add(fakeFile);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
addInitialFileSelectFiles(initialFiles) {
|
|
110
|
-
this.fileList.clear();
|
|
111
|
-
initialFiles.forEach((file) => {
|
|
112
|
-
if (file instanceof File) {
|
|
113
|
-
this.fileList.add(convertFileToFileInfo(file));
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
this.fileList.add(getInitialFileInfo(file));
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
resumeFile(uid) {
|
|
121
|
-
const fileToResume = this.fileList.get(uid);
|
|
122
|
-
this.resumeEvent.emit(new ResumeEvent(fileToResume[0]));
|
|
123
|
-
this.fileList.setFilesStateByUid(uid, FileState.Uploading);
|
|
124
|
-
this._uploadFiles([fileToResume]);
|
|
125
|
-
}
|
|
126
|
-
pauseFile(uid) {
|
|
127
|
-
const pausedFile = this.fileList.get(uid)[0];
|
|
128
|
-
this.pauseEvent.emit(new PauseEvent(pausedFile));
|
|
129
|
-
this.fileList.setFilesStateByUid(uid, FileState.Paused);
|
|
130
|
-
}
|
|
131
|
-
removeFiles(uid) {
|
|
132
|
-
const removedFiles = this.fileList.get(uid);
|
|
133
|
-
// Clone the Headers so that the default ones are not overridden
|
|
134
|
-
const removeEventArgs = new RemoveEvent(removedFiles, this.cloneRequestHeaders(this.async.removeHeaders));
|
|
135
|
-
this.removeEvent.emit(removeEventArgs);
|
|
136
|
-
if (!removeEventArgs.isDefaultPrevented()) {
|
|
137
|
-
if (this.component === 'Upload' &&
|
|
138
|
-
(removedFiles[0].state === FileState.Uploaded ||
|
|
139
|
-
removedFiles[0].state === FileState.Initial)) {
|
|
140
|
-
this.performRemove(removedFiles, removeEventArgs);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
this.fileList.remove(uid);
|
|
144
|
-
if (this.component === 'FileSelect') {
|
|
145
|
-
const flatFiles = this.fileList.filesFlat;
|
|
146
|
-
this.changeEvent.emit(flatFiles.length > 0 ? flatFiles : null);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
cancelFiles(uid) {
|
|
152
|
-
const canceledFiles = this.fileList.get(uid);
|
|
153
|
-
const cancelEventArgs = new CancelEvent(canceledFiles);
|
|
154
|
-
this.cancelEvent.emit(cancelEventArgs);
|
|
155
|
-
for (const file of canceledFiles) {
|
|
156
|
-
if (file.httpSubscription) {
|
|
157
|
-
file.httpSubscription.unsubscribe();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
this.fileList.remove(uid);
|
|
161
|
-
this.checkAllComplete();
|
|
162
|
-
}
|
|
163
|
-
clearFiles() {
|
|
164
|
-
const clearEventArgs = new ClearEvent();
|
|
165
|
-
this.clearEvent.emit(clearEventArgs);
|
|
166
|
-
if (!clearEventArgs.isDefaultPrevented()) {
|
|
167
|
-
const triggerChange = this.fileList.hasFileWithState([
|
|
168
|
-
FileState.Initial,
|
|
169
|
-
FileState.Uploaded
|
|
170
|
-
]);
|
|
171
|
-
this.fileList.clear();
|
|
172
|
-
if (triggerChange) {
|
|
173
|
-
this.onChange();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
uploadFiles() {
|
|
178
|
-
let filesToUpload = [];
|
|
179
|
-
if (this.async.concurrent) {
|
|
180
|
-
filesToUpload = this.fileList.filesToUpload;
|
|
181
|
-
}
|
|
182
|
-
if (!this.async.concurrent && !this.fileList.hasFileWithState([FileState.Uploading])) {
|
|
183
|
-
filesToUpload = this.fileList.firstFileToUpload ? [this.fileList.firstFileToUpload] : [];
|
|
184
|
-
}
|
|
185
|
-
if (filesToUpload && filesToUpload.length > 0) {
|
|
186
|
-
this._uploadFiles(filesToUpload);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
retryFiles(uid) {
|
|
190
|
-
const filesToRetry = [this.fileList.get(uid)];
|
|
191
|
-
if (filesToRetry) {
|
|
192
|
-
this._uploadFiles(filesToRetry);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
_uploadFiles(allFiles) {
|
|
196
|
-
for (const filesToUpload of allFiles) {
|
|
197
|
-
if (filesToUpload[0].state === FileState.Paused) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
// Clone the Headers so that the default ones are not overridden
|
|
201
|
-
const uploadEventArgs = new UploadEvent(filesToUpload, this.cloneRequestHeaders(this.async.saveHeaders));
|
|
202
|
-
this.uploadEvent.emit(uploadEventArgs);
|
|
203
|
-
if (!uploadEventArgs.isDefaultPrevented()) {
|
|
204
|
-
this.fileList.setFilesState(filesToUpload, FileState.Uploading);
|
|
205
|
-
const httpSubcription = this.performUpload(filesToUpload, uploadEventArgs);
|
|
206
|
-
filesToUpload.forEach((file) => {
|
|
207
|
-
file.httpSubscription = httpSubcription;
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
this.fileList.remove(filesToUpload[0].uid);
|
|
212
|
-
this.checkAllComplete();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
performRemove(files, removeEventArgs) {
|
|
217
|
-
const async = this.async;
|
|
218
|
-
const fileNames = files.map((file) => {
|
|
219
|
-
return file.name;
|
|
220
|
-
});
|
|
221
|
-
const formData = this.populateRemoveFormData(fileNames, removeEventArgs.data);
|
|
222
|
-
const options = this.populateRequestOptions(removeEventArgs.headers, false);
|
|
223
|
-
const removeRequest = new HttpRequest(async.removeMethod, async.removeUrl, formData, options);
|
|
224
|
-
this.http.request(removeRequest)
|
|
225
|
-
.subscribe(success => {
|
|
226
|
-
this.onSuccess(success, files, "remove");
|
|
227
|
-
}, error => {
|
|
228
|
-
this.onError(error, files, "remove");
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
performUpload(files, uploadEventArgs) {
|
|
232
|
-
const async = this.async;
|
|
233
|
-
const formData = this.populateUploadFormData(files, uploadEventArgs.data);
|
|
234
|
-
const options = this.populateRequestOptions(uploadEventArgs.headers);
|
|
235
|
-
const uploadRequest = new HttpRequest(async.saveMethod, async.saveUrl, formData, options);
|
|
236
|
-
const httpSubscription = this.http.request(uploadRequest)
|
|
237
|
-
.subscribe(event => {
|
|
238
|
-
if (event.type === HttpEventType.UploadProgress && !this.async.chunk) {
|
|
239
|
-
this.onProgress(event, files);
|
|
240
|
-
}
|
|
241
|
-
else if (event instanceof HttpResponse) {
|
|
242
|
-
this.onSuccess(event, files, "upload");
|
|
243
|
-
this.checkAllComplete();
|
|
244
|
-
}
|
|
245
|
-
}, error => {
|
|
246
|
-
this.onError(error, files, "upload");
|
|
247
|
-
this.checkAllComplete();
|
|
248
|
-
});
|
|
249
|
-
return httpSubscription;
|
|
250
|
-
}
|
|
251
|
-
onSuccess(successResponse, files, operation) {
|
|
252
|
-
if (operation === "upload" && this.async.chunk) {
|
|
253
|
-
this.onChunkProgress(files);
|
|
254
|
-
if (this.isChunkUploadComplete(files[0].uid)) {
|
|
255
|
-
this.removeChunkInfo(files[0].uid);
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
this.updateChunkInfo(files[0].uid);
|
|
259
|
-
this._uploadFiles([files]);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
const successArgs = new SuccessEvent(files, operation, successResponse);
|
|
264
|
-
this.successEvent.emit(successArgs);
|
|
265
|
-
if (operation === "upload") {
|
|
266
|
-
this.fileList.setFilesState(files, successArgs.isDefaultPrevented() ? FileState.Failed : FileState.Uploaded);
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
if (!successArgs.isDefaultPrevented()) {
|
|
270
|
-
this.fileList.remove(files[0].uid);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (!successArgs.isDefaultPrevented()) {
|
|
274
|
-
this.onChange();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
onError(errorResponse, files, operation) {
|
|
278
|
-
if (operation === "upload" && this.async.chunk) {
|
|
279
|
-
const maxRetries = this.chunk.maxAutoRetries;
|
|
280
|
-
const chunkInfo = this.chunkMap.get(files[0].uid);
|
|
281
|
-
if (chunkInfo.retries < maxRetries) {
|
|
282
|
-
chunkInfo.retries += 1;
|
|
283
|
-
setTimeout(() => {
|
|
284
|
-
this.retryFiles(files[0].uid);
|
|
285
|
-
}, this.chunk.autoRetryAfter);
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
const errorArgs = new ErrorEvent(files, operation, errorResponse);
|
|
290
|
-
this.errorEvent.emit(errorArgs);
|
|
291
|
-
if (operation === "upload") {
|
|
292
|
-
this.fileList.setFilesState(files, FileState.Failed);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
onProgress(event, files) {
|
|
296
|
-
const percentComplete = Math.round(100 * event.loaded / event.total);
|
|
297
|
-
const progressArgs = new UploadProgressEvent(files, percentComplete < 100 ? percentComplete : 100);
|
|
298
|
-
this.uploadProgressEvent.emit(progressArgs);
|
|
299
|
-
}
|
|
300
|
-
onChunkProgress(files) {
|
|
301
|
-
const chunkInfo = this.chunkMap.get(files[0].uid);
|
|
302
|
-
let percentComplete = 0;
|
|
303
|
-
if (chunkInfo) {
|
|
304
|
-
if (chunkInfo.index === chunkInfo.totalChunks - 1) {
|
|
305
|
-
percentComplete = 100;
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
percentComplete = Math.round(((chunkInfo.index + 1) / chunkInfo.totalChunks) * 100);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
const progressArgs = new UploadProgressEvent(files, percentComplete < 100 ? percentComplete : 100);
|
|
312
|
-
this.uploadProgressEvent.emit(progressArgs);
|
|
313
|
-
}
|
|
314
|
-
checkAllComplete() {
|
|
315
|
-
if (!this.fileList.hasFileWithState([
|
|
316
|
-
FileState.Uploading,
|
|
317
|
-
FileState.Paused
|
|
318
|
-
]) && this.areAllSelectedFilesHandled()) {
|
|
319
|
-
this.completeEvent.emit();
|
|
320
|
-
}
|
|
321
|
-
else if (this.shouldUploadNextFile()) {
|
|
322
|
-
this.uploadFiles();
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
shouldUploadNextFile() {
|
|
326
|
-
return !this.async.concurrent &&
|
|
327
|
-
this.fileList.hasFileWithState([FileState.Selected]) &&
|
|
328
|
-
!this.fileList.hasFileWithState([FileState.Uploading]);
|
|
329
|
-
}
|
|
330
|
-
areAllSelectedFilesHandled() {
|
|
331
|
-
const validSelectedFiles = this.fileList.getFilesWithState(FileState.Selected).filter(file => !file.validationErrors);
|
|
332
|
-
return validSelectedFiles.length === 0;
|
|
333
|
-
}
|
|
334
|
-
cloneRequestHeaders(headers) {
|
|
335
|
-
const cloned = {};
|
|
336
|
-
if (headers) {
|
|
337
|
-
headers.keys().forEach((key) => {
|
|
338
|
-
if (key !== 'constructor' && key !== '__proto__' && key !== 'prototype')
|
|
339
|
-
cloned[key] = headers.get(key);
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
return new HttpHeaders(cloned);
|
|
343
|
-
}
|
|
344
|
-
populateRequestOptions(headers, reportProgress = true) {
|
|
345
|
-
return {
|
|
346
|
-
headers: headers,
|
|
347
|
-
reportProgress: reportProgress,
|
|
348
|
-
responseType: this.async.responseType,
|
|
349
|
-
withCredentials: this.async.withCredentials
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
populateUploadFormData(files, clientData) {
|
|
353
|
-
const saveField = this.async.saveField;
|
|
354
|
-
const data = new FormData();
|
|
355
|
-
this.populateClientFormData(data, clientData);
|
|
356
|
-
if (this.async.chunk) {
|
|
357
|
-
data.append(saveField, this.getNextChunk(files[0]));
|
|
358
|
-
data.append("metadata", this.getChunkMetadata(files[0]));
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
for (const file of files) {
|
|
362
|
-
data.append(saveField, file.rawFile);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
return data;
|
|
366
|
-
}
|
|
367
|
-
populateRemoveFormData(fileNames, clientData) {
|
|
368
|
-
const data = new FormData();
|
|
369
|
-
this.populateClientFormData(data, clientData);
|
|
370
|
-
for (const fileName of fileNames) {
|
|
371
|
-
data.append(this.async.removeField, fileName);
|
|
372
|
-
}
|
|
373
|
-
return data;
|
|
374
|
-
}
|
|
375
|
-
populateClientFormData(data, clientData) {
|
|
376
|
-
for (const key in clientData) {
|
|
377
|
-
if (clientData.hasOwnProperty(key)) {
|
|
378
|
-
data.append(key, clientData[key]);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
/* Chunking Helper Methods Section */
|
|
383
|
-
getNextChunk(file) {
|
|
384
|
-
const info = this.getChunkInfo(file);
|
|
385
|
-
const newPosition = info.position + this.chunk.size;
|
|
386
|
-
return file.rawFile.slice(info.position, newPosition);
|
|
387
|
-
}
|
|
388
|
-
getChunkInfo(file) {
|
|
389
|
-
let chunkInfo = this.chunkMap.get(file.uid);
|
|
390
|
-
if (!chunkInfo) {
|
|
391
|
-
const totalChunks = file.size > 0 ? Math.ceil(file.size / this.chunk.size) : 1;
|
|
392
|
-
chunkInfo = this.chunkMap.add(file.uid, totalChunks);
|
|
393
|
-
}
|
|
394
|
-
return chunkInfo;
|
|
395
|
-
}
|
|
396
|
-
updateChunkInfo(uid) {
|
|
397
|
-
const chunkInfo = this.chunkMap.get(uid);
|
|
398
|
-
if (chunkInfo.index < chunkInfo.totalChunks - 1) {
|
|
399
|
-
chunkInfo.index += 1;
|
|
400
|
-
chunkInfo.position += this.chunk.size;
|
|
401
|
-
chunkInfo.retries = 0;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
removeChunkInfo(uid) {
|
|
405
|
-
this.chunkMap.remove(uid);
|
|
406
|
-
}
|
|
407
|
-
getChunkMetadata(file) {
|
|
408
|
-
const chunkInfo = this.chunkMap.get(file.uid);
|
|
409
|
-
const chunkMetadata = {
|
|
410
|
-
chunkIndex: chunkInfo.index,
|
|
411
|
-
contentType: file.rawFile.type,
|
|
412
|
-
fileName: file.name,
|
|
413
|
-
fileSize: file.size,
|
|
414
|
-
fileUid: file.uid,
|
|
415
|
-
totalChunks: chunkInfo.totalChunks
|
|
416
|
-
};
|
|
417
|
-
return JSON.stringify(chunkMetadata);
|
|
418
|
-
}
|
|
419
|
-
isChunkUploadComplete(uid) {
|
|
420
|
-
const chunkInfo = this.chunkMap.get(uid);
|
|
421
|
-
if (chunkInfo) {
|
|
422
|
-
return chunkInfo.index + 1 === chunkInfo.totalChunks;
|
|
423
|
-
}
|
|
424
|
-
return false;
|
|
425
|
-
}
|
|
426
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
427
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadService });
|
|
428
|
-
}
|
|
429
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadService, decorators: [{
|
|
430
|
-
type: Injectable
|
|
431
|
-
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { NgModule } from '@angular/core';
|
|
6
|
-
import { KENDO_UPLOADS } from './directives';
|
|
7
|
-
import { ResizeBatchService } from '@progress/kendo-angular-common';
|
|
8
|
-
import { IconsService } from '@progress/kendo-angular-icons';
|
|
9
|
-
import { PopupService } from '@progress/kendo-angular-popup';
|
|
10
|
-
import * as i0 from "@angular/core";
|
|
11
|
-
import * as i1 from "./fileselect.component";
|
|
12
|
-
import * as i2 from "./templates/file-template.directive";
|
|
13
|
-
import * as i3 from "./templates/file-info-template.directive";
|
|
14
|
-
import * as i4 from "./localization/custom-messages.component";
|
|
15
|
-
import * as i5 from "./dropzone-external.directive";
|
|
16
|
-
import * as i6 from "./dropzone.component";
|
|
17
|
-
import * as i7 from "./upload.component";
|
|
18
|
-
import * as i8 from "./rendering/upload-action-buttons.component";
|
|
19
|
-
import * as i9 from "./rendering/upload-status-total.component";
|
|
20
|
-
// IMPORTANT: NgModule export kept for backwards compatibility
|
|
21
|
-
/**
|
|
22
|
-
* Represents the [NgModule](link:site.data.urls.angular['ngmoduleapi'])
|
|
23
|
-
* definition for the Uploads components.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
*
|
|
27
|
-
* ```ts-no-run
|
|
28
|
-
* import { UploadsModule } from '@progress/kendo-angular-upload';
|
|
29
|
-
*
|
|
30
|
-
* import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
31
|
-
* import { NgModule } from '@angular/core';
|
|
32
|
-
*
|
|
33
|
-
* import { AppComponent } from './app.component';
|
|
34
|
-
*
|
|
35
|
-
* _@NgModule({
|
|
36
|
-
* declarations: [AppComponent],
|
|
37
|
-
* imports: [BrowserModule, UploadsModule],
|
|
38
|
-
* bootstrap: [AppComponent]
|
|
39
|
-
* })
|
|
40
|
-
* export class AppModule {}
|
|
41
|
-
*
|
|
42
|
-
* platformBrowserDynamic().bootstrapModule(AppModule);
|
|
43
|
-
*
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export class UploadsModule {
|
|
47
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
48
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: UploadsModule, imports: [i1.FileSelectComponent, i2.FileTemplateDirective, i3.FileInfoTemplateDirective, i4.CustomMessagesComponent, i5.UploadDropZoneDirective, i6.UploadDropZoneComponent, i7.UploadComponent, i8.UploadActionButtonsComponent, i9.UploadStatusTotalComponent, i2.FileTemplateDirective, i3.FileInfoTemplateDirective, i4.CustomMessagesComponent, i5.UploadDropZoneDirective, i6.UploadDropZoneComponent], exports: [i1.FileSelectComponent, i2.FileTemplateDirective, i3.FileInfoTemplateDirective, i4.CustomMessagesComponent, i5.UploadDropZoneDirective, i6.UploadDropZoneComponent, i7.UploadComponent, i8.UploadActionButtonsComponent, i9.UploadStatusTotalComponent, i2.FileTemplateDirective, i3.FileInfoTemplateDirective, i4.CustomMessagesComponent, i5.UploadDropZoneDirective, i6.UploadDropZoneComponent] });
|
|
49
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadsModule, providers: [
|
|
50
|
-
IconsService,
|
|
51
|
-
PopupService,
|
|
52
|
-
ResizeBatchService
|
|
53
|
-
], imports: [i1.FileSelectComponent, i6.UploadDropZoneComponent, i7.UploadComponent, i9.UploadStatusTotalComponent, i6.UploadDropZoneComponent] });
|
|
54
|
-
}
|
|
55
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: UploadsModule, decorators: [{
|
|
56
|
-
type: NgModule,
|
|
57
|
-
args: [{
|
|
58
|
-
exports: [...KENDO_UPLOADS],
|
|
59
|
-
imports: [...KENDO_UPLOADS],
|
|
60
|
-
providers: [
|
|
61
|
-
IconsService,
|
|
62
|
-
PopupService,
|
|
63
|
-
ResizeBatchService
|
|
64
|
-
]
|
|
65
|
-
}]
|
|
66
|
-
}] });
|