@gsp-svc/formdoc-upload 0.1.37 → 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.
@@ -144,6 +144,16 @@
144
144
  return ChangeInstanceRequest;
145
145
  }());
146
146
 
147
+ /**
148
+ * @fileoverview added by tsickle
149
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
150
+ */
151
+ var CopyFileRequest = /** @class */ (function () {
152
+ function CopyFileRequest() {
153
+ }
154
+ return CopyFileRequest;
155
+ }());
156
+
147
157
  /**
148
158
  * @fileoverview added by tsickle
149
159
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -384,6 +394,31 @@
384
394
  return of.of(error);
385
395
  })));
386
396
  };
397
+ /**
398
+ * @param {?} metadataId
399
+ * @param {?} rootId
400
+ * @param {?} path
401
+ * @return {?}
402
+ */
403
+ UploadService.prototype.copyFile = /**
404
+ * @param {?} metadataId
405
+ * @param {?} rootId
406
+ * @param {?} path
407
+ * @return {?}
408
+ */
409
+ function (metadataId, rootId, path) {
410
+ /** @type {?} */
411
+ var url = "/api/runtime/dfs/v1.0/formdoc/copy";
412
+ /** @type {?} */
413
+ var request = new CopyFileRequest;
414
+ request.metadataId = metadataId;
415
+ request.rootId = rootId;
416
+ request.path = path;
417
+ return this.httpclient.post(url, request, { responseType: 'text' }).pipe(operators.tap(( /**
418
+ * @param {?} res
419
+ * @return {?}
420
+ */function (res) { })));
421
+ };
387
422
  /**
388
423
  * @param {?} uploadFileInfoList
389
424
  * @param {?} rootId
@@ -710,7 +745,7 @@
710
745
  this.beyondFileList = [];
711
746
  this.showType = 0;
712
747
  this.mouseOn = false;
713
- this.bufferSize = 1024 * 1024;
748
+ this.bufferSize = 10 * 1024 * 1024;
714
749
  this.selectedFileCount = 0;
715
750
  this.uploadIconAddress = '/platform/runtime/dfs/images/upload.svg';
716
751
  this.uploadLittleIconAddress = '/platform/runtime/dfs/images/uploadIcon.svg';
@@ -1023,26 +1058,17 @@
1023
1058
  * @param {?} uuid
1024
1059
  * @param {?} selectedFile
1025
1060
  * @param {?} fileName
1026
- * @param {?=} state
1027
1061
  * @return {?}
1028
1062
  */
1029
- FileUploadComponent.prototype.uploadFile = /**
1063
+ FileUploadComponent.prototype.handleFileInfo = /**
1030
1064
  * @param {?} uuid
1031
1065
  * @param {?} selectedFile
1032
1066
  * @param {?} fileName
1033
- * @param {?=} state
1034
1067
  * @return {?}
1035
1068
  */
1036
- function (uuid, selectedFile, fileName, state) {
1037
- var _this = this;
1038
- if (state === void 0) {
1039
- state = FileState.New;
1040
- }
1069
+ function (uuid, selectedFile, fileName) {
1041
1070
  /** @type {?} */
1042
1071
  var fileInfo;
1043
- // let uuid = UUID.UUID();
1044
- //reader.readAsBinaryString(selectedFile);
1045
- //reader.onload = (e) => {
1046
1072
  fileInfo = {
1047
1073
  id: uuid,
1048
1074
  name: fileName,
@@ -1068,6 +1094,58 @@
1068
1094
  if (this.storageExtension != null)
1069
1095
  fileInfo.extensionName = this.defaultPropertyName;
1070
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;
1126
+ };
1127
+ /**
1128
+ * @param {?} uuid
1129
+ * @param {?} selectedFile
1130
+ * @param {?} fileName
1131
+ * @param {?=} state
1132
+ * @return {?}
1133
+ */
1134
+ FileUploadComponent.prototype.uploadFile = /**
1135
+ * @param {?} uuid
1136
+ * @param {?} selectedFile
1137
+ * @param {?} fileName
1138
+ * @param {?=} state
1139
+ * @return {?}
1140
+ */
1141
+ function (uuid, selectedFile, fileName, state) {
1142
+ var _this = this;
1143
+ if (state === void 0) {
1144
+ state = FileState.New;
1145
+ }
1146
+ /** @type {?} */
1147
+ var fileInfo = this.handleFileInfo(uuid, selectedFile, fileName);
1148
+ /** @type {?} */
1071
1149
  var chunkTotal = Math.ceil(selectedFile.size / this.bufferSize);
1072
1150
  /** @type {?} */
1073
1151
  var chunkIndex = 0;
@@ -1079,22 +1157,22 @@
1079
1157
  uploadFileInfo.fileSize = fileInfo.size;
1080
1158
  uploadFileInfo.state = state;
1081
1159
  uploadFileInfo.securityInfo = this.securityInfoList[0];
1082
- var _loop_2 = function () {
1160
+ while (chunkIndex < chunkTotal) {
1083
1161
  /** @type {?} */
1084
1162
  var uploadInfo = new GspFormUploadEntity;
1085
- uploadInfo.formId = this_2.formId;
1163
+ uploadInfo.formId = this.formId;
1086
1164
  uploadInfo.mode = OperatingModes.Temp;
1087
- uploadInfo.rootId = this_2.rootId;
1165
+ uploadInfo.rootId = this.rootId;
1088
1166
  /** @type {?} */
1089
1167
  var docInfo = new GspFormDocInfo;
1090
1168
  docInfo.fileName = fileName;
1091
1169
  docInfo.metadataId = uuid;
1092
1170
  docInfo.total = chunkTotal;
1093
- this_2.uploadedChunk[docInfo.metadataId] = 0;
1171
+ this.uploadedChunk[docInfo.metadataId] = 0;
1094
1172
  /** @type {?} */
1095
- var nextSize = Math.min((chunkIndex + 1) * this_2.bufferSize, selectedFile.size);
1173
+ var nextSize = Math.min((chunkIndex + 1) * this.bufferSize, selectedFile.size);
1096
1174
  /** @type {?} */
1097
- var fileData = selectedFile.slice(chunkIndex * this_2.bufferSize, nextSize);
1175
+ var fileData = selectedFile.slice(chunkIndex * this.bufferSize, nextSize);
1098
1176
  // let reader = new FileReader();
1099
1177
  // reader.readAsBinaryString(fileData);
1100
1178
  /** @type {?} */
@@ -1105,8 +1183,8 @@
1105
1183
  docInfo.index = innerIndex;
1106
1184
  docInfo.fileContent = "";
1107
1185
  //chunkIndex++;
1108
- if (this_2.haveExtensionProperty)
1109
- docInfo.exPropertyName = this_2.defaultPropertyName;
1186
+ if (this.haveExtensionProperty)
1187
+ docInfo.exPropertyName = this.defaultPropertyName;
1110
1188
  //docInfo.isLast = true;
1111
1189
  uploadInfo.docInfo = docInfo;
1112
1190
  // let info = uploadInfo;
@@ -1118,63 +1196,10 @@
1118
1196
  formData.append('uploadInfo', JSON.stringify(uploadInfo));
1119
1197
  formData.append('docInfo', JSON.stringify(docInfo));
1120
1198
  formData.append('file', fileData);
1121
- this_2.uploadSliceFile(formData).subscribe(( /**
1122
- * @param {?} res
1123
- * @return {?}
1124
- */function (res) {
1125
- if (res != null) {
1126
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1127
- _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1128
- _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1129
- }
1130
- else {
1131
- _this.uploadedChunk[docInfo.metadataId]++;
1132
- _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[docInfo.metadataId] / _this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1133
- if (_this.uploadedChunk[docInfo.metadataId] == _this.fileTotalChunk[docInfo.metadataId]) {
1134
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1135
- _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1136
- _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1137
- _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1138
- _this.uploadedFileTotal++;
1139
- }
1140
- }
1141
- }));
1199
+ this.sendUploadRequest(formData, fileInfo, docInfo, uploadFileInfo);
1142
1200
  // }
1143
1201
  //console.log(chunkIndex + 1);
1144
1202
  chunkIndex = chunkIndex + 1;
1145
- };
1146
- var this_2 = this;
1147
- while (chunkIndex < chunkTotal) {
1148
- _loop_2();
1149
- }
1150
- /** @type {?} */
1151
- var type = selectedFile.type;
1152
- if (type.includes("tiff")) {
1153
- this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1154
- }
1155
- else if (type.includes("image")) {
1156
- this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1157
- }
1158
- else if (type.includes("word")) {
1159
- this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1160
- }
1161
- else if (type.includes("pdf")) {
1162
- this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1163
- }
1164
- else if (type.includes("plain")) {
1165
- this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1166
- }
1167
- else if (type.includes("sheet") || type.includes("excel")) {
1168
- this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1169
- }
1170
- else if (type.includes("powerpoint") || type.includes("presentation")) {
1171
- this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1172
- }
1173
- else {
1174
- this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1175
- // let name: string = selectedFile.name;
1176
- // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1177
- // this.errTypeList.push(errType);
1178
1203
  }
1179
1204
  /** @type {?} */
1180
1205
  var index = -1;
@@ -1194,6 +1219,44 @@
1194
1219
  this.uploadedFileTotal--;
1195
1220
  }
1196
1221
  };
1222
+ /**
1223
+ * @param {?} formData
1224
+ * @param {?} fileInfo
1225
+ * @param {?} docInfo
1226
+ * @param {?} uploadFileInfo
1227
+ * @return {?}
1228
+ */
1229
+ FileUploadComponent.prototype.sendUploadRequest = /**
1230
+ * @param {?} formData
1231
+ * @param {?} fileInfo
1232
+ * @param {?} docInfo
1233
+ * @param {?} uploadFileInfo
1234
+ * @return {?}
1235
+ */
1236
+ function (formData, fileInfo, docInfo, uploadFileInfo) {
1237
+ var _this = this;
1238
+ this.uploadSliceFile(formData).subscribe(( /**
1239
+ * @param {?} res
1240
+ * @return {?}
1241
+ */function (res) {
1242
+ if (res != null) {
1243
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1244
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1245
+ _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1246
+ }
1247
+ else {
1248
+ _this.uploadedChunk[docInfo.metadataId]++;
1249
+ _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[docInfo.metadataId] / _this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1250
+ if (_this.uploadedChunk[docInfo.metadataId] == _this.fileTotalChunk[docInfo.metadataId]) {
1251
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1252
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1253
+ _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1254
+ _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1255
+ _this.uploadedFileTotal++;
1256
+ }
1257
+ }
1258
+ }));
1259
+ };
1197
1260
  /**
1198
1261
  * @param {?} formdata
1199
1262
  * @return {?}
@@ -1428,7 +1491,7 @@
1428
1491
  this.files.push(fileInfo);
1429
1492
  break;
1430
1493
  }
1431
- case DocType.Image:
1494
+ case DocType.Image: {
1432
1495
  /** @type {?} */
1433
1496
  var reader_1 = new FileReader();
1434
1497
  reader_1.readAsDataURL(selectdFile);
@@ -1441,15 +1504,24 @@
1441
1504
  if (_this.injector != null) {
1442
1505
  /** @type {?} */
1443
1506
  var sanitizer = _this.injector.get(platformBrowser.DomSanitizer);
1444
- fileInfo.source = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1507
+ imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1445
1508
  }
1446
- else
1447
- fileInfo.source = imgUrl;
1509
+ fileInfo.source = imgUrl;
1448
1510
  _this.files.push(fileInfo);
1449
1511
  });
1450
- break;
1512
+ }
1451
1513
  }
1452
1514
  };
1515
+ /**
1516
+ * @param {?} selectdFile
1517
+ * @return {?}
1518
+ */
1519
+ FileUploadComponent.prototype.getImageUrl = /**
1520
+ * @param {?} selectdFile
1521
+ * @return {?}
1522
+ */
1523
+ function (selectdFile) {
1524
+ };
1453
1525
  /**
1454
1526
  * @param {?} strList
1455
1527
  * @return {?}
@@ -2299,6 +2371,7 @@
2299
2371
  exports.GspDocSecurityBaseInfo = GspDocSecurityBaseInfo;
2300
2372
  exports.SecurityEntity = SecurityEntity;
2301
2373
  exports.ExStorageFileInfo = ExStorageFileInfo;
2374
+ exports.CopyFileRequest = CopyFileRequest;
2302
2375
  exports.ɵb = LocalLangPipe;
2303
2376
 
2304
2377
  Object.defineProperty(exports, '__esModule', { value: true });