Permalink
Browse files

Updated for S01E05

  • Loading branch information...
SimonDoy committed May 11, 2016
1 parent 5f8afd7 commit e02ac5c2af67245cbd5bacd7886b96fb4406c148
@@ -2,23 +2,42 @@
var invoiceFormApp = angular.module('itspInvoiceFormApp',
[
'ngRoute', 'invoiceControllersModule', 'dataModelService'
'ngRoute', 'invoiceControllersModule', 'dataModelService', 'AdalAngular', 'configurationServiceModule'
]);
var appStart = function($routeProvider) {
var appStart = function($routeProvider, $httpProvider, adalProvider, applicationConstants) {
$routeProvider.when('/invoices/add', {
templateUrl:'/app/views/add-invoice.html',
controller: 'addInvoiceController'
controller: 'addInvoiceController',
requireADLogin: true
}).when('/invoices', {
templateUrl:'/app/views/list-invoices.html',
controller: 'listInvoicesController'
controller: 'listInvoicesController',
requireADLogin: false
}).otherwise({
redirectTo: '/invoices'
});
var instance=applicationConstants.instance;
var clientId=applicationConstants.clientId;
var tenantName=applicationConstants.tenantName;
var endPoints=applicationConstants.endPoints;
adalProvider.init({
instance: instance,
tenant: tenantName,
clientId: clientId,
endPoints: endPoints,
anonymousEndpoints:{},
extraQueryParameter: 'nux=1',
cacheLocation: 'localStorage', // enable this for IE, as sessionStorage does not work for localhost.
}, $httpProvider);
};
invoiceFormApp.config(['$routeProvider', appStart]);
invoiceFormApp.config(['$routeProvider', '$httpProvider', 'adalAuthenticationServiceProvider', 'applicationConstants', appStart]);
@@ -2,7 +2,7 @@
var invoiceControllersModule = angular.module('invoiceControllersModule', []);
invoiceControllersModule.controller('listInvoicesController', ['$scope', function ($scope) {
invoiceControllersModule.controller('listInvoicesController', ['$scope', '$location', 'adalAuthenticationService', function ($scope, $location, adalService) {
$scope.invoices = [];
$scope.error="";
@@ -32,7 +32,19 @@ invoiceControllersModule.controller('listInvoicesController', ['$scope', functio
$scope.invoices.push(invoice);
};
$scope.load();
$scope.loggedIn=adalService.userInfo.isAuthenticated;
$scope.login = function loginStub(){
adalService.login().then(function(){
$location('#')
});
}
if(adalService.userInfo.isAuthenticated)
{
$scope.load();
}
function createInvoice(){
var invoiceObject={
@@ -24,10 +24,13 @@
<script src="/bower_components/angular-resource/angular-resource.js"></script>
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="/bower_components/adal-angular/dist/adal.min.js"></script>
<script src="/bower_components/adal-angular/dist/adal-angular.min.js"></script>
<script src="/app/controllers/invoiceControllers.js"></script>
<script src="/app/services/dataModelService.js"></script>
<script src="/app/services/configurationService.js"></script>
<script src="/app/app.js"></script>
@@ -0,0 +1,9 @@
var configurationService = angular.module('configurationServiceModule', []);
configurationService.constant('applicationConstants', {
'clientId':'7c27b6a6-1bb8-43c0-9b92-2eee2264cc71',
'tenantName':'ithinksharepoint.com',
'instance':'https://login.microsoftonline.com/',
'endPoints': {'https://itspinvoiceformapp.azurewebsites.net/api':'https://apiinvoiceform.ithinksharepoint.com'},
});
@@ -1,3 +1,4 @@
'use strict'
var dataModelService = angular.module('dataModelService', []);
dataModelService.service('dataModelService', [dataModelServiceFactory]);
@@ -2,7 +2,7 @@
<div class="container">
<div class="row">
<div ng-show="showInvoiceList" class="col-md-10 col-sd-3">
<div ng-show="loggedIn && showInvoiceList" class="col-md-10 col-sd-3">
<div class="table-responsive">
<table class="table table-striped">
<thead>
@@ -25,6 +25,9 @@
</table>
</div>
</div>
<div ng-hide="loggedIn">
<button class="btn btn-primary" title="Login" ng-click="login()">Login</a>
</div>
</div>
<div class="row">
<div ng-show="error !== ''" class="col-sd-3">
@@ -0,0 +1,55 @@
{
"name": "adal-angular",
"version": "1.0.8",
"homepage": "https://github.com/AzureAD/azure-activedirectory-library-for-js",
"authors": [
"MSOpentech"
],
"description": "Azure Active Directory Client Library for js",
"main": [
"./lib/adal.js",
"./lib/adal-angular.js"
],
"moduleType": [
"node"
],
"keywords": [
"adal",
"oauth",
"active",
"directory",
"azure"
],
"licenses": [
{
"type": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": "*"
},
"devDependencies": {
"angular-resource": "~1.2.26",
"angular-mocks": "~1.2.16",
"jasmine": "2.0.0",
"angular-route": "~1.2.26"
},
"_release": "1.0.8",
"_resolution": {
"type": "version",
"tag": "v1.0.8",
"commit": "72d217fb006c29d702ad6d427342c340ccf95b02"
},
"_source": "git://github.com/AzureAD/azure-activedirectory-library-for-js.git",
"_target": "^1.0.8",
"_originalSource": "adal-angular",
"_direct": true
}
@@ -0,0 +1,66 @@
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ['build/'],
jsdoc: {
dist: {
src: ['lib/*.js'],
options: {
destination: 'doc'
}
}
},
jshint: {
src: {
options: {
jshintrc: '.jshintrc'
},
src: ['lib/*.js']
}
},
jasmine_node: {
options: {
forceExit: true,
match: '.',
matchall: false,
extensions: 'js',
specNameMatcher: 'spec',
jUnit: {
report: true,
savePath: "./build/reports/jasmine/",
useDotNotation: true,
consolidate: true
}
},
all: ['tests/unit/spec/']
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
static_mappings: {
// Because these src-dest file mappings are manually specified, every
// time a new file is added or removed, the Gruntfile has to be updated.
files: [
{ src: 'lib/adal.js', dest: 'build/adal.min.js' },
{ src: 'lib/adal-angular.js', dest: 'build/adal-angular.min.js' },
],
}
},
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-jasmine-node');
// uglify task is producing invalid js file
// jasmine node directly js api
grunt.registerTask('default', ['jshint', 'jasmine_node']);
grunt.registerTask('doc', ['jsdoc']);
grunt.registerTask('minify', ['uglify']);
};
Oops, something went wrong.

0 comments on commit e02ac5c

Please sign in to comment.