@gsp-svc/formdoc-upload 0.1.35 → 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
  }());
@@ -994,12 +1020,6 @@ var FileUploadComponent = /** @class */ (function () {
994
1020
  return "continue";
995
1021
  }
996
1022
  }
997
- // if (this.files.find(x => x.name == selectedFile.name) != null) {
998
- // this.errFileList.push(selectedFile.name);
999
- // continue;
1000
- // }
1001
- //this.flag += Math.ceil(selectedFile.size / this.bufferSize);
1002
- //let reader = new FileReader();
1003
1023
  this_1.uploadFile(uuid, selectedFile, selectedFile.name);
1004
1024
  };
1005
1025
  var this_1 = this;
@@ -1127,49 +1147,52 @@ var FileUploadComponent = /** @class */ (function () {
1127
1147
  var nextSize = Math.min((chunkIndex + 1) * this_2.bufferSize, selectedFile.size);
1128
1148
  /** @type {?} */
1129
1149
  var fileData = selectedFile.slice(chunkIndex * this_2.bufferSize, nextSize);
1130
- /** @type {?} */
1131
- var reader = new FileReader();
1132
- reader.readAsBinaryString(fileData);
1150
+ // let reader = new FileReader();
1151
+ // reader.readAsBinaryString(fileData);
1133
1152
  /** @type {?} */
1134
1153
  var innerIndex = chunkIndex;
1135
- 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
1136
1175
  * @return {?}
1137
1176
  */
1138
- function () {
1139
- docInfo.fileContent = btoa(reader.result.toString());
1140
- docInfo.index = innerIndex;
1141
- //chunkIndex++;
1142
- if (_this.haveExtensionProperty)
1143
- docInfo.exPropertyName = _this.defaultPropertyName;
1144
- //docInfo.isLast = true;
1145
- uploadInfo.docInfo = docInfo;
1146
- /** @type {?} */
1147
- var info = uploadInfo;
1148
- // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1149
- _this.requestBodyArray.push(info);
1150
- _this.uploadService.uploadFile(info).subscribe((/**
1151
- * @param {?} res
1152
- * @return {?}
1153
- */
1154
- function (res) {
1155
- if (res != null) {
1156
- _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;
1157
1188
  _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1158
- _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++;
1159
1192
  }
1160
- else {
1161
- _this.uploadedChunk[docInfo.metadataId]++;
1162
- _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[docInfo.metadataId] / _this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1163
- if (_this.uploadedChunk[docInfo.metadataId] == _this.fileTotalChunk[docInfo.metadataId]) {
1164
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1165
- _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1166
- _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1167
- _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1168
- _this.uploadedFileTotal++;
1169
- }
1170
- }
1171
- }));
1172
- });
1193
+ }
1194
+ }));
1195
+ // }
1173
1196
  //console.log(chunkIndex + 1);
1174
1197
  chunkIndex = chunkIndex + 1;
1175
1198
  };