Commit ac04356e61e71ed2b4920749b3af09d805773dc9
1 parent
8bb442a5
Afficher les contrôles de membre si loggué uniquement
Showing
4 changed files
with
8 additions
and
10 deletions
Show diff stats
app/controllers/sessions.js
... | ... | @@ -2,10 +2,6 @@ var Session = require('../models/session'); |
2 | 2 | |
3 | 3 | var sessions = {} |
4 | 4 | |
5 | -sessions.find = function (id, cb) { | |
6 | - Session.findById(id, cb) | |
7 | -} | |
8 | - | |
9 | 5 | sessions.valid = function (session) { |
10 | 6 | return session.started.setSeconds(session.started.getSeconds() + 3600) > new Date() |
11 | 7 | } | ... | ... |
public/js/app.js
1 | -angular.module('ciApp', ['ngRoute', 'appRoutes', 'MembreCtrl', 'SessionsServ', 'SessionsCtrl', 'ConnectCtrl']); | |
2 | 1 | \ No newline at end of file |
2 | +angular.module('ciApp', ['ngRoute', 'appRoutes', 'SessionsServ', 'SessionsCtrl', 'ConnectCtrl', 'MembreCtrl']); | |
3 | 3 | \ No newline at end of file | ... | ... |
public/js/controllers/MembreCtrl.js
1 | -angular.module('MembreCtrl', []).controller('MembreController', ['$scope', '$http', | |
2 | - function ($scope, $http) { | |
1 | +angular.module('MembreCtrl', []).controller('MembreController', ['$scope', '$http', 'SessionService', | |
2 | + function ($scope, $http, SessionService) { | |
3 | 3 | $scope.formData = {}; |
4 | + $scope.canAdd = SessionService.logged | |
5 | + $scope.canDel = SessionService.logged | |
4 | 6 | |
5 | 7 | // when landing on the page, get all Membres and show them |
6 | 8 | $http.get('/api/membres') | ... | ... |
public/views/membres.html
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | <th>Nom</th> |
11 | 11 | <th>Section</th> |
12 | 12 | <th>Rôle</th> |
13 | - <th>Action</th> | |
13 | + <th ng-if="canAdd || canDel">Action</th> | |
14 | 14 | </tr> |
15 | 15 | </thead> |
16 | 16 | <tbody ng-repeat="membre in membres"> |
... | ... | @@ -18,13 +18,13 @@ |
18 | 18 | <td>{{ membre.login }}</td> |
19 | 19 | <td>{{ membre.section }}</td> |
20 | 20 | <td>{{ membre.role }}</td> |
21 | - <td><button type="button" class="btn btn-danger" aria-label="Expulser" ng-click="deleteMembre(membre._id)"> | |
21 | + <td ng-if="canDel"><button type="button" class="btn btn-danger" aria-label="Expulser" ng-click="deleteMembre(membre._id)"> | |
22 | 22 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> |
23 | 23 | </button> |
24 | 24 | </td> |
25 | 25 | </tr> |
26 | 26 | </tbody> |
27 | - <tfoot id="membre-form"> | |
27 | + <tfoot id="membre-form" ng-if="canAdd"> | |
28 | 28 | <tr class="form-group"> |
29 | 29 | <td> |
30 | 30 | <input type="text" class="form-control input-lg" placeholder="Login" ng-model="formData.login"> | ... | ... |