Re-implement existing website template (from PHP). Add all assets.
This commit is contained in:
parent
a87a334bc7
commit
ddf6c5b8ce
60 changed files with 2514 additions and 87 deletions
48
Website/wwwroot/js/controllers/weight.js
Normal file
48
Website/wwwroot/js/controllers/weight.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
angular.module("robware").controller("weight", ["$scope", "weightService", function($scope, weightService) {
|
||||
$scope.submitting = false;
|
||||
$scope.weight = null;
|
||||
$scope.fat = null;
|
||||
|
||||
$scope.readings = [];
|
||||
$scope.headings = {weight: "Weight (KG)", fat: "Fat %", bmi: "BMI"};
|
||||
|
||||
function refreshReadings() {
|
||||
weightService.getReadings().then(function(data) {
|
||||
$scope.readings = data;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.$watch("readings", function() {
|
||||
for (var i = 0; i < $scope.readings.length; i++) {
|
||||
$scope.readings[i].date = new Date($scope.readings[i].date);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.addReading = function() {
|
||||
if (!$scope.weight || !$scope.fat)
|
||||
return;
|
||||
|
||||
$scope.submitting = true;
|
||||
weightService.addWeight($scope.weight, $scope.fat).then(function(data) {
|
||||
refreshReadings();
|
||||
$scope.submitting = false;
|
||||
$scope.weight = null;
|
||||
$scope.fat = null;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteReading = function(id) {
|
||||
weightService.deleteWeight(id).then(function() {
|
||||
refreshReadings();
|
||||
});
|
||||
};
|
||||
|
||||
Object.defineProperty($scope, "tenLatestReadings", {
|
||||
get: function() {
|
||||
var temp = $scope.readings.slice(-10);
|
||||
temp.reverse();
|
||||
return temp;
|
||||
}
|
||||
});
|
||||
}]);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue