mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-12-23 03:59:25 +00:00
Add filter log by failed reason and status
This commit is contained in:
parent
9271e67e7a
commit
2a4721b8de
3 changed files with 19 additions and 24 deletions
|
@ -20,7 +20,6 @@
|
|||
export let data;
|
||||
|
||||
let pageId = '0';
|
||||
let filterProberId = 0;
|
||||
let filterStatus = -1;
|
||||
|
||||
/** @type {MoneroNode | null} */
|
||||
|
@ -67,10 +66,10 @@
|
|||
}
|
||||
};
|
||||
|
||||
$: startInterval(); // Automatically start the interval on change
|
||||
$: startInterval();
|
||||
|
||||
onDestroy(() => {
|
||||
clearInterval(intervalId); // Clear the interval when the component is destroyed
|
||||
clearInterval(intervalId);
|
||||
});
|
||||
onMount(() => {
|
||||
pageId = new URLSearchParams(window.location.search).get('node_id') || '0';
|
||||
|
@ -161,7 +160,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>#ID</th>
|
||||
<th><label for="prober_id">Prober</label></th>
|
||||
<th>Prober ID</th>
|
||||
<th><label for="status">Status</label></th>
|
||||
<th>Height</th>
|
||||
<th>Adjusted Time</th>
|
||||
|
@ -172,21 +171,7 @@
|
|||
<DtSrThSort {handler} orderBy="fetch_runtime">Runtime</DtSrThSort>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<select
|
||||
id="prober_id"
|
||||
name="prober_id"
|
||||
class="select variant-form-material"
|
||||
bind:value={filterProberId}
|
||||
on:change={() => {
|
||||
handler.filter(filterProberId, 'prober_id');
|
||||
handler.invalidate();
|
||||
}}
|
||||
>
|
||||
<option value={0}>Any</option>
|
||||
</select>
|
||||
</th>
|
||||
<th colspan="2">
|
||||
<th colspan="3">
|
||||
<select
|
||||
id="status"
|
||||
name="status"
|
||||
|
@ -206,7 +191,7 @@
|
|||
{handler}
|
||||
filterBy="failed_reason"
|
||||
placeholder="Filter reason"
|
||||
colspan={6}
|
||||
colspan={7}
|
||||
/>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -189,6 +189,8 @@ func ProbeLogs(c *fiber.Ctx) error {
|
|||
SortBy: c.Query("sort_by", "id"),
|
||||
SortDirection: c.Query("sort_direction", "desc"),
|
||||
NodeId: c.QueryInt("node_id", 0),
|
||||
Status: c.QueryInt("status", -1),
|
||||
FailedReason: c.Query("failed_reason"),
|
||||
}
|
||||
|
||||
logs, err := moneroRepo.Logs(query)
|
||||
|
|
|
@ -190,10 +190,10 @@ func (repo *MoneroRepo) Nodes(q MoneroQueryParams) (MoneroNodes, error) {
|
|||
}
|
||||
|
||||
type MoneroLogQueryParams struct {
|
||||
NodeId int // 0 fpr all, >0 for specific node
|
||||
WorkerId int // 0 for all, >0 for specific worker
|
||||
Status int // -1 for all, 0 for failed, 1 for success
|
||||
FailReason string // empty for all, if not empty, will be used as search from failed_reaso
|
||||
NodeId int // 0 fpr all, >0 for specific node
|
||||
WorkerId int // 0 for all, >0 for specific worker
|
||||
Status int // -1 for all, 0 for failed, 1 for success
|
||||
FailedReason string // empty for all, if not empty, will be used as search from failed_reaso
|
||||
|
||||
RowsPerPage int
|
||||
Page int
|
||||
|
@ -231,6 +231,14 @@ func (repo *MoneroRepo) Logs(q MoneroLogQueryParams) (MoneroNodeFetchLogs, error
|
|||
whereQueries = append(whereQueries, "node_id = ?")
|
||||
queryParams = append(queryParams, q.NodeId)
|
||||
}
|
||||
if q.Status != -1 {
|
||||
whereQueries = append(whereQueries, "is_available = ?")
|
||||
queryParams = append(queryParams, q.Status)
|
||||
}
|
||||
if q.FailedReason != "" {
|
||||
whereQueries = append(whereQueries, "failed_reason LIKE ?")
|
||||
queryParams = append(queryParams, "%"+q.FailedReason+"%")
|
||||
}
|
||||
|
||||
if len(whereQueries) > 0 {
|
||||
where = "WHERE " + strings.Join(whereQueries, " AND ")
|
||||
|
|
Loading…
Reference in a new issue