@wizishop/img-manager 0.2.98 → 0.2.101

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.
Files changed (34) hide show
  1. package/assets/i18n/fr.json +1 -1
  2. package/bundles/wizishop-img-manager.umd.js +248 -201
  3. package/bundles/wizishop-img-manager.umd.js.map +1 -1
  4. package/bundles/wizishop-img-manager.umd.min.js +2 -2
  5. package/bundles/wizishop-img-manager.umd.min.js.map +1 -1
  6. package/esm2015/lib/components/canva-btn/canva-btn.component.js +6 -81
  7. package/esm2015/lib/components/images-view/images-view.component.js +18 -11
  8. package/esm2015/lib/components/img-tabs/img-tabs.component.js +2 -2
  9. package/esm2015/lib/components/img-upload/img-upload.component.js +23 -4
  10. package/esm2015/lib/services/canva.service.js +88 -5
  11. package/esm2015/lib/wz-img-manager.component.js +15 -1
  12. package/esm2015/wizishop-img-manager.js +4 -4
  13. package/esm5/lib/components/canva-btn/canva-btn.component.js +6 -87
  14. package/esm5/lib/components/images-view/images-view.component.js +18 -11
  15. package/esm5/lib/components/img-tabs/img-tabs.component.js +2 -2
  16. package/esm5/lib/components/img-upload/img-upload.component.js +23 -4
  17. package/esm5/lib/services/canva.service.js +94 -5
  18. package/esm5/lib/wz-img-manager.component.js +19 -1
  19. package/esm5/wizishop-img-manager.js +4 -4
  20. package/fesm2015/wizishop-img-manager.js +231 -188
  21. package/fesm2015/wizishop-img-manager.js.map +1 -1
  22. package/fesm5/wizishop-img-manager.js +246 -199
  23. package/fesm5/wizishop-img-manager.js.map +1 -1
  24. package/lib/components/canva-btn/canva-btn.component.d.ts +2 -19
  25. package/lib/components/images-view/images-view.component.d.ts +1 -1
  26. package/lib/components/img-upload/img-upload.component.d.ts +3 -0
  27. package/lib/services/canva.service.d.ts +20 -1
  28. package/lib/wz-img-manager.component.d.ts +2 -0
  29. package/package.json +1 -1
  30. package/wizishop-img-manager-0.2.101.tgz +0 -0
  31. package/wizishop-img-manager.d.ts +3 -3
  32. package/wizishop-img-manager.metadata.json +1 -1
  33. package/wz-img-manager.scss +62 -62
  34. package/wizishop-img-manager-0.2.98.tgz +0 -0
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common/http'), require('@angular/animations'), require('@ngx-translate/core'), require('@wizishop/ng-wizi-bulma'), require('rxjs/operators'), require('@angular/router'), require('@angular/common'), require('@angular/forms'), require('ngx-scrollbar'), require('ngx-scrollbar/reached-event'), require('ngx-image-cropper'), require('@angular/cdk/table'), require('@angular/cdk/drag-drop'), require('uuid'), require('ngx-perfect-scrollbar')) :
3
- typeof define === 'function' && define.amd ? define('@wizishop/img-manager', ['exports', '@angular/core', 'rxjs', '@angular/common/http', '@angular/animations', '@ngx-translate/core', '@wizishop/ng-wizi-bulma', 'rxjs/operators', '@angular/router', '@angular/common', '@angular/forms', 'ngx-scrollbar', 'ngx-scrollbar/reached-event', 'ngx-image-cropper', '@angular/cdk/table', '@angular/cdk/drag-drop', 'uuid', 'ngx-perfect-scrollbar'], factory) :
4
- (global = global || self, factory((global.wizishop = global.wizishop || {}, global.wizishop['img-manager'] = {}), global['^9']['0']['3'], global['~6']['5']['4'], global.ng.common.http, global['~9']['0']['3'], global['^13']['0']['0'], global['^9']['1']['4'], global.rxjs.operators, global.ng.router, global['^9']['0']['3'], global['~9']['0']['3'], global['^7']['2']['3'], global.reachedEvent, global['^3']['1']['9'], global.ng.cdk.table, global.ng.cdk['drag-drop'], global.uuid, global['^10']['1']['1']));
5
- }(this, (function (exports, core, rxjs, http, animations, core$1, ngWiziBulma, operators, router, common, forms, ngxScrollbar, reachedEvent, ngxImageCropper, table, dragDrop, uuid, ngxPerfectScrollbar) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common/http'), require('@ngx-translate/core'), require('@wizishop/ng-wizi-bulma'), require('rxjs/operators'), require('@angular/animations'), require('@angular/router'), require('@angular/common'), require('@angular/forms'), require('ngx-scrollbar'), require('ngx-scrollbar/reached-event'), require('ngx-image-cropper'), require('@angular/cdk/table'), require('@angular/cdk/drag-drop'), require('uuid'), require('ngx-perfect-scrollbar')) :
3
+ typeof define === 'function' && define.amd ? define('@wizishop/img-manager', ['exports', '@angular/core', 'rxjs', '@angular/common/http', '@ngx-translate/core', '@wizishop/ng-wizi-bulma', 'rxjs/operators', '@angular/animations', '@angular/router', '@angular/common', '@angular/forms', 'ngx-scrollbar', 'ngx-scrollbar/reached-event', 'ngx-image-cropper', '@angular/cdk/table', '@angular/cdk/drag-drop', 'uuid', 'ngx-perfect-scrollbar'], factory) :
4
+ (global = global || self, factory((global.wizishop = global.wizishop || {}, global.wizishop['img-manager'] = {}), global['^9']['0']['3'], global['~6']['5']['4'], global.ng.common.http, global['^13']['0']['0'], global['^9']['1']['4'], global.rxjs.operators, global['~9']['0']['3'], global.ng.router, global['^9']['0']['3'], global['~9']['0']['3'], global['^7']['2']['3'], global.reachedEvent, global['^3']['1']['9'], global.ng.cdk.table, global.ng.cdk['drag-drop'], global.uuid, global['^10']['1']['1']));
5
+ }(this, (function (exports, core, rxjs, http, core$1, ngWiziBulma, operators, animations, router, common, forms, ngxScrollbar, reachedEvent, ngxImageCropper, table, dragDrop, uuid, ngxPerfectScrollbar) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -603,9 +603,114 @@
603
603
  return UserSettingsService;
604
604
  }());
605
605
 
606
+ var AlertService = /** @class */ (function () {
607
+ function AlertService(nwbAlertService, translateService) {
608
+ this.nwbAlertService = nwbAlertService;
609
+ this.translateService = translateService;
610
+ this.actionMsg = 'ImgManager.alert.action';
611
+ this.alertConfig = {
612
+ message: '',
613
+ duration: 5000
614
+ };
615
+ }
616
+ AlertService.prototype.openAlert = function (msgKey) {
617
+ var _this = this;
618
+ this.closePreviousAlert();
619
+ this.translateService.get(msgKey).subscribe(function (trans) {
620
+ _this.alertConfig.message = trans;
621
+ _this.setAlertColor(msgKey);
622
+ _this.alertRefComponent = _this.nwbAlertService.open(_this.alertConfig);
623
+ _this.alertRefComponent.afterClosed().subscribe();
624
+ });
625
+ };
626
+ AlertService.prototype.openAlertWithBackendRespons = function (msgKey, msgBackend) {
627
+ var _this = this;
628
+ this.translateService.get(msgKey).subscribe(function (trans) {
629
+ _this.alertConfig.message = trans;
630
+ _this.alertConfig.message += '<br/>' + JSON.parse(msgBackend).message;
631
+ _this.closePreviousAlert();
632
+ _this.alertRefComponent = _this.nwbAlertService.open(_this.alertConfig);
633
+ _this.alertRefComponent.afterClosed().subscribe();
634
+ });
635
+ };
636
+ AlertService.prototype.closePreviousAlert = function () {
637
+ if (this.alertRefComponent) {
638
+ this.alertRefComponent.dismiss();
639
+ }
640
+ };
641
+ AlertService.prototype.setAlertColor = function (msgKey) {
642
+ var isErrorMsg = /error/i.test(msgKey);
643
+ this.alertConfig.color = isErrorMsg ? 'is-danger' : 'is-success';
644
+ };
645
+ AlertService.ctorParameters = function () { return [
646
+ { type: ngWiziBulma.NwbAlertService },
647
+ { type: core$1.TranslateService }
648
+ ]; };
649
+ AlertService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function AlertService_Factory() { return new AlertService(core["ɵɵinject"](ngWiziBulma.NwbAlertService), core["ɵɵinject"](core$1.TranslateService)); }, token: AlertService, providedIn: "root" });
650
+ AlertService = __decorate([
651
+ core.Injectable({
652
+ providedIn: 'root'
653
+ }),
654
+ __metadata("design:paramtypes", [ngWiziBulma.NwbAlertService,
655
+ core$1.TranslateService])
656
+ ], AlertService);
657
+ return AlertService;
658
+ }());
659
+
660
+ var ImgEventService = /** @class */ (function () {
661
+ function ImgEventService() {
662
+ this.imgToEditEvent = new rxjs.Subject();
663
+ this.imgRemoved = new rxjs.Subject();
664
+ this.imgAdded = new rxjs.Subject();
665
+ this.listDisplayedChange = new rxjs.Subject();
666
+ }
667
+ ImgEventService.prototype.emitImgRemoved = function (id_file) {
668
+ this.imgRemoved.next(id_file);
669
+ };
670
+ ImgEventService.prototype.getImgRemovedEventListner = function () {
671
+ return this.imgRemoved.asObservable();
672
+ };
673
+ ImgEventService.prototype.emitImgToEdit = function (imgToEdit) {
674
+ this.imgToEditEvent.next(imgToEdit);
675
+ };
676
+ ImgEventService.prototype.getImgToEditEventListner = function () {
677
+ return this.imgToEditEvent.asObservable();
678
+ };
679
+ ImgEventService.prototype.emitImgAdded = function (id_file) {
680
+ this.imgAdded.next(id_file);
681
+ };
682
+ ImgEventService.prototype.getImgAddedEventListner = function () {
683
+ return this.imgAdded.asObservable();
684
+ };
685
+ ImgEventService.prototype.emitlistDisplayedChange = function (value) {
686
+ this.listDisplayedChange.next(value);
687
+ };
688
+ ImgEventService.prototype.getlistDisplayedChange = function () {
689
+ return this.listDisplayedChange.asObservable();
690
+ };
691
+ ImgEventService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function ImgEventService_Factory() { return new ImgEventService(); }, token: ImgEventService, providedIn: "root" });
692
+ ImgEventService = __decorate([
693
+ core.Injectable({
694
+ providedIn: 'root'
695
+ }),
696
+ __metadata("design:paramtypes", [])
697
+ ], ImgEventService);
698
+ return ImgEventService;
699
+ }());
700
+
606
701
  var CanvaService = /** @class */ (function () {
607
- function CanvaService(externalConfigService) {
702
+ function CanvaService(externalConfigService, imgManager, wzImgEventService, alertService, translateService) {
608
703
  this.externalConfigService = externalConfigService;
704
+ this.imgManager = imgManager;
705
+ this.wzImgEventService = wzImgEventService;
706
+ this.alertService = alertService;
707
+ this.translateService = translateService;
708
+ this.imgLoading = false;
709
+ this.uploadingImg = 'ImgManager.CanvaBtn.uploadingImg';
710
+ this.successUploadPhoto = 'ImgManager.CanvaBtn.successImport';
711
+ this.errorUploadCanvaImg = 'ImgManager.CanvaBtn.errorUploadCanvaImg';
712
+ this.errorRenameCanvaImg = 'ImgManager.CanvaBtn.errorRenameCanvaImg';
713
+ this.forceToOpenCanva = false;
609
714
  this.bindExpectedImgSizeEvent = new rxjs.BehaviorSubject(null);
610
715
  this.bindExpectedSizeDone = this.bindExpectedImgSizeEvent.asObservable();
611
716
  }
@@ -621,6 +726,9 @@
621
726
  };
622
727
  CanvaService.prototype.expectedImgSizesChange = function (mediaDTO) {
623
728
  this.bindExpectedImgSizeEvent.next(mediaDTO);
729
+ if (this.forceToOpenCanva) {
730
+ this.openCanva(parseInt(mediaDTO.image_width), parseInt(mediaDTO.image_height));
731
+ }
624
732
  };
625
733
  CanvaService.prototype.getCanvaApi = function () {
626
734
  var _this = this;
@@ -675,58 +783,84 @@
675
783
  };
676
784
  document.getElementsByTagName('head')[0].appendChild(node);
677
785
  };
678
- CanvaService.ctorParameters = function () { return [
679
- { type: ImgManagerConfigService }
680
- ]; };
681
- CanvaService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function CanvaService_Factory() { return new CanvaService(core["ɵɵinject"](ImgManagerConfigService)); }, token: CanvaService, providedIn: "root" });
682
- CanvaService = __decorate([
683
- core.Injectable({
684
- providedIn: 'root'
685
- }),
686
- __metadata("design:paramtypes", [ImgManagerConfigService])
687
- ], CanvaService);
688
- return CanvaService;
689
- }());
690
-
691
- var ImgEventService = /** @class */ (function () {
692
- function ImgEventService() {
693
- this.imgToEditEvent = new rxjs.Subject();
694
- this.imgRemoved = new rxjs.Subject();
695
- this.imgAdded = new rxjs.Subject();
696
- this.listDisplayedChange = new rxjs.Subject();
697
- }
698
- ImgEventService.prototype.emitImgRemoved = function (id_file) {
699
- this.imgRemoved.next(id_file);
700
- };
701
- ImgEventService.prototype.getImgRemovedEventListner = function () {
702
- return this.imgRemoved.asObservable();
703
- };
704
- ImgEventService.prototype.emitImgToEdit = function (imgToEdit) {
705
- this.imgToEditEvent.next(imgToEdit);
706
- };
707
- ImgEventService.prototype.getImgToEditEventListner = function () {
708
- return this.imgToEditEvent.asObservable();
786
+ CanvaService.prototype.openCanva = function (width, height) {
787
+ var _this = this;
788
+ if (this.imgLoading) {
789
+ return;
790
+ }
791
+ this.getCanvaApi().pipe(operators.take(1)).subscribe(function (api) {
792
+ _this.canvaApi = api;
793
+ _this.addOverflowBody();
794
+ _this.createDesign(width, height);
795
+ });
709
796
  };
710
- ImgEventService.prototype.emitImgAdded = function (id_file) {
711
- this.imgAdded.next(id_file);
797
+ CanvaService.prototype.addOverflowBody = function () {
798
+ document.body.classList.add('ovh-canva');
712
799
  };
713
- ImgEventService.prototype.getImgAddedEventListner = function () {
714
- return this.imgAdded.asObservable();
800
+ CanvaService.prototype.removeOverflowBody = function () {
801
+ document.body.classList.remove('ovh-canva');
715
802
  };
716
- ImgEventService.prototype.emitlistDisplayedChange = function (value) {
717
- this.listDisplayedChange.next(value);
803
+ CanvaService.prototype.createDesign = function (width, height) {
804
+ var _this = this;
805
+ var createDesign = {
806
+ type: 'EtsyShopIcon',
807
+ dimensions: {
808
+ units: 'px',
809
+ width: width ? width : undefined,
810
+ height: height ? height : undefined,
811
+ },
812
+ publishLabel: this.translateService.instant('ImgManager.CanvaBtn.publish'),
813
+ };
814
+ this.canvaApi.createDesign({
815
+ design: createDesign,
816
+ onDesignPublish: function (_a) {
817
+ var exportUrl = _a.exportUrl, designTitle = _a.designTitle;
818
+ return _this.designPublished(exportUrl, designTitle);
819
+ },
820
+ onDesignClose: function () {
821
+ _this.removeOverflowBody();
822
+ }
823
+ });
718
824
  };
719
- ImgEventService.prototype.getlistDisplayedChange = function () {
720
- return this.listDisplayedChange.asObservable();
825
+ CanvaService.prototype.designPublished = function (exportUrl, designTitle) {
826
+ var _this = this;
827
+ this.alertService.openAlert(this.uploadingImg);
828
+ this.imgLoading = true;
829
+ this.imgManager.uploadFileByUrl(exportUrl, designTitle).pipe(operators.take(1)).subscribe(function (img) {
830
+ _this.imgLoading = false;
831
+ _this.removeOverflowBody();
832
+ _this.wzImgEventService.emitImgAdded(img.id_file);
833
+ _this.alertService.openAlert(_this.successUploadPhoto);
834
+ }, function (error) {
835
+ _this.imgLoading = false;
836
+ _this.removeOverflowBody();
837
+ if (error.error.code === 406 && error.error.message) {
838
+ _this.alertService.openAlertWithBackendRespons(_this.errorUploadCanvaImg, error.error.message);
839
+ }
840
+ else {
841
+ _this.alertService.openAlert(_this.errorUploadCanvaImg);
842
+ }
843
+ });
721
844
  };
722
- ImgEventService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function ImgEventService_Factory() { return new ImgEventService(); }, token: ImgEventService, providedIn: "root" });
723
- ImgEventService = __decorate([
845
+ CanvaService.ctorParameters = function () { return [
846
+ { type: ImgManagerConfigService },
847
+ { type: ImgManagerService },
848
+ { type: ImgEventService },
849
+ { type: AlertService },
850
+ { type: core$1.TranslateService }
851
+ ]; };
852
+ CanvaService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function CanvaService_Factory() { return new CanvaService(core["ɵɵinject"](ImgManagerConfigService), core["ɵɵinject"](ImgManagerService), core["ɵɵinject"](ImgEventService), core["ɵɵinject"](AlertService), core["ɵɵinject"](core$1.TranslateService)); }, token: CanvaService, providedIn: "root" });
853
+ CanvaService = __decorate([
724
854
  core.Injectable({
725
855
  providedIn: 'root'
726
856
  }),
727
- __metadata("design:paramtypes", [])
728
- ], ImgEventService);
729
- return ImgEventService;
857
+ __metadata("design:paramtypes", [ImgManagerConfigService,
858
+ ImgManagerService,
859
+ ImgEventService,
860
+ AlertService,
861
+ core$1.TranslateService])
862
+ ], CanvaService);
863
+ return CanvaService;
730
864
  }());
731
865
 
732
866
  var DomService = /** @class */ (function () {
@@ -779,6 +913,19 @@
779
913
  this.listDisplayed = false;
780
914
  this.hideTab = false;
781
915
  }
916
+ Object.defineProperty(WzImgManagerComponent.prototype, "forceToOpenCanva", {
917
+ // If forceToOpenCanva is true : Canva will open with the canvaService.expectedImgSizesChange
918
+ // If forceToOpenCanva is a WiziBlockMediaDto, Canva open immediatly
919
+ set: function (forceToOpenCanva) {
920
+ this.canvaService.forceToOpenCanva = !!forceToOpenCanva;
921
+ if (typeof forceToOpenCanva === 'boolean') {
922
+ return;
923
+ }
924
+ this.canvaService.expectedImgSizesChange(forceToOpenCanva);
925
+ },
926
+ enumerable: true,
927
+ configurable: true
928
+ });
782
929
  Object.defineProperty(WzImgManagerComponent.prototype, "multipleImgMode", {
783
930
  get: function () {
784
931
  return this._multipleImgMode;
@@ -927,6 +1074,11 @@
927
1074
  core.Input(),
928
1075
  __metadata("design:type", ImgManagerConfigDto)
929
1076
  ], WzImgManagerComponent.prototype, "externalConfig", void 0);
1077
+ __decorate([
1078
+ core.Input(),
1079
+ __metadata("design:type", Object),
1080
+ __metadata("design:paramtypes", [Object])
1081
+ ], WzImgManagerComponent.prototype, "forceToOpenCanva", null);
930
1082
  __decorate([
931
1083
  core.Output(),
932
1084
  __metadata("design:type", Object)
@@ -973,60 +1125,6 @@
973
1125
  ]),
974
1126
  ]);
975
1127
 
976
- var AlertService = /** @class */ (function () {
977
- function AlertService(nwbAlertService, translateService) {
978
- this.nwbAlertService = nwbAlertService;
979
- this.translateService = translateService;
980
- this.actionMsg = 'ImgManager.alert.action';
981
- this.alertConfig = {
982
- message: '',
983
- duration: 5000
984
- };
985
- }
986
- AlertService.prototype.openAlert = function (msgKey) {
987
- var _this = this;
988
- this.closePreviousAlert();
989
- this.translateService.get(msgKey).subscribe(function (trans) {
990
- _this.alertConfig.message = trans;
991
- _this.setAlertColor(msgKey);
992
- _this.alertRefComponent = _this.nwbAlertService.open(_this.alertConfig);
993
- _this.alertRefComponent.afterClosed().subscribe();
994
- });
995
- };
996
- AlertService.prototype.openAlertWithBackendRespons = function (msgKey, msgBackend) {
997
- var _this = this;
998
- this.translateService.get(msgKey).subscribe(function (trans) {
999
- _this.alertConfig.message = trans;
1000
- _this.alertConfig.message += '<br/>' + JSON.parse(msgBackend).message;
1001
- _this.closePreviousAlert();
1002
- _this.alertRefComponent = _this.nwbAlertService.open(_this.alertConfig);
1003
- _this.alertRefComponent.afterClosed().subscribe();
1004
- });
1005
- };
1006
- AlertService.prototype.closePreviousAlert = function () {
1007
- if (this.alertRefComponent) {
1008
- this.alertRefComponent.dismiss();
1009
- }
1010
- };
1011
- AlertService.prototype.setAlertColor = function (msgKey) {
1012
- var isErrorMsg = /error/i.test(msgKey);
1013
- this.alertConfig.color = isErrorMsg ? 'is-danger' : 'is-success';
1014
- };
1015
- AlertService.ctorParameters = function () { return [
1016
- { type: ngWiziBulma.NwbAlertService },
1017
- { type: core$1.TranslateService }
1018
- ]; };
1019
- AlertService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function AlertService_Factory() { return new AlertService(core["ɵɵinject"](ngWiziBulma.NwbAlertService), core["ɵɵinject"](core$1.TranslateService)); }, token: AlertService, providedIn: "root" });
1020
- AlertService = __decorate([
1021
- core.Injectable({
1022
- providedIn: 'root'
1023
- }),
1024
- __metadata("design:paramtypes", [ngWiziBulma.NwbAlertService,
1025
- core$1.TranslateService])
1026
- ], AlertService);
1027
- return AlertService;
1028
- }());
1029
-
1030
1128
  var ImgUploadComponent = /** @class */ (function () {
1031
1129
  function ImgUploadComponent(imgManager, alertService, externalConfigService) {
1032
1130
  this.imgManager = imgManager;
@@ -1038,6 +1136,7 @@
1038
1136
  this.loadingText = 'ImgManager.ImgUpload.loading';
1039
1137
  this.errorUploadingImg = 'ImgManager.ImgUpload.errorUploadingImg';
1040
1138
  this.errorNotImg = 'ImgManager.ImgUpload.errorNotImg';
1139
+ this.MAX_IMAGE_SIZE = 10000000; // In bytes
1041
1140
  }
1042
1141
  ImgUploadComponent.prototype.ngOnInit = function () {
1043
1142
  this.assetsIcon = this.getAssets();
@@ -1063,13 +1162,19 @@
1063
1162
  try {
1064
1163
  for (var files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
1065
1164
  var file = files_1_1.value;
1066
- var formData = new FormData();
1067
- formData.append('image', file, file.name);
1165
+ console.log('file', file.size);
1068
1166
  if (!this.isFileImage(file.type)) {
1069
1167
  this.alertService.openAlert(this.errorNotImg);
1070
1168
  this.isLoading = false;
1071
1169
  continue;
1072
1170
  }
1171
+ if (!this.isSizeValid(file.size)) {
1172
+ this.alertService.openAlert("L'image : " + file.name + " est trop grande (" + this.getImageSizeInKo(file.size) + "ko). Taille maximum accept\u00E9e: " + this.getImageSizeInKo(this.MAX_IMAGE_SIZE) + "ko");
1173
+ this.isLoading = false;
1174
+ continue;
1175
+ }
1176
+ var formData = new FormData();
1177
+ formData.append('image', file, file.name);
1073
1178
  imgToUploadList.push(this.imgManager.uploadFile(formData));
1074
1179
  }
1075
1180
  }
@@ -1084,7 +1189,13 @@
1084
1189
  _this.onImgUpload(img),
1085
1190
  _this.isLoading = false;
1086
1191
  }, function (error) {
1087
- _this.alertService.openAlert(_this.errorUploadingImg);
1192
+ var _a, _b;
1193
+ if (((_b = (_a = error) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.message) && error.statusText !== 'Bad Request') {
1194
+ _this.alertService.openAlertWithBackendRespons(_this.errorUploadingImg, error.error.message);
1195
+ }
1196
+ else {
1197
+ _this.alertService.openAlert(_this.errorUploadingImg);
1198
+ }
1088
1199
  _this.isLoading = false;
1089
1200
  });
1090
1201
  };
@@ -1099,6 +1210,12 @@
1099
1210
  ImgUploadComponent.prototype.isFileImage = function (fileType) {
1100
1211
  return fileType.split('/')[0] === 'image';
1101
1212
  };
1213
+ ImgUploadComponent.prototype.isSizeValid = function (imageBytesSize) {
1214
+ return imageBytesSize < this.MAX_IMAGE_SIZE;
1215
+ };
1216
+ ImgUploadComponent.prototype.getImageSizeInKo = function (size) {
1217
+ return Math.round(size / 1024);
1218
+ };
1102
1219
  /**
1103
1220
  * Remove the style of the drag and drop box
1104
1221
  * After an img is droped, the box is still grey
@@ -1430,7 +1547,7 @@
1430
1547
  ImgTabsComponent = __decorate([
1431
1548
  core.Component({
1432
1549
  selector: 'img-tabs',
1433
- template: "<div\n class=\"img-tabs\" [ngClass]=\"{'small': stateDisplayed === 'small'}\">\n <div class=\"wrapper-tabs\">\n <div\n class=\"tabs\"\n [ngClass]=\"\n {\n 'tabs--notWindow': stateDisplayed !== 'window',\n 'tabs--notDisplayed': stateDisplayed === 'window' && tabActive.value === tabs[3].value\n }\">\n\n <ul>\n <li class=\"is-active\" [ngClass]=\"{'is-active': tabActive.value === tabs[0].value}\" (click)=\"toggleTabs(tabs[0])\"><a>{{ tabs[0].name | translate }}</a></li>\n <li [ngClass]=\"{'is-active': tabActive.value === tabs[1].value}\" (click)=\"toggleTabs(tabs[1])\"><a>{{ tabs[1].name | translate }}</a></li>\n <li [ngClass]=\"{'is-active': tabActive.value === tabs[2].value}\" (click)=\"toggleTabs(tabs[2])\"><a>{{ tabs[2].name | translate }}</a></li>\n <li [ngClass]=\"{'is-active': tabActive.value === tabs[3].value}\" *ngIf=\"editTab\"><a>{{ tabs[3].name | translate }}</a></li>\n </ul>\n <div\n class=\"img-tabs__canva\"\n [ngClass]=\"{'img-tabs__canva--window': stateDisplayed === 'window'}\">\n <canva-btn\n (showImgUploaded)=\"onShowImgUploaded()\"\n [stateDisplayed]=\"stateDisplayed\">\n </canva-btn>\n </div>\n </div>\n <div class=\"select-mobile-page\">\n <wac-select\n [(ngModel)]=\"tabActive\"\n name=\"tabs\"\n [items]=\"tabs\"\n ></wac-select>\n </div>\n </div>\n\n <!-- Upload section -->\n <div\n class=\"columns img-tabs__tabsFirst\"\n [ngClass]=\"{\n 'img-tabs__tabsFirst--small': stateDisplayed === 'small',\n 'img-tabs__tabsFirst--window': stateDisplayed === 'window'\n }\"\n *ngIf=\"tabActive.value === tabs[0].value\">\n <div class=\"column img-tabs__tabsFirst__upload\">\n <img-upload\n [stateDisplayed]=\"stateDisplayed\"\n (imgUploaded)=\"onImgUploaded($event)\"\n ></img-upload>\n </div>\n <div class=\"column img-tabs__tabsFirst__list\" [ngClass]=\"{\n 'img-tabs__tabsFirst__list--upload': imgUpload\n }\">\n <images-view\n *ngIf=\"!imgUpload\"\n [stateDisplayed]=\"stateDisplayed\"\n [listDisplayed]=\"false\"\n [multipleImgMode]=\"multipleImgMode\"\n [tabDisplayed]=\"tabActive.value\"\n [maxLengthCardShow]=\"stateDisplayed === 'small' ? 16 : 8\"\n (switchDisplayWindow)=\"switchDisplayWindowImgView()\"\n [fullSize]=\"false\">\n </images-view>\n\n\n <div [hidden]=\"!imgUpload\">\n <upload-list\n #imgUploadedImg\n [stateDisplayed]=\"stateDisplayed\"\n [tabDisplayed]=\"tabActive.value\"\n [multipleImgMode]=\"multipleImgMode\"\n (switchDisplayWindow)=\"switchDisplayWindowImgView()\"\n >\n </upload-list>\n </div>\n </div>\n </div>\n\n <!-- Images section -->\n <div class=\"columns img-tabs__tabsSecond\" *ngIf=\"tabActive.value === tabs[1].value\">\n <div class=\"column\">\n\n <images-view\n [stateDisplayed]=\"stateDisplayed\"\n [listDisplayed]=\"listDisplayed\"\n [multipleImgMode]=\"multipleImgMode\"\n [tabDisplayed]=\"tabActive.value\"\n (switchDisplayWindow)=\"switchDisplayWindowImgView()\"\n [fullSize]=\"true\">\n </images-view>\n\n </div>\n </div>\n\n <!-- Pexel img section -->\n <div class=\"columns img-tabs__tabsThird\" *ngIf=\"tabActive.value === tabs[2].value\">\n <div class=\"column\">\n <pexels-lib\n [stateDisplayed]=\"stateDisplayed\"\n (showImgUploaded)=\"onShowImgUploaded()\">\n </pexels-lib>\n </div>\n </div>\n\n <!--Edition section -->\n <div class=\"columns img-tabs__tabsEdit\" *ngIf=\"tabActive.value === tabs[3].value\">\n <div class=\"column\">\n <img-editor\n [stateDisplayed]=\"stateDisplayed\"\n [imgToEdit]=\"imgToEdit\"\n (editClosed)=\"onEditClosed($event)\">\n </img-editor>\n </div>\n </div>\n\n</div>\n"
1550
+ template: "<div\n class=\"img-tabs\" [ngClass]=\"{'small': stateDisplayed === 'small'}\">\n <div class=\"wrapper-tabs\">\n <div\n class=\"tabs\"\n [ngClass]=\"\n {\n 'tabs--notWindow': stateDisplayed !== 'window',\n 'tabs--notDisplayed': stateDisplayed === 'window' && tabActive.value === tabs[3].value\n }\">\n\n <ul>\n <li class=\"is-active\" [ngClass]=\"{'is-active': tabActive.value === tabs[0].value}\" (click)=\"toggleTabs(tabs[0])\"><a>{{ tabs[0].name | translate }}</a></li>\n <li [ngClass]=\"{'is-active': tabActive.value === tabs[1].value}\" (click)=\"toggleTabs(tabs[1])\"><a>{{ tabs[1].name | translate }}</a></li>\n <li [ngClass]=\"{'is-active': tabActive.value === tabs[2].value}\" (click)=\"toggleTabs(tabs[2])\"><a>{{ tabs[2].name | translate }}</a></li>\n <li [ngClass]=\"{'is-active': tabActive.value === tabs[3].value}\" *ngIf=\"editTab\"><a>{{ tabs[3].name | translate }}</a></li>\n </ul>\n <div\n class=\"img-tabs__canva\"\n [ngClass]=\"{'img-tabs__canva--window': stateDisplayed === 'window'}\">\n <canva-btn\n (showImgUploaded)=\"onShowImgUploaded()\"\n [stateDisplayed]=\"stateDisplayed\">\n </canva-btn>\n </div>\n </div>\n <div class=\"select-mobile-page\">\n <wac-select\n [(ngModel)]=\"tabActive\"\n name=\"tabs\"\n [items]=\"tabs\"\n ></wac-select>\n </div>\n </div>\n\n <!-- Upload section -->\n <div\n class=\"columns img-tabs__tabsFirst\"\n [ngClass]=\"{\n 'img-tabs__tabsFirst--small': stateDisplayed === 'small',\n 'img-tabs__tabsFirst--window': stateDisplayed === 'window'\n }\"\n *ngIf=\"tabActive.value === tabs[0].value\">\n <div class=\"column img-tabs__tabsFirst__upload\">\n <img-upload\n [stateDisplayed]=\"stateDisplayed\"\n (imgUploaded)=\"onImgUploaded($event)\"\n ></img-upload>\n </div>\n <div class=\"column img-tabs__tabsFirst__list\" [ngClass]=\"{\n 'img-tabs__tabsFirst__list--upload': imgUpload\n }\">\n <images-view\n *ngIf=\"!imgUpload\"\n [stateDisplayed]=\"stateDisplayed\"\n [listDisplayed]=\"false\"\n [multipleImgMode]=\"multipleImgMode\"\n [tabDisplayed]=\"tabActive.value\"\n [nbRowToShow]=\"2\"\n (switchDisplayWindow)=\"switchDisplayWindowImgView()\"\n [fullSize]=\"false\">\n </images-view>\n\n\n <div [hidden]=\"!imgUpload\">\n <upload-list\n #imgUploadedImg\n [stateDisplayed]=\"stateDisplayed\"\n [tabDisplayed]=\"tabActive.value\"\n [multipleImgMode]=\"multipleImgMode\"\n (switchDisplayWindow)=\"switchDisplayWindowImgView()\"\n >\n </upload-list>\n </div>\n </div>\n </div>\n\n <!-- Images section -->\n <div class=\"columns img-tabs__tabsSecond\" *ngIf=\"tabActive.value === tabs[1].value\">\n <div class=\"column\">\n\n <images-view\n [stateDisplayed]=\"stateDisplayed\"\n [listDisplayed]=\"listDisplayed\"\n [multipleImgMode]=\"multipleImgMode\"\n [tabDisplayed]=\"tabActive.value\"\n (switchDisplayWindow)=\"switchDisplayWindowImgView()\"\n [fullSize]=\"true\">\n </images-view>\n\n </div>\n </div>\n\n <!-- Pexel img section -->\n <div class=\"columns img-tabs__tabsThird\" *ngIf=\"tabActive.value === tabs[2].value\">\n <div class=\"column\">\n <pexels-lib\n [stateDisplayed]=\"stateDisplayed\"\n (showImgUploaded)=\"onShowImgUploaded()\">\n </pexels-lib>\n </div>\n </div>\n\n <!--Edition section -->\n <div class=\"columns img-tabs__tabsEdit\" *ngIf=\"tabActive.value === tabs[3].value\">\n <div class=\"column\">\n <img-editor\n [stateDisplayed]=\"stateDisplayed\"\n [imgToEdit]=\"imgToEdit\"\n (editClosed)=\"onEditClosed($event)\">\n </img-editor>\n </div>\n </div>\n\n</div>\n"
1434
1551
  }),
1435
1552
  __metadata("design:paramtypes", [ImgEventService,
1436
1553
  AlertService,
@@ -2141,13 +2258,8 @@
2141
2258
  }());
2142
2259
 
2143
2260
  var CanvaBtnComponent = /** @class */ (function () {
2144
- function CanvaBtnComponent(canvaService, imgManager, wzImgEventService, translateService, alertService, renderer) {
2261
+ function CanvaBtnComponent(canvaService) {
2145
2262
  this.canvaService = canvaService;
2146
- this.imgManager = imgManager;
2147
- this.wzImgEventService = wzImgEventService;
2148
- this.translateService = translateService;
2149
- this.alertService = alertService;
2150
- this.renderer = renderer;
2151
2263
  this.showImgUploaded = new core.EventEmitter();
2152
2264
  this.imgLoading = false;
2153
2265
  this.availableFormat = {
@@ -2166,10 +2278,6 @@
2166
2278
  };
2167
2279
  this.openDropDownMenu = false;
2168
2280
  this.subs = [];
2169
- this.uploadingImg = 'ImgManager.CanvaBtn.uploadingImg';
2170
- this.successUploadPhoto = 'ImgManager.CanvaBtn.successImport';
2171
- this.errorUploadCanvaImg = 'ImgManager.CanvaBtn.errorUploadCanvaImg';
2172
- this.errorRenameCanvaImg = 'ImgManager.CanvaBtn.errorRenameCanvaImg';
2173
2281
  }
2174
2282
  CanvaBtnComponent.prototype.ngOnInit = function () {
2175
2283
  this.canvaLogoRouteAssets = this.canvaService.getCanvaLogo();
@@ -2191,76 +2299,13 @@
2191
2299
  this.subs.push(subExpectedImgSizesChange);
2192
2300
  };
2193
2301
  CanvaBtnComponent.prototype.onOpenCanva = function (width, height) {
2194
- var _this = this;
2195
- if (this.imgLoading) {
2196
- return;
2197
- }
2198
- var subCanvaApi = this.canvaService.getCanvaApi().subscribe(function (api) {
2199
- _this.canvaApi = api;
2200
- _this.addOverflowBody();
2201
- _this.createDesign(width, height);
2202
- });
2203
- this.subs.push(subCanvaApi);
2204
- };
2205
- CanvaBtnComponent.prototype.createDesign = function (width, height) {
2206
- var _this = this;
2207
- var createDesign = {
2208
- type: 'EtsyShopIcon',
2209
- dimensions: {
2210
- units: 'px',
2211
- width: width ? width : undefined,
2212
- height: height ? height : undefined,
2213
- },
2214
- publishLabel: this.translateService.instant('ImgManager.CanvaBtn.publish'),
2215
- };
2216
- this.canvaApi.createDesign({
2217
- design: createDesign,
2218
- onDesignPublish: function (_a) {
2219
- var exportUrl = _a.exportUrl, designTitle = _a.designTitle;
2220
- return _this.designPublished(exportUrl, designTitle);
2221
- },
2222
- onDesignClose: function () {
2223
- _this.removeOverflowBody();
2224
- }
2225
- });
2226
- };
2227
- CanvaBtnComponent.prototype.designPublished = function (exportUrl, designTitle) {
2228
- var _this = this;
2229
- this.alertService.openAlert(this.uploadingImg);
2230
- this.imgLoading = true;
2231
- var subUploadImg = this.imgManager.uploadFileByUrl(exportUrl, designTitle).subscribe(function (img) {
2232
- _this.imgLoading = false;
2233
- _this.removeOverflowBody();
2234
- _this.wzImgEventService.emitImgAdded(img.id_file);
2235
- _this.alertService.openAlert(_this.successUploadPhoto);
2236
- }, function (error) {
2237
- _this.imgLoading = false;
2238
- _this.removeOverflowBody();
2239
- if (error.error.code === 406 && error.error.message) {
2240
- _this.alertService.openAlertWithBackendRespons(_this.errorUploadCanvaImg, error.error.message);
2241
- }
2242
- else {
2243
- _this.alertService.openAlert(_this.errorUploadCanvaImg);
2244
- }
2245
- });
2246
- this.subs.push(subUploadImg);
2247
- };
2248
- CanvaBtnComponent.prototype.addOverflowBody = function () {
2249
- this.renderer.addClass(document.body, 'ovh-canva');
2250
- };
2251
- CanvaBtnComponent.prototype.removeOverflowBody = function () {
2252
- this.renderer.removeClass(document.body, 'ovh-canva');
2302
+ this.canvaService.openCanva(width, height);
2253
2303
  };
2254
2304
  CanvaBtnComponent.prototype.ngOnDestroy = function () {
2255
2305
  this.subs.forEach(function (sub) { return sub.unsubscribe(); });
2256
2306
  };
2257
2307
  CanvaBtnComponent.ctorParameters = function () { return [
2258
- { type: CanvaService },
2259
- { type: ImgManagerService },
2260
- { type: ImgEventService },
2261
- { type: core$1.TranslateService },
2262
- { type: AlertService },
2263
- { type: core.Renderer2 }
2308
+ { type: CanvaService }
2264
2309
  ]; };
2265
2310
  __decorate([
2266
2311
  core.Input(),
@@ -2275,12 +2320,7 @@
2275
2320
  selector: 'canva-btn',
2276
2321
  template: "<div class=\"canva dropdown is-right is-hoverable\"\n wzAutoHide (clickOutside)=\"openDropDownMenu = false;\"\n [ngClass]=\"{'is-up': stateDisplayed === 'small', 'noTooltip': stateDisplayed !== 'small'}\"\n >\n <div class=\"dropdown-trigger\">\n <div\n class=\"button canva-btn\"\n aria-controls=\"dropdown-menuCanva\"\n (click)=\"openDropDownMenu = true;\"\n >\n <span>{{'ImgManager.CanvaBtn.createImg' | translate}}</span>\n <img [src]=\"canvaLogoRouteAssets\" class=\"canva-btn__logo\">\n\n <span btnLoadingAnim class=\"btnLoadingAnnimation\" *ngIf=\"imgLoading\"></span>\n </div>\n </div>\n <div\n class=\"dropdown-menu dropDownShadow\"\n [ngClass]=\"{'displayDropDownMenu': openDropDownMenu }\"\n id=\"dropdown-menuCanva\"\n role=\"menu\">\n <ng-scrollbar\n #scrollable\n [visibility]=\"'hover'\"\n class=\"smallScroll\"\n >\n <div class=\"dropdown-content\">\n <div class=\"dropdownTitle\">\n <p>{{'ImgManager.CanvaBtn.createImg.title' | translate}}</p>\n </div>\n\n <div class=\"infoItem\">\n <p>{{'ImgManager.CanvaBtn.info' | translate}}</p>\n </div>\n\n <ng-container >\n <div\n *ngIf=\"expectedWidth && expectedHeight\"\n class=\"dropdown-item-wrapper\"\n >\n <div class=\"dropdown-item expectedSizes\" (click)=\"onOpenCanva(expectedWidth, expectedHeight)\">\n <p>{{'ImgManager.CanvaBtn.recommanded' | translate}}</p><p>{{expectedWidth}}*{{expectedHeight}}</p>\n </div>\n </div>\n </ng-container>\n\n <div\n *ngFor=\"let format of availableFormat| keyvalue\"\n class=\"dropdown-item-wrapper\">\n <div\n (click)=\"onOpenCanva(format.value.width, format.value.height)\"\n class=\"dropdown-item\">\n <p>{{format.key | translate}}</p><p>{{format.value.width}}*{{format.value.height}}</p>\n </div>\n </div>\n </div>\n </ng-scrollbar>\n </div>\n</div>\n"
2277
2322
  }),
2278
- __metadata("design:paramtypes", [CanvaService,
2279
- ImgManagerService,
2280
- ImgEventService,
2281
- core$1.TranslateService,
2282
- AlertService,
2283
- core.Renderer2])
2323
+ __metadata("design:paramtypes", [CanvaService])
2284
2324
  ], CanvaBtnComponent);
2285
2325
  return CanvaBtnComponent;
2286
2326
  }());
@@ -2965,9 +3005,9 @@
2965
3005
  this.errorRemoveImg = 'ImgManager.ImgList.errorRemoveImg';
2966
3006
  }
2967
3007
  ImagesViewComponent.prototype.ngOnInit = function () {
2968
- if (this.maxLengthCardShow) {
2969
- this.reducePictureListMaxLength();
2970
- }
3008
+ /* if (this.maxLengthCardShow) {
3009
+ this.reducePictureListMaxLength();
3010
+ } */
2971
3011
  this.setEvents();
2972
3012
  this.imgSelectedList = this.imgSelectionService.getImgSelection();
2973
3013
  };
@@ -2978,9 +3018,9 @@
2978
3018
  this.savePictureList = this.picturesList;
2979
3019
  }
2980
3020
  };
2981
- ImagesViewComponent.prototype.reducePictureListMaxLength = function () {
2982
- this.picturesList.splice(0, this.maxLengthCardShow);
2983
- };
3021
+ /* reducePictureListMaxLength() {
3022
+ this.picturesList.splice(0, this.maxLengthCardShow);
3023
+ } */
2984
3024
  ImagesViewComponent.prototype.getImgList = function () {
2985
3025
  this.filtersChanged.next();
2986
3026
  };
@@ -3006,6 +3046,7 @@
3006
3046
  this.getImgList();
3007
3047
  };
3008
3048
  ImagesViewComponent.prototype.onRenamePicture = function (pictureRenamed) {
3049
+ console.log('onRenamePicture pictureRenamed', pictureRenamed);
3009
3050
  this.renamePictureService.onRenamePicture(pictureRenamed);
3010
3051
  };
3011
3052
  ImagesViewComponent.prototype.removeListImg = function () {
@@ -3112,6 +3153,10 @@
3112
3153
  return imgSizesConfig;
3113
3154
  };
3114
3155
  ImagesViewComponent.prototype.getTotalImgPerPage = function () {
3156
+ if (this.nbRowToShow) {
3157
+ var nbImgPerLine = this.stateDisplayed === 'full' ? this.nbMinImgPerLine : this.nbMaxImgPerLine;
3158
+ return nbImgPerLine * this.nbRowToShow;
3159
+ }
3115
3160
  var total = this.nbMinImgPerLine;
3116
3161
  while (total < 30 || total % this.nbMaxImgPerLine !== 0 || total % this.nbMinImgPerLine !== 0) {
3117
3162
  total += this.nbMinImgPerLine;
@@ -3119,8 +3164,9 @@
3119
3164
  return total;
3120
3165
  };
3121
3166
  ImagesViewComponent.prototype.setParams = function () {
3167
+ var _a;
3122
3168
  this.params = {
3123
- limit: this.tableFilters.itemsPerPage ? this.tableFilters.itemsPerPage.toString() : this.pageSize.toString(),
3169
+ limit: ((_a = this.maxLengthCardShow) === null || _a === void 0 ? void 0 : _a.toString()) || (this.tableFilters.itemsPerPage ? this.tableFilters.itemsPerPage.toString() : this.pageSize.toString()),
3124
3170
  page: this.tableFilters.currentPage.toString()
3125
3171
  };
3126
3172
  if (this.tableFilters.searchValue) {
@@ -3267,9 +3313,6 @@
3267
3313
  _this.length = _this.isTotalRetieved ? _this.length : data.totalRecords;
3268
3314
  _this.tableFilters.totalItems = _this.isTotalRetieved ? _this.tableFilters.totalItems : data.totalRecords;
3269
3315
  _this.tableFilters.itemsPerPage = _this.tableFilters.itemsPerPage ? _this.tableFilters.itemsPerPage : _this.pageSize;
3270
- if (_this.maxLengthCardShow) {
3271
- _this.picturesList = _this.picturesList.splice(0, 8);
3272
- }
3273
3316
  // Display Pexels if no result
3274
3317
  if (data.totalRecords === 0) {
3275
3318
  _this.displayPexelsLib();
@@ -3330,6 +3373,10 @@
3330
3373
  core.Input(),
3331
3374
  __metadata("design:type", Number)
3332
3375
  ], ImagesViewComponent.prototype, "maxLengthCardShow", void 0);
3376
+ __decorate([
3377
+ core.Input(),
3378
+ __metadata("design:type", Number)
3379
+ ], ImagesViewComponent.prototype, "nbRowToShow", void 0);
3333
3380
  __decorate([
3334
3381
  core.Input(),
3335
3382
  __metadata("design:type", Object)
@@ -4970,9 +5017,9 @@
4970
5017
  exports.ɵbz = SelectFiltersPipe;
4971
5018
  exports.ɵc = UserSettingsService;
4972
5019
  exports.ɵd = ImgEventService;
4973
- exports.ɵe = DomService;
4974
- exports.ɵf = ImgTabsComponent;
4975
- exports.ɵg = AlertService;
5020
+ exports.ɵe = AlertService;
5021
+ exports.ɵf = DomService;
5022
+ exports.ɵg = ImgTabsComponent;
4976
5023
  exports.ɵh = ImgUploadComponent;
4977
5024
  exports.ɵi = easeInOut;
4978
5025
  exports.ɵj = PexelLibComponent;