@gsp-svc/formdoc-upload 0.1.38 → 0.1.39

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.
@@ -414,15 +414,10 @@
414
414
  request.metadataId = metadataId;
415
415
  request.rootId = rootId;
416
416
  request.path = path;
417
- return this.http.post(url, request).pipe(operators.tap(( /**
417
+ return this.httpclient.post(url, request, { responseType: 'text' }).pipe(operators.tap(( /**
418
418
  * @param {?} res
419
419
  * @return {?}
420
- */function (res) { })), operators.catchError(( /**
421
- * @param {?} error
422
- * @return {?}
423
- */function (error) {
424
- return of.of(error);
425
- })));
420
+ */function (res) { })));
426
421
  };
427
422
  /**
428
423
  * @param {?} uploadFileInfoList
@@ -1072,68 +1067,62 @@
1072
1067
  * @return {?}
1073
1068
  */
1074
1069
  function (uuid, selectedFile, fileName) {
1075
- var _this = this;
1076
- return new Promise(( /**
1077
- * @param {?} resolve
1078
- * @return {?}
1079
- */function (resolve) {
1080
- /** @type {?} */
1081
- var fileInfo;
1082
- fileInfo = {
1083
- id: uuid,
1084
- name: fileName,
1085
- type: selectedFile.type,
1086
- source: "",
1087
- size: _this.getFileSize(selectedFile.size),
1088
- fileSize: selectedFile.size,
1089
- picListDisplayName: _this.getPicListDisplayName(fileName),
1090
- queueListDisplayName: _this.getQueueDisplayName(fileName),
1091
- //content: reader.result.toString(),
1092
- hasUploaded: false,
1093
- mouseOn: false,
1094
- selectd: false,
1095
- isUploading: true,
1096
- uploadResult: false,
1097
- uploadProcess: 0,
1098
- errorMessage: "",
1099
- extensionDropListId: 0,
1100
- extensionName: "",
1101
- securityDropListId: 0,
1102
- securityInfo: _this.securityInfoList[0]
1103
- };
1104
- if (_this.storageExtension != null)
1105
- fileInfo.extensionName = _this.defaultPropertyName;
1106
- /** @type {?} */
1107
- var type = selectedFile.type;
1108
- if (type.includes("tiff")) {
1109
- _this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1110
- }
1111
- else if (type.includes("image")) {
1112
- _this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1113
- }
1114
- else if (type.includes("word")) {
1115
- _this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1116
- }
1117
- else if (type.includes("pdf")) {
1118
- _this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1119
- }
1120
- else if (type.includes("plain")) {
1121
- _this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1122
- }
1123
- else if (type.includes("sheet") || type.includes("excel")) {
1124
- _this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1125
- }
1126
- else if (type.includes("powerpoint") || type.includes("presentation")) {
1127
- _this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1128
- }
1129
- else {
1130
- _this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1131
- // let name: string = selectedFile.name;
1132
- // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1133
- // this.errTypeList.push(errType);
1134
- }
1135
- resolve(fileInfo);
1136
- }));
1070
+ /** @type {?} */
1071
+ var fileInfo;
1072
+ fileInfo = {
1073
+ id: uuid,
1074
+ name: fileName,
1075
+ type: selectedFile.type,
1076
+ source: "",
1077
+ size: this.getFileSize(selectedFile.size),
1078
+ fileSize: selectedFile.size,
1079
+ picListDisplayName: this.getPicListDisplayName(fileName),
1080
+ queueListDisplayName: this.getQueueDisplayName(fileName),
1081
+ //content: reader.result.toString(),
1082
+ hasUploaded: false,
1083
+ mouseOn: false,
1084
+ selectd: false,
1085
+ isUploading: true,
1086
+ uploadResult: false,
1087
+ uploadProcess: 0,
1088
+ errorMessage: "",
1089
+ extensionDropListId: 0,
1090
+ extensionName: "",
1091
+ securityDropListId: 0,
1092
+ securityInfo: this.securityInfoList[0]
1093
+ };
1094
+ if (this.storageExtension != null)
1095
+ fileInfo.extensionName = this.defaultPropertyName;
1096
+ /** @type {?} */
1097
+ var type = selectedFile.type;
1098
+ if (type.includes("tiff")) {
1099
+ this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1100
+ }
1101
+ else if (type.includes("image")) {
1102
+ this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1103
+ }
1104
+ else if (type.includes("word")) {
1105
+ this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1106
+ }
1107
+ else if (type.includes("pdf")) {
1108
+ this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1109
+ }
1110
+ else if (type.includes("plain")) {
1111
+ this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1112
+ }
1113
+ else if (type.includes("sheet") || type.includes("excel")) {
1114
+ this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1115
+ }
1116
+ else if (type.includes("powerpoint") || type.includes("presentation")) {
1117
+ this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1118
+ }
1119
+ else {
1120
+ this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1121
+ // let name: string = selectedFile.name;
1122
+ // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1123
+ // this.errTypeList.push(errType);
1124
+ }
1125
+ return fileInfo;
1137
1126
  };
1138
1127
  /**
1139
1128
  * @param {?} uuid
@@ -1154,85 +1143,81 @@
1154
1143
  if (state === void 0) {
1155
1144
  state = FileState.New;
1156
1145
  }
1157
- this.handleFileInfo(uuid, selectedFile, fileName).then(( /**
1158
- * @param {?} res
1159
- * @return {?}
1160
- */function (res) {
1146
+ /** @type {?} */
1147
+ var fileInfo = this.handleFileInfo(uuid, selectedFile, fileName);
1148
+ /** @type {?} */
1149
+ var chunkTotal = Math.ceil(selectedFile.size / this.bufferSize);
1150
+ /** @type {?} */
1151
+ var chunkIndex = 0;
1152
+ this.fileTotalChunk[uuid] = chunkTotal;
1153
+ /** @type {?} */
1154
+ var uploadFileInfo = new UploadFileInfo();
1155
+ uploadFileInfo.metadataId = uuid;
1156
+ uploadFileInfo.fileName = fileInfo.name;
1157
+ uploadFileInfo.fileSize = fileInfo.size;
1158
+ uploadFileInfo.state = state;
1159
+ uploadFileInfo.securityInfo = this.securityInfoList[0];
1160
+ while (chunkIndex < chunkTotal) {
1161
1161
  /** @type {?} */
1162
- var fileInfo = res;
1162
+ var uploadInfo = new GspFormUploadEntity;
1163
+ uploadInfo.formId = this.formId;
1164
+ uploadInfo.mode = OperatingModes.Temp;
1165
+ uploadInfo.rootId = this.rootId;
1163
1166
  /** @type {?} */
1164
- var chunkTotal = Math.ceil(selectedFile.size / _this.bufferSize);
1167
+ var docInfo = new GspFormDocInfo;
1168
+ docInfo.fileName = fileName;
1169
+ docInfo.metadataId = uuid;
1170
+ docInfo.total = chunkTotal;
1171
+ this.uploadedChunk[docInfo.metadataId] = 0;
1165
1172
  /** @type {?} */
1166
- var chunkIndex = 0;
1167
- _this.fileTotalChunk[uuid] = chunkTotal;
1173
+ var nextSize = Math.min((chunkIndex + 1) * this.bufferSize, selectedFile.size);
1168
1174
  /** @type {?} */
1169
- var uploadFileInfo = new UploadFileInfo();
1170
- uploadFileInfo.metadataId = uuid;
1171
- uploadFileInfo.fileName = fileInfo.name;
1172
- uploadFileInfo.fileSize = fileInfo.size;
1173
- uploadFileInfo.state = state;
1174
- uploadFileInfo.securityInfo = _this.securityInfoList[0];
1175
- while (chunkIndex < chunkTotal) {
1176
- /** @type {?} */
1177
- var uploadInfo = new GspFormUploadEntity;
1178
- uploadInfo.formId = _this.formId;
1179
- uploadInfo.mode = OperatingModes.Temp;
1180
- uploadInfo.rootId = _this.rootId;
1181
- /** @type {?} */
1182
- var docInfo = new GspFormDocInfo;
1183
- docInfo.fileName = fileName;
1184
- docInfo.metadataId = uuid;
1185
- docInfo.total = chunkTotal;
1186
- _this.uploadedChunk[docInfo.metadataId] = 0;
1187
- /** @type {?} */
1188
- var nextSize = Math.min((chunkIndex + 1) * _this.bufferSize, selectedFile.size);
1189
- /** @type {?} */
1190
- var fileData = selectedFile.slice(chunkIndex * _this.bufferSize, nextSize);
1191
- // let reader = new FileReader();
1192
- // reader.readAsBinaryString(fileData);
1193
- /** @type {?} */
1194
- var innerIndex = chunkIndex;
1195
- // reader.onload = () => {
1196
- // docInfo.fileContent = btoa(reader.result.toString());
1197
- docInfo.size = selectedFile.size;
1198
- docInfo.index = innerIndex;
1199
- docInfo.fileContent = "";
1200
- //chunkIndex++;
1201
- if (_this.haveExtensionProperty)
1202
- docInfo.exPropertyName = _this.defaultPropertyName;
1203
- //docInfo.isLast = true;
1204
- uploadInfo.docInfo = docInfo;
1205
- // let info = uploadInfo;
1206
- // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1207
- // this.requestBodyArray.push(info);
1208
- //封装请求formdata
1209
- /** @type {?} */
1210
- var formData = new FormData();
1211
- formData.append('uploadInfo', JSON.stringify(uploadInfo));
1212
- formData.append('docInfo', JSON.stringify(docInfo));
1213
- formData.append('file', fileData);
1214
- // }
1215
- //console.log(chunkIndex + 1);
1216
- chunkIndex = chunkIndex + 1;
1217
- }
1175
+ var fileData = selectedFile.slice(chunkIndex * this.bufferSize, nextSize);
1176
+ // let reader = new FileReader();
1177
+ // reader.readAsBinaryString(fileData);
1218
1178
  /** @type {?} */
1219
- var index = -1;
1220
- _this.files.forEach(( /**
1221
- * @param {?} x
1222
- * @return {?}
1223
- */function (x) {
1224
- if (x.name == fileInfo.name) {
1225
- if (index == -1)
1226
- index = _this.files.indexOf(x);
1227
- }
1228
- }));
1229
- if (index != -1 && index != _this.files.length - 1) {
1230
- _this.files.splice(index, 1);
1231
- _this.uploadFileInfoList.splice(index, 1);
1232
- _this.uploadedFileInfoList.splice(index, 1);
1233
- _this.uploadedFileTotal--;
1179
+ var innerIndex = chunkIndex;
1180
+ // reader.onload = () => {
1181
+ // docInfo.fileContent = btoa(reader.result.toString());
1182
+ docInfo.size = selectedFile.size;
1183
+ docInfo.index = innerIndex;
1184
+ docInfo.fileContent = "";
1185
+ //chunkIndex++;
1186
+ if (this.haveExtensionProperty)
1187
+ docInfo.exPropertyName = this.defaultPropertyName;
1188
+ //docInfo.isLast = true;
1189
+ uploadInfo.docInfo = docInfo;
1190
+ // let info = uploadInfo;
1191
+ // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1192
+ // this.requestBodyArray.push(info);
1193
+ //封装请求formdata
1194
+ /** @type {?} */
1195
+ var formData = new FormData();
1196
+ formData.append('uploadInfo', JSON.stringify(uploadInfo));
1197
+ formData.append('docInfo', JSON.stringify(docInfo));
1198
+ formData.append('file', fileData);
1199
+ this.sendUploadRequest(formData, fileInfo, docInfo, uploadFileInfo);
1200
+ // }
1201
+ //console.log(chunkIndex + 1);
1202
+ chunkIndex = chunkIndex + 1;
1203
+ }
1204
+ /** @type {?} */
1205
+ var index = -1;
1206
+ this.files.forEach(( /**
1207
+ * @param {?} x
1208
+ * @return {?}
1209
+ */function (x) {
1210
+ if (x.name == fileInfo.name) {
1211
+ if (index == -1)
1212
+ index = _this.files.indexOf(x);
1234
1213
  }
1235
1214
  }));
1215
+ if (index != -1 && index != this.files.length - 1) {
1216
+ this.files.splice(index, 1);
1217
+ this.uploadFileInfoList.splice(index, 1);
1218
+ this.uploadedFileInfoList.splice(index, 1);
1219
+ this.uploadedFileTotal--;
1220
+ }
1236
1221
  };
1237
1222
  /**
1238
1223
  * @param {?} formData
@@ -1475,54 +1460,57 @@
1475
1460
  */
1476
1461
  function (selectdFile, fileInfo, docType) {
1477
1462
  var _this = this;
1478
- return new Promise(( /**
1479
- * @param {?} resolve
1480
- * @return {?}
1481
- */function (resolve) {
1482
- switch (docType) {
1483
- case DocType.Word: {
1484
- fileInfo.source = "/platform/runtime/dfs/images/word.png";
1485
- _this.files.push(fileInfo);
1486
- break;
1487
- }
1488
- case DocType.Pdf: {
1489
- fileInfo.source = "/platform/runtime/dfs/images/pdf.png";
1490
- _this.files.push(fileInfo);
1491
- break;
1492
- }
1493
- case DocType.Excel: {
1494
- fileInfo.source = "/platform/runtime/dfs/images/excel.png";
1495
- _this.files.push(fileInfo);
1496
- break;
1497
- }
1498
- case DocType.Txt: {
1499
- fileInfo.source = "/platform/runtime/dfs/images/txt.png";
1500
- _this.files.push(fileInfo);
1501
- break;
1502
- }
1503
- case DocType.Powerpoint: {
1504
- fileInfo.source = "/platform/runtime/dfs/images/ppt.png";
1505
- _this.files.push(fileInfo);
1506
- break;
1507
- }
1508
- case DocType.Other: {
1509
- fileInfo.source = "/platform/runtime/dfs/images/file.png";
1463
+ switch (docType) {
1464
+ case DocType.Word: {
1465
+ fileInfo.source = "/platform/runtime/dfs/images/word.png";
1466
+ this.files.push(fileInfo);
1467
+ break;
1468
+ }
1469
+ case DocType.Pdf: {
1470
+ fileInfo.source = "/platform/runtime/dfs/images/pdf.png";
1471
+ this.files.push(fileInfo);
1472
+ break;
1473
+ }
1474
+ case DocType.Excel: {
1475
+ fileInfo.source = "/platform/runtime/dfs/images/excel.png";
1476
+ this.files.push(fileInfo);
1477
+ break;
1478
+ }
1479
+ case DocType.Txt: {
1480
+ fileInfo.source = "/platform/runtime/dfs/images/txt.png";
1481
+ this.files.push(fileInfo);
1482
+ break;
1483
+ }
1484
+ case DocType.Powerpoint: {
1485
+ fileInfo.source = "/platform/runtime/dfs/images/ppt.png";
1486
+ this.files.push(fileInfo);
1487
+ break;
1488
+ }
1489
+ case DocType.Other: {
1490
+ fileInfo.source = "/platform/runtime/dfs/images/file.png";
1491
+ this.files.push(fileInfo);
1492
+ break;
1493
+ }
1494
+ case DocType.Image: {
1495
+ /** @type {?} */
1496
+ var reader_1 = new FileReader();
1497
+ reader_1.readAsDataURL(selectdFile);
1498
+ reader_1.onload = ( /**
1499
+ * @param {?} _event
1500
+ * @return {?}
1501
+ */function (_event) {
1502
+ /** @type {?} */
1503
+ var imgUrl = reader_1.result;
1504
+ if (_this.injector != null) {
1505
+ /** @type {?} */
1506
+ var sanitizer = _this.injector.get(platformBrowser.DomSanitizer);
1507
+ imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1508
+ }
1509
+ fileInfo.source = imgUrl;
1510
1510
  _this.files.push(fileInfo);
1511
- break;
1512
- }
1513
- case DocType.Image: {
1514
- _this.getImageUrl(selectdFile).then(( /**
1515
- * @param {?} res
1516
- * @return {?}
1517
- */function (res) {
1518
- fileInfo.source = res;
1519
- _this.files.push(fileInfo);
1520
- resolve(fileInfo);
1521
- }));
1522
- }
1511
+ });
1523
1512
  }
1524
- resolve(fileInfo);
1525
- }));
1513
+ }
1526
1514
  };
1527
1515
  /**
1528
1516
  * @param {?} selectdFile
@@ -1533,28 +1521,6 @@
1533
1521
  * @return {?}
1534
1522
  */
1535
1523
  function (selectdFile) {
1536
- var _this = this;
1537
- return new Promise(( /**
1538
- * @param {?} resolve
1539
- * @return {?}
1540
- */function (resolve) {
1541
- /** @type {?} */
1542
- var reader = new FileReader();
1543
- reader.readAsDataURL(selectdFile);
1544
- reader.onload = ( /**
1545
- * @param {?} _event
1546
- * @return {?}
1547
- */function (_event) {
1548
- /** @type {?} */
1549
- var imgUrl = reader.result;
1550
- if (_this.injector != null) {
1551
- /** @type {?} */
1552
- var sanitizer = _this.injector.get(platformBrowser.DomSanitizer);
1553
- imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1554
- }
1555
- resolve(imgUrl);
1556
- });
1557
- }));
1558
1524
  };
1559
1525
  /**
1560
1526
  * @param {?} strList