diff --git a/check/checkrr.go b/check/checkrr.go index e60aa33..e551ce5 100644 --- a/check/checkrr.go +++ b/check/checkrr.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/aetaric/checkrr/connections" "github.com/aetaric/checkrr/features" @@ -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")) @@ -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 diff --git a/webserver/src/components/Table.jsx b/webserver/src/components/Table.jsx index 97935fa..51ebebb 100644 --- a/webserver/src/components/Table.jsx +++ b/webserver/src/components/Table.jsx @@ -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}, @@ -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,