conjur-asset-ui 1.4.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -3
- data/CHANGELOG.md +10 -0
- data/Makefile +19 -0
- data/README.md +0 -3
- data/Rakefile +22 -17
- data/TODO.md +0 -23
- data/app/.csscomb.json +304 -0
- data/app/.eslintignore +3 -0
- data/app/.eslintrc +265 -0
- data/app/config/preprocessor.js +19 -0
- data/app/config/webpack.js +124 -0
- data/app/gulpfile.js +96 -0
- data/app/package.json +86 -0
- data/app/src/actions.js +550 -0
- data/app/src/app.js +83 -0
- data/app/src/clients/audit.js +34 -0
- data/app/src/clients/auth.js +24 -0
- data/app/src/clients/generic.js +52 -0
- data/app/src/clients/graph.js +7 -0
- data/app/src/clients/layer_members.js +18 -0
- data/app/src/clients/list.js +31 -0
- data/app/src/clients/members.js +20 -0
- data/app/src/clients/request.js +531 -0
- data/app/src/clients/search.js +5 -0
- data/app/src/components/app/__tests__/app-test.js +22 -0
- data/app/src/components/app/app.js +36 -0
- data/app/src/components/app/wrapper.js +17 -0
- data/app/src/components/audit/__tests__/table_header-test.js +22 -0
- data/app/src/components/audit/box.js +9 -0
- data/app/src/components/audit/constants.js +5 -0
- data/app/src/components/audit/entry.js +105 -0
- data/app/src/components/audit/fields_mixin.js +11 -0
- data/app/src/components/audit/humanize_event.js +213 -0
- data/app/src/components/audit/table.js +64 -0
- data/app/src/components/audit/table_header.js +37 -0
- data/app/src/components/audit/timestamp.js +28 -0
- data/app/src/components/auth/login.js +177 -0
- data/app/src/components/auth/login.less +71 -0
- data/app/src/components/auth/logout.js +42 -0
- data/app/src/components/auth/logout.less +21 -0
- data/app/src/components/chart/chart.js +540 -0
- data/app/src/components/chart/chart_helper_mixin.js +78 -0
- data/app/src/components/custom/list.js +3 -0
- data/app/src/components/custom/view.js +81 -0
- data/app/src/components/dashboard/activity.js +144 -0
- data/app/src/components/dashboard/dashboard.js +46 -0
- data/app/src/components/flash/flash.js +98 -0
- data/app/src/components/flash/flash.less +3 -0
- data/app/src/components/generic/__tests__/time-test.js +42 -0
- data/app/src/components/generic/annotations.js +39 -0
- data/app/src/components/generic/breadcrumbs.js +57 -0
- data/app/src/components/generic/foldable_audit_section.js +204 -0
- data/app/src/components/generic/list.js +141 -0
- data/app/src/components/generic/list_factory.js +41 -0
- data/app/src/components/generic/resource_link.js +64 -0
- data/app/src/components/generic/role_link.js +66 -0
- data/app/src/components/generic/tab_mixin.js +146 -0
- data/app/src/components/generic/time.js +32 -0
- data/app/src/components/graph/__tests__/collapse-test.js +133 -0
- data/app/src/components/graph/__tests__/edges-from-vertices-test.js +48 -0
- data/app/src/components/graph/__tests__/new-vertex-set-test.js +16 -0
- data/app/src/components/graph/__tests__/next-id-test.js +27 -0
- data/app/src/components/graph/__tests__/role-kind-from-id-test.js +24 -0
- data/app/src/components/graph/__tests__/vertices-from-edges-test.js +72 -0
- data/app/src/components/graph/graph.js +449 -0
- data/app/src/components/graph/graph.less +39 -0
- data/app/src/components/graph/helpers.js +368 -0
- data/app/src/components/group/list.js +3 -0
- data/app/src/components/group/view.js +153 -0
- data/app/src/components/host/activity.js +111 -0
- data/app/src/components/host/details.js +28 -0
- data/app/src/components/host/executors.js +77 -0
- data/app/src/components/host/host_link.js +18 -0
- data/app/src/components/host/list.js +3 -0
- data/app/src/components/host/updaters.js +77 -0
- data/app/src/components/host/view.js +145 -0
- data/app/src/components/layer/list.js +3 -0
- data/app/src/components/layer/view.js +197 -0
- data/app/src/components/navbar/__tests__/navbar-test.js +21 -0
- data/app/src/components/navbar/nav_search_form.js +40 -0
- data/app/src/components/navbar/navbar.js +96 -0
- data/app/src/components/notfound/notfound.js +35 -0
- data/app/src/components/notfound/notfound.less +21 -0
- data/app/src/components/owned_resources/owned_resources.js +84 -0
- data/app/src/components/owned_resources/owned_resources_box.js +101 -0
- data/app/src/components/permissions/permissions.js +138 -0
- data/app/src/components/permissions/permissions_table.js +101 -0
- data/app/src/components/policy/list.js +3 -0
- data/app/src/components/policy/view.js +107 -0
- data/app/src/components/refresh/refresh.js +29 -0
- data/app/src/components/refresh/refresh.less +15 -0
- data/app/src/components/search/group.js +43 -0
- data/app/src/components/search/group_heading.js +50 -0
- data/app/src/components/search/group_title.js +37 -0
- data/app/src/components/search/result_item.js +55 -0
- data/app/src/components/search/search.js +118 -0
- data/app/src/components/user/activity.js +112 -0
- data/app/src/components/user/details.js +30 -0
- data/app/src/components/user/list.js +3 -0
- data/app/src/components/user/pubkeys.js +118 -0
- data/app/src/components/user/pubkeys.less +56 -0
- data/app/src/components/user/view.js +143 -0
- data/app/src/components/variable/activity.js +101 -0
- data/app/src/components/variable/details.js +46 -0
- data/app/src/components/variable/fetchers.js +77 -0
- data/app/src/components/variable/list.js +3 -0
- data/app/src/components/variable/updaters.js +77 -0
- data/app/src/components/variable/view.js +115 -0
- data/app/src/constants.js +36 -0
- data/{public → app/src}/images/conjur-logo.svg +0 -0
- data/{public → app/src}/images/icon-client-pc.svg +0 -0
- data/{public → app/src}/images/icon-environment.png +0 -0
- data/{public → app/src}/images/icon-person.svg +0 -0
- data/{public → app/src}/images/icon-policy.png +0 -0
- data/{public → app/src}/images/icon-resource.png +0 -0
- data/{public → app/src}/images/icon-service-dots.svg +0 -0
- data/{public → app/src}/images/icon-variable.png +0 -0
- data/app/src/pages/index.html +27 -0
- data/app/src/routes.js +64 -0
- data/app/src/stores/app_store.js +35 -0
- data/app/src/stores/audit_store.js +143 -0
- data/app/src/stores/graph_store.js +51 -0
- data/app/src/stores/group_store.js +104 -0
- data/app/src/stores/host_store.js +111 -0
- data/app/src/stores/layer_store.js +115 -0
- data/app/src/stores/policy_store.js +88 -0
- data/app/src/stores/resources_store.js +115 -0
- data/app/src/stores/route_store.js +21 -0
- data/app/src/stores/search_store.js +77 -0
- data/app/src/stores/user_store.js +109 -0
- data/app/src/stores/variable_store.js +93 -0
- data/app/src/styles/bootstrap.less +54 -0
- data/{public/css → app/src/styles}/styles.less +26 -82
- data/app/src/utils.js +38 -0
- data/app/src/vendor/pace.js +2 -0
- data/conjur-asset-ui.gemspec +3 -4
- data/docker/assets-build/Dockerfile +12 -0
- data/docker/conjur-ui/Dockerfile +33 -0
- data/docker/conjur-ui/README.md +38 -0
- data/docker/conjur-ui/mime.types +90 -0
- data/docker/conjur-ui/nginx.conf +110 -0
- data/docker/conjur-ui/start.py +72 -0
- data/docker/conjur-ui/start.sh +18 -0
- data/docker/conjur-ui/test.env +8 -0
- data/lib/conjur-asset-ui-version.rb +1 -1
- data/lib/conjur/command/ui.rb +10 -2
- data/lib/conjur/webserver/home.rb +3 -3
- data/lib/conjur/webserver/login.rb +1 -1
- data/lib/conjur/webserver/server.rb +16 -4
- data/public/js/views/roleGraph.js +91 -0
- metadata +167 -105
- data/.jshintrc +0 -41
- data/bower.json +0 -98
- data/gulpfile.js +0 -139
- data/package.json +0 -47
- data/preprocessor.js +0 -7
- data/public/_client_libs.html +0 -9
- data/public/index.html.erb +0 -63
- data/public/js/init.js +0 -196
- data/public/js/lib/pace.js +0 -2
- data/public/js/lib/sorted-set.no-require.js +0 -1145
- data/public/js/lib/sorted-set.no-require.js.txt +0 -6
- data/public/js/models/groupRecord.js +0 -72
- data/public/js/models/hostRecord.js +0 -60
- data/public/js/models/layerRecord.js +0 -79
- data/public/js/models/namespace.js +0 -12
- data/public/js/models/policyList.js +0 -16
- data/public/js/models/policyRecord.js +0 -54
- data/public/js/models/record.js +0 -117
- data/public/js/models/resourceList.js +0 -87
- data/public/js/models/userList.js +0 -25
- data/public/js/models/userRecord.js +0 -75
- data/public/js/models/variableList.js +0 -27
- data/public/js/models/variableRecord.js +0 -77
- data/public/js/routers.js +0 -242
- data/public/js/views/annotations.js +0 -47
- data/public/js/views/audit.js +0 -369
- data/public/js/views/breadcrumbs.js +0 -62
- data/public/js/views/chart.js +0 -617
- data/public/js/views/dashboard.js +0 -146
- data/public/js/views/generic.js +0 -122
- data/public/js/views/group.js +0 -109
- data/public/js/views/groups.js +0 -26
- data/public/js/views/host.js +0 -200
- data/public/js/views/hosts.js +0 -26
- data/public/js/views/layer.js +0 -146
- data/public/js/views/layers.js +0 -26
- data/public/js/views/mixins/search.js +0 -22
- data/public/js/views/mixins/tabs.js +0 -154
- data/public/js/views/namespaces.js +0 -40
- data/public/js/views/navSearch.js +0 -36
- data/public/js/views/owned.js +0 -184
- data/public/js/views/permissions.js +0 -254
- data/public/js/views/policies.js +0 -26
- data/public/js/views/policy.js +0 -70
- data/public/js/views/resource.js +0 -59
- data/public/js/views/role.js +0 -63
- data/public/js/views/searchResults.js +0 -212
- data/public/js/views/sections.js +0 -226
- data/public/js/views/time.js +0 -39
- data/public/js/views/user.js +0 -297
- data/public/js/views/users.js +0 -26
- data/public/js/views/variable.js +0 -310
- data/public/js/views/variables.js +0 -26
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/support/jasmine.yml +0 -112
- data/spec/javascripts/support/jasmine_helper.rb +0 -22
- data/spec/javascripts/support/run.html.erb +0 -23
- data/spec/javascripts/views/AuditSpec.js +0 -22
- data/spec/javascripts/views/AuditSpec.ls +0 -18
data/public/js/views/chart.js
DELETED
@@ -1,617 +0,0 @@
|
|
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
|
-
);
|