@provoly/dashboard 1.4.48 → 1.4.50
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.
- package/esm2022/lib/core/components/snackbar/snack.interface.mjs +1 -1
- package/esm2022/lib/core/components/snackbar/snackbar/snackbar.component.mjs +48 -12
- package/esm2022/lib/core/components/snackbar/snackbar.service.mjs +50 -12
- package/esm2022/widgets/widget-map/component/widget-map.component.mjs +20 -1
- package/fesm2022/provoly-dashboard-widgets-widget-map.mjs +19 -0
- package/fesm2022/provoly-dashboard-widgets-widget-map.mjs.map +1 -1
- package/fesm2022/provoly-dashboard.mjs +92 -20
- package/fesm2022/provoly-dashboard.mjs.map +1 -1
- package/lib/core/components/snackbar/snack.interface.d.ts +2 -1
- package/lib/core/components/snackbar/snackbar/snackbar.component.d.ts +16 -3
- package/lib/core/components/snackbar/snackbar.service.d.ts +9 -3
- package/package.json +43 -43
- package/styles-theme/components-theme/_m-snackbar.theme.scss +5 -0
- package/widgets/widget-map/component/widget-map.component.d.ts +2 -0
|
@@ -2705,13 +2705,25 @@ class PrySnackbarComponent {
|
|
|
2705
2705
|
this._data = message;
|
|
2706
2706
|
this.cdRef.detectChanges();
|
|
2707
2707
|
}
|
|
2708
|
-
|
|
2708
|
+
set listIndex(listIndex) {
|
|
2709
|
+
if (!!listIndex || listIndex === 0) {
|
|
2710
|
+
this._listIndex = listIndex;
|
|
2711
|
+
}
|
|
2712
|
+
this.getStyle();
|
|
2713
|
+
}
|
|
2714
|
+
get listIndex() {
|
|
2715
|
+
return this._listIndex;
|
|
2716
|
+
}
|
|
2717
|
+
constructor(cdRef, snackService, router) {
|
|
2709
2718
|
this.cdRef = cdRef;
|
|
2719
|
+
this.snackService = snackService;
|
|
2720
|
+
this.router = router;
|
|
2710
2721
|
this._data = { message: '', action: undefined, type: 'info', timeout: 3000 };
|
|
2711
|
-
this.listIndex = 0;
|
|
2712
2722
|
this.transformOptions = 'translate3d(-50%, 100%, 0px)';
|
|
2713
2723
|
this.transitionOptions = '150ms cubic-bezier(0, 0, 0.2, 1)';
|
|
2714
2724
|
this.hiddenFromAction = false;
|
|
2725
|
+
this._listIndex = 0;
|
|
2726
|
+
this.snackStyle = { top: '' };
|
|
2715
2727
|
}
|
|
2716
2728
|
get data() {
|
|
2717
2729
|
return this._data;
|
|
@@ -2719,12 +2731,25 @@ class PrySnackbarComponent {
|
|
|
2719
2731
|
get typeClass() {
|
|
2720
2732
|
return { ['-' + this.data.type]: true };
|
|
2721
2733
|
}
|
|
2734
|
+
getStyle() {
|
|
2735
|
+
if (this.data.type === 'notif') {
|
|
2736
|
+
this.snackStyle = {
|
|
2737
|
+
top: (this.listIndex === 0 ? 60 : this.listIndex * 60 + 60) + 'px'
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2740
|
+
else {
|
|
2741
|
+
this.snackStyle = {
|
|
2742
|
+
bottom: this.listIndex * 60 + 'px'
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2722
2746
|
get icon() {
|
|
2723
2747
|
const iconsDefs = {
|
|
2724
2748
|
info: 'information-point',
|
|
2725
2749
|
success: 'check',
|
|
2726
2750
|
warning: 'warning',
|
|
2727
|
-
error: 'close'
|
|
2751
|
+
error: 'close',
|
|
2752
|
+
notif: 'information-point'
|
|
2728
2753
|
};
|
|
2729
2754
|
return iconsDefs[this.data.type];
|
|
2730
2755
|
}
|
|
@@ -2734,8 +2759,17 @@ class PrySnackbarComponent {
|
|
|
2734
2759
|
hide() {
|
|
2735
2760
|
this.hiddenFromAction = true;
|
|
2736
2761
|
}
|
|
2737
|
-
|
|
2738
|
-
|
|
2762
|
+
openEvenement(data) {
|
|
2763
|
+
this.router.navigate([]).then(() => {
|
|
2764
|
+
const url = this.router.serializeUrl(this.router.createUrlTree(['/', 'journal', data.message.padStart(6, '0')]));
|
|
2765
|
+
window.open(url, '_blank');
|
|
2766
|
+
});
|
|
2767
|
+
}
|
|
2768
|
+
closeNotif(data) {
|
|
2769
|
+
this.snackService.closeNotif(data);
|
|
2770
|
+
}
|
|
2771
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: PrySnackbarComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: PrySnackbarService }, { token: i2.Router }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2772
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.7", type: PrySnackbarComponent, selector: "pry-snackbar", inputs: { data: "data", actionClicked: "actionClicked", listIndex: "listIndex" }, ngImport: i0, template: "@if (!hiddenFromAction) {\n @if (data.type === 'notif') {\n <div\n (click)=\"openEvenement(data)\"\n class=\"m-snackbar m-snackbar-notif\"\n [@panelState]=\"{ value: 'visible', params: { transform: transformOptions, transition: transitionOptions } }\"\n [style]=\"snackStyle\"\n >\n <div class=\"m-snackbar__content\">\n <p class=\"a-p\">{{ data.message }}</p>\n <pry-icon (click)=\"closeNotif(data)\" class=\"notif-erase\" iconSvg=\"close\" [width]=\"18\" [height]=\"18\"> </pry-icon>\n </div>\n </div>\n } @else {\n <div\n class=\"m-snackbar -bottom\"\n [ngClass]=\"typeClass\"\n [@panelState]=\"{ value: 'visible', params: { transform: transformOptions, transition: transitionOptions } }\"\n [style]=\"snackStyle\"\n >\n <div class=\"m-snackbar__content\">\n <pry-icon [iconSvg]=\"icon\"></pry-icon>\n <p class=\"a-p\">{{ data.message }}</p>\n @if (!!data.action) {\n <button class=\"m-snackbar__action\" (click)=\"actionClick()\">{{ data.action }}</button>\n }\n </div>\n </div>\n }\n}\n", dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: PryIconComponent, selector: "pry-icon", inputs: ["color", "iconSvg", "animation", "iconImage", "alt", "width", "height", "classes"] }], animations: [
|
|
2739
2773
|
trigger('panelState', [
|
|
2740
2774
|
transition('void => visible', [useAnimation(showAnimation)]),
|
|
2741
2775
|
transition('visible => void', [useAnimation(hideAnimation)])
|
|
@@ -2749,13 +2783,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImpor
|
|
|
2749
2783
|
transition('void => visible', [useAnimation(showAnimation)]),
|
|
2750
2784
|
transition('visible => void', [useAnimation(hideAnimation)])
|
|
2751
2785
|
])
|
|
2752
|
-
], template: "@if (!hiddenFromAction) {\n <div\n class=\"m-snackbar -bottom\"\n
|
|
2753
|
-
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { data: [{
|
|
2754
|
-
type: Input
|
|
2755
|
-
}], listIndex: [{
|
|
2786
|
+
], template: "@if (!hiddenFromAction) {\n @if (data.type === 'notif') {\n <div\n (click)=\"openEvenement(data)\"\n class=\"m-snackbar m-snackbar-notif\"\n [@panelState]=\"{ value: 'visible', params: { transform: transformOptions, transition: transitionOptions } }\"\n [style]=\"snackStyle\"\n >\n <div class=\"m-snackbar__content\">\n <p class=\"a-p\">{{ data.message }}</p>\n <pry-icon (click)=\"closeNotif(data)\" class=\"notif-erase\" iconSvg=\"close\" [width]=\"18\" [height]=\"18\"> </pry-icon>\n </div>\n </div>\n } @else {\n <div\n class=\"m-snackbar -bottom\"\n [ngClass]=\"typeClass\"\n [@panelState]=\"{ value: 'visible', params: { transform: transformOptions, transition: transitionOptions } }\"\n [style]=\"snackStyle\"\n >\n <div class=\"m-snackbar__content\">\n <pry-icon [iconSvg]=\"icon\"></pry-icon>\n <p class=\"a-p\">{{ data.message }}</p>\n @if (!!data.action) {\n <button class=\"m-snackbar__action\" (click)=\"actionClick()\">{{ data.action }}</button>\n }\n </div>\n </div>\n }\n}\n" }]
|
|
2787
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: PrySnackbarService }, { type: i2.Router }], propDecorators: { data: [{
|
|
2756
2788
|
type: Input
|
|
2757
2789
|
}], actionClicked: [{
|
|
2758
2790
|
type: Input
|
|
2791
|
+
}], listIndex: [{
|
|
2792
|
+
type: Input
|
|
2759
2793
|
}] } });
|
|
2760
2794
|
|
|
2761
2795
|
const DEFAULT_MSG_TIMEOUT = 3000;
|
|
@@ -2767,6 +2801,7 @@ class PrySnackbarService {
|
|
|
2767
2801
|
this.overlay = overlay;
|
|
2768
2802
|
this.translate = translate;
|
|
2769
2803
|
this.messageEvents$ = new Subject();
|
|
2804
|
+
this.notifRef = [];
|
|
2770
2805
|
// Allows to access snackbar from javascript, for example to manage Vega errors
|
|
2771
2806
|
document.addEventListener(PRY_CUSTOMEVENT_TYPE, (e) => {
|
|
2772
2807
|
const pryMessage = e.detail;
|
|
@@ -2784,26 +2819,63 @@ class PrySnackbarService {
|
|
|
2784
2819
|
dispatchOpenEvent(message) {
|
|
2785
2820
|
document.dispatchEvent(new CustomEvent(PRY_CUSTOMEVENT_TYPE, { detail: message }));
|
|
2786
2821
|
}
|
|
2822
|
+
closeNotif(message) {
|
|
2823
|
+
const notifIndex = this.notifRef.findIndex((notif) => notif.componentRef.instance.data.id === message.id);
|
|
2824
|
+
const elementToRemove = this.notifRef.splice(notifIndex, 1).shift();
|
|
2825
|
+
elementToRemove.componentRef.instance.hiddenFromAction = true;
|
|
2826
|
+
elementToRemove.componentRef.instance.actionClicked.complete();
|
|
2827
|
+
elementToRemove.overlayRef.dispose();
|
|
2828
|
+
elementToRemove.componentRef.destroy();
|
|
2829
|
+
this.notifRef.forEach((notifRef, index) => {
|
|
2830
|
+
notifRef.componentRef.instance.listIndex = index;
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2787
2833
|
notMitigatedOpen(message) {
|
|
2788
|
-
|
|
2834
|
+
const overlayRef = this.overlay.create(new OverlayConfig({
|
|
2789
2835
|
hasBackdrop: false
|
|
2790
2836
|
}));
|
|
2791
2837
|
const componentPortal = new ComponentPortal(PrySnackbarComponent, this.rootViewContainer);
|
|
2792
|
-
const component =
|
|
2838
|
+
const component = overlayRef.attach(componentPortal);
|
|
2793
2839
|
component.instance.data = message;
|
|
2794
|
-
component.instance.listIndex = PrySnackbarService.count++;
|
|
2795
2840
|
component.instance.actionClicked = new Subject();
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2841
|
+
if (message.type === 'notif') {
|
|
2842
|
+
if (this.notifRef.length < 5) {
|
|
2843
|
+
this.notifRef.unshift({ componentRef: component, overlayRef });
|
|
2844
|
+
this.notifRef.forEach((notifRef, index) => {
|
|
2845
|
+
notifRef.componentRef.instance.listIndex = index;
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
else if (this.notifRef.length === 5) {
|
|
2849
|
+
const olderComponent = this.notifRef.pop();
|
|
2850
|
+
olderComponent.componentRef.instance.hiddenFromAction = true;
|
|
2851
|
+
olderComponent.componentRef.instance.actionClicked.complete();
|
|
2852
|
+
olderComponent.overlayRef.dispose();
|
|
2853
|
+
olderComponent.componentRef.destroy();
|
|
2854
|
+
this.notifRef.unshift({ componentRef: component, overlayRef });
|
|
2855
|
+
this.notifRef.forEach((notifRef, index) => {
|
|
2856
|
+
notifRef.componentRef.instance.listIndex = index;
|
|
2857
|
+
});
|
|
2858
|
+
}
|
|
2800
2859
|
setTimeout(() => {
|
|
2801
|
-
/* then clean by removing it */
|
|
2802
2860
|
component.instance.actionClicked.complete();
|
|
2803
|
-
|
|
2861
|
+
overlayRef?.dispose();
|
|
2804
2862
|
component.destroy();
|
|
2805
|
-
},
|
|
2806
|
-
}
|
|
2863
|
+
}, 10000);
|
|
2864
|
+
}
|
|
2865
|
+
else {
|
|
2866
|
+
component.instance.listIndex = PrySnackbarService.count++;
|
|
2867
|
+
setTimeout(() => {
|
|
2868
|
+
/* First hide component so it uses animation */
|
|
2869
|
+
component.instance.hiddenFromAction = true;
|
|
2870
|
+
PrySnackbarService.count--;
|
|
2871
|
+
setTimeout(() => {
|
|
2872
|
+
/* then clean by removing it */
|
|
2873
|
+
component.instance.actionClicked.complete();
|
|
2874
|
+
overlayRef?.dispose();
|
|
2875
|
+
component.destroy();
|
|
2876
|
+
}, DELAY_FOR_HIDE);
|
|
2877
|
+
}, message.timeout ?? DEFAULT_MSG_TIMEOUT);
|
|
2878
|
+
}
|
|
2807
2879
|
return component.instance.actionClicked;
|
|
2808
2880
|
}
|
|
2809
2881
|
open(message) {
|