-
Notifications
You must be signed in to change notification settings - Fork 0
/
Log.js
135 lines (124 loc) · 5.09 KB
/
Log.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import React, {Component} from 'react';
import {List, AutoSizer} from "react-virtualized";
import { Button } from 'react-bootstrap';
import './Log.css';
const rowHeight = 30;
class Log extends Component {
padWord = (str, padNum) => {
if (str.length <= 3) {
str = '';
}
if(str.length === padNum) {
return str;
}
else if(str.length < padNum) {
return str.padEnd(padNum, ' ');
}
return str.substring(0, padNum-3)+'...';
};
rowRenderer = ({ index, isScrolling, key, style }) => {
const accessColor = this.props.data[index].access === 'GRANT' ? '#4481F8' : '#DC3545';
return (
<div key={`row-${index}`} style={style}>
<div>
ACTION:
<span style={{color: accessColor}}>
{this.props.data[index].access.padEnd(9, ' ')}
</span>
USER(S):
<span style={{color: "darkgray"}}>
{this.padWord('[' + this.props.data[index].email.join(', ') + ']', 75)}
</span>
</div>
<div>
FILE: <span style={{color: "peachpuff"}}>
{this.padWord(this.props.data[index].file, 25)}
</span>
LOCATION:
<span style={{color: "darkgray"}}>
{!!this.props.data[index].loc ?
this.padWord([this.props.data[index].loc.city, this.props.data[index].loc.country].join(', '), 50) :
""}
</span>
</div>
</div>
);
};
binary = (str) => {
let spans = [];
for(let i = 0; i < str.length; i++)
{
const randColor = Math.random() > 0.3 ? '#4481F8' : 'dimgray';
spans.push(
<span style={{fontWeight:"bold", color: randColor}}>
{str[i]}
</span>);
}
return spans;
};
render() {
return (
<div className="log">
<div className="header">
<span>
<b>{this.binary("A̩̯͔̞̙̮̰͗͋̎̒̓̚ͅu̖͖̝̟͎̦̦̞͈̤̐̑̆̈̆̂̀̊͒̄̃͒ͅd̳͍̮̖͌̅́̋ì̗̣̥̜̯̫̰̰͛͌̉͐̔̇́̊̈́͂́t͙̘̭̫͐̏̃͑͊̌̾̔̚ͅ M̫̟̮̣͉̭̗̳̲͉̌̌̑͋̽͋̀͗͐̾̚̚ͅà͙͎̲̲̈́̄́͑̂̆̄p͎͉̣̱̳̗͉̬̋̀͒̓̽̿̊ͅ >")}</b>
<span className="virtru">
>
</span>
<span style={{fontSize: "0.8em", color: "dimgray"}}>
an entry for the Virtru Privacy Engineering Challenge
</span>
</span>
<span className="save">
<Button variant = "primary" size = "sm" onClick = {this.props.writeFile}> Save JSON </Button>
</span>
</div>
<div className="underline">
{"Logs"}
</div>
<div className="list">
<AutoSizer>
{({height, width}) => (
<List
rowCount={this.props.data.length}
width={width}
height={height}
rowHeight={rowHeight*2}
rowRenderer={this.rowRenderer}
scrollToRow={this.props.data.length}
overscanRowCount={100}
/>
)}
</AutoSizer>
</div>
<div style=
{{fontSize: "0.7em", textAlign: "right",
paddingRight: "1em", color: "dimgray"}}>
{"powered by"}
<span style={{color: '#4481F8'}}>
{
<a href=
"https://developer.virtru.com/docs/getting-started-node-js"
target="_blank" rel="noopener noreferrer">
virtru-sdk
</a>}
</span>
<span>
and
</span>
<span style={{color: "darkgray"}}>
<a href="https://uber.github.io/react-map-gl/" target="_blank"
rel="noopener noreferrer">
react-map-gl
</a>
</span>
</div>
</div>
);
}
}
export default Log;