@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.
@@ -53,54 +53,6 @@
53
53
  function RaDashboardService(injector) {
54
54
  var _this = _super.call(this, injector, '') || this;
55
55
  _this.loadedScripts = [];
56
- _this.widgets = [
57
- {
58
- dashboardId: '1',
59
- id: '1',
60
- customTag: 'ra-test-widget',
61
- scriptUrl: './assets/ra-test-widget.bundle.js',
62
- title: 'Test Widget',
63
- widgetInstanceId: 1,
64
- widgetId: 1,
65
- position_x: 0,
66
- position_y: 0,
67
- width: 50,
68
- height: 20,
69
- widgetConfigInfo: {
70
- scriptPath: "./assets/ra-test-widget-config.bundle.js",
71
- configControlTag: "ra-test-widget-config",
72
- config: { country: 'All' }
73
- },
74
- widgetName: '',
75
- widgetTitle: 'Test Widget',
76
- dashboardAreaId: 1,
77
- dashboardAreaKey: '',
78
- dashboardName: ''
79
- },
80
- {
81
- dashboardId: '2',
82
- id: '2',
83
- customTag: 'ra-test-widget',
84
- scriptUrl: './assets/ra-test-widget.bundle.js',
85
- title: 'Test Widget',
86
- widgetInstanceId: 2,
87
- dashboardAreaKey: '',
88
- widgetId: 1,
89
- position_x: 0,
90
- position_y: 0,
91
- width: 50,
92
- height: 20,
93
- widgetConfigInfo: {
94
- scriptPath: "./assets/ra-test-widget-config.bundle.js",
95
- configControlTag: "ra-test-widget-config",
96
- config: { country: 'All' }
97
- },
98
- widgetName: '',
99
- widgetTitle: 'Test Widget',
100
- dashboardAreaId: 1,
101
- dashboardName: ''
102
- },
103
- ];
104
56
  return _this;
105
57
  }
106
58
  /*
@@ -167,32 +119,31 @@
167
119
  return this.post(url, widgetInfo);
168
120
  };
169
121
  /**
170
- * @param {?} widgetInfo
122
+ * @param {?} widgetList
123
+ * @param {?} appConfig
171
124
  * @return {?}
172
125
  */
173
- RaDashboardService.prototype.getWidgetConfigInfo = /**
174
- * @param {?} widgetInfo
126
+ RaDashboardService.prototype.updateWidgets = /**
127
+ * @param {?} widgetList
128
+ * @param {?} appConfig
175
129
  * @return {?}
176
130
  */
177
- function (widgetInfo) {
178
- return rxjs.of();
131
+ function (widgetList, appConfig) {
132
+ this.baseUrl = appConfig.apiBaseUrl;
133
+ /** @type {?} */
134
+ var url = 'widget/UpdateAreaWidgets';
135
+ return this.post(url, widgetList);
179
136
  };
180
137
  /**
181
- * @param {?} widgetId
138
+ * @param {?} widgetInfo
182
139
  * @return {?}
183
140
  */
184
- RaDashboardService.prototype.getWidgetById = /**
185
- * @param {?} widgetId
141
+ RaDashboardService.prototype.getWidgetConfigInfo = /**
142
+ * @param {?} widgetInfo
186
143
  * @return {?}
187
144
  */
188
- function (widgetId) {
189
- return this.widgets.filter((/**
190
- * @param {?} t
191
- * @return {?}
192
- */
193
- function (t) {
194
- t.widgetId == widgetId;
195
- }));
145
+ function (widgetInfo) {
146
+ return rxjs.of();
196
147
  };
197
148
  /*
198
149
  * To update the configuration of a widget.
@@ -592,7 +543,9 @@
592
543
  * @return {?}
593
544
  */
594
545
  function (item) {
546
+ console.log('in change call back');
595
547
  areaContext.setAreaHeight();
548
+ areaContext.updateWidgets();
596
549
  });
597
550
  };
598
551
  /**
@@ -632,6 +585,22 @@
632
585
  function () {
633
586
  this.conifgAddClick.unsubscribe();
634
587
  };
588
+ /**
589
+ * @return {?}
590
+ */
591
+ RADashboardArea.prototype.updateWidgets = /**
592
+ * @return {?}
593
+ */
594
+ function () {
595
+ console.log('in update widgets');
596
+ this.dashboardService.updateWidgets(this.mapGridsterListToObject(this.widgetList), this.appConfig).subscribe((/**
597
+ * @param {?} widgets
598
+ * @return {?}
599
+ */
600
+ function (widgets) {
601
+ }));
602
+ return true;
603
+ };
635
604
  /** To retrieve widgets based on userDashboardid and area name */
636
605
  /**
637
606
  * To retrieve widgets based on userDashboardid and area name
@@ -658,8 +627,10 @@
658
627
  * @return {?}
659
628
  */
660
629
  function (widgets) {
661
- if (widgets)
630
+ if (widgets) {
662
631
  _this.widgetList = _this.mapObjectListToGridsterItemList(widgets);
632
+ _this.setAreaHeight();
633
+ }
663
634
  }));
664
635
  };
665
636
  /** To set Area(Gridster) height dynamically as widgets are added/removed */
@@ -693,49 +664,6 @@
693
664
  }
694
665
  this.gridheight = areaHeight;
695
666
  };
696
- /**To map IwidgetInfo object to gridsterItem */
697
- /**
698
- * To map IwidgetInfo object to gridsterItem
699
- * @param {?} widget
700
- * @return {?}
701
- */
702
- RADashboardArea.prototype.mapObjectsToGridsterItem = /**
703
- * To map IwidgetInfo object to gridsterItem
704
- * @param {?} widget
705
- * @return {?}
706
- */
707
- function (widget) {
708
- /** @type {?} */
709
- var gridsterItem = (/** @type {?} */ ({
710
- cols: widget.width,
711
- rows: widget.height,
712
- x: widget.position_x,
713
- y: widget.position_y,
714
- widgetInfo: widget
715
- }));
716
- return gridsterItem;
717
- };
718
- /**
719
- * @param {?} widgetList
720
- * @return {?}
721
- */
722
- RADashboardArea.prototype.mapObjectListToGridsterItemList = /**
723
- * @param {?} widgetList
724
- * @return {?}
725
- */
726
- function (widgetList) {
727
- var _this = this;
728
- /** @type {?} */
729
- var widgetArray = Array();
730
- widgetList.forEach((/**
731
- * @param {?} widget
732
- * @return {?}
733
- */
734
- function (widget) {
735
- widgetArray.push(_this.mapObjectsToGridsterItem(widget));
736
- }));
737
- return widgetArray;
738
- };
739
667
  /** To remove a widget instance from dashboard and to save info in database */
740
668
  /**
741
669
  * To remove a widget instance from dashboard and to save info in database
@@ -801,6 +729,88 @@
801
729
  _this.setAreaHeight();
802
730
  }));
803
731
  };
732
+ /**To map IwidgetInfo object to gridsterItem */
733
+ /**
734
+ * To map IwidgetInfo object to gridsterItem
735
+ * @param {?} widget
736
+ * @return {?}
737
+ */
738
+ RADashboardArea.prototype.mapObjectsToGridsterItem = /**
739
+ * To map IwidgetInfo object to gridsterItem
740
+ * @param {?} widget
741
+ * @return {?}
742
+ */
743
+ function (widget) {
744
+ /** @type {?} */
745
+ var gridsterItem = (/** @type {?} */ ({
746
+ cols: widget.width,
747
+ rows: widget.height,
748
+ x: widget.position_x,
749
+ y: widget.position_y,
750
+ widgetInfo: widget
751
+ }));
752
+ return gridsterItem;
753
+ };
754
+ /**
755
+ * @param {?} widgetList
756
+ * @return {?}
757
+ */
758
+ RADashboardArea.prototype.mapObjectListToGridsterItemList = /**
759
+ * @param {?} widgetList
760
+ * @return {?}
761
+ */
762
+ function (widgetList) {
763
+ var _this = this;
764
+ /** @type {?} */
765
+ var widgetArray = Array();
766
+ widgetList.forEach((/**
767
+ * @param {?} widget
768
+ * @return {?}
769
+ */
770
+ function (widget) {
771
+ widgetArray.push(_this.mapObjectsToGridsterItem(widget));
772
+ }));
773
+ return widgetArray;
774
+ };
775
+ /**
776
+ * @param {?} widgetItem
777
+ * @return {?}
778
+ */
779
+ RADashboardArea.prototype.mapGridsterItemToObject = /**
780
+ * @param {?} widgetItem
781
+ * @return {?}
782
+ */
783
+ function (widgetItem) {
784
+ /** @type {?} */
785
+ var widget;
786
+ widget = widgetItem.widgetInfo;
787
+ widget.height = widgetItem.rows;
788
+ widget.width = widgetItem.cols;
789
+ widget.position_x = widgetItem.x;
790
+ widget.position_y = widgetItem.y;
791
+ return widget;
792
+ };
793
+ /**
794
+ * @param {?} widgetItemList
795
+ * @return {?}
796
+ */
797
+ RADashboardArea.prototype.mapGridsterListToObject = /**
798
+ * @param {?} widgetItemList
799
+ * @return {?}
800
+ */
801
+ function (widgetItemList) {
802
+ var _this = this;
803
+ /** @type {?} */
804
+ var widgetListArray = Array();
805
+ widgetItemList.forEach((/**
806
+ * @param {?} widget
807
+ * @return {?}
808
+ */
809
+ function (widget) {
810
+ widgetListArray.push(_this.mapGridsterItemToObject(widget));
811
+ }));
812
+ return widgetListArray;
813
+ };
804
814
  RADashboardArea.decorators = [
805
815
  { type: core.Component, args: [{
806
816
  selector: 'ra-dashboard-area',