Skip to content

Commit

Permalink
v1.2 - možnost seřazení dat
Browse files Browse the repository at this point in the history
  • Loading branch information
jahhoo committed Jul 26, 2023
1 parent 6276df3 commit 4c326c7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
12 changes: 11 additions & 1 deletion server/api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,17 @@
$where.=" url_group.groupname='".sqlInject($_GET['kat'])."'";
}

$api->loadData($db, $where, '', $from, $limit, $join);

if($_GET['order']=="url") { $order="url.url"; }
elseif($_GET['order']=="checkTime") { $order="status.date"; }
elseif($_GET['order']=="deadTime") { $order="exticint.exticintDate"; }
elseif($_GET['order']=="index") { $order="status.metadata_match"; }
else { $order="url.id"; }

if(!empty($_GET['orderReverse'])) { $order.=" DESC"; }
else { $order.=" ASC"; }

$api->loadData($db, $where, $order, $from, $limit, $join);
$import=$api->import($db);
if($import) {
$data=$import;
Expand Down
19 changes: 13 additions & 6 deletions ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import Pagination from "./components/Pagination.svelte";
import LimitSelect from "./components/LimitSelect.svelte";
import Notify from "./components/Notify.svelte";
import OrderStatus from "./components/OrderStatus.svelte";
import { api, db } from "./ConfigService.js";
export let urlPath = "";
Expand All @@ -34,6 +35,8 @@
export let checkbox=[];
export let filterDateFrom=false;
export let filterDateTo=false;
export let order="id";
export let orderReverse=false;
export let page=1;
export let limit=15;
Expand All @@ -55,6 +58,10 @@
if(filterType && filterType!="") { param+='&filter='+filterType; }
if(filterDateFrom && filterDateFrom!="") { param+='&dateFrom='+filterDateFrom; }
if(filterDateTo && filterDateTo!="") { param+='&dateTo='+filterDateTo; }
if(order) {
param+='&order='+order;
if(orderReverse) { param+='&orderReverse=1'; }
}
return param;
}
Expand Down Expand Up @@ -92,7 +99,7 @@
});
$: {
if(active) { loadData(filterUrl, filterType, page, limit, filterDateFrom, filterDateTo); }
if(active) { loadData(filterUrl, filterType, page, limit, filterDateFrom, filterDateTo, order, orderReverse); }
if(needsUpdate) {
checkbox=[];
loadData(needsUpdate);
Expand Down Expand Up @@ -220,13 +227,13 @@
<table class="table data-table m-0">
<thead>
<tr>
<th></th>
<th>URL</th>
<th><OrderStatus id="id" bind:order bind:orderReverse /></th>
<th>URL <OrderStatus id="url" bind:order bind:orderReverse /></th>
<th style="min-width:205px;">Info</th>
<th>Poslední kontrola</th>
<th>Index úmrtí</th>
<th>Poslední kontrola <OrderStatus id="checkTime" bind:order bind:orderReverse /></th>
<th>Index úmrtí <OrderStatus id="index" bind:order bind:orderReverse /></th>
<th>Stav</th>
<th>Datum úmrtí</th>
<th>Datum úmrtí <OrderStatus id="deadTime" bind:order bind:orderReverse /></th>
<!--<th>Kategorie</th>-->
<th style="min-width:80px;">Kontrola</th>
</tr>
Expand Down
28 changes: 28 additions & 0 deletions ui/src/components/OrderStatus.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script>
import IoIosArrowDown from 'svelte-icons/io/IoIosArrowDown.svelte'
import IoIosArrowUp from 'svelte-icons/io/IoIosArrowUp.svelte'
export let id="";
export let order;
export let orderReverse;
function setOrder(o, r) {
console.log(id);
order=o;
orderReverse=r;
}
function getActiveClass(o, r, v) {
if(o==id && r==v) { return "orderIconActive"; }
return "";
}
</script>

<div class="orderIcon {getActiveClass(order, orderReverse, 1)}" on:click="{()=>setOrder(id, 1)}"><IoIosArrowDown /></div>
<div class="orderIcon {getActiveClass(order, orderReverse, 0)}" on:click="{()=>setOrder(id, 0)}"><IoIosArrowUp /></div>


<style>
.orderIcon { width:13px; float:right; color:silver; cursor:pointer; }
.orderIconActive { color:black; }
</style>

0 comments on commit 4c326c7

Please sign in to comment.