@schneideress/dashboardframework 0.0.11 → 0.0.13

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.
@@ -395,6 +395,10 @@
395
395
  CopyWidget: "CopyWidget",
396
396
  /**triggers when user clicks on Move widget */
397
397
  MoveWidget: "MoveWidget",
398
+ /**triggers when user raise delete widget event */
399
+ WidgetDelete: "WidgetDelete",
400
+ /** used to add widget to widgetlist when user copies a widget to current dashboard */
401
+ AddWidget: "AddWidget",
398
402
  };
399
403
  /** @enum {string} */
400
404
  var RAEventKey = {
@@ -519,6 +523,21 @@
519
523
  function () {
520
524
  this.initiateGridsterConfig();
521
525
  };
526
+ /**
527
+ * @param {?} changes
528
+ * @return {?}
529
+ */
530
+ RADashboardArea.prototype.ngOnChanges = /**
531
+ * @param {?} changes
532
+ * @return {?}
533
+ */
534
+ function (changes) {
535
+ if (this.raDashboardEventBus && this.userDashboardId && this.areaKey) {
536
+ this.initiateGridsterConfig();
537
+ this.loadWidgets(this.userDashboardId, this.areaKey);
538
+ this.inititateEventBusSubscritions();
539
+ }
540
+ };
522
541
  /**To set GridsterConfig */
523
542
  /**
524
543
  * To set GridsterConfig
@@ -542,34 +561,53 @@
542
561
  areaContext.updateWidgets();
543
562
  });
544
563
  };
564
+ /** To initiate eventbus subsctiptions */
545
565
  /**
546
- * @param {?} changes
566
+ * To initiate eventbus subsctiptions
547
567
  * @return {?}
548
568
  */
549
- RADashboardArea.prototype.ngOnChanges = /**
550
- * @param {?} changes
569
+ RADashboardArea.prototype.inititateEventBusSubscritions = /**
570
+ * To initiate eventbus subsctiptions
551
571
  * @return {?}
552
572
  */
553
- function (changes) {
573
+ function () {
554
574
  var _this = this;
555
- if (changes.raDashboardEventBus && changes.raDashboardEventBus.currentValue != changes.raDashboardEventBus.previousValue) {
556
- this.conifgAddClick = this.raDashboardEventBus.subscribe(RAEvent.ConfigAddClick).subscribe((/**
557
- * @param {?} e
575
+ this.widgetDeleteEvent = this.raDashboardEventBus.subscribe(RAEvent.WidgetDelete).subscribe((/**
576
+ * @param {?} instanceId
577
+ * @return {?}
578
+ */
579
+ function (instanceId) {
580
+ _this.ngZone.run((/**
558
581
  * @return {?}
559
582
  */
560
- function (e) {
561
- _this.ngZone.run((/**
562
- * @return {?}
563
- */
564
- function () {
565
- _this.addWidget(e);
566
- }));
583
+ function () {
584
+ _this.deleteWidget(instanceId, true);
567
585
  }));
568
- }
569
- if (this.raDashboardEventBus && this.userDashboardId && this.areaKey) {
570
- this.initiateGridsterConfig();
571
- this.loadWidgets(this.userDashboardId, this.areaKey);
572
- }
586
+ }));
587
+ this.widgetAddEvent = this.raDashboardEventBus.subscribe(RAEvent.AddWidget).subscribe((/**
588
+ * @param {?} widgetInfo
589
+ * @return {?}
590
+ */
591
+ function (widgetInfo) {
592
+ _this.ngZone.run((/**
593
+ * @return {?}
594
+ */
595
+ function () {
596
+ _this.copyWidget(widgetInfo);
597
+ }));
598
+ }));
599
+ this.conifgAddClick = this.raDashboardEventBus.subscribe(RAEvent.ConfigAddClick).subscribe((/**
600
+ * @param {?} e
601
+ * @return {?}
602
+ */
603
+ function (e) {
604
+ _this.ngZone.run((/**
605
+ * @return {?}
606
+ */
607
+ function () {
608
+ _this.addWidget(e);
609
+ }));
610
+ }));
573
611
  };
574
612
  /**
575
613
  * @return {?}
@@ -579,11 +617,16 @@
579
617
  */
580
618
  function () {
581
619
  this.conifgAddClick.unsubscribe();
620
+ this.widgetAddEvent.unsubscribe();
621
+ this.widgetDeleteEvent.unsubscribe();
582
622
  };
623
+ /**To update position/dimention of all widgets in the area */
583
624
  /**
625
+ * To update position/dimention of all widgets in the area
584
626
  * @return {?}
585
627
  */
586
628
  RADashboardArea.prototype.updateWidgets = /**
629
+ * To update position/dimention of all widgets in the area
587
630
  * @return {?}
588
631
  */
589
632
  function () {
@@ -670,14 +713,17 @@
670
713
  /**
671
714
  * To remove a widget instance from dashboard and to save info in database
672
715
  * @param {?} widgetInstanceId
716
+ * @param {?=} isalertDisabled
673
717
  * @return {?}
674
718
  */
675
719
  RADashboardArea.prototype.deleteWidget = /**
676
720
  * To remove a widget instance from dashboard and to save info in database
677
721
  * @param {?} widgetInstanceId
722
+ * @param {?=} isalertDisabled
678
723
  * @return {?}
679
724
  */
680
- function (widgetInstanceId) {
725
+ function (widgetInstanceId, isalertDisabled) {
726
+ if (isalertDisabled === void 0) { isalertDisabled = false; }
681
727
  /** @type {?} */
682
728
  var widget = this.widgetList.filter((/**
683
729
  * @param {?} item
@@ -689,7 +735,9 @@
689
735
  if (widget.length > 0) {
690
736
  this.widgetList.splice(this.widgetList.indexOf(widget[0]), 1);
691
737
  this.setAreaHeight();
692
- this.notifier.notify('success', "Widget (" + widget[0].widgetInfo.widgetTitle + ") deleted successfully!");
738
+ if (!isalertDisabled) {
739
+ this.notifier.notify('success', "Widget (" + widget[0].widgetInfo.widgetTitle + ") deleted successfully!");
740
+ }
693
741
  }
694
742
  };
695
743
  /**To add widget instance to the database with the next available position and to make changes in
@@ -736,6 +784,29 @@
736
784
  //this.ngxService.stop();
737
785
  }));
738
786
  };
787
+ /** To add widget to current widget list ,invoked from copy widget window*/
788
+ /**
789
+ * To add widget to current widget list ,invoked from copy widget window
790
+ * @param {?} data
791
+ * @return {?}
792
+ */
793
+ RADashboardArea.prototype.copyWidget = /**
794
+ * To add widget to current widget list ,invoked from copy widget window
795
+ * @param {?} data
796
+ * @return {?}
797
+ */
798
+ function (data) {
799
+ /** @type {?} */
800
+ var gridsterItem = this.mapObjectsToGridsterItem(data);
801
+ if (this.options.api) {
802
+ gridsterItem = this.options.api.getFirstPossiblePosition(gridsterItem);
803
+ }
804
+ data.position_x = gridsterItem.x;
805
+ data.position_y = gridsterItem.y;
806
+ gridsterItem = this.mapObjectsToGridsterItem(data);
807
+ this.widgetList.push(gridsterItem);
808
+ this.setAreaHeight();
809
+ };
739
810
  /**To map IwidgetInfo object to gridsterItem */
740
811
  /**
741
812
  * To map IwidgetInfo object to gridsterItem
@@ -822,7 +893,7 @@
822
893
  { type: core.Component, args: [{
823
894
  selector: 'ra-dashboard-area',
824
895
  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",
825
- 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}"]
896
+ styles: ["gridster{width:inherit;resize:height;display:flex;min-height:600px}gridster-item{background:#fff!important}.dvheader{width:100%;height:35px;background:#000;color:#fff;padding:7px 3px 5px 6px;text-transform:uppercase}"]
826
897
  }] }
827
898
  ];
828
899
  /** @nocollapse */