mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Highlight chores/tasks/batteries due today in a separate color + status filter (closes #1740)
This commit is contained in:
@@ -71,7 +71,7 @@ $(document).on('click', '.track-charge-cycle-button', function(e)
|
||||
function(result)
|
||||
{
|
||||
var batteryRow = $('#battery-' + batteryId + '-row');
|
||||
var nextXDaysThreshold = moment().add($("#info-due-batteries").data("next-x-days"), "days");
|
||||
var nextXDaysThreshold = moment().add($("#info-due-soon-batteries").data("next-x-days"), "days");
|
||||
var now = moment();
|
||||
var nextExecutionTime = moment(result.next_estimated_charge_time);
|
||||
|
||||
@@ -139,28 +139,38 @@ $(document).on('click', '.battery-grocycode-label-print', function(e)
|
||||
|
||||
function RefreshStatistics()
|
||||
{
|
||||
var nextXDays = $("#info-due-batteries").data("next-x-days");
|
||||
var nextXDays = $("#info-due-soon-batteries").data("next-x-days");
|
||||
Grocy.Api.Get('batteries',
|
||||
function(result)
|
||||
{
|
||||
var dueCount = 0;
|
||||
var dueTodayCount = 0;
|
||||
var dueSoonCount = 0;
|
||||
var overdueCount = 0;
|
||||
var now = moment();
|
||||
var overdueThreshold = moment();
|
||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||
var todayThreshold = moment().endOf("day");
|
||||
|
||||
result.forEach(element =>
|
||||
{
|
||||
var date = moment(element.next_estimated_charge_time);
|
||||
if (date.isBefore(now))
|
||||
|
||||
if (date.isBefore(overdueThreshold))
|
||||
{
|
||||
overdueCount++;
|
||||
}
|
||||
else if (date.isBefore(nextXDaysThreshold))
|
||||
else if (date.isSameOrBefore(todayThreshold))
|
||||
{
|
||||
dueCount++;
|
||||
dueTodayCount++;
|
||||
dueSoonCount++;
|
||||
}
|
||||
else if (date.isSameOrBefore(nextXDaysThreshold))
|
||||
{
|
||||
dueSoonCount++;
|
||||
}
|
||||
});
|
||||
|
||||
$("#info-due-batteries").html('<span class="d-block d-md-none">' + dueCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueCount, '%s battery is due to be charged', '%s batteries are due to be charged') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-due-today-batteries").html('<span class="d-block d-md-none">' + dueTodayCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueTodayCount, '%s battery is due to be charged today', '%s batteries are due to be charged today'));
|
||||
$("#info-due-soon-batteries").html('<span class="d-block d-md-none">' + dueSoonCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueSoonCount, '%s battery is due to be charged', '%s batteries are due to be charged') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-overdue-batteries").html('<span class="d-block d-md-none">' + overdueCount + ' <i class="fas fa-times-circle"></i></span><span class="d-none d-md-block">' + __n(overdueCount, '%s battery is overdue to be charged', '%s batteries are overdue to be charged'));
|
||||
},
|
||||
function(xhr)
|
||||
|
@@ -109,7 +109,7 @@ $(document).on('click', '.track-chore-button', function(e)
|
||||
function(result)
|
||||
{
|
||||
var choreRow = $('#chore-' + choreId + '-row');
|
||||
var nextXDaysThreshold = moment().add($("#info-due-chores").data("next-x-days"), "days");
|
||||
var nextXDaysThreshold = moment().add($("#info-due-soon-chores").data("next-x-days"), "days");
|
||||
var now = moment();
|
||||
var nextExecutionTime = moment(result.next_estimated_execution_time);
|
||||
|
||||
@@ -202,25 +202,34 @@ $(document).on('click', '.chore-grocycode-label-print', function(e)
|
||||
|
||||
function RefreshStatistics()
|
||||
{
|
||||
var nextXDays = $("#info-due-chores").data("next-x-days");
|
||||
var nextXDays = $("#info-due-soon-chores").data("next-x-days");
|
||||
Grocy.Api.Get('chores',
|
||||
function(result)
|
||||
{
|
||||
var dueCount = 0;
|
||||
var dueTodayCount = 0;
|
||||
var dueSoonCount = 0;
|
||||
var overdueCount = 0;
|
||||
var assignedToMeCount = 0;
|
||||
var now = moment();
|
||||
var overdueThreshold = moment();
|
||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||
var todayThreshold = moment().endOf("day");
|
||||
|
||||
result.forEach(element =>
|
||||
{
|
||||
var date = moment(element.next_estimated_execution_time);
|
||||
if (date.isBefore(now))
|
||||
|
||||
if (date.isBefore(overdueThreshold))
|
||||
{
|
||||
overdueCount++;
|
||||
}
|
||||
else if (date.isBefore(nextXDaysThreshold))
|
||||
else if (date.isSameOrBefore(todayThreshold))
|
||||
{
|
||||
dueCount++;
|
||||
dueTodayCount++;
|
||||
dueSoonCount++;
|
||||
}
|
||||
else if (date.isSameOrBefore(nextXDaysThreshold))
|
||||
{
|
||||
dueSoonCount++;
|
||||
}
|
||||
|
||||
if (parseInt(element.next_execution_assigned_to_user_id) == Grocy.UserId)
|
||||
@@ -229,7 +238,8 @@ function RefreshStatistics()
|
||||
}
|
||||
});
|
||||
|
||||
$("#info-due-chores").html('<span class="d-block d-md-none">' + dueCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueCount, '%s chore is due to be done', '%s chores are due to be done') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-due-today-chores").html('<span class="d-block d-md-none">' + dueTodayCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueTodayCount, '%s chore is due to be done today', '%s chores are due to be done today'));
|
||||
$("#info-due-soon-chores").html('<span class="d-block d-md-none">' + dueSoonCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueSoonCount, '%s chore is due to be done', '%s chores are due to be done') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-overdue-chores").html('<span class="d-block d-md-none">' + overdueCount + ' <i class="fas fa-times-circle"></i></span><span class="d-none d-md-block">' + __n(overdueCount, '%s chore is overdue to be done', '%s chores are overdue to be done'));
|
||||
$("#info-assigned-to-me-chores").html('<span class="d-block d-md-none">' + assignedToMeCount + ' <i class="fas fa-exclamation-circle"></i></span><span class="d-none d-md-block">' + __n(assignedToMeCount, '%s chore is assigned to me', '%s chores are assigned to me'));
|
||||
},
|
||||
|
@@ -183,28 +183,38 @@ if (GetUriParam('include_done'))
|
||||
|
||||
function RefreshStatistics()
|
||||
{
|
||||
var nextXDays = $("#info-due-tasks").data("next-x-days");
|
||||
var nextXDays = $("#info-due-soon-tasks").data("next-x-days");
|
||||
Grocy.Api.Get('tasks',
|
||||
function(result)
|
||||
{
|
||||
var dueCount = 0;
|
||||
var dueTodayCount = 0;
|
||||
var dueSoonCount = 0;
|
||||
var overdueCount = 0;
|
||||
var now = moment();
|
||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||
var overdueThreshold = moment().subtract(1, "days").endOf("day");
|
||||
var nextXDaysThreshold = moment().endOf("day").add(nextXDays, "days");
|
||||
var todayThreshold = moment().endOf("day");
|
||||
|
||||
result.forEach(element =>
|
||||
{
|
||||
var date = moment(element.due_date);
|
||||
if (date.isBefore(now))
|
||||
var date = moment(element.due_date + " 23:59:59").endOf("day");
|
||||
|
||||
if (date.isSameOrBefore(overdueThreshold))
|
||||
{
|
||||
overdueCount++;
|
||||
}
|
||||
else if (date.isBefore(nextXDaysThreshold))
|
||||
else if (date.isSameOrBefore(todayThreshold))
|
||||
{
|
||||
dueCount++;
|
||||
dueTodayCount++;
|
||||
dueSoonCount++;
|
||||
}
|
||||
else if (date.isSameOrBefore(nextXDaysThreshold))
|
||||
{
|
||||
dueSoonCount++;
|
||||
}
|
||||
});
|
||||
|
||||
$("#info-due-tasks").html('<span class="d-block d-md-none">' + dueCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueCount, '%s task is due to be done', '%s tasks are due to be done') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-due-today-tasks").html('<span class="d-block d-md-none">' + dueTodayCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueTodayCount, '%s task is due to be done today', '%s tasks are due to be done today'));
|
||||
$("#info-due-soon-tasks").html('<span class="d-block d-md-none">' + dueSoonCount + ' <i class="fas fa-clock"></i></span><span class="d-none d-md-block">' + __n(dueSoonCount, '%s task is due to be done', '%s tasks are due to be done') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-overdue-tasks").html('<span class="d-block d-md-none">' + overdueCount + ' <i class="fas fa-times-circle"></i></span><span class="d-none d-md-block">' + __n(overdueCount, '%s task is overdue to be done', '%s tasks are overdue to be done'));
|
||||
},
|
||||
function(xhr)
|
||||
|
Reference in New Issue
Block a user