Commit c9024fa8e9d9ee0b7955801cdb8ad2b6f7aaf1f5
Exists in
master
and in
1 other branch
merge?
Showing 2 changed files Side-by-side Diff
scripts/SettingsController.js
View file @
c9024fa
1 | 1 | angular.module('flashy.SettingsController', ['ui.router']). |
2 | 2 | |
3 | - controller('SettingsController', function($scope, $http) { | |
4 | - $scope.changePassword = function(oldPassword, newPassword, confirmedNewPassword) { | |
3 | + controller('SettingsController', function($rootScope, $resource, $scope, $state, $http, UserService) { | |
4 | + $scope.error = false; | |
5 | + $scope.success = false; | |
6 | + $scope.mismatch = false; | |
7 | + $scope.unacceptable = false; | |
5 | 8 | |
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) { | |
17 | + | |
18 | + console.log('password successfully changes'); | |
19 | + | |
20 | + }). | |
21 | + error(function(data) { | |
22 | + console.log('not changed'); | |
23 | + }); | |
24 | + | |
25 | + | |
6 | 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 | + }; | |
43 | + | |
44 | + | |
45 | + | |
7 | 46 | console.log('checking to see if chrome'); |
47 | + | |
8 | 48 | if (!chrome) { |
9 | 49 | pushSwitch.disabled = true; |
10 | 50 | return; |
templates/settings.html
View file @
c9024fa
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"> | |
21 | + <form name="ChangePasswordForm"> | |
14 | 22 | |
15 | - <div class="row"> | |
16 | - <div class="input-field col s12"> | |
17 | - <input id="password" type="password" 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 class="row"> | |
23 | - <div class="input-field col s12"> | |
24 | - <input id="password" type="password" ng-model="newPassword" class="validate"> | |
25 | - <label for="password">New Password</label> | |
30 | + <div role="alert"> | |
31 | + <span class="error" ng-show="ChangePasswordForm.oldpw.$error.required"> | |
32 | + Required!</span> | |
26 | 33 | </div> |
27 | - </div> | |
28 | 34 | |
29 | - <div class="row"> | |
30 | - <div class="input-field col s12"> | |
31 | - <input id="password" type="password" ng-model="confirmedNewPassword" class="validate"> | |
32 | - <label for="password">Confirm New Password</label> | |
35 | + | |
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> | |
33 | 41 | </div> |
34 | - </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> | |
35 | 47 | |
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> | |
53 | + </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> | |
36 | 59 | |
37 | - </form> | |
38 | 60 | |
39 | - <a class="waves-effect waves-light btn" id="resetPWButton" | |
40 | - ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Reset Password</a> | |
41 | - | |
61 | + </form> | |
62 | + <a class="waves-effect waves-light btn" id="resetPWButton" | |
63 | + ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Change Password</a> | |
64 | + </div> | |
42 | 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> | |
43 | 95 | </div> |