mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Added a rudimentary habit analysis possibility
This commit is contained in:
@@ -50,6 +50,15 @@ class HabitsController extends BaseController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function Analysis(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
|
{
|
||||||
|
return $this->AppContainer->view->render($response, 'habitsanalysis', [
|
||||||
|
'habitsLog' => $this->Database->habits_log()->orderBy('tracked_time', 'DESC'),
|
||||||
|
'habits' => $this->Database->habits()->orderBy('name'),
|
||||||
|
'users' => $this->Database->users()->orderBy('username')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function HabitEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function HabitEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
if ($args['habitId'] == 'new')
|
if ($args['habitId'] == 'new')
|
||||||
|
@@ -184,6 +184,8 @@ return array(
|
|||||||
'Done by' => 'Ausgeführt von',
|
'Done by' => 'Ausgeführt von',
|
||||||
'Last done by' => 'Zuletzt ausgeführt von',
|
'Last done by' => 'Zuletzt ausgeführt von',
|
||||||
'Unknown' => 'Unbekannt',
|
'Unknown' => 'Unbekannt',
|
||||||
|
'Filter by habit' => 'Nach Gewohnheit filtern',
|
||||||
|
'Habits analysis' => 'Gewohnheiten Analyse',
|
||||||
|
|
||||||
//Constants
|
//Constants
|
||||||
'manually' => 'Manuell',
|
'manually' => 'Manuell',
|
||||||
|
37
public/viewjs/habitsanalysis.js
Normal file
37
public/viewjs/habitsanalysis.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
var habitsAnalysisTable = $('#habits-analysis-table').DataTable({
|
||||||
|
'paginate': false,
|
||||||
|
'order': [[1, 'desc']],
|
||||||
|
'language': JSON.parse(L('datatables_localization')),
|
||||||
|
'scrollY': false,
|
||||||
|
'colReorder': true,
|
||||||
|
'stateSave': true
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#habit-filter").on("change", function()
|
||||||
|
{
|
||||||
|
var value = $(this).val();
|
||||||
|
var text = $("#habit-filter option:selected").text();
|
||||||
|
if (value === "all")
|
||||||
|
{
|
||||||
|
text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
habitsAnalysisTable.column(0).search(text).draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#search").on("keyup", function()
|
||||||
|
{
|
||||||
|
var value = $(this).val();
|
||||||
|
if (value === "all")
|
||||||
|
{
|
||||||
|
value = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
habitsAnalysisTable.search(value).draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (typeof GetUriParam("habit") !== "undefined")
|
||||||
|
{
|
||||||
|
$("#habit-filter").val(GetUriParam("habit"));
|
||||||
|
$("#habit-filter").trigger("change");
|
||||||
|
}
|
@@ -41,6 +41,7 @@ $app->group('', function()
|
|||||||
// Habit routes
|
// Habit routes
|
||||||
$this->get('/habitsoverview', '\Grocy\Controllers\HabitsController:Overview');
|
$this->get('/habitsoverview', '\Grocy\Controllers\HabitsController:Overview');
|
||||||
$this->get('/habittracking', '\Grocy\Controllers\HabitsController:TrackHabitExecution');
|
$this->get('/habittracking', '\Grocy\Controllers\HabitsController:TrackHabitExecution');
|
||||||
|
$this->get('/habitsanalysis', '\Grocy\Controllers\HabitsController:Analysis');
|
||||||
|
|
||||||
$this->get('/habits', '\Grocy\Controllers\HabitsController:HabitsList');
|
$this->get('/habits', '\Grocy\Controllers\HabitsController:HabitsList');
|
||||||
$this->get('/habit/{habitId}', '\Grocy\Controllers\HabitsController:HabitEditForm');
|
$this->get('/habit/{habitId}', '\Grocy\Controllers\HabitsController:HabitEditForm');
|
||||||
|
63
views/habitsanalysis.blade.php
Normal file
63
views/habitsanalysis.blade.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
@extends('layout.default')
|
||||||
|
|
||||||
|
@section('title', $L('Habits analysis'))
|
||||||
|
@section('activeNav', 'habitsanalysis')
|
||||||
|
@section('viewJsName', 'habitsanalysis')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<h1>@yield('title')</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-xs-12 col-md-6 col-xl-3">
|
||||||
|
<label for="habit-filter">{{ $L('Filter by habit') }}</label> <i class="fas fa-filter"></i>
|
||||||
|
<select class="form-control" id="habit-filter">
|
||||||
|
<option value="all">{{ $L('All') }}</option>
|
||||||
|
@foreach($habits as $habit)
|
||||||
|
<option value="{{ $habit->id }}">{{ $habit->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-6 col-xl-3">
|
||||||
|
<label for="search">{{ $L('Search') }}</label> <i class="fas fa-search"></i>
|
||||||
|
<input type="text" class="form-control" id="search">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<table id="habits-analysis-table" class="table table-sm table-striped dt-responsive">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{{ $L('Habit') }}</th>
|
||||||
|
<th>{{ $L('Tracked time') }}</th>
|
||||||
|
<th>{{ $L('Done by') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($habitsLog as $habitLogEntry)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ FindObjectInArrayByPropertyValue($habits, 'id', $habitLogEntry->habit_id)->name }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ $habitLogEntry->tracked_time }}
|
||||||
|
<time class="timeago timeago-contextual" datetime="{{ $habitLogEntry->tracked_time }}"></time>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@if ($habitLogEntry->done_by_user_id !== null && !empty($habitLogEntry->done_by_user_id))
|
||||||
|
{{ GetUserDisplayName(FindObjectInArrayByPropertyValue($users, 'id', $habitLogEntry->done_by_user_id)) }}
|
||||||
|
@else
|
||||||
|
{{ $L('Unknown') }}
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@stop
|
@@ -44,6 +44,9 @@
|
|||||||
data-habit-name="{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}">
|
data-habit-name="{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}">
|
||||||
<i class="fas fa-play"></i>
|
<i class="fas fa-play"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a class="btn btn-info btn-sm" href="{{ $U('/habitsanalysis?habit=') }}{{ $curentHabitEntry->habit_id }}">
|
||||||
|
<i class="fas fa-chart-line"></i>
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}
|
{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}
|
||||||
|
Reference in New Issue
Block a user