@schneideress/dashboardframework 0.0.10 → 0.0.12

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 (30) hide show
  1. package/bundles/schneideress-dashboardframework.umd.js +161 -48
  2. package/bundles/schneideress-dashboardframework.umd.js.map +1 -1
  3. package/bundles/schneideress-dashboardframework.umd.min.js +1 -1
  4. package/bundles/schneideress-dashboardframework.umd.min.js.map +1 -1
  5. package/esm2015/lib/custom.notifier.options.js +46 -0
  6. package/esm2015/lib/ra-dashboard-area/ra.dashboard.area.js +95 -23
  7. package/esm2015/lib/ra-widget-container/ra.widget.container.component.js +18 -7
  8. package/esm2015/lib/ra.dashboard.module.js +5 -2
  9. package/esm2015/lib/ra.dashboard.service.js +1 -8
  10. package/esm2015/lib/ra.event.enum.js +5 -1
  11. package/esm2015/schneideress-dashboardframework.js +2 -1
  12. package/esm5/lib/custom.notifier.options.js +46 -0
  13. package/esm5/lib/ra-dashboard-area/ra.dashboard.area.js +111 -25
  14. package/esm5/lib/ra-widget-container/ra.widget.container.component.js +17 -7
  15. package/esm5/lib/ra.dashboard.module.js +5 -2
  16. package/esm5/lib/ra.dashboard.service.js +1 -14
  17. package/esm5/lib/ra.event.enum.js +5 -1
  18. package/esm5/schneideress-dashboardframework.js +2 -1
  19. package/fesm2015/schneideress-dashboardframework.js +143 -37
  20. package/fesm2015/schneideress-dashboardframework.js.map +1 -1
  21. package/fesm5/schneideress-dashboardframework.js +158 -45
  22. package/fesm5/schneideress-dashboardframework.js.map +1 -1
  23. package/lib/custom.notifier.options.d.ts +2 -0
  24. package/lib/ra-dashboard-area/ra.dashboard.area.d.ts +12 -3
  25. package/lib/ra-widget-container/ra.widget.container.component.d.ts +3 -1
  26. package/lib/ra.dashboard.service.d.ts +0 -2
  27. package/lib/ra.event.enum.d.ts +5 -1
  28. package/package.json +1 -1
  29. package/schneideress-dashboardframework.d.ts +1 -0
  30. package/schneideress-dashboardframework.metadata.json +1 -1
@@ -3,6 +3,7 @@ import { of, Subject } from 'rxjs';
3
3
  import { BaseService } from '@schneideress/ess-util';
4
4
  import { filter, map } from 'rxjs/operators';
5
5
  import { NgxUiLoaderService, NgxUiLoaderModule } from 'ngx-ui-loader';
6
+ import { NotifierService, NotifierModule } from 'angular-notifier';
6
7
  import { BrowserModule } from '@angular/platform-browser';
7
8
  import { HttpClientModule } from '@angular/common/http';
8
9
  import { CommonModule } from '@angular/common';
@@ -128,13 +129,6 @@ class RaDashboardService extends BaseService {
128
129
  */
129
130
  copyWidget(widgetInfo) {
130
131
  }
131
- /**
132
- * To Collapse current widget
133
- * @param {?} widgetInfo
134
- * @return {?}
135
- */
136
- collapse(widgetInfo) {
137
- }
138
132
  }
139
133
  RaDashboardService.decorators = [
140
134
  { type: Injectable, args: [{
@@ -251,6 +245,10 @@ const RAEvent = {
251
245
  CopyWidget: "CopyWidget",
252
246
  /**triggers when user clicks on Move widget */
253
247
  MoveWidget: "MoveWidget",
248
+ /**triggers when user raise delete widget event */
249
+ WidgetDelete: "WidgetDelete",
250
+ /** used to add widget to widgetlist when user copies a widget to current dashboard */
251
+ AddWidget: "AddWidget",
254
252
  };
255
253
  /** @enum {string} */
256
254
  const RAEventKey = {
@@ -360,11 +358,13 @@ class RADashboardArea {
360
358
  * @param {?} dashboardService
361
359
  * @param {?} ngZone
362
360
  * @param {?} ngxService
361
+ * @param {?} notifier
363
362
  */
364
- constructor(dashboardService, ngZone, ngxService) {
363
+ constructor(dashboardService, ngZone, ngxService, notifier) {
365
364
  this.dashboardService = dashboardService;
366
365
  this.ngZone = ngZone;
367
366
  this.ngxService = ngxService;
367
+ this.notifier = notifier;
368
368
  this.widgetList = Array();
369
369
  this.gridheight = 300;
370
370
  this.widgetHeight = 20;
@@ -376,6 +376,17 @@ class RADashboardArea {
376
376
  ngOnInit() {
377
377
  this.initiateGridsterConfig();
378
378
  }
379
+ /**
380
+ * @param {?} changes
381
+ * @return {?}
382
+ */
383
+ ngOnChanges(changes) {
384
+ if (this.raDashboardEventBus && this.userDashboardId && this.areaKey) {
385
+ this.initiateGridsterConfig();
386
+ this.loadWidgets(this.userDashboardId, this.areaKey);
387
+ this.inititateEventBusSubscritions();
388
+ }
389
+ }
379
390
  /**
380
391
  * To set GridsterConfig
381
392
  * @return {?}
@@ -395,36 +406,57 @@ class RADashboardArea {
395
406
  });
396
407
  }
397
408
  /**
398
- * @param {?} changes
409
+ * To initiate eventbus subsctiptions
399
410
  * @return {?}
400
411
  */
401
- ngOnChanges(changes) {
402
- if (changes.raDashboardEventBus && changes.raDashboardEventBus.currentValue != changes.raDashboardEventBus.previousValue) {
403
- this.conifgAddClick = this.raDashboardEventBus.subscribe(RAEvent.ConfigAddClick).subscribe((/**
404
- * @param {?} e
412
+ inititateEventBusSubscritions() {
413
+ this.widgetDeleteEvent = this.raDashboardEventBus.subscribe(RAEvent.WidgetDelete).subscribe((/**
414
+ * @param {?} instanceId
415
+ * @return {?}
416
+ */
417
+ (instanceId) => {
418
+ this.ngZone.run((/**
405
419
  * @return {?}
406
420
  */
407
- (e) => {
408
- this.ngZone.run((/**
409
- * @return {?}
410
- */
411
- () => {
412
- this.addWidget(e);
413
- }));
421
+ () => {
422
+ this.deleteWidget(instanceId, true);
414
423
  }));
415
- }
416
- if (this.raDashboardEventBus && this.userDashboardId && this.areaKey) {
417
- this.initiateGridsterConfig();
418
- this.loadWidgets(this.userDashboardId, this.areaKey);
419
- }
424
+ }));
425
+ this.widgetAddEvent = this.raDashboardEventBus.subscribe(RAEvent.AddWidget).subscribe((/**
426
+ * @param {?} widgetInfo
427
+ * @return {?}
428
+ */
429
+ (widgetInfo) => {
430
+ this.ngZone.run((/**
431
+ * @return {?}
432
+ */
433
+ () => {
434
+ this.copyWidget(widgetInfo);
435
+ }));
436
+ }));
437
+ this.conifgAddClick = this.raDashboardEventBus.subscribe(RAEvent.ConfigAddClick).subscribe((/**
438
+ * @param {?} e
439
+ * @return {?}
440
+ */
441
+ (e) => {
442
+ this.ngZone.run((/**
443
+ * @return {?}
444
+ */
445
+ () => {
446
+ this.addWidget(e);
447
+ }));
448
+ }));
420
449
  }
421
450
  /**
422
451
  * @return {?}
423
452
  */
424
453
  ngOnDestroy() {
425
454
  this.conifgAddClick.unsubscribe();
455
+ this.widgetAddEvent.unsubscribe();
456
+ this.widgetDeleteEvent.unsubscribe();
426
457
  }
427
458
  /**
459
+ * To update position/dimention of all widgets in the area
428
460
  * @return {?}
429
461
  */
430
462
  updateWidgets() {
@@ -497,9 +529,10 @@ class RADashboardArea {
497
529
  /**
498
530
  * To remove a widget instance from dashboard and to save info in database
499
531
  * @param {?} widgetInstanceId
532
+ * @param {?=} isalertDisabled
500
533
  * @return {?}
501
534
  */
502
- deleteWidget(widgetInstanceId) {
535
+ deleteWidget(widgetInstanceId, isalertDisabled = false) {
503
536
  /** @type {?} */
504
537
  let widget = this.widgetList.filter((/**
505
538
  * @param {?} item
@@ -511,6 +544,9 @@ class RADashboardArea {
511
544
  if (widget.length > 0) {
512
545
  this.widgetList.splice(this.widgetList.indexOf(widget[0]), 1);
513
546
  this.setAreaHeight();
547
+ if (!isalertDisabled) {
548
+ this.notifier.notify('success', "Widget (" + widget[0].widgetInfo.widgetTitle + ") deleted successfully!");
549
+ }
514
550
  }
515
551
  }
516
552
  /**
@@ -544,9 +580,26 @@ class RADashboardArea {
544
580
  gridsterItem = this.mapObjectsToGridsterItem(widget);
545
581
  this.widgetList.push(gridsterItem);
546
582
  this.setAreaHeight();
547
- this.ngxService.stop();
583
+ //this.ngxService.stop();
548
584
  }));
549
585
  }
586
+ /**
587
+ * To add widget to current widget list ,invoked from copy widget window
588
+ * @param {?} data
589
+ * @return {?}
590
+ */
591
+ copyWidget(data) {
592
+ /** @type {?} */
593
+ let gridsterItem = this.mapObjectsToGridsterItem(data);
594
+ if (this.options.api) {
595
+ gridsterItem = this.options.api.getFirstPossiblePosition(gridsterItem);
596
+ }
597
+ data.position_x = gridsterItem.x;
598
+ data.position_y = gridsterItem.y;
599
+ gridsterItem = this.mapObjectsToGridsterItem(data);
600
+ this.widgetList.push(gridsterItem);
601
+ this.setAreaHeight();
602
+ }
550
603
  /**
551
604
  * To map IwidgetInfo object to gridsterItem
552
605
  * @param {?} widget
@@ -613,7 +666,7 @@ class RADashboardArea {
613
666
  RADashboardArea.decorators = [
614
667
  { type: Component, args: [{
615
668
  selector: 'ra-dashboard-area',
616
- template: "<div #gridWrapper class=\"wrap gridster\" [style.height.px]=\"gridheight\">\r\n<!-- <div #gridWrapper class=\"wrap gridster\"> -->\r\n <gridster [options]=\"options\" style=\"height:100%;\">\r\n <gridster-item [item]=\"item\" *ngFor=\"let item of widgetList\">\r\n <ra-widget-container [app-config]=\"appConfig\" [event-bus]=\"raDashboardEventBus\" (widgetDeleted)=\"deleteWidget($event)\" [data]=\"item\"\r\n [global-filter]=\"globalFilter\" [widget-instance-id]=\"item.widgetInstanceId\"></ra-widget-container>\r\n </gridster-item>\r\n </gridster>\r\n</div>\r\n\r\n",
669
+ template: "<div #gridWrapper class=\"wrap gridster\" [style.height.px]=\"gridheight\">\r\n<!-- <div #gridWrapper class=\"wrap gridster\"> -->\r\n <gridster [options]=\"options\" style=\"height:100%;\">\r\n <gridster-item [item]=\"item\" *ngFor=\"let item of widgetList\">\r\n <ra-widget-container [app-config]=\"appConfig\" [event-bus]=\"raDashboardEventBus\" (widgetDeleted)=\"deleteWidget($event)\" [data]=\"item\"\r\n [global-filter]=\"globalFilter\" [widget-instance-id]=\"item.widgetInstanceId\"></ra-widget-container>\r\n </gridster-item>\r\n </gridster>\r\n <notifier-container></notifier-container>\r\n</div>\r\n\r\n",
617
670
  styles: ["gridster{width:inherit;resize:height;display:flex;min-height:600px}gridster-item{border:1px solid #ccc;background:#fff!important}.dvheader{width:100%;height:35px;background:#000;color:#fff;padding:7px 3px 5px 6px;text-transform:uppercase}"]
618
671
  }] }
619
672
  ];
@@ -621,7 +674,8 @@ RADashboardArea.decorators = [
621
674
  RADashboardArea.ctorParameters = () => [
622
675
  { type: RaDashboardService },
623
676
  { type: NgZone },
624
- { type: NgxUiLoaderService }
677
+ { type: NgxUiLoaderService },
678
+ { type: NotifierService }
625
679
  ];
626
680
  RADashboardArea.propDecorators = {
627
681
  userDashboardId: [{ type: Input, args: ['user-dashboard-id',] }],
@@ -641,10 +695,12 @@ class RAWidgetContainer {
641
695
  /**
642
696
  * @param {?} dashboardService
643
697
  * @param {?} ngxService
698
+ * @param {?} notifier
644
699
  */
645
- constructor(dashboardService, ngxService) {
700
+ constructor(dashboardService, ngxService, notifier) {
646
701
  this.dashboardService = dashboardService;
647
702
  this.ngxService = ngxService;
703
+ this.notifier = notifier;
648
704
  this.isIEOrEdge = /msie\s|trident\/|edge\//i.test(window.navigator.userAgent);
649
705
  this.widgetDeleted = new EventEmitter();
650
706
  }
@@ -704,9 +760,12 @@ class RAWidgetContainer {
704
760
  */
705
761
  status => {
706
762
  widgetContainerContext.ngxService.stop();
707
- {
763
+ if (status) {
708
764
  widgetContainerContext.widgetDeleted.emit(this.data.widgetInfo.widgetInstanceId);
709
765
  }
766
+ else {
767
+ widgetContainerContext.notifier.notify('error', "Failed to remove widget (" + this.data.widgetInfo.widgetTitle + ")!");
768
+ }
710
769
  }));
711
770
  }
712
771
  /**
@@ -714,7 +773,6 @@ class RAWidgetContainer {
714
773
  * @return {?}
715
774
  */
716
775
  moveWidget() {
717
- console.log('in move widget');
718
776
  this.raDashboardEventBus.publish(RAEvent.MoveWidget, this.data.widgetInfo);
719
777
  // this.dashboardService.moveWidget(widgetInfo);
720
778
  }
@@ -796,14 +854,15 @@ class RAWidgetContainer {
796
854
  RAWidgetContainer.decorators = [
797
855
  { type: Component, args: [{
798
856
  selector: 'ra-widget-container',
799
- template: "<div class=\"wc-wrapper\">\r\n <div class=\"wcheader\">\r\n <div class=\"col-md-12 wc-mover\">\r\n <div class=\"row\">\r\n <div class=\"col-md-11 float-left\" style=\"width:96%;\">{{data.widgetInfo.title?data.widgetInfo.title:\"Title\"}}\r\n </div>\r\n <div class=\"col-md-1\">\r\n <div class=\"float-right\">\r\n <div class=\"dropdown\">\r\n <div class=\"dropbtn\"> <i class=\"fal fa-cog\"></i></div>\r\n <div class=\"dropdown-content\">\r\n <a (click)=\"editWidget()\">Edit</a>\r\n <a (click)=\"copyWidget()\">Copy</a>\r\n <a (click)=\"moveWidget()\">Move</a> \r\n <hr class=\"hr\">\r\n <a (click)=\"deleteWidget()\">Delete</a>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"wcBody\">\r\n <div class=\"wcBodyBorder\" #ctlWidget></div>\r\n </div>\r\n</div>\r\n",
800
- styles: [".wcheader{width:100%;height:26px;background:#fff;color:#3dcd58;padding:7px 7px 0 6px;font-family:\"Arial Rounded MT\";border-bottom:1px solid;border-color:#fff;font-size:16px}.wc-mover{cursor:all-scroll}.wcBody{padding:8px}.wcBodyBorder{border:1px dashed #e6e2e2}.sp_icon{float:left;margin:0 15% 0 0}.dropbtn{cursor:pointer;color:#42b4e6}.dropdown{display:none;position:relative}.dropdown hr{margin:0!important}.dropdown-content{display:none;position:absolute;right:0;background-color:#f9f9f9;min-width:100px;box-shadow:0 8px 16px 8px rgba(0,0,0,.2);z-index:1;font-size:12px;font-family:\"Arial Rounded MT\"}.dropdown-content a{color:#000;padding:5px 16px;text-decoration:none;display:block;cursor:pointer}.dropdown-content a:hover{background-color:#f1f1f1}.dropdown:hover .dropdown-content,.wc-wrapper:hover .dropdown{display:block}.dropdown:hover .dropbtn{color:#2b7797}.hr{border:0;border-top:1px solid rgba(0,0,0,.1)}"]
857
+ template: "<div class=\"wc-wrapper\">\r\n <div class=\"wcheader\">\r\n <div class=\"col-md-12 wc-mover\">\r\n <div class=\"row\">\r\n <div class=\"col-md-11 float-left\" style=\"width:96%;\">{{data.widgetInfo.title?data.widgetInfo.title:\"Title\"}}\r\n </div>\r\n <div class=\"col-md-1\">\r\n <div class=\"float-right\">\r\n <div class=\"dropdown\">\r\n <div class=\"dropbtn gearIcon\"> <i class=\"fal fa-cog\"></i></div>\r\n <div class=\"dropdown-content\">\r\n <a (click)=\"editWidget()\">Edit</a>\r\n <a (click)=\"copyWidget()\">Copy</a>\r\n <a (click)=\"moveWidget()\">Move</a> \r\n <hr class=\"hr\">\r\n <a (click)=\"deleteWidget()\">Delete</a>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"wcBody\">\r\n <div class=\"wcBodyBorder\" #ctlWidget></div>\r\n </div>\r\n</div>\r\n",
858
+ styles: [".wcheader{width:100%;height:26px;background:#fff;color:#3dcd58;padding:7px 7px 0 6px;font-family:\"Arial Rounded MT\";border-bottom:1px solid;border-color:#fff;font-size:16px}.wc-mover{cursor:all-scroll}.wcBody{padding:8px}.wcBodyBorder{border:1px dashed #e6e2e2}.sp_icon{float:left;margin:0 15% 0 0}.dropbtn{cursor:pointer;color:#42b4e6}.dropdown{display:none;position:relative}.dropdown hr{margin:0!important}.dropdown-content{display:none;position:absolute;right:0;background-color:#f9f9f9;min-width:100px;box-shadow:0 8px 16px 8px rgba(0,0,0,.2);z-index:1;font-size:12px;font-family:\"Arial Rounded MT\"}.dropdown-content a{color:#000;padding:5px 16px;text-decoration:none;display:block;cursor:pointer}.dropdown-content a:hover{background-color:#f1f1f1}.dropdown:hover .dropdown-content,.wc-wrapper:hover .dropdown{display:block}.dropdown:hover .dropbtn{color:#2b7797}.gearIcon{color:#42b4e6}.hr{border:0;border-top:1px solid rgba(0,0,0,.1)}"]
801
859
  }] }
802
860
  ];
803
861
  /** @nocollapse */
804
862
  RAWidgetContainer.ctorParameters = () => [
805
863
  { type: RaDashboardService },
806
- { type: NgxUiLoaderService }
864
+ { type: NgxUiLoaderService },
865
+ { type: NotifierService }
807
866
  ];
808
867
  RAWidgetContainer.propDecorators = {
809
868
  ctlWidget: [{ type: ViewChild, args: ['ctlWidget', { static: false },] }],
@@ -815,6 +874,52 @@ RAWidgetContainer.propDecorators = {
815
874
  widgetDeleted: [{ type: Output }]
816
875
  };
817
876
 
877
+ /**
878
+ * @fileoverview added by tsickle
879
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
880
+ */
881
+ /** @type {?} */
882
+ const customNotifierOptions = {
883
+ position: {
884
+ horizontal: {
885
+ position: 'right',
886
+ distance: 12
887
+ },
888
+ vertical: {
889
+ position: 'top',
890
+ distance: 12,
891
+ gap: 10
892
+ }
893
+ },
894
+ theme: 'material',
895
+ behaviour: {
896
+ autoHide: 5000,
897
+ onClick: 'hide',
898
+ onMouseover: 'pauseAutoHide',
899
+ showDismissButton: true,
900
+ stacking: 4
901
+ },
902
+ animations: {
903
+ enabled: true,
904
+ show: {
905
+ preset: 'slide',
906
+ speed: 300,
907
+ easing: 'ease'
908
+ },
909
+ hide: {
910
+ preset: 'fade',
911
+ speed: 300,
912
+ easing: 'ease',
913
+ offset: 50
914
+ },
915
+ shift: {
916
+ speed: 300,
917
+ easing: 'ease'
918
+ },
919
+ overlap: 150
920
+ }
921
+ };
922
+
818
923
  /**
819
924
  * @fileoverview added by tsickle
820
925
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -4759,7 +4864,8 @@ DashboardFrameworkModule.decorators = [
4759
4864
  BrowserModule,
4760
4865
  GridsterModule,
4761
4866
  HttpClientModule,
4762
- NgxUiLoaderModule
4867
+ NgxUiLoaderModule,
4868
+ NotifierModule.withConfig(customNotifierOptions)
4763
4869
  ],
4764
4870
  exports: [
4765
4871
  RADashboardArea
@@ -4829,5 +4935,5 @@ RaBaseDashboardFilter.propDecorators = {
4829
4935
  getAllFilterConfig: [{ type: Input }]
4830
4936
  };
4831
4937
 
4832
- export { DashboardFrameworkModule, RADashboardArea, RADashboardEventBus, RAEvent, RAEventKey, RAWidgetContainer, RaBaseDashboardFilter, RaBaseDashboardTemplate, RaDashboardService, GridsterModule as ɵa, GridsterComponent as ɵb, GridsterItemComponent as ɵc, GridsterPreviewComponent as ɵd };
4938
+ export { DashboardFrameworkModule, RADashboardArea, RADashboardEventBus, RAEvent, RAEventKey, RAWidgetContainer, RaBaseDashboardFilter, RaBaseDashboardTemplate, RaDashboardService, GridsterModule as ɵa, GridsterComponent as ɵb, GridsterItemComponent as ɵc, GridsterPreviewComponent as ɵd, customNotifierOptions as ɵe };
4833
4939
  //# sourceMappingURL=schneideress-dashboardframework.js.map