ngx-techlify-core 11.4.5 → 11.4.6

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.
@@ -747,6 +747,7 @@
747
747
  this.authClientSecret = '';
748
748
  this.authGrantType = '';
749
749
  this.apiUrl = '';
750
+ this.isLogoutWhileApiGetsFailed = false;
750
751
  this.loadFromMap(data);
751
752
  }
752
753
  TechlifyConfig.prototype.loadFromMap = function (data) {
@@ -757,6 +758,7 @@
757
758
  this.apiUrl = data.apiUrl;
758
759
  this.storage = data === null || data === void 0 ? void 0 : data.storage;
759
760
  this.rawConfigs = data;
761
+ this.isLogoutWhileApiGetsFailed = data === null || data === void 0 ? void 0 : data.isLogoutWhileApiGetsFailed;
760
762
  };
761
763
  return TechlifyConfig;
762
764
  }());
@@ -882,8 +884,9 @@
882
884
  * @since 20171202
883
885
  */
884
886
  var ErrorHandlerService = /** @class */ (function () {
885
- function ErrorHandlerService(alerter) {
887
+ function ErrorHandlerService(alerter, config) {
886
888
  this.alerter = alerter;
889
+ this.config = config;
887
890
  }
888
891
  ErrorHandlerService.prototype.handleError = function (errorResponse, msg) {
889
892
  if (msg === void 0) { msg = ''; }
@@ -911,17 +914,23 @@
911
914
  }
912
915
  var errMessage = errors.length ? errors[0] : msg;
913
916
  this.alerter.addAlert("Error: " + errMessage, "warning");
917
+ if (errorResponse.status == 403 && this.config.isLogoutWhileApiGetsFailed) {
918
+ sessionStorage.clear();
919
+ localStorage.clear();
920
+ location.reload();
921
+ }
914
922
  };
915
923
  return ErrorHandlerService;
916
924
  }());
917
- ErrorHandlerService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ErrorHandlerService_Factory() { return new ErrorHandlerService(i0.ɵɵinject(AlertService)); }, token: ErrorHandlerService, providedIn: "root" });
925
+ ErrorHandlerService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ErrorHandlerService_Factory() { return new ErrorHandlerService(i0.ɵɵinject(AlertService), i0.ɵɵinject(TechlifyConfig)); }, token: ErrorHandlerService, providedIn: "root" });
918
926
  ErrorHandlerService.decorators = [
919
927
  { type: i0.Injectable, args: [{
920
928
  providedIn: 'root'
921
929
  },] }
922
930
  ];
923
931
  ErrorHandlerService.ctorParameters = function () { return [
924
- { type: AlertService }
932
+ { type: AlertService },
933
+ { type: TechlifyConfig }
925
934
  ]; };
926
935
 
927
936
  var log = new Logger('ErrorHandlerInterceptor');
@@ -1391,9 +1400,13 @@
1391
1400
  EntityFileService.prototype.deleteEntityFile = function (model) {
1392
1401
  return this.http.delete("api/entity-files/" + model.id).toPromise();
1393
1402
  };
1394
- EntityFileService.prototype.uploadEntityFile = function (file) {
1403
+ EntityFileService.prototype.uploadEntityFile = function (file, params) {
1395
1404
  var formData = new FormData();
1396
1405
  formData.append("fileData", file, file.name);
1406
+ if (params === null || params === void 0 ? void 0 : params.entity_id) {
1407
+ formData.append('entity_id', params.entity_id);
1408
+ formData.append('entity_type', params.entity_type);
1409
+ }
1397
1410
  return this.http
1398
1411
  .skipHeader()
1399
1412
  .post("api/entity-files-upload", formData).toPromise();
@@ -1459,7 +1472,8 @@
1459
1472
  entity_type: [''],
1460
1473
  entity_id: [],
1461
1474
  file: ['', forms.Validators.required],
1462
- url: ['', forms.Validators.required]
1475
+ url: ['', forms.Validators.required],
1476
+ file_size: ['', forms.Validators.required],
1463
1477
  });
1464
1478
  };
1465
1479
  EntityFileFormComponent.prototype.ngOnInit = function () {
@@ -1538,12 +1552,8 @@
1538
1552
  return [4 /*yield*/, this.entityFileService.uploadEntityFile(this.fileList[0])];
1539
1553
  case 1:
1540
1554
  result = _c.sent();
1541
- this.entityFileGroup
1542
- .get("file")
1543
- .setValue(result.item.file);
1544
- this.entityFileGroup
1545
- .get("url")
1546
- .setValue(result.item.url);
1555
+ this.entityFileGroup.patchValue(result.item);
1556
+ ;
1547
1557
  this.fileList = [];
1548
1558
  _c.label = 2;
1549
1559
  case 2: return [2 /*return*/];
@@ -1582,7 +1592,7 @@
1582
1592
  EntityFileFormComponent.decorators = [
1583
1593
  { type: i0.Component, args: [{
1584
1594
  selector: 'entity-file-form',
1585
- template: "<form [formGroup]=\"entityFileGroup\" (ngSubmit)=\"submit()\">\n <div fxLayout=\"column\" class=\"mat-typography\">\n <div mat-dialog-title class=\"text-center\">\n <div>Entity File</div>\n </div>\n\n <div mat-dialog-content fxLayout=\"column\" fxLayoutAlign.=\"start\">\n <ng-container *ngIf=\"!hideTitleAndDetails\">\n <mat-form-field>\n <input type=\"text\" matInput formControlName=\"title\" placeholder=\"Title\" autocomplete=\"off\">\n </mat-form-field>\n <mat-form-field>\n <textarea matInput formControlName=\"details\" placeholder=\"Details\" autocomplete=\"off\"></textarea>\n </mat-form-field>\n </ng-container>\n\n <ng-template #fileUpload>\n <section fxFlex=\"100%\">\n <div>Entity File*</div>\n <app-file-dropper [config]=\"fileConfig\" (fileChanged)=\"fileChanged($event)\" [fileArray]=\"fileList\">\n </app-file-dropper>\n <div class=\"text-danger\" *ngIf=\"isFieldValid('url')\">\n {{getErrorMessage(\"url\")}}\n </div>\n </section>\n </ng-template>\n\n\n <div fxFlex=\"100%\" class=\"mt-2\" *ngIf=\"entityFileGroup.get('url').value;else fileUpload;\">\n <app-document-viewer [file]=\"entityFileGroup.get('file').value\"\n [fileUrl]=\"entityFileGroup.get('url').value\" [config]=\"this.viewerConfig\" (remove)=\"removeFile()\"\n [disableEdit]=\"updateMode\">\n </app-document-viewer>\n\n </div>\n\n <div class=\"mt-4 mb-2\" fxLayout=\"row\" fxLayoutGap=\"30px\" fxLayoutAlign=\"end\" fxFlex=\"100%\">\n <button mat-raised-button type=\"button\" (click)=\"dialogRef.close()\">\n Cancel\n </button>\n <button mat-raised-button type=\"submit\" color=\"primary\">Save</button>\n </div>\n </div>\n </div>\n</form>",
1595
+ template: "<form [formGroup]=\"entityFileGroup\" (ngSubmit)=\"submit()\">\n <div fxLayout=\"column\" class=\"mat-typography\">\n <div mat-dialog-title class=\"text-center\">\n <div>Entity File</div>\n </div>\n <div mat-dialog-content fxLayout=\"column\" fxLayoutAlign.=\"start\">\n <ng-container *ngIf=\"!hideTitleAndDetails\">\n <mat-form-field>\n <input type=\"text\" matInput formControlName=\"title\" placeholder=\"Title\" autocomplete=\"off\">\n </mat-form-field>\n <mat-form-field>\n <textarea matInput formControlName=\"details\" placeholder=\"Details\" autocomplete=\"off\"></textarea>\n </mat-form-field>\n </ng-container>\n <ng-template #fileUpload>\n <section fxFlex=\"100%\">\n <div>Entity File*</div>\n <app-file-dropper [config]=\"fileConfig\" (fileChanged)=\"fileChanged($event)\" [fileArray]=\"fileList\">\n </app-file-dropper>\n <div class=\"text-danger\" *ngIf=\"isFieldValid('url')\">\n {{getErrorMessage(\"url\")}}\n </div>\n </section>\n </ng-template>\n <div fxFlex=\"100%\" class=\"mt-2\" *ngIf=\"entityFileGroup.get('url').value;else fileUpload;\">\n <app-document-viewer [file]=\"entityFileGroup.get('file').value\" [fileUrl]=\"entityFileGroup.get('url').value\"\n [config]=\"this.viewerConfig\" (remove)=\"removeFile()\" [disableEdit]=\"updateMode\">\n </app-document-viewer>\n </div>\n <div class=\"mt-4 mb-2\" fxLayout=\"row\" fxLayoutGap=\"30px\" fxLayoutAlign=\"end\" fxFlex=\"100%\">\n <button mat-raised-button type=\"button\" (click)=\"dialogRef.close()\">\n Cancel\n </button>\n <button mat-raised-button type=\"submit\" color=\"primary\">Save</button>\n </div>\n </div>\n </div>\n</form>\n",
1586
1596
  styles: [""]
1587
1597
  },] }
1588
1598
  ];
@@ -1602,17 +1612,37 @@
1602
1612
  this.alertService = alertService;
1603
1613
  this.dialog = dialog;
1604
1614
  this.viewOnly = false;
1615
+ this.title = "File";
1605
1616
  this.filters = {};
1606
1617
  this.entityFiles = [];
1607
- this.displayedColumns = ['index', 'title', 'details', 'file',];
1618
+ this.displayedColumns = [
1619
+ 'index',
1620
+ 'title',
1621
+ 'details',
1622
+ 'file_size',
1623
+ 'uploaded_on',
1624
+ ];
1608
1625
  this.isWorking = false;
1609
1626
  this.search = new forms.FormControl('');
1610
1627
  this.page = 1;
1611
1628
  this.perPage = 25;
1612
1629
  this.lastPage = 0;
1630
+ this.fileList = [];
1613
1631
  }
1614
1632
  EntityFilesViewAllComponent.prototype.ngOnInit = function () {
1615
1633
  var _this = this;
1634
+ //File dropper config
1635
+ this.fileConfig = {
1636
+ fileId: "entityDashboardDropper",
1637
+ containerId: "entityDashboardDropperContainer",
1638
+ styles: {
1639
+ height: "500px"
1640
+ },
1641
+ multiple: false,
1642
+ acceptFile: "*",
1643
+ maxSize: 10,
1644
+ acceptFileText: "All Files"
1645
+ };
1616
1646
  this.viewerConfig = {
1617
1647
  imageStyle: {
1618
1648
  height: '200px',
@@ -1648,6 +1678,7 @@
1648
1678
  switch (_a.label) {
1649
1679
  case 0:
1650
1680
  this.filters.page = this.page;
1681
+ this.filters.perPage = this.perPage;
1651
1682
  this.isWorking = true;
1652
1683
  return [4 /*yield*/, this.entityFileService.getEntityFiles(this.filters)];
1653
1684
  case 1:
@@ -1743,12 +1774,42 @@
1743
1774
  EntityFilesViewAllComponent.prototype.resetFieldValue = function () {
1744
1775
  this.search.setValue("");
1745
1776
  };
1777
+ EntityFilesViewAllComponent.prototype.sizeOf = function (bytes) {
1778
+ if (!bytes) {
1779
+ return "0.00 B";
1780
+ }
1781
+ var e = Math.floor(Math.log(bytes) / Math.log(1024));
1782
+ return (bytes / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'B';
1783
+ };
1784
+ EntityFilesViewAllComponent.prototype.fileChanged = function (event) {
1785
+ return __awaiter(this, void 0, void 0, function () {
1786
+ var result;
1787
+ return __generator(this, function (_a) {
1788
+ switch (_a.label) {
1789
+ case 0:
1790
+ this.fileList = event;
1791
+ if (!(this.fileList.length > 0)) return [3 /*break*/, 2];
1792
+ return [4 /*yield*/, this.entityFileService.uploadEntityFile(this.fileList[0], {
1793
+ entity_type: this.entityType,
1794
+ entity_id: this.entityId,
1795
+ })];
1796
+ case 1:
1797
+ result = _a.sent();
1798
+ this.fileList = [];
1799
+ this.alertService.addAlert('Successfull uploaded', 'success');
1800
+ this.reload();
1801
+ _a.label = 2;
1802
+ case 2: return [2 /*return*/];
1803
+ }
1804
+ });
1805
+ });
1806
+ };
1746
1807
  return EntityFilesViewAllComponent;
1747
1808
  }());
1748
1809
  exports.ɵo.decorators = [
1749
1810
  { type: i0.Component, args: [{
1750
1811
  selector: 'app-entity-files-view-all',
1751
- template: "<div fxLayout=\"column\" fxLayoutGap=\"1rem\" class=\"mat-typography p-4\" *ngIf=\"!displayMode\">\n <div fxLayout=\"column\" fxLayoutGap=\"0.25rem\">\n <h3 class=\"font-weight-bold\" fxLayoutAlign=\"center center\"> Files\n <button type=\"button\" class=\"mx-1\" mat-mini-fab color=\"primary\" (click)=\"addEntityFile()\" *ngIf=\"!viewOnly\">\n <mat-icon>add</mat-icon>\n </button>\n </h3>\n <div fxLayout=\"row wrap\" fxLayoutAlign=\"start\" *ngIf=\"!removeSearch\">\n <mat-form-field class=\"mt-1\">\n <input type=\"text\" matInput [formControl]=\"search\" placeholder=\"Title\" name=\"title\"\n autocomplete=\"off\" />\n <button mat-button *ngIf=\"filters.title\" matSuffix mat-icon-button (click)=\"resetFieldValue()\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n </div>\n <table mat-table [dataSource]=\"entityFiles\" class=\"w-100\" matSort multiTemplateDataRows\n infiniteScrollContainer=\"body\" infiniteScroll [infiniteScrollDistance]=\"1.5\" [infiniteScrollThrottle]=\"50\"\n [fromRoot]=\"true\" (scrolled)=\"onScroll()\">\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let element; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n <!-- Title Column -->\n <ng-container matColumnDef=\"title\">\n <th mat-header-cell *matHeaderCellDef> Title </th>\n <td mat-cell *matCellDef=\"let element\"> {{element.title}} </td>\n </ng-container>\n\n <!-- Details Column -->\n <ng-container matColumnDef=\"details\">\n <th mat-header-cell *matHeaderCellDef> Details </th>\n <td mat-cell *matCellDef=\"let element\"> {{element.details}} </td>\n </ng-container>\n\n <!-- File Column -->\n <ng-container matColumnDef=\"file\">\n <th mat-header-cell *matHeaderCellDef> File </th>\n <td mat-cell *matCellDef=\"let element\">\n <a href=\"{{element.url}}\" target=\"_blank\">\n <button mat-button type=\"button\">View</button>\n </a>\n </td>\n </ng-container>\n\n <!-- Actions Column -->\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef> Actions </th>\n <td mat-cell *matCellDef=\"let element\" style=\"min-width:110px\">\n <button type=\"button\" mat-icon-button (click)=\"editEntityFile(element)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteEntityFile(element)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </div>\n</div>\n\n<div fxLayout=\"row wrap\" fxLayoutGap=\"1rem\" class=\"mat-typography p-4\" *ngIf=\"displayMode\">\n\n <div *ngFor=\"let efile of entityFiles\">\n <app-document-viewer [file]=\"efile.file\" [fileUrl]=\"efile.url\" [config]=\"this.viewerConfig\"\n [disableEdit]=\"true\">\n </app-document-viewer>\n <a href=\"{{efile.url}}\" target=\"_blank\">\n <button mat-button type=\"button\">View</button>\n </a>\n </div>\n\n</div>",
1812
+ template: "<div class=\"mat-typography\" *ngIf=\"!displayMode\">\n <div fxLayout=\"row\" fxLayoutGap=\"1rem\">\n <mat-card fxFlex=\"70%\">\n <mat-card-title fxLayout fxLayoutGap=\"1rem\">\n <h3 class=\"font-weight-bold primary-color\" fxLayout=\"center center\">\n <mat-icon>\n <span class=\"material-icons\">\n description\n </span>\n </mat-icon>\n {{title}}s\n </h3>\n <div>\n <button type=\"button\" class=\"mx-1\" mat-raised-button color=\"primary\" (click)=\"addEntityFile()\"\n *ngIf=\"!viewOnly\">\n <mat-icon>\n <span class=\"material-icons\">\n add_circle_outline\n </span>\n </mat-icon>\n {{title}}\n </button>\n </div>\n <mat-form-field *ngIf=\"!removeSearch\" appearance=\"outline\" style=\"font-size: 10px;\">\n <mat-label>Search</mat-label>\n <input type=\"text\" matInput [formControl]=\"search\" placeholder=\"Search\" name=\"title\" autocomplete=\"off\" />\n <button mat-button *ngIf=\"filters.title\" matSuffix mat-icon-button (click)=\"resetFieldValue()\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n </mat-card-title>\n <mat-card-content class=\"entity-file-card\">\n <table mat-table [dataSource]=\"entityFiles\" class=\"w-100\" matSort multiTemplateDataRows infiniteScroll\n [infiniteScrollDistance]=\"1.5\" [infiniteScrollThrottle]=\"50\" (scrolled)=\"onScroll()\">\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let element; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n <!-- Title Column -->\n <ng-container matColumnDef=\"title\">\n <th mat-header-cell *matHeaderCellDef> Title </th>\n <td mat-cell *matCellDef=\"let element\">\n <div>\n <span>\n {{element.title}}\n </span>\n <span>\n <a href=\"{{element.url}}\" target=\"_blank\" class=\"text-decoration-none text-muted\">\n <button mat-icon-button type=\"button\">\n <mat-icon>download</mat-icon>\n </button>\n </a>\n </span>\n </div>\n </td>\n </ng-container>\n\n <!-- Details Column -->\n <ng-container matColumnDef=\"details\">\n <th mat-header-cell *matHeaderCellDef> Details </th>\n <td mat-cell *matCellDef=\"let element\"> {{element.details}} </td>\n </ng-container>\n\n <!-- File size Column -->\n <ng-container matColumnDef=\"file_size\">\n <th mat-header-cell *matHeaderCellDef> File Size </th>\n <td mat-cell *matCellDef=\"let element\"> {{ sizeOf(element.file_size)}} </td>\n </ng-container>\n\n <!-- Uploaded On Column -->\n <ng-container matColumnDef=\"uploaded_on\">\n <th mat-header-cell *matHeaderCellDef> Uploaded On </th>\n <td mat-cell *matCellDef=\"let element\">\n <div>\n {{element.created_at | date: 'mediumDate'}}\n </div>\n <div class=\"text-muted\">\n By {{element.creator?.name}}\n </div>\n </td>\n </ng-container>\n\n <!-- Actions Column -->\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef> Actions </th>\n <td mat-cell *matCellDef=\"let element\" style=\"min-width:110px\" class=\"text-muted\">\n <button type=\"button\" mat-icon-button (click)=\"editEntityFile(element)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteEntityFile(element)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </mat-card-content>\n </mat-card>\n <section fxFlex=\"30%\">\n <app-file-dropper [config]=\"fileConfig\" (fileChanged)=\"fileChanged($event)\" [fileArray]=\"fileList\">\n </app-file-dropper>\n </section>\n </div>\n</div>\n\n<div fxLayout=\"row wrap\" fxLayoutGap=\"1rem\" class=\"mat-typography p-4\" *ngIf=\"displayMode\">\n <div *ngFor=\"let efile of entityFiles\">\n <app-document-viewer [file]=\"efile.file\" [fileUrl]=\"efile.url\" [config]=\"this.viewerConfig\" [disableEdit]=\"true\">\n </app-document-viewer>\n <a href=\"{{efile.url}}\" target=\"_blank\">\n <button mat-button type=\"button\">View</button>\n </a>\n </div>\n</div>\n",
1752
1813
  styles: [""]
1753
1814
  },] }
1754
1815
  ];
@@ -1764,7 +1825,8 @@
1764
1825
  viewOnly: [{ type: i0.Input }],
1765
1826
  removeSearch: [{ type: i0.Input }],
1766
1827
  hideTitleAndDetails: [{ type: i0.Input }],
1767
- displayMode: [{ type: i0.Input }]
1828
+ displayMode: [{ type: i0.Input }],
1829
+ title: [{ type: i0.Input }]
1768
1830
  };
1769
1831
  exports.ɵo = __decorate([
1770
1832
  untilDestroy.UntilDestroy()