yipo
3/24/2015 - 4:27 PM

redmine-spent-time-page

redmine-spent-time-page


.time-entry p span {
	margin-right: 1em;
}

.time-entry p:last-child {
	margin-bottom: 0;
}

.time-entry .project {
	font-weight: bold;
}

.time-entry .activity {
	font-style: italic;
}


function jsonp_handler(data) {

	var name = location.search.substr(1);

	var list = data.time_entries
		.filter(function(d) {return d.user.name == name});

	var nest = d3.nest()
		.key(function(d) {return d.spent_on.substr(0,10)})
		.entries(list);

	display(nest);
}

function display(data) {

	var report = d3.select('#report');

	var panel = report.selectAll('div').data(data)
		.enter().append('div').classed('panel panel-default',true);

	var head = panel.append('div').classed('panel-heading clearfix',true);

	head.append('span').text(function(d) {return d.key});
	head.append('span').text(function(d) {
		return d3.sum(d.values,function(d) {return d.hours});
	}).classed('pull-right',true);

	var list = panel.append('ul').classed('list-group',true);

	var item = list.selectAll('li').data(function(d) {return d.values})
		.enter().append('li').classed('time-entry list-group-item clearfix',true);

	item.append('span').text(function(d) {return d.hours}).classed('pull-right',true);

	var l1 = item.append('p');

	l1.append('span').text(function(d) {return d.project.name}).classed('project',true);
	l1.append('span').text(function(d) {return d.issue.id}).classed('issue',true);

	var l2 = item.append('p');

	l2.append('span').text(function(d) {return d.activity.name}).classed('activity',true);
	l2.append('span').text(function(d) {return d.comments}).classed('comments',true);
}

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>redmine-spent-time-page</title>
	<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
	<link rel="stylesheet" href="style.css">
</head>
<body>
	<div class="container-fluid">
		<div class="page-header"></div>
		<div id="report"></div>
	</div>
	<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
	<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
	<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
	<script src="script.js"></script>
	<script src="//redmine.site/time_entries.json?callback=jsonp_handler"></script>
</body>
</html>