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

Assignment Session 2 #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
1,018 changes: 1,018 additions & 0 deletions Scripts/Angular/angular-route.js

Large diffs are not rendered by default.

29,018 changes: 29,018 additions & 0 deletions Scripts/Angular/angular.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions Scripts/Controller/dashController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';
app.controller('DashboardCtrl', ['$scope', 'incomeService', 'expenseService', function ($scope, incomeService, expenseService) {
// Income Total
$scope.incomeData;
var promise = incomeService.getIncomeDetails();
promise.then(function (data) {
// Here data will return the complete response
// data.data will contain actual data
$scope.incomeData = data.data;

$scope.incomeTotal = 0;
for (var a in $scope.incomeData) {
$scope.incomeTotal += parseFloat($scope.incomeData[a]["amount"]);
}

});

// Expense Total
$scope.expenseData;
var expensePromise = expenseService.getExpenseDetails();
expensePromise.then(function (data) {
$scope.expenseData = data.data;

$scope.expenseTotal = 0;
for (var a in $scope.expenseData) {
$scope.expenseTotal += parseFloat($scope.expenseData[a]["amount"]);
}
});

}]);




49 changes: 49 additions & 0 deletions Scripts/Controller/expController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';
app.controller('ExpenseCtrl', ['$scope', 'expenseService',
function ($scope, expenseService) {

/**
* @desc Array of expenses object
* @memberOf ExpenseCtrl
*/
$scope.expenseArray;
var promise = expenseService.getExpenseDetails();
promise.then(function (data) {
$scope.expenseArray = data.data;
});

$scope.expDetailsEdit = {};
$scope.editable = false;

$scope.compose = function (transaction) {
$scope.editable = true;
$scope.expVisible = false;
$scope.expDetailsEdit = transaction;
};

$scope.saveComposition = function () {
$scope.editable = false;
}
// Adding Expense

$scope.newListing = {};
$scope.addExpense = function (newListing) {
$scope.expenseArray.push(newListing);
$scope.newListing = {};
$scope.expDetails = {};
$scope.expVisible = false;

}
$scope.expVisible = false;
$scope.AddNewExpenseBtn = function () {
$scope.expVisible = true;
$scope.editable = false;

}

// Removing expense
$scope.removeExpense = function (index) {
$scope.expenseArray.splice(index, 1);
}

}]);
53 changes: 53 additions & 0 deletions Scripts/Controller/incomeController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@


'use strict';
app.controller('IncomeCtrl', ['$scope', 'incomeService',

function ($scope, incomeService) {


$scope.expDetails = {};
$scope.incomeArray;
var promise = incomeService.getIncomeDetails();
promise.then(function (data) {
$scope.incomeArray = data.data;
});

$scope.expDetailsEdit = {};
$scope.editable = false;

$scope.compose = function (transaction) {
$scope.editable = true;
$scope.incomeVisible = false;
$scope.expDetailsEdit = transaction;
};

$scope.saveComposition = function () {
$scope.editable = false;
}

// Add Income

$scope.incomeVisible = false;
/*function To show the add income form*/
$scope.AddNewIncomeBtn = function () {
$scope.incomeVisible = true;
$scope.editable = false;
}

$scope.newListing = {};
$scope.addIncome = function (newListing) {

console.log(newListing);
$scope.incomeArray.push(newListing);
$scope.newListing = {};
$scope.expDetails = {};
$scope.incomeVisible = false;
}

// Removing Income
$scope.removeIncome = function (index) {
$scope.incomeArray.splice(index, 1);
}

}]);
30 changes: 30 additions & 0 deletions Scripts/Controller/settingController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';
app.controller('settingCtrl', ['$scope', function($scope) {

$scope.notifyArray =[{ "category": "Movie",
"subCategory": 2000,
"transType": "15-10-2015",
"reccur": "online"
},
{ "category": "Movie",
"subCategory": 2000,
"transType": "15-10-2015",
"reccur": "online"
}

];

$scope.addNotification = function (notifyData) {
console.log(notifyData);

$scope.notifyArray.push(notifyData);
$scope.notifyData = {};
console.log($scope.notifyArray);


}

}]);



33 changes: 33 additions & 0 deletions Scripts/JSON/expensedata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[

{
"transactionId": 1,
"payer": "Hemant",
"payee": "Ajay",
"category": "Movie",
"amount": 2000,
"date": "15-10-2015",
"modeofpayment": "online"

},
{
"transactionId": 2,
"payer": "john",
"payee": "rocky",
"category": "Shopping",
"amount": 1000,
"date": "18-01-2016",
"modeofpayment": "cash"

},
{
"transactionId": 3,
"payer": "ricky",
"payee": "robb",
"category": "Entertainment",
"amount": 2000,
"date": "11-01-2016",
"modeofpayment": "cash"

}
]
31 changes: 31 additions & 0 deletions Scripts/JSON/incomedata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{
"transactionId": 1,
"payer": "Martin",
"payee": "Organization name",
"category": "payment",
"amount": 20000,
"date": "15-10-2015",
"modeofpayment": "online"

},
{
"transactionId": 2,
"payer": "Rahul",
"payee": "rocky",
"category": "Business",
"amount": 180,
"date": "18-01-2016",
"modeofpayment": "cash"
},
{
"transactionId": 3,
"payer": "Andy",
"payee": "Bank",
"category": "Interest",
"amount": 200,
"date": "11-01-2016",
"modeofpayment": "cash"

}
]
17 changes: 17 additions & 0 deletions Scripts/Services/Expense/expService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

app.service('expenseService',function( $http,$q ){



var deferred = $q.defer();

$http.get("Scripts/JSON/expensedata.json").then(function (data) {
deferred.resolve(data);
});

this.getExpenseDetails = function () {
return deferred.promise;
};

});
17 changes: 17 additions & 0 deletions Scripts/Services/Income/incService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

app.service('incomeService',function( $http,$q ){



var deferred = $q.defer();

$http.get("Scripts/JSON/incomedata.json").then(function (data) {
deferred.resolve(data);
});

this.getIncomeDetails = function () {
return deferred.promise;
};

});
39 changes: 39 additions & 0 deletions Scripts/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var app = angular.module('myApp',['ngRoute']);


app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/',{
templateUrl: 'Views/Dashboard.html'
}).
when('/dashboard', {
templateUrl: 'Views/Dashboard.html',
controller: 'DashboardCtrl'
}).
when('/income', {
templateUrl: 'views/IncomeShow.html',
controller: 'IncomeCtrl'
}).
when('/expense', {
templateUrl: 'views/ExpenceShow.html',
controller: 'ExpenseCtrl'
}).
when('/setting', {
templateUrl: 'views/Setting.html',
controller: 'settingCtrl'
}).
otherwise({
redirectTo: '/Views/Dashboard.html'
});
}]);


app.directive("notification", function(){
return {
restrict:'E',
scope: {
data:'='
},
templateUrl:"views/notification.html"
}
});
22 changes: 22 additions & 0 deletions Views/Dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div>
<h1>
Dashboard
</h1>
</div>

<table style=" margin-left:20px;" border="1">

<tr>
<th>Total Income</th>
<th>Total Expense</th>
<th>Total Balance</th>
</tr>


<tr>
<td ng-bind="incomeTotal"></td>
<td ng-bind="expenseTotal"></td>
<td ng-bind="incomeTotal - expenseTotal"></td>
</tr>

</table>
Loading