@gsp-svc/formdoc-upload 0.1.34 → 0.1.36

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.
@@ -11,10 +11,10 @@ import { ProgressModule } from '@farris/ui-progress';
11
11
  import { FormsModule } from '@angular/forms';
12
12
  import { ComboListModule } from '@farris/ui-combo-list';
13
13
  import { LanguageService, HttpService } from '@ecp-caf/caf-common';
14
- import { Injectable, Pipe, Inject, LOCALE_ID, NgModule, Component, ViewChild, Input, Injector, ComponentFactoryResolver, defineInjectable } from '@angular/core';
14
+ import { Injectable, Pipe, Inject, LOCALE_ID, NgModule, Component, Injector, ComponentFactoryResolver, ViewChild, Input, defineInjectable } from '@angular/core';
15
15
  import { BsModalService } from '@farris/ui-modal';
16
16
  import { of as of$1 } from 'rxjs';
17
- import { HttpClientModule } from '@angular/common/http';
17
+ import { HttpClient, HttpClientModule } from '@angular/common/http';
18
18
  import { NotifyModule } from '@farris/ui-notify';
19
19
 
20
20
  /**
@@ -160,8 +160,9 @@ var ChangeInstanceRequest = /** @class */ (function () {
160
160
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
161
161
  */
162
162
  var UploadService = /** @class */ (function () {
163
- function UploadService(http) {
163
+ function UploadService(http, httpclient) {
164
164
  this.http = http;
165
+ this.httpclient = httpclient;
165
166
  }
166
167
  /**
167
168
  * @param {?} docListInfo
@@ -309,6 +310,30 @@ var UploadService = /** @class */ (function () {
309
310
  return of(error);
310
311
  })));
311
312
  };
313
+ /**
314
+ * @param {?} formdata
315
+ * @return {?}
316
+ */
317
+ UploadService.prototype.uploadSliceFile = /**
318
+ * @param {?} formdata
319
+ * @return {?}
320
+ */
321
+ function (formdata) {
322
+ /** @type {?} */
323
+ var url = "/api/runtime/dfs/v1.0/formdoc/slice";
324
+ //url = "/api/runtime/dfs/v1.0/formdoc/list";
325
+ return this.httpclient.post(url, formdata).pipe(tap((/**
326
+ * @param {?} res
327
+ * @return {?}
328
+ */
329
+ function (res) { })), catchError((/**
330
+ * @param {?} error
331
+ * @return {?}
332
+ */
333
+ function (error) {
334
+ return of(error);
335
+ })));
336
+ };
312
337
  /**
313
338
  * @return {?}
314
339
  */
@@ -497,7 +522,8 @@ var UploadService = /** @class */ (function () {
497
522
  ];
498
523
  /** @nocollapse */
499
524
  UploadService.ctorParameters = function () { return [
500
- { type: HttpService }
525
+ { type: HttpService },
526
+ { type: HttpClient }
501
527
  ]; };
502
528
  return UploadService;
503
529
  }());
@@ -897,9 +923,11 @@ var FileUploadComponent = /** @class */ (function () {
897
923
  this_1.nullFileList.push(selectedFile.name);
898
924
  return "continue";
899
925
  }
900
- if (selectedFile.size > this_1.maxFileSize * 1000) {
901
- this_1.beyondFileList.push(selectedFile.name);
902
- return "continue";
926
+ if (this_1.maxFileSize != null && this_1.maxFileSize > 0) {
927
+ if (selectedFile.size > this_1.maxFileSize * 1000) {
928
+ this_1.beyondFileList.push(selectedFile.name);
929
+ return "continue";
930
+ }
903
931
  }
904
932
  if (!this_1.sameNameAllowed) {
905
933
  if (this_1.uploadedFileInfoList.find((/**
@@ -992,12 +1020,6 @@ var FileUploadComponent = /** @class */ (function () {
992
1020
  return "continue";
993
1021
  }
994
1022
  }
995
- // if (this.files.find(x => x.name == selectedFile.name) != null) {
996
- // this.errFileList.push(selectedFile.name);
997
- // continue;
998
- // }
999
- //this.flag += Math.ceil(selectedFile.size / this.bufferSize);
1000
- //let reader = new FileReader();
1001
1023
  this_1.uploadFile(uuid, selectedFile, selectedFile.name);
1002
1024
  };
1003
1025
  var this_1 = this;
@@ -1125,49 +1147,52 @@ var FileUploadComponent = /** @class */ (function () {
1125
1147
  var nextSize = Math.min((chunkIndex + 1) * this_2.bufferSize, selectedFile.size);
1126
1148
  /** @type {?} */
1127
1149
  var fileData = selectedFile.slice(chunkIndex * this_2.bufferSize, nextSize);
1128
- /** @type {?} */
1129
- var reader = new FileReader();
1130
- reader.readAsBinaryString(fileData);
1150
+ // let reader = new FileReader();
1151
+ // reader.readAsBinaryString(fileData);
1131
1152
  /** @type {?} */
1132
1153
  var innerIndex = chunkIndex;
1133
- reader.onload = (/**
1154
+ // reader.onload = () => {
1155
+ // docInfo.fileContent = btoa(reader.result.toString());
1156
+ docInfo.size = selectedFile.size;
1157
+ docInfo.index = innerIndex;
1158
+ docInfo.fileContent = "";
1159
+ //chunkIndex++;
1160
+ if (this_2.haveExtensionProperty)
1161
+ docInfo.exPropertyName = this_2.defaultPropertyName;
1162
+ //docInfo.isLast = true;
1163
+ uploadInfo.docInfo = docInfo;
1164
+ // let info = uploadInfo;
1165
+ // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1166
+ // this.requestBodyArray.push(info);
1167
+ //封装请求formdata
1168
+ /** @type {?} */
1169
+ var formData = new FormData();
1170
+ formData.append('uploadInfo', JSON.stringify(uploadInfo));
1171
+ formData.append('docInfo', JSON.stringify(docInfo));
1172
+ formData.append('file', fileData);
1173
+ this_2.uploadService.uploadSliceFile(formData).subscribe((/**
1174
+ * @param {?} res
1134
1175
  * @return {?}
1135
1176
  */
1136
- function () {
1137
- docInfo.fileContent = btoa(reader.result.toString());
1138
- docInfo.index = innerIndex;
1139
- //chunkIndex++;
1140
- if (_this.haveExtensionProperty)
1141
- docInfo.exPropertyName = _this.defaultPropertyName;
1142
- //docInfo.isLast = true;
1143
- uploadInfo.docInfo = docInfo;
1144
- /** @type {?} */
1145
- var info = uploadInfo;
1146
- // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1147
- _this.requestBodyArray.push(info);
1148
- _this.uploadService.uploadFile(info).subscribe((/**
1149
- * @param {?} res
1150
- * @return {?}
1151
- */
1152
- function (res) {
1153
- if (res != null) {
1154
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1177
+ function (res) {
1178
+ if (res != null) {
1179
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1180
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1181
+ _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1182
+ }
1183
+ else {
1184
+ _this.uploadedChunk[docInfo.metadataId]++;
1185
+ _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[docInfo.metadataId] / _this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1186
+ if (_this.uploadedChunk[docInfo.metadataId] == _this.fileTotalChunk[docInfo.metadataId]) {
1187
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1155
1188
  _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1156
- _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1189
+ _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1190
+ _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1191
+ _this.uploadedFileTotal++;
1157
1192
  }
1158
- else {
1159
- _this.uploadedChunk[docInfo.metadataId]++;
1160
- _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[docInfo.metadataId] / _this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1161
- if (_this.uploadedChunk[docInfo.metadataId] == _this.fileTotalChunk[docInfo.metadataId]) {
1162
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1163
- _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1164
- _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1165
- _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1166
- _this.uploadedFileTotal++;
1167
- }
1168
- }
1169
- }));
1170
- });
1193
+ }
1194
+ }));
1195
+ // }
1171
1196
  //console.log(chunkIndex + 1);
1172
1197
  chunkIndex = chunkIndex + 1;
1173
1198
  };