@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.
@@ -11,7 +11,7 @@ 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 { CacheService, HttpService, LanguageService, SessionService } from '@ecp-caf/caf-common';
14
- import { Injectable, Pipe, Inject, LOCALE_ID, Component, ViewChild, Input, Injector, ComponentFactoryResolver, NgModule, defineInjectable } from '@angular/core';
14
+ import { Injectable, Pipe, Inject, LOCALE_ID, Component, NgModule, 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
17
  import { HttpClientModule, HttpClient } from '@angular/common/http';
@@ -157,6 +157,16 @@ var ChangeInstanceRequest = /** @class */ (function () {
157
157
  return ChangeInstanceRequest;
158
158
  }());
159
159
 
160
+ /**
161
+ * @fileoverview added by tsickle
162
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
163
+ */
164
+ var CopyFileRequest = /** @class */ (function () {
165
+ function CopyFileRequest() {
166
+ }
167
+ return CopyFileRequest;
168
+ }());
169
+
160
170
  /**
161
171
  * @fileoverview added by tsickle
162
172
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -411,6 +421,32 @@ var UploadService = /** @class */ (function () {
411
421
  return of(error);
412
422
  })));
413
423
  };
424
+ /**
425
+ * @param {?} metadataId
426
+ * @param {?} rootId
427
+ * @param {?} path
428
+ * @return {?}
429
+ */
430
+ UploadService.prototype.copyFile = /**
431
+ * @param {?} metadataId
432
+ * @param {?} rootId
433
+ * @param {?} path
434
+ * @return {?}
435
+ */
436
+ function (metadataId, rootId, path) {
437
+ /** @type {?} */
438
+ var url = "/api/runtime/dfs/v1.0/formdoc/copy";
439
+ /** @type {?} */
440
+ var request = new CopyFileRequest;
441
+ request.metadataId = metadataId;
442
+ request.rootId = rootId;
443
+ request.path = path;
444
+ return this.httpclient.post(url, request, { responseType: 'text' }).pipe(tap((/**
445
+ * @param {?} res
446
+ * @return {?}
447
+ */
448
+ function (res) { })));
449
+ };
414
450
  /**
415
451
  * @param {?} uploadFileInfoList
416
452
  * @param {?} rootId
@@ -752,7 +788,7 @@ var FileUploadComponent = /** @class */ (function () {
752
788
  this.beyondFileList = [];
753
789
  this.showType = 0;
754
790
  this.mouseOn = false;
755
- this.bufferSize = 1024 * 1024;
791
+ this.bufferSize = 10 * 1024 * 1024;
756
792
  this.selectedFileCount = 0;
757
793
  this.uploadIconAddress = '/platform/runtime/dfs/images/upload.svg';
758
794
  this.uploadLittleIconAddress = '/platform/runtime/dfs/images/uploadIcon.svg';
@@ -1080,24 +1116,17 @@ var FileUploadComponent = /** @class */ (function () {
1080
1116
  * @param {?} uuid
1081
1117
  * @param {?} selectedFile
1082
1118
  * @param {?} fileName
1083
- * @param {?=} state
1084
1119
  * @return {?}
1085
1120
  */
1086
- FileUploadComponent.prototype.uploadFile = /**
1121
+ FileUploadComponent.prototype.handleFileInfo = /**
1087
1122
  * @param {?} uuid
1088
1123
  * @param {?} selectedFile
1089
1124
  * @param {?} fileName
1090
- * @param {?=} state
1091
1125
  * @return {?}
1092
1126
  */
1093
- function (uuid, selectedFile, fileName, state) {
1094
- var _this = this;
1095
- if (state === void 0) { state = FileState.New; }
1127
+ function (uuid, selectedFile, fileName) {
1096
1128
  /** @type {?} */
1097
1129
  var fileInfo;
1098
- // let uuid = UUID.UUID();
1099
- //reader.readAsBinaryString(selectedFile);
1100
- //reader.onload = (e) => {
1101
1130
  fileInfo = {
1102
1131
  id: uuid,
1103
1132
  name: fileName,
@@ -1123,6 +1152,56 @@ var FileUploadComponent = /** @class */ (function () {
1123
1152
  if (this.storageExtension != null)
1124
1153
  fileInfo.extensionName = this.defaultPropertyName;
1125
1154
  /** @type {?} */
1155
+ var type = selectedFile.type;
1156
+ if (type.includes("tiff")) {
1157
+ this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1158
+ }
1159
+ else if (type.includes("image")) {
1160
+ this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1161
+ }
1162
+ else if (type.includes("word")) {
1163
+ this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1164
+ }
1165
+ else if (type.includes("pdf")) {
1166
+ this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1167
+ }
1168
+ else if (type.includes("plain")) {
1169
+ this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1170
+ }
1171
+ else if (type.includes("sheet") || type.includes("excel")) {
1172
+ this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1173
+ }
1174
+ else if (type.includes("powerpoint") || type.includes("presentation")) {
1175
+ this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1176
+ }
1177
+ else {
1178
+ this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1179
+ // let name: string = selectedFile.name;
1180
+ // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1181
+ // this.errTypeList.push(errType);
1182
+ }
1183
+ return fileInfo;
1184
+ };
1185
+ /**
1186
+ * @param {?} uuid
1187
+ * @param {?} selectedFile
1188
+ * @param {?} fileName
1189
+ * @param {?=} state
1190
+ * @return {?}
1191
+ */
1192
+ FileUploadComponent.prototype.uploadFile = /**
1193
+ * @param {?} uuid
1194
+ * @param {?} selectedFile
1195
+ * @param {?} fileName
1196
+ * @param {?=} state
1197
+ * @return {?}
1198
+ */
1199
+ function (uuid, selectedFile, fileName, state) {
1200
+ var _this = this;
1201
+ if (state === void 0) { state = FileState.New; }
1202
+ /** @type {?} */
1203
+ var fileInfo = this.handleFileInfo(uuid, selectedFile, fileName);
1204
+ /** @type {?} */
1126
1205
  var chunkTotal = Math.ceil(selectedFile.size / this.bufferSize);
1127
1206
  /** @type {?} */
1128
1207
  var chunkIndex = 0;
@@ -1134,22 +1213,22 @@ var FileUploadComponent = /** @class */ (function () {
1134
1213
  uploadFileInfo.fileSize = fileInfo.size;
1135
1214
  uploadFileInfo.state = state;
1136
1215
  uploadFileInfo.securityInfo = this.securityInfoList[0];
1137
- var _loop_2 = function () {
1216
+ while (chunkIndex < chunkTotal) {
1138
1217
  /** @type {?} */
1139
1218
  var uploadInfo = new GspFormUploadEntity;
1140
- uploadInfo.formId = this_2.formId;
1219
+ uploadInfo.formId = this.formId;
1141
1220
  uploadInfo.mode = OperatingModes.Temp;
1142
- uploadInfo.rootId = this_2.rootId;
1221
+ uploadInfo.rootId = this.rootId;
1143
1222
  /** @type {?} */
1144
1223
  var docInfo = new GspFormDocInfo;
1145
1224
  docInfo.fileName = fileName;
1146
1225
  docInfo.metadataId = uuid;
1147
1226
  docInfo.total = chunkTotal;
1148
- this_2.uploadedChunk[docInfo.metadataId] = 0;
1227
+ this.uploadedChunk[docInfo.metadataId] = 0;
1149
1228
  /** @type {?} */
1150
- var nextSize = Math.min((chunkIndex + 1) * this_2.bufferSize, selectedFile.size);
1229
+ var nextSize = Math.min((chunkIndex + 1) * this.bufferSize, selectedFile.size);
1151
1230
  /** @type {?} */
1152
- var fileData = selectedFile.slice(chunkIndex * this_2.bufferSize, nextSize);
1231
+ var fileData = selectedFile.slice(chunkIndex * this.bufferSize, nextSize);
1153
1232
  // let reader = new FileReader();
1154
1233
  // reader.readAsBinaryString(fileData);
1155
1234
  /** @type {?} */
@@ -1160,8 +1239,8 @@ var FileUploadComponent = /** @class */ (function () {
1160
1239
  docInfo.index = innerIndex;
1161
1240
  docInfo.fileContent = "";
1162
1241
  //chunkIndex++;
1163
- if (this_2.haveExtensionProperty)
1164
- docInfo.exPropertyName = this_2.defaultPropertyName;
1242
+ if (this.haveExtensionProperty)
1243
+ docInfo.exPropertyName = this.defaultPropertyName;
1165
1244
  //docInfo.isLast = true;
1166
1245
  uploadInfo.docInfo = docInfo;
1167
1246
  // let info = uploadInfo;
@@ -1173,64 +1252,10 @@ var FileUploadComponent = /** @class */ (function () {
1173
1252
  formData.append('uploadInfo', JSON.stringify(uploadInfo));
1174
1253
  formData.append('docInfo', JSON.stringify(docInfo));
1175
1254
  formData.append('file', fileData);
1176
- this_2.uploadSliceFile(formData).subscribe((/**
1177
- * @param {?} res
1178
- * @return {?}
1179
- */
1180
- function (res) {
1181
- if (res != null) {
1182
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1183
- _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1184
- _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1185
- }
1186
- else {
1187
- _this.uploadedChunk[docInfo.metadataId]++;
1188
- _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[docInfo.metadataId] / _this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1189
- if (_this.uploadedChunk[docInfo.metadataId] == _this.fileTotalChunk[docInfo.metadataId]) {
1190
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1191
- _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1192
- _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1193
- _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1194
- _this.uploadedFileTotal++;
1195
- }
1196
- }
1197
- }));
1255
+ this.sendUploadRequest(formData, fileInfo, docInfo, uploadFileInfo);
1198
1256
  // }
1199
1257
  //console.log(chunkIndex + 1);
1200
1258
  chunkIndex = chunkIndex + 1;
1201
- };
1202
- var this_2 = this;
1203
- while (chunkIndex < chunkTotal) {
1204
- _loop_2();
1205
- }
1206
- /** @type {?} */
1207
- var type = selectedFile.type;
1208
- if (type.includes("tiff")) {
1209
- this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1210
- }
1211
- else if (type.includes("image")) {
1212
- this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1213
- }
1214
- else if (type.includes("word")) {
1215
- this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1216
- }
1217
- else if (type.includes("pdf")) {
1218
- this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1219
- }
1220
- else if (type.includes("plain")) {
1221
- this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1222
- }
1223
- else if (type.includes("sheet") || type.includes("excel")) {
1224
- this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1225
- }
1226
- else if (type.includes("powerpoint") || type.includes("presentation")) {
1227
- this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1228
- }
1229
- else {
1230
- this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1231
- // let name: string = selectedFile.name;
1232
- // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1233
- // this.errTypeList.push(errType);
1234
1259
  }
1235
1260
  /** @type {?} */
1236
1261
  var index = -1;
@@ -1251,6 +1276,45 @@ var FileUploadComponent = /** @class */ (function () {
1251
1276
  this.uploadedFileTotal--;
1252
1277
  }
1253
1278
  };
1279
+ /**
1280
+ * @param {?} formData
1281
+ * @param {?} fileInfo
1282
+ * @param {?} docInfo
1283
+ * @param {?} uploadFileInfo
1284
+ * @return {?}
1285
+ */
1286
+ FileUploadComponent.prototype.sendUploadRequest = /**
1287
+ * @param {?} formData
1288
+ * @param {?} fileInfo
1289
+ * @param {?} docInfo
1290
+ * @param {?} uploadFileInfo
1291
+ * @return {?}
1292
+ */
1293
+ function (formData, fileInfo, docInfo, uploadFileInfo) {
1294
+ var _this = this;
1295
+ this.uploadSliceFile(formData).subscribe((/**
1296
+ * @param {?} res
1297
+ * @return {?}
1298
+ */
1299
+ function (res) {
1300
+ if (res != null) {
1301
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1302
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1303
+ _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1304
+ }
1305
+ else {
1306
+ _this.uploadedChunk[docInfo.metadataId]++;
1307
+ _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[docInfo.metadataId] / _this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1308
+ if (_this.uploadedChunk[docInfo.metadataId] == _this.fileTotalChunk[docInfo.metadataId]) {
1309
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1310
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1311
+ _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1312
+ _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1313
+ _this.uploadedFileTotal++;
1314
+ }
1315
+ }
1316
+ }));
1317
+ };
1254
1318
  /**
1255
1319
  * @param {?} formdata
1256
1320
  * @return {?}
@@ -1495,7 +1559,7 @@ var FileUploadComponent = /** @class */ (function () {
1495
1559
  this.files.push(fileInfo);
1496
1560
  break;
1497
1561
  }
1498
- case DocType.Image:
1562
+ case DocType.Image: {
1499
1563
  /** @type {?} */
1500
1564
  var reader_1 = new FileReader();
1501
1565
  reader_1.readAsDataURL(selectdFile);
@@ -1509,15 +1573,24 @@ var FileUploadComponent = /** @class */ (function () {
1509
1573
  if (_this.injector != null) {
1510
1574
  /** @type {?} */
1511
1575
  var sanitizer = _this.injector.get(DomSanitizer);
1512
- fileInfo.source = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1576
+ imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1513
1577
  }
1514
- else
1515
- fileInfo.source = imgUrl;
1578
+ fileInfo.source = imgUrl;
1516
1579
  _this.files.push(fileInfo);
1517
1580
  });
1518
- break;
1581
+ }
1519
1582
  }
1520
1583
  };
1584
+ /**
1585
+ * @param {?} selectdFile
1586
+ * @return {?}
1587
+ */
1588
+ FileUploadComponent.prototype.getImageUrl = /**
1589
+ * @param {?} selectdFile
1590
+ * @return {?}
1591
+ */
1592
+ function (selectdFile) {
1593
+ };
1521
1594
  /**
1522
1595
  * @param {?} strList
1523
1596
  * @return {?}
@@ -2344,6 +2417,6 @@ var SecurityEntity = /** @class */ (function () {
2344
2417
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2345
2418
  */
2346
2419
 
2347
- export { FormdocUploadService, FormdocUploadComponent, FormdocUploadModule, UploadDialogMoudle, UploadDialogComponent, UploadDialogService, UploadService, DownloadService, FileUploadComponent, UploadFileInfo, UploadModule, ɵa, UploadLimit, GspFormDocOperateEntity, GspFormRemoveListEntity, GspFormUploadListEntity, GspFormDocInfo, GspDocMetaProperty, GspFormUploadEntity, FileInfo, OperatingModes, FileState, GspDocSecurityBaseInfo, SecurityEntity, ExStorageFileInfo, LocalLangPipe as ɵb };
2420
+ export { FormdocUploadService, FormdocUploadComponent, FormdocUploadModule, UploadDialogMoudle, UploadDialogComponent, UploadDialogService, UploadService, DownloadService, FileUploadComponent, UploadFileInfo, UploadModule, ɵa, UploadLimit, GspFormDocOperateEntity, GspFormRemoveListEntity, GspFormUploadListEntity, GspFormDocInfo, GspDocMetaProperty, GspFormUploadEntity, FileInfo, OperatingModes, FileState, GspDocSecurityBaseInfo, SecurityEntity, ExStorageFileInfo, CopyFileRequest, LocalLangPipe as ɵb };
2348
2421
 
2349
2422
  //# sourceMappingURL=gsp-svc-formdoc-upload.js.map