-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed project structure, introduce routing
- Loading branch information
Showing
12 changed files
with
151 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
{ | ||
"directory": "public/bower_components" | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Declare app level module which depends on views, and components | ||
angular.module("myApp", [ | ||
"ngRoute", | ||
"myApp.login" | ||
]). | ||
config(["$routeProvider", function($routeProvider) { | ||
$routeProvider.otherwise({redirectTo: "/login"}); | ||
}]); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!doctype html> | ||
<html lang="en" ng-app="myApp"> | ||
<head> | ||
<script src="bower_components/angular/angular.js"></script> | ||
<script src="bower_components/angular-route/angular-route.js"></script> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<title>Cmput391</title> | ||
<!-- Latest compiled and minified CSS --> | ||
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> | ||
|
||
<!-- jQuery library --> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> | ||
|
||
<!-- Latest compiled JavaScript --> | ||
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | ||
</head> | ||
<body> | ||
<div data-ng-view></div> | ||
<script src="./app.js"></script> | ||
<script src="login/login.js"></script> | ||
<script src="login/loginHandler.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="loginWrapper" style="text-align:center;" ng-controller="LoginController"> | ||
<div> <h1> CMPUT 391 App </h1> </div> | ||
<div class="username" style=""> | ||
<div class="form-group"> | ||
<label for="usernameInput">Username</label> | ||
<input class="form-control input-sm" ng-model="usernameInput" id="inputuser" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
|
||
<div class="password"> | ||
<div class="form-group"> | ||
<label for="passwordInput">Password</label> | ||
<input class="form-control input-sm" ng-model="passwordInput" id="inputpass" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
<button type="button" class="btn btn-default" ng-click="submit()">LOGIN</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
angular.module("myApp.login", ["ngRoute", "myApp.login.loginHandler"]) | ||
|
||
.config(["$routeProvider", function($routeProvider) { | ||
$routeProvider.when("/login", { | ||
templateUrl: "login/login.html", | ||
controller: "LoginController" | ||
}); | ||
}]) | ||
|
||
.controller("LoginController", function($scope, $location, loginHandler) { | ||
$scope.submit = function() { | ||
loginHandler.login($scope.usernameInput, $scope.passwordInput).then(function() { | ||
// $location.url("/"); | ||
console.log("asdfasd"); | ||
}); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var SERVICE_BASE_URL = 'http://localhost:8080/'; | ||
|
||
angular.module("myApp.login.loginHandler", []) | ||
.service("loginHandler", function($http, $q) { | ||
this.loginWatchers = []; | ||
|
||
this.login = function (username, password) { | ||
return ($loginpost = $http({ | ||
method: 'POST', | ||
url: SERVICE_BASE_URL + "login", | ||
headers: {'Content-Type': 'application/x-www-form-urlencoded'}, | ||
transformRequest: function(obj) { | ||
var str = []; | ||
for(var p in obj) | ||
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); | ||
return str.join("&"); | ||
}, | ||
data: {userName: username, password: password} | ||
}).success(function (result) { | ||
console.log("success " + result.success); | ||
}).error(function (result) { | ||
console.log("error "+ result.success); | ||
})); | ||
}; | ||
|
||
this.logout = function() { | ||
// //Keep this wrapped in 'q' just to keep everything consistent. | ||
// return $q(function(resolve/*, reject*/) { | ||
// // $httpProvider.defaults.headers.common.Authorization = undefined; | ||
// this.loginWatchers.forEach(function(f) { | ||
// f(false); | ||
// }); | ||
// resolve(); | ||
// }.bind(this)); | ||
}; | ||
|
||
this.watchLogin = function(callback) { | ||
this.loginWatchers.push(callback); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "c391-project1-jwoo-tcngo", | ||
"description": "project for cmput 391 ualberta", | ||
"main": "server.js", | ||
"moduleType": [], | ||
"authors": [ | ||
"tcngo", | ||
"jwoo" | ||
], | ||
"license": "ISC", | ||
"homepage": "https://github.com/jwoo12/CMPUT391_W16", | ||
"private": true, | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"angular": "^1.5.0", | ||
"angular-route": "~1.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.