@plusscommunities/pluss-maintenance-web-forms 1.1.37-beta.3 → 1.2.0-beta.0
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/dist/{index.esm.js → index.js} +3331 -2998
- package/dist/index.js.map +1 -0
- package/package.json +17 -27
- package/.babelrc +0 -3
- package/dist/index.cjs.js +0 -6362
- package/dist/index.umd.js +0 -6355
- package/rollup.config.js +0 -59
- package/src/actions/JobsActions.js +0 -150
- package/src/actions/index.js +0 -1
- package/src/actions/types.js +0 -8
- package/src/apis/index.js +0 -10
- package/src/apis/maintenanceActions.js +0 -203
- package/src/apis/reactionActions.js +0 -46
- package/src/components/ActivityText.js +0 -57
- package/src/components/AnalyticsHub.js +0 -359
- package/src/components/Configuration.js +0 -392
- package/src/components/JobList.js +0 -1108
- package/src/components/JobTypes.js +0 -198
- package/src/components/PreviewFull.js +0 -33
- package/src/components/PreviewGrid.js +0 -29
- package/src/components/PreviewWidget.js +0 -35
- package/src/components/ViewFull.js +0 -25
- package/src/components/ViewWidget.js +0 -23
- package/src/feature.config.js +0 -127
- package/src/helper/index.js +0 -26
- package/src/images/forms/full.png +0 -0
- package/src/images/forms/fullNoTitle.png +0 -0
- package/src/images/forms/previewWidget.png +0 -0
- package/src/images/forms/widget.png +0 -0
- package/src/images/full.png +0 -0
- package/src/images/fullNoTitle.png +0 -0
- package/src/images/previewWidget.png +0 -0
- package/src/images/widget.png +0 -0
- package/src/index.js +0 -29
- package/src/maintenancePriority.json +0 -5
- package/src/maintenanceStatus.json +0 -20
- package/src/reducers/MaintenanceReducer.js +0 -49
- package/src/screens/AddJob.js +0 -1138
- package/src/screens/AddJobType.js +0 -865
- package/src/screens/Job.js +0 -1531
- package/src/screens/RequestsHub.js +0 -237
- package/src/values.config.a.js +0 -63
- package/src/values.config.default.js +0 -75
- package/src/values.config.enquiry.js +0 -76
- package/src/values.config.feedback.js +0 -74
- package/src/values.config.food.js +0 -74
- package/src/values.config.forms.js +0 -74
- package/src/values.config.js +0 -74
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import moment from "moment";
|
|
3
|
-
import {
|
|
4
|
-
faCircleCheck,
|
|
5
|
-
faComment,
|
|
6
|
-
faWrench,
|
|
7
|
-
} from "@fortawesome/free-solid-svg-icons";
|
|
8
|
-
import { connect } from "react-redux";
|
|
9
|
-
import { analyticsActions } from "../apis";
|
|
10
|
-
import { PlussCore } from "../feature.config";
|
|
11
|
-
import { values } from "../values.config";
|
|
12
|
-
|
|
13
|
-
const { Analytics, Session, Components, Helper, Colours } = PlussCore;
|
|
14
|
-
|
|
15
|
-
const getInitialState = () => ({
|
|
16
|
-
requests: 0,
|
|
17
|
-
prevRequests: 0,
|
|
18
|
-
completedRequests: 0,
|
|
19
|
-
prevCompletedRequests: 0,
|
|
20
|
-
comments: 0,
|
|
21
|
-
prevComments: 0,
|
|
22
|
-
isLoading: true,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// AnalyticsHub Component
|
|
26
|
-
const AnalyticsHub = ({
|
|
27
|
-
startTime,
|
|
28
|
-
endTime,
|
|
29
|
-
auth,
|
|
30
|
-
prevText,
|
|
31
|
-
dayCount,
|
|
32
|
-
strings,
|
|
33
|
-
userType,
|
|
34
|
-
userCategory,
|
|
35
|
-
selectedSites,
|
|
36
|
-
}) => {
|
|
37
|
-
const [analyticsData, setAnalyticsData] = useState(getInitialState());
|
|
38
|
-
const [isExportOpen, setIsExportOpen] = useState(false);
|
|
39
|
-
const [failedSites, setFailedSites] = useState([]);
|
|
40
|
-
const [comparisonData, setComparisonData] = useState({
|
|
41
|
-
requests: [],
|
|
42
|
-
completedRequests: [],
|
|
43
|
-
comments: [],
|
|
44
|
-
isLoading: true,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const comparisonMode = selectedSites && selectedSites.length > 1;
|
|
48
|
-
|
|
49
|
-
const hasAccess = Session.validateAccess(
|
|
50
|
-
auth.site,
|
|
51
|
-
values.permissionMaintenanceTracking,
|
|
52
|
-
auth,
|
|
53
|
-
);
|
|
54
|
-
if (!hasAccess) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const featureTitle = ((key) => {
|
|
59
|
-
if (!strings || !strings.sideNav || !strings.sideNav[key]) {
|
|
60
|
-
return values.textMenuTitle;
|
|
61
|
-
}
|
|
62
|
-
return strings.sideNav[key];
|
|
63
|
-
})();
|
|
64
|
-
|
|
65
|
-
const exportColumns = [
|
|
66
|
-
{ label: "Select All", key: "" },
|
|
67
|
-
...(comparisonMode ? [{ label: "Site", key: "site" }] : []),
|
|
68
|
-
{ label: "Start Date", key: "startDate" },
|
|
69
|
-
{ label: "End Date", key: "endDate" },
|
|
70
|
-
{ label: `${values.textSingularName}s`, key: "requests" },
|
|
71
|
-
{
|
|
72
|
-
label: `Completed ${values.textSingularName}s`,
|
|
73
|
-
key: "completedRequests",
|
|
74
|
-
},
|
|
75
|
-
{ label: "Comments", key: "comments" },
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
getData();
|
|
80
|
-
}, [startTime, endTime, userType, userCategory, selectedSites]);
|
|
81
|
-
|
|
82
|
-
const getData = async () => {
|
|
83
|
-
try {
|
|
84
|
-
if (comparisonMode) {
|
|
85
|
-
setComparisonData({
|
|
86
|
-
requests: [],
|
|
87
|
-
completedRequests: [],
|
|
88
|
-
comments: [],
|
|
89
|
-
isLoading: true,
|
|
90
|
-
});
|
|
91
|
-
const multiSiteResultsObj = await Analytics.fetchMultiSiteData(
|
|
92
|
-
selectedSites,
|
|
93
|
-
async (site) => {
|
|
94
|
-
const { data } = await analyticsActions.getAggregateEntityStats(
|
|
95
|
-
site,
|
|
96
|
-
values.analyticsKey,
|
|
97
|
-
startTime,
|
|
98
|
-
endTime,
|
|
99
|
-
true,
|
|
100
|
-
{ userType, userCategory },
|
|
101
|
-
);
|
|
102
|
-
return data;
|
|
103
|
-
},
|
|
104
|
-
);
|
|
105
|
-
const roles = auth.user.Roles;
|
|
106
|
-
const failed = Object.entries(multiSiteResultsObj)
|
|
107
|
-
.filter(([, data]) => data === null)
|
|
108
|
-
.map(([site]) => Helper.getSiteNameFromRoles(site, roles));
|
|
109
|
-
setFailedSites(failed);
|
|
110
|
-
const multiSiteResults = Object.entries(multiSiteResultsObj)
|
|
111
|
-
.filter(([, data]) => data !== null)
|
|
112
|
-
.map(([site, data]) => ({ site, data }));
|
|
113
|
-
const buildComparison = (activityKey, countType) =>
|
|
114
|
-
multiSiteResults.map((result) => ({
|
|
115
|
-
name: Helper.getSiteNameFromRoles(result.site, roles),
|
|
116
|
-
value: Analytics.countActivities(result.data, activityKey, countType),
|
|
117
|
-
}));
|
|
118
|
-
setComparisonData({
|
|
119
|
-
requests: buildComparison("Request", "total"),
|
|
120
|
-
completedRequests: buildComparison("RequestCompleted", "unique"),
|
|
121
|
-
comments: buildComparison("Comment", "total"),
|
|
122
|
-
isLoading: false,
|
|
123
|
-
});
|
|
124
|
-
} else {
|
|
125
|
-
setAnalyticsData(getInitialState());
|
|
126
|
-
const site =
|
|
127
|
-
selectedSites && selectedSites.length === 1
|
|
128
|
-
? selectedSites[0]
|
|
129
|
-
: auth.site;
|
|
130
|
-
const timeDifference = endTime - startTime;
|
|
131
|
-
const [currentStatsResponse, prevStatsResponse] = await Promise.all([
|
|
132
|
-
analyticsActions.getAggregateEntityStats(
|
|
133
|
-
site,
|
|
134
|
-
values.analyticsKey,
|
|
135
|
-
startTime,
|
|
136
|
-
endTime,
|
|
137
|
-
true,
|
|
138
|
-
{ userType, userCategory },
|
|
139
|
-
),
|
|
140
|
-
analyticsActions.getAggregateEntityStats(
|
|
141
|
-
site,
|
|
142
|
-
values.analyticsKey,
|
|
143
|
-
startTime - timeDifference,
|
|
144
|
-
startTime,
|
|
145
|
-
true,
|
|
146
|
-
{ userType, userCategory },
|
|
147
|
-
),
|
|
148
|
-
]);
|
|
149
|
-
|
|
150
|
-
const data = {
|
|
151
|
-
requests: Analytics.countActivities(
|
|
152
|
-
currentStatsResponse.data,
|
|
153
|
-
"Request",
|
|
154
|
-
"total",
|
|
155
|
-
),
|
|
156
|
-
prevRequests: Analytics.countActivities(
|
|
157
|
-
prevStatsResponse.data,
|
|
158
|
-
"Request",
|
|
159
|
-
"total",
|
|
160
|
-
),
|
|
161
|
-
completedRequests: Analytics.countActivities(
|
|
162
|
-
currentStatsResponse.data,
|
|
163
|
-
"RequestCompleted",
|
|
164
|
-
"unique",
|
|
165
|
-
),
|
|
166
|
-
prevCompletedRequests: Analytics.countActivities(
|
|
167
|
-
prevStatsResponse.data,
|
|
168
|
-
"RequestCompleted",
|
|
169
|
-
"unique",
|
|
170
|
-
),
|
|
171
|
-
comments: Analytics.countActivities(
|
|
172
|
-
currentStatsResponse.data,
|
|
173
|
-
"Comment",
|
|
174
|
-
"total",
|
|
175
|
-
),
|
|
176
|
-
prevComments: Analytics.countActivities(
|
|
177
|
-
prevStatsResponse.data,
|
|
178
|
-
"Comment",
|
|
179
|
-
"total",
|
|
180
|
-
),
|
|
181
|
-
isLoading: false,
|
|
182
|
-
};
|
|
183
|
-
setAnalyticsData(data);
|
|
184
|
-
}
|
|
185
|
-
} catch (err) {
|
|
186
|
-
if (comparisonMode) {
|
|
187
|
-
setComparisonData((prev) => ({ ...prev, isLoading: false }));
|
|
188
|
-
} else {
|
|
189
|
-
setAnalyticsData((prev) => ({ ...prev, isLoading: false }));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const isReadyToOpenCSV = () => {
|
|
195
|
-
return comparisonMode
|
|
196
|
-
? !comparisonData.isLoading
|
|
197
|
-
: !analyticsData.isLoading;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const getExportSource = () => {
|
|
201
|
-
if (comparisonMode) {
|
|
202
|
-
const sites = comparisonData.requests || [];
|
|
203
|
-
return sites.map((site, i) => ({
|
|
204
|
-
site: site.name,
|
|
205
|
-
startDate: moment(startTime + 1).format("D-MM-YYYY"),
|
|
206
|
-
endDate: moment(endTime).format("D-MM-YYYY"),
|
|
207
|
-
requests: site.value,
|
|
208
|
-
completedRequests:
|
|
209
|
-
(comparisonData.completedRequests[i] &&
|
|
210
|
-
comparisonData.completedRequests[i].value) ||
|
|
211
|
-
0,
|
|
212
|
-
comments:
|
|
213
|
-
(comparisonData.comments[i] && comparisonData.comments[i].value) || 0,
|
|
214
|
-
}));
|
|
215
|
-
}
|
|
216
|
-
return [
|
|
217
|
-
{
|
|
218
|
-
startDate: moment(startTime + 1).format("D-MM-YYYY"),
|
|
219
|
-
endDate: moment(endTime).format("D-MM-YYYY"),
|
|
220
|
-
requests: analyticsData.requests,
|
|
221
|
-
completedRequests: analyticsData.completedRequests,
|
|
222
|
-
comments: analyticsData.comments,
|
|
223
|
-
},
|
|
224
|
-
];
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const csvPopup = () => {
|
|
228
|
-
if (!isExportOpen) {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
const source = getExportSource();
|
|
232
|
-
const filterSuffix = [userType, userCategory]
|
|
233
|
-
.filter(Boolean)
|
|
234
|
-
.map((f) => f.toLowerCase().replace(/\s+/g, "-"))
|
|
235
|
-
.join("_");
|
|
236
|
-
return (
|
|
237
|
-
<Components.ExportCsvPopup
|
|
238
|
-
onClose={() => {
|
|
239
|
-
setIsExportOpen(false);
|
|
240
|
-
}}
|
|
241
|
-
columns={exportColumns}
|
|
242
|
-
source={source}
|
|
243
|
-
filename={`${values.analyticsKey}analytics${comparisonMode ? "_comparison" : ""}${filterSuffix ? `_${filterSuffix}` : ""}_${source[0].startDate}_${source[0].endDate}.csv`}
|
|
244
|
-
/>
|
|
245
|
-
);
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
return (
|
|
249
|
-
<div className="dashboardSection">
|
|
250
|
-
{csvPopup()}
|
|
251
|
-
<div>
|
|
252
|
-
<Components.Text type="h4" className="inlineBlock marginRight-40">
|
|
253
|
-
{featureTitle}
|
|
254
|
-
</Components.Text>
|
|
255
|
-
<Components.Button
|
|
256
|
-
inline
|
|
257
|
-
buttonType="primaryAction"
|
|
258
|
-
onClick={() => {
|
|
259
|
-
if (!isReadyToOpenCSV()) return;
|
|
260
|
-
setIsExportOpen(true);
|
|
261
|
-
}}
|
|
262
|
-
isActive={isReadyToOpenCSV()}
|
|
263
|
-
leftIcon="file-code-o"
|
|
264
|
-
>
|
|
265
|
-
Export CSV
|
|
266
|
-
</Components.Button>
|
|
267
|
-
</div>
|
|
268
|
-
{failedSites.length > 0 && (
|
|
269
|
-
<Components.Text type="help" style={{ color: Colours.COLOUR_RED }}>
|
|
270
|
-
Data unavailable for: {failedSites.join(", ")}
|
|
271
|
-
</Components.Text>
|
|
272
|
-
)}
|
|
273
|
-
<div className="analyticsSection dashboardSection_content">
|
|
274
|
-
{(() => {
|
|
275
|
-
const chartSuffix = [
|
|
276
|
-
selectedSites && selectedSites.length > 0
|
|
277
|
-
? `&sites=${selectedSites.join(",")}`
|
|
278
|
-
: "",
|
|
279
|
-
userType ? `&userType=${encodeURIComponent(userType)}` : "",
|
|
280
|
-
userCategory
|
|
281
|
-
? `&userCategory=${encodeURIComponent(userCategory)}`
|
|
282
|
-
: "",
|
|
283
|
-
].join("");
|
|
284
|
-
if (comparisonMode) {
|
|
285
|
-
return (
|
|
286
|
-
<div
|
|
287
|
-
style={{ display: "flex", flexDirection: "column", gap: 16 }}
|
|
288
|
-
>
|
|
289
|
-
<Components.ComparisonStatBox
|
|
290
|
-
title={`${featureTitle} Requests`}
|
|
291
|
-
data={comparisonData.requests}
|
|
292
|
-
prevText={prevText}
|
|
293
|
-
viewGraphLink={`/chart?entity=${values.analyticsKey}&startTime=${startTime}&endTime=${endTime}&key=Request&countType=total&dayCount=${dayCount}${chartSuffix}`}
|
|
294
|
-
isLoading={comparisonData.isLoading}
|
|
295
|
-
/>
|
|
296
|
-
<Components.ComparisonStatBox
|
|
297
|
-
title={`Completed ${featureTitle} Requests`}
|
|
298
|
-
data={comparisonData.completedRequests}
|
|
299
|
-
prevText={prevText}
|
|
300
|
-
viewGraphLink={`/chart?entity=${values.analyticsKey}&startTime=${startTime}&endTime=${endTime}&key=RequestCompleted&countType=unique&dayCount=${dayCount}${chartSuffix}`}
|
|
301
|
-
isLoading={comparisonData.isLoading}
|
|
302
|
-
/>
|
|
303
|
-
<Components.ComparisonStatBox
|
|
304
|
-
title={`${featureTitle} Comments`}
|
|
305
|
-
data={comparisonData.comments}
|
|
306
|
-
prevText={prevText}
|
|
307
|
-
viewGraphLink={`/chart?entity=${values.analyticsKey}&startTime=${startTime}&endTime=${endTime}&key=Comment&countType=total&dayCount=${dayCount}${chartSuffix}`}
|
|
308
|
-
isLoading={comparisonData.isLoading}
|
|
309
|
-
/>
|
|
310
|
-
</div>
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
return (
|
|
314
|
-
<>
|
|
315
|
-
<Components.StatBox
|
|
316
|
-
title={`${featureTitle} Requests`}
|
|
317
|
-
icon={faWrench}
|
|
318
|
-
value={analyticsData.requests}
|
|
319
|
-
previousValue={analyticsData.prevRequests}
|
|
320
|
-
prevText={prevText}
|
|
321
|
-
viewGraphLink={`/chart?entity=${values.analyticsKey}&startTime=${startTime}&endTime=${endTime}&key=Request&countType=total&dayCount=${dayCount}${chartSuffix}`}
|
|
322
|
-
isLoading={analyticsData.isLoading}
|
|
323
|
-
/>
|
|
324
|
-
<Components.StatBox
|
|
325
|
-
title={`Completed ${featureTitle} Requests`}
|
|
326
|
-
icon={faCircleCheck}
|
|
327
|
-
value={analyticsData.completedRequests}
|
|
328
|
-
previousValue={analyticsData.prevCompletedRequests}
|
|
329
|
-
prevText={prevText}
|
|
330
|
-
viewGraphLink={`/chart?entity=${values.analyticsKey}&startTime=${startTime}&endTime=${endTime}&key=RequestCompleted&countType=unique&dayCount=${dayCount}${chartSuffix}`}
|
|
331
|
-
isLoading={analyticsData.isLoading}
|
|
332
|
-
/>
|
|
333
|
-
<Components.StatBox
|
|
334
|
-
title={`${featureTitle} Comments`}
|
|
335
|
-
icon={faComment}
|
|
336
|
-
value={analyticsData.comments}
|
|
337
|
-
previousValue={analyticsData.prevComments}
|
|
338
|
-
prevText={prevText}
|
|
339
|
-
viewGraphLink={`/chart?entity=${values.analyticsKey}&startTime=${startTime}&endTime=${endTime}&key=Comment&countType=total&dayCount=${dayCount}${chartSuffix}`}
|
|
340
|
-
isLoading={analyticsData.isLoading}
|
|
341
|
-
/>
|
|
342
|
-
</>
|
|
343
|
-
);
|
|
344
|
-
})()}
|
|
345
|
-
</div>
|
|
346
|
-
</div>
|
|
347
|
-
);
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
const mapStateToProps = (state) => {
|
|
351
|
-
const { auth } = state;
|
|
352
|
-
return {
|
|
353
|
-
auth,
|
|
354
|
-
strings: (state.strings && state.strings.config) || {},
|
|
355
|
-
};
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
const toExport = connect(mapStateToProps, {})(AnalyticsHub);
|
|
359
|
-
export { toExport as AnalyticsHub };
|