mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Make it also possible to directly execute/track battery charge cycles and habits from overview pages
This commit is contained in:
parent
6fa4e13ba2
commit
02b6c3b721
@ -127,6 +127,8 @@ return array(
|
|||||||
'Tracked charge cylce of battery #1 on #2' => 'Ladezyklus für Batterie #1 am #2 erfasst',
|
'Tracked charge cylce of battery #1 on #2' => 'Ladezyklus für Batterie #1 am #2 erfasst',
|
||||||
'Consume all #1 which are currently in stock' => 'Verbrauche den kompletten Bestand von #1',
|
'Consume all #1 which are currently in stock' => 'Verbrauche den kompletten Bestand von #1',
|
||||||
'All' => 'Alle',
|
'All' => 'Alle',
|
||||||
|
'Track charge cycle of battery #1' => 'Erfasse einen Ladezyklus für Batterie #1',
|
||||||
|
'Track execution of habit #1' => 'Erfasse eine Ausführung von #1',
|
||||||
|
|
||||||
//Constants
|
//Constants
|
||||||
'manually' => 'Manuell',
|
'manually' => 'Manuell',
|
||||||
|
@ -26,7 +26,11 @@ if (!Grocy.ActiveNav.isEmpty())
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.timeago.settings.allowFuture = true;
|
$.timeago.settings.allowFuture = true;
|
||||||
$('time.timeago').timeago();
|
RefreshContextualTimeago = function()
|
||||||
|
{
|
||||||
|
$('time.timeago').timeago();
|
||||||
|
}
|
||||||
|
RefreshContextualTimeago();
|
||||||
|
|
||||||
toastr.options = {
|
toastr.options = {
|
||||||
toastClass: 'alert',
|
toastClass: 'alert',
|
||||||
|
@ -1,5 +1,33 @@
|
|||||||
$('#batteries-overview-table').DataTable({
|
$('#batteries-overview-table').DataTable({
|
||||||
'pageLength': 50,
|
'pageLength': 50,
|
||||||
'order': [[1, 'desc']],
|
'order': [[2, 'desc']],
|
||||||
|
'columnDefs': [
|
||||||
|
{ 'orderable': false, 'targets': 0 }
|
||||||
|
],
|
||||||
'language': JSON.parse(L('datatables_localization'))
|
'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({
|
$('#habits-overview-table').DataTable({
|
||||||
'pageLength': 50,
|
'pageLength': 50,
|
||||||
'order': [[1, 'desc']],
|
'order': [[2, 'desc']],
|
||||||
|
'columnDefs': [
|
||||||
|
{ 'orderable': false, 'targets': 0 }
|
||||||
|
],
|
||||||
'language': JSON.parse(L('datatables_localization'))
|
'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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
@section('activeNav', 'batteriesoverview')
|
@section('activeNav', 'batteriesoverview')
|
||||||
@section('viewJsName', 'batteriesoverview')
|
@section('viewJsName', 'batteriesoverview')
|
||||||
|
|
||||||
|
@push('pageScripts')
|
||||||
|
<script src="{{ $U('/bower_components/jquery-ui/jquery-ui.min.js?v=') }}{{ $version }}"></script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h1 class="page-header">@yield('title')</h1>
|
<h1 class="page-header">@yield('title')</h1>
|
||||||
|
|
||||||
@ -20,6 +24,7 @@
|
|||||||
<table id="batteries-overview-table" class="table table-striped">
|
<table id="batteries-overview-table" class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
<th>{{ $L('Battery') }}</th>
|
<th>{{ $L('Battery') }}</th>
|
||||||
<th>{{ $L('Last charged') }}</th>
|
<th>{{ $L('Last charged') }}</th>
|
||||||
<th>{{ $L('Next planned charge cycle') }}</th>
|
<th>{{ $L('Next planned charge cycle') }}</th>
|
||||||
@ -28,12 +33,19 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach($current as $curentBatteryEntry)
|
@foreach($current as $curentBatteryEntry)
|
||||||
<tr class="@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $nextChargeTimes[$curentBatteryEntry->battery_id] < date('Y-m-d H:i:s')) error-bg @endif">
|
<tr class="@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $nextChargeTimes[$curentBatteryEntry->battery_id] < date('Y-m-d H:i:s')) error-bg @endif">
|
||||||
|
<td class="fit-content">
|
||||||
|
<a class="btn btn-success btn-xs track-charge-cycle-button" href="#" title="{{ $L('Track charge cycle of battery #1', FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name) }}"
|
||||||
|
data-battery-id="{{ $curentBatteryEntry->battery_id }}"
|
||||||
|
data-battery-name="{{ FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name }}">
|
||||||
|
<i class="fa fa-fire"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name }}
|
{{ FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->name }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ $curentBatteryEntry->last_tracked_time }}
|
<span id="battery-{{ $curentBatteryEntry->battery_id }}-last-tracked-time">{{ $curentBatteryEntry->last_tracked_time }}</span>
|
||||||
<time class="timeago timeago-contextual" datetime="{{ $curentBatteryEntry->last_tracked_time }}"></time>
|
<time id="battery-{{ $curentBatteryEntry->battery_id }}-last-tracked-time-timeago" class="timeago timeago-contextual" datetime="{{ $curentBatteryEntry->last_tracked_time }}"></time>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0)
|
@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0)
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
@section('activeNav', 'habitsoverview')
|
@section('activeNav', 'habitsoverview')
|
||||||
@section('viewJsName', 'habitsoverview')
|
@section('viewJsName', 'habitsoverview')
|
||||||
|
|
||||||
|
@push('pageScripts')
|
||||||
|
<script src="{{ $U('/bower_components/jquery-ui/jquery-ui.min.js?v=') }}{{ $version }}"></script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h1 class="page-header">@yield('title')</h1>
|
<h1 class="page-header">@yield('title')</h1>
|
||||||
|
|
||||||
@ -20,6 +24,7 @@
|
|||||||
<table id="habits-overview-table" class="table table-striped">
|
<table id="habits-overview-table" class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
<th>{{ $L('Habit') }}</th>
|
<th>{{ $L('Habit') }}</th>
|
||||||
<th>{{ $L('Next estimated tracking') }}</th>
|
<th>{{ $L('Next estimated tracking') }}</th>
|
||||||
<th>{{ $L('Last tracked') }}</th>
|
<th>{{ $L('Last tracked') }}</th>
|
||||||
@ -28,6 +33,13 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach($currentHabits as $curentHabitEntry)
|
@foreach($currentHabits as $curentHabitEntry)
|
||||||
<tr class="@if(FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->period_type === \Grocy\Services\HabitsService::HABIT_TYPE_DYNAMIC_REGULAR && $nextHabitTimes[$curentHabitEntry->habit_id] < date('Y-m-d H:i:s')) error-bg @endif">
|
<tr class="@if(FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->period_type === \Grocy\Services\HabitsService::HABIT_TYPE_DYNAMIC_REGULAR && $nextHabitTimes[$curentHabitEntry->habit_id] < date('Y-m-d H:i:s')) error-bg @endif">
|
||||||
|
<td class="fit-content">
|
||||||
|
<a class="btn btn-success btn-xs track-habit-button" href="#" title="{{ $L('Track execution of habit #1', FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name) }}"
|
||||||
|
data-habit-id="{{ $curentHabitEntry->habit_id }}"
|
||||||
|
data-habit-name="{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}">
|
||||||
|
<i class="fa fa-play"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}
|
{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}
|
||||||
</td>
|
</td>
|
||||||
@ -40,8 +52,8 @@
|
|||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ $curentHabitEntry->last_tracked_time }}
|
<span id="habit-{{ $curentHabitEntry->habit_id }}-last-tracked-time">{{ $curentHabitEntry->last_tracked_time }}</span>
|
||||||
<time class="timeago timeago-contextual" datetime="{{ $curentHabitEntry->last_tracked_time }}"></time>
|
<time id="habit-{{ $curentHabitEntry->habit_id }}-last-tracked-time-timeago" class="timeago timeago-contextual" datetime="{{ $curentHabitEntry->last_tracked_time }}"></time>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
Loading…
x
Reference in New Issue
Block a user