diff --git a/docs-parent/TODO b/docs-parent/TODO index dc04a294..77c83d1a 100644 --- a/docs-parent/TODO +++ b/docs-parent/TODO @@ -1,2 +1 @@ - Reordering files (server) -- User settings \ No newline at end of file diff --git a/docs-web/src/main/webapp/index.html b/docs-web/src/main/webapp/index.html index f0f710eb..b8aa0b95 100644 --- a/docs-web/src/main/webapp/index.html +++ b/docs-web/src/main/webapp/index.html @@ -35,6 +35,7 @@ + @@ -45,11 +46,19 @@
diff --git a/docs-web/src/main/webapp/js/app.js b/docs-web/src/main/webapp/js/app.js index 96d22b8b..097d8537 100644 --- a/docs-web/src/main/webapp/js/app.js +++ b/docs-web/src/main/webapp/js/app.js @@ -3,7 +3,7 @@ /** * Trackino application. */ -var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.keypress', 'ui.sortable', 'restangular', 'ngSanitize']) +var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.keypress', 'ui.validate', 'ui.sortable', 'restangular', 'ngSanitize']) /** * Configuring modules. @@ -29,6 +29,15 @@ var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.ke } } }) + .state('settings', { + url: '/settings', + views: { + 'page': { + templateUrl: 'partial/settings.html', + controller: 'Settings' + } + } + }) .state('document', { url: '/document', abstract: true, diff --git a/docs-web/src/main/webapp/js/controller/DocumentEdit.js b/docs-web/src/main/webapp/js/controller/DocumentEdit.js index 50142b77..8c25e489 100644 --- a/docs-web/src/main/webapp/js/controller/DocumentEdit.js +++ b/docs-web/src/main/webapp/js/controller/DocumentEdit.js @@ -4,6 +4,16 @@ * Document edition controller. */ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams, Restangular, Tag) { + // Alerts + $scope.alerts = []; + + /** + * Close an alert. + */ + $scope.closeAlert = function(index) { + $scope.alerts.splice(index, 1); + }; + /** * Returns true if in edit mode (false in add mode). */ @@ -61,6 +71,7 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams, $scope.document = {}; $scope.newFiles = []; $scope.loadDocuments(); + $scope.alerts.push({ type: 'success', msg: 'Document successfully added' }); } } diff --git a/docs-web/src/main/webapp/js/controller/Main.js b/docs-web/src/main/webapp/js/controller/Main.js index 17384b71..5cc3b957 100644 --- a/docs-web/src/main/webapp/js/controller/Main.js +++ b/docs-web/src/main/webapp/js/controller/Main.js @@ -3,8 +3,8 @@ /** * Main controller. */ -App.controller('Main', function($scope, $state, User) { - User.userInfo(true).then(function(data) { +App.controller('Main', function($scope, $rootScope, $state, User) { + User.userInfo().then(function(data) { if (data.anonymous) { $state.transitionTo('login'); } else { diff --git a/docs-web/src/main/webapp/js/controller/Navigation.js b/docs-web/src/main/webapp/js/controller/Navigation.js index b213b8d3..01b8323d 100644 --- a/docs-web/src/main/webapp/js/controller/Navigation.js +++ b/docs-web/src/main/webapp/js/controller/Navigation.js @@ -3,6 +3,17 @@ /** * Navigation controller. */ -App.controller('Navigation', function($scope, $rootScope, User) { +App.controller('Navigation', function($scope, $state, $rootScope, User, Restangular) { $rootScope.userInfo = User.userInfo(); + + /** + * User logout. + */ + $scope.logout = function($event) { + User.logout().then(function() { + $rootScope.userInfo = User.userInfo(true); + $state.transitionTo('main'); + }); + $event.preventDefault(); + }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/js/controller/Settings.js b/docs-web/src/main/webapp/js/controller/Settings.js new file mode 100644 index 00000000..5bbcdd03 --- /dev/null +++ b/docs-web/src/main/webapp/js/controller/Settings.js @@ -0,0 +1,28 @@ +'use strict'; + +/** + * Settings controller. + */ +App.controller('Settings', function($scope, Restangular) { + $scope.editUserAlert = false; + + // Alerts + $scope.alerts = []; + + /** + * Close an alert. + */ + $scope.closeAlert = function(index) { + $scope.alerts.splice(index, 1); + }; + + /** + * Edit user. + */ + $scope.editUser = function() { + Restangular.one('user').post('', $scope.user).then(function() { + $scope.user = {}; + $scope.alerts.push({ type: 'success', msg: 'Account successfully updated' }); + }); + }; +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/js/service/User.js b/docs-web/src/main/webapp/js/service/User.js index 8999aae8..eb0e9171 100644 --- a/docs-web/src/main/webapp/js/service/User.js +++ b/docs-web/src/main/webapp/js/service/User.js @@ -23,6 +23,13 @@ App.factory('User', function(Restangular) { */ login: function(user) { return Restangular.one('user').post('login', user); + }, + + /** + * Logout the current user. + */ + logout: function() { + return Restangular.one('user').post('logout', {}); } } }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/partial/document.edit.html b/docs-web/src/main/webapp/partial/document.edit.html index f5b0e06a..517bd211 100644 --- a/docs-web/src/main/webapp/partial/document.edit.html +++ b/docs-web/src/main/webapp/partial/document.edit.html @@ -38,4 +38,6 @@