Commit b5dead51c507e40feda943435abd76266b171812
1 parent
338930e1
Notifications
Showing
7 changed files
with
74 additions
and
28 deletions
Show diff stats
bower.json
1 | { | 1 | { |
2 | - "name": "ci-site", | ||
3 | - "version": "0.0.1", | ||
4 | - "dependencies": { | ||
5 | - "font-awesome": "latest", | ||
6 | - "angular": "latest", | ||
7 | - "angular-route": "latest", | ||
8 | - "bootswatch-dist": "3.3.2-cerulean", | ||
9 | - "jsencrypt": "~2.1.0" | ||
10 | - } | 2 | + "name": "ci-site", |
3 | + "version": "0.0.1", | ||
4 | + "dependencies": { | ||
5 | + "font-awesome": "latest", | ||
6 | + "angular": "latest", | ||
7 | + "angular-route": "latest", | ||
8 | + "bootswatch-dist": "3.3.2-cerulean", | ||
9 | + "jsencrypt": "~2.1.0", | ||
10 | + "animate.css": "~3.2.6", | ||
11 | + "remarkable-bootstrap-notify": "~3.0.0" | ||
12 | + } | ||
11 | } | 13 | } |
public/css/style.css
public/js/app.js
public/js/controllers/MembreCtrl.js
1 | -angular.module('MembreCtrl', []).controller('MembreCtrl', ['$scope', '$http', 'SessionServ', | ||
2 | - function ($scope, $http, SessionServ) { | 1 | +angular.module('MembreCtrl', []).controller('MembreCtrl', ['$scope', '$http', 'SessionServ', 'NotifyServ', |
2 | + function ($scope, $http, SessionServ, NotifyServ) { | ||
3 | $scope.formData = {}; | 3 | $scope.formData = {}; |
4 | 4 | ||
5 | $scope.session = SessionServ.cur; | 5 | $scope.session = SessionServ.cur; |
@@ -10,21 +10,20 @@ angular.module('MembreCtrl', []).controller('MembreCtrl', ['$scope', '$http', 'S | @@ -10,21 +10,20 @@ angular.module('MembreCtrl', []).controller('MembreCtrl', ['$scope', '$http', 'S | ||
10 | $http.get('/api/membres') | 10 | $http.get('/api/membres') |
11 | .success(function (data) { | 11 | .success(function (data) { |
12 | $scope.membres = data; | 12 | $scope.membres = data; |
13 | - console.log(data); | ||
14 | }) | 13 | }) |
15 | .error(function (data) { | 14 | .error(function (data) { |
16 | - console.log('Error: ' + data); | 15 | + NotifyServ.error("Impossible d'obtenir la liste des membres", data); |
17 | }); | 16 | }); |
18 | 17 | ||
19 | $scope.createMembre = function () { | 18 | $scope.createMembre = function () { |
20 | - console.log('Adding', $scope.formData); | ||
21 | $http.post('/api/membres', $scope.formData) | 19 | $http.post('/api/membres', $scope.formData) |
22 | .success(function (data) { | 20 | .success(function (data) { |
23 | $scope.formData = {}; | 21 | $scope.formData = {}; |
24 | $scope.membres = data; | 22 | $scope.membres = data; |
23 | + NotifyServ.success("Membre ajouté"); | ||
25 | }) | 24 | }) |
26 | .error(function (data) { | 25 | .error(function (data) { |
27 | - console.log('Error: ' + data); | 26 | + NotifyServ.error("Impossible d'ajouter le membre", data); |
28 | }); | 27 | }); |
29 | }; | 28 | }; |
30 | 29 | ||
@@ -32,10 +31,10 @@ angular.module('MembreCtrl', []).controller('MembreCtrl', ['$scope', '$http', 'S | @@ -32,10 +31,10 @@ angular.module('MembreCtrl', []).controller('MembreCtrl', ['$scope', '$http', 'S | ||
32 | $http.delete('/api/membres/' + id) | 31 | $http.delete('/api/membres/' + id) |
33 | .success(function (data) { | 32 | .success(function (data) { |
34 | $scope.membres = data; | 33 | $scope.membres = data; |
35 | - console.log(data); | 34 | + NotifyServ.success("Membre supprimé."); |
36 | }) | 35 | }) |
37 | .error(function (data) { | 36 | .error(function (data) { |
38 | - console.log('Error: ' + data); | 37 | + NotifyServ.error("Impossible de supprimer le membre", data); |
39 | }); | 38 | }); |
40 | }; | 39 | }; |
41 | 40 |
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +angular.module('NotifyServ', []).service('NotifyServ', [ | ||
2 | + function () { | ||
3 | + return { | ||
4 | + notify: function (type, message) { | ||
5 | + $.notify({ | ||
6 | + message: message | ||
7 | + }, { | ||
8 | + type: type, | ||
9 | + animate: { | ||
10 | + enter: 'animated bounceInDown', | ||
11 | + exit: 'animated bounceOutUp' | ||
12 | + } | ||
13 | + }); | ||
14 | + }, | ||
15 | + success: function (message) { | ||
16 | + this.notify('success', message); | ||
17 | + }, | ||
18 | + info: function (message) { | ||
19 | + this.notify('info', message); | ||
20 | + }, | ||
21 | + warn: function (message) { | ||
22 | + this.notify('warning', message); | ||
23 | + }, | ||
24 | + error: function (context, error) { | ||
25 | + this.notify('danger', context); | ||
26 | + console.error(context, error); | ||
27 | + } | ||
28 | + }; | ||
29 | + } | ||
30 | +]); |
public/js/services/SessionServ.js
1 | -angular.module('SessionsServ', []).service('SessionServ', ['$http', 'EncryptServ', | ||
2 | - function ($http, EncryptServ) { | 1 | +angular.module('SessionsServ', []).service('SessionServ', ['$http', 'EncryptServ', 'NotifyServ', |
2 | + function ($http, EncryptServ, NotifyServ) { | ||
3 | a = { | 3 | a = { |
4 | cur: false, | 4 | cur: false, |
5 | changeHandlers: [], | 5 | changeHandlers: [], |
@@ -12,9 +12,10 @@ angular.module('SessionsServ', []).service('SessionServ', ['$http', 'EncryptServ | @@ -12,9 +12,10 @@ angular.module('SessionsServ', []).service('SessionServ', ['$http', 'EncryptServ | ||
12 | } | 12 | } |
13 | }, | 13 | }, |
14 | updateSessionInfos: function (data) { | 14 | updateSessionInfos: function (data) { |
15 | - console.log("Connection:", data); | ||
16 | if (typeof data === 'object') { | 15 | if (typeof data === 'object') { |
17 | this.cur = data; | 16 | this.cur = data; |
17 | + } else if (data === 'expired') { | ||
18 | + NotifyServ.warn("Votre session a expiré"); | ||
18 | } else { | 19 | } else { |
19 | this.cur = false; | 20 | this.cur = false; |
20 | } | 21 | } |
@@ -43,19 +44,26 @@ angular.module('SessionsServ', []).service('SessionServ', ['$http', 'EncryptServ | @@ -43,19 +44,26 @@ angular.module('SessionsServ', []).service('SessionServ', ['$http', 'EncryptServ | ||
43 | EncryptServ.encrypt(data, function (dataCrypt) { | 44 | EncryptServ.encrypt(data, function (dataCrypt) { |
44 | $http.post('/api/session', [dataCrypt]).success(function (body) { | 45 | $http.post('/api/session', [dataCrypt]).success(function (body) { |
45 | _this.updateSessionInfos(body); | 46 | _this.updateSessionInfos(body); |
46 | - if (cb) { | ||
47 | - if (this.logged) { | 47 | + if (_this.cur) { |
48 | + NotifyServ.info("Connecté en tant que <strong>" + _this.cur.nom + "</strong>"); | ||
49 | + if (cb) | ||
48 | cb(null); | 50 | cb(null); |
49 | - } else { | ||
50 | - cb(body); | 51 | + } else { |
52 | + if (body === 'invalid') { | ||
53 | + NotifyServ.warn("Identifiants invalides"); | ||
51 | } | 54 | } |
55 | + if (cb) | ||
56 | + cb(body); | ||
52 | } | 57 | } |
53 | }); | 58 | }); |
54 | }); | 59 | }); |
55 | }, | 60 | }, |
56 | disconnect: function () { | 61 | disconnect: function () { |
57 | - this.updateSessionInfos(false); | ||
58 | - $http.delete('/api/session'); | 62 | + _this = this; |
63 | + $http.delete('/api/session').success(function () { | ||
64 | + _this.updateSessionInfos(false); | ||
65 | + NotifyServ.info("Déconnecté"); | ||
66 | + }); | ||
59 | } | 67 | } |
60 | }; | 68 | }; |
61 | a.get(); | 69 | a.get(); |
public/views/index.html
@@ -8,14 +8,17 @@ | @@ -8,14 +8,17 @@ | ||
8 | <title>Club Informatique de Polytech Lille</title> | 8 | <title>Club Informatique de Polytech Lille</title> |
9 | <link rel="stylesheet" href="libs/bootswatch-dist/css/bootstrap.min.css"> | 9 | <link rel="stylesheet" href="libs/bootswatch-dist/css/bootstrap.min.css"> |
10 | <link rel="stylesheet" href="css/style.css"> | 10 | <link rel="stylesheet" href="css/style.css"> |
11 | + <link rel="stylesheet" href="libs/animate.css/animate.min.css"> | ||
11 | <script src="libs/jquery/dist/jquery.min.js"></script> | 12 | <script src="libs/jquery/dist/jquery.min.js"></script> |
12 | <script src="libs/angular/angular.min.js"></script> | 13 | <script src="libs/angular/angular.min.js"></script> |
13 | <script src="libs/angular-route/angular-route.min.js"></script> | 14 | <script src="libs/angular-route/angular-route.min.js"></script> |
14 | <script src="libs/angular-bootstrap/ui-bootstrap.min.js"></script> | 15 | <script src="libs/angular-bootstrap/ui-bootstrap.min.js"></script> |
15 | <script src="libs/jsencrypt/bin/jsencrypt.min.js"></script> | 16 | <script src="libs/jsencrypt/bin/jsencrypt.min.js"></script> |
16 | - <script src="js/controllers/MembreCtrl.js"></script> | 17 | + <script src="libs/remarkable-bootstrap-notify/bootstrap-notify.min.js"></script> |
18 | + <script src="js/services/NotifyServ.js"></script> | ||
17 | <script src="js/services/EncryptServ.js"></script> | 19 | <script src="js/services/EncryptServ.js"></script> |
18 | <script src="js/services/SessionServ.js"></script> | 20 | <script src="js/services/SessionServ.js"></script> |
21 | + <script src="js/controllers/MembreCtrl.js"></script> | ||
19 | <script src="js/controllers/SessionCtrl.js"></script> | 22 | <script src="js/controllers/SessionCtrl.js"></script> |
20 | <script src="js/controllers/ConnectCtrl.js"></script> | 23 | <script src="js/controllers/ConnectCtrl.js"></script> |
21 | <script src="js/appRoutes.js"></script> | 24 | <script src="js/appRoutes.js"></script> |