diff options
author | Dennis Eriksen <dennis.se@gmail.com> | 2013-05-23 17:17:16 +0200 |
---|---|---|
committer | Dennis Eriksen <dennis.se@gmail.com> | 2013-05-23 17:17:16 +0200 |
commit | 59ee9f2325a31a9900b56ff182a77372948e5fe2 (patch) | |
tree | d509d5403b770a4e0f6bbfe7fb304ac772b94c89 | |
parent | added method to get recent activity for all projects a user belongs to (diff) | |
download | Divid-59ee9f2325a31a9900b56ff182a77372948e5fe2.tar.gz |
fixed recent activity
-rw-r--r-- | controllers/system.js | 17 | ||||
-rw-r--r-- | views/dashboard.ejs | 256 |
2 files changed, 73 insertions, 200 deletions
diff --git a/controllers/system.js b/controllers/system.js index 03a73d3..ffbb16b 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -95,13 +95,24 @@ exports.dashboard = function(req, res) { Access.loadUser(req.user._id, function(err, projects) { if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); Project.populate(projects, { path: 'project.user', model: User }, function(err, projects) { - - res.render('dashboard', { + var projectIDs = []; + projects.forEach(function(project) { projectIDs.push(project.project._id); console.log(project.project.name); }); + pPost.loadByProjects(projectIDs, function(err, posts) { + console.log(posts); + if (err) return res.status(500).render('error', { title: '500', text: 'En serverfeil oppstod', error: err.stack }); + res.render('dashboard', { + title: 'Dashboard', + user: req.user, + projects: projects, + posts: posts + }); + }); + /* res.render('dashboard', { title: 'Dashboard', user: req.user, projects: projects }); - +*/ }); }); diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 9678c9c..1c1c4df 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -71,207 +71,69 @@ <section class="overview"> <h1>Siste aktivitet</h1> <div class="lastactivity"> - <div class="row-fluid act443 activity"> - <div class="span1 date"> - <div class="row-fluid">12</div> - <div class="row-fluid info">MAR</div> - </div> - <div class="span7"> - <div class="row-fluid"> - <div class="span2 info text-right">prosjekt</div> - <div class="span10"><a href="/turidl/Kosekveldene">turidl/<strong>Kosekveldene</strong></a></div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">av</div> - <div class="span10">Turid Laila</div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">hva</div> - <div class="span10">Mer kaviar</div> - </div> - </div> - <div class="span1"> - <div class="row-fluid"> </div> - <div class="row-fluid"> </div> - <div class="row-fluid"><a href="http://i.minus.com/iJvlaTeLavINR.gif"><i class="icon-picture"></i></a></div> - </div> - <div class="span2"> - <div class="row-fluid"> </div> - <div class="row-fluid"> - <div class="span4 info text-right smallfullwidth">sum </div> - <div class="span7 smallfullwidth"><strong>24 kr</strong></div> - </div> - </div> - </div> - - - - - <div class="row-fluid act443 activity"> - <div class="span8"> - <div class="row-fluid"> - <div class="span2 info text-right">prosjekt</div> - <div class="span10"><a href="/kurt/Kollektivet">kurt/<strong>Kollektivet</strong></a></div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">av</div> - <div class="span10">Dennis Eriksen</div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">hva</div> - <div class="span10">Stol!</div> - </div> - </div> - <div class="span4"> - <div class="row-fluid"> - <div class="span3 info text-right">når</div> - <div class="span9">2013-04-12 15:11</div> - </div> - <div class="row-fluid"> - <div class="span12"> </div> - </div> - <div class="row-fluid"> - <div class="span1"><a href="http://i.imgur.com/PZzttmu.png" gtarget="_blank"><i class="icon-picture"></i></a></div> - <div class="span4 info text-right">sum</div> - <div class="span7">105 kr</div> - </div> - </div> - </div> - - - - - <div class="row-fluid act443 activity"> - <div class="span8"> - <div class="row-fluid"> - <div class="span2 info text-right">prosjekt</div> - <div class="span10"><a href="/kurt/Kollektivet">kurt/<strong>Kollektivet</strong></a></div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">av</div> - <div class="span10">Kurt Iversen</div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">hva</div> - <div class="span10">Kjøpte no iskrem</div> - </div> - </div> - <div class="span4"> - <div class="row-fluid"> - <div class="span3 info text-right">når</div> - <div class="span9">2013-04-10 15:22</div> - </div> - <div class="row-fluid"> - <div class="span12"> </div> - </div> - <div class="row-fluid"> - <div class="span1"> </div> - <div class="span4 info text-right">sum</div> - <div class="span7">55 kr</div> - </div> - </div> - </div> - - - - - <div class="row-fluid act443 activity"> - <div class="span8"> - <div class="row-fluid"> - <div class="span2 info text-right">prosjekt</div> - <div class="span10"><a href="/dennisse/hyttetur">dennisse/<strong>hyttetur</strong></a></div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">av</div> - <div class="span10">Dennis Eriksen</div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">hva</div> - <div class="span10">En halvspist osteskive med kaviar</div> - </div> - </div> - <div class="span4"> - <div class="row-fluid"> - <div class="span3 info text-right">når</div> - <div class="span9">2013-04-04 22:39</div> - </div> - <div class="row-fluid"> - <div class="span12"> </div> - </div> - <div class="row-fluid"> - <div class="span1"> </div> - <div class="span4 info text-right">sum</div> - <div class="span7">23 kr</div> - </div> - </div> - </div> - - - - - <div class="row-fluid act443 activity"> - <div class="span8"> - <div class="row-fluid"> - <div class="span2 info text-right">prosjekt</div> - <div class="span10"><a href="/dennisse/hyttetur">dennisse/<strong>hyttetur</strong></a></div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">av</div> - <div class="span10">Robert Joramo</div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">hva</div> - <div class="span10">kaviar</div> - </div> - </div> - <div class="span4"> - <div class="row-fluid"> - <div class="span3 info text-right">når</div> - <div class="span9">2013-04-04 22:37</div> - </div> - <div class="row-fluid"> - <div class="span12"> </div> + <% posts.forEach(function(post) { %> + <div class="row-fluid post-<%= post._id %> activity"> + <div class="row-fluid"> + <div class="span1 date"> + <% + var d = new Date(post.when); + var month = ['JAN', 'FEB', 'MAR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DES']; + %> + <div class="row-fluid"><%= d.getDate() %></div> + <div class="row-fluid info"><%= month[d.getMonth()] %></div> + <div class="row-fluid"><a href="#details-<%= post._id %>" data-toggle="collapse" class="no-text-decoration" data-parent="#lastactivity">▼</a></div> + </div> + <div class="span6"> + <div class="row-fluid"> + <div class="span2 info text-right smallfullwidth">prosjekt</div> + <div class="span10 smallfullwidth"><a href="/project/<%= post.project.shortURL %>"><%= post.project.name %></a></div> + </div> + <div class="row-fluid"> + <div class="span2 info text-right smallfullwidth">av</div> + <div class="span10 smallfullwidth"><%= post.user.name === undefined ? post.user.email + ' <span class="muted">(ikke registrert)</span>' : post.user.name %></div> + </div> + <div class="row-fluid"> + <div class="span2 info text-right smallfullwidth">hva</div> + <div class="span10 smallfullwidth"><%= post.what %></div> + </div> + </div> + <div class="span2"> + <div class="row-fluid"> + <div class="span4 info text-right smallfullwidth"> + delt på + </div> + <div class="span8 text-small smallfullwidth"> + Helene, Robert + </div> + </div> + </div> + <div class="span2"> + <div class="row-fluid text-right"> + <span class="info">sum</span> + <strong><%= post.value %> <%= post.currency %></strong> + </div> + <div class="row-fluid text-right"> + <i class="icon-picture"></i> + </div> + </div> </div> - <div class="row-fluid"> - <div class="span1"> </div> - <div class="span4 info text-right">sum</div> - <div class="span7">5433 kr</div> + <div class="fluid-row collapse details" id="details-<%= post._id %>"> + <div class="span7"> + <div class="row-fluid"> + <div class="span2 info text-right smallfullwidth">kommentar</div> + <div class="span10"> + <%= post.comment %> + </div> + </div> + </div> + <div class="span2"> + <div class="row-fluid info"> + </div> + </div> </div> </div> - </div> - - - <div class="row-fluid act443 activity"> - <div class="span8"> - <div class="row-fluid"> - <div class="span2 info text-right">prosjekt</div> - <div class="span10"><a href="/turidl/Kosekveldene">turidl/<strong>Kosekveldene</strong></a></div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">av</div> - <div class="span10">Kurt Sanandreas</div> - </div> - <div class="row-fluid"> - <div class="span2 info text-right">hva</div> - <div class="span10">Tok med Turiid på restaurant og hadde det kjempekoselig. Var litt dyrt, men verdt det!</div> - </div> - </div> - <div class="span4"> - <div class="row-fluid"> - <div class="span3 info text-right">når</div> - <div class="span9">2013-03-05 11:48</div> - </div> - <div class="row-fluid"> - <div class="span12"> </div> - </div> - <div class="row-fluid"> - <div class="span1"><a href="http://i.imgur.com/qYL2mLb.jpg" target="_blank"><i class="icon-picture"></i></a></div> - <div class="span4 info text-right">sum</div> - <div class="span7">534 kr</div> - </div> - </div> - </div> + <% }); %> </div> </section> </div><!-- /div.span7 --> |