tnx-shared 5.0.70 → 5.0.72

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.
@@ -19479,6 +19479,9 @@
19479
19479
  }
19480
19480
  return false;
19481
19481
  };
19482
+ FileObjectService.prototype.getPublicDownloadLinkByFileId = function (fileId) {
19483
+ return this.serviceUri + "/public/" + fileId + "/download";
19484
+ };
19482
19485
  return FileObjectService;
19483
19486
  }(BaseService));
19484
19487
  FileObjectService.ɵprov = i0.ɵɵdefineInjectable({ factory: function FileObjectService_Factory() { return new FileObjectService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: FileObjectService, providedIn: "root" });
@@ -34416,6 +34419,12 @@
34416
34419
  _this.hasFile = false;
34417
34420
  _this.showNoti = false;
34418
34421
  _this.notification = null;
34422
+ _this.supportedExtensions = [
34423
+ 'pdf',
34424
+ 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp',
34425
+ 'mp4', 'webm', 'ogg',
34426
+ 'mp3', 'wav', 'aac' // Âm thanh
34427
+ ];
34419
34428
  return _this;
34420
34429
  }
34421
34430
  FileUploadComponent.prototype.writeValue = function (obj) {
@@ -34436,15 +34445,15 @@
34436
34445
  FileUploadComponent.prototype.getFile = function () {
34437
34446
  return __awaiter(this, void 0, void 0, function () {
34438
34447
  var fileObject;
34439
- return __generator(this, function (_a) {
34440
- switch (_a.label) {
34448
+ return __generator(this, function (_b) {
34449
+ switch (_b.label) {
34441
34450
  case 0:
34442
34451
  if (!this.fileId) return [3 /*break*/, 2];
34443
34452
  this.loading = true;
34444
34453
  this.notification = 'Đang đính kèm...';
34445
34454
  return [4 /*yield*/, this._fileObjectService.getDetail(this.fileId)];
34446
34455
  case 1:
34447
- fileObject = (_a.sent()).data;
34456
+ fileObject = (_b.sent()).data;
34448
34457
  if (fileObject) {
34449
34458
  this.selectedFileName = fileObject.name;
34450
34459
  this.hasFile = true;
@@ -34455,7 +34464,7 @@
34455
34464
  else {
34456
34465
  this.hasFile = false;
34457
34466
  }
34458
- _a.label = 2;
34467
+ _b.label = 2;
34459
34468
  case 2: return [2 /*return*/];
34460
34469
  }
34461
34470
  });
@@ -34549,12 +34558,38 @@
34549
34558
  this._downloadLinkService.download(model);
34550
34559
  }
34551
34560
  };
34561
+ FileUploadComponent.prototype.isViewableFile = function (url) {
34562
+ var _a;
34563
+ if (!url) {
34564
+ return false;
34565
+ }
34566
+ try {
34567
+ // Lấy phần mở rộng của file từ URL
34568
+ var extension = (_a = url.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
34569
+ return extension ? this.supportedExtensions.includes(extension) : false;
34570
+ }
34571
+ catch (error) {
34572
+ console.error('Lỗi khi kiểm tra đuôi file:', error);
34573
+ return false;
34574
+ }
34575
+ };
34576
+ FileUploadComponent.prototype.onDownloadOrViewFile = function () {
34577
+ if (this.isViewableFile(this.selectedFileName)) {
34578
+ if (this.fileId) {
34579
+ var url = this._fileObjectService.getPublicDownloadLinkByFileId(this.fileId);
34580
+ window.open(url, '_blank');
34581
+ }
34582
+ }
34583
+ else {
34584
+ this.onDownloadFile();
34585
+ }
34586
+ };
34552
34587
  return FileUploadComponent;
34553
34588
  }(ComponentBase));
34554
34589
  FileUploadComponent.decorators = [
34555
34590
  { type: i0.Component, args: [{
34556
34591
  selector: 'file-upload',
34557
- template: "<div class=\"file-upload\">\r\n <div class=\"fl-icon\">\r\n <i *ngIf=\"loading\" class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\r\n <i *ngIf=\"!loading\" class=\"pi pi-file-o\" style=\"font-size: 2rem\"></i>\r\n </div>\r\n\r\n <div class=\"fl-file-name\" (click)=\"onDownloadFile()\">\r\n <span *ngIf=\"!showNoti\">{{selectedFileName}}</span>\r\n <span *ngIf=\"showNoti\"> {{notification}} </span>\r\n </div>\r\n\r\n <div class=\"fl-buttons\">\r\n <button *ngIf=\"!hasFile && !readonly\" pTooltip=\"Ch\u1ECDn file\" class=\"fl-choose\"\r\n class=\"link-or-action p-button-text p-button-rounded fl-choose\" tooltipPosition=\"top\" pButton type=\"button\"\r\n icon=\"pi pi-plus\" (click)=\"onOpenSelect()\"></button>\r\n\r\n <button *ngIf=\"hasFile && !readonly\" (click)=\"onRemoveFile()\"\r\n class=\"link-or-action p-button-text p-button-rounded p-button-danger fl-remove\" pTooltip=\"X\u00F3a file\"\r\n tooltipPosition=\"top\" pButton type=\"button\" icon=\"pi pi-trash\"></button>\r\n\r\n <button [disabled]=\"!menu || !menu.length\" type=\"button\" pButton icon=\"pi pi-ellipsis-v\"\r\n class=\"link-or-action p-button-text p-button-rounded\" pTooltip=\"Th\u00EAm\" tooltipPosition=\"top\"\r\n (click)=\"showContextMenu($event)\"></button>\r\n </div>\r\n\r\n <div style=\"display: none;\">\r\n <p-fileUpload #file [accept]=\"accept\" [auto]=\"false\" class=\"file-upload\" mode=\"basic\"\r\n [chooseLabel]=\"chooseLabel\" name=\"file[]\" [maxFileSize]=\"maxFileSize\" accept=\"{{accept}}\"\r\n pTooltip=\"Ch\u1ECDn t\u1EEB m\u00E1y t\u00EDnh\" toolStipPosition=\"top\" multiple=\"single\"\r\n [invalidFileSizeMessageSummary]=\"invalidFileSizeMessageSummary\"\r\n [invalidFileSizeMessageDetail]=\"invalidFileSizeMessageDetail\"\r\n [invalidFileTypeMessageSummary]=\"invalidFileTypeMessageSummary\"\r\n [invalidFileTypeMessageDetail]=\"invalidFileTypeMessageDetail\"\r\n [invalidFileLimitMessageSummary]=\"invalidFileLimitMessageSummary\"\r\n [invalidFileLimitMessageDetail]=\"invalidFileLimitMessageDetail\" (onSelect)=\"onSelectFile($event)\"\r\n (onError)=\"handleError($event)\">\r\n </p-fileUpload>\r\n </div>\r\n\r\n</div>\r\n\r\n<p-contextMenu #contextMenu [appendTo]=\"'body'\" [model]=\"menu\" styleClass=\"fm-contextMenu-panel\">\r\n</p-contextMenu>",
34592
+ template: "<div class=\"file-upload\">\r\n <div class=\"fl-icon\">\r\n <i *ngIf=\"loading\" class=\"pi pi-spin pi-spinner\" style=\"font-size: 2rem\"></i>\r\n <i *ngIf=\"!loading\" class=\"pi pi-file-o\" style=\"font-size: 2rem\"></i>\r\n </div>\r\n\r\n <div class=\"fl-file-name\" (click)=\"onDownloadOrViewFile()\">\r\n <span *ngIf=\"!showNoti\">{{selectedFileName}}</span>\r\n <span *ngIf=\"showNoti\"> {{notification}} </span>\r\n </div>\r\n\r\n <div class=\"fl-buttons\">\r\n <button *ngIf=\"!hasFile && !readonly\" pTooltip=\"Ch\u1ECDn file\" class=\"fl-choose\"\r\n class=\"link-or-action p-button-text p-button-rounded fl-choose\" tooltipPosition=\"top\" pButton type=\"button\"\r\n icon=\"pi pi-plus\" (click)=\"onOpenSelect()\"></button>\r\n\r\n <button *ngIf=\"hasFile && !readonly\" (click)=\"onRemoveFile()\"\r\n class=\"link-or-action p-button-text p-button-rounded p-button-danger fl-remove\" pTooltip=\"X\u00F3a file\"\r\n tooltipPosition=\"top\" pButton type=\"button\" icon=\"pi pi-trash\"></button>\r\n\r\n <button [disabled]=\"!menu || !menu.length\" type=\"button\" pButton icon=\"pi pi-ellipsis-v\"\r\n class=\"link-or-action p-button-text p-button-rounded\" pTooltip=\"Th\u00EAm\" tooltipPosition=\"top\"\r\n (click)=\"showContextMenu($event)\"></button>\r\n </div>\r\n\r\n <div style=\"display: none;\">\r\n <p-fileUpload #file [accept]=\"accept\" [auto]=\"false\" class=\"file-upload\" mode=\"basic\"\r\n [chooseLabel]=\"chooseLabel\" name=\"file[]\" [maxFileSize]=\"maxFileSize\" accept=\"{{accept}}\"\r\n pTooltip=\"Ch\u1ECDn t\u1EEB m\u00E1y t\u00EDnh\" toolStipPosition=\"top\" multiple=\"single\"\r\n [invalidFileSizeMessageSummary]=\"invalidFileSizeMessageSummary\"\r\n [invalidFileSizeMessageDetail]=\"invalidFileSizeMessageDetail\"\r\n [invalidFileTypeMessageSummary]=\"invalidFileTypeMessageSummary\"\r\n [invalidFileTypeMessageDetail]=\"invalidFileTypeMessageDetail\"\r\n [invalidFileLimitMessageSummary]=\"invalidFileLimitMessageSummary\"\r\n [invalidFileLimitMessageDetail]=\"invalidFileLimitMessageDetail\" (onSelect)=\"onSelectFile($event)\"\r\n (onError)=\"handleError($event)\">\r\n </p-fileUpload>\r\n </div>\r\n\r\n</div>\r\n\r\n<p-contextMenu #contextMenu [appendTo]=\"'body'\" [model]=\"menu\" styleClass=\"fm-contextMenu-panel\">\r\n</p-contextMenu>",
34558
34593
  providers: [
34559
34594
  {
34560
34595
  provide: forms.NG_VALUE_ACCESSOR,