conjur-asset-ui 1.3.2 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.jshintrc +41 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -1
- data/README.md +38 -4
- data/Rakefile +69 -1
- data/TODO.md +31 -0
- data/bower.json +98 -0
- data/conjur-asset-ui.gemspec +3 -3
- data/features/navigation_bar.feature +31 -0
- data/features/step_definitions/custom_step.rb +32 -0
- data/features/support/env.rb +38 -0
- data/features/support/hooks.rb +30 -0
- data/features/support/world.rb +17 -0
- data/gulpfile.js +139 -0
- data/lib/conjur/command/ui.rb +1 -1
- data/lib/conjur/webserver/server.rb +14 -8
- data/lib/conjur-asset-ui-version.rb +1 -1
- data/package.json +47 -0
- data/preprocessor.js +7 -0
- data/public/_client_libs.html +1 -16
- data/public/build/css/styles.css +87 -0
- data/public/build/css/vendor.css +5 -0
- data/public/build/fonts/glyphicons-halflings-regular.eot +0 -0
- data/public/{fonts → build/fonts}/glyphicons-halflings-regular.svg +47 -47
- data/public/{fonts → build/fonts}/glyphicons-halflings-regular.ttf +0 -0
- data/public/build/fonts/glyphicons-halflings-regular.woff +0 -0
- data/public/build/js/app.min.js +4 -0
- data/public/build/js/vendor.min.js +23 -0
- data/public/build/maps/app.min.js.map +1 -0
- data/public/build/maps/vendor.min.js.map +1 -0
- data/public/css/styles.less +246 -17
- data/public/index.html.erb +11 -10
- data/public/js/init.js +186 -97
- data/public/js/lib/sorted-set.no-require.js +3 -28
- data/public/js/models/groupRecord.js +14 -12
- data/public/js/models/hostRecord.js +13 -8
- data/public/js/models/layerRecord.js +14 -12
- data/public/js/models/namespace.js +2 -0
- data/public/js/models/policyList.js +3 -1
- data/public/js/models/policyRecord.js +8 -8
- data/public/js/models/record.js +59 -27
- data/public/js/models/resourceList.js +28 -10
- data/public/js/models/userList.js +7 -2
- data/public/js/models/userRecord.js +14 -9
- data/public/js/models/variableList.js +18 -7
- data/public/js/models/variableRecord.js +18 -14
- data/public/js/routers.js +74 -37
- data/public/js/views/annotations.js +39 -28
- data/public/js/views/audit.js +31 -25
- data/public/js/views/breadcrumbs.js +62 -0
- data/public/js/views/chart.js +617 -0
- data/public/js/views/dashboard.js +144 -65
- data/public/js/views/generic.js +16 -9
- data/public/js/views/group.js +103 -55
- data/public/js/views/groups.js +3 -7
- data/public/js/views/host.js +192 -56
- data/public/js/views/hosts.js +2 -6
- data/public/js/views/layer.js +136 -82
- data/public/js/views/layers.js +2 -6
- data/public/js/views/mixins/search.js +12 -5
- data/public/js/views/mixins/tabs.js +95 -55
- data/public/js/views/navSearch.js +16 -5
- data/public/js/views/owned.js +14 -8
- data/public/js/views/permissions.js +244 -178
- data/public/js/views/policies.js +2 -4
- data/public/js/views/policy.js +65 -38
- data/public/js/views/resource.js +54 -34
- data/public/js/views/role.js +59 -37
- data/public/js/views/searchResults.js +205 -138
- data/public/js/views/sections.js +226 -0
- data/public/js/views/time.js +38 -13
- data/public/js/views/user.js +288 -59
- data/public/js/views/users.js +2 -7
- data/public/js/views/variable.js +293 -53
- data/public/js/views/variables.js +4 -8
- metadata +34 -56
- data/.git-hooks/pre_commit/ensure_livescript_compiled.rb +0 -31
- data/.overcommit.yml +0 -5
- data/compile_ls +0 -6
- data/livescript/views/audit.ls +0 -136
- data/public/_client_code.html +0 -42
- data/public/css/bootstrap.css +0 -7
- data/public/fonts/glyphicons-halflings-regular.eot +0 -0
- data/public/fonts/glyphicons-halflings-regular.woff +0 -0
- data/public/js/lib/JSXTransformer.js +0 -10862
- data/public/js/lib/async.js +0 -958
- data/public/js/lib/backbone.js +0 -2
- data/public/js/lib/bootstrap.js +0 -6
- data/public/js/lib/date.extensions.js +0 -141
- data/public/js/lib/less.js +0 -16
- data/public/js/lib/moment.js +0 -7768
- data/public/js/lib/prelude-browser-min.js +0 -1
- data/public/js/lib/react-bootstrap.js +0 -5346
- data/public/js/lib/react-bootstrap.min.js +0 -4
- data/public/js/lib/underscore-min.js +0 -6
- data/public/js/lib/underscore.string.min.js +0 -1
- data/public/js/main.js +0 -57
- data/vendor/prelude-ls/.gitignore +0 -2
- data/vendor/prelude-ls/.travis.yml +0 -3
- data/vendor/prelude-ls/CHANGELOG.md +0 -81
- data/vendor/prelude-ls/LICENSE +0 -22
- data/vendor/prelude-ls/Makefile +0 -50
- data/vendor/prelude-ls/README.md +0 -15
- data/vendor/prelude-ls/browser/prelude-browser-min.js +0 -1
- data/vendor/prelude-ls/browser/prelude-browser.js +0 -1172
- data/vendor/prelude-ls/lib/Func.js +0 -40
- data/vendor/prelude-ls/lib/List.js +0 -602
- data/vendor/prelude-ls/lib/Num.js +0 -129
- data/vendor/prelude-ls/lib/Obj.js +0 -153
- data/vendor/prelude-ls/lib/Str.js +0 -68
- data/vendor/prelude-ls/lib/index.js +0 -164
- data/vendor/prelude-ls/package.json +0 -50
- data/vendor/prelude-ls/package.ls +0 -46
- data/vendor/prelude-ls/src/Func.ls +0 -17
- data/vendor/prelude-ls/src/List.ls +0 -299
- data/vendor/prelude-ls/src/Num.ls +0 -83
- data/vendor/prelude-ls/src/Obj.ls +0 -61
- data/vendor/prelude-ls/src/Str.ls +0 -32
- data/vendor/prelude-ls/src/index.ls +0 -56
- data/vendor/prelude-ls/test/Func.ls +0 -36
- data/vendor/prelude-ls/test/List.ls +0 -751
- data/vendor/prelude-ls/test/Num.ls +0 -258
- data/vendor/prelude-ls/test/Obj.ls +0 -145
- data/vendor/prelude-ls/test/Prelude.ls +0 -49
- data/vendor/prelude-ls/test/Str.ls +0 -208
- data/vendor/prelude-ls/test/browser.html +0 -5
@@ -0,0 +1,62 @@
|
|
1
|
+
/** @jsx React.DOM */
|
2
|
+
/* global conjur, React, _ */
|
3
|
+
|
4
|
+
(function(conjur, React, _) {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var Breadcrumb = React.createClass({
|
8
|
+
render: function() {
|
9
|
+
var className = '',
|
10
|
+
text;
|
11
|
+
|
12
|
+
if (this.props.active === true) {
|
13
|
+
className = 'active';
|
14
|
+
text = this.props.text;
|
15
|
+
|
16
|
+
} else if (this.props.extra === true) {
|
17
|
+
className = 'b-breadcrumb__extra';
|
18
|
+
text = this.props.text;
|
19
|
+
} else {
|
20
|
+
text = (<a href={this.props.url}>{this.props.text}</a>);
|
21
|
+
}
|
22
|
+
|
23
|
+
return (
|
24
|
+
<li className={className}>
|
25
|
+
{text}
|
26
|
+
</li>
|
27
|
+
);
|
28
|
+
}
|
29
|
+
});
|
30
|
+
|
31
|
+
this.Breadcrumbs = React.createClass({
|
32
|
+
render: function() {
|
33
|
+
var items = _.map(this.props.elems || [], function(e, idx, coll) {
|
34
|
+
var length = coll.length - 1,
|
35
|
+
active = idx + 1 === length ? true : false,
|
36
|
+
extra = idx === length ? true : false;
|
37
|
+
|
38
|
+
return (
|
39
|
+
<Breadcrumb url={e.url}
|
40
|
+
text={e.text}
|
41
|
+
active={active}
|
42
|
+
extra={extra}
|
43
|
+
key={e.url + e.text} />
|
44
|
+
);
|
45
|
+
});
|
46
|
+
|
47
|
+
return (
|
48
|
+
<div className="b-breadcrumbs">
|
49
|
+
<ol className="breadcrumb">
|
50
|
+
{items}
|
51
|
+
</ol>
|
52
|
+
</div>
|
53
|
+
);
|
54
|
+
}
|
55
|
+
});
|
56
|
+
|
57
|
+
}).bind(conjur.views)
|
58
|
+
(
|
59
|
+
conjur,
|
60
|
+
React,
|
61
|
+
_
|
62
|
+
);
|
@@ -0,0 +1,617 @@
|
|
1
|
+
/** @jsx React.DOM */
|
2
|
+
/* global conjur, React, d3, _ */
|
3
|
+
|
4
|
+
(function(conjur, React, d3, _) {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var bisector = d3.bisector(function(d) { return d.date; }).left,
|
8
|
+
oneDay = 86400000;
|
9
|
+
|
10
|
+
function _translate(x, y) {
|
11
|
+
return 'translate(' + x + ',' + y + ')';
|
12
|
+
}
|
13
|
+
|
14
|
+
this.Chart = React.createClass({
|
15
|
+
getInitialState: function() {
|
16
|
+
return {ready: false};
|
17
|
+
},
|
18
|
+
|
19
|
+
getDefaultProps: function() {
|
20
|
+
return {
|
21
|
+
defaultOptions: {
|
22
|
+
legend: {},
|
23
|
+
axis: {
|
24
|
+
x: {
|
25
|
+
label: 'X axis'
|
26
|
+
},
|
27
|
+
y: {
|
28
|
+
label: 'Y axis'
|
29
|
+
}
|
30
|
+
},
|
31
|
+
margin: {
|
32
|
+
top: 20,
|
33
|
+
right: 145,
|
34
|
+
bottom: 30,
|
35
|
+
left: 50
|
36
|
+
}
|
37
|
+
}
|
38
|
+
};
|
39
|
+
},
|
40
|
+
|
41
|
+
el: undefined,
|
42
|
+
svg: undefined,
|
43
|
+
|
44
|
+
componentDidMount: function() {
|
45
|
+
// should be better way to do this
|
46
|
+
this.el = this.getDOMNode();
|
47
|
+
this.svg = {};
|
48
|
+
|
49
|
+
this._calculateInitialState(this.props);
|
50
|
+
},
|
51
|
+
|
52
|
+
componentWillReceiveProps: function(nextProps) {
|
53
|
+
this._calculateInitialState(nextProps);
|
54
|
+
},
|
55
|
+
|
56
|
+
componentDidUpdate: function() {
|
57
|
+
if (this.state.ready === false) {
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
|
61
|
+
if (typeof this.svg.svg === 'undefined') {
|
62
|
+
this._create();
|
63
|
+
}
|
64
|
+
|
65
|
+
this._update();
|
66
|
+
|
67
|
+
return;
|
68
|
+
},
|
69
|
+
|
70
|
+
componentWillUnmount: function() {
|
71
|
+
this.el = undefined;
|
72
|
+
this.svg = undefined;
|
73
|
+
},
|
74
|
+
|
75
|
+
render: function() {
|
76
|
+
return (
|
77
|
+
<div className="b-chart"></div>
|
78
|
+
);
|
79
|
+
},
|
80
|
+
|
81
|
+
_getHeight: function(top, bottom) {
|
82
|
+
var height;
|
83
|
+
|
84
|
+
if (this.el.offsetHeight) {
|
85
|
+
height = this.el.offsetHeight;
|
86
|
+
} else if (this.el.style.pixelHeight) {
|
87
|
+
height = this.el.style.pixelHeight;
|
88
|
+
}
|
89
|
+
|
90
|
+
height = window.parseFloat(height) -
|
91
|
+
top - bottom;
|
92
|
+
|
93
|
+
return height;
|
94
|
+
},
|
95
|
+
|
96
|
+
_getWidth: function(left, right) {
|
97
|
+
var width;
|
98
|
+
|
99
|
+
if (this.el.offsetWidth) {
|
100
|
+
width = this.el.offsetWidth;
|
101
|
+
} else if (this.el.style.pixelWidth) {
|
102
|
+
width = this.el.style.pixelWidth;
|
103
|
+
}
|
104
|
+
|
105
|
+
width = window.parseFloat(width) -
|
106
|
+
left - right;
|
107
|
+
|
108
|
+
return width;
|
109
|
+
},
|
110
|
+
|
111
|
+
_create: function() {
|
112
|
+
var svg = d3.select(this.el)
|
113
|
+
.append('svg')
|
114
|
+
.attr('class', 'd3-line-chart')
|
115
|
+
.attr('width', this.state.fullWidth)
|
116
|
+
.attr('height', this.state.fullHeight)
|
117
|
+
.append('g')
|
118
|
+
.attr('class', 'd3-line-chart__inner')
|
119
|
+
.attr('transform', _translate(this.state.margin.left, this.state.margin.top));
|
120
|
+
|
121
|
+
this.svg.svg = svg;
|
122
|
+
|
123
|
+
this.svg.axis = svg.append('g')
|
124
|
+
.attr('class', 'd3-axis');
|
125
|
+
|
126
|
+
this.svg.axis.append('g')
|
127
|
+
.attr('class', 'd3-axis__x');
|
128
|
+
|
129
|
+
this.svg.axis.append('g')
|
130
|
+
.attr('class', 'd3-axis__y');
|
131
|
+
|
132
|
+
this.svg.legend = svg.append('g')
|
133
|
+
.attr('class', 'd3-legend');
|
134
|
+
|
135
|
+
this.svg.graph = svg.append('g')
|
136
|
+
.attr('class', 'd3-graph');
|
137
|
+
|
138
|
+
this.svg.focus = this.svg.graph.append('g')
|
139
|
+
.attr('class', 'd3-graph__focus');
|
140
|
+
},
|
141
|
+
|
142
|
+
_update: function() {
|
143
|
+
this._drawAxisX();
|
144
|
+
this._drawAxisY();
|
145
|
+
this._drawLegend();
|
146
|
+
this._drawLine();
|
147
|
+
this._drawFocus();
|
148
|
+
},
|
149
|
+
|
150
|
+
_calculateInitialState: function(props) {
|
151
|
+
var options = _.deepExtend({}, props.options,
|
152
|
+
props.defaultOptions);
|
153
|
+
|
154
|
+
var width = this._getWidth(options.margin.left,
|
155
|
+
options.margin.right),
|
156
|
+
height = this._getHeight(options.margin.top,
|
157
|
+
options.margin.bottom),
|
158
|
+
fullWidth = (
|
159
|
+
width +
|
160
|
+
options.margin.left +
|
161
|
+
options.margin.right
|
162
|
+
),
|
163
|
+
fullHeight = (
|
164
|
+
height +
|
165
|
+
options.margin.top +
|
166
|
+
options.margin.bottom
|
167
|
+
);
|
168
|
+
|
169
|
+
var color = d3.scale.category10();
|
170
|
+
|
171
|
+
color.domain(d3.keys(options.legend)
|
172
|
+
.filter(function(key) {
|
173
|
+
return key !== 'date';
|
174
|
+
}));
|
175
|
+
|
176
|
+
var data = color.domain().map(function(name) {
|
177
|
+
return {
|
178
|
+
name: name,
|
179
|
+
values: props.data.map(function(d) {
|
180
|
+
return {date: d.date, value: +d[name]};
|
181
|
+
})
|
182
|
+
};
|
183
|
+
});
|
184
|
+
|
185
|
+
var xExtent = d3.extent(props.data, function(d) {
|
186
|
+
return d.date;
|
187
|
+
});
|
188
|
+
|
189
|
+
var currentDate = (new Date()).getTime();
|
190
|
+
|
191
|
+
var xMin = xExtent[0] || new Date(currentDate - oneDay),
|
192
|
+
xMax = xExtent[1] || new Date(currentDate);
|
193
|
+
|
194
|
+
var yMin = d3.min(data, function(c) {
|
195
|
+
return d3.min(c.values, function(v) {
|
196
|
+
return v.value;
|
197
|
+
});
|
198
|
+
}) || 0;
|
199
|
+
|
200
|
+
if (yMin < 1) {
|
201
|
+
yMin = 0;
|
202
|
+
}
|
203
|
+
|
204
|
+
var yMax = d3.max(data, function(c) {
|
205
|
+
return d3.max(c.values, function(v) {
|
206
|
+
return v.value;
|
207
|
+
});
|
208
|
+
}) || 4;
|
209
|
+
|
210
|
+
yMax = yMax + 1;
|
211
|
+
|
212
|
+
if (yMax < 5) {
|
213
|
+
yMax = 5;
|
214
|
+
}
|
215
|
+
|
216
|
+
var x = this._getScaleX('time')
|
217
|
+
.range([0, width])
|
218
|
+
.domain([xMin, xMax]),
|
219
|
+
|
220
|
+
y = this._getScaleX('linear')
|
221
|
+
.range([height, 0])
|
222
|
+
.domain([yMin, yMax]),
|
223
|
+
|
224
|
+
legendScale = d3.scale.ordinal()
|
225
|
+
.domain([])
|
226
|
+
.range([0, 20, 40, 60, 80, 100, 120, 140]),
|
227
|
+
|
228
|
+
scales = {x: x, y: y, yMax: yMax, legend: legendScale};
|
229
|
+
|
230
|
+
var line = this._getLine(scales);
|
231
|
+
|
232
|
+
this.setState({
|
233
|
+
ready: true,
|
234
|
+
legend: options.legend,
|
235
|
+
axis: options.axis,
|
236
|
+
margin: options.margin,
|
237
|
+
width: width,
|
238
|
+
height: height,
|
239
|
+
fullWidth: fullWidth,
|
240
|
+
fullHeight: fullHeight,
|
241
|
+
color: color,
|
242
|
+
scales: scales,
|
243
|
+
lineStencil: line,
|
244
|
+
data: data
|
245
|
+
});
|
246
|
+
},
|
247
|
+
|
248
|
+
_getScaleX: function(type) {
|
249
|
+
if (type === 'linear') {
|
250
|
+
return d3.scale.linear();
|
251
|
+
} else if (type === 'time') {
|
252
|
+
return d3.time.scale();
|
253
|
+
}
|
254
|
+
|
255
|
+
return null;
|
256
|
+
},
|
257
|
+
|
258
|
+
_getLine: function(scales) {
|
259
|
+
return d3.svg.line()
|
260
|
+
.x(function(d) {
|
261
|
+
return scales.x(d.date);
|
262
|
+
})
|
263
|
+
.y(function(d) {
|
264
|
+
return scales.y(d.value);
|
265
|
+
});
|
266
|
+
},
|
267
|
+
|
268
|
+
_drawAxisX: function() {
|
269
|
+
var xAxis = d3.svg.axis()
|
270
|
+
.scale(this.state.scales.x)
|
271
|
+
.orient('bottom');
|
272
|
+
|
273
|
+
this.svg.axis.select('.d3-axis__x')
|
274
|
+
.attr('transform', _translate(0, this.state.height))
|
275
|
+
.call(xAxis);
|
276
|
+
},
|
277
|
+
|
278
|
+
_drawAxisY: function() {
|
279
|
+
var yAxis = d3.svg.axis()
|
280
|
+
.scale(this.state.scales.y)
|
281
|
+
.orient('left')
|
282
|
+
.ticks(this.state.scales.yMax > 10 ? 10 : this.state.scales.yMax)
|
283
|
+
.tickFormat(d3.format('d'))
|
284
|
+
.tickSubdivide(0);
|
285
|
+
|
286
|
+
var axis = this.svg.axis.select('.d3-axis__y')
|
287
|
+
.call(yAxis);
|
288
|
+
|
289
|
+
if (typeof(this.state.yAxisLabel) === 'string') {
|
290
|
+
this._drawAxisLabel(axis, this.state.yAxisLabel, true);
|
291
|
+
}
|
292
|
+
},
|
293
|
+
|
294
|
+
_drawAxisLabel: function(axis, text, rotate) {
|
295
|
+
var label = axis.append('text');
|
296
|
+
|
297
|
+
if (typeof(rotate) === 'boolean' && rotate === true) {
|
298
|
+
label.attr('transform', 'rotate(-90)')
|
299
|
+
.attr('y', 0 - this.state.margin.left)
|
300
|
+
.attr('x', 0 - (this.state.height / 2))
|
301
|
+
.attr('dy', '1em')
|
302
|
+
.style('text-anchor', 'middle')
|
303
|
+
.text(text);
|
304
|
+
} else {
|
305
|
+
label.attr('transform',
|
306
|
+
_translate(this.state.width / 2,
|
307
|
+
this.state.height + this.state.margin.bottom))
|
308
|
+
.style('text-anchor', 'middle')
|
309
|
+
.text(text);
|
310
|
+
}
|
311
|
+
},
|
312
|
+
|
313
|
+
_drawLegend: function() {
|
314
|
+
var self = this,
|
315
|
+
legend,
|
316
|
+
enter;
|
317
|
+
|
318
|
+
legend = this.svg.legend
|
319
|
+
.selectAll('.d3-legend__item')
|
320
|
+
.data(d3.keys(this.state.legend));
|
321
|
+
|
322
|
+
enter = legend
|
323
|
+
.enter()
|
324
|
+
.append('g')
|
325
|
+
.style('opacity', 0.9)
|
326
|
+
.attr('class', 'd3-legend__item')
|
327
|
+
.attr('data-graph-line-id', function(d) {
|
328
|
+
return 'd3-legend__item--' + d;
|
329
|
+
})
|
330
|
+
.on('mouseover', function(d) {
|
331
|
+
self._handleLegendMouseover(this, d);
|
332
|
+
})
|
333
|
+
.on('mouseout', function(d) {
|
334
|
+
self._handleLegendMouseout(this, d);
|
335
|
+
})
|
336
|
+
.on('click', function(d) {
|
337
|
+
self._handleLegendClick(this, d);
|
338
|
+
});
|
339
|
+
|
340
|
+
enter.append('circle')
|
341
|
+
.attr('cx', this.state.width + 30)
|
342
|
+
.attr('cy', function(d, i) {
|
343
|
+
return self.state.scales.legend(i) - 3.1;
|
344
|
+
})
|
345
|
+
.attr('r', 5.5)
|
346
|
+
.style('fill', function(d) {
|
347
|
+
return self.state.color(d);
|
348
|
+
});
|
349
|
+
|
350
|
+
enter.append('text')
|
351
|
+
.attr('x', this.state.width + 40)
|
352
|
+
.attr('y', function(d, i) {
|
353
|
+
return self.state.scales.legend(i);
|
354
|
+
})
|
355
|
+
.text(function(d) {
|
356
|
+
return self.state.legend[d];
|
357
|
+
});
|
358
|
+
},
|
359
|
+
|
360
|
+
_handleLegendMouseover: function(self) {
|
361
|
+
var opacity = parseFloat(self.style.opacity);
|
362
|
+
|
363
|
+
if (opacity >= 0.9) {
|
364
|
+
d3.select(self)
|
365
|
+
.style('opacity', 1);
|
366
|
+
} else {
|
367
|
+
d3.select(self)
|
368
|
+
.style('opacity', 0.5);
|
369
|
+
}
|
370
|
+
},
|
371
|
+
|
372
|
+
_handleLegendMouseout: function(self) {
|
373
|
+
var opacity = parseFloat(self.style.opacity);
|
374
|
+
|
375
|
+
if (opacity >= 0.9) {
|
376
|
+
d3.select(self)
|
377
|
+
.style('opacity', 0.9);
|
378
|
+
} else {
|
379
|
+
d3.select(self)
|
380
|
+
.style('opacity', 0.2);
|
381
|
+
}
|
382
|
+
},
|
383
|
+
|
384
|
+
_handleLegendClick: function(self) {
|
385
|
+
var line = document.getElementById(self.getAttribute('data-graph-line-id'));
|
386
|
+
|
387
|
+
if (line === null) {
|
388
|
+
return;
|
389
|
+
}
|
390
|
+
|
391
|
+
if (line.style.opacity !== '0') {
|
392
|
+
d3.select(line).transition()
|
393
|
+
.duration(500)
|
394
|
+
.style('opacity', 0);
|
395
|
+
|
396
|
+
d3.select(self).transition()
|
397
|
+
.duration(500)
|
398
|
+
.style('opacity', 0.2);
|
399
|
+
} else {
|
400
|
+
d3.select(line).transition()
|
401
|
+
.duration(500)
|
402
|
+
.style('opacity', 1);
|
403
|
+
|
404
|
+
d3.select(self).transition()
|
405
|
+
.duration(500)
|
406
|
+
.style('opacity', 0.9);
|
407
|
+
}
|
408
|
+
},
|
409
|
+
|
410
|
+
_drawLine: function() {
|
411
|
+
var self = this,
|
412
|
+
line;
|
413
|
+
|
414
|
+
this.svg.graph.selectAll('.d3-graph__line')
|
415
|
+
.remove();
|
416
|
+
|
417
|
+
line = this.svg.graph.selectAll('.d3-graph__line')
|
418
|
+
.data(this.state.data)
|
419
|
+
.enter()
|
420
|
+
.append('g')
|
421
|
+
.attr('class', 'd3-graph__line')
|
422
|
+
.attr('id', function(d) {
|
423
|
+
return 'd3-legend__item--' + d.name;
|
424
|
+
});
|
425
|
+
|
426
|
+
line.append('path')
|
427
|
+
.attr('class', 'line')
|
428
|
+
.attr('d', function(d) {
|
429
|
+
return self.state.lineStencil(d.values);
|
430
|
+
})
|
431
|
+
.style('stroke', function(d) {
|
432
|
+
return self.state.color(d.name);
|
433
|
+
});
|
434
|
+
},
|
435
|
+
|
436
|
+
_drawFocus: function() {
|
437
|
+
var self = this;
|
438
|
+
|
439
|
+
var circle = this.svg.focus.selectAll('.d3-graph__focus-circle')
|
440
|
+
.data(this.state.data)
|
441
|
+
.enter()
|
442
|
+
.append('g')
|
443
|
+
.attr('class', 'd3-graph__focus-circle')
|
444
|
+
.attr('id', function(d) {
|
445
|
+
return 'd3-graph__focus-circle--' + d.name;
|
446
|
+
})
|
447
|
+
.style('display', 'none');
|
448
|
+
|
449
|
+
circle.append('circle')
|
450
|
+
.attr('r', 4.5);
|
451
|
+
|
452
|
+
circle.append('text')
|
453
|
+
.attr('x', 9)
|
454
|
+
.attr('dy', '.35em');
|
455
|
+
|
456
|
+
this.svg.focus.selectAll('.d3-graph__focus-line')
|
457
|
+
.data([1])
|
458
|
+
.enter()
|
459
|
+
.append('line')
|
460
|
+
.attr('class', 'd3-graph__focus-line')
|
461
|
+
.attr('x1', 0)
|
462
|
+
.attr('y1', 0)
|
463
|
+
.attr('x2', 0)
|
464
|
+
.attr('y2', this.state.height)
|
465
|
+
.style('display', 'none')
|
466
|
+
.style('stroke', 'gray')
|
467
|
+
.style('stroke-width', 0.5)
|
468
|
+
.style('stroke-dasharray', '5,10');
|
469
|
+
|
470
|
+
this.svg.graph.selectAll('.d3-graph__overlay')
|
471
|
+
.data([1])
|
472
|
+
.enter()
|
473
|
+
.append('rect')
|
474
|
+
.attr('class', 'd3-graph__overlay')
|
475
|
+
.attr('width', this.state.width)
|
476
|
+
.attr('height', this.state.height)
|
477
|
+
.on('mouseover', function() {
|
478
|
+
self.svg.focus.selectAll('.d3-graph__focus-line')
|
479
|
+
.style('display', null);
|
480
|
+
})
|
481
|
+
.on('mouseout', function() {
|
482
|
+
self.svg.focus.selectAll('.d3-graph__focus-line')
|
483
|
+
.style('display', 'none');
|
484
|
+
|
485
|
+
self.svg.focus.selectAll('.d3-graph__focus-circle')
|
486
|
+
.style('display', 'none');
|
487
|
+
})
|
488
|
+
.on('mousemove', function() {
|
489
|
+
self._handleFocusMousemove(this);
|
490
|
+
});
|
491
|
+
},
|
492
|
+
|
493
|
+
_handleFocusMousemove: function(overlay) {
|
494
|
+
var self = this,
|
495
|
+
mouse = d3.mouse(overlay)[0],
|
496
|
+
x0 = this.state.scales.x.invert(mouse);
|
497
|
+
|
498
|
+
var bisectData = function(data) {
|
499
|
+
var i = bisector(data.values, x0, 1),
|
500
|
+
d0 = data.values[i - 1],
|
501
|
+
d1 = data.values[i],
|
502
|
+
ret = {name: data.name, data: {value: []}};
|
503
|
+
|
504
|
+
if (typeof d0 === 'object' || typeof d1 === 'object') {
|
505
|
+
var d = x0 - d0.date > d1.date - x0 ? d1 : d0;
|
506
|
+
|
507
|
+
ret.data = d;
|
508
|
+
}
|
509
|
+
|
510
|
+
return ret;
|
511
|
+
};
|
512
|
+
|
513
|
+
this.svg.focus.selectAll('.d3-graph__focus-line')
|
514
|
+
.attr('transform', _translate(this.state.scales.x(x0), 0));
|
515
|
+
|
516
|
+
this.state.data.map(function(e) {
|
517
|
+
return bisectData(e);
|
518
|
+
}).map(function(d) {
|
519
|
+
var circle = document.getElementById('d3-graph__focus-circle--' + d.name),
|
520
|
+
line = document.getElementById('d3-legend__item--' + d.name);
|
521
|
+
|
522
|
+
if (d.data.value > 0 && line.style.opacity !== '0') {
|
523
|
+
d3.select(circle)
|
524
|
+
.style('display', null)
|
525
|
+
.attr('transform',
|
526
|
+
_translate(self.state.scales.x(d.data.date),
|
527
|
+
self.state.scales.y(d.data.value)))
|
528
|
+
|
529
|
+
.select('text').text(d3.format(',.2f')(d.data.value));
|
530
|
+
} else {
|
531
|
+
d3.select(circle)
|
532
|
+
.style('display', 'none');
|
533
|
+
}
|
534
|
+
});
|
535
|
+
}
|
536
|
+
});
|
537
|
+
|
538
|
+
this.ChartHelperMixin = {
|
539
|
+
getData: function(audit) {
|
540
|
+
var values = {},
|
541
|
+
min,
|
542
|
+
max,
|
543
|
+
self = this;
|
544
|
+
|
545
|
+
_.each(audit, function(e) {
|
546
|
+
var date,
|
547
|
+
type,
|
548
|
+
value;
|
549
|
+
|
550
|
+
if (typeof e.timestamp === 'string') {
|
551
|
+
date = d3.time.hour(new Date(e.timestamp));
|
552
|
+
}
|
553
|
+
|
554
|
+
type = self.getEventType(e);
|
555
|
+
|
556
|
+
if (date instanceof Date && typeof type === 'string') {
|
557
|
+
value = values[date.toString()];
|
558
|
+
|
559
|
+
if (typeof value === 'undefined') {
|
560
|
+
value = self.getDefaultItem();
|
561
|
+
value.date = date;
|
562
|
+
}
|
563
|
+
|
564
|
+
value[type] = value[type] + 1;
|
565
|
+
|
566
|
+
values[date.toString()] = value;
|
567
|
+
|
568
|
+
if (typeof max === 'undefined') {
|
569
|
+
max = date;
|
570
|
+
}
|
571
|
+
|
572
|
+
if (typeof min === 'undefined') {
|
573
|
+
min = date;
|
574
|
+
}
|
575
|
+
|
576
|
+
if (date > max) {
|
577
|
+
max = date;
|
578
|
+
}
|
579
|
+
|
580
|
+
if (date < min) {
|
581
|
+
min = date;
|
582
|
+
}
|
583
|
+
}
|
584
|
+
});
|
585
|
+
|
586
|
+
var x = max - min;
|
587
|
+
|
588
|
+
if (x < oneDay) {
|
589
|
+
var delta = Math.round((86400000 - x) / 2);
|
590
|
+
|
591
|
+
min = new Date(min.getTime() - delta);
|
592
|
+
max = new Date(max.getTime() + delta);
|
593
|
+
}
|
594
|
+
|
595
|
+
return d3.time.scale()
|
596
|
+
.domain([min, max])
|
597
|
+
.ticks(d3.time.hours, 1)
|
598
|
+
.map(function(date) {
|
599
|
+
var d = values[date.toString()] || self.getDefaultItem();
|
600
|
+
|
601
|
+
d.date = date;
|
602
|
+
|
603
|
+
return d;
|
604
|
+
})
|
605
|
+
.sort(function(a, b) {
|
606
|
+
return a.date - b.date;
|
607
|
+
});
|
608
|
+
}
|
609
|
+
};
|
610
|
+
|
611
|
+
}).bind(conjur.views)
|
612
|
+
(
|
613
|
+
conjur,
|
614
|
+
React,
|
615
|
+
d3,
|
616
|
+
_
|
617
|
+
);
|