Skip to content

Commit b683d25

Browse files
joanagmaiamariobalcaepipav
authored
Members report (#418)
Co-authored-by: Mário Balça <mario.balca@gmail.com> Co-authored-by: anilb <epipav@gmail.com>
1 parent f5c2372 commit b683d25

45 files changed

Lines changed: 2604 additions & 167 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/src/api/report/reportDestroy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import Permissions from '../../security/permissions'
22
import ReportService from '../../services/reportService'
33
import PermissionChecker from '../../services/user/permissionChecker'
4+
import track from '../../segment/track'
45

56
export default async (req, res) => {
67
new PermissionChecker(req).validateHas(Permissions.values.reportDestroy)
78

89
await new ReportService(req).destroyAll(req.query.ids)
910

11+
track('Report Deleted')
12+
1013
const payload = true
1114

1215
await req.responseHandler.success(req, res, payload)

backend/src/api/report/reportFind.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Permissions from '../../security/permissions'
22
import ReportService from '../../services/reportService'
33
import PermissionChecker from '../../services/user/permissionChecker'
4+
import track from '../../segment/track'
45

56
export default async (req, res) => {
67
const payload = await new ReportService(req).findById(req.params.id)
@@ -9,5 +10,7 @@ export default async (req, res) => {
910
new PermissionChecker(req).validateHas(Permissions.values.reportRead)
1011
}
1112

13+
track('Report Viewed', { id: payload.id, name: payload.name, public: payload.public }, { ...req })
14+
1215
await req.responseHandler.success(req, res, payload)
1316
}

backend/src/api/widget/widgetDestroy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Permissions from '../../security/permissions'
22
import PermissionChecker from '../../services/user/permissionChecker'
33
import WidgetService from '../../services/widgetService'
4+
import track from '../../segment/track'
45

56
export default async (req, res) => {
67
new PermissionChecker(req).validateHas(Permissions.values.widgetDestroy)
@@ -9,5 +10,7 @@ export default async (req, res) => {
910

1011
const payload = true
1112

13+
track('Widget Deleted')
14+
1215
await req.responseHandler.success(req, res, payload)
1316
}

backend/src/database/repositories/__tests__/conversationRepository.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ describe('ConversationRepository tests', () => {
443443
'activeOn',
444444
'identities',
445445
'activeDaysCount',
446-
'activityTypes',
447446
])
448447

449448
const conversation1Expected = {

frontend/public/icons/crowd-icons.svg

Lines changed: 6 additions & 0 deletions
Loading

frontend/src/modules/dashboard/components/dashboard-filters.vue

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
<template>
22
<div class="flex items-center py-6">
33
<!-- period filters -->
4-
<div class="flex text-xs text-gray-600">
5-
<div
6-
class="px-3 h-8 border border-gray-200 border-r-0 rounded-l-md flex items-center justify-center transition hover:bg-gray-50 cursor-pointer"
7-
:class="periodStateClasses(7)"
8-
@click="setPeriod(7)"
9-
>
10-
7D
11-
</div>
12-
<div
13-
class="px-3 h-8 border border-gray-200 flex items-center justify-center transition hover:bg-gray-50 cursor-pointer"
14-
:class="periodStateClasses(14)"
15-
@click="setPeriod(14)"
16-
>
17-
14D
18-
</div>
19-
<div
20-
class="px-3 h-8 border border-gray-200 border-l-0 rounded-r-md flex items-center justify-center transition hover:bg-gray-50 cursor-pointer"
21-
:class="periodStateClasses(30)"
22-
@click="setPeriod(30)"
23-
>
24-
30D
25-
</div>
26-
</div>
4+
<app-widget-period
5+
:period="period"
6+
@on-update="setPeriod"
7+
/>
278

289
<!-- platform filter -->
2910
<el-dropdown
@@ -75,9 +56,13 @@
7556
<script>
7657
import { mapGetters, mapActions } from 'vuex'
7758
import { CrowdIntegrations } from '@/integrations/integrations-config'
59+
import AppWidgetPeriod from '@/modules/widget/components/v2/shared/widget-period.vue'
7860
7961
export default {
8062
name: 'AppDashboardFilters',
63+
components: {
64+
AppWidgetPeriod
65+
},
8166
data() {
8267
return {
8368
platformDropdownOpen: false,
@@ -135,11 +120,6 @@ export default {
135120
platformDetails(platform) {
136121
return CrowdIntegrations.getConfig(platform)
137122
},
138-
periodStateClasses(period) {
139-
return this.period === period
140-
? 'bg-gray-100 font-medium text-gray-900'
141-
: 'bg-white'
142-
},
143123
setPeriod(period) {
144124
this.setFilters({
145125
period

frontend/src/modules/dashboard/store/actions.js

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { OrganizationService } from '@/modules/organization/organization-service
33
import { ActivityService } from '@/modules/activity/activity-service'
44
import { ConversationService } from '@/modules/conversation/conversation-service'
55
import moment from 'moment'
6+
import { SEVEN_DAYS_PERIOD_FILTER } from '@/modules/widget/widget-constants'
67

78
export default {
89
async reset({ dispatch }) {
910
dispatch('setFilters', {
10-
period: 7,
11+
period: SEVEN_DAYS_PERIOD_FILTER,
1112
platform: 'all'
1213
})
1314
},
@@ -42,7 +43,12 @@ export default {
4243
lastActive: {
4344
gte: moment()
4445
.startOf('day')
45-
.subtract(period - 1, 'day')
46+
.subtract(
47+
period.granularity === 'day'
48+
? period.value - 1
49+
: period.value,
50+
period.granularity
51+
)
4652
.toISOString()
4753
}
4854
},
@@ -97,7 +103,12 @@ export default {
97103
timestamp: {
98104
gte: moment()
99105
.startOf('day')
100-
.subtract(period - 1, 'day')
106+
.subtract(
107+
period.granularity === 'day'
108+
? period.value - 1
109+
: period.value,
110+
period.granularity
111+
)
101112
.toISOString()
102113
}
103114
},
@@ -153,7 +164,12 @@ export default {
153164
lastActive: {
154165
gte: moment()
155166
.startOf('day')
156-
.subtract(period - 1, 'day')
167+
.subtract(
168+
period.granularity === 'day'
169+
? period.value - 1
170+
: period.value,
171+
period.granularity
172+
)
157173
.toISOString()
158174
}
159175
},
@@ -193,7 +209,12 @@ export default {
193209
joinedAt: {
194210
gte: moment()
195211
.startOf('day')
196-
.subtract(period - 1, 'day')
212+
.subtract(
213+
period.granularity === 'day'
214+
? period.value - 1
215+
: period.value,
216+
period.granularity
217+
)
197218
.toISOString()
198219
}
199220
},
@@ -251,7 +272,12 @@ export default {
251272
lastActive: {
252273
gte: moment()
253274
.startOf('day')
254-
.subtract(period - 1, 'day')
275+
.subtract(
276+
period.granularity === 'day'
277+
? period.value - 1
278+
: period.value,
279+
period.granularity
280+
)
255281
.toISOString()
256282
}
257283
},
@@ -291,7 +317,12 @@ export default {
291317
joinedAt: {
292318
gte: moment()
293319
.startOf('day')
294-
.subtract(period - 1, 'day')
320+
.subtract(
321+
period.granularity === 'day'
322+
? period.value - 1
323+
: period.value,
324+
period.granularity
325+
)
295326
.toISOString()
296327
}
297328
},

frontend/src/modules/dashboard/store/mutations.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import { SEVEN_DAYS_PERIOD_FILTER } from '@/modules/widget/widget-constants'
2+
13
export default {
24
SET_FILTERS(state, payload) {
35
state.filters.period =
4-
payload.period || state.filters.period || 7
6+
payload.period ||
7+
state.filters.period ||
8+
SEVEN_DAYS_PERIOD_FILTER
59
state.filters.platform =
610
payload.platform || state.filters.platform || 'all'
711
},

frontend/src/modules/dashboard/store/state.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { SEVEN_DAYS_PERIOD_FILTER } from '@/modules/widget/widget-constants'
2+
13
export default () => {
24
return {
35
filters: {
4-
period: 7,
6+
period: SEVEN_DAYS_PERIOD_FILTER,
57
platform: 'all'
68
},
79
conversations: {

frontend/src/modules/layout/components/layout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<el-container>
33
<app-menu></app-menu>
44
<el-container :style="elMainStyle">
5-
<el-main class="relative">
5+
<el-main id="main-page-wrapper" class="relative">
66
<div :class="computedBannerWrapperClass">
77
<banner
88
v-if="shouldShowSampleDataAlert"

0 commit comments

Comments
 (0)