Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
public/stylesheets
.DS_Store
config.js
.idea
2 changes: 1 addition & 1 deletion config.js.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ module.exports = {
'user': '',
'password': '',
'database': '',
'debug': true
'debug': true
}
}
23 changes: 23 additions & 0 deletions public/javascripts/templates/cart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<blockquote>
<p>Koszyk</p>
</blockquote>

<div class="row">
<table class="col-md-4 table-bordered">
<tr>
<th>Id produktu</th>
<th>Nazwa produktu</th>
<th>Cena produktu</th>
<th>Opiss</th>
<th></th>
</tr>
<tr ng-repeat="product in products">
<td>{{ product.id }}</td>
<td>{{ product.name }}</td>
<td>{{ product.price }}</td>
<td>{{ product.description }}</td>
<td><a ng-click="removeCart(product.id)" href="/cart/remove" class="btn btn-danger">Usuń</a></td>
</tr>
</table>
</div>
<div ng-show="products.length == 0" class="alert alert-info">Niestety, nie dodano jeszcze żadnych produktów do koszyka.</div>
2 changes: 1 addition & 1 deletion public/javascripts/templates/product-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
<div class="clearfix"></div>
</div>

<a class="btn btn-primary" href="#/product/{{ product.id }}/cart">Dodaj do koszyka</a>
<a ng-click="addToCart(product)" class="btn btn-primary" href="#/product/{{ product.id }}/cart">Dodaj do koszyka</a>
22 changes: 22 additions & 0 deletions src/controllers/cart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports.controller = function(app, mysql) {
app.post('/cart/add', function(req, res) {
if (!req.session.products) {
req.session.products = [];
}

req.session.products.push(req.body);
res.send(200, null);
});

app.delete('/cart/:id/remove', function(req, res) {
req.session.products = (req.session.products || []).filter(function(product) {
return product.id != req.params.id;
});

res.send(200, null);
});

app.get('/cart', function(req, res) {
res.send(200, req.session.products || []);
});
}
2 changes: 1 addition & 1 deletion src/services/authManager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
administratorEmailAddress: ['mateusz.nowak@xsolve.pl'],
administratorEmailAddress: ['mateusz.nowak@xsolve.pl', 'paykitson@gmail.com'],

isAdmin: function(profile) {
var self = this,
Expand Down
1 change: 1 addition & 0 deletions src/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<a class="btn btn-primary" href="#/admin">Admin</a>
<% } %>
<a class="btn btn-info" href="/auth/logout">Wyloguj</a>
<a class="btn btn-info " href="#/cart/"><span class="glyphicon glyphicon-shopping-cart"></span> Koszyk</a>
<% } else { %>
<a class="btn btn-info" href="/auth">Zaloguj</a>
<% } %>
Expand Down