Skip to content

Commit

Permalink
Merge branch 'implement_usage_view'
Browse files Browse the repository at this point in the history
  • Loading branch information
jessie-apollotech committed Mar 27, 2012
2 parents b147b63 + ef3325f commit cd58d95
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 10 deletions.
Binary file added data.tgz
Binary file not shown.
7 changes: 6 additions & 1 deletion grails-app/controllers/timelog/TaskController.groovy
Expand Up @@ -111,7 +111,12 @@ class TaskController {
}

try {
def project = taskInstance.story.project
def story = taskInstance.story
def project = story.project
taskInstance.timeEntries.each{te->
te.task = null
}
story.removeFromTasks(taskInstance)
taskInstance.delete(flush: true)
flash.message = message(code: 'default.deleted.message', args: [message(code: 'task.label', default: 'Task'), params.id])
redirect(controller:'project',action: "show", id: project?.id)
Expand Down
35 changes: 35 additions & 0 deletions grails-app/controllers/timelog/UsageController.groovy
@@ -0,0 +1,35 @@
package timelog

class UsageController {

def index() {
def model = [:]
def today = TimeEntry.today()
model.today = today
def all_users = User.findAllByEnabled(true).collect{ it.username.split('@')[0] }
model.users_with_entry = []
model.users_without_entry = []
(0..7).each{
def users_with_entry
model.users_with_entry[it] = listUsersWithEntry(today - (it))
model.users_without_entry[it] = all_users - model.users_with_entry[it]
}
return model
}

private def listUsersWithEntry = { date ->
def time_entries = TimeEntry.withCriteria{
ge('entryDate',date)
lt('entryDate',date+1)
order('id','desc')
}
def users_with_entry = []
time_entries.each{
def name = it.createdBy.split('@')[0]
if(!users_with_entry.contains(name)){
users_with_entry.add(name)
}
}
return users_with_entry
}
}
6 changes: 3 additions & 3 deletions grails-app/domain/timelog/Story.groovy
Expand Up @@ -49,20 +49,20 @@ class Story {

def completedTasks(){
return tasks.findAll{t->
t.status == 'Completed'
((t != null) && (t?.status == 'Completed'))
}
}

def unestimatedTasks(){
return tasks.findAll{t->
t.estimate == null
t?.estimate == null
}
}

def workedOnBy(){
def workers = [] as Set
tasks.each{ t->
t.timeEntries.each{e->
t?.timeEntries.each{e->
workers.add(e.createdBy.split('@')[0])
}
}
Expand Down
8 changes: 7 additions & 1 deletion grails-app/views/navigation/index.gsp
Expand Up @@ -3,8 +3,8 @@
<div class="container">
<a class="brand" href="${createLink(uri:'/')}">Timelog</a>
<ul class="nav">
<li class="${pageProperty(name:'meta.menu')=='Home'?'active':''}"><a href="${createLink(controller:'home')}">Home</a></li>
<sec:ifLoggedIn>
<li class="${pageProperty(name:'meta.menu')=='Home'?'active':''}"><a href="${createLink(controller:'home')}">Home</a></li>
<li class="dropdown ${pageProperty(name:'meta.menu')=='My Projects'?'active':''}" data-dropdown="dropdown">
<a href="${createLink(controller:'project')}" class="dropdown-toggle">My Projects</a>
<ul class="dropdown-menu">
Expand All @@ -21,6 +21,12 @@
</sec:ifAllGranted>
</ul>
</li>
<li class="dropdown ${pageProperty(name:'meta.menu')=='Reports'?'active':''}" data-dropdown="dropdown">
<a href="${createLink(controller:'project')}" class="dropdown-toggle">Reports</a>
<ul class="dropdown-menu">
<li><a href="${createLink(controller:'usage')}">Daily Usage</a></li>
</ul>
</li>
</sec:ifLoggedIn>
</ul>
<sec:ifNotLoggedIn>
Expand Down
10 changes: 5 additions & 5 deletions grails-app/views/project/show.gsp
Expand Up @@ -146,16 +146,16 @@
<tbody>
<g:each in="${s.tasks}" var="t" status="i">
<tr>
<td>${t.description}</td>
<td>${t.status}</td>
<td style="text-align:center;">${t.estimate}</td>
<td style="text-align:center;">${t.actualHours()}</td>
<td>${t?.description}</td>
<td>${t?.status}</td>
<td style="text-align:center;">${t?.estimate}</td>
<td style="text-align:center;">${t?.actualHours()}</td>
<td>
<g:link controller="task" action="edit"
id="${t?.id}" class="mini btn">
Edit
</g:link>
<g:if test="${t.status in ['Pending','Incomplete']}">
<g:if test="${t?.status in ['Pending','Incomplete']}">
<g:link controller="task" action="addEntry"
params="${[task_id:t?.id]}"
class="mini btn success">
Expand Down
95 changes: 95 additions & 0 deletions grails-app/views/usage/index.gsp
@@ -0,0 +1,95 @@
<%@ page import="timelog.User" %>
<html>
<head>
<meta name='layout' content='user'/>
<meta name='menu' content='Reports'/>
</head>

<body>
<div class="page-header">
<div class="row">
<h3 class="span7">People with entries</h3>
<h3 class="span7">People without entries</h3>
</div>
<div class="row">
<p class="span14">
<strong>
<g:formatDate date="${today}" type="date" style="FULL"/>
</strong>
</p>
</div>
<div class="row">
<div class="span7">
<g:if test="${users_with_entry[0]}">
<div class="unstyled alert-message block-message success">
<g:each in="${users_with_entry[0]}" var="u">
${u}
</g:each>
</div>
</g:if>
<g:else>
<div class="unstyled alert-message block-message error">
<p>No one has recorded an entry</p>
</div>
</g:else>
</div>
<div class="span7">
<g:if test="${users_without_entry[0]}">
<div class="unstyled alert-message block-message error">
<g:each in="${users_without_entry[0]}" var="u">
<strong>${u}</strong>
</g:each>
</div>
</g:if>
<g:else>
<div class="unstyled alert-message block-message success">
<p>Everyone has recorded an entry</p>
</div>
</g:else>
</div>
</div>
</div>
<g:each in="${(1..7)}" var="i">
<g:if test="${users_with_entry[i]}">
<div class="row">
<p class="span14">
<strong>
<g:formatDate date="${today - i}" type="date" style="FULL"/>
</strong>
</p>
</div>
<div class="row">
<div class="span7">
<g:if test="${users_with_entry[i]}">
<div class="unstyled alert-message block-message success">
<g:each in="${users_with_entry[i]}" var="u">
${u}
</g:each>
</div>
</g:if>
<g:else>
<div class="unstyled alert-message block-message error">
<p>No one has recorded an entry</p>
</div>
</g:else>
</div>
<div class="span7">
<g:if test="${users_without_entry[i]}">
<div class="unstyled alert-message block-message error">
<g:each in="${users_without_entry[i]}" var="u">
<strong>${u}</strong>
</g:each>
</div>
</g:if>
<g:else>
<div class="unstyled alert-message block-message success">
<p>Everyone has recorded an entry</p>
</div>
</g:else>
</div>
</div>
<hr class="span14"/>
</g:if>
</g:each>
</body>
</html>

0 comments on commit cd58d95

Please sign in to comment.