forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeSummaryTableData.js
More file actions
126 lines (118 loc) · 3.2 KB
/
makeSummaryTableData.js
File metadata and controls
126 lines (118 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
Temporary file to populate the summary table with data
delete file once table is connected to API
*/
import React from 'react'
import { Icon } from '@chakra-ui/core'
const range = len => {
const arr = []
for (let i = 0; i < len; i++) {
arr.push(i)
}
return arr
}
const generateWebStatusIcon = () => {
const randNum = Math.floor(Math.random() * 100 + 1)
let statusIcon
if (randNum < 70) {
statusIcon = <Icon name="check" color="strong" />
} else {
statusIcon = <Icon name="warning" color="weak" />
}
return statusIcon
}
const generateEmailStatusIcon = () => {
const randNum = Math.floor(Math.random() * 100 + 1)
let statusIcon
if (randNum < 33) {
statusIcon = <Icon name="check" color="strong" />
} else if (randNum >= 33 && randNum < 66) {
statusIcon = <Icon name="warning-2" color="moderate" />
} else {
statusIcon = <Icon name="warning" color="weak" />
}
return statusIcon
}
const newDomain = names => {
const ind = Math.floor(Math.random() * 13)
return {
host_domain: names[ind],
https_result: generateWebStatusIcon(),
hsts_result: generateWebStatusIcon(),
preloaded_result: generateWebStatusIcon(),
ssl_result: generateWebStatusIcon(),
protocol_cipher_result: generateWebStatusIcon(),
cert_use_result: generateWebStatusIcon(),
dmarc_result: generateEmailStatusIcon(),
dkim_result: generateEmailStatusIcon(),
spf_result: generateEmailStatusIcon(),
}
}
export default function MakeSummaryTableData(...lens) {
// const domainNames = [
// <Link as={RouteLink} to={`${path}/cyber`}>
// cyber.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/tbs-sct`}>
// tbs-sct.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/canada`}>
// canada.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/cra-arc`}>
// cra-arc.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/pm`}>
// pm.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/cse-cst`}>
// cse-cst.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/forces`}>
// forces.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/faker`}>
// faker.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/rcmp-grc`}>
// rcmp-grc.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/hc-sc`}>
// hc-sc.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/dfait-maeci`}>
// dfait-maeci.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/ec`}>
// ec.gc.ca
// </Link>,
// <Link as={RouteLink} to={`${path}/dfo-mpo`}>
// dfo-mpo.gc.ca
// </Link>,
// ]
const domainNames = [
'cyber.gc.ca',
'tbs-sct.gc.ca',
'canada.ca',
'cra-arc.gc.ca',
'pm.gc.ca',
'cse-cst.gc.ca',
'forces.gc.ca',
'faker.gc.ca',
'rcmp-grc.gc.ca',
'hc-sc.gc.ca',
'dfait-maeci.gc.ca',
'ec.gc.ca',
'dfo-mpo.gc.ca',
]
const makeDataLevel = (depth = 0) => {
const len = lens[depth]
return range(len).map(() => {
return {
...newDomain(domainNames),
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined,
}
})
}
return makeDataLevel()
}