@schneideress/dashboardframework 0.0.2 → 0.0.4

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.
@@ -16,54 +16,6 @@ var RaDashboardService = /** @class */ (function (_super) {
16
16
  function RaDashboardService(injector) {
17
17
  var _this = _super.call(this, injector, '') || this;
18
18
  _this.loadedScripts = [];
19
- _this.widgets = [
20
- {
21
- dashboardId: '1',
22
- id: '1',
23
- customTag: 'ra-test-widget',
24
- scriptUrl: './assets/ra-test-widget.bundle.js',
25
- title: 'Test Widget',
26
- widgetInstanceId: 1,
27
- widgetId: 1,
28
- position_x: 0,
29
- position_y: 0,
30
- width: 50,
31
- height: 20,
32
- widgetConfigInfo: {
33
- scriptPath: "./assets/ra-test-widget-config.bundle.js",
34
- configControlTag: "ra-test-widget-config",
35
- config: { country: 'All' }
36
- },
37
- widgetName: '',
38
- widgetTitle: 'Test Widget',
39
- dashboardAreaId: 1,
40
- dashboardAreaKey: '',
41
- dashboardName: ''
42
- },
43
- {
44
- dashboardId: '2',
45
- id: '2',
46
- customTag: 'ra-test-widget',
47
- scriptUrl: './assets/ra-test-widget.bundle.js',
48
- title: 'Test Widget',
49
- widgetInstanceId: 2,
50
- dashboardAreaKey: '',
51
- widgetId: 1,
52
- position_x: 0,
53
- position_y: 0,
54
- width: 50,
55
- height: 20,
56
- widgetConfigInfo: {
57
- scriptPath: "./assets/ra-test-widget-config.bundle.js",
58
- configControlTag: "ra-test-widget-config",
59
- config: { country: 'All' }
60
- },
61
- widgetName: '',
62
- widgetTitle: 'Test Widget',
63
- dashboardAreaId: 1,
64
- dashboardName: ''
65
- },
66
- ];
67
19
  return _this;
68
20
  }
69
21
  /*
@@ -130,32 +82,31 @@ var RaDashboardService = /** @class */ (function (_super) {
130
82
  return this.post(url, widgetInfo);
131
83
  };
132
84
  /**
133
- * @param {?} widgetInfo
85
+ * @param {?} widgetList
86
+ * @param {?} appConfig
134
87
  * @return {?}
135
88
  */
136
- RaDashboardService.prototype.getWidgetConfigInfo = /**
137
- * @param {?} widgetInfo
89
+ RaDashboardService.prototype.updateWidgets = /**
90
+ * @param {?} widgetList
91
+ * @param {?} appConfig
138
92
  * @return {?}
139
93
  */
140
- function (widgetInfo) {
141
- return of();
94
+ function (widgetList, appConfig) {
95
+ this.baseUrl = appConfig.apiBaseUrl;
96
+ /** @type {?} */
97
+ var url = 'widget/UpdateAreaWidgets';
98
+ return this.post(url, widgetList);
142
99
  };
143
100
  /**
144
- * @param {?} widgetId
101
+ * @param {?} widgetInfo
145
102
  * @return {?}
146
103
  */
147
- RaDashboardService.prototype.getWidgetById = /**
148
- * @param {?} widgetId
104
+ RaDashboardService.prototype.getWidgetConfigInfo = /**
105
+ * @param {?} widgetInfo
149
106
  * @return {?}
150
107
  */
151
- function (widgetId) {
152
- return this.widgets.filter((/**
153
- * @param {?} t
154
- * @return {?}
155
- */
156
- function (t) {
157
- t.widgetId == widgetId;
158
- }));
108
+ function (widgetInfo) {
109
+ return of();
159
110
  };
160
111
  /*
161
112
  * To update the configuration of a widget.
@@ -555,7 +506,9 @@ var RADashboardArea = /** @class */ (function () {
555
506
  * @return {?}
556
507
  */
557
508
  function (item) {
509
+ console.log('in change call back');
558
510
  areaContext.setAreaHeight();
511
+ areaContext.updateWidgets();
559
512
  });
560
513
  };
561
514
  /**
@@ -595,6 +548,22 @@ var RADashboardArea = /** @class */ (function () {
595
548
  function () {
596
549
  this.conifgAddClick.unsubscribe();
597
550
  };
551
+ /**
552
+ * @return {?}
553
+ */
554
+ RADashboardArea.prototype.updateWidgets = /**
555
+ * @return {?}
556
+ */
557
+ function () {
558
+ console.log('in update widgets');
559
+ this.dashboardService.updateWidgets(this.mapGridsterListToObject(this.widgetList), this.appConfig).subscribe((/**
560
+ * @param {?} widgets
561
+ * @return {?}
562
+ */
563
+ function (widgets) {
564
+ }));
565
+ return true;
566
+ };
598
567
  /** To retrieve widgets based on userDashboardid and area name */
599
568
  /**
600
569
  * To retrieve widgets based on userDashboardid and area name
@@ -621,8 +590,10 @@ var RADashboardArea = /** @class */ (function () {
621
590
  * @return {?}
622
591
  */
623
592
  function (widgets) {
624
- if (widgets)
593
+ if (widgets) {
625
594
  _this.widgetList = _this.mapObjectListToGridsterItemList(widgets);
595
+ _this.setAreaHeight();
596
+ }
626
597
  }));
627
598
  };
628
599
  /** To set Area(Gridster) height dynamically as widgets are added/removed */
@@ -656,49 +627,6 @@ var RADashboardArea = /** @class */ (function () {
656
627
  }
657
628
  this.gridheight = areaHeight;
658
629
  };
659
- /**To map IwidgetInfo object to gridsterItem */
660
- /**
661
- * To map IwidgetInfo object to gridsterItem
662
- * @param {?} widget
663
- * @return {?}
664
- */
665
- RADashboardArea.prototype.mapObjectsToGridsterItem = /**
666
- * To map IwidgetInfo object to gridsterItem
667
- * @param {?} widget
668
- * @return {?}
669
- */
670
- function (widget) {
671
- /** @type {?} */
672
- var gridsterItem = (/** @type {?} */ ({
673
- cols: widget.width,
674
- rows: widget.height,
675
- x: widget.position_x,
676
- y: widget.position_y,
677
- widgetInfo: widget
678
- }));
679
- return gridsterItem;
680
- };
681
- /**
682
- * @param {?} widgetList
683
- * @return {?}
684
- */
685
- RADashboardArea.prototype.mapObjectListToGridsterItemList = /**
686
- * @param {?} widgetList
687
- * @return {?}
688
- */
689
- function (widgetList) {
690
- var _this = this;
691
- /** @type {?} */
692
- var widgetArray = Array();
693
- widgetList.forEach((/**
694
- * @param {?} widget
695
- * @return {?}
696
- */
697
- function (widget) {
698
- widgetArray.push(_this.mapObjectsToGridsterItem(widget));
699
- }));
700
- return widgetArray;
701
- };
702
630
  /** To remove a widget instance from dashboard and to save info in database */
703
631
  /**
704
632
  * To remove a widget instance from dashboard and to save info in database
@@ -764,6 +692,88 @@ var RADashboardArea = /** @class */ (function () {
764
692
  _this.setAreaHeight();
765
693
  }));
766
694
  };
695
+ /**To map IwidgetInfo object to gridsterItem */
696
+ /**
697
+ * To map IwidgetInfo object to gridsterItem
698
+ * @param {?} widget
699
+ * @return {?}
700
+ */
701
+ RADashboardArea.prototype.mapObjectsToGridsterItem = /**
702
+ * To map IwidgetInfo object to gridsterItem
703
+ * @param {?} widget
704
+ * @return {?}
705
+ */
706
+ function (widget) {
707
+ /** @type {?} */
708
+ var gridsterItem = (/** @type {?} */ ({
709
+ cols: widget.width,
710
+ rows: widget.height,
711
+ x: widget.position_x,
712
+ y: widget.position_y,
713
+ widgetInfo: widget
714
+ }));
715
+ return gridsterItem;
716
+ };
717
+ /**
718
+ * @param {?} widgetList
719
+ * @return {?}
720
+ */
721
+ RADashboardArea.prototype.mapObjectListToGridsterItemList = /**
722
+ * @param {?} widgetList
723
+ * @return {?}
724
+ */
725
+ function (widgetList) {
726
+ var _this = this;
727
+ /** @type {?} */
728
+ var widgetArray = Array();
729
+ widgetList.forEach((/**
730
+ * @param {?} widget
731
+ * @return {?}
732
+ */
733
+ function (widget) {
734
+ widgetArray.push(_this.mapObjectsToGridsterItem(widget));
735
+ }));
736
+ return widgetArray;
737
+ };
738
+ /**
739
+ * @param {?} widgetItem
740
+ * @return {?}
741
+ */
742
+ RADashboardArea.prototype.mapGridsterItemToObject = /**
743
+ * @param {?} widgetItem
744
+ * @return {?}
745
+ */
746
+ function (widgetItem) {
747
+ /** @type {?} */
748
+ var widget;
749
+ widget = widgetItem.widgetInfo;
750
+ widget.height = widgetItem.rows;
751
+ widget.width = widgetItem.cols;
752
+ widget.position_x = widgetItem.x;
753
+ widget.position_y = widgetItem.y;
754
+ return widget;
755
+ };
756
+ /**
757
+ * @param {?} widgetItemList
758
+ * @return {?}
759
+ */
760
+ RADashboardArea.prototype.mapGridsterListToObject = /**
761
+ * @param {?} widgetItemList
762
+ * @return {?}
763
+ */
764
+ function (widgetItemList) {
765
+ var _this = this;
766
+ /** @type {?} */
767
+ var widgetListArray = Array();
768
+ widgetItemList.forEach((/**
769
+ * @param {?} widget
770
+ * @return {?}
771
+ */
772
+ function (widget) {
773
+ widgetListArray.push(_this.mapGridsterItemToObject(widget));
774
+ }));
775
+ return widgetListArray;
776
+ };
767
777
  RADashboardArea.decorators = [
768
778
  { type: Component, args: [{
769
779
  selector: 'ra-dashboard-area',