Commit 4da3dd30319c3c5e9401658414737bab2c0c84a2
1 parent
0c77c1b84f
Exists in
master
and in
1 other branch
Tried unbreaking frontend. Set up gjslint. Damn it's strict
Showing 8 changed files with 53 additions and 154 deletions Side-by-side Diff
config.js
View file @
4da3dd3
1 | -angular.module('flashy', ['flashy.controller', 'ngCookies']) | |
2 | - | |
3 | - .config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', | |
1 | +angular.module('flashy', [ | |
2 | + 'flashy.LogoutController', | |
3 | + 'flashy.LoginController', | |
4 | + 'flashy.HomeController', | |
5 | + 'flashy.FeedController', | |
6 | + 'ngCookies']). | |
7 | + config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', | |
4 | 8 | function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { |
9 | + "use strict"; | |
10 | + $httpProvider.defaults.withCredentials = true; | |
11 | + $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
12 | + $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
5 | 13 | $locationProvider.html5Mode(true); |
6 | - | |
7 | - | |
8 | 14 | $urlRouterProvider.otherwise('/home'); |
9 | - | |
10 | 15 | $stateProvider. |
11 | 16 | state('home', { |
12 | 17 | url: '/home', |
13 | 18 | |
14 | 19 | |
... | ... | @@ -28,15 +33,11 @@ |
28 | 33 | templateUrl: 'templates/dashboard.html', |
29 | 34 | controller: 'DashboardController' |
30 | 35 | }). |
31 | - state('dashboard.feed', { | |
36 | + state('feed', { | |
32 | 37 | url: '/feed', |
33 | 38 | templateUrl: 'templates/feed.html', |
34 | 39 | controller: 'FeedController' |
35 | - }) | |
40 | + }); | |
36 | 41 | |
37 | - }]).run(function run($http, $cookies) { | |
38 | - console.log($cookies.csrftoken); | |
39 | - $.getJSON('https://flashy.cards/api/sections/') | |
40 | - $http.defaults.headers.post['X-CSRFToken'] = $cookies.csrftoken; | |
41 | - }); | |
42 | + }]); |
gjslint.conf
View file @
4da3dd3
scripts/FeedController.js
View file @
4da3dd3
1 | -angular.module('flashy.controllers', ['ui.router']).config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', | |
2 | - function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | |
3 | - $httpProvider.defaults.withCredentials = true; | |
4 | - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
5 | - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
6 | - } | |
7 | -]). | |
1 | +angular.module('flashy.FeedController', ['ui.router']). | |
8 | 2 | |
9 | -controller("FeedController", ['$scope', '$state', function ($scope, $state) { | |
10 | - console.log("Hello from feed"); | |
3 | +controller('FeedController', ['$scope', '$state', function($scope, $state) { | |
4 | + console.log('Hello from feed'); | |
11 | 5 | }]); |
scripts/HomeController.js
View file @
4da3dd3
1 | -angular.module('flashy.controllers', ['ui.router']).config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', | |
2 | - function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | |
3 | - $httpProvider.defaults.withCredentials = true; | |
4 | - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
5 | - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
6 | - } | |
7 | -]). | |
1 | +angular.module('flashy.HomeController', ['ui.router']). | |
8 | 2 | |
9 | -controller("HomeController", ['$scope', '$state', function ($scope, $state) { | |
10 | - $state.go('login'); | |
11 | -}]); | |
3 | + controller('HomeController', ['$scope', '$state', function($scope, $state) { | |
4 | + $state.go('login'); | |
5 | + }]); |
scripts/LoginController.js
View file @
4da3dd3
1 | -angular.module('flashy.controllers', ['ui.router']).config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', | |
2 | - function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | |
3 | - $httpProvider.defaults.withCredentials = true; | |
4 | - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
5 | - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
6 | - } | |
7 | -]). | |
8 | - | |
9 | -controller('LoginController', ['$scope', '$state', '$http', function ($scope, $state, $http) { | |
10 | - $.ajaxPrefilter(function (options, originalOptions, jqXHR) { | |
11 | - options.crossDomain = { | |
12 | - crossDomain: true | |
13 | - }; | |
14 | - options.xhrFields = { | |
15 | - withCredentials: true | |
16 | - }; | |
17 | - }); | |
18 | - | |
19 | - $scope.signUp = function (email, password) { | |
20 | - $http.post('https://flashy.cards/api/users/me', JSON.stringify({ | |
21 | - "email": email, | |
22 | - "password": password | |
23 | - })).success(function (data) { | |
24 | - $state.go('dashboard'); | |
25 | - console.log(data); | |
26 | - }); | |
27 | - | |
28 | - }; | |
29 | - | |
30 | - $scope.login = function (email, password) { | |
31 | - $http.post('https://flashy.cards/api/login', JSON.stringify({ | |
32 | - "email": email, | |
33 | - "password": password | |
34 | - })).success(function (data) { | |
35 | - $state.go('dashboard'); | |
36 | - console.log(data); | |
37 | - }); | |
38 | - }; | |
39 | - | |
40 | - | |
41 | -}]); | |
1 | +angular.module('flashy.LoginController', ['ui.router']). | |
2 | + controller('LoginController', ['$scope', '$state', '$http', | |
3 | + function($scope, $state, $http) { | |
4 | + 'use strict'; | |
5 | + $scope.login = function(email, password) { | |
6 | + $http.post('/api/login', JSON.stringify({ | |
7 | + 'email': email, | |
8 | + 'password': password | |
9 | + })).success(function(data) { | |
10 | + $state.go('feed'); | |
11 | + console.log(data); | |
12 | + }); | |
13 | + }; | |
14 | + $scope.register = function(email, password) { | |
15 | + $http.post('/api/users/me', JSON.stringify({ | |
16 | + 'email': email, | |
17 | + 'password': password | |
18 | + })).success(function(data) { | |
19 | + $state.go('feed'); | |
20 | + console.log(data); | |
21 | + }); | |
22 | + }; | |
23 | + }]); |
scripts/LogoutController.js
View file @
4da3dd3
1 | -angular.module('flashy.controllers', ['ui.router']).config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', | |
2 | - function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | |
3 | - $httpProvider.defaults.withCredentials = true; | |
4 | - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
5 | - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
6 | - } | |
7 | -]). | |
1 | +angular.module('flashy.LogoutController', ['ui.router']). | |
8 | 2 | |
9 | -controller("LogoutController", ['$scope', '$state', '$http', function ($s | |
10 | - $http.post('https://flashy.cards/api/logout').success(function () { | |
11 | - $state.go('home'); | |
12 | - }); | |
13 | -}]); | |
3 | + controller('LogoutController', ['$scope', '$state', '$http', function($scope, $state, $http) { | |
4 | + $http.post('/api/logout').success(function() { | |
5 | + $state.go('home'); | |
6 | + }); | |
7 | + }]); |
scripts/controller.js
View file @
4da3dd3
1 | -var app = angular.module('flashy.controller', ['ui.router']).config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', | |
2 | - function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { | |
3 | - $httpProvider.defaults.withCredentials = true; | |
4 | - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; | |
5 | - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; | |
6 | - }]); | |
7 | - | |
8 | - | |
9 | -app.controller('LoginController', ['$scope', '$state', '$http', function ($scope, $state, $http) { | |
10 | - $.ajaxPrefilter(function (options, originalOptions, jqXHR) { | |
11 | - options.crossDomain = { | |
12 | - crossDomain: true | |
13 | - }; | |
14 | - options.xhrFields = { | |
15 | - withCredentials: true | |
16 | - }; | |
17 | - }); | |
18 | - | |
19 | - $scope.signUp = function (email, password) { | |
20 | - $http.post('https://flashy.cards/api/users/me', JSON.stringify({ | |
21 | - "email": email, | |
22 | - "password": password | |
23 | - })).success(function (data) { | |
24 | - $state.go('dashboard'); | |
25 | - console.log(data); | |
26 | - }); | |
27 | - | |
28 | - }; | |
29 | - | |
30 | - $scope.login = function (email, password) { | |
31 | - $http.post('https://flashy.cards/api/login', JSON.stringify({ | |
32 | - "email": email, | |
33 | - "password": password | |
34 | - })).success(function (data) { | |
35 | - $state.go('dashboard'); | |
36 | - console.log(data); | |
37 | - }); | |
38 | - }; | |
39 | - | |
40 | - | |
41 | -}]); | |
42 | - | |
43 | - | |
44 | -app.controller("HomeController", ['$scope', '$state', function ($scope, $state) { | |
45 | - $state.go('login'); | |
46 | -}]); | |
47 | - | |
48 | -app.controller("FeedController", ['$scope', '$state', function ($scope, $state) { | |
49 | - console.log("Hello from feed"); | |
50 | -}]); | |
51 | - | |
52 | -app.controller("LogoutController", ['$scope', '$state', '$http', function ($scope, $state, $http) { | |
53 | - $http.post('https://flashy.cards/api/logout').success(function () { | |
54 | - $state.go('home'); | |
55 | - }); | |
56 | -}]); | |
57 | - | |
58 | - | |
59 | -app.controller("SidebarController", function ($scope, $state) { | |
60 | - // This gets really annoying every time I refresh the page :( | |
61 | - //alert("HEYYYYYY"); | |
62 | - | |
63 | - | |
64 | -}); |
templates/login_form.html
View file @
4da3dd3
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | <input type="password" class="form-control" ng-model="loginPassword" placeholder="Password"/> |
13 | 13 | </div> |
14 | 14 | <input type="submit" class="btn btn-primary" ng-click="login(loginEmail, loginPassword)" value="LOGIN"/> |
15 | - <input type="submit" class="btn btn-primary" ng-click="signUp(loginEmail, loginPassword)" value="REGISTER"/> | |
15 | + <input type="submit" class="btn btn-primary" ng-click="register(loginEmail, loginPassword)" value="REGISTER"/> | |
16 | 16 | </form> |
17 | 17 | </div> |