Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vibronet committed Oct 22, 2014
1 parent 464317d commit ae98d4b
Show file tree
Hide file tree
Showing 27 changed files with 2,194 additions and 0 deletions.
22 changes: 22 additions & 0 deletions TodoSPA.sln
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoSPA", "TodoSPA\TodoSPA.csproj", "{C177F6EE-E7DB-4FA3-96A2-72CB04A98F68}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C177F6EE-E7DB-4FA3-96A2-72CB04A98F68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C177F6EE-E7DB-4FA3-96A2-72CB04A98F68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C177F6EE-E7DB-4FA3-96A2-72CB04A98F68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C177F6EE-E7DB-4FA3-96A2-72CB04A98F68}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
28 changes: 28 additions & 0 deletions TodoSPA/App/Scripts/App.js
@@ -0,0 +1,28 @@
'use strict';
var app = angular.module('TodoSPA', ['ngRoute','AdalAngular']);
// version 1
app.config(['$routeProvider', '$httpProvider', 'adalAuthenticationServiceProvider', function ($routeProvider, $httpProvider, adalAuthenticationServiceProvider) {

$routeProvider.when("/Home", {
controller: "HomeController",
templateUrl: "/App/Views/Home.html",
}).when("/TodoList", {
controller: "TodoListController",
templateUrl: "/App/Views/TodoList.html",
requireADLogin: true,
}).when("/UserData", {
controller: "UserDataController",
templateUrl: "/App/Views/UserData.html",
}).otherwise({ redirectTo: "/Home" });

adalAuthenticationServiceProvider.init(
{
tenant: '52d4b072-9470-49fb-8721-bc3a1c9912a1',
clientId: 'e9a5a8b6-8af7-4719-9821-0deef255f68e',
instance: 'https://login.windows-ppe.net/',
extraQueryParameter: 'nux=1'
},
$httpProvider // pass http provider to inject request interceptor to attach tokens
);

}]);
11 changes: 11 additions & 0 deletions TodoSPA/App/Scripts/HomeController.js
@@ -0,0 +1,11 @@
app.controller('HomeController', ['$scope', 'adalAuthenticationService','$location', function ($scope, adalAuthenticationService, $location) {
$scope.Login = function () {
adalAuthenticationService.login();
};
$scope.Logout = function () {
adalAuthenticationService.logOut();
};
$scope.isActive = function (viewLocation) {
return viewLocation === $location.path();
};
}]);
3 changes: 3 additions & 0 deletions TodoSPA/App/Scripts/IndexController.js
@@ -0,0 +1,3 @@
app.controller('IndexController', ['$scope', 'adalAuthenticationService', function ($scope, adalAuthenticationService) {

}]);
74 changes: 74 additions & 0 deletions TodoSPA/App/Scripts/TodoListController.js
@@ -0,0 +1,74 @@
'use strict';
app.controller('TodoListController', ['$scope', '$location', 'TodoListService', function ($scope, $location, TodoListService) {
$scope.error = "";
$scope.loadingMsg = "Loading...";
$scope.TodoList = null;
$scope.EditingInProgress = false;

$scope.NewTodo = {
Owner: "default",
Description: ""
};

$scope.EditInProgressTodo = {
Description: "",
ID: 0
};

$scope.InitNewTodo = function () {
$scope.NewTodo = {
Owner: "default",
Description: ""
};
};

$scope.EditSwitch = function (todo) {
todo.edit = !todo.edit;
if (todo.edit) {
$scope.EditInProgressTodo.Description = todo.Description;
$scope.EditInProgressTodo.ID = todo.ID;
$scope.EditingInProgress = true;
} else {
$scope.EditingInProgress = false;
}
};

$scope.Populate = function () {
TodoListService.getItems().success(function (results) {
$scope.TodoList = results;
$scope.loadingMsg = "";
}).error(function (err) {
$scope.error = err;
$scope.loadingMsg = "";
})
};
$scope.Delete = function (id) {
TodoListService.deleteItem(id).success(function (results) {
$scope.loadingMsg = "";
$scope.Populate();
}).error(function (err) {
$scope.error = err;
$scope.loadingMsg = "";
})
};
$scope.Update = function (todo) {
TodoListService.putItem($scope.EditInProgressTodo).success(function (results) {
$scope.loadingMsg = "";
$scope.Populate();
$scope.EditSwitch(todo);
}).error(function (err) {
$scope.error = err;
$scope.loadingMsg = "";
})
};
$scope.Add = function () {
TodoListService.postItem($scope.NewTodo).success(function (results) {
$scope.loadingMsg = "";
$scope.InitNewTodo();
$scope.Populate();
}).error(function (err) {
$scope.error = err;
$scope.loadingMsg = "";
})
};
}]);
36 changes: 36 additions & 0 deletions TodoSPA/App/Scripts/TodoListService.js
@@ -0,0 +1,36 @@
'use strict';
app.factory('TodoListService', ['$http', function ($http) {
var serviceFactory = {};

var _getItems = function () {
return $http.get('/api/TodoList');
};

var _getItem = function (id) {
return $http.get('/api/TodoList/' + id);
};

var _postItem = function (data) {
return $http.post('/api/TodoList/',data);
};

var _putItem = function (data) {
return $http.put('/api/TodoList/', data);
};

var _deleteItem = function (id) {
return $http({
method: 'DELETE',
url: '/api/TodoList/' + id
});
};

serviceFactory.getItems = _getItems;
serviceFactory.getItem = _getItem;
serviceFactory.deleteItem = _deleteItem;
serviceFactory.postItem = _postItem;
serviceFactory.putItem = _putItem;

return serviceFactory;

}]);
4 changes: 4 additions & 0 deletions TodoSPA/App/Scripts/UserDataController.js
@@ -0,0 +1,4 @@
app.controller('UserDataController', ['$scope', 'adalAuthenticationService', function ($scope, adalAuthenticationService) {


}]);

0 comments on commit ae98d4b

Please sign in to comment.