Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth), arch(requirejs) #23

Merged
merged 1 commit into from
Aug 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ dist
app/components
test-results.xml
.DS_Store
docs/*
docs/*
libpeerconnection.log
*.jar
31 changes: 13 additions & 18 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" ng-app="app"> <!--<![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Title</title>
<title>ngSeed</title>
<base href="/">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">

<!-- build:css styles/screen.css -->
<link rel="stylesheet" href="styles/screen.css">
<link rel="stylesheet" href="styles/bootstrap.css">
<link rel="stylesheet" href="styles/application.css">
<!-- endbuild -->

</head>
<body>
<div class="navbar">
<a class="navbar-brand" href="#">ngSeed</a>
<ul class="nav navbar-nav">
<li><a href="/users">Users</a></li>
</ul>
</div>

<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
<![endif]-->
Expand All @@ -30,21 +39,7 @@
<div class="container" ng-view></div>

<!-- build:js scripts/scripts.js -->
<script src="components/underscore/underscore.js"></script>
<script src="components/async/lib/async.js"></script>
<script src="components/angular-unstable/angular.js"></script>
<script src="components/angular-resource-unstable/angular-resource.js"></script>
<script src="components/angular-http-auth/src/http-auth-interceptor.js"></script>

<script src="scripts/init.js"></script>
<script src="scripts/routes.js"></script>
<script src="scripts/controllers/home.js"></script>
<script src="scripts/directives/string-to-number.js"></script>
<script src="scripts/services/generic.js"></script>
<script src="scripts/services/session.js"></script>
<script src="scripts/services/http-options.js"></script>
<script src="scripts/services/country-list.js"></script>
<script src="scripts/filters/starts-with.js"></script>
<script data-main="scripts/main" src="components/requirejs/require.js"></script>
<!-- endbuild -->

</body>
Expand Down
30 changes: 30 additions & 0 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
define(['angular'],function (angular) {

'use strict';

var services = angular.module('app.services',
[ 'ngResource',
'http-auth-interceptor'
]);

var directives = angular.module('app.directives',
[
]);

var filters = angular.module('app.filters',
[
]);

var resources = angular.module('app.resources',
[
]);

var app = angular.module('app',
[ 'app.services',
'app.directives',
'app.filters',
'app.resources'
]);

return app;
});
25 changes: 25 additions & 0 deletions app/scripts/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
define(['angular', 'app'], function (angular, app) {
'use strict';

app.config(
['$locationProvider', '$httpProvider', '$authProvider',
function ($locationProvider, $httpProvider, $authProvider) {

$httpProvider.defaults.withCredentials = true;
$locationProvider.html5Mode( true );
}]);

// Initialize $auth
// app.run(['$auth', '$resourceFactory',
// function ($auth, $resourceFactory) {
// You can register your resources here
// $resourceFactory('Resource#1')
// $resourceFactory('Resource#2')
// After this, they will be available to be injected
// in your controllers like regular services.
// }]);
//
app.run(['$auth', '$debug', function ($auth, $debug) {
}]);

});
1 change: 1 addition & 0 deletions app/scripts/controllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty file
19 changes: 6 additions & 13 deletions app/scripts/controllers/home.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
var app = angular.module('app');

app.controller( 'HomeCtrl',
['$scope',
function( $scope ) {

'use strict';

$scope.welcome = 'Hello!';

$scope.awesomeThings = [1,2,3];

}]);
define(['app'], function (app) {
'use strict';
app.controller('Home', ['$scope', function ($scope) {
$scope.welcome = "Hello there!";
}]);
});
17 changes: 17 additions & 0 deletions app/scripts/controllers/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
define(['app'], function (app) {
'use strict';

app.controller('Login', ['$scope','$auth', function ($scope, $auth) {
$scope.login = function () {
$auth.login($scope.credentials);
}

$scope.$on('$auth:loginFailure', function (event, data) {
console.log("LoginController:",event,data);
if(data === '403') {
alert('Invalid username/password');
}
});

}]);
});
10 changes: 10 additions & 0 deletions app/scripts/controllers/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
define(['app'], function (app) {
'use strict';

app.controller('Users', ['$scope', '$auth', function ($scope, $auth) {

$scope.welcome = "This is a private area.";

}]);

});
1 change: 1 addition & 0 deletions app/scripts/directives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty file
81 changes: 42 additions & 39 deletions app/scripts/directives/string-to-number.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
var directives = angular.module('ngSeed.directives');

/**
* @ngdoc directive
* @name ngSeed.directives:string2number
* @description
* Converts a string to a number. Useful in type="number" input
* elements that bind to a stringified number model.
*/
directives.directive('string2number', function() {

define(['angular', 'app'], function (angular) {
'use strict';

return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attr, ngModel) {
/**
* @ngdoc directive
* @name ngSeed.directives:string2number
* @description
* Converts a string to a number. Useful in type="number" input
* elements that bind to a stringified number model.
*/
angular
.module('app.directives')
.directive('string2number', function() {

return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attr, ngModel) {

/**
* @ngdoc method
* @name fromField
* @methodOf ngSeed.directives:string2number
* @param {Number, String} number Just the number that has been input.
* @return {Number} The number.
*/
function fromField(number) {
return Number(number);
}

/**
* @ngdoc method
* @name fromField
* @methodOf ngSeed.directives:string2number
* @param {Number, String} number Just the number that has been input.
* @return {Number} The number.
*/
function fromField(number) {
return Number(number);
}
/**
* @ngdoc method
* @name toField
* @methodOf ngSeed.directives:string2number
* @param {Number, String} number Just the number that has been input.
* @return {Number} The number or 0.
*/
function toField(text) {
return Number(text || 0);
}
ngModel.$parsers.push(fromField);
ngModel.$formatters.push(toField);
}
};
});

/**
* @ngdoc method
* @name toField
* @methodOf ngSeed.directives:string2number
* @param {Number, String} number Just the number that has been input.
* @return {Number} The number or 0.
*/
function toField(text) {
return Number(text || 0);
}
ngModel.$parsers.push(fromField);
ngModel.$formatters.push(toField);
}
};
});
1 change: 1 addition & 0 deletions app/scripts/filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty file
Loading