Skip to content

Instantly share code, notes, and snippets.

View SimonDoy's full-sized avatar

Simon Doy SimonDoy

View GitHub Profile
@SimonDoy
SimonDoy / app.js
Created May 8, 2016 12:24
app.js after having the new dataModelService module added
'use strict';
var invoiceFormApp = angular.module('itspInvoiceFormApp',
[
'ngRoute', 'invoiceControllersModule', 'dataModelService'
]);
@SimonDoy
SimonDoy / invoiceControllers.js
Created May 8, 2016 12:31
Invoice Controllers, "addInvoiceController"
invoiceControllersModule.controller('addInvoiceController', ['$scope', 'dataModelService', '$location', function($scope, dataModelService, $location){
$scope.invoice=new dataModelService.Invoice();
$scope.addInvoiceLine = function addInvoiceLine() {
var newInvoiceLine=new dataModelService.InvoiceLine();
$scope.invoice.invoiceLines.push(newInvoiceLine);
}
$scope.cancel = function cancelStub(){
$location.path('/');
<div class="container">
<div class="row">
<div class="col-md-4 col-sd-12">
<button class="btn btn-default" type="button" title="Save" ng-click="saveInvoice()">Save</button>
&nbsp;
<button class="btn" type="button" title="Cancel" ng-click="cancel()">Cancel</button>
</div>
<div class="col-md-8 col-sd-12">
<span ng-show="status !== ''">{{status}}</span>
@SimonDoy
SimonDoy / dataModelService.js
Created May 10, 2016 07:18
Data Model Service implementation
'use strict'
var dataModelService = angular.module('dataModelService', []);
dataModelService.service('dataModelService', [dataModelServiceFactory]);
dataModelService.provider('dataModelService', function dataModelServiceProvider(){
this.$get = [function initDataModelService(){
var service=new dataModelServiceFactory();
return service;
}];
});
@SimonDoy
SimonDoy / configurationService.js
Created May 11, 2016 06:26
Initial configurationService with our application constants
var configurationService = angular.module('configurationServiceModule', []);
configurationService.constant('applicationConstants', {
'clientId':'7c27b6a6-1bb8-43c0-9b92-2eee2264cc71',
'tenantName':'ithinksharepoint.com',
'instance':'https://login.microsoftonline.com/',
'endPoints': {}
});
@SimonDoy
SimonDoy / invoiceControllers.js
Created May 11, 2016 21:42
Added support for only showing data when the user is authenticated
'use strict'
var invoiceControllersModule = angular.module('invoiceControllersModule', []);
invoiceControllersModule.controller('listInvoicesController', ['$scope', '$location', 'adalAuthenticationService', function ($scope, $location, adalService) {
$scope.invoices = [];
$scope.error="";
$scope.showInvoiceList=function(){
return true;
<div class="container">
<div class="row">
<div ng-show="loggedIn && showInvoiceList" class="col-md-10 col-sd-3">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<th>Date</th>
<th>Invoice Reference</th>
@SimonDoy
SimonDoy / app,js
Created May 11, 2016 21:59
app.js adding support for Adal.js
'use strict';
var invoiceFormApp = angular.module('itspInvoiceFormApp',
[
'ngRoute', 'invoiceControllersModule', 'dataModelService', 'AdalAngular', 'configurationServiceModule'
]);
var appStart = function($routeProvider, $httpProvider, adalProvider, applicationConstants) {
$routeProvider.when('/invoices/add', {
@SimonDoy
SimonDoy / ConfigurationController.cs
Created May 12, 2016 21:12
Configuration Controllers with initial implementation, no authentication
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace Itsp365.InvoiceFormApp.Api.Api.Controllers
{
public class ConfigurationController : ApiController
@SimonDoy
SimonDoy / settings.html
Created May 12, 2016 22:12
Settings View
<section>
<h1> Settings </h1>
<h2> Login Information </h2>
<p class="form-control">
Username: {{userInfo.userName}}
</p>
<p class="form-control">
Profile: <br/>
<ul>