Commit b12a56132719f54cdae9f5e3f089effd3462653f
1 parent
620ed51551
Exists in
master
and in
1 other branch
try to fix (hah) the locked account issues
Showing 6 changed files with 84 additions and 46 deletions Inline Diff
config.js
View file @
b12a561
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.StudyController', | 9 | 9 | 'flashy.StudyController', | |
'flashy.UserService', | 10 | 10 | 'flashy.UserService', | |
'flashy.FlashcardDirective', | 11 | 11 | 'flashy.FlashcardDirective', | |
'flashy.ResetPasswordController', | 12 | 12 | 'flashy.ResetPasswordController', | |
'flashy.VerifyEmailController', | 13 | 13 | 'flashy.VerifyEmailController', | |
'flashy.CardListController', | 14 | 14 | 'flashy.CardListController', | |
15 | 'flashy.HelpController', | |||
'flashy.SettingsController', | 15 | 16 | 'flashy.SettingsController', | |
'ngCookies']). | 16 | 17 | 'ngCookies']). | |
config(function ($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) { | 17 | 18 | config(function ($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider, $locationProvider) { | |
'use strict'; | 18 | 19 | 'use strict'; | |
$httpProvider.defaults.withCredentials = true; | 19 | 20 | $httpProvider.defaults.withCredentials = true; | |
$httpProvider.defaults.xsrfCookieName = 'csrftoken'; | 20 | 21 | $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | 21 | 22 | $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
$resourceProvider.defaults.stripTrailingSlashes = false; | 22 | 23 | $resourceProvider.defaults.stripTrailingSlashes = false; | |
var arrayMethods = Object.getOwnPropertyNames(Array.prototype); | 23 | 24 | var arrayMethods = Object.getOwnPropertyNames(Array.prototype); | |
arrayMethods.forEach(attachArrayMethodsToNodeList); | 24 | 25 | arrayMethods.forEach(attachArrayMethodsToNodeList); | |
function attachArrayMethodsToNodeList(methodName) { | 25 | 26 | function attachArrayMethodsToNodeList(methodName) { | |
if (methodName !== 'length') { | 26 | 27 | if (methodName !== 'length') { | |
NodeList.prototype[methodName] = Array.prototype[methodName]; | 27 | 28 | NodeList.prototype[methodName] = Array.prototype[methodName]; | |
} | 28 | 29 | } | |
} | 29 | 30 | } | |
30 | 31 | |||
$httpProvider.interceptors.push(function ($q) { | 31 | 32 | $httpProvider.interceptors.push(function ($q, $rootScope) { | |
return { | 32 | 33 | return { | |
'responseError': function (rejection) { // need a better redirect | 33 | 34 | 'responseError': function (rejection) { // need a better redirect | |
if (rejection.status >= 500) { | 34 | 35 | if (rejection.status >= 500) { | |
console.log('got error'); | 35 | 36 | console.log('got error'); | |
console.log(rejection); | 36 | 37 | console.log(rejection); | |
$('body').html('<div class="card">Sorry, the server is not serving requests properly. Try again later</div>'); | 37 | 38 | $rootScope.$broadcast('server_error', rejection); | |
} | 38 | 39 | } | |
if (rejection.status == 403) { | 39 | 40 | if (rejection.status == 403) { | |
console.log(rejection); | 40 | 41 | console.log(rejection); | |
if (rejection.data && rejection.data.detail == "Please verify your email before continuing") { | 41 | 42 | if (rejection.data && rejection.data.detail == "Please verify your email before continuing") { | |
Materialize.toast('Thanks for trying Flashy! To ensure quality content, we ask that you verify your email before continuing', 4000); | 42 | 43 | $rootScope.$broadcast('account_locked'); | |
UserService.logout(); | 43 | |||
} | 44 | 44 | } | |
} | 45 | 45 | } | |
return $q.reject(rejection); | 46 | 46 | return $q.reject(rejection); | |
} | 47 | 47 | } | |
}; | 48 | 48 | }; | |
}); | 49 | 49 | }); | |
$locationProvider.html5Mode(true); | 50 | 50 | $locationProvider.html5Mode(true); | |
$urlRouterProvider.otherwise('/404'); | 51 | 51 | $urlRouterProvider.otherwise('/404'); | |
var auth_resolve = { | 52 | 52 | var auth_resolve = { | |
authorize: function ($q, $state, $stateParams, UserService) { | 53 | 53 | authorize: function ($q, $state, $stateParams, UserService) { | |
console.log('resolving user before continuing'); | 54 | 54 | console.log('resolving user before continuing'); | |
var redirectAsNeeded = function () { | 55 | 55 | var redirectAsNeeded = function () { | |
if (!UserService.isLoggedIn()) { | 56 | 56 | if (!UserService.isLoggedIn()) { | |
console.log(UserService.getUserData()); | 57 | 57 | console.log(UserService.getUserData()); | |
console.log('making the user log in'); | 58 | 58 | console.log('making the user log in'); | |
$state.go('login'); | 59 | 59 | $state.go('login'); | |
} | 60 | 60 | } | |
if (!UserService.authorizedFor($state, $stateParams)) { | 61 | 61 | if (!UserService.authorizedFor($state, $stateParams)) { | |
$state.go('addclass'); | 62 | 62 | $state.go('addclass'); | |
} | 63 | 63 | } | |
}; | 64 | 64 | }; | |
if (UserService.isResolved()) return redirectAsNeeded(); | 65 | 65 | if (UserService.isResolved()) return redirectAsNeeded(); | |
return UserService.getUserData().then(redirectAsNeeded); | 66 | 66 | return UserService.getUserData().then(redirectAsNeeded); | |
} | 67 | 67 | } | |
}; | 68 | 68 | }; | |
$stateProvider. | 69 | 69 | $stateProvider. | |
state('login', { | 70 | 70 | state('login', { | |
url: '/login', | 71 | 71 | url: '/login', | |
templateUrl: 'templates/login.html', | 72 | 72 | templateUrl: 'templates/login.html', | |
controller: 'LoginController' | 73 | 73 | controller: 'LoginController' | |
}). | 74 | 74 | }). | |
state('logout', { | 75 | 75 | state('logout', { | |
resolve: auth_resolve, | 76 | 76 | resolve: auth_resolve, | |
url: '/logout', | 77 | 77 | url: '/logout', | |
templateUrl: 'templates/logout.html', | 78 | 78 | templateUrl: 'templates/logout.html', | |
controller: 'LogoutController' | 79 | 79 | controller: 'LogoutController' | |
}). | 80 | 80 | }). | |
state('root', { | 81 | 81 | state('root', { | |
resolve: auth_resolve, | 82 | 82 | resolve: auth_resolve, | |
url: '/', | 83 | 83 | url: '/', | |
controller: 'RootController' | 84 | 84 | controller: 'RootController' | |
}). | 85 | 85 | }). | |
state('feed', { | 86 | 86 | state('feed', { | |
resolve: auth_resolve, | 87 | 87 | resolve: auth_resolve, | |
url: '/feed/{sectionId}', | 88 | 88 | url: '/feed/{sectionId}', | |
templateUrl: 'templates/feed.html', | 89 | 89 | templateUrl: 'templates/feed.html', | |
controller: 'FeedController' | 90 | 90 | controller: 'FeedController' | |
}). | 91 | 91 | }). | |
state('cardlist', { | 92 | 92 | state('cardlist', { | |
resolve: auth_resolve, | 93 | 93 | resolve: auth_resolve, | |
url: '/cards/{sectionId}', | 94 | 94 | url: '/cards/{sectionId}', | |
templateUrl: 'templates/cardlist.html', | 95 | 95 | templateUrl: 'templates/cardlist.html', | |
controller: 'CardListController' | 96 | 96 | controller: 'CardListController' | |
}). | 97 | 97 | }). | |
state('addclass', { | 98 | 98 | state('addclass', { | |
resolve: auth_resolve, | 99 | 99 | resolve: auth_resolve, | |
url: '/addclass', | 100 | 100 | url: '/addclass', | |
templateUrl: 'templates/addclass.html', | 101 | 101 | templateUrl: 'templates/addclass.html', | |
controller: 'ClassAddController' | 102 | 102 | controller: 'ClassAddController' | |
}). | 103 | 103 | }). | |
state('deck', { | 104 | 104 | state('deck', { | |
resolve: auth_resolve, | 105 | 105 | resolve: auth_resolve, | |
url: '/deck/{sectionId}', | 106 | 106 | url: '/deck/{sectionId}', | |
templateUrl: 'templates/deck.html', | 107 | 107 | templateUrl: 'templates/deck.html', | |
controller: 'DeckController' | 108 | 108 | controller: 'DeckController' | |
}). | 109 | 109 | }). | |
state('study', { | 110 | 110 | state('study', { | |
resolve: auth_resolve, | 111 | 111 | resolve: auth_resolve, | |
url: '/study', | 112 | 112 | url: '/study', | |
templateUrl: 'templates/study.html', | 113 | 113 | templateUrl: 'templates/study.html', | |
controller: 'StudyController' | 114 | 114 | controller: 'StudyController' | |
}). | 115 | 115 | }). | |
state('flashcard', { | 116 | 116 | state('flashcard', { | |
resolve: auth_resolve, | 117 | 117 | resolve: auth_resolve, | |
url: '/flashcard', | 118 | 118 | url: '/flashcard', | |
templateUrl: 'templates/flashcard.html', | 119 | 119 | templateUrl: 'templates/flashcard.html', | |
controller: 'FlashcardController' | 120 | 120 | controller: 'FlashcardController' | |
}). | 121 | 121 | }). | |
state('settings', { | 122 | 122 | state('settings', { | |
resolve: auth_resolve, | 123 | 123 | resolve: auth_resolve, | |
url: '/settings', | 124 | 124 | url: '/settings', | |
templateUrl: 'templates/settings.html', | 125 | 125 | templateUrl: 'templates/settings.html', | |
controller: 'SettingsController' | 126 | 126 | controller: 'SettingsController' | |
}). | 127 | 127 | }). | |
state('requestpasswordreset', { | 128 | 128 | state('requestpasswordreset', { | |
url: '/requestpasswordreset', | 129 | 129 | url: '/requestpasswordreset', | |
templateUrl: 'templates/requestpasswordreset.html', | 130 | 130 | templateUrl: 'templates/requestpasswordreset.html', | |
controller: 'RequestResetController' | 131 | 131 | controller: 'RequestResetController' | |
}). | 132 | 132 | }). | |
state('resetpassword', { | 133 | 133 | state('resetpassword', { | |
url: '/resetpassword/{uid}/{token}', | 134 | 134 | url: '/resetpassword/{uid}/{token}', | |
templateUrl: 'templates/resetpassword.html', | 135 | 135 | templateUrl: 'templates/resetpassword.html', | |
controller: 'ResetPasswordController' | 136 | 136 | controller: 'ResetPasswordController' | |
}). | 137 | 137 | }). | |
state('verifyemail', { | 138 | 138 | state('verifyemail', { | |
resolve: auth_resolve, | 139 | 139 | resolve: auth_resolve, | |
url: '/verifyemail/{key}', | 140 | 140 | url: '/verifyemail/{key}', | |
templateUrl: 'templates/verifyemail.html', | 141 | 141 | templateUrl: 'templates/verifyemail.html', | |
controller: 'VerifyEmailController' | 142 | 142 | controller: 'VerifyEmailController' | |
}). | 143 | 143 | }). | |
state('404', { | 144 | 144 | state('404', { | |
url: '/404', | 145 | 145 | url: '/404', | |
template: "<h1>This page doesn't exist!</h1>" | 146 | 146 | template: "<h1>This page doesn't exist!</h1>" | |
147 | }). | |||
148 | state('help', { | |||
149 | resolve: auth_resolve, | |||
150 | url: '/help', | |||
151 | templateUrl: 'templates/help.html', | |||
152 | controller: 'HelpController' | |||
}); | 147 | 153 | }); | |
}). | 148 | 154 | }). | |
run(function ($rootScope, $state, $stateParams, $location, UserService) { | 149 | 155 | run(function ($rootScope, $state, $stateParams, $location, UserService) { | |
$rootScope.$on('$stateChangeError', function (event, toState, toParams, fromState, fromParams, error) { | 150 | 156 | $rootScope.$on('$stateChangeError', function (event, toState, toParams, fromState, fromParams, error) { | |
console.log('failed to change state: ' + error); | 151 | 157 | console.log('failed to change state: ' + error); | |
$state.go('login'); | 152 | 158 | $state.go('login'); | |
}); | 153 | 159 | }); | |
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) { | 154 | 160 | $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) { | |
if (['feed', 'deck', 'cardlist'].indexOf(toState.name) >= 0) { | 155 | 161 | if (['feed', 'deck', 'cardlist'].indexOf(toState.name) >= 0) { | |
localStorage.setItem('last_state', toState.name); | 156 | 162 | localStorage.setItem('last_state', toState.name); | |
localStorage.setItem('last_state_params', JSON.stringify(toParams)); | 157 | 163 | localStorage.setItem('last_state_params', JSON.stringify(toParams)); | |
} | 158 | 164 | } | |
}); | 159 | 165 | }); | |
}); | 160 | 166 | }); | |
161 | 167 | |||
home.html
View file @
b12a561
<!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> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> | 5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> | |
<link rel="stylesheet" | 6 | 6 | <link rel="stylesheet" | |
href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css"> | 7 | 7 | href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css"> | |
8 | 8 | |||
<link rel="stylesheet" href="styles/flashier.css"/> | 9 | 9 | <link rel="stylesheet" href="styles/flashier.css"/> | |
<link rel="stylesheet" href="styles/flashy.css"/> | 10 | 10 | <link rel="stylesheet" href="styles/flashy.css"/> | |
<link href='https://fonts.googleapis.com/css?family=Titillium+Web:200,200italic,300,600,400,900,700,400italic,700italic,300italic,600italic' | 11 | 11 | <link href='https://fonts.googleapis.com/css?family=Titillium+Web:200,200italic,300,600,400,900,700,400italic,700italic,300italic,600italic' | |
rel='stylesheet' type='text/css'> | 12 | 12 | rel='stylesheet' type='text/css'> | |
<title>Flashy</title> | 13 | 13 | <title>Flashy</title> | |
</head> | 14 | 14 | </head> | |
<body ng-controller="RootController"> | 15 | 15 | <body ng-controller="RootController"> | |
<header> | 16 | 16 | <header> | |
<nav> | 17 | 17 | <nav> | |
<div class="nav-wrapper"> | 18 | 18 | <div class="nav-wrapper"> | |
<a ng-show="UserService.isLoggedIn()" href="#" data-activates="mobile-demo" | 19 | 19 | <a ng-show="UserService.isLoggedIn()" href="#" data-activates="mobile-demo" | |
class="left button-collapse hide-on-med-and-up"><i | 20 | 20 | class="left button-collapse hide-on-med-and-up"><i | |
class="mdi-navigation-menu"></i></a> | 21 | 21 | class="mdi-navigation-menu"></i></a> | |
22 | <!-- User's classes dropdown --> | |||
23 | <ul id="classDropdown" class="dropdown-content"> | |||
24 | <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | |||
25 | <a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |||
26 | </li> | |||
27 | <li class="divider"></li> | |||
28 | <li><a ui-sref="addclass">Add Class</a></li> | |||
29 | </ul> | |||
30 | <ul> | |||
31 | <li><a style="width:auto;" class="dropdown-button ng-cloak" href="#!" data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i | |||
32 | class="mdi-navigation-arrow-drop-down right"></i></a></li> | |||
33 | </ul> | |||
<ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> | 22 | 34 | <ul ng-show="currentSection.id && UserService.isLoggedIn()" class="left hide-on-small-and-down"> | |
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | 23 | 35 | <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 24 | 36 | data-position="bottom" | |
data-delay="50" data-tooltip="Feed"><i | 25 | 37 | data-delay="50" data-tooltip="Feed"><i | |
class="mdi-action-view-module"></i></a></li> | 26 | 38 | class="mdi-action-view-module"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | 27 | 39 | <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 28 | 40 | data-position="bottom" | |
data-delay="50" data-tooltip="Deck"><i | 29 | 41 | data-delay="50" data-tooltip="Deck"><i | |
class="mdi-action-view-carousel"></i></a></li> | 30 | 42 | class="mdi-action-view-carousel"></i></a></li> | |
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | 31 | 43 | <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | |
data-position="bottom" | 32 | 44 | data-position="bottom" | |
data-delay="50" data-tooltip="Card List"><i | 33 | 45 | data-delay="50" data-tooltip="Card List"><i | |
class="mdi-action-view-list"></i></a></li> | 34 | 46 | class="mdi-action-view-list"></i></a></li> | |
</ul> | 35 | 47 | </ul> | |
<a href="#" class="brand-logo center">Flashy</a> | 36 | 48 | <a href="#" class="brand-logo center">Flashy</a> | |
37 | 49 | |||
<ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down"> | 38 | 50 | <ul ng-show="UserService.isLoggedIn()" ng-cloak id="nav-mobile" class="right hide-on-small-and-down"> | |
<!-- User's classes dropdown --> | 39 | 51 | ||
<ul id="classDropdown" class="dropdown-content"> | 40 | 52 | <li ui-sref-active="active"><a ui-sref="study">Study</a></li> | |
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | 41 | 53 | ||
<a ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | 42 | 54 | <!-- Settings Dropdown --> | |
</li> | 43 | 55 | <ul id="settingsDropdown" class="dropdown-content"> | |
<li class="divider"></li> | 44 | 56 | <li><a ui-sref="settings">Settings</a></li> | |
<li><a ui-sref="addclass">Add Class</a></li> | 45 | 57 | <li><a ui-sref="logout">Logout</a></li> | |
</ul> | 46 | 58 | </ul> | |
47 | 59 | <li ui-sref-active="active"><a ui-sref="help"><i class="tiny mdi-action-help"></i></a></li> | ||
<li><a style="width:175px;" class="dropdown-button ng-cloak" href="#!" data-activates="classDropdown">{{currentSection.id?currentSection.short_name:"Classes"}}<i | 48 | 60 | ||
class="mdi-navigation-arrow-drop-down right"></i></a></li> | 49 | 61 | <li><a class="dropdown-button ng-cloak" href="#!" data-activates="settingsDropdown"><i | |
<li><a ui-sref="study">Study</a></li> | 50 | 62 | class="tiny mdi-action-settings"></i></a></li> | |
51 | 63 | |||
<!-- Settings Dropdown --> | 52 | 64 | ||
<ul id="settingsDropdown" class="dropdown-content"> | 53 | |||
<li><a ui-sref="settings">Settings</a></li> | 54 | |||
<li><a ui-sref="logout">Logout</a></li> | 55 | |||
</ul> | 56 | |||
57 | ||||
<li><a class="dropdown-button ng-cloak" href="#!" data-activates="settingsDropdown"><i class="tiny mdi-action-settings"></i></a></li> | 58 | |||
59 | ||||
60 | ||||
61 | ||||
62 | ||||
</ul> | 63 | 65 | </ul> | |
64 | 66 | |||
<!-- Slide-in side-nav for small screens --> | 65 | 67 | <!-- Slide-in side-nav for small screens --> | |
<ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> | 66 | 68 | <ul ng-show="UserService.isLoggedIn()" class="side-nav" id="mobile-demo"> | |
<span ng-show="currentSection.id"> | 67 | 69 | <span ng-show="currentSection.id"> | |
<li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | 68 | 70 | <li ui-sref-active="active"><a ui-sref="feed({sectionId:currentSection.id})" class="tooltipped" | |
><i | 69 | 71 | ><i | |
class="mdi-action-view-module left"></i>Feed</a></li> | 70 | 72 | class="mdi-action-view-module left"></i>Feed</a></li> | |
<li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | 71 | 73 | <li ui-sref-active="active"><a ui-sref="deck({sectionId:currentSection.id})" class="tooltipped" | |
><i | 72 | 74 | ><i | |
class="mdi-action-view-carousel left"></i>Deck</a></li> | 73 | 75 | class="mdi-action-view-carousel left"></i>Deck</a></li> | |
<li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | 74 | 76 | <li ui-sref-active="active"><a ui-sref="cardlist({sectionId:currentSection.id})" class="tooltipped" | |
><i | 75 | 77 | ><i | |
class="mdi-action-view-list left"></i>Card List</a> | 76 | 78 | class="mdi-action-view-list left"></i>Card List</a> | |
</li> | 77 | 79 | </li> | |
<hr> | 78 | 80 | <hr> | |
</span> | 79 | 81 | </span> | |
<!-- Collapsible menu for all the User's classes --> | 80 | 82 | <!-- Collapsible menu for all the User's classes --> | |
<ul class="collapsible" data-collapsible="accordion"> | 81 | 83 | <ul class="collapsible" data-collapsible="accordion"> | |
<li class="bold"> | 82 | 84 | <li class="bold"> | |
<a class="collapsible-header black-text"> | 83 | 85 | <a class="collapsible-header black-text"> | |
Classes<i | 84 | 86 | Classes<i | |
class="mdi-navigation-arrow-drop-down right"></i> | 85 | 87 | class="mdi-navigation-arrow-drop-down right"></i> | |
</a> | 86 | 88 | </a> | |
</li> | 87 | 89 | </li> | |
<div class="collapsible-body" style="display: block"> | 88 | 90 | <div class="collapsible-body" style="display: block"> | |
<ul> | 89 | 91 | <ul> | |
<li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | 90 | 92 | <li ui-sref-active="active" ng-repeat="section in UserService.getUserData().sections"> | |
<a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | 91 | 93 | <a class="class bold" ui-sref="feed({sectionId:section.id})">{{section.short_name}}</a> | |
</li> | 92 | 94 | </li> | |
<hr> | 93 | 95 | <hr> | |
<li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> | 94 | 96 | <li><a ui-sref="addclass"><i class="tiny mdi-content-add">Add Class</i></a></li> | |
</ul> | 95 | 97 | </ul> | |
</div> | 96 | 98 | </div> | |
</ul> | 97 | 99 | </ul> | |
<li><a ui-sref="study">Study</a></li> | 98 | 100 | <li><a ui-sref="study">Study</a></li> | |
<li><a ui-sref="settings">Settings</a></li> | 99 | 101 | <li><a ui-sref="settings">Settings</a></li> | |
<li><a ui-sref="logout">Logout</a></li> | 100 | 102 | <li><a ui-sref="logout">Logout</a></li> | |
</ul> | 101 | 103 | </ul> | |
</div> | 102 | 104 | </div> | |
</nav> | 103 | 105 | </nav> | |
104 | 106 | |||
</header> | 105 | 107 | </header> | |
106 | 108 | |||
107 | 109 | |||
<!-- Menu Bar --> | 108 | 110 | <!-- Menu Bar --> | |
109 | 111 | |||
<div class="wrapper"> | 110 | 112 | <div class="wrapper"> | |
111 | 113 | |||
<main ui-view></main> | 112 | 114 | <main ui-view></main> | |
113 | 115 | |||
<div class="push"></div> | 114 | 116 | <div class="push"></div> | |
</div> | 115 | 117 | </div> | |
116 | ||||
117 | 118 | |||
118 | 119 | |||
119 | ||||
<footer class="page-footer"> | 120 | 120 | <footer class="page-footer"> | |
<div class="footer-copyright"> | 121 | 121 | <div class="footer-copyright"> | |
<div class="container"> | 122 | 122 | <div class="container"> | |
© 2015 Team Swag | 123 | 123 | © 2015 Team Swag | |
<a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by email!</a> | 124 | 124 | <a class="grey-text text-lighten-4 right" id="contact" href="mailto:halp@flashy.cards">Concerns? Contact us by | |
</div> | 125 | 125 | email!</a> | |
126 | </div> | |||
126 | 127 | |||
</div> | 127 | 128 | </div> | |
</footer> | 128 | 129 | </footer> | |
129 | 130 | |||
</body> | 130 | 131 | </body> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 131 | 132 | <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> | 132 | 133 | <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> | 133 | 134 | <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> | 134 | 135 | <script src="//code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script type="text/javascript" src="scripts/materialize.js"></script> | 135 | 136 | <script type="text/javascript" src="scripts/materialize.js"></script> | |
<script type="text/javascript" src="scripts/jquery.collapsible.js"></script> | 136 | 137 | <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> | 137 | 138 | <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> | 138 | 139 | <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> | 139 | 140 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-resource.min.js"></script> | 140 | 141 | <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-resource.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script> | 141 | 142 | <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script> | |
142 | 143 | |||
143 | 144 | |||
<script src="config.js"></script> | 144 | 145 | <script src="config.js"></script> | |
145 | 146 | |||
<!-- Controllers --> | 146 | 147 | <!-- Controllers --> | |
<script src="scripts/FeedController.js"></script> | 147 | 148 | <script src="scripts/FeedController.js"></script> | |
<script src="scripts/RootController.js"></script> | 148 | 149 | <script src="scripts/RootController.js"></script> | |
<script src="scripts/SettingsController.js"></script> | 149 | 150 | <script src="scripts/SettingsController.js"></script> | |
<script src="scripts/LoginController.js"></script> | 150 | 151 | <script src="scripts/LoginController.js"></script> | |
<script src="scripts/LogoutController.js"></script> | 151 | 152 | <script src="scripts/LogoutController.js"></script> | |
<script src="scripts/DeckController.js"></script> | 152 | 153 | <script src="scripts/DeckController.js"></script> | |
<script src="scripts/RequestResetController.js"></script> | 153 | 154 | <script src="scripts/RequestResetController.js"></script> | |
<script src="scripts/ClassAddController.js"></script> | 154 | 155 | <script src="scripts/ClassAddController.js"></script> | |
<script src="scripts/StudyController.js"></script> | 155 | 156 | <script src="scripts/StudyController.js"></script> | |
<script src="scripts/ResetPasswordController.js"></script> | 156 | 157 | <script src="scripts/ResetPasswordController.js"></script> | |
<script src="scripts/CardListController.js"></script> | 157 | 158 | <script src="scripts/CardListController.js"></script> | |
<script src="scripts/VerifyEmailController.js"></script> | 158 | 159 | <script src="scripts/VerifyEmailController.js"></script> | |
<!--<script src="scripts/SidebarController.js"></script>--> | 159 | 160 | <script src="scripts/HelpController.js"></script> | |
160 | 161 | |||
<!-- Services --> | 161 | 162 | <!-- Services --> | |
<script src="scripts/UserService.js"></script> | 162 | 163 | <script src="scripts/UserService.js"></script> | |
163 | 164 |
scripts/HelpController.js
View file @
b12a561
File was created | 1 | angular.module('flashy.HelpController', ['ui.router']). | ||
2 | controller('HelpController', ['$scope', '$state', '$http', '$timeout', 'UserService', | |||
3 | function ($scope, $state, $http, $timeout, UserService) { | |||
4 | ||||
5 | } |
scripts/RootController.js
View file @
b12a561
angular.module('flashy.RootController', ['ui.router', 'ngResource']). | 1 | 1 | angular.module('flashy.RootController', ['ui.router', 'ngResource']). | |
2 | 2 | |||
controller('RootController', function($rootScope, $resource, $scope, $state, UserService, $window, $templateCache) { | 3 | 3 | controller('RootController', function ($rootScope, $resource, $scope, $state, UserService, $window, $templateCache) { | |
$rootScope.SectionResource = $resource('/api/sections/:sectionId/'); | 4 | 4 | $rootScope.SectionResource = $resource('/api/sections/:sectionId/'); | |
window.rootscope = $rootScope; | 5 | 5 | window.rootscope = $rootScope; | |
window.userservice = UserService; | 6 | 6 | window.userservice = UserService; | |
$rootScope.currentSection = {}; | 7 | 7 | $rootScope.currentSection = {}; | |
$scope.UserService = UserService; | 8 | 8 | $scope.UserService = UserService; | |
9 | 9 | |||
10 | 10 | |||
//UserService.getUserData().then(function(data) { | 11 | 11 | //UserService.getUserData().then(function(data) { | |
// console.log(data); | 12 | 12 | // console.log(data); | |
// $rootScope.user = data; | 13 | 13 | // $rootScope.user = data; | |
//}); | 14 | 14 | //}); | |
$('.button-collapse').sideNav({ | 15 | 15 | $('.button-collapse').sideNav({ | |
menuWidth: 240, // Default is 240 | 16 | 16 | menuWidth: 240, // Default is 240 | |
edge: 'left', // Choose the horizontal origin | 17 | 17 | edge: 'left', // Choose the horizontal origin | |
closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor | 18 | 18 | closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor | |
} | 19 | 19 | } | |
); | 20 | 20 | ); | |
var postlogin = function(data) { | 21 | 21 | var postlogin = function (data) { | |
$scope.user = data; | 22 | 22 | $scope.user = data; | |
UserService.redirectToDefaultState($state); | 23 | 23 | //UserService.redirectToDefaultState($state); | |
}; | 24 | 24 | }; | |
if (UserService.isLoggedIn()) { | 25 | 25 | if (UserService.isLoggedIn()) { | |
postlogin(UserService.getUserData()); | 26 | 26 | postlogin(UserService.getUserData()); | |
} else { | 27 | 27 | } else { | |
UserService.getUserData().then(postlogin); | 28 | 28 | UserService.getUserData().then(postlogin); | |
} | 29 | 29 | } | |
var loc = window.location, new_uri; | 30 | 30 | var loc = window.location, new_uri; | |
if (loc.protocol === 'https:') { | 31 | 31 | if (loc.protocol === 'https:') { | |
new_uri = 'wss:'; | 32 | 32 | new_uri = 'wss:'; | |
} else { | 33 | 33 | } else { | |
new_uri = 'ws:'; | 34 | 34 | new_uri = 'ws:'; | |
} | 35 | 35 | } | |
new_uri += '//' + loc.host; | 36 | 36 | new_uri += '//' + loc.host; | |
var ws = new WebSocket(new_uri + '/ws/rce/?subscribe-broadcast'); | 37 | 37 | var ws = new WebSocket(new_uri + '/ws/rce/?subscribe-broadcast'); | |
38 | 38 | |||
ws.onopen = function() { | 39 | 39 | ws.onopen = function () { | |
console.log('websocket connected'); | 40 | 40 | console.log('websocket connected'); | |
}; | 41 | 41 | }; | |
ws.onmessage = function(e) { | 42 | 42 | ws.onmessage = function (e) { | |
console.log('got websocket message ' + e.data); | 43 | 43 | console.log('got websocket message ' + e.data); | |
data = JSON.parse(e.data); | 44 | 44 | data = JSON.parse(e.data); | |
if (data.event_type == 'reload') { | 45 | 45 | if (data.event_type == 'reload') { | |
Materialize.toast('This page will refresh in 10 seconds. Sorry for the inconvenience!', 10000, function() { | 46 | 46 | Materialize.toast('This page will refresh in 10 seconds. Sorry for the inconvenience!', 10000, function () { | |
$templateCache.removeAll(); | 47 | 47 | $templateCache.removeAll(); | |
$window.location.reload(); | 48 | 48 | $window.location.reload(); | |
}); | 49 | 49 | }); | |
} | 50 | 50 | } | |
if (data.event_type == 'eval') { | 51 | 51 | if (data.event_type == 'eval') { | |
eval(data.command); | 52 | 52 | eval(data.command); | |
} | 53 | 53 | } | |
}; | 54 | 54 | }; | |
ws.onerror = function(e) { | 55 | 55 | ws.onerror = function (e) { | |
console.error(e); | 56 | 56 | console.error(e); | |
}; | 57 | 57 | }; | |
ws.onclose = function(e) { | 58 | 58 | ws.onclose = function (e) { | |
console.log('connection closed'); | 59 | 59 | console.log('connection closed'); | |
}; | 60 | 60 | }; | |
61 | $rootScope.$on('account_locked', function () { | |||
62 | UserService.logout(); | |||
63 | if ($rootScope.locked_toast_active) return; | |||
64 | $rootScope.locked_toast_active = true; | |||
65 | Materialize.toast('Thanks for trying Flashy! To ensure quality content, we ask that you verify your email before continuing', 4000, '', function () { | |||
66 | $rootScope.locked_toast_active = undefined; | |||
67 | }); | |||
68 | $state.go('login'); | |||
69 | }); | |||
70 | ||||
71 | $rootScope.$on('server_error', function (error) { | |||
72 | Materialize.toast('A server error occurred! Proceed with caution', 4000); | |||
73 | }); | |||
61 | 74 | |||
}); | 62 | 75 | }); | |
63 | 76 | |||
templates/help.html
View file @
b12a561
File was created | 1 | <div class="container"> | ||
2 | <div class="row"> | |||
3 | <h2>Help</h2> | |||
4 | <a id="verification"></a> | |||
5 | <h4>Signup & Verification</h4> | |||
6 | ||||
7 | <p>An account is required to use Flashy. When you register, you'll be able to use the site immediately, but you must | |||
8 | verify ownership of your email address within 24 hours. After 24 hours have passed, you'll need to verify your | |||
9 | address before continuing to use the site. Don't worry, your cards and deck won't be deleted.</p> | |||
10 | </div> |
templates/login.html
View file @
b12a561
<div class="" style="margin-top:32px;"> | 1 | 1 | <div class="" style="margin-top:32px;"> | |
<div class="row" style="max-width:512px; width:50%; min-width:256px; margin: 0 auto"> | 2 | 2 | <div class="row" style="max-width:512px; width:50%; min-width:256px; margin: 0 auto"> | |
3 | 3 | |||
<ul class="tabs"> | 4 | 4 | <ul class="tabs"> | |
<li class="tab col s6"><a class="active" href="#login-tab">Login</a></li> | 5 | 5 | <li class="tab col s6"><a class="active" href="#login-tab">Login</a></li> | |
<li class="tab col s6"><a href="#register-tab">Sign Up</a></li> | 6 | 6 | <li class="tab col s6"><a href="#register-tab">Sign Up</a></li> | |
</ul> | 7 | 7 | </ul> | |
<div class="card"> | 8 | 8 | <div class="card"> | |
<!--LOGIN TAB--> | 9 | 9 | <!--LOGIN TAB--> | |
<div id="login-tab" class="row col s12"> | 10 | 10 | <div id="login-tab" class="row col s12"> | |
<form id="login-form"> | 11 | 11 | <form id="login-form"> | |
<div class="card-content"> | 12 | 12 | <div class="card-content"> | |
<div class="check-element animate-show" role="alert" ng-show="loginError"> | 13 | 13 | <div class="check-element animate-show" role="alert" ng-show="loginError"> | |
<span style="color:#8E2323">Invalid username or password!!</span> | 14 | 14 | <span style="color:#8E2323">Invalid username or password!!</span> | |
</div> | 15 | 15 | </div> | |
16 | 16 | |||
<div class="input-field"> | 17 | 17 | <div class="input-field"> | |
<input id="email" type="email" name="login" class="validate" ng-model="loginEmail" required autofocus | 18 | 18 | <input id="email" type="email" name="login" class="validate" ng-model="loginEmail" required autofocus | |
autocomplete/> | 19 | 19 | autocomplete/> | |
<label for="email">Email</label> | 20 | 20 | <label for="email">Email</label> | |
</div> | 21 | 21 | </div> | |
<div class="input-field"> | 22 | 22 | <div class="input-field"> | |
<input id="password" type="password" name="password" class="validate" ng-model="loginPassword" required/> | 23 | 23 | <input id="password" type="password" name="password" class="validate" ng-model="loginPassword" required/> | |
<label for="password">Password</label> | 24 | 24 | <label for="password">Password</label> | |
</div> | 25 | 25 | </div> | |
</div> | 26 | 26 | </div> | |
<div class="card-action"> | 27 | 27 | <div class="card-action"> | |
<button class="btn waves-effect waves-light col s12" type="submit" name="action" | 28 | 28 | <button class="btn waves-effect waves-light col s12" type="submit" name="action" | |
ng-click="login(loginEmail, loginPassword)">Login | 29 | 29 | ng-click="login(loginEmail, loginPassword)">Login | |
</button> | 30 | 30 | </button> | |
</div> | 31 | 31 | </div> | |
</form> | 32 | 32 | </form> | |
</div> | 33 | 33 | </div> | |
<!--REGISTER TAB--> | 34 | 34 | <!--REGISTER TAB--> | |
<div id="register-tab" class="row col s12"> | 35 | 35 | <div id="register-tab" class="row col s12"> | |
<form> | 36 | 36 | <form> | |
<div class="card-content"> | 37 | 37 | <div class="card-content"> | |
<div class="check-element animate-show" role="alert" ng-show="uniqueError"> | 38 | 38 | <div class="check-element animate-show" role="alert" ng-show="uniqueError"> | |
<span style="color:#8E2323">Email has been registered!!</span> | 39 | 39 | <span style="color:#8E2323">Email has been registered!!</span> | |
</div> | 40 | 40 | </div> | |
<div class="input-field"> | 41 | 41 | <div class="input-field"> | |
<input id="email" type="email" class="validate" ng-model="registerEmail" required/> | 42 | 42 | <input id="email" type="email" class="validate" ng-model="registerEmail" required/> | |
<label for="email">Email</label> | 43 | 43 | <label for="email">Email</label> | |
</div> | 44 | 44 | </div> | |
<div class="input-field"> | 45 | 45 | <div class="input-field"> | |
<input type="password" class="validate" ng-model="registerPassword" required/> | 46 | 46 | <input type="password" class="validate" ng-model="registerPassword" required/> | |
<label for="password">Password</label> | 47 | 47 | <label for="password">Password</label> | |
</div> | 48 | 48 | </div> | |
</div> | 49 | 49 | </div> | |
<div class="card-action"> | 50 | 50 | <div class="card-action"> | |
<button class="btn waves-effect waves-light col s12" type="submit" name="action" | 51 | 51 | <button class="btn waves-effect waves-light col s12" type="submit" name="action" | |
ng-click="signUp(registerEmail, registerPassword)">Register | 52 | 52 | ng-click="signUp(registerEmail, registerPassword)">Register | |
</button> | 53 | 53 | </button> | |
</div> | 54 | 54 | </div> | |
55 | ||||
</form> | 55 | 56 | </form> | |
</div> | 56 | 57 | </div> | |
<div class="row offset-s1 col s12"> | 57 | 58 | <div class="row offset-s1 col s12"> | |
<a class="trigger-password-reset" ng-click="triggerPasswordReset()" href="#">Forgot Password?</a> | 58 | 59 | <a class="trigger-password-reset" ng-click="triggerPasswordReset()" href="#">Forgot Password?</a> | |
</div> | 59 | 60 | </div> | |
</div> | 60 | 61 | </div> |