Skip to content

Commit

Permalink
Close #59 adds a date column to the bad files table.
Browse files Browse the repository at this point in the history
  • Loading branch information
aetaric committed Oct 8, 2024
1 parent 709aee6 commit 7b5977a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions check/checkrr.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"strings"
"time"

"github.com/aetaric/checkrr/connections"
"github.com/aetaric/checkrr/features"
Expand Down Expand Up @@ -386,6 +387,7 @@ func (c *Checkrr) recordBadFile(path string, fileType string) {

bad.Service = fileType
bad.FileExt = filepath.Ext(path)
bad.Date = time.Now().UTC().Unix() // put this in UTC for the webui to render in local later

err := c.DB.Update(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("Checkrr-files"))
Expand All @@ -411,6 +413,7 @@ type BadFile struct {
FileExt string `json:"fileExt"`
Reacquire bool `json:"reacquire"`
Service string `json:"service"`
Date int64 `json:"date`
}

// TODO: if h2non/filetype#120 ever gets completed, remove this logic
Expand Down
13 changes: 13 additions & 0 deletions webserver/src/components/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Typography from '@mui/material/Typography';

const columns = [
{ field: 'id', headerName: 'ID', flex: 0.05, },
{ field: 'date', headerName: 'Date Added', flex: 0.15},
{ field: 'path', headerName: 'Path', flex: 1},
{ field: 'ext', headerName: 'File Extension', flex: 0.15,},
{ field: 'reacquire', headerName: 'Reacquired', flex: 0.15},
Expand All @@ -36,11 +37,23 @@ export default function DataTable() {
p: 4,
};


function timeConverter(UNIX_timestamp){
var a = new Date(UNIX_timestamp * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var time = date + ' ' + month + ' ' + year ;
return time;
}

function fetchData() {
http.get(`./api/files/bad`)
.then(data => {
const rows = data?.map((l, i) => ({
id: i + 1,
date: timeConverter(l.Data.Date),
path: l.Path,
ext: l.Data.fileExt,
reacquire: l.Data.reacquire,
Expand Down

0 comments on commit 7b5977a

Please sign in to comment.