-
Notifications
You must be signed in to change notification settings - Fork 58
/
compliance-dashboard.component.js
108 lines (101 loc) · 2.69 KB
/
compliance-dashboard.component.js
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
import React, { Component, Fragment } from 'react'
import { loadScript } from 'utils/other'
import LazyHTML from 'components/lazy-html'
import client from 'api-client'
const onDashboard = [
'DHS',
'DOC',
'DOD',
'DOE',
'DOI',
'DOJ',
'DOL',
'DOS',
'DOT',
'ED',
'EPA',
'GSA',
'HHS',
'HUD',
'NASA',
'NRC',
'NSF',
'OPM',
'SBA',
'SSA',
'TREASURY',
'USAID',
'USDA',
'VA'
]
const dataurl = `${PUBLIC_PATH}src/components/about-page/html/`
const configJSON = {
scores: {
compliant: [1, null],
partial: [0.25, 0.9999999],
noncompliant: [null, 0.244444444]
},
text: [
{
req: 'agencyWidePolicy',
variants: {
compliant: 'Agency policy is consistent with the Federal Source Code Policy.',
noncompliant:
'Agency policy has not been reviewed for consistency with the Federal Source Code Policy.',
partial:
'Agency policy is being updated for consistency with the Federal Source Code Policy.'
}
},
{
req: 'openSourceRequirement',
variants: {
compliant: 'Agency has open sourced greater than 20% of their custom developed code.',
noncompliant: 'Agency has open sourced less than 10% of their custom developed code.',
partial: 'Agency has open sourced greater than 10% of their custom developed code.'
}
},
{
req: 'inventoryRequirement',
variants: {
compliant: 'Agency has inventoried 100% of new custom code.',
noncompliant: 'Agency has inventoried less than 50% of new custom code.',
partial: 'Agency has inventoried more than 50% of new custom code.'
}
}
]
}
class ComplianceDashboard extends Component {
constructor(props) {
super(props)
this.loading = false
this.state = {}
}
componentDidMount() {
if (!this.loading) {
const webcomponent = customElements.get('compliance-dashboard')
if (!webcomponent) {
loadScript(`${PUBLIC_PATH}webcomponents/compliance-dashboard.js`, true)
}
client.getCompliance().then(compliance => {
compliance = compliance.filter(agency => onDashboard.includes(agency.acronym))
compliance.forEach(agency => {
agency.img = `${PUBLIC_PATH}assets/img/logos/agencies/${agency.acronym}-50x50.png`
})
this.setState({ compliance })
})
}
}
render() {
return (
<Fragment>
<LazyHTML url={`${dataurl}compliance/agency-compliance.html`} />
<compliance-dashboard
id="compliance-dashboard"
config={JSON.stringify(configJSON)}
data={JSON.stringify(this.state.compliance)}
/>
</Fragment>
)
}
}
export default ComplianceDashboard