Commit ad710526 authored by Gergely Ujvari's avatar Gergely Ujvari

Fetch subscriptions list from backend

The h.auth.local.ProfileController class (which handles account editing)
has now a profile GET call which sends back all subscriptions for an uri
(now a username)
parent a4d4a052
......@@ -28,7 +28,11 @@ class AccountController
$scope.$broadcast 'formState', form.$name, '' # Update status btn
$scope.tab = 'account'
$scope.tab = 'Account'
session.profile({user_id: $scope.persona}).$promise
.then (result) =>
$scope.subscriptions = result.subscriptions
# Data for each of the forms
$scope.editProfile = {}
$scope.changePassword = {}
......@@ -67,6 +71,17 @@ class AccountController
promise = session.edit_profile(packet)
promise.$promise.then(successHandler, errorHandler)
$scope.updated = (index, form) ->
packet =
username: $scope.persona
subscriptions: JSON.stringify $scope.subscriptions[index]
successHandler = angular.bind(null, onSuccess, form)
errorHandler = angular.bind(null, onError, form)
promise = session.edit_profile(packet)
promise.$promise.then(successHandler, errorHandler)
angular.module('h.auth')
.controller('AccountController', AccountController)
......@@ -111,6 +111,12 @@ configure = [
method: 'GET'
withCredentials: true
sessionProvider.actions.profile =
method: 'GET'
params:
__formid__: 'profile'
withCredentials: true
for action in AUTH_SESSION_ACTIONS
sessionProvider.actions[action] =
method: 'POST'
......
<div class="tabbable"
tab-reveal="['account', 'notifications']"
ng-controller="AccountController"
ng-model="tab"
>
<div class="tab-pane" title="Account" ng-click="tab = 'account'">
<form class="account-form form" name="changePasswordForm" ng-submit="submit(changePasswordForm)" novalidate form-validate>
<div class="tab-pane" title="Account">
<form class="account-form form"
name="changePasswordForm"
ng-submit="submit(changePasswordForm)"
novalidate form-validate>
<h2 class="form-heading"><span>Change Your Password</span></h2>
<div class="form-field">
......@@ -70,6 +72,16 @@
</div>
</form>
</div>
<div class="tab-pane" title="Notifications" ng-click="tab = 'notifications'">
<div class="tab-pane" title="Notifications">
<form class="account-form form" name="notificationsForm">
<ul>
<li ng-repeat="subscription in subscriptions">
<input type="checkbox"
ng-model="subscription.active"
ng-change="updated($index, notificationsForm)">
<span>{{subscription.description}}</span>
</li>
</ul>
</form>
</div>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment