Commit c9024fa8e9d9ee0b7955801cdb8ad2b6f7aaf1f5
Exists in
master
and in
1 other branch
merge?
Showing 2 changed files Inline Diff
scripts/SettingsController.js
View file @
c9024fa
angular.module('flashy.SettingsController', ['ui.router']). | 1 | 1 | angular.module('flashy.SettingsController', ['ui.router']). | |
2 | 2 | |||
controller('SettingsController', function($scope, $http) { | 3 | 3 | controller('SettingsController', function($rootScope, $resource, $scope, $state, $http, UserService) { | |
$scope.changePassword = function(oldPassword, newPassword, confirmedNewPassword) { | 4 | 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 | ||||
console.log('checking to see if chrome'); | 7 | 46 | console.log('checking to see if chrome'); | |
47 | ||||
if (!chrome) { | 8 | 48 | if (!chrome) { | |
pushSwitch.disabled = true; | 9 | 49 | pushSwitch.disabled = true; | |
return; | 10 | 50 | return; | |
} | 11 | 51 | } | |
12 | 52 | |||
console.log('chrome'); | 13 | 53 | console.log('chrome'); | |
14 | 54 | |||
console.log('executing things outside of module'); | 15 | 55 | console.log('executing things outside of module'); | |
var PUSH_SERVER_URL = '/api/subscribe/'; | 16 | 56 | var PUSH_SERVER_URL = '/api/subscribe/'; | |
var UNPUSH_SERVER_URL = '/api/unsubscribe/'; | 17 | 57 | var UNPUSH_SERVER_URL = '/api/unsubscribe/'; | |
18 | 58 | |||
function onPushSubscription(pushSubscription) { | 19 | 59 | function onPushSubscription(pushSubscription) { | |
console.log('pushSubscription = ', pushSubscription.endpoint); | 20 | 60 | console.log('pushSubscription = ', pushSubscription.endpoint); | |
// Here we would normally send the endpoint | 21 | 61 | // Here we would normally send the endpoint | |
// and subscription ID to our server. | 22 | 62 | // and subscription ID to our server. | |
// In this demo we just use send these values to | 23 | 63 | // In this demo we just use send these values to | |
// our server via XHR which sends a push message. | 24 | 64 | // our server via XHR which sends a push message. | |
25 | 65 | |||
var endpoint = pushSubscription.endpoint; | 26 | 66 | var endpoint = pushSubscription.endpoint; | |
var subscriptionId = pushSubscription.subscriptionId; | 27 | 67 | var subscriptionId = pushSubscription.subscriptionId; | |
28 | 68 | |||
console.log('registration_id: ', subscriptionId); | 29 | 69 | console.log('registration_id: ', subscriptionId); | |
$http.post(PUSH_SERVER_URL, {'registration_id': subscriptionId}); | 30 | 70 | $http.post(PUSH_SERVER_URL, {'registration_id': subscriptionId}); | |
} | 31 | 71 | } | |
32 | 72 | |||
function removeSubscription(pushSubscription) { | 33 | 73 | function removeSubscription(pushSubscription) { | |
console.log('removing subscription'); | 34 | 74 | console.log('removing subscription'); | |
console.log('pushSubscription endpoint = ', pushSubscription.endpoint); | 35 | 75 | console.log('pushSubscription endpoint = ', pushSubscription.endpoint); | |
36 | 76 | |||
var subscriptionId = pushSubscription.subscriptionId; | 37 | 77 | var subscriptionId = pushSubscription.subscriptionId; | |
38 | 78 | |||
console.log('registration_id: ', subscriptionId); | 39 | 79 | console.log('registration_id: ', subscriptionId); | |
$http.post(UNPUSH_SERVER_URL, {'registration_id': subscriptionId}); | 40 | 80 | $http.post(UNPUSH_SERVER_URL, {'registration_id': subscriptionId}); | |
} | 41 | 81 | } | |
42 | 82 | |||
function subscribeDevice() { | 43 | 83 | function subscribeDevice() { | |
// We need the service worker registration to access the push manager | 44 | 84 | // We need the service worker registration to access the push manager | |
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { | 45 | 85 | navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { | |
serviceWorkerRegistration.pushManager.subscribe() | 46 | 86 | serviceWorkerRegistration.pushManager.subscribe() | |
.then(onPushSubscription) | 47 | 87 | .then(onPushSubscription) | |
.catch(function(e) { | 48 | 88 | .catch(function(e) { | |
console.log('Error in subscribing'); | 49 | 89 | console.log('Error in subscribing'); | |
// Check for a permission prompt issue | 50 | 90 | // Check for a permission prompt issue | |
if ('permissions' in navigator) { | 51 | 91 | if ('permissions' in navigator) { | |
navigator.permissions.query({name: 'push', userVisibleOnly: true}) | 52 | 92 | navigator.permissions.query({name: 'push', userVisibleOnly: true}) | |
.then(function(permissionStatus) { | 53 | 93 | .then(function(permissionStatus) { | |
console.log('subscribe() Error: Push permission status = ', | 54 | 94 | console.log('subscribe() Error: Push permission status = ', | |
permissionStatus); | 55 | 95 | permissionStatus); | |
if (permissionStatus.status === 'denied') { | 56 | 96 | if (permissionStatus.status === 'denied') { | |
pushSwitch.checked = false; | 57 | 97 | pushSwitch.checked = false; | |
pushSwitch.disabled = true; | 58 | 98 | pushSwitch.disabled = true; | |
// The user blocked the permission prompt | 59 | 99 | // The user blocked the permission prompt | |
console.log('Ooops Notifications are Blocked', | 60 | 100 | console.log('Ooops Notifications are Blocked', | |
'Unfortunately you just permanently blocked notifications. ' + | 61 | 101 | 'Unfortunately you just permanently blocked notifications. ' + | |
'Please unblock / allow them to switch on push ' + | 62 | 102 | 'Please unblock / allow them to switch on push ' + | |
'notifications.'); | 63 | 103 | 'notifications.'); | |
} else { | 64 | 104 | } else { | |
pushSwitch.checked = false; | 65 | 105 | pushSwitch.checked = false; | |
console.log('Ooops Push Couldn\'t Register', | 66 | 106 | console.log('Ooops Push Couldn\'t Register', | |
'<p>When we tried to ' + | 67 | 107 | '<p>When we tried to ' + | |
'get the subscription ID for GCM, something went wrong,' + | 68 | 108 | 'get the subscription ID for GCM, something went wrong,' + | |
' not sure why.</p>' + | 69 | 109 | ' not sure why.</p>' + | |
'<p>Have you defined "gcm_sender_id" and ' + | 70 | 110 | '<p>Have you defined "gcm_sender_id" and ' + | |
'"gcm_user_visible_only" in the manifest?</p>' + | 71 | 111 | '"gcm_user_visible_only" in the manifest?</p>' + | |
'<p>Error message: ' + | 72 | 112 | '<p>Error message: ' + | |
e.message + | 73 | 113 | e.message + | |
'</p>'); | 74 | 114 | '</p>'); | |
} | 75 | 115 | } | |
}).catch(function(err) { | 76 | 116 | }).catch(function(err) { | |
pushSwitch.checked = false; | 77 | 117 | pushSwitch.checked = false; | |
console.log('Ooops Push Couldn\'t Register', | 78 | 118 | console.log('Ooops Push Couldn\'t Register', | |
'<p>When we tried to ' + | 79 | 119 | '<p>When we tried to ' + | |
'get the subscription ID for GCM, something went wrong, not ' + | 80 | 120 | 'get the subscription ID for GCM, something went wrong, not ' + | |
'sure why.</p>' + | 81 | 121 | 'sure why.</p>' + | |
'<p>Have you defined "gcm_sender_id" and ' + | 82 | 122 | '<p>Have you defined "gcm_sender_id" and ' + | |
'"gcm_user_visible_only" in the manifest?</p>' + | 83 | 123 | '"gcm_user_visible_only" in the manifest?</p>' + | |
'<p>Error message: ' + | 84 | 124 | '<p>Error message: ' + | |
err.message + | 85 | 125 | err.message + | |
'</p>'); | 86 | 126 | '</p>'); | |
}); | 87 | 127 | }); | |
} else { | 88 | 128 | } else { | |
// Use notification permission to do something | 89 | 129 | // Use notification permission to do something | |
if (Notification.permission === 'denied') { | 90 | 130 | if (Notification.permission === 'denied') { | |
pushSwitch.disabled = true; | 91 | 131 | pushSwitch.disabled = true; | |
pushSwitch.checked = false; | 92 | 132 | pushSwitch.checked = false; | |
console.log('Ooops Notifications are Blocked', | 93 | 133 | console.log('Ooops Notifications are Blocked', | |
'Unfortunately you just permanently blocked notifications. ' + | 94 | 134 | 'Unfortunately you just permanently blocked notifications. ' + | |
'Please unblock / allow them to switch on push notifications.'); | 95 | 135 | 'Please unblock / allow them to switch on push notifications.'); | |
} else { | 96 | 136 | } else { | |
pushSwitch.checked = false; | 97 | 137 | pushSwitch.checked = false; | |
console.log('Ooops Push Couldn\'t Register', | 98 | 138 | console.log('Ooops Push Couldn\'t Register', | |
'<p>When we tried to ' + | 99 | 139 | '<p>When we tried to ' + | |
'get the subscription ID for GCM, something went wrong, not ' + | 100 | 140 | 'get the subscription ID for GCM, something went wrong, not ' + | |
'sure why.</p>' + | 101 | 141 | 'sure why.</p>' + | |
'<p>Have you defined "gcm_sender_id" and ' + | 102 | 142 | '<p>Have you defined "gcm_sender_id" and ' + | |
'"gcm_user_visible_only" in the manifest?</p>' + | 103 | 143 | '"gcm_user_visible_only" in the manifest?</p>' + | |
'<p>Error message: ' + | 104 | 144 | '<p>Error message: ' + | |
e.message + | 105 | 145 | e.message + | |
'</p>'); | 106 | 146 | '</p>'); | |
} | 107 | 147 | } | |
} | 108 | 148 | } | |
}); | 109 | 149 | }); | |
}); | 110 | 150 | }); | |
} | 111 | 151 | } | |
112 | 152 | |||
function unsubscribeDevice() { | 113 | 153 | function unsubscribeDevice() { | |
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { | 114 | 154 | navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { | |
serviceWorkerRegistration.pushManager.getSubscription().then( | 115 | 155 | serviceWorkerRegistration.pushManager.getSubscription().then( | |
function(pushSubscription) { | 116 | 156 | function(pushSubscription) { | |
// Check we have everything we need to unsubscribe | 117 | 157 | // Check we have everything we need to unsubscribe | |
if (!pushSubscription) { | 118 | 158 | if (!pushSubscription) { | |
pushSwitch.checked = false; | 119 | 159 | pushSwitch.checked = false; | |
return; | 120 | 160 | return; | |
} | 121 | 161 | } | |
122 | 162 | |||
// TODO: Remove the device details from the server | 123 | 163 | // TODO: Remove the device details from the server | |
// i.e. the pushSubscription.subscriptionId and | 124 | 164 | // i.e. the pushSubscription.subscriptionId and | |
// pushSubscription.endpoint | 125 | 165 | // pushSubscription.endpoint | |
var subscriptionId = pushSubscription.subscriptionId; | 126 | 166 | var subscriptionId = pushSubscription.subscriptionId; | |
127 | 167 | |||
pushSubscription.unsubscribe().then(function(successful) { | 128 | 168 | pushSubscription.unsubscribe().then(function(successful) { | |
console.log('Unsubscribed from push: ', successful); | 129 | 169 | console.log('Unsubscribed from push: ', successful); | |
130 | 170 | |||
if (!successful) { | 131 | 171 | if (!successful) { | |
// The unsubscribe was unsuccessful, but we can | 132 | 172 | // The unsubscribe was unsuccessful, but we can | |
// remove the subscriptionId from our server | 133 | 173 | // remove the subscriptionId from our server | |
// and notifications will stop | 134 | 174 | // and notifications will stop | |
// This just may be in a bad state when the user returns | 135 | 175 | // This just may be in a bad state when the user returns | |
pushSwitch.checked = true; | 136 | 176 | pushSwitch.checked = true; | |
removeSubscription(pushSubscription); | 137 | 177 | removeSubscription(pushSubscription); | |
console.error('We were unable to unregister from push, but we removed'+ | 138 | 178 | console.error('We were unable to unregister from push, but we removed'+ | |
'registration id from the server'); | 139 | 179 | 'registration id from the server'); | |
} | 140 | 180 | } | |
141 | 181 | |||
}).catch(function(e) { | 142 | 182 | }).catch(function(e) { | |
console.log('Unsubscribtion error: ', e); | 143 | 183 | console.log('Unsubscribtion error: ', e); | |
}); | 144 | 184 | }); | |
}.bind(this)).catch(function(e) { | 145 | 185 | }.bind(this)).catch(function(e) { | |
console.error('Error thrown while revoking push notifications. ' + | 146 | 186 | console.error('Error thrown while revoking push notifications. ' + | |
'Most likely because push was never registered', e); | 147 | 187 | 'Most likely because push was never registered', e); | |
}); | 148 | 188 | }); | |
}); | 149 | 189 | }); | |
} | 150 | 190 | } | |
151 | 191 | |||
function permissionStatusChange(permissionStatus) { | 152 | 192 | function permissionStatusChange(permissionStatus) { | |
console.log('permissionStatusChange = ', permissionStatus); | 153 | 193 | console.log('permissionStatusChange = ', permissionStatus); | |
// If the notification permission is denied, it's a permanent block | 154 | 194 | // If the notification permission is denied, it's a permanent block | |
switch (permissionStatus.status) { | 155 | 195 | switch (permissionStatus.status) { | |
case 'denied': | 156 | 196 | case 'denied': | |
pushSwitch.disabled = true; | 157 | 197 | pushSwitch.disabled = true; | |
console.log('Ooops Push has been Blocked', | 158 | 198 | console.log('Ooops Push has been Blocked', | |
'Unfortunately the user permanently blocked push. Please unblock / ' + | 159 | 199 | 'Unfortunately the user permanently blocked push. Please unblock / ' + | |
'allow them to switch on push notifications.'); | 160 | 200 | 'allow them to switch on push notifications.'); | |
break; | 161 | 201 | break; | |
case 'granted': | 162 | 202 | case 'granted': | |
// Set the state of the push switch | 163 | 203 | // Set the state of the push switch | |
console.log('case granted'); | 164 | 204 | console.log('case granted'); | |
break; | 165 | 205 | break; | |
case 'prompt': | 166 | 206 | case 'prompt': | |
pushSwitch.checked = false; | 167 | 207 | pushSwitch.checked = false; | |
console.log('case prompt'); | 168 | 208 | console.log('case prompt'); | |
break; | 169 | 209 | break; | |
} | 170 | 210 | } | |
} | 171 | 211 | } | |
172 | 212 | |||
function setUpPushPermission() { | 173 | 213 | function setUpPushPermission() { | |
navigator.permissions.query({name: 'push', userVisibleOnly: true}) | 174 | 214 | navigator.permissions.query({name: 'push', userVisibleOnly: true}) | |
.then(function(permissionStatus) { | 175 | 215 | .then(function(permissionStatus) { | |
// Set the initial state | 176 | 216 | // Set the initial state | |
permissionStatusChange(permissionStatus); | 177 | 217 | permissionStatusChange(permissionStatus); | |
178 | 218 | |||
// Handle Permission State Changes | 179 | 219 | // Handle Permission State Changes | |
permissionStatus.onchange = function() { | 180 | 220 | permissionStatus.onchange = function() { | |
permissionStatusChange(this); | 181 | 221 | permissionStatusChange(this); | |
}; | 182 | 222 | }; | |
183 | 223 | |||
// Check if push is supported and what the current state is | 184 | 224 | // Check if push is supported and what the current state is | |
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { | 185 | 225 | navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { | |
// Let's see if we have a subscription already | 186 | 226 | // Let's see if we have a subscription already | |
serviceWorkerRegistration.pushManager.getSubscription() | 187 | 227 | serviceWorkerRegistration.pushManager.getSubscription() | |
.then(function(subscription) { | 188 | 228 | .then(function(subscription) { | |
if (!subscription) { | 189 | 229 | if (!subscription) { | |
// NOOP | 190 | 230 | // NOOP | |
return; | 191 | 231 | return; | |
} | 192 | 232 | } | |
193 | 233 | |||
console.log('update current state.'); | 194 | 234 | console.log('update current state.'); | |
// Update the current state with the | 195 | 235 | // Update the current state with the | |
// subscriptionid and endpoint | 196 | 236 | // subscriptionid and endpoint | |
onPushSubscription(subscription); | 197 | 237 | onPushSubscription(subscription); | |
}) | 198 | 238 | }) | |
.catch(function(e) { | 199 | 239 | .catch(function(e) { | |
console.log('An error occured while calling getSubscription()', e); | 200 | 240 | console.log('An error occured while calling getSubscription()', e); | |
}); | 201 | 241 | }); | |
}); | 202 | 242 | }); | |
}).catch(function(err) { | 203 | 243 | }).catch(function(err) { | |
console.log('Ooops Unable to check the permission', | 204 | 244 | console.log('Ooops Unable to check the permission', | |
'Unfortunately the permission for push notifications couldn\'t be ' + | 205 | 245 | 'Unfortunately the permission for push notifications couldn\'t be ' + | |
'checked. Are you on Chrome 43+?'); | 206 | 246 | 'checked. Are you on Chrome 43+?'); | |
}); | 207 | 247 | }); | |
} | 208 | 248 | } | |
209 | 249 | |||
function setUpNotificationPermission() { | 210 | 250 | function setUpNotificationPermission() { | |
console.log('setting notification setting'); | 211 | 251 | console.log('setting notification setting'); | |
212 | 252 | |||
if (Notification.permission === 'default') { | 213 | 253 | if (Notification.permission === 'default') { | |
console.log('notification permissions === default'); | 214 | 254 | console.log('notification permissions === default'); | |
return; | 215 | 255 | return; | |
} | 216 | 256 | } | |
217 | 257 | |||
// Check if push is supported and what the current state is | 218 | 258 | // Check if push is supported and what the current state is | |
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { | 219 | 259 | navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { | |
// Let's see if we have a subscription already | 220 | 260 | // Let's see if we have a subscription already | |
serviceWorkerRegistration.pushManager.getSubscription() | 221 | 261 | serviceWorkerRegistration.pushManager.getSubscription() | |
.then(function(subscription) { | 222 | 262 | .then(function(subscription) { | |
if (!subscription) { | 223 | 263 | if (!subscription) { | |
// NOOP | 224 | 264 | // NOOP | |
console.log('not subscription'); | 225 | 265 | console.log('not subscription'); | |
return; | 226 | 266 | return; | |
} | 227 | 267 | } | |
228 | 268 | |||
// Update the current state with the | 229 | 269 | // Update the current state with the | |
// subscriptionid and endpoint | 230 | 270 | // subscriptionid and endpoint | |
console.log('onpushsubscription should be entered'); | 231 | 271 | console.log('onpushsubscription should be entered'); | |
onPushSubscription(subscription); | 232 | 272 | onPushSubscription(subscription); | |
}) | 233 | 273 | }) | |
.catch(function(e) { | 234 | 274 | .catch(function(e) { | |
console.log('An error occured while calling getSubscription()', e); | 235 | 275 | console.log('An error occured while calling getSubscription()', e); | |
}); | 236 | 276 | }); | |
}); | 237 | 277 | }); | |
} | 238 | 278 | } | |
239 | 279 | |||
// Once the service worker is registered set the initial state | 240 | 280 | // Once the service worker is registered set the initial state | |
function initialiseState() { | 241 | 281 | function initialiseState() { | |
// Check if notifications are supported | 242 | 282 | // Check if notifications are supported | |
if (!('showNotification' in ServiceWorkerRegistration.prototype)) { | 243 | 283 | if (!('showNotification' in ServiceWorkerRegistration.prototype)) { | |
console.warn('Notifications aren\'t supported.'); | 244 | 284 | console.warn('Notifications aren\'t supported.'); | |
return; | 245 | 285 | return; | |
} | 246 | 286 | } | |
// Check the current Notification permission. | 247 | 287 | // Check the current Notification permission. | |
// If its denied, it's a permanent block until the | 248 | 288 | // If its denied, it's a permanent block until the | |
// user changes the permission | 249 | 289 | // user changes the permission | |
else if (Notification.permission === 'denied') { | 250 | 290 | else if (Notification.permission === 'denied') { | |
console.log('Ooops Notifications are Blocked', | 251 | 291 | console.log('Ooops Notifications are Blocked', | |
'Unfortunately notifications are permanently blocked. Please unblock / ' + | 252 | 292 | 'Unfortunately notifications are permanently blocked. Please unblock / ' + | |
'allow them to switch on push notifications.'); | 253 | 293 | 'allow them to switch on push notifications.'); | |
return; | 254 | 294 | return; | |
} | 255 | 295 | } | |
// Check if push messaging is supported | 256 | 296 | // Check if push messaging is supported | |
else if (!('PushManager' in window)) { | 257 | 297 | else if (!('PushManager' in window)) { | |
console.warn('Push messaging isn\'t supported.'); | 258 | 298 | console.warn('Push messaging isn\'t supported.'); | |
return; | 259 | 299 | return; | |
} | 260 | 300 | } | |
261 | 301 | |||
pushSwitch.disabled = false; | 262 | 302 | pushSwitch.disabled = false; | |
// Is the Permissions API supported | 263 | 303 | // Is the Permissions API supported | |
if ('permissions' in navigator) { | 264 | 304 | if ('permissions' in navigator) { | |
console.log('setting push permissions'); | 265 | 305 | console.log('setting push permissions'); | |
setUpPushPermission(); | 266 | 306 | setUpPushPermission(); | |
return; | 267 | 307 | return; | |
} else { | 268 | 308 | } else { | |
console.log('setting notification permissions'); | 269 | 309 | console.log('setting notification permissions'); | |
setUpNotificationPermission(); | 270 | 310 | setUpNotificationPermission(); | |
} | 271 | 311 | } | |
} | 272 | 312 | } | |
273 | 313 | |||
var enablePushSwitch = $('.js-checkbox'); | 274 | 314 | var enablePushSwitch = $('.js-checkbox'); | |
275 | 315 | |||
var pushSwitch = document.getElementById("notifbox"); | 276 | 316 | var pushSwitch = document.getElementById("notifbox"); | |
pushSwitch.disabled = true; | 277 | 317 | pushSwitch.disabled = true; | |
278 | 318 | |||
var ua = navigator.userAgent.toLowerCase(); | 279 | 319 | var ua = navigator.userAgent.toLowerCase(); | |
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); | 280 | 320 | var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); | |
281 | 321 | |||
if(!isAndroid) { | 282 | 322 | if(!isAndroid) { | |
// Do something! | 283 | 323 | // Do something! | |
// Redirect to Android-site? | 284 | 324 | // Redirect to Android-site? |
templates/settings.html
View file @
c9024fa
<div class="card" id="resetPasswordForm"> | 1 | 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 | 15 | <div class="row"> | |
class="js-checkbox" name="notifbox" value="toggle notifs"> --> | 4 | 16 | <div class="col s6 offset-s3"> | |
<form action="#"> | 5 | 17 | <div class="card-panel" id="resetPasswordForm"> | |
<input type="checkbox" id = "notifbox" class="js-checkbox" /> | 6 | |||
<label for="notifbox">Check this to enable notifications</label> | 7 | |||
</form> | 8 | |||
9 | 18 | |||
<h2>Change Password</h2> | 10 | 19 | <h2>Change Password</h2> | |
11 | 20 | |||
<div class="row"> | 12 | 21 | <form name="ChangePasswordForm"> | |
<form class="col s12"> | 13 | |||
14 | 22 | |||
<div class="row"> | 15 | 23 | <div class="row"> | |
<div class="input-field col s12"> | 16 | 24 | <div class="input-field col s12"> | |
<input id="password" type="password" ng-model="oldPassword" class="validate"> | 17 | 25 | <input id="password" required type="password" name="oldpw" ng-model="oldPassword" class="validate"> | |
<label for="password">Old Password</label> | 18 | 26 | <label for="password">Old Password</label> | |
27 | </div> | |||
</div> | 19 | 28 | </div> | |
</div> | 20 | |||
21 | 29 | |||
<div class="row"> | 22 | 30 | <div role="alert"> | |
<div class="input-field col s12"> | 23 | 31 | <span class="error" ng-show="ChangePasswordForm.oldpw.$error.required"> | |
<input id="password" type="password" ng-model="newPassword" class="validate"> | 24 | 32 | Required!</span> | |
<label for="password">New Password</label> | 25 | |||
</div> | 26 | 33 | </div> | |
</div> | 27 | |||
28 | 34 | |||
<div class="row"> | 29 | 35 | ||
<div class="input-field col s12"> | 30 | 36 | <div class="row"> | |
<input id="password" type="password" ng-model="confirmedNewPassword" class="validate"> | 31 | 37 | <div class="input-field col s12"> | |
<label for="password">Confirm New Password</label> | 32 | 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> | |||
</div> | 33 | 41 | </div> | |
</div> | 34 | 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 | |||
</form> | 37 | |||
38 | 60 | |||
<a class="waves-effect waves-light btn" id="resetPWButton" | 39 | 61 | </form> | |
ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Reset Password</a> | 40 | 62 | <a class="waves-effect waves-light btn" id="resetPWButton" | |
41 | 63 | ng-click="changePassword(oldPassword, newPassword, confirmedNewPassword)">Change Password</a> | ||
64 | </div> | |||
</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> | |||
</div> | 43 | 95 | </div> | |
44 | 96 | |||
45 | ||||
46 | ||||