profile page

This commit is contained in:
Athou
2013-04-13 12:19:59 +02:00
parent b3465f33c1
commit 6739166b04
8 changed files with 136 additions and 2 deletions

View File

@@ -261,6 +261,9 @@ module.controller('ToolbarCtrl',
$scope.toSettings = function() {
$location.path('settings');
};
$scope.toProfile = function() {
$location.path('profile');
};
});
module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
@@ -556,6 +559,27 @@ module.controller('SettingsCtrl', function($scope, $location, SettingsService) {
};
});
module.controller('ProfileCtrl', function($scope, $location, SessionService) {
$scope.user = SessionService.get();
$scope.cancel = function() {
$location.path('/');
};
$scope.save = function() {
if (!$scope.profileForm.$valid) {
return;
}
var o = {
email : $scope.user.email
};
if ($scope.user.password == $scope.password_c) {
o.password = $scope.user.password;
}
SessionService.save(o);
$location.path('/');
};
});
module.controller('ManageSettingsCtrl', function($scope, $location, $state,
AdminSettingsService) {

View File

@@ -50,6 +50,12 @@ app.config(function($routeProvider, $stateProvider, $urlRouterProvider) {
templateUrl : 'templates/settings.html',
controller : 'SettingsCtrl'
});
$stateProvider.state('profile', {
url : '/profile',
templateUrl : 'templates/profile.html',
controller : 'ProfileCtrl'
});
$urlRouterProvider.when('/', '/feeds/view/category/all');
$urlRouterProvider.when('/admin', '/admin/settings');

View File

@@ -1,7 +1,21 @@
var module = angular.module('commafeed.services', [ 'ngResource' ]);
module.factory('SessionService', function($resource) {
return $resource('rest/session/get');
var actions = {
get : {
method : 'GET',
params : {
_method : 'get'
}
},
save : {
method : 'POST',
params : {
_method : 'save'
}
}
};
return $resource('rest/session/:_method', {}, actions);
});
module.factory('SubscriptionService', function($resource, $http) {

View File

@@ -17,9 +17,10 @@
<a class="btn dropdown-toggle" data-toggle="dropdown" href="settings"><i class="icon-cog"></i> {{session.name}} <span class="caret"></span></a>
<ul class="dropdown-menu pull-right">
<li><a ng-click="toSettings()"><i class="icon-wrench"></i> Settings</a></li>
<li><a ng-click="toProfile()"><i class="icon-user"></i> Profile</a></li>
<li ng-show="session.admin"><a ng-click="toAdmin()"><i class="icon-edit"></i> Admin</a></li>
<li class="divider"></li>
<li><a href="logout"><i class="icon-user"></i> Logout</a></li>
<li><a href="logout"><i class="icon-off"></i> Logout</a></li>
</ul>
</div>
</span>

View File

@@ -0,0 +1,36 @@
<div class="container profile">
<div class="page-header">
<h1>Profile</h1>
</div>
{{user}}
{{profileForm.$valid}}
<form name="profileForm" ng-submit="save()" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="email">E-mail</label>
<div class="controls">
<input type="email" id="email" ng-model="user.email" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="password">Change password</label>
<div class="controls">
<input type="password" name="password" id="password" ng-model="user.password"
ng-minlength="6" />
<span class="help-inline" ng-show="profileForm.password.$error.minlength">Minimum 6 characters</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="password">Confirm password</label>
<div class="controls">
<input type="password" name="password_c" id="password_c" ng-model="password_c"
ui-validate="'$value==user.password'" ui-validate-watch="'user.password'">
<span class="help-inline" ng-show="profileForm.password_c.$error.validator">Passwords do not match</span>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn" ng-click="cancel()">Cancel</button>
</div>
</form>
</div>