Finalize loading speed improvements for all data tables (this now closes #120)

This is a workaround for now. The tables are still DOM sourced because of too big dependencies between server side rendering and frontend JS code. The tables are initially load while tbody is hidden, this results in a speedup by around 65 %.
This commit is contained in:
Bernd Bestel 2019-01-05 20:06:35 +01:00
parent 2e265ac70a
commit f6649d51bd
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
38 changed files with 40 additions and 20 deletions

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#batteries-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#batteries-journal-table tbody').removeClass("d-none");
$("#battery-filter").on("change", function() $("#battery-filter").on("change", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#batteries-overview-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#chores-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#chores-journal-table tbody').removeClass("d-none");
$("#chore-filter").on("change", function() $("#chore-filter").on("change", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#chores-overview-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -21,6 +21,7 @@
DisplayEquipment($('#equipment-table tbody tr:eq(0)').data("equipment-id")); DisplayEquipment($('#equipment-table tbody tr:eq(0)').data("equipment-id"));
} }
}); });
$('#equipment-table tbody').removeClass("d-none");
equipmentTable.on('select', function(e, dt, type, indexes) equipmentTable.on('select', function(e, dt, type, indexes)
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#locations-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#apikeys-table tbody').removeClass("d-none");
var createdApiKeyId = GetUriParam('CreatedApiKeyId'); var createdApiKeyId = GetUriParam('CreatedApiKeyId');
if (createdApiKeyId !== undefined) if (createdApiKeyId !== undefined)

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#productgroups-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#products-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#quantityunits-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -43,6 +43,7 @@ var recipesPosTables = $('#recipes-pos-table').DataTable({
dataSrc: 4 dataSrc: 4
} }
}); });
$('#recipes-pos-table tbody').removeClass("d-none");
var recipesIncludesTables = $('#recipes-includes-table').DataTable({ var recipesIncludesTables = $('#recipes-includes-table').DataTable({
'paginate': false, 'paginate': false,
@ -64,6 +65,7 @@ var recipesIncludesTables = $('#recipes-includes-table').DataTable({
}); });
} }
}); });
$('#recipes-includes-table tbody').removeClass("d-none");
Grocy.FrontendHelpers.ValidateForm('recipe-form'); Grocy.FrontendHelpers.ValidateForm('recipe-form');
$("#name").focus(); $("#name").focus();

View File

@ -23,6 +23,7 @@
this.api().row({ order: 'current' }, 0).select(); this.api().row({ order: 'current' }, 0).select();
} }
}); });
$('#recipes-table tbody').removeClass("d-none");
var rowSelect = GetUriParam("row"); var rowSelect = GetUriParam("row");
if (typeof rowSelect !== "undefined") if (typeof rowSelect !== "undefined")

View File

@ -23,6 +23,7 @@
dataSrc: 3 dataSrc: 3
} }
}); });
$('#shoppinglist-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#stock-journal-table tbody').removeClass("d-none");
$("#product-filter").on("change", function() $("#product-filter").on("change", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#taskcategories-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -22,6 +22,7 @@
dataSrc: 3 dataSrc: 3
} }
}); });
$('#tasks-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -18,6 +18,7 @@
}); });
} }
}); });
$('#users-table tbody').removeClass("d-none");
$("#search").on("keyup", function() $("#search").on("keyup", function()
{ {

View File

@ -35,7 +35,7 @@
<th>{{ $L('Charge cycle interval (days)') }}</th> <th>{{ $L('Charge cycle interval (days)') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($batteries as $battery) @foreach($batteries as $battery)
<tr> <tr>
<td class="fit-content"> <td class="fit-content">

View File

@ -37,7 +37,7 @@
<th>{{ $L('Tracked time') }}</th> <th>{{ $L('Tracked time') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($chargeCycles as $chargeCycleEntry) @foreach($chargeCycles as $chargeCycleEntry)
<tr class="@if($chargeCycleEntry->undone == 1) text-muted @endif"> <tr class="@if($chargeCycleEntry->undone == 1) text-muted @endif">
<td class="fit-content"> <td class="fit-content">

View File

@ -48,7 +48,7 @@
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($current as $curentBatteryEntry) @foreach($current as $curentBatteryEntry)
<tr id="battery-{{ $curentBatteryEntry->battery_id }}-row" class="@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $curentBatteryEntry->next_estimated_charge_time < date('Y-m-d H:i:s')) table-danger @elseif(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $curentBatteryEntry->next_estimated_charge_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) table-warning @endif"> <tr id="battery-{{ $curentBatteryEntry->battery_id }}-row" class="@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $curentBatteryEntry->next_estimated_charge_time < date('Y-m-d H:i:s')) table-danger @elseif(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $curentBatteryEntry->next_estimated_charge_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) table-warning @endif">
<td class="fit-content"> <td class="fit-content">

View File

@ -35,7 +35,7 @@
<th>{{ $L('Description') }}</th> <th>{{ $L('Description') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($chores as $chore) @foreach($chores as $chore)
<tr> <tr>
<td class="fit-content"> <td class="fit-content">

View File

@ -38,7 +38,7 @@
<th>{{ $L('Done by') }}</th> <th>{{ $L('Done by') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($choresLog as $choreLogEntry) @foreach($choresLog as $choreLogEntry)
<tr class="@if($choreLogEntry->undone == 1) text-muted @endif"> <tr class="@if($choreLogEntry->undone == 1) text-muted @endif">
<td class="fit-content"> <td class="fit-content">

View File

@ -48,7 +48,7 @@
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($currentChores as $curentChoreEntry) @foreach($currentChores as $curentChoreEntry)
<tr id="chore-{{ $curentChoreEntry->chore_id }}-row" class="@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type === \Grocy\Services\ChoresService::CHORE_TYPE_DYNAMIC_REGULAR && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s')) table-danger @elseif(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type === \Grocy\Services\ChoresService::CHORE_TYPE_DYNAMIC_REGULAR && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) table-warning @endif"> <tr id="chore-{{ $curentChoreEntry->chore_id }}-row" class="@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type === \Grocy\Services\ChoresService::CHORE_TYPE_DYNAMIC_REGULAR && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s')) table-danger @elseif(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type === \Grocy\Services\ChoresService::CHORE_TYPE_DYNAMIC_REGULAR && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) table-warning @endif">
<td class="fit-content"> <td class="fit-content">

View File

@ -24,7 +24,7 @@
<th>{{ $L('Name') }}</th> <th>{{ $L('Name') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($equipment as $equipmentItem) @foreach($equipment as $equipmentItem)
<tr data-equipment-id="{{ $equipmentItem->id }}"> <tr data-equipment-id="{{ $equipmentItem->id }}">
<td> <td>

View File

@ -33,7 +33,7 @@
<th>{{ $L('Description') }}</th> <th>{{ $L('Description') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($locations as $location) @foreach($locations as $location)
<tr> <tr>
<td class="fit-content"> <td class="fit-content">

View File

@ -40,7 +40,7 @@
<th>{{ $L('Created') }}</th> <th>{{ $L('Created') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($apiKeys as $apiKey) @foreach($apiKeys as $apiKey)
<tr id="apiKeyRow_{{ $apiKey->id }}"> <tr id="apiKeyRow_{{ $apiKey->id }}">
<td class="fit-content"> <td class="fit-content">

View File

@ -33,7 +33,7 @@
<th>{{ $L('Description') }}</th> <th>{{ $L('Description') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($productGroups as $productGroup) @foreach($productGroups as $productGroup)
<tr> <tr>
<td class="fit-content"> <td class="fit-content">

View File

@ -41,7 +41,7 @@
<th>{{ $L('Product group') }}</th> <th>{{ $L('Product group') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($products as $product) @foreach($products as $product)
<tr> <tr>
<td class="fit-content"> <td class="fit-content">

View File

@ -33,7 +33,7 @@
<th>{{ $L('Description') }}</th> <th>{{ $L('Description') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($quantityunits as $quantityunit) @foreach($quantityunits as $quantityunit)
<tr> <tr>
<td class="fit-content"> <td class="fit-content">

View File

@ -72,7 +72,7 @@
<th class="d-none">Hiden ingredient group</th> <th class="d-none">Hiden ingredient group</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@if($mode == "edit") @if($mode == "edit")
@foreach($recipePositions as $recipePosition) @foreach($recipePositions as $recipePosition)
<tr class="@if(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->need_fulfilled == 1) table-success @elseif(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->need_fulfilled_with_shopping_list == 1) table-warning @else table-danger @endif"> <tr class="@if(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->need_fulfilled == 1) table-success @elseif(FindObjectInArrayByPropertyValue($recipesFulfillment, 'recipe_pos_id', $recipePosition->id)->need_fulfilled_with_shopping_list == 1) table-warning @else table-danger @endif">
@ -125,7 +125,7 @@
<th>{{ $L('Recipe') }}</th> <th>{{ $L('Recipe') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@if($mode == "edit") @if($mode == "edit")
@foreach($recipeNestings as $recipeNesting) @foreach($recipeNestings as $recipeNesting)
<tr> <tr>

View File

@ -26,7 +26,7 @@
<th class="d-none">Hidden status for sorting of "Requirements fulfilled" column</th> <th class="d-none">Hidden status for sorting of "Requirements fulfilled" column</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($recipes as $recipe) @foreach($recipes as $recipe)
<tr data-recipe-id="{{ $recipe->id }}"> <tr data-recipe-id="{{ $recipe->id }}">
<td> <td>

View File

@ -63,7 +63,7 @@
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($listItems as $listItem) @foreach($listItems as $listItem)
<tr id="shoppinglistitem-{{ $listItem->id }}-row" class="@if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) table-info @endif"> <tr id="shoppinglistitem-{{ $listItem->id }}-row" class="@if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) table-info @endif">
<td class="fit-content"> <td class="fit-content">

View File

@ -39,7 +39,7 @@
<th>{{ $L('Booking type') }}</th> <th>{{ $L('Booking type') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($stockLog as $stockLogEntry) @foreach($stockLog as $stockLogEntry)
<tr class="@if($stockLogEntry->undone == 1) text-muted @endif"> <tr class="@if($stockLogEntry->undone == 1) text-muted @endif">
<td class="fit-content"> <td class="fit-content">

View File

@ -33,7 +33,7 @@
<th>{{ $L('Description') }}</th> <th>{{ $L('Description') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($taskCategories as $taskCategory) @foreach($taskCategories as $taskCategory)
<tr> <tr>
<td class="fit-content"> <td class="fit-content">

View File

@ -64,7 +64,7 @@
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($tasks as $task) @foreach($tasks as $task)
<tr id="task-{{ $task->id }}-row" class="@if($task->done == 1) text-muted @endif @if(!empty($task->due_date) && $task->due_date < date('Y-m-d')) table-danger @elseif(!empty($task->due_date) && $task->due_date < date('Y-m-d', strtotime("+$nextXDays days"))) table-warning @endif"> <tr id="task-{{ $task->id }}-row" class="@if($task->done == 1) text-muted @endif @if(!empty($task->due_date) && $task->due_date < date('Y-m-d')) table-danger @elseif(!empty($task->due_date) && $task->due_date < date('Y-m-d', strtotime("+$nextXDays days"))) table-warning @endif">
<td class="fit-content"> <td class="fit-content">

View File

@ -34,7 +34,7 @@
<th>{{ $L('Last name') }}</th> <th>{{ $L('Last name') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="d-none">
@foreach($users as $user) @foreach($users as $user)
<tr> <tr>
<td class="fit-content"> <td class="fit-content">