diff --git a/config.js b/config.js
index 6dde881..72a3c52 100644
--- a/config.js
+++ b/config.js
@@ -49,7 +49,7 @@ angular.module('flashy', [
}).
state('feed', {
resolve: auth_resolve,
- url: '/feed',
+ url: '/feed/{sectionId}',
templateUrl: 'templates/feed.html',
controller: 'FeedController'
}).
@@ -78,13 +78,11 @@ angular.module('flashy', [
controller: 'FlashcardController'
}).
state('requestpasswordreset', {
- resolve: auth_resolve,
url: '/requestpasswordreset',
templateUrl: 'templates/requestpasswordreset.html',
controller: 'RequestResetController'
}).
state('resetpassword', {
- resolve: auth_resolve,
url: '/resetpassword/{uid}/{token}',
templateUrl: 'templates/resetpassword.html',
controller: 'ResetPasswordController'
@@ -99,15 +97,16 @@ angular.module('flashy', [
function($rootScope, $state, $stateParams, $location, UserService) {
$rootScope.$on('$stateChangeStart', function(event, toState, toStateParams) {
if (UserService.isLoggedIn()) return console.log('no login required; going straight to ' + toState.name);
- if (toState.name == 'login') return;
- if (!UserService.isUserResolved()) return;
+ if (toState.name == 'login') return console.log('we are going to login anyway; just let it happen :)');
+ if (!UserService.isUserResolved()) return console.log('user not yet resolved; hold off');
$rootScope.returnToState = toState;
$rootScope.returnToStateParams = toStateParams;
console.log('going to ' + toState.name + ' after login');
$state.go('login');
});
- $rootScope.$on('$routeChangeError', function() {
- console.log('failed to change routes');
+ $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
+ console.log('failed to change state: ' + error);
+ $state.go('login');
});
}
]);
diff --git a/flashy.css b/flashy.css
index 00e5f26..88066bb 100644
--- a/flashy.css
+++ b/flashy.css
@@ -60,10 +60,6 @@ ul.side-nav.fixed li a {
font-size:24px;
}
-
-#logo-container{
- height:110px;
-}
/* Flashcard directive css */
.card.fixed-size {
height: calc(3 * 5vw);
diff --git a/home.html b/home.html
index c18d2e9..5c35abf 100644
--- a/home.html
+++ b/home.html
@@ -13,7 +13,7 @@
-
+
-
Flashy
@@ -24,9 +24,9 @@
-
- WRONG 123
- - CSE 1337
- - MATH 20Z
- - BILD 99
+ - CSE 1337
+ - MATH 20Z
+ - BILD 99
- Add Class
diff --git a/scripts/FeedController.js b/scripts/FeedController.js
index a9f945a..7290a06 100644
--- a/scripts/FeedController.js
+++ b/scripts/FeedController.js
@@ -1,24 +1,23 @@
angular.module('flashy.FeedController', ['ui.router']).
- controller('FeedController', ['$scope', '$state', '$http', function($scope, $state, $http) {
+ controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) {
console.log('Hello from feed');
-
+ sectionId = $stateParams.sectionId;
$scope.cards = [];
+ $scope.cards[0] = {'id': 1, 'title': 'title1', 'content': 'abc'};
+ $scope.cards[1] = {'id': 2, 'title': 'title2', 'content': 'xyz'};
+ $scope.cards[2] = {'id': 2, 'title': 'title3', 'content': 'qwe'};
- $scope.cards[0] = { 'id': 1, 'title': 'title1', 'content': 'abc' };
- $scope.cards[1] = { 'id': 2, 'title': 'title2', 'content': 'xyz' };
- $scope.cards[2] = { 'id': 2, 'title': 'title3', 'content': 'qwe' };
-
- $http.get('/api/sections/{pk}/flashcards').
- success(function(data) {
- for (var i = 0; i < data.length; i++) {
- cards.push({ 'title': data[i].title, 'content': data[i].content });
- }
- }).
- error(function(err) {
- console.log('no');
- });
+ $http.get('/api/sections/' + sectionId + '/flashcards/').
+ success(function(data) {
+ for (var i = 0; i < data.length; i++) {
+ cards.push({'title': data[i].title, 'content': data[i].content});
+ }
+ }).
+ error(function(err) {
+ console.log('no');
+ });
$scope.viewDeck = function() {
$state.go('deck');
@@ -38,30 +37,31 @@ angular.module('flashy.FeedController', ['ui.router']).
// attempt to make card :(
$http.post('/api/flashcards/', {'text': $scope.text, 'pushed': pushed, 'mask': []}).
- success(function(data) {
- console.log('No way, really?');
- }).
- error(function(error) {
- console.log('haha, n00b');
- });
+ success(function(data) {
+ console.log('No way, really?');
+ }).
+ error(function(error) {
+ console.log('haha, n00b');
+ });
$scope.text = '';
};
- $scope.flashcard = 'hi i am a flashcard. I need to be really long and awesome I ain\'t know how long I am right now. Is it good enough now?????????? Howz about now???';
+ $scope.flashcard = 'hi i am a flashcard. I need to be really long and awesome I ain\'t ' +
+ 'know how long I am right now. Is it good enough now?????????? Howz about now???';
$scope.text = '';
$(document).ready(function() {
- // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
- $('.modal-trigger').leanModal({
- dismissible: true, // Modal can be dismissed by clicking outside of the modal
- opacity: 0, // Opacity of modal background
- in_duration: 300, // Transition in duration
- out_duration: 200, // Transition out duration
- /*ready: function() { alert('Ready'); }, // Callback for Modal open
- complete: function() { alert('Closed'); } // Callback for Modal close*/
- }
- );
+ // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
+ $('.modal-trigger').leanModal({
+ dismissible: true, // Modal can be dismissed by clicking outside of the modal
+ opacity: 0, // Opacity of modal background
+ in_duration: 300, // Transition in duration
+ out_duration: 200, // Transition out duration
+ /*ready: function() { alert('Ready'); }, // Callback for Modal open
+ complete: function() { alert('Closed'); } // Callback for Modal close*/
+ }
+ );
});
}]);
diff --git a/scripts/RequestResetController.js b/scripts/RequestResetController.js
index 1588c38..78b1cea 100644
--- a/scripts/RequestResetController.js
+++ b/scripts/RequestResetController.js
@@ -6,7 +6,7 @@ angular.module('flashy.RequestResetController', ['ui.router'])
$scope.success = false;
$scope.error = false;
$scope.resetPass = function(email) {
- $http.post('/api/request_password_reset', JSON.stringify({
+ $http.post('/api/request_password_reset/', JSON.stringify({
'email': email
}))
.success(function(data) {
diff --git a/scripts/ResetPasswordController.js b/scripts/ResetPasswordController.js
index 2256987..ab5c4d1 100644
--- a/scripts/ResetPasswordController.js
+++ b/scripts/ResetPasswordController.js
@@ -25,7 +25,7 @@ angular.module('flashy.ResetPasswordController', ['ui.router']).
console.log('mismatch');
return;
}
- $http.post('/api/reset_password', JSON.stringify({
+ $http.post('/api/reset_password/', JSON.stringify({
'uid': uid,
'token': token,
'new_password': $scope.newPassword
diff --git a/scripts/RootController.js b/scripts/RootController.js
index d22ac6e..aad0e2f 100644
--- a/scripts/RootController.js
+++ b/scripts/RootController.js
@@ -5,4 +5,5 @@ angular.module('flashy.RootController', ['ui.router']).
//$('#top').collapsible('accordion');
if (UserService.isLoggedIn()) $state.go('login');
else $state.go('addclass');
+ $rootScope.isLoggedIn = false;
}]);
diff --git a/scripts/UserService.js b/scripts/UserService.js
index 1e3a522..828d80b 100644
--- a/scripts/UserService.js
+++ b/scripts/UserService.js
@@ -5,18 +5,24 @@ angular.module('flashy.UserService', ['ui.router']).
var deferred = $q.defer();
if (angular.isDefined(_user)) {
console.log('user is already defined: ' + _user);
- if (!_user) deferred.reject(_user);
- deferred.resolve(_user);
+ if (!_user) {
+ console.log('rejecting deferred');
+ deferred.reject(_user);
+ } else {
+ $rootScope.isLoggedIn = true;
+ deferred.resolve(_user);
+ }
return deferred.promise;
}
$http.get('/api/me/').success(function(data) {
console.log('user is logged in!');
_user = data;
+ $rootScope.isLoggedIn = true;
deferred.resolve(data);
}).error(function(data) {
+ console.log('not logged in yet: ' + data.detail);
deferred.reject('error getting own data');
_user = false;
- console.log(data);
});
return deferred.promise;
};
@@ -27,6 +33,7 @@ angular.module('flashy.UserService', ['ui.router']).
return angular.isDefined(_user);
};
this.logout = function() {
+ $rootScope.isLoggedIn = false;
_user = undefined;
};
this.isLoggedIn = function() {
diff --git a/scripts/VerifyEmailController.js b/scripts/VerifyEmailController.js
index e241602..e08283f 100644
--- a/scripts/VerifyEmailController.js
+++ b/scripts/VerifyEmailController.js
@@ -3,26 +3,26 @@ angular.module('flashy.VerifyEmailController', ['ui.router'])
.controller('VerifyEmailController', ['$scope', '$state', '$http', '$timeout',
function($scope, $state, $http, $timeout) {
'use strict';
- var url = document.location.href.split('/');
- var key = url[url.length - 1];
+ var url = document.location.href.split('/');
+ var key = url[url.length - 1];
$scope.success = false;
$scope.error = false;
- $http.patch('/api/me', JSON.stringify({
- 'confirmation_key': key
- }))
- .success(function(data) {
- $scope.success = true;
- console.log('SUCCESS');
- console.log(data);
- $timeout(function($state) {
- $state.go('feed');
- }, 2000);
- })
- .error(function(data, status, header, config) {
- $scope.error = true;
- console.log('ERROR');
- console.log(data);
- });
+ $http.patch('/api/me/', JSON.stringify({
+ 'confirmation_key': key
+ }))
+ .success(function(data) {
+ $scope.success = true;
+ console.log('SUCCESS');
+ console.log(data);
+ $timeout(function($state) {
+ $state.go('feed');
+ }, 2000);
+ })
+ .error(function(data, status, header, config) {
+ $scope.error = true;
+ console.log('ERROR');
+ console.log(data);
+ });
}
]);