Commit 8607c44bb6ba5faf57980c428767f6021128c503
Exists in
master
and in
1 other branch
Merge branch 'master' of https://git.ucsd.edu/110swag/flashy-frontend
Conflicts: config.js home.html templates/login.html
Showing 17 changed files Inline Diff
- casper_test.js
- config.js
- flashy.css
- home.html
- scripts/ClassAddController.js
- scripts/DeckController.js
- scripts/FeedController.js
- scripts/LoginController.js
- scripts/RequestResetController.js
- scripts/ResetPasswordController.js
- scripts/RootController.js
- templates/addclass.html
- templates/deck.html
- templates/feed.html
- templates/login.html
- templates/requestpasswordreset.html
- templates/resetpassword.html
casper_test.js
View file @
8607c44
File was created | 1 | phantom.casperPath = 'path/to/node_modules/casperjs'; | ||
2 | phantom.injectJs('path/to/node_modules/casperjs/bin/bootstrap.js'); | |||
3 | ||||
4 | phantom.casperTest = true; | |||
5 | ||||
6 | ||||
7 | //var casper = require('casper'); | |||
8 | var x = require('casper').selectXPath; | |||
9 | ||||
10 | casper.start('http://google.com/', function() { |
config.js
View file @
8607c44
angular.module('flashy', [ | 1 | 1 | angular.module('flashy', [ | |
'flashy.LogoutController', | 2 | 2 | 'flashy.LogoutController', | |
'flashy.LoginController', | 3 | 3 | 'flashy.LoginController', | |
'flashy.RootController', | 4 | 4 | 'flashy.RootController', | |
'flashy.FeedController', | 5 | 5 | 'flashy.FeedController', | |
'flashy.DeckController', | 6 | 6 | 'flashy.DeckController', | |
'flashy.ClassAddController', | 7 | 7 | 'flashy.ClassAddController', | |
'flashy.RequestResetController', | 8 | 8 | 'flashy.RequestResetController', | |
'flashy.ReviewController', | 9 | 9 | 'flashy.ReviewController', | |
'flashy.UserService', | 10 | 10 | 'flashy.UserService', | |
'flashy.FlashcardDirective', | 11 | 11 | 'flashy.FlashcardDirective', | |
12 | 'flashy.ResetPasswordController', | |||
'ngCookies']). | 12 | 13 | 'ngCookies']). | |
config(['$stateProvider', '$urlRouterProvider', '$httpProvider', | 13 | 14 | config(['$stateProvider', '$urlRouterProvider', '$httpProvider', | |
'$locationProvider', | 14 | 15 | '$locationProvider', | |
function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | 15 | 16 | function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | |
'use strict'; | 16 | 17 | 'use strict'; | |
$httpProvider.defaults.withCredentials = true; | 17 | 18 | $httpProvider.defaults.withCredentials = true; | |
$httpProvider.defaults.xsrfCookieName = 'csrftoken'; | 18 | 19 | $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | 19 | 20 | $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
$locationProvider.html5Mode(true); | 20 | 21 | $locationProvider.html5Mode(true); | |
$urlRouterProvider.otherwise('/home'); | 21 | 22 | $urlRouterProvider.otherwise('/home'); | |
$stateProvider. | 22 | 23 | $stateProvider. | |
state('login', { | 23 | 24 | state('login', { | |
url: '/login', | 24 | 25 | url: '/login', | |
templateUrl: 'templates/login.html', | 25 | 26 | templateUrl: 'templates/login.html', | |
controller: 'LoginController' | 26 | 27 | controller: 'LoginController' | |
}). | 27 | 28 | }). | |
state('logout', { | 28 | 29 | state('logout', { | |
url: '/logout', | 29 | 30 | url: '/logout', | |
templateUrl: 'templates/logout.html', | 30 | 31 | templateUrl: 'templates/logout.html', | |
controller: 'LogoutController' | 31 | 32 | controller: 'LogoutController' | |
}). | 32 | 33 | }). | |
state('root', { | 33 | 34 | state('root', { | |
url: '/', | 34 | 35 | url: '/', | |
templateUrl: 'templates/root.html', | 35 | 36 | templateUrl: 'templates/root.html', | |
controller: 'RootController' | 36 | 37 | controller: 'RootController' | |
}). | 37 | 38 | }). | |
state('feed', { | 38 | 39 | state('feed', { | |
url: '/feed', | 39 | 40 | url: '/feed', | |
templateUrl: 'templates/feed.html', | 40 | 41 | templateUrl: 'templates/feed.html', | |
controller: 'FeedController' | 41 | 42 | controller: 'FeedController' | |
}). | 42 | 43 | }). | |
state('addclass', { | 43 | 44 | state('addclass', { | |
url: '/addclass', | 44 | 45 | url: '/addclass', | |
templateUrl: 'templates/addclass.html', | 45 | 46 | templateUrl: 'templates/addclass.html', | |
controller: 'ClassAddController' | 46 | 47 | controller: 'ClassAddController' | |
}). | 47 | 48 | }). | |
state('deck', { | 48 | 49 | state('deck', { | |
url: '/deck', | 49 | 50 | url: '/deck', | |
templateUrl: 'templates/deck.html', | 50 | 51 | templateUrl: 'templates/deck.html', | |
controller: 'DeckController' | 51 | 52 | controller: 'DeckController' | |
}). | 52 | 53 | }). | |
state('review', { | 53 | 54 | state('review', { | |
url: '/review', | 54 | 55 | url: '/review', | |
templateUrl: 'templates/review.html', | 55 | 56 | templateUrl: 'templates/review.html', | |
controller: 'ReviewController' | 56 | 57 | controller: 'ReviewController' | |
}). | 57 | 58 | }). | |
state('flashcard', { | 58 | 59 | state('flashcard', { | |
url: '/flashcard', | 59 | 60 | url: '/flashcard', | |
templateUrl: 'templates/flashcard.html', | 60 | 61 | templateUrl: 'templates/flashcard.html', | |
controller: 'FlashcardController' | 61 | 62 | controller: 'FlashcardController' | |
}). | 62 | 63 | }). | |
state('requestpasswordreset', { | 63 | 64 | state('requestpasswordreset', { | |
url: '/requestpasswordreset', | 64 | 65 | url: '/requestpasswordreset', | |
templateUrl: 'templates/requestpasswordreset.html', | 65 | 66 | templateUrl: 'templates/requestpasswordreset.html', | |
controller: 'RequestResetController' | 66 | 67 | controller: 'RequestResetController' | |
}); | 67 | 68 | }). | |
69 | state('resetpassword', { | |||
70 | url: '/resetpassword', | |||
71 | templateUrl: 'templates/resetpassword.html', | |||
72 | controller: 'ResetPasswordController' | |||
73 | }); | |||
68 | 74 | |||
}]); | 69 | 75 | }]); |
flashy.css
View file @
8607c44
.angucomplete-dropdown { | 1 | 1 | .diclaimer { | |
2 | color:#00AFD8; | |||
3 | } | |||
4 | ||||
5 | .form-section { | |||
6 | width: 330px; | |||
7 | top: 50%; | |||
8 | position: relative; | |||
9 | } | |||
10 | ||||
11 | .form-inputs { | |||
12 | margin-top: 0px; | |||
13 | border: 0px none; | |||
14 | font: 16px/1.4 "Helvetica Neue","HelveticaNeue",Helvetica,Arial; | |||
15 | padding: 5px 10px 11px 13px; | |||
16 | width: 100%; | |||
17 | box-sizing: border-box; | |||
18 | } | |||
19 | ||||
20 | .form-buttons { | |||
21 | margin-top: 10px; | |||
22 | width: 100%; | |||
23 | font-size: 16px; | |||
24 | } | |||
25 | ||||
26 | .form-buttons .last-button { | |||
27 | float: right; | |||
28 | } | |||
29 | ||||
30 | .container { | |||
31 | position: relative; | |||
32 | width: 600px; | |||
33 | height: 80px; | |||
34 | } | |||
35 | ||||
36 | .angucomplete-dropdown { | |||
border-color: #ececec; | 2 | 37 | border-color: #ececec; | |
border-width: 1px; | 3 | 38 | border-width: 1px; | |
border-style: solid; | 4 | 39 | border-style: solid; | |
border-radius: 2px; | 5 | 40 | border-radius: 2px; | |
/*width: 250px;*/ | 6 | 41 | /*width: 250px;*/ | |
padding: 6px; | 7 | 42 | padding: 6px; | |
cursor: pointer; | 8 | 43 | cursor: pointer; | |
z-index: 9999; | 9 | 44 | z-index: 9999; | |
position: absolute; | 10 | 45 | position: absolute; | |
/*top: 32px; | 11 | 46 | /*top: 32px; | |
left: 0px; | 12 | 47 | left: 0px; | |
*/ | 13 | 48 | */ | |
margin-top: -6px; | 14 | 49 | margin-top: -6px; | |
background-color: #ffffff; | 15 | 50 | background-color: #ffffff; | |
} | 16 | 51 | } | |
17 | 52 | |||
.angucomplete-description { | 18 | 53 | .angucomplete-description { | |
font-size: 14px; | 19 | 54 | font-size: 14px; | |
} | 20 | 55 | } | |
21 | 56 | |||
.angucomplete-row { | 22 | 57 | .angucomplete-row { | |
padding: 5px; | 23 | 58 | padding: 5px; | |
color: #000000; | 24 | 59 | color: #000000; | |
margin-bottom: 4px; | 25 | 60 | margin-bottom: 4px; | |
clear: both; | 26 | 61 | clear: both; | |
} | 27 | 62 | } | |
28 | 63 | |||
.angucomplete-selected-row { | 29 | 64 | .angucomplete-selected-row { |
home.html
View file @
8607c44
<!DOCTYPE html> | 1 | 1 | <!DOCTYPE html> | |
<html ng-app="flashy"> | 2 | 2 | <html ng-app="flashy"> | |
<base href="/app/"> | 3 | 3 | <base href="/app/"> | |
<head> | 4 | 4 | <head> | |
<link type="text/css" rel="stylesheet" href="styles/materialize.min.css" media="screen,projection"/> | 5 | 5 | <link type="text/css" rel="stylesheet" href="styles/materialize.min.css" media="screen,projection"/> | |
<!--<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css"/>--> | 6 | 6 | <!--<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css"/>--> | |
7 | <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css"> | |||
8 | ||||
<link rel="stylesheet" href="flashy.css"/> | 7 | 9 | <link rel="stylesheet" href="flashy.css"/> | |
</head> | 8 | 10 | </head> | |
9 | 11 | |||
<body ng-controller="RootController"> | 10 | 12 | <body ng-controller="RootController"> | |
11 | 13 | |||
<ul id="nav" class="side-nav fixed"> | 12 | 14 | <ul id="nav" class="side-nav fixed"> | |
<li class="bold"><a ui-sref="login">Login</a></li> | 13 | 15 | <li class="bold"><a ui-sref="login">Login</a></li> | |
<li class="bold"><a ui-sref="addclass">Add Class</a></li> | 14 | 16 | <li class="bold"><a ui-sref="addclass">Add Class</a></li> | |
</ul> | 15 | 17 | </ul> | |
<div class="container" ui-view></div> | 16 | 18 | <div class="container" ui-view></div> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 17 | 19 | <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script> | 18 | 20 | <script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.js"></script> | 19 | 21 | <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.js"></script> | |
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | 20 | 22 | <script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script type="text/javascript" src="scripts/materialize.min.js"></script> | 21 | 23 | <script type="text/javascript" src="scripts/materialize.min.js"></script> | |
24 | <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script> | |||
25 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script> | |||
26 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> | |||
22 | 27 | |||
<script src="config.js"></script> | 23 | 28 | <script src="config.js"></script> | |
24 | 29 | |||
<!-- Controllers --> | 25 | 30 | <!-- Controllers --> | |
<script src="scripts/FeedController.js"></script> | 26 | 31 | <script src="scripts/FeedController.js"></script> | |
<script src="scripts/RootController.js"></script> | 27 | 32 | <script src="scripts/RootController.js"></script> | |
<script src="scripts/LoginController.js"></script> | 28 | 33 | <script src="scripts/LoginController.js"></script> | |
<script src="scripts/LogoutController.js"></script> | 29 | 34 | <script src="scripts/LogoutController.js"></script> | |
<script src="scripts/DeckController.js"></script> | 30 | 35 | <script src="scripts/DeckController.js"></script> | |
<script src="scripts/RequestResetController.js"></script> | 31 | 36 | <script src="scripts/RequestResetController.js"></script> | |
<script src="scripts/ClassAddController.js"></script> | 32 | 37 | <script src="scripts/ClassAddController.js"></script> | |
<script src="scripts/ReviewController.js"></script> | 33 | 38 | <script src="scripts/ReviewController.js"></script> | |
34 | 39 | |||
<!-- Services --> | 35 | 40 | <!-- Services --> | |
<script src="scripts/UserService.js"></script> | 36 | 41 | <script src="scripts/UserService.js"></script> | |
37 | 42 | |||
<!-- Directives --> | 38 | 43 | <!-- Directives --> | |
<script src="scripts/FlashcardDirective.js"></script> | 39 | 44 | <script src="scripts/FlashcardDirective.js"></script> | |
40 | 45 | |||
<!-- Other --> | 41 | 46 | <!-- Other --> |
scripts/ClassAddController.js
View file @
8607c44
angular.module('flashy.ClassAddController', ['ui.router', 'angucomplete-alt']). | 1 | 1 | angular.module('flashy.ClassAddController', ['ui.router', 'angucomplete-alt', 'ngMaterial']). | |
2 | 2 | |||
controller('ClassAddController', ['$scope', '$state', function($scope, $state) { | 3 | 3 | controller('ClassAddController', ['$scope', '$state', '$http', function($scope, $state, $http) { | |
4 | 4 | |||
$scope.remoteUrlRequestFn = function(str) { | 5 | 5 | $scope.trySearch = function(searchText) { | |
return {q: str}; | 6 | 6 | return $http.get('/api/sections/search/', { | |
7 | params: { | |||
8 | q: searchText | |||
9 | } | |||
10 | }).then(function(response) { | |||
11 | return response.data; | |||
12 | }); | |||
}; | 7 | 13 | }; | |
$(document).ready(function() { | 8 | 14 | ||
}); | 9 | 15 | $scope.searchText = ''; | |
16 | ||||
17 | /*$scope.trySearch = function() { | |||
18 | $http.get('/api/sections/search', [$scope.searchText]). | |||
19 | success(function(data) { | |||
20 | return data; | |||
21 | }). | |||
22 | error(function(err) { | |||
23 | console.log('you eejit'); | |||
24 | }); | |||
25 | };*/ | |||
10 | 26 | |||
}]); | 11 | 27 | }]); | |
12 | 28 | |||
scripts/DeckController.js
View file @
8607c44
var app = angular.module('flashy.DeckController', ['ui.router']); | 1 | 1 | var app = angular.module('flashy.DeckController', ['ui.router']); | |
2 | 2 | |||
app.controller('DeckController', ['$scope', function($scope) { | 3 | 3 | app.controller('DeckController', ['$scope', '$http', function($scope, $http) { | |
$scope.hello = function() { | 4 | 4 | ||
alert('hello'); | 5 | 5 | ||
}; | 6 | 6 | ||
7 | $scope.cards = []; | |||
8 | ||||
9 | ||||
10 | ||||
11 | $scope.cards[0] = { 'id': 1, 'title': 'title1', 'content': 'abc' }; | |||
12 | $scope.cards[1] = { 'id': 2, 'title': 'title2', 'content': 'xyz' }; | |||
13 | $scope.cards[2] = { 'id': 2, 'title': 'title3', 'content': 'qwe' }; | |||
14 | ||||
15 | ||||
16 | $scope.removeCard = function(item) { | |||
17 | ||||
18 | ||||
19 | var index = $scope.cards.indexOf(item); | |||
20 | ||||
21 | $scope.cards.splice(index, 1); | |||
22 | ||||
23 | alert('removed card'); | |||
24 | }; | |||
25 | ||||
26 | ||||
27 | $http.get('/api/sections/{pk}/deck'). | |||
28 | success(function(data) { | |||
29 | ||||
30 | ||||
31 | for (var i = 0; i < data.length; i++) { | |||
32 | cards.push({ 'title': data[i].title, 'content': data[i].content }); | |||
33 | } | |||
34 | }). | |||
35 | error(function(data) { | |||
36 | ||||
37 | console.log('no cards?!!'); | |||
38 | ||||
39 | }); | |||
40 | ||||
41 | ||||
42 | ||||
43 | ||||
}]); | 7 | 44 | }]); | |
8 | 45 | |||
scripts/FeedController.js
View file @
8607c44
angular.module('flashy.FeedController', ['ui.router']). | 1 | 1 | angular.module('flashy.FeedController', ['ui.router']). | |
2 | 2 | |||
controller('FeedController', ['$scope', '$state', function($scope, $state) { | 3 | 3 | controller('FeedController', ['$scope', '$state', '$http', function($scope, $state, $http) { | |
console.log('Hello from feed'); | 4 | 4 | console.log('Hello from feed'); | |
5 | 5 | |||
$scope.createCard = function() { | 6 | |||
7 | ||||
$(document).ready(function() { | 8 | |||
$('#createCardModal').modal('show'); | 9 | |||
}); | 10 | |||
}; | 11 | |||
12 | ||||
$scope.viewDeck = function() { | 13 | 6 | $scope.viewDeck = function() { | |
$state.go('deck'); | 14 | 7 | $state.go('deck'); | |
console.log('go to deck'); | 15 | 8 | console.log('go to deck'); | |
}; | 16 | 9 | }; | |
10 | ||||
11 | $scope.pullCard = function() { | |||
12 | console.log('card clicked'); | |||
13 | }; | |||
14 | ||||
15 | $scope.create = false; // show make flashcard | |||
16 | ||||
17 | $scope.pushCard = function() { | |||
18 | console.log('make! card content:' + $scope.text); | |||
19 | var pushed = new Date(Date.now()); | |||
20 | console.log(pushed.toString()); | |||
21 | ||||
22 | // attempt to make card :( | |||
23 | $http.post('/api/flashcards/', {'text': $scope.text, 'pushed': pushed, 'mask': []}). | |||
24 | success(function(data) { | |||
25 | console.log('No way, really?'); | |||
26 | }). | |||
27 | error(function(error) { | |||
28 | console.log('haha, n00b'); | |||
29 | }); | |||
30 | ||||
31 | $scope.create = false; // hide make flashcard | |||
32 | $scope.text = ''; | |||
33 | }; | |||
34 |
scripts/LoginController.js
View file @
8607c44
angular.module('flashy.LoginController', ['ui.router']). | 1 | 1 | angular.module('flashy.LoginController', ['ui.router']). | |
2 | 2 | |||
controller('LoginController', ['$scope', '$state', '$http', 'UserService', | 3 | 3 | controller('LoginController', ['$scope', '$state', '$http', 'UserService', | |
function ($scope, $state, $http, UserService) { | 4 | 4 | function($scope, $state, $http, UserService) { | |
'use strict'; | 5 | 5 | 'use strict'; | |
6 | 6 | |||
$scope.uniqueError = false; | 7 | 7 | $scope.uniqueError = false; | |
$scope.loginError = false; | 8 | 8 | $scope.loginError = false; | |
$scope.login = function (email, password) { | 9 | 9 | $scope.login = function(email, password) { | |
$http.post('/api/login', JSON.stringify({ | 10 | 10 | $http.post('/api/login', JSON.stringify({ | |
'email': email, | 11 | 11 | 'email': email, | |
'password': password | 12 | 12 | 'password': password | |
})). | 13 | 13 | })). | |
success(function (data) { | 14 | 14 | success(function(data) { | |
UserService.getUserData(); | 15 | 15 | UserService.getUserData(); | |
$state.go('feed'); | 16 | 16 | $state.go('feed'); | |
console.log(data); | 17 | 17 | console.log(data); | |
}). | 18 | 18 | }). | |
error(function (data, status, header, config) { | 19 | 19 | error(function(data, status, header, config) { | |
if (data.detail) { // assume 'invalid email or pass' | 20 | 20 | if (data.detail) { // assume 'invalid email or pass' | |
$scope.loginError = true; | 21 | 21 | $scope.loginError = true; | |
} | 22 | 22 | } | |
console.log(data); | 23 | 23 | console.log(data); | |
}); | 24 | 24 | }); | |
}; | 25 | 25 | }; | |
$scope.signUp = function (email, password) { | 26 | 26 | $scope.signUp = function(email, password) { | |
$http.post('/api/register', JSON.stringify({ | 27 | 27 | $http.post('/api/register', JSON.stringify({ | |
'email': email, | 28 | 28 | 'email': email, | |
'password': password | 29 | 29 | 'password': password | |
})). | 30 | 30 | })). | |
success(function (data) { | 31 | 31 | success(function(data) { | |
$state.go('feed'); | 32 | 32 | $state.go('feed'); | |
console.log(data); | 33 | 33 | console.log(data); | |
}). | 34 | 34 | }). | |
error(function (data, status, headers, config) { | 35 | 35 | error(function(data, status, headers, config) { | |
console.log(data.email); | 36 | 36 | console.log(data.email); | |
if (data.email == 'This field is required.') { | 37 | 37 | if (data.email == 'This field is required.') { | |
$scope.invalid = true; | 38 | 38 | $scope.invalid = true; | |
$scope.uniqueError = false; | 39 | 39 | $scope.uniqueError = false; | |
} else if (data.email) { | 40 | 40 | } else if (data.email) { | |
// assume 'email not unique' error | 41 | 41 | // assume 'email not unique' error | |
$scope.uniqueError = true; | 42 | 42 | $scope.uniqueError = true; | |
$scope.invalid = false; | 43 | 43 | $scope.invalid = false; | |
} | 44 | 44 | } | |
console.log(data); | 45 | 45 | console.log(data); | |
}); | 46 | 46 | }); | |
47 | 47 | |||
}; | 48 | 48 | }; | |
$scope.triggerPasswordReset = function () { | 49 | 49 | $scope.triggerPasswordReset = function() { | |
$state.go('requestpasswordreset'); | 50 | 50 | $state.go('requestpasswordreset'); | |
}; | 51 | 51 | }; | |
} | 52 | 52 | } | |
]); | 53 | 53 | ]); | |
54 | 54 | |||
scripts/RequestResetController.js
View file @
8607c44
angular.module('flashy.RequestResetController', ['ui.router']) | 1 | 1 | angular.module('flashy.RequestResetController', ['ui.router']) | |
2 | 2 | |||
.controller('RequestResetController', ['$scope', '$state', '$http', | 3 | 3 | .controller('RequestResetController', ['$scope', '$state', '$http', | |
function($scope, $state, $http) { | 4 | 4 | function($scope, $state, $http) { | |
'use strict'; | 5 | 5 | 'use strict'; | |
$scope.success = false; | 6 | 6 | $scope.success = false; | |
$scope.invalid = false; | 7 | 7 | $scope.invalid = false; | |
$scope.resetPass = function(email) { | 8 | 8 | $scope.resetPass = function(email) { | |
$http.post('/api/request_password_reset', JSON.stringify({ | 9 | 9 | $http.post('/api/request_password_reset', JSON.stringify({ | |
'email': email | 10 | 10 | 'email': email | |
})) | 11 | 11 | })) | |
.success(function(data) { | 12 | 12 | .success(function(data) { | |
$scope.success = true; | 13 | 13 | $scope.success = true; | |
$state.go('passwordreset'); | 14 | 14 | $state.go('passwordreset'); | |
console.log(data); | 15 | 15 | console.log(data); | |
}) | 16 | 16 | }) | |
.error(function(data, status, header, config) { | 17 | 17 | .error(function(data, status, header, config) { | |
if (data.email) { | 18 | 18 | if (data.email) { | |
$scope.invalid = true; | 19 | 19 | $scope.invalid = true; | |
} | 20 | 20 | } | |
console.log(data); | 21 | 21 | console.log(data); | |
}); | 22 | 22 | }); | |
}; | 23 | 23 | }; | |
$scope.cancel = function() { | 24 | 24 | $scope.cancelReset = function() { | |
$state.go('home'); | 25 | 25 | $state.go('login'); | |
}; | 26 | 26 | }; | |
} | 27 | 27 | } | |
]); | 28 | 28 | ]); | |
29 | 29 |
scripts/ResetPasswordController.js
View file @
8607c44
File was created | 1 | angular.module('flashy.ResetPasswordController', ['ui.router']). | ||
2 | ||||
3 | controller('ResetPasswordController', ['$scope', '$state', '$http', | |||
4 | function($scope, $state, $http) { | |||
5 | 'use strict'; | |||
6 | var url = document.location.href.split("/"); | |||
7 | var token = url[url.length-1]; | |||
8 | var uid = url[url.length-2]; | |||
9 | $scope.error = false; | |||
10 | $scope.confirmResetPass = function(newPassword) { | |||
11 | $http.post('/api/reset_password', JSON.stringify({ | |||
12 | 'uid': uid, | |||
13 | 'token': token | |||
14 | })) | |||
15 | .success(function(data) { | |||
16 | $scope.error = false; | |||
17 | $state.go('resetpasssuccess'); | |||
18 | console.log(data); | |||
19 | }) | |||
20 | .error(function(data, status, header, config) { | |||
21 | $scope.error = true; | |||
22 | console.log(data); | |||
23 | }); | |||
24 | }; | |||
25 | $scope.cancelReset = function() { | |||
26 | $state.go('login'); | |||
27 | }; | |||
28 | } |
scripts/RootController.js
View file @
8607c44
angular.module('flashy.RootController', ['ui.router']). | 1 | 1 | angular.module('flashy.RootController', ['ui.router']). | |
2 | 2 | |||
controller('RootController', ['$scope', '$state', 'UserService', function ($scope, $state, UserService) { | 3 | 3 | controller('RootController', ['$scope', '$state', 'UserService', function($scope, $state, UserService) { | |
if (UserService.isLoggedIn()) $state.go('login'); | 4 | 4 | if (UserService.isLoggedIn()) $state.go('login'); | |
else $state.go('addclass'); | 5 | 5 | else $state.go('addclass'); | |
}]); | 6 | 6 | }]); |
templates/addclass.html
View file @
8607c44
<div angucomplete-alt id="classes" | 1 | 1 | <div> | |
placeholder="Search classes" | 2 | 2 | ||
pause="100" | 3 | 3 | <div layout="column"> | |
selected-object="selectedClass" | 4 | 4 | <md-content layout-padding="" layout="column" style="overflow:hidden"> | |
remote-url="/api/sections/search/" | 5 | 5 | ||
remote-url-request-formatter="remoteUrlRequestFn" , | 6 | 6 | <form ng-submit="$event.preventDefault()"> | |
remote-url-data-field="" , | 7 | 7 | <div layout="column"> | |
title-field="short_name" , | 8 | 8 | <md-autocomplete flex="" | |
description-field="long_name" , | 9 | 9 | md-autofocus="true" | |
minlength="2" , | 10 | 10 | md-selected-item="selectedItem" | |
pause="0" , | 11 | 11 | md-search-text="searchText" | |
input-class="form-control"/> | 12 | 12 | md-items="item in trySearch(searchText)" | |
13 | md-item-text="item.short_name" | |||
14 | > | |||
15 | <md-item-template> | |||
16 | <div layout="row"> | |||
17 | <div>{{item.short_name}}: {{item.course_title}} ({{item.instructor}})</div> | |||
18 | <div style="margin-left:auto;text-align:right;padding-left:30px">{{item.lecture_times}}</div> | |||
19 | </div> | |||
20 | </md-item-template> | |||
21 | <md-not-found> | |||
22 | No classes match "{{searchText}}". | |||
23 | </md-not-found> | |||
24 | </md-autocomplete> | |||
25 | </div> | |||
26 | </form> | |||
27 | </md-content> | |||
28 | </div> | |||
29 | </div> | |||
13 | ||||
14 | ||||
templates/deck.html
View file @
8607c44
<!DOCTYPE html> | 1 | 1 | <div class="row"> | |
<html ng-app="flashy"> | 2 | |||
<head> | 3 | |||
4 | ||||
<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css" /> | 5 | |||
<link rel="stylesheet" href="flashy.css" /> | 6 | |||
7 | 2 | |||
</head> | 8 | 3 | <div ng-repeat="card in cards"> | |
<body ng-controller="DeckController"> | 9 | |||
10 | 4 | |||
<button type="button" ng-click="hello()">SUPPPP</button> | 11 | 5 | <div class="col s6"> | |
12 | 6 | |||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 13 | 7 | <div class="card"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script> | 14 | |||
<script src="/app/config.js"></script> | 15 | |||
<!--<script src="controller.js"></script>--> | 16 | |||
17 | 8 | |||
<script src="DeckController.js"></script> | 18 | |||
</body> | 19 | |||
</html> | 20 | |||
21 | 9 | |||
22 | 10 | |||
<script src="viewDeckController.js"></script> | 23 | 11 | <div class="card-image"> | |
</body> | 24 | 12 | <span class="card-title">{{card.title}}</span> | |
</html> | 25 | 13 | </div> | |
14 | <div class="card-content"> | |||
15 | ||||
16 | ||||
17 | ||||
18 | <p> | |||
19 | {{card.content}} | |||
20 | ||||
21 | ||||
22 | </p> | |||
23 | </div> | |||
24 | ||||
25 | ||||
26 | ||||
27 | <div class="card-action"> | |||
28 | ||||
29 | ||||
30 | <button type="button" class="waves-effect waves-light btn" ng-click="removeCard()">Remove</button> | |||
31 | ||||
32 | ||||
33 | </div> | |||
34 | ||||
35 | </div> | |||
36 | ||||
37 | </div> | |||
38 | ||||
39 | ||||
40 | </div> | |||
41 | </div> | |||
42 |
templates/feed.html
View file @
8607c44
<h2>cards go here or something</h2> | 1 | 1 | <div class="col s9"> | |
2 | <div class="row"> | |||
3 | <a class="waves-effect waves-light btn purple" ng-click="viewDeck()" style="top: 15px">View Deck</a> | |||
4 | </div> | |||
2 | 5 | |||
6 | <!--random dummy cards--> | |||
7 | <div class="row"> | |||
8 | <div class="col s1 m2 l4"> | |||
9 | <div class="card-panel" ng-click="pullCard()"> | |||
10 | <span>{{ flashcard }}</span> | |||
11 | </div> | |||
12 | </div> | |||
3 | 13 | |||
<button type="button" ng-click="viewDeck()">View Deck</button> | 4 | 14 | <div class="col s1 m2 l4"> | |
5 | 15 | <div class="card" ng-click="pullCard()"> | ||
6 | 16 | <div class="card-content"> | ||
7 | 17 | <span class="card-title activator grey-text text-darken-4">{{ flashcard }}<i class="mdi-navigation-more-vert right"></i></span> | ||
<button type="button" id="createCardModal" ng-click="createCard()" data-toggle="modal" data-target="#createCardModal">CREATE A CARD</button> | 8 | |||
9 | ||||
<div id="createCardModal" class="modal fade" aria-labelledby="createCardModal" aria-hidden="true"> | 10 | |||
<div class="modal-dialog"> | 11 | |||
<div class="modal-content"> | 12 | |||
13 | ||||
<div class="modal-header"> | 14 | |||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | 15 | |||
<h4 class="modal-title">Confirmation</h4> | 16 | |||
</div> | 17 | |||
<div class="modal-footer"> | 18 | |||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | 19 | |||
<button type="button" class="btn btn-primary">Save changes</button> | 20 | |||
</div> | 21 | |||
</div> | 22 | 18 | </div> | |
19 | <div class="card-reveal"> | |||
20 | <span class="card-title grey-text text-darken-4">{{ flashcard }}<i class="mdi-navigation-close right"></i></span> | |||
21 | <p>Herro der. I see you have found me.</p> | |||
22 | </div> | |||
23 | </div> | |||
</div> | 23 | 24 | </div> | |
25 | ||||
26 | <div class="col s1 m2 l4"> | |||
27 | <div class="card-panel" ng-click="pullCard()"> | |||
28 | <span>{{ flashcard }}</span> | |||
29 | </div> | |||
30 | </div> | |||
31 | ||||
32 | <!--New flashcard (still working on placement)--> | |||
33 | <div class="row" ng-show="create"> | |||
34 | <form class="col s6 offset-s10" ng-submit="pushCard()"> | |||
35 | <div class="row"> | |||
36 | <div class="input-field col s12"> | |||
37 | <i class="mdi-editor-mode-edit prefix"></i> | |||
38 | <textarea class="materialize-textarea" ng-model="text" name="text"></textarea> | |||
39 | <label id="newCardSign" for="newCard">New Flashcard</label> | |||
40 | <div class="container"> | |||
41 | <button class="btn waves-effect waves-light purple" type="submit" name="action">Submit | |||
42 | <i class="mdi-content-send right"></i> | |||
43 | </button> | |||
44 | </div> | |||
45 | </div> | |||
46 | </div> | |||
47 | </form> | |||
48 | </div> | |||
49 | ||||
50 | <!--Lil plus button in corner--> | |||
51 | <div class="fixed-action-btn" ng-click="create = !create" style="bottom: 45px; right: 24px;"> | |||
52 | <a class="btn-floating btn-large purple"> | |||
53 | <i class="large mdi-content-add"></i> | |||
54 | </a> | |||
55 | <!--Maybe this will come in handy later? Floating bubbles on mouseover--> | |||
56 | <ul> | |||
57 | <li><a class="btn-floating red"><i class="large mdi-editor-insert-chart"></i></a></li> | |||
58 | <li><a class="btn-floating yellow darken-1"><i class="large mdi-editor-format-quote"></i></a></li> | |||
59 | <li><a class="btn-floating green"><i class="large mdi-editor-publish"></i></a></li> | |||
60 | <li><a class="btn-floating blue"><i class="large mdi-editor-attach-file"></i></a></li> | |||
61 | </ul> |
templates/login.html
View file @
8607c44
<div class="container"> | 1 | 1 | <div class="container"> | |
<div class="row"> | 2 | 2 | <div class="row"> | |
<form id="loginform" class="col s12 right-align" ng-submit="login(loginEmail, loginPassword)"> | 3 | 3 | <div class="col s6"> | |
4 | <ul class="tabs" tabs> | |||
5 | <li class="tab col s3"><a href="#register-tab">Sign Up</a></li> | |||
6 | <li class="tab col s3"><a class="active" href="#login-tab">Login</a></li> | |||
7 | </ul> | |||
8 | </div> | |||
9 | <!--LOGIN TAB--> | |||
10 | <div id="login-tab" class="col s12"> | |||
<div class="check-element animate-show" role="alert" ng-show="loginError"> | 4 | 11 | <div class="check-element animate-show" role="alert" ng-show="loginError"> | |
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | 5 | |||
<span style="color:#8E2323">Invalid username or password!!</span> | 6 | 12 | <span style="color:#8E2323">Invalid username or password!!</span> | |
</div> | 7 | 13 | </div> | |
<div class="row"> | 8 | 14 | <div class="row"> | |
<div class="input-field col s6"> | 9 | 15 | <div class="input-field col s6"> | |
<input type="email" class="validate" ng-model="loginEmail" required/> | 10 | 16 | <input id="email" type="email" class="validate" ng-model="loginEmail" placeholder="Email" required/> | |
<label for="email">Email</label> | 11 | 17 | <label for="email">Email</label> | |
</div> | 12 | 18 | </div> | |
19 | </div> | |||
20 | <div class="row"> | |||
<div class="input-field col s6"> | 13 | 21 | <div class="input-field col s6"> | |
<input type="password" class="validate" ng-model="loginPassword" required/> | 14 | 22 | <input id="password" type="password" class="validate" ng-model="loginPassword" placeholder="Password" required/> | |
<label for="password">Password</label> | 15 | 23 | <label for="password">Password</label> | |
</div> | 16 | 24 | </div> | |
</div> | 17 | 25 | </div> | |
<button class="btn waves-effect waves-light right-align" type="" name="action" | 18 | 26 | <div class="row"> | |
ng-click="signUp(loginEmail, loginPassword)">Register | 19 | 27 | <button class="btn waves-effect waves-light right-align" type="submit" name="action" | |
</button> | 20 | 28 | ng-click="login(loginEmail, loginPassword)">Login | |
<button class="btn waves-effect waves-light right-align" type="submit" name="action" | 21 | 29 | </button> | |
ng-click="login(loginEmail, loginPassword)">Login | 22 | 30 | </div> | |
</button> | 23 | 31 | </div> | |
24 | 32 | <!--REGISTER TAB--> | ||
</form> | 25 | 33 | <div id="register-tab" class="col s12"> | |
<a class="trigger-password-reset" ng-click="triggerPasswordReset()" href="#">Forgot Password?</a> | 26 | 34 | <div class="row"> | |
35 | <div class="input-field col s6"> | |||
36 | <input type="email" class="validate" ng-model="loginEmail" placeholder="Email" required/> | |||
37 | <label for="email">Email</label> | |||
38 | </div> | |||
39 | </div> | |||
40 | <div class="row"> | |||
41 | <div class="input-field col s6"> | |||
42 | <input type="password" class="validate" ng-model="registerPassword" placeholder="Password" required/> | |||
43 | <label for="password">Password</label> | |||
44 | </div> | |||
45 | </div> | |||
46 | <div class="row"> | |||
47 | <button class="btn waves-effect waves-light left-align" type="" name="action" | |||
48 | ng-click="signUp(loginEmail, registerPassword)">Register | |||
49 | </button> | |||
50 | </div> | |||
51 | </div> | |||
</div> | 27 | 52 | </div> | |
53 | <a class="trigger-password-reset" ng-click="triggerPasswordReset()" href="#">Forgot Password?</a> | |||
</div> | 28 | 54 | </div> | |
29 | 55 | |||
templates/requestpasswordreset.html
View file @
8607c44
<div class="content"> | 1 | 1 | <div class="content"> | |
<div class="container"> | 2 | 2 | <div class="container"> | |
<h1 class="text-muted">Reset Password</h1> | 3 | 3 | <h1 class="text-muted">Reset Password</h1> | |
</div> | 4 | 4 | </div> | |
<div name="passreset" class="form-section"> | 5 | 5 | <div name="passreset" class="form-section"> | |
<form class="form-inputs" name="passreset_form"> | 6 | 6 | <form class="form-inputs" name="passreset_form"> | |
<div class="check-element animate-show" role="alert" ng-show="invalid"> | 7 | 7 | <div class="check-element animate-show" role="alert" ng-show="invalid"> | |
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | 8 | |||
<span style="color:#8E2323">Enter a valid email!</span> | 9 | 8 | <span style="color:#8E2323">Enter a valid email!</span> | |
</div> | 10 | 9 | </div> | |
10 | <!--FORM INPUTS--> | |||
<div class="form-group"> | 11 | 11 | <div class="form-group"> | |
<input type="email" class="form-control" ng-model="user_email" placeholder="Email" required /> | 12 | 12 | <input type="email" class="form-control" ng-model="user_email" placeholder="Email" required /> | |
</div> | 13 | 13 | </div> | |
<div class="form-buttons"> | 14 | 14 | <div class="row"> | |
<div class="btn-group"> | 15 | 15 | <div class="btn-group"> | |
<button type="button" class="btn btn-default" ng-click="cancel()"><strong>Cancel</strong></button> | 16 | 16 | <button type="button" class="btn btn-default" ng-click="cancelReset()"><strong>Cancel</strong></button> | |
</div> | 17 | 17 | </div> | |
<div class="last-button"> | 18 | 18 | <div class="last-button"> | |
<div class="btn-group"> | 19 | 19 | <div class="btn-group"> | |
<button type="button" class="btn btn-danger" ng-click="resetPass(user_email)"><strong>Reset Password</strong></button> | 20 | 20 | <button type="button" class="btn btn-danger" ng-click="resetPass(user_email)"><strong>Reset Password</strong></button> | |
</div> | 21 | 21 | </div> | |
</div> | 22 | 22 | </div> | |
</div> | 23 | 23 | </div> | |
</form> | 24 | 24 | </form> | |
</div> | 25 | 25 | </div> | |
</div> | 26 | 26 | </div> | |
templates/resetpassword.html
View file @
8607c44
File was created | 1 | <div class="container"> | ||
2 | <div class="row"> | |||
3 | <h1>Reset Password</h1> | |||
4 | </div> | |||
5 | ||||
6 | <div class="row"> | |||
7 | <form class="col s12"> | |||
8 | <div class="row" ng-show="error" role="alert"> | |||
9 | <i style="color:#8E2323" class="mdi-alert-error"></i> | |||
10 | <span style="color:#8E2323">Please use link from email!</span> | |||
11 | </div> | |||
12 | <div class="row"> | |||
13 | <input id="newpassword" type="password" class="validate" ng-model="newPassword" placeholder="New password" required/> | |||
14 | <label for="newpassword">New password</label> | |||
15 | </div> | |||
16 | <div class="row"> | |||
17 | <input id="confirmpassword" type="password" class="validate" ng-model="confirmPassword" placeholder="Confirm password" required/> | |||
18 | <label for="confirmpassword">Confirm password</label> | |||
19 | </div> | |||
20 | </form> | |||
21 | <div class="row"> | |||
22 | <button class="btn waves-effect waves-light red" type="submit" name="action" | |||
23 | ng-click="cancelReset()">Cancel | |||
24 | </button> | |||
25 | <button class="btn waves-effect waves-light green" type="submit" name="action" | |||
26 | ng-click="confirmResetPass(newPassword)">Confirm | |||
27 | </button> | |||
28 | </div> | |||
29 | </div> |