@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.
@@ -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, Injector, ComponentFactoryResolver, Component, ViewChild, Input, 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';
@@ -441,17 +441,11 @@ var UploadService = /** @class */ (function () {
441
441
  request.metadataId = metadataId;
442
442
  request.rootId = rootId;
443
443
  request.path = path;
444
- return this.http.post(url, request).pipe(tap((/**
444
+ return this.httpclient.post(url, request, { responseType: 'text' }).pipe(tap((/**
445
445
  * @param {?} res
446
446
  * @return {?}
447
447
  */
448
- function (res) { })), catchError((/**
449
- * @param {?} error
450
- * @return {?}
451
- */
452
- function (error) {
453
- return of(error);
454
- })));
448
+ function (res) { })));
455
449
  };
456
450
  /**
457
451
  * @param {?} uploadFileInfoList
@@ -1131,69 +1125,62 @@ var FileUploadComponent = /** @class */ (function () {
1131
1125
  * @return {?}
1132
1126
  */
1133
1127
  function (uuid, selectedFile, fileName) {
1134
- var _this = this;
1135
- return new Promise((/**
1136
- * @param {?} resolve
1137
- * @return {?}
1138
- */
1139
- function (resolve) {
1140
- /** @type {?} */
1141
- var fileInfo;
1142
- fileInfo = {
1143
- id: uuid,
1144
- name: fileName,
1145
- type: selectedFile.type,
1146
- source: "",
1147
- size: _this.getFileSize(selectedFile.size),
1148
- fileSize: selectedFile.size,
1149
- picListDisplayName: _this.getPicListDisplayName(fileName),
1150
- queueListDisplayName: _this.getQueueDisplayName(fileName),
1151
- //content: reader.result.toString(),
1152
- hasUploaded: false,
1153
- mouseOn: false,
1154
- selectd: false,
1155
- isUploading: true,
1156
- uploadResult: false,
1157
- uploadProcess: 0,
1158
- errorMessage: "",
1159
- extensionDropListId: 0,
1160
- extensionName: "",
1161
- securityDropListId: 0,
1162
- securityInfo: _this.securityInfoList[0]
1163
- };
1164
- if (_this.storageExtension != null)
1165
- fileInfo.extensionName = _this.defaultPropertyName;
1166
- /** @type {?} */
1167
- var type = selectedFile.type;
1168
- if (type.includes("tiff")) {
1169
- _this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1170
- }
1171
- else if (type.includes("image")) {
1172
- _this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1173
- }
1174
- else if (type.includes("word")) {
1175
- _this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1176
- }
1177
- else if (type.includes("pdf")) {
1178
- _this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1179
- }
1180
- else if (type.includes("plain")) {
1181
- _this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1182
- }
1183
- else if (type.includes("sheet") || type.includes("excel")) {
1184
- _this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1185
- }
1186
- else if (type.includes("powerpoint") || type.includes("presentation")) {
1187
- _this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1188
- }
1189
- else {
1190
- _this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1191
- // let name: string = selectedFile.name;
1192
- // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1193
- // this.errTypeList.push(errType);
1194
- }
1195
- resolve(fileInfo);
1196
- }));
1128
+ /** @type {?} */
1129
+ var fileInfo;
1130
+ fileInfo = {
1131
+ id: uuid,
1132
+ name: fileName,
1133
+ type: selectedFile.type,
1134
+ source: "",
1135
+ size: this.getFileSize(selectedFile.size),
1136
+ fileSize: selectedFile.size,
1137
+ picListDisplayName: this.getPicListDisplayName(fileName),
1138
+ queueListDisplayName: this.getQueueDisplayName(fileName),
1139
+ //content: reader.result.toString(),
1140
+ hasUploaded: false,
1141
+ mouseOn: false,
1142
+ selectd: false,
1143
+ isUploading: true,
1144
+ uploadResult: false,
1145
+ uploadProcess: 0,
1146
+ errorMessage: "",
1147
+ extensionDropListId: 0,
1148
+ extensionName: "",
1149
+ securityDropListId: 0,
1150
+ securityInfo: this.securityInfoList[0]
1151
+ };
1152
+ if (this.storageExtension != null)
1153
+ fileInfo.extensionName = this.defaultPropertyName;
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;
1197
1184
  };
1198
1185
  /**
1199
1186
  * @param {?} uuid
@@ -1212,87 +1199,82 @@ var FileUploadComponent = /** @class */ (function () {
1212
1199
  function (uuid, selectedFile, fileName, state) {
1213
1200
  var _this = this;
1214
1201
  if (state === void 0) { state = FileState.New; }
1215
- this.handleFileInfo(uuid, selectedFile, fileName).then((/**
1216
- * @param {?} res
1217
- * @return {?}
1218
- */
1219
- function (res) {
1202
+ /** @type {?} */
1203
+ var fileInfo = this.handleFileInfo(uuid, selectedFile, fileName);
1204
+ /** @type {?} */
1205
+ var chunkTotal = Math.ceil(selectedFile.size / this.bufferSize);
1206
+ /** @type {?} */
1207
+ var chunkIndex = 0;
1208
+ this.fileTotalChunk[uuid] = chunkTotal;
1209
+ /** @type {?} */
1210
+ var uploadFileInfo = new UploadFileInfo();
1211
+ uploadFileInfo.metadataId = uuid;
1212
+ uploadFileInfo.fileName = fileInfo.name;
1213
+ uploadFileInfo.fileSize = fileInfo.size;
1214
+ uploadFileInfo.state = state;
1215
+ uploadFileInfo.securityInfo = this.securityInfoList[0];
1216
+ while (chunkIndex < chunkTotal) {
1220
1217
  /** @type {?} */
1221
- var fileInfo = res;
1218
+ var uploadInfo = new GspFormUploadEntity;
1219
+ uploadInfo.formId = this.formId;
1220
+ uploadInfo.mode = OperatingModes.Temp;
1221
+ uploadInfo.rootId = this.rootId;
1222
1222
  /** @type {?} */
1223
- var chunkTotal = Math.ceil(selectedFile.size / _this.bufferSize);
1223
+ var docInfo = new GspFormDocInfo;
1224
+ docInfo.fileName = fileName;
1225
+ docInfo.metadataId = uuid;
1226
+ docInfo.total = chunkTotal;
1227
+ this.uploadedChunk[docInfo.metadataId] = 0;
1224
1228
  /** @type {?} */
1225
- var chunkIndex = 0;
1226
- _this.fileTotalChunk[uuid] = chunkTotal;
1229
+ var nextSize = Math.min((chunkIndex + 1) * this.bufferSize, selectedFile.size);
1227
1230
  /** @type {?} */
1228
- var uploadFileInfo = new UploadFileInfo();
1229
- uploadFileInfo.metadataId = uuid;
1230
- uploadFileInfo.fileName = fileInfo.name;
1231
- uploadFileInfo.fileSize = fileInfo.size;
1232
- uploadFileInfo.state = state;
1233
- uploadFileInfo.securityInfo = _this.securityInfoList[0];
1234
- while (chunkIndex < chunkTotal) {
1235
- /** @type {?} */
1236
- var uploadInfo = new GspFormUploadEntity;
1237
- uploadInfo.formId = _this.formId;
1238
- uploadInfo.mode = OperatingModes.Temp;
1239
- uploadInfo.rootId = _this.rootId;
1240
- /** @type {?} */
1241
- var docInfo = new GspFormDocInfo;
1242
- docInfo.fileName = fileName;
1243
- docInfo.metadataId = uuid;
1244
- docInfo.total = chunkTotal;
1245
- _this.uploadedChunk[docInfo.metadataId] = 0;
1246
- /** @type {?} */
1247
- var nextSize = Math.min((chunkIndex + 1) * _this.bufferSize, selectedFile.size);
1248
- /** @type {?} */
1249
- var fileData = selectedFile.slice(chunkIndex * _this.bufferSize, nextSize);
1250
- // let reader = new FileReader();
1251
- // reader.readAsBinaryString(fileData);
1252
- /** @type {?} */
1253
- var innerIndex = chunkIndex;
1254
- // reader.onload = () => {
1255
- // docInfo.fileContent = btoa(reader.result.toString());
1256
- docInfo.size = selectedFile.size;
1257
- docInfo.index = innerIndex;
1258
- docInfo.fileContent = "";
1259
- //chunkIndex++;
1260
- if (_this.haveExtensionProperty)
1261
- docInfo.exPropertyName = _this.defaultPropertyName;
1262
- //docInfo.isLast = true;
1263
- uploadInfo.docInfo = docInfo;
1264
- // let info = uploadInfo;
1265
- // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1266
- // this.requestBodyArray.push(info);
1267
- //封装请求formdata
1268
- /** @type {?} */
1269
- var formData = new FormData();
1270
- formData.append('uploadInfo', JSON.stringify(uploadInfo));
1271
- formData.append('docInfo', JSON.stringify(docInfo));
1272
- formData.append('file', fileData);
1273
- // }
1274
- //console.log(chunkIndex + 1);
1275
- chunkIndex = chunkIndex + 1;
1276
- }
1231
+ var fileData = selectedFile.slice(chunkIndex * this.bufferSize, nextSize);
1232
+ // let reader = new FileReader();
1233
+ // reader.readAsBinaryString(fileData);
1277
1234
  /** @type {?} */
1278
- var index = -1;
1279
- _this.files.forEach((/**
1280
- * @param {?} x
1281
- * @return {?}
1282
- */
1283
- function (x) {
1284
- if (x.name == fileInfo.name) {
1285
- if (index == -1)
1286
- index = _this.files.indexOf(x);
1287
- }
1288
- }));
1289
- if (index != -1 && index != _this.files.length - 1) {
1290
- _this.files.splice(index, 1);
1291
- _this.uploadFileInfoList.splice(index, 1);
1292
- _this.uploadedFileInfoList.splice(index, 1);
1293
- _this.uploadedFileTotal--;
1235
+ var innerIndex = chunkIndex;
1236
+ // reader.onload = () => {
1237
+ // docInfo.fileContent = btoa(reader.result.toString());
1238
+ docInfo.size = selectedFile.size;
1239
+ docInfo.index = innerIndex;
1240
+ docInfo.fileContent = "";
1241
+ //chunkIndex++;
1242
+ if (this.haveExtensionProperty)
1243
+ docInfo.exPropertyName = this.defaultPropertyName;
1244
+ //docInfo.isLast = true;
1245
+ uploadInfo.docInfo = docInfo;
1246
+ // let info = uploadInfo;
1247
+ // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1248
+ // this.requestBodyArray.push(info);
1249
+ //封装请求formdata
1250
+ /** @type {?} */
1251
+ var formData = new FormData();
1252
+ formData.append('uploadInfo', JSON.stringify(uploadInfo));
1253
+ formData.append('docInfo', JSON.stringify(docInfo));
1254
+ formData.append('file', fileData);
1255
+ this.sendUploadRequest(formData, fileInfo, docInfo, uploadFileInfo);
1256
+ // }
1257
+ //console.log(chunkIndex + 1);
1258
+ chunkIndex = chunkIndex + 1;
1259
+ }
1260
+ /** @type {?} */
1261
+ var index = -1;
1262
+ this.files.forEach((/**
1263
+ * @param {?} x
1264
+ * @return {?}
1265
+ */
1266
+ function (x) {
1267
+ if (x.name == fileInfo.name) {
1268
+ if (index == -1)
1269
+ index = _this.files.indexOf(x);
1294
1270
  }
1295
1271
  }));
1272
+ if (index != -1 && index != this.files.length - 1) {
1273
+ this.files.splice(index, 1);
1274
+ this.uploadFileInfoList.splice(index, 1);
1275
+ this.uploadedFileInfoList.splice(index, 1);
1276
+ this.uploadedFileTotal--;
1277
+ }
1296
1278
  };
1297
1279
  /**
1298
1280
  * @param {?} formData
@@ -1546,56 +1528,58 @@ var FileUploadComponent = /** @class */ (function () {
1546
1528
  */
1547
1529
  function (selectdFile, fileInfo, docType) {
1548
1530
  var _this = this;
1549
- return new Promise((/**
1550
- * @param {?} resolve
1551
- * @return {?}
1552
- */
1553
- function (resolve) {
1554
- switch (docType) {
1555
- case DocType.Word: {
1556
- fileInfo.source = "/platform/runtime/dfs/images/word.png";
1557
- _this.files.push(fileInfo);
1558
- break;
1559
- }
1560
- case DocType.Pdf: {
1561
- fileInfo.source = "/platform/runtime/dfs/images/pdf.png";
1562
- _this.files.push(fileInfo);
1563
- break;
1564
- }
1565
- case DocType.Excel: {
1566
- fileInfo.source = "/platform/runtime/dfs/images/excel.png";
1567
- _this.files.push(fileInfo);
1568
- break;
1569
- }
1570
- case DocType.Txt: {
1571
- fileInfo.source = "/platform/runtime/dfs/images/txt.png";
1572
- _this.files.push(fileInfo);
1573
- break;
1574
- }
1575
- case DocType.Powerpoint: {
1576
- fileInfo.source = "/platform/runtime/dfs/images/ppt.png";
1577
- _this.files.push(fileInfo);
1578
- break;
1579
- }
1580
- case DocType.Other: {
1581
- fileInfo.source = "/platform/runtime/dfs/images/file.png";
1531
+ switch (docType) {
1532
+ case DocType.Word: {
1533
+ fileInfo.source = "/platform/runtime/dfs/images/word.png";
1534
+ this.files.push(fileInfo);
1535
+ break;
1536
+ }
1537
+ case DocType.Pdf: {
1538
+ fileInfo.source = "/platform/runtime/dfs/images/pdf.png";
1539
+ this.files.push(fileInfo);
1540
+ break;
1541
+ }
1542
+ case DocType.Excel: {
1543
+ fileInfo.source = "/platform/runtime/dfs/images/excel.png";
1544
+ this.files.push(fileInfo);
1545
+ break;
1546
+ }
1547
+ case DocType.Txt: {
1548
+ fileInfo.source = "/platform/runtime/dfs/images/txt.png";
1549
+ this.files.push(fileInfo);
1550
+ break;
1551
+ }
1552
+ case DocType.Powerpoint: {
1553
+ fileInfo.source = "/platform/runtime/dfs/images/ppt.png";
1554
+ this.files.push(fileInfo);
1555
+ break;
1556
+ }
1557
+ case DocType.Other: {
1558
+ fileInfo.source = "/platform/runtime/dfs/images/file.png";
1559
+ this.files.push(fileInfo);
1560
+ break;
1561
+ }
1562
+ case DocType.Image: {
1563
+ /** @type {?} */
1564
+ var reader_1 = new FileReader();
1565
+ reader_1.readAsDataURL(selectdFile);
1566
+ reader_1.onload = (/**
1567
+ * @param {?} _event
1568
+ * @return {?}
1569
+ */
1570
+ function (_event) {
1571
+ /** @type {?} */
1572
+ var imgUrl = reader_1.result;
1573
+ if (_this.injector != null) {
1574
+ /** @type {?} */
1575
+ var sanitizer = _this.injector.get(DomSanitizer);
1576
+ imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1577
+ }
1578
+ fileInfo.source = imgUrl;
1582
1579
  _this.files.push(fileInfo);
1583
- break;
1584
- }
1585
- case DocType.Image: {
1586
- _this.getImageUrl(selectdFile).then((/**
1587
- * @param {?} res
1588
- * @return {?}
1589
- */
1590
- function (res) {
1591
- fileInfo.source = res;
1592
- _this.files.push(fileInfo);
1593
- resolve(fileInfo);
1594
- }));
1595
- }
1580
+ });
1596
1581
  }
1597
- resolve(fileInfo);
1598
- }));
1582
+ }
1599
1583
  };
1600
1584
  /**
1601
1585
  * @param {?} selectdFile
@@ -1606,30 +1590,6 @@ var FileUploadComponent = /** @class */ (function () {
1606
1590
  * @return {?}
1607
1591
  */
1608
1592
  function (selectdFile) {
1609
- var _this = this;
1610
- return new Promise((/**
1611
- * @param {?} resolve
1612
- * @return {?}
1613
- */
1614
- function (resolve) {
1615
- /** @type {?} */
1616
- var reader = new FileReader();
1617
- reader.readAsDataURL(selectdFile);
1618
- reader.onload = (/**
1619
- * @param {?} _event
1620
- * @return {?}
1621
- */
1622
- function (_event) {
1623
- /** @type {?} */
1624
- var imgUrl = reader.result;
1625
- if (_this.injector != null) {
1626
- /** @type {?} */
1627
- var sanitizer = _this.injector.get(DomSanitizer);
1628
- imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1629
- }
1630
- resolve(imgUrl);
1631
- });
1632
- }));
1633
1593
  };
1634
1594
  /**
1635
1595
  * @param {?} strList