Commit 25f31ee2a67bf170078c248b7645854b7c387da6

Authored by Melody
1 parent e91de4c040

Add more to settings

Showing 2 changed files with 119 additions and 63 deletions Side-by-side Diff

scripts/SettingsController.js View file @ 25f31ee
1 1 angular.module('flashy.SettingsController', ['ui.router']).
2 2  
3   - controller('SettingsController', function($scope, $http) {
  3 + controller('SettingsController', function($rootScope, $resource, $scope, $state, $http, UserService) {
4 4 $scope.error = false;
5   - $scope.success = false;
6   - $scope.mismatch = false;
7   - $scope.unacceptable = false;
  5 + $scope.success = false;
  6 + $scope.mismatch = false;
  7 + $scope.unacceptable = false;
8 8  
9   - $scope.changePassword = function(oldPassword, newPassword, confirmedNewPassword) {
10   - console.log('in change password');
  9 + $scope.changePassword = function(oldPassword, newPassword, confirmedNewPassword) {
  10 + console.log('in change password');
  11 +
  12 + $http.patch('/api/me/', {
  13 + 'old_password': oldPassword,
  14 + 'new_password': newPassword
  15 + }).
  16 + success(function(data) {
11 17  
12   - $http.patch('/api/me/', {
13   - 'old_password': oldPassword,
14   - 'new_password': newPassword
15   - }).
16   - success(function(data) {
17   -
18   - console.log('password successfully changes');
19   -
20   - }).
21   - error(function(data) {
22   - console.log('not changed');
23   - });
  18 + console.log('password successfully changes');
  19 +
  20 + }).
  21 + error(function(data) {
  22 + console.log('not changed');
  23 + });
24 24  
25   -
26   - };
  25 +
  26 + };
  27 +
  28 + $rootScope.SectionResource = $resource('/api/sections/:sectionId/');
  29 + $rootScope.currentSection = {};
  30 + $rootScope.UserService = UserService;
  31 +
  32 + $scope.dropClass = function(section) {
  33 + $http.post('/api/sections/' + section.id + '/drop/').
  34 + success(function(data) {
  35 + console.log(section.short_name + ' dropped');
  36 +
  37 + Materialize.toast('Dropped', 3000, 'rounded');
  38 + }).
  39 + error(function(err) {
  40 + console.log('no drop for you');
  41 + });
  42 + };
27 43  
28 44  
29 45  
30   - console.log('checking to see if chrome');
31   - if (!chrome) {
  46 + console.log('checking to see if chrome');
  47 + if (true/*!chrome*/) {
32 48 return;
33 49 }
34 50 console.log('chrome');
templates/settings.html View file @ 25f31ee
1   -<div class="card" id="resetPasswordForm">
  1 +<div class="row">
  2 + <div class="col s6 offset-s3">
  3 + <div class="card-panel" id="dropClassForm">
  4 + <h2>Notification Settings</h2>
  5 + <!--
  6 + class="js-checkbox" name="notifbox" value="toggle notifs"> -->
  7 + <form action="#">
  8 + <input type="checkbox" id = "notifbox" class="js-checkbox" />
  9 + <label for="notifbox">Enable notifications</label>
  10 + </form>
  11 + </div>
  12 + </div>
  13 +</div>
2 14  
3   - <!--
4   - class="js-checkbox" name="notifbox" value="toggle notifs"> -->
5   - <form action="#">
6   - <input type="checkbox" id = "notifbox" class="js-checkbox" />
7   - <label for="notifbox">Check this to enable notifications</label>
8   - </form>
  15 +<div class="row">
  16 + <div class="col s6 offset-s3">
  17 + <div class="card-panel" id="resetPasswordForm">
9 18  
10   - <h2>Change Password</h2>
  19 + <h2>Change Password</h2>
11 20  
12   - <div class="row">
13   - <form class="col s12" name="ChangePasswordForm">
  21 + <form name="ChangePasswordForm">
14 22  
15   - <div class="row">
16   - <div class="input-field col s12">
17   - <input id="password" required type="password" name="oldpw" ng-model="oldPassword" class="validate">
18   - <label for="password">Old Password</label>
  23 + <div class="row">
  24 + <div class="input-field col s12">
  25 + <input id="password" required type="password" name="oldpw" ng-model="oldPassword" class="validate">
  26 + <label for="password">Old Password</label>
  27 + </div>
19 28 </div>
20   - </div>
21 29  
22   - <div role="alert">
23   - <span class="error" ng-show="ChangePasswordForm.oldpw.$error.required">
24   - Required!</span>
25   - </div>
  30 + <div role="alert">
  31 + <span class="error" ng-show="ChangePasswordForm.oldpw.$error.required">
  32 + Required!</span>
  33 + </div>
26 34  
27 35  
28   - <div class="row">
29   - <div class="input-field col s12">
30   - <input id="password" required ng-minlength=8 type="password" name="newpw" ng-model="newPassword" class="validate">
31   - <label for="password">New Password</label>
  36 + <div class="row">
  37 + <div class="input-field col s12">
  38 + <input id="password" required ng-minlength=8 type="password" name="newpw" ng-model="newPassword" class="validate">
  39 + <label for="password">New Password</label>
  40 + </div>
32 41 </div>
33   - </div>
34   -
35   - <div role="alert">
36   - <span class="error" ng-show="ChangePasswordForm.newpw.$error.minlength">
37   - New password must be at least 8 characters. </span>
38   - </div>
  42 +
  43 + <div role="alert">
  44 + <span class="error" ng-show="ChangePasswordForm.newpw.$error.minlength">
  45 + New password must be at least 8 characters. </span>
  46 + </div>
39 47  
40   - <div class="row">
41   - <div class="input-field col s12">
42   - <input id="password" required ng-minlength=8 compare-to="newpw" type="password" name="confirmpw" ng-model="confirmedNewPassword" class="validate">
43   - <label for="password">Confirm New Password</label>
  48 + <div class="row">
  49 + <div class="input-field col s12">
  50 + <input id="password" required ng-minlength=8 compare-to="newpw" type="password" name="confirmpw" ng-model="confirmedNewPassword" class="validate">
  51 + <label for="password">Confirm New Password</label>
  52 + </div>
44 53 </div>
45   - </div>
46   -
47   - <div role="alert">
48   - <span class="error" ng-show="ChangePasswordForm.confirm.$error.minlength">
49   - Must be the same as the new password. </span>
50   - </div>
  54 +
  55 + <div role="alert">
  56 + <span class="error" ng-show="ChangePasswordForm.confirm.$error.minlength">
  57 + Must be the same as the new password. </span>
  58 + </div>
51 59  
52 60  
53   - </form>
54   - <a class="waves-effect waves-light btn" id="resetPWButton"
  61 + </form>
  62 + <a class="waves-effect waves-light btn" id="resetPWButton"
55 63 ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Change Password</a>
  64 + </div>
  65 + </div>
  66 +</div>
  67 +
  68 +<div class="row">
  69 + <div class="col s6 offset-s3">
  70 + <div class="card-panel" id="dropClassForm">
  71 +
  72 + <h2>Enrolled Classes</h2>
  73 + <div class="row" style="padding: 0px 25px">
  74 + <table class="hoverable responsive-table">
  75 + <thead>
  76 + <tr>
  77 + <th data-field="id">Class</th>
  78 + <th data-field="drop">Drop?</th>
  79 + </tr>
  80 + </thead>
  81 +
  82 + <tbody>
  83 + <tr ng-repeat="section in UserService.getUserData().sections">
  84 + <td>
  85 + <span>{{section.short_name}}</span>
  86 + <p>{{section.long_name}}</p>
  87 + </td>
  88 + <td><a href="" ng-click="dropClass(section)"><i class="mdi-content-clear small"></i></a></td>
  89 + </tr>
  90 + </tbody>
  91 + </table>
  92 + </div>
  93 + </div>
  94 + </div>
  95 +</div>