@wizishop/img-manager 15.0.4 → 15.0.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.
@@ -1,13 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, EventEmitter, Directive, Input, Output, Pipe, Component, ViewEncapsulation, HostBinding, HostListener, ViewChild, Inject, NgModule } from '@angular/core';
3
- import { ReplaySubject, Observable, Subject, BehaviorSubject, forkJoin } from 'rxjs';
3
+ import { ReplaySubject, Observable, of, delay, tap, Subject, BehaviorSubject, forkJoin } from 'rxjs';
4
4
  import * as i3 from '@angular/common/http';
5
5
  import { HttpParams, HttpHeaders, HttpClientModule } from '@angular/common/http';
6
6
  import * as i7 from '@ngx-translate/core';
7
7
  import { TranslateModule } from '@ngx-translate/core';
8
8
  import * as i1 from '@wizishop/ng-wizi-bulma';
9
9
  import { NwbAllModule } from '@wizishop/ng-wizi-bulma';
10
- import { take, debounceTime, map, takeUntil, distinctUntilChanged, tap } from 'rxjs/operators';
10
+ import { take, debounceTime, map, takeUntil, distinctUntilChanged, tap as tap$1 } from 'rxjs/operators';
11
11
  import * as i2 from '@angular/common';
12
12
  import { DOCUMENT, CommonModule } from '@angular/common';
13
13
  import { trigger, state, style, transition, animate, query, stagger } from '@angular/animations';
@@ -209,7 +209,13 @@ class ImgManagerService {
209
209
  return header;
210
210
  }
211
211
  getShopImgList(params) {
212
- return this.http.get(`${this.imgManagerRoute}/images`, this.getOptionsHeaders(params));
212
+ if (params && this.previousParams && this.previousParams.limit === params.limit && this.previousParams.page === params.page && this.shopImgList) {
213
+ return of(this.shopImgList).pipe(delay(0));
214
+ }
215
+ return this.http.get(`${this.imgManagerRoute}/images`, this.getOptionsHeaders(params)).pipe(tap((shopImgList) => {
216
+ this.shopImgList = shopImgList;
217
+ this.previousParams = params;
218
+ }));
213
219
  }
214
220
  getShopTotalImgList(params) {
215
221
  return this.http.get(`${this.imgManagerRoute}/total/image`, this.getOptionsHeaders(params));
@@ -1279,7 +1285,7 @@ class AbstractDebounceDirective {
1279
1285
  }
1280
1286
  ngOnInit() {
1281
1287
  this.emitEvent$
1282
- .pipe(takeUntil(this.subscription$), debounceTime(this.debounceTime), distinctUntilChanged(), tap(value => this.emitChange(value)))
1288
+ .pipe(takeUntil(this.subscription$), debounceTime(this.debounceTime), distinctUntilChanged(), tap$1(value => this.emitChange(value)))
1283
1289
  .subscribe();
1284
1290
  }
1285
1291
  emitChange(value) {
@@ -2427,14 +2433,14 @@ class MosaicViewComponent extends ImagesActionHandler {
2427
2433
  }
2428
2434
  }
2429
2435
  MosaicViewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: MosaicViewComponent, deps: [{ token: ImgManagerService }, { token: ImgSelectionService }, { token: i3.HttpClient }, { token: ImgCDNService }, { token: ImgEventService }, { token: AlertService }, { token: i7.TranslateService }, { token: ImgManagerConfigService }], target: i0.ɵɵFactoryTarget.Component });
2430
- MosaicViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: MosaicViewComponent, selector: "mosaic-view", inputs: { tabDisplayed: "tabDisplayed", fullSize: "fullSize", nbFakeImg: "nbFakeImg" }, outputs: { switchDisplayWindow: "switchDisplayWindow" }, usesInheritance: true, ngImport: i0, template: "<div class=\"mosaic\" [ngClass]=\"{'fullSize': fullSize, 'small': stateDisplayed === 'small', 'mosaic--displayPexelsImg': displayPexelsResults}\">\n <!-- Search section -->\n <div\n class=\"mosaic__search\"\n [ngClass]=\"{'mosaic__search--small': stateDisplayed === 'small'}\"\n *ngIf=\"tabDisplayed !== 'img-upload'\">\n <wz-input-search\n [(ngModel)]=\"tableFilters.searchValue\"\n (changeDebounced)=\"onSearchChange($event)\"\n [placeholder]=\"'ImgManager.SearchBar.placeholder' | translate\"\n [smallPadding]=\"stateDisplayed === 'small'\"\n ></wz-input-search>\n </div>\n\n <!-- Cards section -->\n <div\n class=\"mosaic__container__cards\"\n [ngClass]=\"{'mosaic__container__cards--padding': stateDisplayed !== 'window'}\"\n [@listAnimation]=\"picturesList.length\"\n *ngIf=\"false\"\n >\n <img-card\n *ngFor=\"let picture of picturesList; let index = index;\"\n [picture]=\"picture\"\n [stateDisplayed]=\"stateDisplayed\"\n [tabDisplayed]=\"tabDisplayed\"\n [disable]=\"disable\"\n (toggleImgSelected)=\"onToggleSelectImg(index)\"\n (pictureNameChange)=\"onCardRenamePicture($event)\"\n (switchDisplayWindow)=\"switchDisplayWindowCard()\"\n [fullSize]=\"fullSize\"\n ></img-card>\n <div\n *ngFor=\"let fakeImg of nbFakeImg | numberToArray\"\n class=\"mosaic__container__cards__fakeImg\"\n [ngClass]=\"{'mosaic__container__cards__fakeImg--smallFakeImg': stateDisplayed === 'small' || tabDisplayed === 'img-upload'}\">\n </div>\n </div>\n <!-- Loader section -->\n <div class=\"mosaic__container__loader\" *ngIf=\"true\">\n <wz-loader [small]=\"true\"></wz-loader>\n </div>\n\n <!-- Pagination section -->\n <div class=\"mosaic__pagination\" *ngIf=\"picturesList.length && tabDisplayed !== 'img-upload' && !displayPexelsResults\" >\n <wz-pagination\n [pagination]=\"tableFilters\"\n (pageChange)=\"onFiltersChange()\"\n >\n </wz-pagination>\n </div>\n\n</div>\n", dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ImgCardComponent, selector: "img-card", inputs: ["tabDisplayed", "fullSize", "picture", "index"], outputs: ["toggleImgSelected", "switchDisplayWindow"] }, { kind: "component", type: LoaderComponent, selector: "wz-loader", inputs: ["text", "small", "position"] }, { kind: "component", type: InputSearchComponent, selector: "wz-input-search", inputs: ["placeholder", "smallPadding", "id"], outputs: ["changeDebounced"] }, { kind: "component", type: PaginationComponent, selector: "wz-pagination", inputs: ["pagination"], outputs: ["pageChange"] }, { kind: "pipe", type: i7.TranslatePipe, name: "translate" }, { kind: "pipe", type: NumberToArray, name: "numberToArray" }], animations: [
2436
+ MosaicViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: MosaicViewComponent, selector: "mosaic-view", inputs: { tabDisplayed: "tabDisplayed", fullSize: "fullSize", nbFakeImg: "nbFakeImg" }, outputs: { switchDisplayWindow: "switchDisplayWindow" }, usesInheritance: true, ngImport: i0, template: "<div class=\"mosaic\" [ngClass]=\"{'fullSize': fullSize, 'small': stateDisplayed === 'small', 'mosaic--displayPexelsImg': displayPexelsResults}\">\n <!-- Search section -->\n <div\n class=\"mosaic__search\"\n [ngClass]=\"{'mosaic__search--small': stateDisplayed === 'small'}\"\n *ngIf=\"tabDisplayed !== 'img-upload'\">\n <wz-input-search\n [(ngModel)]=\"tableFilters.searchValue\"\n (changeDebounced)=\"onSearchChange($event)\"\n [placeholder]=\"'ImgManager.SearchBar.placeholder' | translate\"\n [smallPadding]=\"stateDisplayed === 'small'\"\n ></wz-input-search>\n </div>\n\n <!-- Cards section -->\n <div\n class=\"mosaic__container__cards\"\n [ngClass]=\"{'mosaic__container__cards--padding': stateDisplayed !== 'window'}\"\n [@listAnimation]=\"picturesList.length\"\n *ngIf=\"!isLoading && !displayPexelsResults\"\n >\n <img-card\n *ngFor=\"let picture of picturesList; let index = index;\"\n [picture]=\"picture\"\n [stateDisplayed]=\"stateDisplayed\"\n [tabDisplayed]=\"tabDisplayed\"\n [disable]=\"disable\"\n (toggleImgSelected)=\"onToggleSelectImg(index)\"\n (pictureNameChange)=\"onCardRenamePicture($event)\"\n (switchDisplayWindow)=\"switchDisplayWindowCard()\"\n [fullSize]=\"fullSize\"\n ></img-card>\n <div\n *ngFor=\"let fakeImg of nbFakeImg | numberToArray\"\n class=\"mosaic__container__cards__fakeImg\"\n [ngClass]=\"{'mosaic__container__cards__fakeImg--smallFakeImg': stateDisplayed === 'small' || tabDisplayed === 'img-upload'}\">\n </div>\n </div>\n <!-- Loader section -->\n <div class=\"mosaic__container__loader\" *ngIf=\"isLoading\">\n <wz-loader [small]=\"true\"></wz-loader>\n </div>\n\n <!-- Pagination section -->\n <div class=\"mosaic__pagination\" *ngIf=\"picturesList.length && tabDisplayed !== 'img-upload' && !displayPexelsResults\" >\n <wz-pagination\n [pagination]=\"tableFilters\"\n (pageChange)=\"onFiltersChange()\"\n >\n </wz-pagination>\n </div>\n\n</div>\n", dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ImgCardComponent, selector: "img-card", inputs: ["tabDisplayed", "fullSize", "picture", "index"], outputs: ["toggleImgSelected", "switchDisplayWindow"] }, { kind: "component", type: LoaderComponent, selector: "wz-loader", inputs: ["text", "small", "position"] }, { kind: "component", type: InputSearchComponent, selector: "wz-input-search", inputs: ["placeholder", "smallPadding", "id"], outputs: ["changeDebounced"] }, { kind: "component", type: PaginationComponent, selector: "wz-pagination", inputs: ["pagination"], outputs: ["pageChange"] }, { kind: "pipe", type: i7.TranslatePipe, name: "translate" }, { kind: "pipe", type: NumberToArray, name: "numberToArray" }], animations: [
2431
2437
  listAnnimation
2432
2438
  ] });
2433
2439
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: MosaicViewComponent, decorators: [{
2434
2440
  type: Component,
2435
2441
  args: [{ selector: 'mosaic-view', animations: [
2436
2442
  listAnnimation
2437
- ], template: "<div class=\"mosaic\" [ngClass]=\"{'fullSize': fullSize, 'small': stateDisplayed === 'small', 'mosaic--displayPexelsImg': displayPexelsResults}\">\n <!-- Search section -->\n <div\n class=\"mosaic__search\"\n [ngClass]=\"{'mosaic__search--small': stateDisplayed === 'small'}\"\n *ngIf=\"tabDisplayed !== 'img-upload'\">\n <wz-input-search\n [(ngModel)]=\"tableFilters.searchValue\"\n (changeDebounced)=\"onSearchChange($event)\"\n [placeholder]=\"'ImgManager.SearchBar.placeholder' | translate\"\n [smallPadding]=\"stateDisplayed === 'small'\"\n ></wz-input-search>\n </div>\n\n <!-- Cards section -->\n <div\n class=\"mosaic__container__cards\"\n [ngClass]=\"{'mosaic__container__cards--padding': stateDisplayed !== 'window'}\"\n [@listAnimation]=\"picturesList.length\"\n *ngIf=\"false\"\n >\n <img-card\n *ngFor=\"let picture of picturesList; let index = index;\"\n [picture]=\"picture\"\n [stateDisplayed]=\"stateDisplayed\"\n [tabDisplayed]=\"tabDisplayed\"\n [disable]=\"disable\"\n (toggleImgSelected)=\"onToggleSelectImg(index)\"\n (pictureNameChange)=\"onCardRenamePicture($event)\"\n (switchDisplayWindow)=\"switchDisplayWindowCard()\"\n [fullSize]=\"fullSize\"\n ></img-card>\n <div\n *ngFor=\"let fakeImg of nbFakeImg | numberToArray\"\n class=\"mosaic__container__cards__fakeImg\"\n [ngClass]=\"{'mosaic__container__cards__fakeImg--smallFakeImg': stateDisplayed === 'small' || tabDisplayed === 'img-upload'}\">\n </div>\n </div>\n <!-- Loader section -->\n <div class=\"mosaic__container__loader\" *ngIf=\"true\">\n <wz-loader [small]=\"true\"></wz-loader>\n </div>\n\n <!-- Pagination section -->\n <div class=\"mosaic__pagination\" *ngIf=\"picturesList.length && tabDisplayed !== 'img-upload' && !displayPexelsResults\" >\n <wz-pagination\n [pagination]=\"tableFilters\"\n (pageChange)=\"onFiltersChange()\"\n >\n </wz-pagination>\n </div>\n\n</div>\n" }]
2443
+ ], template: "<div class=\"mosaic\" [ngClass]=\"{'fullSize': fullSize, 'small': stateDisplayed === 'small', 'mosaic--displayPexelsImg': displayPexelsResults}\">\n <!-- Search section -->\n <div\n class=\"mosaic__search\"\n [ngClass]=\"{'mosaic__search--small': stateDisplayed === 'small'}\"\n *ngIf=\"tabDisplayed !== 'img-upload'\">\n <wz-input-search\n [(ngModel)]=\"tableFilters.searchValue\"\n (changeDebounced)=\"onSearchChange($event)\"\n [placeholder]=\"'ImgManager.SearchBar.placeholder' | translate\"\n [smallPadding]=\"stateDisplayed === 'small'\"\n ></wz-input-search>\n </div>\n\n <!-- Cards section -->\n <div\n class=\"mosaic__container__cards\"\n [ngClass]=\"{'mosaic__container__cards--padding': stateDisplayed !== 'window'}\"\n [@listAnimation]=\"picturesList.length\"\n *ngIf=\"!isLoading && !displayPexelsResults\"\n >\n <img-card\n *ngFor=\"let picture of picturesList; let index = index;\"\n [picture]=\"picture\"\n [stateDisplayed]=\"stateDisplayed\"\n [tabDisplayed]=\"tabDisplayed\"\n [disable]=\"disable\"\n (toggleImgSelected)=\"onToggleSelectImg(index)\"\n (pictureNameChange)=\"onCardRenamePicture($event)\"\n (switchDisplayWindow)=\"switchDisplayWindowCard()\"\n [fullSize]=\"fullSize\"\n ></img-card>\n <div\n *ngFor=\"let fakeImg of nbFakeImg | numberToArray\"\n class=\"mosaic__container__cards__fakeImg\"\n [ngClass]=\"{'mosaic__container__cards__fakeImg--smallFakeImg': stateDisplayed === 'small' || tabDisplayed === 'img-upload'}\">\n </div>\n </div>\n <!-- Loader section -->\n <div class=\"mosaic__container__loader\" *ngIf=\"isLoading\">\n <wz-loader [small]=\"true\"></wz-loader>\n </div>\n\n <!-- Pagination section -->\n <div class=\"mosaic__pagination\" *ngIf=\"picturesList.length && tabDisplayed !== 'img-upload' && !displayPexelsResults\" >\n <wz-pagination\n [pagination]=\"tableFilters\"\n (pageChange)=\"onFiltersChange()\"\n >\n </wz-pagination>\n </div>\n\n</div>\n" }]
2438
2444
  }], ctorParameters: function () { return [{ type: ImgManagerService }, { type: ImgSelectionService }, { type: i3.HttpClient }, { type: ImgCDNService }, { type: ImgEventService }, { type: AlertService }, { type: i7.TranslateService }, { type: ImgManagerConfigService }]; }, propDecorators: { tabDisplayed: [{
2439
2445
  type: Input
2440
2446
  }], fullSize: [{
@@ -3143,7 +3149,7 @@ class ImagesViewComponent {
3143
3149
  this.nbImgToDelSelected = 0;
3144
3150
  this.disable = false; // Use to disable action during server request
3145
3151
  this.isLoading = true;
3146
- this.isTotalRetieved = false;
3152
+ this.isTotalRetrieved = false;
3147
3153
  this.delListImgLoader = false;
3148
3154
  this.initComponent = true;
3149
3155
  this.failLoaded = false;
@@ -3346,7 +3352,7 @@ class ImagesViewComponent {
3346
3352
  * Set a img list in order to fill properly all the line of images displayed in mosaic.
3347
3353
  * Otherwise, the space-between css will do a bad display
3348
3354
  */
3349
- calculNbImgFake(nbImgDisplayed) {
3355
+ calculateNbImgFake(nbImgDisplayed) {
3350
3356
  const nbImgPerLine = this.stateDisplayed === 'small' || this.tabDisplayed === 'img-upload' ? this.nbMaxImgPerLine : this.nbMinImgPerLine;
3351
3357
  if (nbImgDisplayed % nbImgPerLine !== 0) {
3352
3358
  this.nbFakeImg = nbImgPerLine - nbImgDisplayed % nbImgPerLine;
@@ -3417,35 +3423,38 @@ class ImagesViewComponent {
3417
3423
  this.displayPexelsResults = false;
3418
3424
  this.setParams();
3419
3425
  this.refreshTotalImgList();
3420
- this.imgManager.getShopImgList(this.params).pipe(take(1)).subscribe((data) => {
3421
- this.initVariables(true);
3422
- const nbImgDisplayed = data.data.length;
3423
- this.calculNbImgFake(nbImgDisplayed);
3424
- this.picturesList = data.data;
3425
- this.renamePictureService.setPicturesList(this.picturesList);
3426
- this.selectImgSelected();
3427
- this.length = this.isTotalRetieved ? this.length : data.totalRecords;
3428
- this.tableFilters.totalItems = this.isTotalRetieved ? this.tableFilters.totalItems : data.totalRecords;
3429
- this.tableFilters.itemsPerPage = this.tableFilters.itemsPerPage ? this.tableFilters.itemsPerPage : this.pageSize;
3430
- // Display Pexels if no result
3431
- if (data.totalRecords === 0) {
3432
- this.displayPexelsLib();
3426
+ this.imgManager.getShopImgList(this.params).pipe(take(1)).subscribe({
3427
+ next: (data) => {
3428
+ this.initVariables(true);
3429
+ const nbImgDisplayed = data.data.length;
3430
+ this.calculateNbImgFake(nbImgDisplayed);
3431
+ this.picturesList = data.data;
3432
+ this.renamePictureService.setPicturesList(this.picturesList);
3433
+ this.selectImgSelected();
3434
+ this.length = this.isTotalRetrieved ? this.length : data.totalRecords;
3435
+ this.tableFilters.totalItems = this.isTotalRetrieved ? this.tableFilters.totalItems : data.totalRecords;
3436
+ this.tableFilters.itemsPerPage = this.tableFilters.itemsPerPage ? this.tableFilters.itemsPerPage : this.pageSize;
3437
+ // Display Pexels if no result
3438
+ if (data.totalRecords === 0) {
3439
+ this.displayPexelsLib();
3440
+ }
3441
+ },
3442
+ error: error => {
3443
+ this.alertService.openAlert(this.errorGetAllImg);
3444
+ this.initVariables(false);
3433
3445
  }
3434
- }, error => {
3435
- this.alertService.openAlert(this.errorGetAllImg);
3436
- this.initVariables(false);
3437
3446
  });
3438
3447
  }
3439
3448
  refreshTotalImgList() {
3440
3449
  const searchValue = this.tableFilters.searchValue;
3441
- if (this.isTotalRetieved && searchValue === this.previousSearchValue) {
3450
+ if (this.isTotalRetrieved && searchValue === this.previousSearchValue) {
3442
3451
  // Keep current total result
3443
3452
  return;
3444
3453
  }
3445
- this.isTotalRetieved = false;
3454
+ this.isTotalRetrieved = false;
3446
3455
  this.imgManager.getShopTotalImgList(this.params).pipe(take(1)).subscribe((data) => {
3447
3456
  this.previousSearchValue = searchValue;
3448
- this.isTotalRetieved = true;
3457
+ this.isTotalRetrieved = true;
3449
3458
  this.length = data.totalRecords;
3450
3459
  this.tableFilters.totalItems = data.totalRecords;
3451
3460
  }, error => {