Commit 4932caf35e0fb4f6a6e5cd662e4b4e4b6481e77d
1 parent
8ae24f57
Nettoyage et rebranding
Showing
12 changed files
with
67 additions
and
133 deletions
Show diff stats
app/models/nerd.js renamed to app/models/membre.js
1 | -// app/models/nerd.js | |
2 | -// grab the mongoose module | |
3 | 1 | var mongoose = require('mongoose'); |
4 | 2 | |
5 | -// define our nerd model | |
6 | -// module.exports allows us to pass this to other files when it is called | |
7 | -module.exports = mongoose.model('Nerd', { | |
8 | - login: { | |
3 | +module.exports = mongoose.model('Membre', { | |
4 | + login: { // On récupèrera le nom via les passwd | |
9 | 5 | type: String, |
10 | 6 | default: 'login' |
11 | 7 | }, |
... | ... | @@ -13,7 +9,7 @@ module.exports = mongoose.model('Nerd', { |
13 | 9 | type: String, |
14 | 10 | default: 'IMA' |
15 | 11 | }, |
16 | - promo: { | |
12 | + promo: { // Nécessaire pour calculer le numéro de section | |
17 | 13 | type: Number, |
18 | 14 | default: 2017 |
19 | 15 | }, | ... | ... |
app/routes.js
1 | -// app/routes.js | |
2 | - | |
3 | -// grab the nerd model we just created | |
4 | -var Nerd = require('./models/nerd'); | |
1 | +var Membre = require('./models/membre'); | |
5 | 2 | |
6 | 3 | module.exports = function (app) { |
7 | 4 | |
8 | - // server routes =========================================================== | |
9 | - // handle things like api calls | |
10 | - // authentication routes | |
11 | - | |
12 | - // sample api route | |
13 | - app.get('/api/nerds', function (req, res) { | |
14 | - // use mongoose to get all nerds in the database | |
15 | - Nerd.find(function (err, nerds) { | |
5 | + app.get('/api/membres', function (req, res) { | |
6 | + Membre.find(function (err, membres) { | |
16 | 7 | if (err) |
17 | 8 | res.send(err); |
18 | - res.json(nerds); | |
9 | + res.json(membres); | |
19 | 10 | }); |
20 | 11 | }); |
21 | - app.post('/api/nerds', function (req, res) { | |
22 | - Nerd.create({ | |
12 | + app.post('/api/membres', function (req, res) { | |
13 | + Membre.create({ | |
23 | 14 | login: req.body.login, |
24 | 15 | role: req.body.role, |
25 | 16 | section: req.body.section, |
26 | - }, function (err, nerd) { | |
17 | + }, function (err, membre) { | |
27 | 18 | if (err) |
28 | 19 | res.send(err); |
29 | - Nerd.find(function (err, nerds) { | |
20 | + Membre.find(function (err, membres) { | |
30 | 21 | if (err) |
31 | 22 | res.send(err); |
32 | - res.json(nerds); | |
23 | + res.json(membres); | |
33 | 24 | }); |
34 | 25 | }); |
35 | 26 | }); |
36 | - app.delete('/api/nerds/:nerd_id', function (req, res) { | |
37 | - Nerd.remove({ | |
38 | - _id: req.params.nerd_id | |
39 | - }, function (err, nerd) { | |
27 | + app.delete('/api/membres/:membre_id', function (req, res) { | |
28 | + Membre.remove({ | |
29 | + _id: req.params.membre_id | |
30 | + }, function (err, membre) { | |
40 | 31 | if (err) |
41 | 32 | res.send(err); |
42 | - Nerd.find(function (err, nerds) { | |
33 | + Membre.find(function (err, membres) { | |
43 | 34 | if (err) |
44 | 35 | res.send(err); |
45 | - res.json(nerds); | |
36 | + res.json(membres); | |
46 | 37 | }); |
47 | 38 | }) |
48 | 39 | }) |
49 | 40 | |
50 | - // route to handle creating goes here (app.post) | |
51 | - // route to handle delete goes here (app.delete) | |
52 | - | |
53 | - // frontend routes ========================================================= | |
54 | - // route to handle all angular requests | |
55 | 41 | app.get('*', function (req, res) { |
56 | - res.sendfile('./public/views/index.html'); // load our public/index.html file | |
42 | + res.sendfile('./public/views/index.html'); | |
57 | 43 | }); |
58 | 44 | |
59 | 45 | }; |
60 | 46 | \ No newline at end of file | ... | ... |
public/css/style.css
public/js/app.js
public/js/appRoutes.js
... | ... | @@ -6,14 +6,13 @@ angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider', |
6 | 6 | |
7 | 7 | // home page |
8 | 8 | .when('/', { |
9 | - templateUrl: 'views/home.html', | |
10 | - controller: 'MainController' | |
9 | + templateUrl: 'views/home.html' | |
11 | 10 | }) |
12 | 11 | |
13 | - // nerds page that will use the NerdController | |
14 | - .when('/nerds', { | |
15 | - templateUrl: 'views/nerd.html', | |
16 | - controller: 'NerdController' | |
12 | + // membres page that will use the MembreController | |
13 | + .when('/membres', { | |
14 | + templateUrl: 'views/membres.html', | |
15 | + controller: 'MembreController' | |
17 | 16 | }); |
18 | 17 | |
19 | 18 | $locationProvider.html5Mode(true); | ... | ... |
public/js/controllers/MainCtrl.js deleted
public/js/controllers/NerdCtrl.js renamed to public/js/controllers/MembreCtrl.js
1 | -// public/js/controllers/NerdCtrl.js | |
2 | -angular.module('NerdCtrl', []).controller('NerdController', function ($scope, $http) { | |
1 | +// public/js/controllers/MembreCtrl.js | |
2 | +angular.module('MembreCtrl', []).controller('MembreController', function ($scope, $http) { | |
3 | 3 | $scope.formData = {}; |
4 | 4 | |
5 | - // when landing on the page, get all Nerds and show them | |
6 | - $http.get('/api/nerds') | |
5 | + // when landing on the page, get all Membres and show them | |
6 | + $http.get('/api/membres') | |
7 | 7 | .success(function (data) { |
8 | - $scope.nerds = data; | |
8 | + $scope.membres = data; | |
9 | 9 | console.log(data); |
10 | 10 | }) |
11 | 11 | .error(function (data) { |
... | ... | @@ -13,23 +13,23 @@ angular.module('NerdCtrl', []).controller('NerdController', function ($scope, $h |
13 | 13 | }); |
14 | 14 | |
15 | 15 | // when submitting the add form, send the text to the node API |
16 | - $scope.createNerd = function () { | |
16 | + $scope.createMembre = function () { | |
17 | 17 | console.log('Adding', $scope.formData); |
18 | - $http.post('/api/nerds', $scope.formData) | |
18 | + $http.post('/api/membres', $scope.formData) | |
19 | 19 | .success(function (data) { |
20 | 20 | $scope.formData = {}; // clear the form so our user is ready to enter another |
21 | - $scope.nerds = data; | |
21 | + $scope.membres = data; | |
22 | 22 | }) |
23 | 23 | .error(function (data) { |
24 | 24 | console.log('Error: ' + data); |
25 | 25 | }); |
26 | 26 | }; |
27 | 27 | |
28 | - // delete a Nerd after checking it | |
29 | - $scope.deleteNerd = function (id) { | |
30 | - $http.delete('/api/nerds/' + id) | |
28 | + // delete a Membre after checking it | |
29 | + $scope.deleteMembre = function (id) { | |
30 | + $http.delete('/api/membres/' + id) | |
31 | 31 | .success(function (data) { |
32 | - $scope.nerds = data; | |
32 | + $scope.membres = data; | |
33 | 33 | console.log(data); |
34 | 34 | }) |
35 | 35 | .error(function (data) { | ... | ... |
public/js/services/NerdService.js deleted
... | ... | @@ -1,22 +0,0 @@ |
1 | -// public/js/services/NerdService.js | |
2 | -angular.module('NerdService', []).factory('Nerd', ['$http', | |
3 | - function ($http) { | |
4 | - | |
5 | - return { | |
6 | - // call to get all nerds | |
7 | - get: function () { | |
8 | - return $http.get('/api/nerds'); | |
9 | - }, | |
10 | - // call to POST and create a new nerd | |
11 | - create: function (nerdData) { | |
12 | - return $http.post('/api/nerds', nerdData); | |
13 | - }, | |
14 | - | |
15 | - // call to DELETE a nerd | |
16 | - delete: function (id) { | |
17 | - return $http.delete('/api/nerds/' + id); | |
18 | - } | |
19 | - } | |
20 | - | |
21 | - } | |
22 | -]); | |
23 | 0 | \ No newline at end of file |
public/views/home.html
1 | -<!-- public/views/home.html --> | |
2 | - | |
3 | 1 | <div class="jumbotron text-center"> |
4 | - <h1>Home Page 4 Life</h1> | |
5 | - | |
6 | - <p>{{ tagline }}</p> | |
2 | + <h1>Site internet du Club Info</h1> | |
3 | + <p>Hey ! Bienvenue sur le site internet du Club Info !<br/> | |
4 | + Pour l'instant, on travaille encore dessus, donc n'hésites pas à t'y aventurer, mais prends garde, les erreurs 404 te guettent !</p> | |
7 | 5 | </div> |
8 | 6 | \ No newline at end of file | ... | ... |
public/views/index.html
... | ... | @@ -8,25 +8,24 @@ |
8 | 8 | <title>Club Informatique de Polytech Lille</title> |
9 | 9 | <!-- CSS --> |
10 | 10 | <link rel="stylesheet" href="libs/bootstrap/dist/css/bootstrap.min.css"> |
11 | - <link rel="stylesheet" href="css/style.css"> <!-- custom styles --> | |
11 | + <link rel="stylesheet" href="css/style.css"> | |
12 | 12 | <!-- JS --> |
13 | - <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> | |
13 | + <script src="libs/jquery/dist/jquery.min.js"></script> | |
14 | 14 | <script src="libs/angular/angular.min.js"></script> |
15 | 15 | <script src="libs/angular-route/angular-route.min.js"></script> |
16 | - <script src="js/controllers/MainCtrl.js"></script> | |
17 | - <script src="js/controllers/NerdCtrl.js"></script> | |
18 | - <script src="js/services/NerdService.js"></script> | |
16 | + <!-- APP --> | |
17 | + <script src="js/controllers/MembreCtrl.js"></script> | |
19 | 18 | <script src="js/appRoutes.js"></script> |
20 | 19 | <script src="js/app.js"></script> |
21 | 20 | </head> |
22 | - <body ng-app="sampleApp" ng-controller="NerdController"> | |
21 | + <body ng-app="ciApp"> | |
23 | 22 | <div class="container"> |
24 | 23 | <nav class="navbar navbar-inverse"> |
25 | 24 | <div class="navbar-header"> |
26 | 25 | <a class="navbar-brand" href="/">Club Info</a> |
27 | 26 | </div> |
28 | 27 | <ul class="nav navbar-nav"> |
29 | - <li><a href="/nerds">Nerds</a></li> | |
28 | + <li><a href="/membres">Membres</a></li> | |
30 | 29 | </ul> |
31 | 30 | </nav> |
32 | 31 | <div ng-view></div> | ... | ... |
public/views/nerd.html renamed to public/views/membres.html
1 | 1 | <div class="container"> |
2 | 2 | <!-- HEADER AND TODO COUNT --> |
3 | 3 | <div class="jumbotron text-center"> |
4 | - <h1>Il y a <span class="label label-info">{{ nerds.length }}</span> personnes au Club Info !</h1> | |
4 | + <h1>Il y a <span class="label label-info">{{ membres.length }}</span> personnes au Club Info !</h1> | |
5 | 5 | </div> |
6 | - <table id="nerd-list"> | |
6 | + <table id="membre-list"> | |
7 | 7 | <thead> |
8 | 8 | <tr> |
9 | 9 | <th>Nom</th> |
... | ... | @@ -12,18 +12,18 @@ |
12 | 12 | <th>Action</th> |
13 | 13 | </tr> |
14 | 14 | </thead> |
15 | - <tbody ng-repeat="nerd in nerds"> | |
15 | + <tbody ng-repeat="membre in membres"> | |
16 | 16 | <tr> |
17 | - <td>{{ nerd.login }}</td> | |
18 | - <td>{{ nerd.section }}</td> | |
19 | - <td>{{ nerd.role }}</td> | |
20 | - <td><button type="button" class="btn btn-danger" aria-label="Expulser" ng-click="deleteNerd(nerd._id)"> | |
17 | + <td>{{ membre.login }}</td> | |
18 | + <td>{{ membre.section }}</td> | |
19 | + <td>{{ membre.role }}</td> | |
20 | + <td><button type="button" class="btn btn-danger" aria-label="Expulser" ng-click="deleteMembre(membre._id)"> | |
21 | 21 | <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> |
22 | 22 | </button> |
23 | 23 | </td> |
24 | 24 | </tr> |
25 | 25 | </tbody> |
26 | - <tfoot id="nerd-form"> | |
26 | + <tfoot id="membre-form"> | |
27 | 27 | <tr class="form-group"> |
28 | 28 | <td> |
29 | 29 | <input type="text" class="form-control input-lg" placeholder="Login" ng-model="formData.login"> |
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | <input type="text" class="form-control input-lg" placeholder="Rôle" ng-model="formData.role"> |
36 | 36 | </td> |
37 | 37 | <td> |
38 | - <button type="submit" class="btn btn-primary" aria-label="Ajouter" ng-click="createNerd()"> | |
38 | + <button type="submit" class="btn btn-primary" aria-label="Ajouter" ng-click="createMembre()"> | |
39 | 39 | <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> |
40 | 40 | </button> |
41 | 41 | </td> | ... | ... |
server.js
1 | -// server.js | |
2 | - | |
3 | -// modules ================================================= | |
1 | +// Modules ==================================================================== | |
4 | 2 | var express = require('express'); |
5 | 3 | var app = express(); |
6 | 4 | var mongoose = require('mongoose'); |
... | ... | @@ -8,47 +6,32 @@ var morgan = require('morgan'); |
8 | 6 | var bodyParser = require('body-parser'); |
9 | 7 | var methodOverride = require('method-override'); |
10 | 8 | |
11 | -// configuration =========================================== | |
12 | - | |
13 | -// config files | |
14 | -var db = require('./config/db'); | |
9 | +// Application ================================================================ | |
15 | 10 | |
16 | -// set our port | |
17 | 11 | var port = process.env.PORT || 8080; |
18 | 12 | |
19 | -// connect to our mongoDB database | |
20 | -// (uncomment after you enter in your own credentials in config/db.js) | |
13 | +// Connection à la BDD | |
14 | +var db = require('./config/db'); | |
21 | 15 | mongoose.connect(db.url); |
22 | 16 | |
23 | -// get all data/stuff of the body (POST) parameters | |
24 | -// parse application/json | |
17 | +// Tricks | |
25 | 18 | app.use(bodyParser.json()); |
26 | - | |
27 | -// parse application/vnd.api+json as json | |
28 | 19 | app.use(bodyParser.json({ |
29 | 20 | type: 'application/vnd.api+json' |
30 | 21 | })); |
31 | - | |
32 | -// parse application/x-www-form-urlencoded | |
33 | 22 | app.use(bodyParser.urlencoded({ |
34 | 23 | extended: true |
35 | 24 | })); |
36 | - | |
37 | -// override with the X-HTTP-Method-Override header in the request. simulate DELETE/PUT | |
38 | 25 | app.use(methodOverride('X-HTTP-Method-Override')); |
39 | 26 | |
40 | -// set the static files location /public/img will be /img for users | |
27 | +// Dossier public | |
41 | 28 | app.use(express.static(__dirname + '/public')); |
42 | 29 | |
43 | -// routes ================================================== | |
44 | -require('./app/routes')(app); // configure our routes | |
30 | +// Routes | |
31 | +require('./app/routes')(app); | |
45 | 32 | |
46 | -// start app =============================================== | |
47 | -// startup our app at http://localhost:8080 | |
48 | 33 | app.listen(port); |
49 | 34 | |
50 | -// shoutout to the user | |
51 | -console.log('Magic happens on port ' + port); | |
35 | +console.log('La magie du CI se passe au port ' + port); | |
52 | 36 | |
53 | -// expose app | |
54 | 37 | exports = module.exports = app; |
55 | 38 | \ No newline at end of file | ... | ... |