@wizishop/img-manager 0.2.69 → 0.2.74

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.
@@ -5,7 +5,7 @@ import { HttpParams, HttpHeaders, HttpClient, HttpClientModule } from '@angular/
5
5
  import { trigger, state, style, transition, animate, query, stagger } from '@angular/animations';
6
6
  import { TranslateService, TranslateModule } from '@ngx-translate/core';
7
7
  import { NwbAlertService, NwbFilterRoutingBuilder, NwbAllModule } from '@wizishop/ng-wizi-bulma';
8
- import { debounceTime, map, takeUntil, distinctUntilChanged, tap } from 'rxjs/operators';
8
+ import { debounceTime, map, take, takeUntil, distinctUntilChanged, tap } from 'rxjs/operators';
9
9
  import { DOCUMENT, CommonModule } from '@angular/common';
10
10
  import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
11
11
  import { NgScrollbarModule } from 'ngx-scrollbar';
@@ -212,6 +212,9 @@ var ImgManagerService = /** @class */ (function () {
212
212
  ImgManagerService.prototype.getShopImgList = function (params) {
213
213
  return this.http.get(this.imgManagerRoute + "/images", this.getOptionsHeaders(params));
214
214
  };
215
+ ImgManagerService.prototype.getShopTotalImgList = function (params) {
216
+ return this.http.get(this.imgManagerRoute + "/total/images", this.getOptionsHeaders(params));
217
+ };
215
218
  ImgManagerService.prototype.getShopImg = function (idFile) {
216
219
  return this.http.get(this.imgManagerRoute + "/images/" + idFile, this.getOptionsHeaders());
217
220
  };
@@ -2061,7 +2064,7 @@ var ImgSelectionComponent = /** @class */ (function () {
2061
2064
  ImgSelectionComponent = __decorate([
2062
2065
  Component({
2063
2066
  selector: 'img-selection',
2064
- template: "<div\n class=\"trash\"\n cdkDropList\n #unSelectList=\"cdkDropList\"\n (cdkDropListDropped)=\"removeImgFromSelection($event)\">\n <p>{{'ImgManager.ImgSelection.unselect' | translate}}</p>\n</div>\n\n<div\n class=\"img-selection\"\n [ngClass]=\"{'img-selection--visible' : imgSelectedList && imgSelectedList.length}\">\n\n <div\n cdkDropList\n #selectionList=\"cdkDropList\"\n cdkDropListOrientation=\"horizontal\"\n class=\"list_img_selection\"\n (cdkDropListDropped)=\"drop($event)\"\n [cdkDropListConnectedTo]=\"[unSelectList]\"\n >\n\n <div\n class=\"img_box\"\n *ngFor=\"let picture of imgSelectedList; let index = index\"\n cdkDrag\n (cdkDragStarted)=\"dragStart = true;\"\n (cdkDragEnded)=\"dragStart = false;\"\n >\n\n <img\n *ngIf=\"index < 1\"\n class=\"drag__img\"\n [src]=\"picture.file_name | imgSrc : '400'\"\n [title]=\"picture.display_name\"\n />\n\n <img\n *ngIf=\"index > 0\"\n class=\"drag__img\"\n [src]=\"picture.file_name | imgSrc : '200'\"\n [title]=\"picture.display_name\"\n />\n\n <div class=\"delete-btn\" (click)=\"removeImg(index)\">{{'ImgManager.ImgSelection.deleteImg' | translate}}</div>\n\n <span class=\"drag__tooltips\">{{'ImgManager.ImgSelection.tooltips' | translate}}</span>\n\n </div>\n </div>\n</div>\n\n<!-- Loader -->\n<ng-container *ngIf=\"isLoading && !(imgSelectedList && imgSelectedList.length)\">\n <wz-loader></wz-loader>\n</ng-container>\n"
2067
+ template: "<div\n class=\"trash\"\n cdkDropList\n #unSelectList=\"cdkDropList\"\n (cdkDropListDropped)=\"removeImgFromSelection($event)\">\n <p>{{'ImgManager.ImgSelection.unselect' | translate}}</p>\n</div>\n\n<div\n class=\"img-selection\"\n [ngClass]=\"{'img-selection--visible' : imgSelectedList && imgSelectedList.length}\"\n *ngIf=\"!isLoading\">\n\n <div\n cdkDropList\n #selectionList=\"cdkDropList\"\n cdkDropListOrientation=\"horizontal\"\n class=\"list_img_selection\"\n (cdkDropListDropped)=\"drop($event)\"\n [cdkDropListConnectedTo]=\"[unSelectList]\"\n >\n\n <div\n class=\"img_box\"\n *ngFor=\"let picture of imgSelectedList; let index = index\"\n cdkDrag\n (cdkDragStarted)=\"dragStart = true;\"\n (cdkDragEnded)=\"dragStart = false;\"\n >\n\n <img\n *ngIf=\"index < 1\"\n class=\"drag__img\"\n [src]=\"picture.file_name | imgSrc : '400'\"\n [title]=\"picture.display_name\"\n />\n\n <img\n *ngIf=\"index > 0\"\n class=\"drag__img\"\n [src]=\"picture.file_name | imgSrc : '200'\"\n [title]=\"picture.display_name\"\n />\n\n <div class=\"delete-btn\" (click)=\"removeImg(index)\">{{'ImgManager.ImgSelection.deleteImg' | translate}}</div>\n\n <span class=\"drag__tooltips\">{{'ImgManager.ImgSelection.tooltips' | translate}}</span>\n\n </div>\n </div>\n</div>\n\n<!-- Loader -->\n<ng-container *ngIf=\"isLoading\">\n <wz-loader></wz-loader>\n</ng-container>\n"
2065
2068
  }),
2066
2069
  __metadata("design:paramtypes", [ImgSelectionService])
2067
2070
  ], ImgSelectionComponent);
@@ -2669,6 +2672,7 @@ var ImagesViewComponent = /** @class */ (function () {
2669
2672
  this.nbImgToDelSelected = 0;
2670
2673
  this.disable = false; // Use to disable action during server request
2671
2674
  this.isLoading = true;
2675
+ this.isTotalRetieved = false;
2672
2676
  this.delListImgLoader = false;
2673
2677
  this.initComponent = true;
2674
2678
  this.failLoaded = false;
@@ -2680,6 +2684,7 @@ var ImagesViewComponent = /** @class */ (function () {
2680
2684
  this.pageSize = 30; // Default value
2681
2685
  this.pageSizeOptions = [25, 50, 100, 250];
2682
2686
  this.errorGetAllImg = 'ImgManager.ImgLib.errorGetAllImg';
2687
+ this.errorGetTotalImg = 'ImgManager.ImgLib.errorGetTotalImg';
2683
2688
  this.errorGetImg = 'ImgManager.ImgLib.errorGetCanvaImg';
2684
2689
  this.msgNoImgFound = 'ImgManager.ImgLib.noImgFound';
2685
2690
  this.errorRemoveImg = 'ImgManager.ImgList.errorRemoveImg';
@@ -2887,7 +2892,7 @@ var ImagesViewComponent = /** @class */ (function () {
2887
2892
  };
2888
2893
  ImagesViewComponent.prototype.getImg = function (id_file) {
2889
2894
  var _this = this;
2890
- this.imgSubscribe = this.imgManager.getShopImg(id_file).subscribe(function (picture) {
2895
+ this.imgManager.getShopImg(id_file).pipe(take(1)).subscribe(function (picture) {
2891
2896
  if (!_this.imgAlreadyExist(picture.id_file)) {
2892
2897
  // check the img is not already present
2893
2898
  _this.picturesList.unshift(picture);
@@ -2975,16 +2980,17 @@ var ImagesViewComponent = /** @class */ (function () {
2975
2980
  var _this = this;
2976
2981
  this.isLoading = true;
2977
2982
  this.displayPexelsResults = false;
2983
+ this.isTotalRetieved = false;
2978
2984
  this.setParams();
2979
- this.imgSubscribe = this.imgManager.getShopImgList(this.params).subscribe(function (data) {
2985
+ this.imgManager.getShopImgList(this.params).pipe(take(1)).subscribe(function (data) {
2980
2986
  _this.initVariables(true);
2981
2987
  var nbImgDisplayed = data.data.length;
2982
2988
  _this.calculNbImgFake(nbImgDisplayed);
2983
2989
  _this.picturesList = data.data;
2984
2990
  _this.renamePictureService.setPicturesList(_this.picturesList);
2985
2991
  _this.selectImgSelected();
2986
- _this.length = data.totalRecords;
2987
- _this.tableFilters.totalItems = data.totalRecords;
2992
+ _this.length = _this.isTotalRetieved ? _this.length : data.totalRecords;
2993
+ _this.tableFilters.totalItems = _this.isTotalRetieved ? _this.tableFilters.totalItems : data.totalRecords;
2988
2994
  _this.tableFilters.itemsPerPage = _this.tableFilters.itemsPerPage ? _this.tableFilters.itemsPerPage : _this.pageSize;
2989
2995
  if (_this.maxLengthCardShow) {
2990
2996
  _this.picturesList = _this.picturesList.splice(0, 8);
@@ -2993,11 +2999,23 @@ var ImagesViewComponent = /** @class */ (function () {
2993
2999
  if (data.totalRecords === 0) {
2994
3000
  _this.displayPexelsLib();
2995
3001
  }
3002
+ _this.refreshTotalImgList();
2996
3003
  }, function (error) {
2997
3004
  _this.alertService.openAlert(_this.errorGetAllImg);
2998
3005
  _this.initVariables(false);
2999
3006
  });
3000
3007
  };
3008
+ ImagesViewComponent.prototype.refreshTotalImgList = function () {
3009
+ var _this = this;
3010
+ this.imgManager.getShopTotalImgList(this.params).pipe(take(1)).subscribe(function (data) {
3011
+ _this.isTotalRetieved = true;
3012
+ _this.length = data.totalRecords;
3013
+ _this.tableFilters.totalItems = data.totalRecords;
3014
+ }, function (error) {
3015
+ _this.alertService.openAlert(_this.errorGetTotalImg);
3016
+ _this.initVariables(false);
3017
+ });
3018
+ };
3001
3019
  ImagesViewComponent.prototype.ngOnDestroy = function () {
3002
3020
  this.searchQueryChanged.unsubscribe();
3003
3021
  this.imgRemovedEvent.unsubscribe();