Commit e2db4a265b052a23c1634c5cb3fdbdab4a30ad1c
1 parent
8fa323ef66
Exists in
master
and in
1 other branch
class add functional now
Showing 5 changed files with 31 additions and 12 deletions Inline Diff
home.html
View file @
e2db4a2
<!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" | 5 | 5 | <link type="text/css" rel="stylesheet" href="styles/materialize.min.css" | |
media="screen,projection"/> | 6 | 6 | media="screen,projection"/> | |
<!--<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css"/>--> | 7 | 7 | <!--<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css"/>--> | |
<link rel="stylesheet" | 8 | 8 | <link rel="stylesheet" | |
href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css"> | 9 | 9 | href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css"> | |
10 | 10 | |||
<link rel="stylesheet" href="flashy.css"/> | 11 | 11 | <link rel="stylesheet" href="flashy.css"/> | |
</head> | 12 | 12 | </head> | |
13 | 13 | |||
<body ng-controller="RootController"> | 14 | 14 | <body ng-controller="RootController"> | |
15 | 15 | |||
<ul id="slide-out" ng-show="isLoggedIn" class="side-nav fixed"> | 16 | 16 | <ul id="slide-out" ng-show="isLoggedIn" class="side-nav fixed"> | |
<li class="logo"><a href="//flashy.cards/" id="logo-container"> | 17 | 17 | <li class="logo"><a href="//flashy.cards/" id="logo-container"> | |
<h1>Flashy</h1> | 18 | 18 | <h1>Flashy</h1> | |
</a></li> | 19 | 19 | </a></li> | |
<li class="bold"> | 20 | 20 | <li class="bold"> | |
<a>Classes</a> | 21 | 21 | <a>Classes</a> | |
<!--<a ui-sref="addclass"><i class="mdi-content-add"></i></a>--> | 22 | 22 | <!--<a ui-sref="addclass"><i class="mdi-content-add"></i></a>--> | |
</li> | 23 | 23 | </li> | |
<li> | 24 | 24 | <li> | |
<ul> | 25 | 25 | <ul ng-repeat="section in sections"> | |
<li ui-sref="feed">WRONG 123</li> | 26 | 26 | <li ui-sref="feed({{section.id}})">{{section.short_name}} </li> | |
<li ui-sref="feed(4567)">CSE 1337</li> | 27 | |||
<li ui-sref="feed(1242)">MATH 20Z</li> | 28 | |||
<li ui-sref="feed(2842)">BILD 99</li> | 29 | |||
</ul> | 30 | 27 | </ul> | |
</li> | 31 | 28 | </li> | |
<li class="bold"><a ui-sref="addclass">Add Class</a></li> | 32 | 29 | <li class="bold"><a ui-sref="addclass">Add Class</a></li> | |
<li class="bold"><a ui-sref="feed">Feed</a></li> | 33 | 30 | <li class="bold"><a ui-sref="feed">Feed</a></li> | |
<li class="bold"><a ui-sref="deck">Deck</a></li> | 34 | 31 | <li class="bold"><a ui-sref="deck">Deck</a></li> | |
<li class="bold"><a ui-sref="logout">Logout</a></li> | 35 | 32 | <li class="bold"><a ui-sref="logout">Logout</a></li> | |
</ul> | 36 | 33 | </ul> | |
37 | 34 | |||
38 | 35 | |||
<div class="container" ui-view></div> | 39 | 36 | <div class="container" ui-view></div> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 40 | 37 | <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> | 41 | 38 | <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> | 42 | 39 | <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> | 43 | 40 | <script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script type="text/javascript" src="scripts/materialize.min.js"></script> | 44 | 41 | <script type="text/javascript" src="scripts/materialize.min.js"></script> | |
<script type="text/javascript" src="scripts/jquery.collapsible.js"></script> | 45 | 42 | <script type="text/javascript" src="scripts/jquery.collapsible.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script> | 46 | 43 | <script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script> | 47 | 44 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> | 48 | 45 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> | |
49 | 46 | |||
<script src="config.js"></script> | 50 | 47 | <script src="config.js"></script> | |
51 | 48 | |||
<!-- Controllers --> | 52 | 49 | <!-- Controllers --> | |
<script src="scripts/FeedController.js"></script> | 53 | 50 | <script src="scripts/FeedController.js"></script> | |
<script src="scripts/RootController.js"></script> | 54 | 51 | <script src="scripts/RootController.js"></script> | |
<script src="scripts/LoginController.js"></script> | 55 | 52 | <script src="scripts/LoginController.js"></script> | |
<script src="scripts/LogoutController.js"></script> | 56 | 53 | <script src="scripts/LogoutController.js"></script> | |
<script src="scripts/DeckController.js"></script> | 57 | 54 | <script src="scripts/DeckController.js"></script> | |
<script src="scripts/RequestResetController.js"></script> | 58 | 55 | <script src="scripts/RequestResetController.js"></script> | |
<script src="scripts/ClassAddController.js"></script> | 59 | 56 | <script src="scripts/ClassAddController.js"></script> | |
<script src="scripts/StudyController.js"></script> | 60 | 57 | <script src="scripts/StudyController.js"></script> | |
58 | <script src="scripts/ResetPasswordController.js"></script> | |||
<script src="scripts/VerifyEmailController.js"></script> | 61 | 59 | <script src="scripts/VerifyEmailController.js"></script> | |
<!--<script src="scripts/SidebarController.js"></script>--> | 62 | 60 | <!--<script src="scripts/SidebarController.js"></script>--> | |
63 | 61 | |||
<!-- Services --> | 64 | 62 | <!-- Services --> | |
<script src="scripts/UserService.js"></script> | 65 | 63 | <script src="scripts/UserService.js"></script> | |
66 | 64 | |||
<!-- Directives --> | 67 | 65 | <!-- Directives --> | |
<script src="scripts/FlashcardDirective.js"></script> | 68 | 66 | <script src="scripts/FlashcardDirective.js"></script> | |
69 | 67 | |||
<!-- Other --> | 70 | 68 | <!-- Other --> |
scripts/ClassAddController.js
View file @
e2db4a2
angular.module('flashy.ClassAddController', ['ui.router', 'angucomplete-alt', 'ngMaterial']). | 1 | 1 | angular.module('flashy.ClassAddController', ['ui.router', 'ngMaterial']). | |
2 | 2 | |||
controller('ClassAddController', ['$scope', '$state', '$http', function($scope, $state, $http) { | 3 | 3 | controller('ClassAddController', ['$scope', '$state', '$http', function($scope, $state, $http) { | |
4 | 4 | |||
$scope.trySearch = function(searchText) { | 5 | 5 | $scope.trySearch = function(searchText) { | |
return $http.get('/api/sections/search/', { | 6 | 6 | return $http.get('/api/sections/search/', { | |
params: { | 7 | 7 | params: { | |
q: searchText | 8 | 8 | q: searchText | |
} | 9 | 9 | } | |
}).then(function(response) { | 10 | 10 | }).then(function(response) { | |
return response.data; | 11 | 11 | return response.data; | |
}); | 12 | 12 | }); | |
}; | 13 | 13 | }; | |
14 | 14 | |||
$scope.searchText = ''; | 15 | 15 | $scope.searchText = ''; | |
16 | $scope.submit = function() { | |||
17 | $http.post('/api/sections/' + $scope.selectedItem.id + '/enroll/'). | |||
18 | success(function(data) { | |||
19 | $scope.sections.push($scope.selectedItem); | |||
20 | $state.go('feed', {sectionId: $scope.selectedItem.id}); | |||
21 | }). | |||
22 | error(function(data, status, header, config) { | |||
23 | console.log(data); | |||
24 | }); | |||
25 | }; | |||
16 | 26 | |||
/*$scope.trySearch = function() { | 17 | 27 | /*$scope.trySearch = function() { | |
$http.get('/api/sections/search', [$scope.searchText]). | 18 | 28 | $http.get('/api/sections/search', [$scope.searchText]). | |
success(function(data) { | 19 | 29 | success(function(data) { | |
return data; | 20 | 30 | return data; | |
}). | 21 | 31 | }). | |
error(function(err) { | 22 | 32 | error(function(err) { | |
console.log('you eejit'); | 23 | 33 | console.log('you eejit'); |
scripts/RootController.js
View file @
e2db4a2
angular.module('flashy.RootController', ['ui.router']). | 1 | 1 | angular.module('flashy.RootController', ['ui.router']). | |
2 | 2 | |||
controller('RootController', ['$rootScope', '$scope', '$state', 'UserService', function($rootScope, $scope, $state, UserService) { | 3 | 3 | controller('RootController', ['$rootScope', '$scope', '$state', 'UserService', function($rootScope, $scope, $state, UserService) { | |
//UserService.getUserData(); | 4 | 4 | //UserService.getUserData(); | |
//$('#top').collapsible('accordion'); | 5 | 5 | //$('#top').collapsible('accordion'); | |
if (UserService.isLoggedIn()) $state.go('login'); | 6 | 6 | if (UserService.isLoggedIn()) $state.go('login'); | |
else $state.go('addclass'); | 7 | 7 | else $state.go('addclass'); | |
$rootScope.isLoggedIn = false; | 8 | 8 | $rootScope.isLoggedIn = false; | |
9 | console.log(UserService._user); | |||
10 | UserService.getUserData().then(function(data) { | |||
11 | console.log(data); | |||
12 | $rootScope.user = data; | |||
13 | }); |
scripts/UserService.js
View file @
e2db4a2
angular.module('flashy.UserService', ['ui.router']). | 1 | 1 | angular.module('flashy.UserService', ['ui.router']). | |
service('UserService', function($rootScope, $http, $q) { | 2 | 2 | service('UserService', function($rootScope, $http, $q) { | |
var _user = undefined; | 3 | 3 | var _user = undefined; | |
this.getUserData = function() { | 4 | 4 | $rootScope.sections = []; | |
5 | this.getUserData = function(refresh) { | |||
var deferred = $q.defer(); | 5 | 6 | var deferred = $q.defer(); | |
if (angular.isDefined(_user)) { | 6 | 7 | if (angular.isDefined(_user)) { | |
console.log('user is already defined: ' + _user); | 7 | 8 | console.log('user is already defined: ' + _user); | |
if (!_user) { | 8 | 9 | if (!_user) { | |
console.log('rejecting deferred'); | 9 | 10 | console.log('rejecting deferred'); | |
deferred.reject(_user); | 10 | 11 | deferred.reject(_user); | |
} else { | 11 | 12 | } else { | |
$rootScope.isLoggedIn = true; | 12 | 13 | $rootScope.isLoggedIn = true; | |
14 | $rootScope.sections = _user.sections; | |||
deferred.resolve(_user); | 13 | 15 | deferred.resolve(_user); | |
} | 14 | 16 | } | |
return deferred.promise; | 15 | 17 | return deferred.promise; | |
} | 16 | 18 | } | |
$http.get('/api/me/').success(function(data) { | 17 | 19 | $http.get('/api/me/').success(function(data) { | |
console.log('user is logged in!'); | 18 | 20 | console.log('user is logged in!'); | |
_user = data; | 19 | 21 | _user = data; | |
$rootScope.isLoggedIn = true; | 20 | 22 | $rootScope.isLoggedIn = true; | |
23 | $rootScope.sections = _user.sections; | |||
deferred.resolve(data); | 21 | 24 | deferred.resolve(data); | |
}).error(function(data) { | 22 | 25 | }).error(function(data) { | |
console.log('not logged in yet: ' + data.detail); | 23 | 26 | console.log('not logged in yet: ' + data.detail); | |
deferred.reject('error getting own data'); | 24 | 27 | deferred.reject('error getting own data'); | |
_user = false; | 25 | 28 | _user = false; | |
}); | 26 | 29 | }); | |
return deferred.promise; | 27 | 30 | return deferred.promise; | |
}; | 28 | 31 | }; | |
this.setUserData = function(data) { | 29 | 32 | this.setUserData = function(data) { | |
_user = data; | 30 | 33 | _user = data; | |
}; | 31 | 34 | }; | |
this.isUserResolved = function() { | 32 | 35 | this.isUserResolved = function() { | |
return angular.isDefined(_user); | 33 | 36 | return angular.isDefined(_user); | |
}; | 34 | 37 | }; | |
this.logout = function() { | 35 | 38 | this.logout = function() { | |
$rootScope.isLoggedIn = false; | 36 | 39 | $rootScope.isLoggedIn = false; | |
_user = undefined; | 37 | 40 | _user = undefined; | |
}; | 38 | 41 | }; | |
this.isLoggedIn = function() { | 39 | 42 | this.isLoggedIn = function() { | |
rv = this.isUserResolved() && _user; | 40 | 43 | rv = this.isUserResolved() && _user; | |
console.log('is user logged in? ' + rv); | 41 | 44 | console.log('is user logged in? ' + rv); | |
return rv; | 42 | 45 | return rv; | |
}; | 43 | 46 | }; | |
}); | 44 | 47 | }); | |
45 | 48 |
templates/addclass.html
View file @
e2db4a2
<div> | 1 | 1 | <div> | |
2 | 2 | |||
<div layout="column"> | 3 | 3 | <div layout="column"> | |
<md-content layout-padding="" layout="column" style="overflow:hidden"> | 4 | 4 | <md-content layout-padding="" layout="column" style="overflow:hidden"> | |
5 | 5 | |||
<form ng-submit="$event.preventDefault()"> | 6 | 6 | <form ng-submit="$event.preventDefault()"> | |
<div layout="column"> | 7 | 7 | <div layout="row"> | |
<md-autocomplete flex="" | 8 | 8 | <md-autocomplete flex="" | |
md-autofocus="true" | 9 | 9 | md-autofocus="true" | |
md-selected-item="selectedItem" | 10 | 10 | md-selected-item="selectedItem" | |
md-search-text="searchText" | 11 | 11 | md-search-text="searchText" | |
md-items="item in trySearch(searchText)" | 12 | 12 | md-items="item in trySearch(searchText)" | |
md-item-text="item.short_name" | 13 | 13 | md-item-text="item.short_name" | |
14 | md-selected-item-change="selectObject(event)" | |||
15 | md-autoselect="true" | |||
> | 14 | 16 | > | |
<md-item-template> | 15 | 17 | <md-item-template> | |
<div layout="row"> | 16 | 18 | <div layout="row"> | |
<div>{{item.short_name}}: {{item.course_title}} | 17 | 19 | <div>{{item.short_name}}: {{item.course_title}} | |
({{item.instructor}}) | 18 | 20 | ({{item.instructor}}) | |
</div> | 19 | 21 | </div> | |
<div style="margin-left:auto;text-align:right;padding-left:30px"> | 20 | 22 | <div style="margin-left:auto;text-align:right;padding-left:30px"> | |
{{item.lecture_times}} | 21 | 23 | {{item.lecture_times}} | |
</div> | 22 | 24 | </div> | |
</div> | 23 | 25 | </div> | |
</md-item-template> | 24 | 26 | </md-item-template> | |
<md-not-found> | 25 | 27 | <md-not-found> | |
No classes match "{{searchText}}". | 26 | 28 | No classes match "{{searchText}}". | |
</md-not-found> | 27 | 29 | </md-not-found> | |
</md-autocomplete> | 28 | 30 | </md-autocomplete> | |
31 | <button class="btn waves-effect waves-light" type="submit" name="add" ng-click="submit()">Add | |||
32 | <i class="mdi-content-add right"></i> | |||
33 | </button> | |||
</div> | 29 | 34 | </div> | |
35 | ||||
</form> | 30 | 36 | </form> | |
</md-content> | 31 | 37 | </md-content> | |
</div> | 32 | 38 | </div> |