diff --git a/app/models/membre.js b/app/models/membre.js new file mode 100644 index 0000000..a34280f --- /dev/null +++ b/app/models/membre.js @@ -0,0 +1,20 @@ +var mongoose = require('mongoose'); + +module.exports = mongoose.model('Membre', { + login: { // On récupèrera le nom via les passwd + type: String, + default: 'login' + }, + section: { + type: String, + default: 'IMA' + }, + promo: { // Nécessaire pour calculer le numéro de section + type: Number, + default: 2017 + }, + role: { + type: String, + default: 'Membre' + } +}); \ No newline at end of file diff --git a/app/models/nerd.js b/app/models/nerd.js deleted file mode 100644 index 5efbcbc..0000000 --- a/app/models/nerd.js +++ /dev/null @@ -1,24 +0,0 @@ -// app/models/nerd.js -// grab the mongoose module -var mongoose = require('mongoose'); - -// define our nerd model -// module.exports allows us to pass this to other files when it is called -module.exports = mongoose.model('Nerd', { - login: { - type: String, - default: 'login' - }, - section: { - type: String, - default: 'IMA' - }, - promo: { - type: Number, - default: 2017 - }, - role: { - type: String, - default: 'Membre' - } -}); \ No newline at end of file diff --git a/app/routes.js b/app/routes.js index 7a32c8e..917fcff 100644 --- a/app/routes.js +++ b/app/routes.js @@ -1,59 +1,45 @@ -// app/routes.js - -// grab the nerd model we just created -var Nerd = require('./models/nerd'); +var Membre = require('./models/membre'); module.exports = function (app) { - // server routes =========================================================== - // handle things like api calls - // authentication routes - - // sample api route - app.get('/api/nerds', function (req, res) { - // use mongoose to get all nerds in the database - Nerd.find(function (err, nerds) { + app.get('/api/membres', function (req, res) { + Membre.find(function (err, membres) { if (err) res.send(err); - res.json(nerds); + res.json(membres); }); }); - app.post('/api/nerds', function (req, res) { - Nerd.create({ + app.post('/api/membres', function (req, res) { + Membre.create({ login: req.body.login, role: req.body.role, section: req.body.section, - }, function (err, nerd) { + }, function (err, membre) { if (err) res.send(err); - Nerd.find(function (err, nerds) { + Membre.find(function (err, membres) { if (err) res.send(err); - res.json(nerds); + res.json(membres); }); }); }); - app.delete('/api/nerds/:nerd_id', function (req, res) { - Nerd.remove({ - _id: req.params.nerd_id - }, function (err, nerd) { + app.delete('/api/membres/:membre_id', function (req, res) { + Membre.remove({ + _id: req.params.membre_id + }, function (err, membre) { if (err) res.send(err); - Nerd.find(function (err, nerds) { + Membre.find(function (err, membres) { if (err) res.send(err); - res.json(nerds); + res.json(membres); }); }) }) - // route to handle creating goes here (app.post) - // route to handle delete goes here (app.delete) - - // frontend routes ========================================================= - // route to handle all angular requests app.get('*', function (req, res) { - res.sendfile('./public/views/index.html'); // load our public/index.html file + res.sendfile('./public/views/index.html'); }); }; \ No newline at end of file diff --git a/public/css/style.css b/public/css/style.css index b11e73a..dd8f285 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1,9 +1,11 @@ html { overflow-y: scroll; } + body { padding-top: 50px; } -#nerd-list { + +#membre-list { width: 90 %; } \ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js index 145886e..b09133c 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,2 +1 @@ -// public/js/app.js -angular.module('sampleApp', ['ngRoute', 'appRoutes', 'MainCtrl', 'NerdCtrl', 'NerdService']); \ No newline at end of file +angular.module('ciApp', ['ngRoute', 'appRoutes', 'MembreCtrl']); \ No newline at end of file diff --git a/public/js/appRoutes.js b/public/js/appRoutes.js index 0816e66..ccb1ab5 100644 --- a/public/js/appRoutes.js +++ b/public/js/appRoutes.js @@ -6,14 +6,13 @@ angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider', // home page .when('/', { - templateUrl: 'views/home.html', - controller: 'MainController' + templateUrl: 'views/home.html' }) - // nerds page that will use the NerdController - .when('/nerds', { - templateUrl: 'views/nerd.html', - controller: 'NerdController' + // membres page that will use the MembreController + .when('/membres', { + templateUrl: 'views/membres.html', + controller: 'MembreController' }); $locationProvider.html5Mode(true); diff --git a/public/js/controllers/MainCtrl.js b/public/js/controllers/MainCtrl.js deleted file mode 100644 index fa569cb..0000000 --- a/public/js/controllers/MainCtrl.js +++ /dev/null @@ -1,6 +0,0 @@ -// public/js/controllers/MainCtrl.js -angular.module('MainCtrl', []).controller('MainController', function ($scope) { - - $scope.tagline = 'To the moon and back!'; - -}); \ No newline at end of file diff --git a/public/js/controllers/MembreCtrl.js b/public/js/controllers/MembreCtrl.js new file mode 100644 index 0000000..f0ddfc2 --- /dev/null +++ b/public/js/controllers/MembreCtrl.js @@ -0,0 +1,40 @@ +// public/js/controllers/MembreCtrl.js +angular.module('MembreCtrl', []).controller('MembreController', function ($scope, $http) { + $scope.formData = {}; + + // when landing on the page, get all Membres and show them + $http.get('/api/membres') + .success(function (data) { + $scope.membres = data; + console.log(data); + }) + .error(function (data) { + console.log('Error: ' + data); + }); + + // when submitting the add form, send the text to the node API + $scope.createMembre = function () { + console.log('Adding', $scope.formData); + $http.post('/api/membres', $scope.formData) + .success(function (data) { + $scope.formData = {}; // clear the form so our user is ready to enter another + $scope.membres = data; + }) + .error(function (data) { + console.log('Error: ' + data); + }); + }; + + // delete a Membre after checking it + $scope.deleteMembre = function (id) { + $http.delete('/api/membres/' + id) + .success(function (data) { + $scope.membres = data; + console.log(data); + }) + .error(function (data) { + console.log('Error: ' + data); + }); + }; + +}); \ No newline at end of file diff --git a/public/js/controllers/NerdCtrl.js b/public/js/controllers/NerdCtrl.js deleted file mode 100644 index 67cb397..0000000 --- a/public/js/controllers/NerdCtrl.js +++ /dev/null @@ -1,40 +0,0 @@ -// public/js/controllers/NerdCtrl.js -angular.module('NerdCtrl', []).controller('NerdController', function ($scope, $http) { - $scope.formData = {}; - - // when landing on the page, get all Nerds and show them - $http.get('/api/nerds') - .success(function (data) { - $scope.nerds = data; - console.log(data); - }) - .error(function (data) { - console.log('Error: ' + data); - }); - - // when submitting the add form, send the text to the node API - $scope.createNerd = function () { - console.log('Adding', $scope.formData); - $http.post('/api/nerds', $scope.formData) - .success(function (data) { - $scope.formData = {}; // clear the form so our user is ready to enter another - $scope.nerds = data; - }) - .error(function (data) { - console.log('Error: ' + data); - }); - }; - - // delete a Nerd after checking it - $scope.deleteNerd = function (id) { - $http.delete('/api/nerds/' + id) - .success(function (data) { - $scope.nerds = data; - console.log(data); - }) - .error(function (data) { - console.log('Error: ' + data); - }); - }; - -}); \ No newline at end of file diff --git a/public/js/services/NerdService.js b/public/js/services/NerdService.js deleted file mode 100644 index 513f0e6..0000000 --- a/public/js/services/NerdService.js +++ /dev/null @@ -1,22 +0,0 @@ -// public/js/services/NerdService.js -angular.module('NerdService', []).factory('Nerd', ['$http', - function ($http) { - - return { - // call to get all nerds - get: function () { - return $http.get('/api/nerds'); - }, - // call to POST and create a new nerd - create: function (nerdData) { - return $http.post('/api/nerds', nerdData); - }, - - // call to DELETE a nerd - delete: function (id) { - return $http.delete('/api/nerds/' + id); - } - } - - } -]); \ No newline at end of file diff --git a/public/views/home.html b/public/views/home.html index b12bc2e..340af94 100644 --- a/public/views/home.html +++ b/public/views/home.html @@ -1,7 +1,5 @@ - -
{{ tagline }}
+Hey ! Bienvenue sur le site internet du Club Info !
+ Pour l'instant, on travaille encore dessus, donc n'hésites pas à t'y aventurer, mais prends garde, les erreurs 404 te guettent !
Nom | +Section | +Rôle | +Action | +
---|---|---|---|
{{ membre.login }} | +{{ membre.section }} | +{{ membre.role }} | ++ | +
+ + | ++ + | ++ + | ++ + | +
Nom | -Section | -Rôle | -Action | -
---|---|---|---|
{{ nerd.login }} | -{{ nerd.section }} | -{{ nerd.role }} | -- | -
- - | -- - | -- - | -- - | -