mirror of
https://github.com/grocy/grocy.git
synced 2025-10-12 16:44:55 +00:00
Make it also possible to directly execute/track battery charge cycles and habits from overview pages
This commit is contained in:
@@ -1,5 +1,33 @@
|
||||
$('#batteries-overview-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'desc']],
|
||||
'order': [[2, 'desc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
||||
$(document).on('click', '.track-charge-cycle-button', function(e)
|
||||
{
|
||||
var batteryId = $(e.currentTarget).attr('data-battery-id');
|
||||
var batteryName = $(e.currentTarget).attr('data-battery-name');
|
||||
var trackedTime = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
Grocy.Api.Get('batteries/track-charge-cycle/' + batteryId + '?tracked_time=' + trackedTime,
|
||||
function(result)
|
||||
{
|
||||
$('#battery-' + batteryId + '-last-tracked-time').parent().effect('highlight', {}, 500);
|
||||
$('#battery-' + batteryId + '-last-tracked-time').fadeOut(500, function () {
|
||||
$(this).text(trackedTime).fadeIn(500);
|
||||
});
|
||||
$('#battery-' + batteryId + '-last-tracked-time-timeago').attr('datetime', trackedTime);
|
||||
RefreshContextualTimeago();
|
||||
|
||||
toastr.success(L('Tracked charge cylce of battery #1 on #2', batteryName, trackedTime));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@@ -1,5 +1,33 @@
|
||||
$('#habits-overview-table').DataTable({
|
||||
'pageLength': 50,
|
||||
'order': [[1, 'desc']],
|
||||
'order': [[2, 'desc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
||||
$(document).on('click', '.track-habit-button', function(e)
|
||||
{
|
||||
var habitId = $(e.currentTarget).attr('data-habit-id');
|
||||
var habitName = $(e.currentTarget).attr('data-habit-name');
|
||||
var trackedTime = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
Grocy.Api.Get('habits/track-habit-execution/' + habitId + '?tracked_time=' + trackedTime,
|
||||
function(result)
|
||||
{
|
||||
$('#habit-' + habitId + '-last-tracked-time').parent().effect('highlight', {}, 500);
|
||||
$('#habit-' + habitId + '-last-tracked-time').fadeOut(500, function () {
|
||||
$(this).text(trackedTime).fadeIn(500);
|
||||
});
|
||||
$('#habit-' + habitId + '-last-tracked-time-timeago').attr('datetime', trackedTime);
|
||||
RefreshContextualTimeago();
|
||||
|
||||
toastr.success(L('Tracked execution of habit #1 on #2', habitName, trackedTime));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user