diff options
-rw-r--r-- | controllers/system.js | 19 | ||||
-rw-r--r-- | views/dashboard.ejs | 4 |
2 files changed, 17 insertions, 6 deletions
diff --git a/controllers/system.js b/controllers/system.js index e3a55bd..6bd9d22 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -54,11 +54,17 @@ exports.faq = function(req, res) { exports.dashboard = function(req, res) { console.log('/dashboard - ' + req.user); - res.render('dashboard', { - title: 'kanin', - loggedin: true + + Project.find(function(err, projects) { + if (err) return res.render('500'); + console.log(projects); + res.render('dashboard', { + title: 'Dashboad', + loggedin: true, + projects: projects + }); }); -}; +} @@ -73,7 +79,10 @@ exports.newProject = function(req, res) { exports.postNewProject = function(req, res) { var project = new Project(req.body); project.save(function(err) { - if (err) return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true, errors: err.errors, project: project }); + if (err) { + console.log(err.errors); + return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true, errors: err.errors, project: project }); + } return res.redirect('/dashboard'); }); } diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 5eca9f1..a1f625a 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -12,10 +12,11 @@ <div class="smallfullwidth span5"> <h1>Prosjekter</h1> <section class="projects"> + <% projects.forEach(function(project) { %> <section class="project"> <div class="row-fluid"> <div class="span11"> - <h1><a href="/project">dennisse/<strong>hytteturskogentilfrank</strong></a></h1> + <h1><a href="/project">dennisse/<strong><%= project.name %></strong></a></h1> <div class="row-fluid"> <div class="span8"> <small>Meg, Robert, Turid-Laila, Kurt, Stian, Aleksander, Frank, Olav, Heidi, Anette, Kristine</small> @@ -30,6 +31,7 @@ </div> </div> </section> + <% }); %> <section class="project"> <div class="row-fluid"> <div class="span11"> |