Skip to content

Commit

Permalink
logger update
Browse files Browse the repository at this point in the history
  • Loading branch information
Malachi Partlow committed Jan 9, 2017
1 parent c53a5d5 commit 197f5a7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ label { display: block; overflow: hidden; }
.loggerSubmit {
padding: 20px;
width: 100%;
background: #009688;
background: #184f2c;
border: 0;
color: #fff;
font-size: 15px;
Expand All @@ -50,7 +50,7 @@ label { display: block; overflow: hidden; }
}
.progress {
width: 0%;
background: #009688;
background: #184f2c;
height: 100%;
transition: .2s width ease-out;
max-width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<input type="text" ng-model="name" class="x12" spellcheck="false"/>
</label>
<label>
<span class="labelText">Amount of Hours Worked</span>
<span class="labelText">Amount of Service Hours</span>
<input type="number" ng-model="amount" class="x12" min="1" spellcheck="false"/>
</label>
<label>
Expand Down
45 changes: 26 additions & 19 deletions js/app.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
Controller.$inject = ['$scope', '$firebaseArray', '$timeout'];

/* @ngInject */
function Controller($scope, $firebaseArray) {
function Controller($scope, $firebaseArray, $timeout) {
var self = this;
var currentRef = firebase.database().ref('track').on("value", function(values){
$scope.current = values.val().currentAmount;
$scope.final = values.val().finalAmount;
/// $scope.$apply();
console.log(values.val())
var data = values.val();
if(!data) data = false;
console.log(data)
$timeout(function(){
$scope.current = data.currentAmount || 0;
$scope.final = data.finalAmount || 0;
});
});

/*
$scope.words = [];
var reasonRef = firebase.database().ref('users').orderByChild('reason').once("value", function(reasonList){
reasonList.forEach(function(reasons){
Expand All @@ -27,21 +32,23 @@
console.log($scope.words);
$scope.$apply();
});

*/
this.addHours = function(name, body, newAmount) {
var hoursRef = firebase.database().ref('track').child('currentAmount');
if(newAmount > 0){
hoursRef.transaction(function(hours) {
if(hours) {
hours += newAmount;
self.saveUser(name, body, newAmount);
}
else hours = newAmount;
$scope.name = "";
$scope.body = "";
$scope.amount = "";
return hours;
});
if(name && body && newAmount){
var hoursRef = firebase.database().ref('track').child('currentAmount');
if(newAmount > 0){
hoursRef.transaction(function(hours) {
if(hours >= 0) {
hours += newAmount;
self.saveUser(name, body, newAmount);
}
else hours = newAmount;
$scope.name = "";
$scope.body = "";
$scope.amount = "";
return hours;
});
}
}
}
this.saveUser = function(name, body, hours) {
Expand Down

0 comments on commit 197f5a7

Please sign in to comment.