@zeesoft/i18n-verify 2.0.1 → 2.1.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.
Files changed (38) hide show
  1. package/dist/driver/adapters/cypress.js +2 -1
  2. package/dist/driver/adapters/nightwatch.js +43 -2
  3. package/dist/driver/baseDriver.js +24 -0
  4. package/dist/index.js +10 -5
  5. package/dist/lib/i18n.js +126 -44
  6. package/dist/{utils → lib}/reports.js +42 -27
  7. package/dist/lib/validator/string.js +2 -2
  8. package/dist/template/report.html +1678 -0
  9. package/dist/utils/cache.js +15 -15
  10. package/dist/utils/constants.js +8 -5
  11. package/dist/utils/file.js +8 -4
  12. package/dist/utils/{2Dgraphic.js → graphic.js} +1 -1
  13. package/dist/utils/logs.js +30 -11
  14. package/dist/utils/objects/cacheData.js +14 -33
  15. package/dist/utils/objects/metaData.js +7 -26
  16. package/dist/utils/objects/reportData.js +0 -18
  17. package/dist/utils/objects/statData.js +43 -28
  18. package/dist/utils/objects/stringData.js +4 -7
  19. package/dist/utils/reportFactory/base.js +15 -7
  20. package/dist/utils/reportFactory/html/index.js +13 -9
  21. package/dist/utils/reportFactory/html/template/body.js +110 -0
  22. package/dist/utils/reportFactory/html/template/css.js +446 -409
  23. package/dist/utils/reportFactory/html/template/html.js +15 -112
  24. package/dist/utils/reportFactory/html/template/javascript/data.js +59 -1
  25. package/dist/utils/reportFactory/html/template/javascript/global.js +19 -0
  26. package/dist/utils/reportFactory/html/template/javascript/grid.js +54 -80
  27. package/dist/utils/reportFactory/html/template/javascript/index.js +7 -7
  28. package/dist/utils/reportFactory/html/template/javascript/insight.js +226 -201
  29. package/dist/utils/reportFactory/html/template/javascript/menuBar.js +40 -35
  30. package/dist/utils/reportFactory/html/template/javascript/overview.js +725 -533
  31. package/dist/utils/reportFactory/index.js +4 -6
  32. package/dist/utils/reportFactory/table.js +95 -0
  33. package/dist/utils/resource.js +10 -6
  34. package/dist/utils/runtime.js +23 -3
  35. package/dist/utils/scripts/postinstall.js +3 -2
  36. package/package.json +8 -3
  37. package/types/index.d.ts +46 -0
  38. package/dist/utils/reportsTable.js +0 -71
@@ -4,334 +4,429 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = () => `
8
- //Overview
9
- (() => {
10
- document.addEventListener("DOMContentLoaded", function () {
11
- let overviewChart,
12
- stringChart,
13
- dateTimeChart,
14
- numberChart,
15
- ignoredChart;
7
+ var _default = () => `//overview content
8
+ (() => {
9
+ if (!DataStore.ranSuccessfully()) {
10
+ document.getElementById('overview').innerHtml =
11
+ 'Unable to prepare zQA automation report for the project.';
12
+ return;
13
+ }
16
14
 
17
- window.persistOverviewCharts = () => {
18
- const reset = (chart) => {
19
- chart.resetSeries(true, true);
20
- };
15
+ document.addEventListener('DOMContentLoaded', function () {
16
+ let overviewChart,
17
+ stringChart,
18
+ dateTimeChart,
19
+ numberChart,
20
+ ignoredChart;
21
21
 
22
- reset(overviewChart);
23
- reset(stringChart);
24
- reset(dateTimeChart);
25
- reset(numberChart);
26
- reset(ignoredChart);
22
+ window.persistOverviewCharts = () => {
23
+ const reset = (chart) => {
24
+ chart.resetSeries(true, true);
27
25
  };
28
26
 
29
- renderOverallChart();
30
- renderStringChart();
31
- renderIgnoredChart();
32
- renderNumberChart();
33
- renderDatetimeChart();
27
+ reset(overviewChart);
28
+ reset(stringChart);
29
+ reset(dateTimeChart);
30
+ reset(numberChart);
31
+ reset(ignoredChart);
32
+ };
33
+
34
+ renderOverallChart();
35
+ renderStringChart();
36
+ renderIgnoredChart();
37
+ renderNumberChart();
38
+ renderDatetimeChart();
39
+
40
+ function renderOverallChart() {
41
+ const overallStats = DataStore.getOverallStats();
42
+ const reviewed = overallStats.reviewed;
43
+ const locales = DataStore.getLocales().length;
44
+ const type = {
45
+ I18NED: 'Internationalized',
46
+ NOT_I18NED: 'Not Internationalized',
47
+ SKIPPED: 'Skipped'
48
+ },
49
+ valueMap = {
50
+ [type.I18NED]:
51
+ overallStats.localizedStrings +
52
+ overallStats.partialStrings + // TODO: need to confirm
53
+ overallStats.untranslatedStrings +
54
+ overallStats.localizedDateTime +
55
+ overallStats.localizedDate +
56
+ overallStats.localizedTime +
57
+ overallStats.localizedNumber +
58
+ overallStats.localizedCurrency +
59
+ overallStats.localizedPercentage,
60
+ [type.NOT_I18NED]:
61
+ overallStats.notLocalizedStrings +
62
+ overallStats.notLocalizedDateTime +
63
+ overallStats.notLocalizedDate +
64
+ overallStats.notLocalizedTime +
65
+ overallStats.notLocalizedNumber +
66
+ overallStats.notLocalizedCurrency +
67
+ overallStats.notLocalizedPercentage,
68
+ [type.SKIPPED]:
69
+ overallStats.dnt +
70
+ overallStats.ignored +
71
+ overallStats.autoIgnored +
72
+ overallStats.userInput
73
+ },
74
+ percentageCalc = (value) => {
75
+ const val = ((value / reviewed) * 100).toFixed(0);
76
+ return isNaN(val) || !isFinite(val) ? 0 : val;
77
+ };
34
78
 
35
- function renderOverallChart() {
36
- const reviewed = 2000;
37
- const locales = 2;
38
- const type = {
39
- I18NED: "Internationalized",
40
- NOT_I18NED: "Not Internationalized",
41
- SKIPPED: "Skipped",
79
+ var options = {
80
+ series: [
81
+ {
82
+ name: '',
83
+ data: [
84
+ percentageCalc(valueMap[type.I18NED]),
85
+ percentageCalc(valueMap[type.NOT_I18NED]),
86
+ percentageCalc(valueMap[type.SKIPPED])
87
+ ]
88
+ }
89
+ ],
90
+ chart: {
91
+ type: 'bar',
92
+ height: 200,
93
+ toolbar: {
94
+ show: false
95
+ },
96
+ animations: {
97
+ enabled: true,
98
+ easing: 'easeinout',
99
+ speed: 800,
100
+ animateGradually: {
101
+ enabled: true,
102
+ delay: 150
103
+ },
104
+ dynamicAnimation: {
105
+ enabled: true,
106
+ speed: 350
107
+ }
108
+ }
109
+ },
110
+ plotOptions: {
111
+ bar: {
112
+ horizontal: true,
113
+ borderRadius: 3,
114
+ dataLabels: {
115
+ position: 'right'
116
+ }
117
+ }
118
+ },
119
+ title: {
120
+ text: \`Total Reviewed strings in \${locales} locales: \${reviewed}\`,
121
+ align: 'center',
122
+ floating: true,
123
+ style: {
124
+ fontSize: '14px',
125
+ fontWeight: 'bold'
126
+ }
127
+ },
128
+ dataLabels: {
129
+ enabled: true,
130
+ style: {
131
+ colors: ['#080404b0']
42
132
  },
43
- valueMap = {
44
- [type.I18NED]: 1500,
45
- [type.NOT_I18NED]: 400,
46
- [type.SKIPPED]: 100,
133
+ formatter: (val) => {
134
+ return \`\${val}%\`;
135
+ }
136
+ },
137
+ xaxis: {
138
+ categories: [type.I18NED, type.NOT_I18NED, type.SKIPPED],
139
+ min: 0,
140
+ max: 100,
141
+ labels: {
142
+ formatter: (v) => \`\${v}%\`
143
+ }
144
+ },
145
+ yaxis: {
146
+ labels: {
147
+ style: {
148
+ fontSize: '13px'
149
+ }
150
+ }
151
+ },
152
+ colors: [
153
+ (v) => {
154
+ switch (v.dataPointIndex) {
155
+ case 0:
156
+ return '#31E994'; //green
157
+ case 1:
158
+ return '#ff8173'; //red
159
+ case 2:
160
+ return '#f5eb5f'; //yellow
161
+ }
162
+ }
163
+ ],
164
+ tooltip: {
165
+ theme: 'dark',
166
+ x: {
167
+ formatter: (v) => \`Total Number of \${v} instances:\`
47
168
  },
48
- percentageCalc = (value) => ((value / reviewed) * 100).toFixed(0);
169
+ y: {
170
+ formatter: function (v, { dataPointIndex }) {
171
+ let count = 0;
172
+ switch (dataPointIndex) {
173
+ case 0:
174
+ count = valueMap[type.I18NED];
175
+ break;
176
+ case 1:
177
+ count = valueMap[type.NOT_I18NED];
178
+ break;
179
+ case 2:
180
+ count = valueMap[type.SKIPPED];
181
+ break;
182
+ }
183
+ return \`\${v}% (\${count} strings)\`;
184
+ }
185
+ }
186
+ }
187
+ };
49
188
 
50
- var options = {
51
- series: [
52
- {
53
- name: "",
54
- data: [
55
- percentageCalc(valueMap[type.I18NED]),
56
- percentageCalc(valueMap[type.NOT_I18NED]),
57
- percentageCalc(valueMap[type.SKIPPED]),
58
- ],
59
- },
60
- ],
189
+ (overviewChart = new ApexCharts(
190
+ document.querySelector('.overall-quality .graph'),
191
+ options
192
+ )).render();
193
+ }
194
+
195
+ function renderStringChart() {
196
+ const overallStats = DataStore.getOverallStats();
197
+ const type = {
198
+ LOCALIZED: 'Localized',
199
+ PARTIAL: 'Partially Localized',
200
+ NOT_LOCALIZED: 'Not Localized',
201
+ UNTRANSLATED: 'Untranslated',
202
+ ENCODING: 'Encoding Issue',
203
+ IGNORED: 'Ignored'
204
+ },
205
+ valueMap = {
206
+ [type.LOCALIZED]: overallStats.localizedStrings,
207
+ [type.PARTIAL]: overallStats.partialStrings,
208
+ [type.NOT_LOCALIZED]: overallStats.notLocalizedStrings,
209
+ [type.UNTRANSLATED]: overallStats.untranslatedStrings,
210
+ [type.ENCODING]: overallStats.encoding,
211
+ [type.IGNORED]:
212
+ overallStats.dnt +
213
+ overallStats.ignored +
214
+ overallStats.autoIgnored +
215
+ overallStats.userInput
216
+ },
217
+ total = Object.values(valueMap).reduce(
218
+ (acc, curr) => acc + curr,
219
+ 0
220
+ ),
221
+ data = [
222
+ valueMap[type.LOCALIZED],
223
+ valueMap[type.PARTIAL],
224
+ valueMap[type.NOT_LOCALIZED],
225
+ valueMap[type.IGNORED],
226
+ valueMap[type.ENCODING],
227
+ valueMap[type.UNTRANSLATED]
228
+ ],
229
+ options = {
230
+ series:
231
+ data.reduce((acc, curr) => acc + curr, 0) === 0 ? [] : data,
61
232
  chart: {
62
- type: "bar",
63
- height: 200,
64
- toolbar: {
65
- show: false,
66
- },
233
+ width: 415,
234
+ type: 'pie',
67
235
  animations: {
68
236
  enabled: true,
69
- easing: "easeinout",
237
+ easing: 'easeinout',
70
238
  speed: 800,
71
239
  animateGradually: {
72
240
  enabled: true,
73
- delay: 150,
241
+ delay: 150
74
242
  },
75
243
  dynamicAnimation: {
76
244
  enabled: true,
77
- speed: 350,
78
- },
79
- },
80
- },
81
- plotOptions: {
82
- bar: {
83
- horizontal: true,
84
- borderRadius: 3,
85
- dataLabels: {
86
- position: "right",
87
- },
88
- },
89
- },
90
- title: {
91
- text: \`Total Reviewed strings in \${locales} locales: \${reviewed}\`,
92
- align: "center",
93
- floating: true,
94
- style: {
95
- fontSize: "14px",
96
- fontWeight: "bold",
97
- },
245
+ speed: 350
246
+ }
247
+ }
98
248
  },
99
- dataLabels: {
100
- enabled: true,
249
+ noData: {
250
+ text: 'No metrics available',
251
+ align: 'left',
252
+ verticalAlign: 'middle',
253
+ offsetX: 0,
254
+ offsetY: -50,
101
255
  style: {
102
- colors: ["#080404b0"],
103
- },
104
- formatter: (val) => {
105
- return \`\${val}%\`;
106
- },
107
- },
108
- xaxis: {
109
- categories: [type.I18NED, type.NOT_I18NED, type.SKIPPED],
110
- min: 0,
111
- max: 100,
112
- labels: {
113
- formatter: (v) => \`\${v}%\`,
114
- },
256
+ fontSize: '14px'
257
+ }
115
258
  },
116
- yaxis: {
117
- labels: {
118
- style: {
119
- fontSize: "13px",
120
- },
121
- },
122
- },
123
- colors: [
124
- (v) => {
125
- switch (v.dataPointIndex) {
126
- case 0:
127
- return "#31E994"; //green
128
- case 1:
129
- return "#ff8173"; //red
130
- case 2:
131
- return "#f5eb5f"; //yellow
132
- }
133
- },
259
+ labels: [
260
+ type.LOCALIZED,
261
+ type.PARTIAL,
262
+ type.NOT_LOCALIZED,
263
+ type.IGNORED,
264
+ type.ENCODING,
265
+ type.UNTRANSLATED
134
266
  ],
135
267
  tooltip: {
136
- theme: "dark",
137
- x: {
138
- formatter: function (v) {
139
- switch (v) {
140
- case type.NOT_I18NED:
141
- return \`Total Number of \${v}, Partially Localized and Encoding issue instances\`;
142
-
143
- default:
144
- return \`Total Number of \${v} instances\`;
145
- }
146
- },
147
- },
268
+ theme: 'dark',
148
269
  y: {
149
- formatter: function (v) {
150
- return \`\${v}%\`;
151
- },
152
- },
153
- },
154
- };
155
-
156
- (overviewChart = new ApexCharts(
157
- document.querySelector(".overall-quality .graph"),
158
- options
159
- )).render();
160
- }
161
-
162
- function renderStringChart() {
163
- const type = {
164
- LOCALIZED: "Localized",
165
- PARTIAL: "Partially Localized",
166
- NOT_LOCALIZED: "Not Localized",
167
- UNTRANSLATED: "Untranslated",
168
- ENCODING: "Encoding Issue",
169
- IGNORED: "Ignored",
170
- },
171
- valueMap = {
172
- [type.LOCALIZED]: 8000,
173
- [type.PARTIAL]: 1200,
174
- [type.NOT_LOCALIZED]: 300,
175
- [type.UNTRANSLATED]: 500,
176
- [type.ENCODING]: 250,
177
- [type.IGNORED]: 250,
178
- },
179
- total = Object.values(valueMap).reduce(
180
- (acc, curr) => acc + curr,
181
- 0
182
- ),
183
- options = {
184
- series: [
185
- valueMap[type.LOCALIZED],
186
- valueMap[type.PARTIAL],
187
- valueMap[type.NOT_LOCALIZED],
188
- valueMap[type.IGNORED],
189
- valueMap[type.ENCODING],
190
- valueMap[type.UNTRANSLATED],
191
- ],
192
- chart: {
193
- width: 430,
194
- type: "pie",
195
- animations: {
196
- enabled: true,
197
- easing: "easeinout",
198
- speed: 800,
199
- animateGradually: {
200
- enabled: true,
201
- delay: 150,
202
- },
203
- dynamicAnimation: {
204
- enabled: true,
205
- speed: 350,
206
- },
207
- },
208
- },
209
- labels: [
210
- type.LOCALIZED,
211
- type.PARTIAL,
212
- type.NOT_LOCALIZED,
213
- type.IGNORED,
214
- type.ENCODING,
215
- type.UNTRANSLATED,
216
- ],
217
- tooltip: {
218
- theme: "dark",
219
- y: {
220
- formatter: function (v, { config }) {
221
- return \`\${Number(
270
+ formatter: function (v, { config, dataPointIndex }) {
271
+ let count = 0,
272
+ value = Number(
222
273
  (v /
223
274
  config.series.reduce((acc, curr) => acc + curr, 0)) *
224
275
  100
225
- ).toFixed(0)}%\`;
226
- },
227
- title: {
228
- formatter: function (a) {
229
- return \`Total Number of \${a} strings including all locales\`;
230
- },
231
- },
232
- },
233
- },
234
- colors: [
235
- ({ seriesIndex, w }) => {
236
- const currType = w.config.labels[seriesIndex];
237
-
238
- switch (currType) {
239
- case type.LOCALIZED:
240
- return "#31E994";
241
- case type.NOT_LOCALIZED:
242
- return "#E44242";
243
- case type.PARTIAL:
244
- return "#DADF40";
245
- case type.UNTRANSLATED:
246
- return "#4C57EC";
247
- case type.IGNORED:
248
- return "#AFA6AB";
249
- case type.ENCODING:
250
- return "#F44E9E";
276
+ ).toFixed(0);
277
+ value = isNaN(value) || !isFinite(value) ? 0 : value;
251
278
 
252
- default:
253
- return "";
279
+ switch (dataPointIndex) {
280
+ case 0:
281
+ count = valueMap[type.LOCALIZED];
282
+ break;
283
+ case 1:
284
+ count = valueMap[type.PARTIAL];
285
+ break;
286
+ case 2:
287
+ count = valueMap[type.NOT_LOCALIZED];
288
+ break;
289
+ case 3:
290
+ count = valueMap[type.IGNORED];
291
+ break;
292
+ case 4:
293
+ count = valueMap[type.ENCODING];
294
+ break;
295
+ case 5:
296
+ count = valueMap[type.UNTRANSLATED];
297
+ break;
254
298
  }
299
+
300
+ return \`\${value}% (\${count} strings)\`;
255
301
  },
256
- ],
257
- legend: {
258
- offsetX: -50,
259
- width: 170,
260
- formatter: (seriesName, a, b, c) =>
261
- \`\${seriesName} (\${(
262
- (valueMap[seriesName] / total) *
263
- 100
264
- ).toFixed(0)}%)\`,
265
- },
266
- dataLabels: {
267
- formatter: (v) => \`\${Number(v).toFixed(0)}%\`,
268
- dropShadow: { enabled: false },
269
- style: {
270
- colors: ["#080404b0"],
271
- },
272
- },
273
- };
302
+ title: {
303
+ formatter: function (a) {
304
+ return \`Total Number of \${a} strings:\`;
305
+ }
306
+ }
307
+ }
308
+ },
309
+ colors: [
310
+ ({ seriesIndex, w }) => {
311
+ const currType = w.config.labels[seriesIndex];
274
312
 
275
- (stringChart = new ApexCharts(
276
- document.querySelector(".string-quality .graph"),
277
- options
278
- )).render();
279
- }
313
+ switch (currType) {
314
+ case type.LOCALIZED:
315
+ return '#31E994';
316
+ case type.NOT_LOCALIZED:
317
+ return '#E44242';
318
+ case type.PARTIAL:
319
+ return '#DADF40';
320
+ case type.UNTRANSLATED:
321
+ return '#F44E9E';
322
+ case type.IGNORED:
323
+ return '#AFA6AB';
324
+ case type.ENCODING:
325
+ return '#3AD1F3';
280
326
 
281
- function renderIgnoredChart() {
282
- const type = {
283
- DNT: "DNT",
284
- IGNORED: "Ignored",
285
- AUTO_IGNORED: "User Inputs",
286
- },
287
- valueMap = {
288
- [type.DNT]: 50,
289
- [type.IGNORED]: 10,
290
- [type.AUTO_IGNORED]: 137,
327
+ default:
328
+ return '';
329
+ }
330
+ }
331
+ ],
332
+ legend: {
333
+ offsetX: -50,
334
+ width: 170,
335
+ formatter: (seriesName, a, b, c) => {
336
+ let value = ((valueMap[seriesName] / total) * 100).toFixed(0);
337
+ value = isNaN(value) || !isFinite(value) ? 0 : value;
338
+ return \`\${seriesName} (\${value}%)\`;
339
+ }
291
340
  },
292
- total = Object.values(valueMap).reduce(
293
- (acc, curr) => acc + curr,
294
- 0
295
- );
341
+ dataLabels: {
342
+ formatter: (v) => \`\${Number(v).toFixed(0)}%\`,
343
+ dropShadow: { enabled: false },
344
+ style: {
345
+ colors: ['#080404b0']
346
+ }
347
+ }
348
+ };
349
+
350
+ (stringChart = new ApexCharts(
351
+ document.querySelector('.string-quality .graph'),
352
+ options
353
+ )).render();
354
+ }
355
+
356
+ function renderIgnoredChart() {
357
+ const overallStats = DataStore.getOverallStats();
358
+ const type = {
359
+ DNT: 'DNT',
360
+ IGNORED: 'Ignored',
361
+ USER_INPUTS: 'User Inputs'
362
+ },
363
+ valueMap = {
364
+ [type.DNT]: overallStats.dnt,
365
+ [type.IGNORED]: overallStats.ignored + overallStats.autoIgnored,
366
+ [type.USER_INPUTS]: overallStats.userInput
367
+ },
368
+ total = Object.values(valueMap).reduce(
369
+ (acc, curr) => acc + curr,
370
+ 0
371
+ ),
372
+ data = [
373
+ valueMap[type.DNT],
374
+ valueMap[type.IGNORED],
375
+ valueMap[type.USER_INPUTS]
376
+ ],
296
377
  options = {
297
- series: [
298
- valueMap[type.DNT],
299
- valueMap[type.IGNORED],
300
- valueMap[type.AUTO_IGNORED],
301
- ],
378
+ series:
379
+ data.reduce((acc, curr) => acc + curr, 0) === 0 ? [] : data,
302
380
  chart: {
303
- width: 385,
304
- type: "pie",
381
+ width: 360,
382
+ type: 'pie',
305
383
  animations: {
306
384
  enabled: true,
307
- easing: "easeinout",
385
+ easing: 'easeinout',
308
386
  speed: 800,
309
387
  animateGradually: {
310
388
  enabled: true,
311
- delay: 150,
389
+ delay: 150
312
390
  },
313
391
  dynamicAnimation: {
314
392
  enabled: true,
315
- speed: 350,
316
- },
317
- },
393
+ speed: 350
394
+ }
395
+ }
318
396
  },
319
- labels: [type.DNT, type.IGNORED, type.AUTO_IGNORED],
397
+ labels: [type.DNT, type.IGNORED, type.USER_INPUTS],
320
398
  tooltip: {
321
- theme: "dark",
399
+ theme: 'dark',
322
400
  y: {
323
- formatter: function (v, { config }) {
324
- return \`\${Number(
325
- (v / config.series.reduce((acc, curr) => acc + curr, 0)) *
326
- 100
327
- ).toFixed(0)}%\`;
401
+ formatter: function (v, { config, dataPointIndex }) {
402
+ let count = 0,
403
+ value = Number(
404
+ (v /
405
+ config.series.reduce((acc, curr) => acc + curr, 0)) *
406
+ 100
407
+ ).toFixed(0);
408
+ value = isNaN(value) || !isFinite(value) ? 0 : value;
409
+
410
+ switch (dataPointIndex) {
411
+ case 0:
412
+ count = valueMap[type.DNT];
413
+ break;
414
+ case 1:
415
+ count = valueMap[type.IGNORED];
416
+ break;
417
+ case 2:
418
+ count = valueMap[type.USER_INPUTS];
419
+ break;
420
+ }
421
+
422
+ return \`\${value}% (\${count} strings)\`;
328
423
  },
329
424
  title: {
330
425
  formatter: function (a) {
331
- return \`Total Number of localized \${a} instances including all locales\`;
332
- },
333
- },
334
- },
426
+ return \`Total Number of \${a} strings:\`;
427
+ }
428
+ }
429
+ }
335
430
  },
336
431
  colors: [
337
432
  ({ seriesIndex, w }) => {
@@ -339,288 +434,385 @@ var _default = () => `
339
434
 
340
435
  switch (currType) {
341
436
  case type.DNT:
342
- return "#31E994";
437
+ return '#31E994';
343
438
  case type.IGNORED:
344
- return "#3AD1F3";
345
- case type.AUTO_IGNORED:
346
- return "#DADF40";
439
+ return '#3AD1F3';
440
+ case type.USER_INPUTS:
441
+ return '#DADF40';
347
442
 
348
443
  default:
349
- return "";
444
+ return '';
350
445
  }
351
- },
446
+ }
352
447
  ],
448
+ noData: {
449
+ text: 'No metrics available',
450
+ align: 'center',
451
+ verticalAlign: 'middle',
452
+ offsetX: -70,
453
+ offsetY: -25,
454
+ style: {
455
+ fontSize: '14px'
456
+ }
457
+ },
353
458
  legend: {
354
459
  offsetX: -40,
355
- formatter: (seriesName) =>
356
- \`\${seriesName} (\${(
357
- (valueMap[seriesName] / total) *
358
- 100
359
- ).toFixed(0)}%)\`,
460
+ formatter: (seriesName) => {
461
+ let value = ((valueMap[seriesName] / total) * 100).toFixed(0);
462
+ value = isNaN(value) || !isFinite(value) ? 0 : value;
463
+ return \`\${seriesName} (\${value}%)\`;
464
+ }
360
465
  },
361
466
  dataLabels: {
362
467
  formatter: (v) => \`\${Number(v).toFixed(0)}%\`,
363
468
  style: {
364
- colors: ["#080404b0"],
469
+ colors: ['#080404b0']
365
470
  },
366
- dropShadow: { enabled: false },
367
- },
471
+ dropShadow: { enabled: false }
472
+ }
368
473
  };
369
474
 
370
- (ignoredChart = new ApexCharts(
371
- document.querySelector(".skipped-items .graph"),
372
- options
373
- )).render();
374
- }
475
+ (ignoredChart = new ApexCharts(
476
+ document.querySelector('.skipped-items .graph'),
477
+ options
478
+ )).render();
479
+ }
375
480
 
376
- function renderNumberChart() {
377
- const types = ["Number", "Currency", "Percentage"],
378
- data = {
379
- number_i18n: 25,
380
- currency_i18n: 10,
381
- percentage_i18n: 4,
382
- number_not_i18n: 10,
383
- currency_not_i18n: 3,
384
- percentage_not_i18n: 7,
385
- },
386
- total = Object.values(data).reduce((acc, curr) => acc + curr, 0),
387
- percentageCalc = (v, t) => ((v / t) * 100).toFixed(0),
388
- i18nPercentage = percentageCalc(
389
- data.number_i18n + data.percentage_i18n + data.currency_i18n,
390
- total
391
- ),
392
- nonI18nPercentage = percentageCalc(
393
- data.number_not_i18n +
394
- data.percentage_not_i18n +
395
- data.currency_not_i18n,
396
- total
397
- ),
398
- numberTotal = data.number_i18n + data.number_not_i18n,
399
- currencyTotal = data.currency_i18n + data.currency_not_i18n,
400
- percentageTotal = data.percentage_i18n + data.percentage_not_i18n,
401
- numberI18n = percentageCalc(data.number_i18n, numberTotal),
402
- currencyI18n = percentageCalc(data.currency_i18n, currencyTotal),
403
- percentageI18n = percentageCalc(
404
- data.percentage_i18n,
405
- currencyTotal
406
- ),
407
- numberNotI18n = percentageCalc(data.number_not_i18n, numberTotal),
408
- currencyNotI18n = percentageCalc(
481
+ function renderNumberChart() {
482
+ const overallStats = DataStore.getOverallStats();
483
+ const types = ['Number', 'Currency', 'Percentage'],
484
+ data = {
485
+ number_i18n: overallStats.localizedNumber,
486
+ currency_i18n: overallStats.localizedCurrency,
487
+ percentage_i18n: overallStats.localizedPercentage,
488
+ number_not_i18n: overallStats.notLocalizedNumber,
489
+ currency_not_i18n: overallStats.notLocalizedCurrency,
490
+ percentage_not_i18n: overallStats.notLocalizedPercentage
491
+ },
492
+ total = Object.values(data).reduce((acc, curr) => acc + curr, 0),
493
+ percentageCalc = (v, t) => {
494
+ const val = ((v / t) * 100).toFixed(0);
495
+ return isNaN(val) || !isFinite(val) ? 0 : val;
496
+ },
497
+ i18nPercentage = percentageCalc(
498
+ data.number_i18n + data.percentage_i18n + data.currency_i18n,
499
+ total
500
+ ),
501
+ nonI18nPercentage = percentageCalc(
502
+ data.number_not_i18n +
503
+ data.percentage_not_i18n +
409
504
  data.currency_not_i18n,
410
- currencyTotal
411
- ),
412
- percentageNotI18n = percentageCalc(
413
- data.percentage_not_i18n,
414
- currencyTotal
415
- ),
416
- options = {
417
- series: [
418
- {
419
- name: "Internationalized",
420
- data: [numberI18n, currencyI18n, percentageI18n],
421
- },
422
- {
423
- name: "Not Internationalized",
424
- data: [numberNotI18n, currencyNotI18n, percentageNotI18n],
425
- },
426
- ],
427
- chart: {
428
- type: "bar",
429
- height: 220,
430
- width: 500,
431
- toolbar: {
432
- show: false,
433
- },
434
- animations: {
435
- enabled: true,
436
- easing: "easeinout",
437
- speed: 800,
438
- animateGradually: {
439
- enabled: true,
440
- delay: 150,
441
- },
442
- dynamicAnimation: {
443
- enabled: true,
444
- speed: 350,
445
- },
446
- },
505
+ total
506
+ ),
507
+ numberTotal = data.number_i18n + data.number_not_i18n,
508
+ currencyTotal = data.currency_i18n + data.currency_not_i18n,
509
+ percentageTotal = data.percentage_i18n + data.percentage_not_i18n,
510
+ numberI18n = percentageCalc(data.number_i18n, numberTotal),
511
+ currencyI18n = percentageCalc(data.currency_i18n, currencyTotal),
512
+ percentageI18n = percentageCalc(
513
+ data.percentage_i18n,
514
+ currencyTotal
515
+ ),
516
+ numberNotI18n = percentageCalc(data.number_not_i18n, numberTotal),
517
+ currencyNotI18n = percentageCalc(
518
+ data.currency_not_i18n,
519
+ currencyTotal
520
+ ),
521
+ percentageNotI18n = percentageCalc(
522
+ data.percentage_not_i18n,
523
+ currencyTotal
524
+ ),
525
+ options = {
526
+ series: [
527
+ {
528
+ name: 'Internationalized',
529
+ data: [numberI18n, currencyI18n, percentageI18n]
447
530
  },
448
- dataLabels: {
531
+ {
532
+ name: 'Not Internationalized',
533
+ data: [numberNotI18n, currencyNotI18n, percentageNotI18n]
534
+ }
535
+ ],
536
+ chart: {
537
+ type: 'bar',
538
+ height: 220,
539
+ width: 500,
540
+ toolbar: {
541
+ show: false
542
+ },
543
+ animations: {
449
544
  enabled: true,
450
- dropShadow: { enabled: false },
451
- style: {
452
- colors: ["#080404b0"],
453
- },
454
- formatter: (val) => {
455
- return \`\${val}%\`;
545
+ easing: 'easeinout',
546
+ speed: 800,
547
+ animateGradually: {
548
+ enabled: true,
549
+ delay: 150
456
550
  },
551
+ dynamicAnimation: {
552
+ enabled: true,
553
+ speed: 350
554
+ }
555
+ }
556
+ },
557
+ dataLabels: {
558
+ enabled: true,
559
+ dropShadow: { enabled: false },
560
+ style: {
561
+ colors: ['#080404b0']
457
562
  },
458
- stroke: {
459
- show: true,
460
- width: 1,
461
- colors: ["#fff"],
462
- },
463
- tooltip: {
464
- theme: "dark",
465
- shared: true,
466
- intersect: false,
467
- },
468
- xaxis: {
469
- categories: types,
470
- },
471
- yaxis: {
472
- min: 0,
473
- max: 100,
474
- labels: {
475
- formatter: (v) => \`\${v}%\`,
476
- },
563
+ formatter: (val) => {
564
+ return \`\${val}%\`;
565
+ }
566
+ },
567
+ stroke: {
568
+ show: true,
569
+ width: 1,
570
+ colors: ['#fff']
571
+ },
572
+ tooltip: {
573
+ theme: 'dark',
574
+ shared: true,
575
+ intersect: false,
576
+ x: {
577
+ formatter: (type) => \`\${type} instances:\`
477
578
  },
478
- colors: ["#31E994", "#ff8173"],
479
- legend: {
480
- offsetX: -13,
481
- position: "right",
482
- formatter: (seriesName) => {
483
- if (seriesName === "Internationalized") {
484
- return \`\${seriesName} (\${i18nPercentage}%)\`;
579
+ y: {
580
+ formatter: (v, { seriesIndex, dataPointIndex }) => {
581
+ const getI18nCount = (type) => {
582
+ switch (type) {
583
+ case 'number':
584
+ return data.number_i18n;
585
+ case 'currency':
586
+ return data.currency_i18n;
587
+ case 'percentage':
588
+ return data.percentage_i18n;
589
+ }
590
+ },
591
+ getNonI18nCount = (type) => {
592
+ switch (type) {
593
+ case 'number':
594
+ return data.number_not_i18n;
595
+ case 'currency':
596
+ return data.currency_not_i18n;
597
+ case 'percentage':
598
+ return data.percentage_not_i18n;
599
+ }
600
+ },
601
+ getCount = (type) => {
602
+ return seriesIndex === 0
603
+ ? getI18nCount(type)
604
+ : getNonI18nCount(type);
605
+ };
606
+
607
+ switch (dataPointIndex) {
608
+ case 0:
609
+ return getCount('number');
610
+ case 1:
611
+ return getCount('currency');
612
+ case 2:
613
+ return getCount('percentage');
485
614
  }
486
- return \`\${seriesName} (\${nonI18nPercentage}%)\`;
487
- },
488
- },
489
- plotOptions: {
490
- bar: {
491
- borderRadius: 3,
492
- columnWidth: "85%",
493
- },
494
- },
495
- };
615
+ }
616
+ }
617
+ },
618
+ xaxis: {
619
+ categories: types
620
+ },
621
+ yaxis: {
622
+ min: 0,
623
+ max: 100,
624
+ labels: {
625
+ formatter: (v) => \`\${v}%\`
626
+ }
627
+ },
628
+ colors: ['#31E994', '#ff8173'],
629
+ legend: {
630
+ offsetX: -13,
631
+ position: 'right',
632
+ formatter: (seriesName) => {
633
+ if (seriesName === 'Internationalized') {
634
+ return \`\${seriesName} (\${i18nPercentage}%)\`;
635
+ }
636
+ return \`\${seriesName} (\${nonI18nPercentage}%)\`;
637
+ }
638
+ },
639
+ plotOptions: {
640
+ bar: {
641
+ borderRadius: 3,
642
+ columnWidth: '85%'
643
+ }
644
+ }
645
+ };
496
646
 
497
- (numberChart = new ApexCharts(
498
- document.querySelector(".number-quality .graph"),
499
- options
500
- )).render();
501
- }
647
+ (numberChart = new ApexCharts(
648
+ document.querySelector('.number-quality .graph'),
649
+ options
650
+ )).render();
651
+ }
502
652
 
503
- function renderDatetimeChart() {
504
- const types = ["Date", "Time", "DateTime"],
505
- data = {
506
- date_i18n: 10,
507
- time_i18n: 35,
508
- date_time_i18n: 17,
509
- date_not_i18n: 28,
510
- time_not_i18n: 12,
511
- date_time_not_i18n: 5,
512
- },
513
- total = Object.values(data).reduce((acc, curr) => acc + curr, 0),
514
- percentageCalc = (v, t) => ((v / t) * 100).toFixed(0),
515
- i18nPercentage = percentageCalc(
516
- data.date_i18n + data.time_i18n + data.date_time_i18n,
517
- total
518
- ),
519
- nonI18nPercentage = percentageCalc(
520
- data.date_not_i18n +
521
- data.time_not_i18n +
522
- data.date_time_not_i18n,
523
- total
524
- ),
525
- dateTotal = data.date_i18n + data.date_not_i18n,
526
- timeTotal = data.time_i18n + data.time_not_i18n,
527
- dateTimeTotal = data.date_time_i18n + data.date_time_not_i18n,
528
- dateI18n = percentageCalc(data.date_i18n, dateTotal),
529
- timeI18n = percentageCalc(data.time_i18n, timeTotal),
530
- dateTimeI18n = percentageCalc(data.date_time_i18n, dateTimeTotal),
531
- dateNotI18n = percentageCalc(data.date_not_i18n, dateTotal),
532
- timeNotI18n = percentageCalc(data.time_not_i18n, timeTotal),
533
- dateTimeNotI18n = percentageCalc(
534
- data.date_time_not_i18n,
535
- dateTimeTotal
536
- ),
537
- options = {
538
- series: [
539
- {
540
- name: "Internationalized",
541
- data: [dateI18n, timeI18n, dateTimeI18n],
542
- },
543
- {
544
- name: "Not Internationalized",
545
- data: [dateNotI18n, timeNotI18n, dateTimeNotI18n],
546
- },
547
- ],
548
- chart: {
549
- type: "bar",
550
- height: 220,
551
- width: 500,
552
- toolbar: {
553
- show: false,
554
- },
555
- animations: {
556
- enabled: true,
557
- easing: "easeinout",
558
- speed: 800,
559
- animateGradually: {
560
- enabled: true,
561
- delay: 150,
562
- },
563
- dynamicAnimation: {
564
- enabled: true,
565
- speed: 350,
566
- },
567
- },
653
+ function renderDatetimeChart() {
654
+ const overallStats = DataStore.getOverallStats();
655
+ const types = ['Date', 'Time', 'DateTime'],
656
+ data = {
657
+ date_i18n: overallStats.localizedDate,
658
+ time_i18n: overallStats.localizedTime,
659
+ date_time_i18n: overallStats.localizedDateTime,
660
+ date_not_i18n: overallStats.notLocalizedDate,
661
+ time_not_i18n: overallStats.notLocalizedTime,
662
+ date_time_not_i18n: overallStats.notLocalizedDateTime
663
+ },
664
+ total = Object.values(data).reduce((acc, curr) => acc + curr, 0),
665
+ percentageCalc = (v, t) => {
666
+ const val = ((v / t) * 100).toFixed(0);
667
+ return isNaN(val) || !isFinite(val) ? 0 : val;
668
+ },
669
+ i18nPercentage = percentageCalc(
670
+ data.date_i18n + data.time_i18n + data.date_time_i18n,
671
+ total
672
+ ),
673
+ nonI18nPercentage = percentageCalc(
674
+ data.date_not_i18n + data.time_not_i18n + data.date_time_not_i18n,
675
+ total
676
+ ),
677
+ dateTotal = data.date_i18n + data.date_not_i18n,
678
+ timeTotal = data.time_i18n + data.time_not_i18n,
679
+ dateTimeTotal = data.date_time_i18n + data.date_time_not_i18n,
680
+ dateI18n = percentageCalc(data.date_i18n, dateTotal),
681
+ timeI18n = percentageCalc(data.time_i18n, timeTotal),
682
+ dateTimeI18n = percentageCalc(data.date_time_i18n, dateTimeTotal),
683
+ dateNotI18n = percentageCalc(data.date_not_i18n, dateTotal),
684
+ timeNotI18n = percentageCalc(data.time_not_i18n, timeTotal),
685
+ dateTimeNotI18n = percentageCalc(
686
+ data.date_time_not_i18n,
687
+ dateTimeTotal
688
+ ),
689
+ options = {
690
+ series: [
691
+ {
692
+ name: 'Internationalized',
693
+ data: [dateI18n, timeI18n, dateTimeI18n]
568
694
  },
569
- dataLabels: {
695
+ {
696
+ name: 'Not Internationalized',
697
+ data: [dateNotI18n, timeNotI18n, dateTimeNotI18n]
698
+ }
699
+ ],
700
+ chart: {
701
+ type: 'bar',
702
+ height: 220,
703
+ width: 500,
704
+ toolbar: {
705
+ show: false
706
+ },
707
+ animations: {
570
708
  enabled: true,
571
- dropShadow: { enabled: false },
572
- style: {
573
- colors: ["#080404b0"],
574
- },
575
- formatter: (val) => {
576
- return \`\${val}%\`;
709
+ easing: 'easeinout',
710
+ speed: 800,
711
+ animateGradually: {
712
+ enabled: true,
713
+ delay: 150
577
714
  },
715
+ dynamicAnimation: {
716
+ enabled: true,
717
+ speed: 350
718
+ }
719
+ }
720
+ },
721
+ dataLabels: {
722
+ enabled: true,
723
+ dropShadow: { enabled: false },
724
+ style: {
725
+ colors: ['#080404b0']
578
726
  },
579
- stroke: {
580
- show: true,
581
- width: 1,
582
- colors: ["#fff"],
583
- },
584
- tooltip: {
585
- theme: "dark",
586
- shared: true,
587
- intersect: false,
588
- },
589
- xaxis: {
590
- categories: types,
591
- },
592
- yaxis: {
593
- min: 0,
594
- max: 100,
595
- labels: {
596
- formatter: (v) => \`\${v}%\`,
597
- },
727
+ formatter: (val) => {
728
+ return \`\${val}%\`;
729
+ }
730
+ },
731
+ stroke: {
732
+ show: true,
733
+ width: 1,
734
+ colors: ['#fff']
735
+ },
736
+ tooltip: {
737
+ theme: 'dark',
738
+ shared: true,
739
+ intersect: false,
740
+ x: {
741
+ formatter: (type) => \`\${type} instances:\`
598
742
  },
599
- colors: ["#31E994", "#ff8173"],
600
- legend: {
601
- offsetX: 4,
602
- position: "right",
603
- formatter: (seriesName) => {
604
- if (seriesName === "Internationalized") {
605
- return \`\${seriesName} (\${i18nPercentage}%)\`;
743
+ y: {
744
+ formatter: (v, { seriesIndex, dataPointIndex }) => {
745
+ const getI18nCount = (type) => {
746
+ switch (type) {
747
+ case 'date':
748
+ return data.date_i18n;
749
+ case 'time':
750
+ return data.time_i18n;
751
+ case 'date_time':
752
+ return data.date_time_i18n;
753
+ }
754
+ },
755
+ getNonI18nCount = (type) => {
756
+ switch (type) {
757
+ case 'date':
758
+ return data.date_not_i18n;
759
+ case 'time':
760
+ return data.time_not_i18n;
761
+ case 'date_time':
762
+ return data.date_time_not_i18n;
763
+ }
764
+ },
765
+ getCount = (type) => {
766
+ return seriesIndex === 0
767
+ ? getI18nCount(type)
768
+ : getNonI18nCount(type);
769
+ };
770
+
771
+ switch (dataPointIndex) {
772
+ case 0:
773
+ return getCount('date');
774
+ case 1:
775
+ return getCount('time');
776
+ case 2:
777
+ return getCount('date_time');
606
778
  }
607
- return \`\${seriesName} (\${nonI18nPercentage}%)\`;
608
- },
609
- },
610
- plotOptions: {
611
- bar: {
612
- borderRadius: 3,
613
- columnWidth: "85%",
614
- },
615
- },
616
- };
779
+ }
780
+ }
781
+ },
782
+ xaxis: {
783
+ categories: types
784
+ },
785
+ yaxis: {
786
+ min: 0,
787
+ max: 100,
788
+ labels: {
789
+ formatter: (v) => \`\${v}%\`
790
+ }
791
+ },
792
+ colors: ['#31E994', '#ff8173'],
793
+ legend: {
794
+ offsetX: 4,
795
+ position: 'right',
796
+ formatter: (seriesName) => {
797
+ if (seriesName === 'Internationalized') {
798
+ return \`\${seriesName} (\${i18nPercentage}%)\`;
799
+ }
800
+ return \`\${seriesName} (\${nonI18nPercentage}%)\`;
801
+ }
802
+ },
803
+ plotOptions: {
804
+ bar: {
805
+ borderRadius: 3,
806
+ columnWidth: '85%'
807
+ }
808
+ }
809
+ };
617
810
 
618
- (dateTimeChart = new ApexCharts(
619
- document.querySelector(".datetime-quality .graph"),
620
- options
621
- )).render();
622
- }
623
- });
624
- })();
625
- `;
811
+ (dateTimeChart = new ApexCharts(
812
+ document.querySelector('.datetime-quality .graph'),
813
+ options
814
+ )).render();
815
+ }
816
+ });
817
+ })();`;
626
818
  exports.default = _default;