Finalize project reorganization

This commit is contained in:
Bernd Bestel
2018-04-14 11:10:38 +02:00
parent 5a1d21ef31
commit 642f95a3f8
47 changed files with 254 additions and 233 deletions

View File

@@ -0,0 +1,20 @@
Grocy.Components.BatteryCard = { };
Grocy.Components.BatteryCard.Refresh = function(batteryId)
{
Grocy.FetchJson('/api/batteries/get-battery-details/' + batteryId,
function(batteryDetails)
{
$('#batterycard-battery-name').text(batteryDetails.battery.name);
$('#batterycard-battery-last-charged').text((batteryDetails.last_charged || 'never'));
$('#batterycard-battery-last-charged-timeago').text($.timeago(batteryDetails.last_charged || ''));
$('#batterycard-battery-charge-cycles-count').text((batteryDetails.charge_cycles_count || '0'));
EmptyElementWhenMatches('#batterycard-battery-last-charged-timeago', 'NaN years ago');
},
function(xhr)
{
console.error(xhr);
}
);
};

View File

@@ -0,0 +1,20 @@
Grocy.Components.HabitCard = { };
Grocy.Components.HabitCard.Refresh = function (habitId)
{
Grocy.FetchJson('/api/habits/get-habit-details/' + habitId,
function(habitDetails)
{
$('#habitcard-habit-name').text(habitDetails.habit.name);
$('#habitcard-habit-last-tracked').text((habitDetails.last_tracked || 'never'));
$('#habitcard-habit-last-tracked-timeago').text($.timeago(habitDetails.last_tracked || ''));
$('#habitcard-habit-tracked-count').text((habitDetails.tracked_count || '0'));
EmptyElementWhenMatches('#habitcard-habit-last-tracked-timeago', 'NaN years ago');
},
function(xhr)
{
console.error(xhr);
}
);
};

View File

@@ -0,0 +1,25 @@
Grocy.Components.ProductCard = { };
Grocy.Components.ProductCard.Refresh = function(productId)
{
Grocy.FetchJson('/api/stock/get-product-details/' + productId,
function(productDetails)
{
$('#productcard-product-name').text(productDetails.product.name);
$('#productcard-product-stock-amount').text(productDetails.stock_amount || '0');
$('#productcard-product-stock-qu-name').text(productDetails.quantity_unit_stock.name);
$('#productcard-product-stock-qu-name2').text(productDetails.quantity_unit_stock.name);
$('#productcard-product-last-purchased').text((productDetails.last_purchased || 'never').substring(0, 10));
$('#productcard-product-last-purchased-timeago').text($.timeago(productDetails.last_purchased || ''));
$('#productcard-product-last-used').text((productDetails.last_used || 'never').substring(0, 10));
$('#productcard-product-last-used-timeago').text($.timeago(productDetails.last_used || ''));
EmptyElementWhenMatches('#productcard-product-last-purchased-timeago', 'NaN years ago');
EmptyElementWhenMatches('#productcard-product-last-used-timeago', 'NaN years ago');
},
function(xhr)
{
console.error(xhr);
}
);
};