@kigi/components 1.37.0-beta.2 → 1.37.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kigi/components",
3
- "version": "1.37.0-beta.2",
3
+ "version": "1.37.0-beta.3",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -2,11 +2,12 @@
2
2
  <div class="home-chart"> </div>
3
3
  <div class="divider"></div>
4
4
  <div class="home-cards">
5
- <mbg-card-panel ng-repeat="panel in $ctrl.panels"
5
+ <mbg-card-panel ng-repeat="panel in $ctrl.panels track by $index"
6
6
  loading="$ctrl.loading"
7
7
  allow-dashboard-main-sales="$ctrl.allowDashboardMainSales"
8
8
  display-values="$ctrl.displayValues"
9
9
  allowed-to-see="$ctrl.allowedToSee"
10
+ active-filter="$ctrl.activeFilter"
10
11
  allowed-call-back="$ctrl.allowedCallBack()"
11
12
  panel="panel">
12
13
  <i class="{{ panel.icon }}"
@@ -15,6 +15,7 @@ const mbgChartWrapper = {
15
15
  allowedToSee: '=?',
16
16
  allowedCallBack: '&?',
17
17
  allowDashboardMainSales: '=?',
18
+ activeFilter: '=?',
18
19
  },
19
20
  template,
20
21
  controller: MbgChartWrapperController,
@@ -20,19 +20,37 @@
20
20
  ng-show="!$ctrl.hideValue"
21
21
  disable-animate>
22
22
  <p class="value"
23
- ng-class="{'positive': $ctrl.panel.isCurrency && $ctrl.panel.value >= 0,
24
- 'negative': $ctrl.panel.isCurrency && $ctrl.panel.value < 0}"
23
+ ng-class="{'positive': $ctrl.panel.increasedValue,
24
+ 'negative': !$ctrl.panel.increasedValue}"
25
25
  ng-if="$ctrl.panel.isCurrency">{{ $ctrl.panel.value || 0 | currency: 'R$ ' }}
26
26
  </p>
27
27
  <p class="value"
28
+ ng-class="{'positive': $ctrl.panel.increasedValue,
29
+ 'negative': !$ctrl.panel.increasedValue}"
28
30
  ng-if="!$ctrl.panel.isCurrency">{{ $ctrl.panel.value || 0}}
29
31
  </p>
30
- <span ng-if="$ctrl.panel.value > 0"
31
- class="positive"><i class="fa fa-arrow-up"
32
- aria-hidden="true"></i></i></span>
33
- <span ng-if="!$ctrl.panel.positive < 0"
34
- class="negative"><i class="fa fa-arrow-down"
35
- aria-hidden="true"></i></span>
32
+
33
+
34
+ <div uib-tooltip-html="$ctrl.panel.message"
35
+ tooltip-placement="{{$ctrl.panel.avgSales ? 'top' :'bottom' }}">
36
+ <span ng-if="$ctrl.panel.increasedValue && !$ctrl.valuesEqual && !$ctrl.hideValue"
37
+ class="positive">
38
+ <i class="fa fa-arrow-up"
39
+ aria-hidden="true"></i></span>
40
+
41
+ <span ng-if="$ctrl.valuesEqual && !$ctrl.hideValue"
42
+ class="equal">
43
+ <i class="fa fa-minus"
44
+ aria-hidden="true"></i></span>
45
+ </div>
46
+
47
+
48
+ <div uib-tooltip-html="$ctrl.panel.message"
49
+ tooltip-placement="{{$ctrl.panel.avgSales ? 'top' :'bottom' }}">
50
+ <span ng-if="!$ctrl.panel.increasedValue && !$ctrl.valuesEqual && !$ctrl.hideValue"
51
+ class="negative"><i class="fa fa-arrow-down"
52
+ aria-hidden="true"></i></span>
53
+ </div>
36
54
  </div>
37
55
 
38
56
  <!-- quando valores estão ocultos -->
@@ -41,12 +59,19 @@
41
59
  disable-animate>
42
60
  <p class="value">{{ $ctrl.randomEmoji }}</p>
43
61
 
44
- <span ng-if="$ctrl.panel.value > 0"
62
+ <span ng-if="$ctrl.panel.increasedValue && !$ctrl.valuesEqual"
45
63
  class="positive"><i class="fa fa-arrow-up"
46
- aria-hidden="true"></i></i></span>
47
- <span ng-if="!$ctrl.panel.positive < 0"
64
+ aria-hidden="true"></i></span>
65
+
66
+ <span ng-if="!$ctrl.panel.increasedValue && !$ctrl.valuesEqual"
48
67
  class="negative"><i class="fa fa-arrow-down"
49
68
  aria-hidden="true"></i></span>
69
+
70
+ <span ng-if="$ctrl.valuesEqual"
71
+ class="equal">
72
+ <i class="fa fa-minus"
73
+ aria-hidden="true"></i></span>
74
+
50
75
  </div>
51
76
  </div>
52
77
  </div>
@@ -1,6 +1,27 @@
1
1
  mbg-card-panel {
2
+ .tooltip-chart-panel {
3
+ display: flex;
4
+ flex-direction: column;
5
+ position: relative;
6
+ background:#0EBCBD;
7
+ font-weight: bold;
8
+ color: #FFFFFF;
9
+ width: 100%;
10
+ height: 100%;
11
+ margin-right: 200px;
12
+ }
13
+
14
+ .tooltip-inner {
15
+ background: transparent;
16
+ margin-right: 180px;
17
+ }
18
+
19
+
20
+
2
21
  .mbg-h-c-panel {
3
- border: 1px solid #5f5b5b;
22
+ border: 1px solid #F1F1F1;
23
+ border-radius: 12px;
24
+ padding: 8px;
4
25
  border-radius: 12px;
5
26
  padding: 8px;
6
27
 
@@ -1,5 +1,8 @@
1
1
  import './panel.scss'
2
2
  import template from './panel.html'
3
+ import { DashboardService } from 'services/dashboard-service'
4
+ import moment from 'moment'
5
+
3
6
 
4
7
  class MbgCardPanelController {
5
8
  public loading
@@ -9,8 +12,20 @@ class MbgCardPanelController {
9
12
  public allowedToSee: boolean
10
13
  private allowedCallBack: Function
11
14
  private allowDashboardMainSales
15
+ private activeFilter: any
16
+ private totalSalesFilter = false
17
+ private index
18
+ private messagetooltip = ''
19
+ private valuesEqual: boolean = false
12
20
 
13
- constructor(public $scope, public $element, public $attrs, public $timeout) {}
21
+ constructor(
22
+ public $scope,
23
+ public $element,
24
+ public $attrs,
25
+ public $timeout,
26
+ public dashboardService: DashboardService,
27
+ public $filter,
28
+ ) {}
14
29
  $onInit() {
15
30
  this.syncValue()
16
31
  this.$scope.$watch('$ctrl.displayValues', (data) => {
@@ -23,6 +38,7 @@ class MbgCardPanelController {
23
38
  this.panel.setNewValue = (value) => {
24
39
  this.setValue(value)
25
40
  }
41
+ this.getCardsGeral()
26
42
  }
27
43
 
28
44
  setValue = (value) => {
@@ -32,6 +48,135 @@ class MbgCardPanelController {
32
48
  }, 1000)
33
49
  }
34
50
 
51
+ async getCardsGeral() {
52
+ this.$timeout(async () => {
53
+ const { dateIni, dateFim } = this.getFilterDate()
54
+ let response = await this.dashboardService
55
+ .getCardsTotalSalesDashboardByFilter({ dateIni, dateFim })
56
+ .then((response) => response.data)
57
+
58
+ const values = {
59
+ totalSales: response.totalSales ? response.totalSales : 0,
60
+ avgSales: response.avgSales ? response.avgSales : 0,
61
+ countSales: response.countSales || 0,
62
+ countItems: response.countItems || 0,
63
+ }
64
+
65
+ if (this.panel.countSales) {
66
+ this.panel.increasedValue = this.panel.value > values.countSales
67
+ this.valuesEqual = this.panel.value === values.countSales
68
+ this.panel.message = `
69
+ <div class="tooltip-chart-panel">
70
+ <label>Comparado as data de:</label>
71
+ <label>${
72
+ moment(dateIni).format('DD-MM') + ' até ' + moment(dateFim).format('DD-MM')
73
+ }</label>
74
+ <label>Vendas: ${values.countSales}</label>
75
+ </div>`
76
+ }
77
+
78
+ if (this.panel.countItems) {
79
+ this.panel.increasedValue = this.panel.value > values.countItems
80
+ this.valuesEqual = this.panel.value === values.countItems
81
+ this.panel.message = `
82
+ <div class="tooltip-chart-panel">
83
+ <label>Comparado as data de:</label>
84
+ <label>${
85
+ moment(dateIni).format('DD-MM') + ' até ' + moment(dateFim).format('DD-MM')
86
+ }</label>
87
+ <label>Items: ${values.countItems}</label>
88
+ </div>`
89
+ }
90
+
91
+ if (this.panel.avgSales) {
92
+ this.panel.increasedValue = this.panel.value > values.avgSales
93
+ this.valuesEqual = this.panel.value === values.avgSales
94
+ this.panel.message = `
95
+ <div class="tooltip-chart-panel">
96
+ <label>Comparado as data de:</label>
97
+ <label>${
98
+ moment(dateIni).format('DD-MM') + ' até ' + moment(dateFim).format('DD-MM')
99
+ }</label>
100
+ <label>Valor: ${this.$filter('currency')(values.avgSales, 'R$ ')}</label>
101
+ </div>`
102
+ }
103
+
104
+ if (this.panel.totalSales) {
105
+ this.panel.increasedValue = this.panel.value > values.totalSales
106
+ this.valuesEqual = this.panel.value === values.totalSales
107
+
108
+ this.panel.message = `
109
+ <div class="tooltip-chart-panel">
110
+ <label>Comparado as data de:</label>
111
+ <label>${
112
+ moment(dateIni).format('DD-MM') + ' até ' + moment(dateFim).format('DD-MM')
113
+ }</label>
114
+ <label>Valor: ${this.$filter('currency')(values.totalSales, 'R$ ')}</label>
115
+ </div>`
116
+ }
117
+ }, 1000)
118
+ }
119
+
120
+ formatToBRL(value) {
121
+ return value.toLocaleString('pt-BR', {
122
+ style: 'currency',
123
+ currency: 'BRL',
124
+ })
125
+ }
126
+
127
+ getFilterDate() {
128
+ this.activeFilter = this.activeFilter || { name: 'Hoje', key: 'TODAY' }
129
+ switch (this.activeFilter.key) {
130
+ case 'TODAY':
131
+ return {
132
+ dateIni: moment()
133
+ .subtract(1, 'd')
134
+ .set({ hours: 0, minutes: 0, seconds: 0 })
135
+ .format('YYYY-MM-DD HH:mm:ss'),
136
+ dateFim: moment()
137
+ .subtract(1, 'd')
138
+ .set({ hours: 23, minutes: 59, seconds: 59 })
139
+ .format('YYYY-MM-DD HH:mm:ss'),
140
+ }
141
+ case 'YESTERDAY':
142
+ return {
143
+ dateIni: moment()
144
+ .subtract(2, 'd')
145
+ .set({ hours: 0, minutes: 0, seconds: 0 })
146
+ .format('YYYY-MM-DD HH:mm:ss'),
147
+ dateFim: moment()
148
+ .subtract(2, 'd')
149
+ .set({ hours: 23, minutes: 59, seconds: 59 })
150
+ .format('YYYY-MM-DD HH:mm:ss'),
151
+ }
152
+ case 'THIS_WEEK':
153
+ const startOfLastWeek = moment()
154
+ .subtract(7, 'days')
155
+ .startOf('week')
156
+ .set({ hours: 0, minutes: 0, seconds: 0 })
157
+ const lastWeekToday = moment()
158
+ .subtract(7, 'days')
159
+ .set({ hours: 23, minutes: 59, seconds: 59 })
160
+
161
+ return {
162
+ dateIni: startOfLastWeek.format('YYYY-MM-DD HH:mm:ss'),
163
+ dateFim: lastWeekToday.format('YYYY-MM-DD HH:mm:ss'),
164
+ }
165
+
166
+ default:
167
+ return {
168
+ dateIni: moment()
169
+ .subtract(1, 'month')
170
+ .set({ date: 1, hours: 23, minutes: 59, seconds: 59 })
171
+ .format('YYYY-MM-DD HH:mm:ss'),
172
+ dateFim: moment()
173
+ .subtract(1, 'month')
174
+ .set({ date: moment().date(), hours: 0, minutes: 0, seconds: 0 })
175
+ .format('YYYY-MM-DD HH:mm:ss'),
176
+ }
177
+ }
178
+ }
179
+
35
180
  syncValue() {
36
181
  if (this.panel.sync) {
37
182
  this.panel.loading = true
@@ -57,7 +202,14 @@ class MbgCardPanelController {
57
202
  }
58
203
  }
59
204
 
60
- MbgCardPanelController['$inject'] = ['$scope', '$element', '$attrs', '$timeout']
205
+ MbgCardPanelController['$inject'] = [
206
+ '$scope',
207
+ '$element',
208
+ '$attrs',
209
+ '$timeout',
210
+ 'dashboardService',
211
+ '$filter',
212
+ ]
61
213
 
62
214
  const mbgCardPanel = {
63
215
  transclude: true,
@@ -68,6 +220,7 @@ const mbgCardPanel = {
68
220
  allowedToSee: '=?',
69
221
  allowedCallBack: '&?',
70
222
  allowDashboardMainSales: '=?',
223
+ activeFilter: '=?',
71
224
  },
72
225
  template,
73
226
  controller: MbgCardPanelController,
@@ -5,6 +5,7 @@
5
5
  allow-dashboard-main-sales="$ctrl.allowDashboardMainSales"
6
6
  display-values="$ctrl.displayValues"
7
7
  allowed-to-see="$ctrl.allowedToSee"
8
+ active-filter="$ctrl.activeFilter"
8
9
  allowed-call-back="$ctrl.allowedCallBack()"></mbg-chart-wrapper>
9
10
 
10
11
  <div ng-show="!$ctrl.hasData()"
@@ -257,6 +257,7 @@ const mbgChartBarLine = {
257
257
  allowedToSee: '=?',
258
258
  allowedCallBack: '&?',
259
259
  allowDashboardMainSales: '=?',
260
+ activeFilter: '=?',
260
261
  },
261
262
  template,
262
263
  controller: MbgChartBarLineController,
@@ -5,6 +5,7 @@
5
5
  display-values="$ctrl.displayValues"
6
6
  allow-dashboard-main-sales="$ctrl.allowDashboardMainSales"
7
7
  allowed-to-see="$ctrl.allowedToSee"
8
+ active-filter="$ctrl.activeFilter"
8
9
  allowed-call-back="$ctrl.allowedCallBack()"></mbg-chart-wrapper>
9
10
 
10
11
  <div ng-show="!$ctrl.hasData()"
@@ -282,6 +282,7 @@ const mbgChartBarLinePie = {
282
282
  allowedToSee: '=?',
283
283
  allowedCallBack: '&?',
284
284
  allowDashboardMainSales: '=?',
285
+ activeFilter: '=?',
285
286
  },
286
287
  template,
287
288
  controller: MbgChartBarLinePieController,
@@ -5,6 +5,7 @@
5
5
  display-values="$ctrl.displayValues"
6
6
  allow-dashboard-main-sales="$ctrl.allowDashboardMainSales"
7
7
  allowed-to-see="$ctrl.allowedToSee"
8
+ active-filter="$ctrl.activeFilter"
8
9
  allowed-call-back="$ctrl.allowedCallBack()"></mbg-chart-wrapper>
9
10
 
10
11
  <div ng-show="!$ctrl.hasData()"
@@ -278,6 +278,7 @@ const mbgChartLine = {
278
278
  allowedToSee: '=?',
279
279
  allowedCallBack: '&?',
280
280
  allowDashboardMainSales: '=?',
281
+ activeFilter: '=?',
281
282
  },
282
283
  template,
283
284
  controller: MbgChartLineController,
@@ -14,3 +14,4 @@ const mbgHomeScreenModule = angular
14
14
  .component('mbgChartWrapper', mbgChartWrapper).name
15
15
 
16
16
  export { mbgHomeScreenModule }
17
+
@@ -52,6 +52,7 @@
52
52
  loading="$ctrl.loading"
53
53
  allowed-to-see="$ctrl.allowedToSee"
54
54
  allowed-call-back="$ctrl.allowedCallBack()"
55
+ active-filter="$ctrl.activeFilter"
55
56
  ng-if="$ctrl.chart && $ctrl.chart.type == 'line'"></mbg-chart-line>
56
57
  <mbg-chart-bar-line chart="$ctrl.chart"
57
58
  panels="$ctrl.cards"
@@ -60,6 +61,7 @@
60
61
  loading="$ctrl.loading"
61
62
  allowed-to-see="$ctrl.allowedToSee"
62
63
  allowed-call-back="$ctrl.allowedCallBack()"
64
+ active-filter="$ctrl.activeFilter"
63
65
  ng-if="$ctrl.chart && $ctrl.chart.type == 'barline'"></mbg-chart-bar-line>
64
66
  <mbg-chart-bar-line-pie chart="$ctrl.chart"
65
67
  panels="$ctrl.cards"
@@ -68,6 +70,7 @@
68
70
  loading="$ctrl.loading"
69
71
  allowed-to-see="$ctrl.allowedToSee"
70
72
  allowed-call-back="$ctrl.allowedCallBack()"
73
+ active-filter="$ctrl.activeFilter"
71
74
  ng-if="$ctrl.chart && $ctrl.chart.type == 'barlinepie'"></mbg-chart-bar-line-pie>
72
75
  <div class="display-values">
73
76
  <a ng-show="!$ctrl.displayValues"
@@ -22,6 +22,7 @@ class MbgHomescreenController {
22
22
  isCurrency: boolean
23
23
  }[]
24
24
  private allowDashboardMainSales
25
+ private filterActive
25
26
 
26
27
  constructor(public $scope, public $element, public $attrs, public $timeout) {}
27
28
 
@@ -63,6 +64,7 @@ class MbgHomescreenController {
63
64
  return tab
64
65
  })
65
66
  this.activeFilter = item
67
+ this.filterActive = this.activeFilter
66
68
  item.active = true
67
69
  if (this.tabs[this.activeIndex].executeFilter) {
68
70
  this.tabs[this.activeIndex].executeFilter(this.config)
@@ -78,6 +80,7 @@ class MbgHomescreenController {
78
80
  this.tabs.forEach((tab, index) => (this.tabs[index].active = false))
79
81
  this.tabs[tabIndex].active = true
80
82
  this.activeFilter = (this.tabs[tabIndex].filters || []).find((filter) => filter.active)
83
+ this.filterActive = this.activeFilter
81
84
  this.cards = this.tabs[tabIndex].cards
82
85
  this.chart = this.tabs[tabIndex].chart
83
86
  }