From 9992675971ac4db2b465120d540ec81dff71fa90 Mon Sep 17 00:00:00 2001 From: ze0s <43699394+zze0s@users.noreply.github.com> Date: Tue, 2 Jan 2024 21:53:38 +0100 Subject: [PATCH] feat(releases): show details in list view (#1337) * feat(releases): show details in list view * fix(releases): activitytable columns type * fix(releases): incognito mode * feat(releases): move details button * do we wanna truncate? * fix(web): release column width at full size --------- Co-authored-by: martylukyy <35452459+martylukyy@users.noreply.github.com> --- internal/database/release.go | 12 +- internal/domain/release.go | 28 +---- web/src/components/data-table/Cells.tsx | 125 +++++++++++++++----- web/src/components/data-table/index.tsx | 2 +- web/src/screens/dashboard/ActivityTable.tsx | 6 +- web/src/screens/releases/ReleaseTable.tsx | 29 +---- web/src/types/Release.d.ts | 16 +++ web/src/utils/index.ts | 28 +++++ 8 files changed, 155 insertions(+), 91 deletions(-) diff --git a/internal/database/release.go b/internal/database/release.go index 7c6a6e2..38cfff9 100644 --- a/internal/database/release.go +++ b/internal/database/release.go @@ -211,7 +211,7 @@ func (repo *ReleaseRepo) findReleases(ctx context.Context, tx *Tx, params domain } queryBuilder := repo.db.squirrel. - Select("r.id", "r.filter_status", "r.rejections", "r.indexer", "r.filter", "r.protocol", "r.info_url", "r.download_url", "r.title", "r.torrent_name", "r.size", "r.timestamp", + Select("r.id", "r.filter_status", "r.rejections", "r.indexer", "r.filter", "r.protocol", "r.info_url", "r.download_url", "r.title", "r.torrent_name", "r.size", "r.category", "r.season", "r.episode", "r.year", "r.resolution", "r.source", "r.codec", "r.container", "r.release_group", "r.timestamp", "ras.id", "ras.status", "ras.action", "ras.action_id", "ras.type", "ras.client", "ras.filter", "ras.filter_id", "ras.release_id", "ras.rejections", "ras.timestamp"). Column(sq.Alias(countQuery, "page_total")). From("release r"). @@ -245,17 +245,22 @@ func (repo *ReleaseRepo) findReleases(ctx context.Context, tx *Tx, params domain var rls domain.Release var ras domain.ReleaseActionStatus - var rlsindexer, rlsfilter, infoUrl, downloadUrl sql.NullString + var rlsindexer, rlsfilter, infoUrl, downloadUrl, codec sql.NullString var rasId, rasFilterId, rasReleaseId, rasActionId sql.NullInt64 var rasStatus, rasAction, rasType, rasClient, rasFilter sql.NullString var rasRejections []sql.NullString var rasTimestamp sql.NullTime - if err := rows.Scan(&rls.ID, &rls.FilterStatus, pq.Array(&rls.Rejections), &rlsindexer, &rlsfilter, &rls.Protocol, &infoUrl, &downloadUrl, &rls.Title, &rls.TorrentName, &rls.Size, &rls.Timestamp, &rasId, &rasStatus, &rasAction, &rasActionId, &rasType, &rasClient, &rasFilter, &rasFilterId, &rasReleaseId, pq.Array(&rasRejections), &rasTimestamp, &countItems); err != nil { + if err := rows.Scan(&rls.ID, &rls.FilterStatus, pq.Array(&rls.Rejections), &rlsindexer, &rlsfilter, &rls.Protocol, &infoUrl, &downloadUrl, &rls.Title, &rls.TorrentName, &rls.Size, &rls.Category, &rls.Season, &rls.Episode, &rls.Year, &rls.Resolution, &rls.Source, &codec, &rls.Container, &rls.Group, &rls.Timestamp, &rasId, &rasStatus, &rasAction, &rasActionId, &rasType, &rasClient, &rasFilter, &rasFilterId, &rasReleaseId, pq.Array(&rasRejections), &rasTimestamp, &countItems); err != nil { return res, 0, 0, errors.Wrap(err, "error scanning row") } + //for _, codec := range codecs { + // rls.Codec = append(rls.Codec, codec.String) + // + //} + ras.ID = rasId.Int64 ras.Status = domain.ReleasePushStatus(rasStatus.String) ras.Action = rasAction.String @@ -291,6 +296,7 @@ func (repo *ReleaseRepo) findReleases(ctx context.Context, tx *Tx, params domain rls.ActionStatus = make([]domain.ReleaseActionStatus, 0) rls.InfoURL = infoUrl.String rls.DownloadURL = downloadUrl.String + rls.Codec = strings.Split(codec.String, ",") // only add ActionStatus if it's not empty if ras.ID > 0 { diff --git a/internal/domain/release.go b/internal/domain/release.go index bca09c7..75e96f7 100644 --- a/internal/domain/release.go +++ b/internal/domain/release.go @@ -59,7 +59,7 @@ type Release struct { TorrentTmpFile string `json:"-"` TorrentDataRawBytes []byte `json:"-"` TorrentHash string `json:"-"` - TorrentName string `json:"torrent_name"` // full release name + TorrentName string `json:"name"` // full release name Size uint64 `json:"size"` Title string `json:"title"` // Parsed title Description string `json:"-"` @@ -538,32 +538,6 @@ func (r *Release) HasMagnetUri() bool { return r.MagnetURI != "" } -type magnetRoundTripper struct{} - -func (rt *magnetRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) { - if r.URL.Scheme == "magnet" { - responseBody := r.URL.String() - respReader := io.NopCloser(strings.NewReader(responseBody)) - - resp := &http.Response{ - Status: http.StatusText(http.StatusOK), - StatusCode: http.StatusOK, - Body: respReader, - ContentLength: int64(len(responseBody)), - Header: map[string][]string{ - "Content-Type": {"text/plain"}, - "Location": {responseBody}, - }, - Proto: "HTTP/2.0", - ProtoMajor: 2, - } - - return resp, nil - } - - return http.DefaultTransport.RoundTrip(r) -} - func (r *Release) ResolveMagnetUri(ctx context.Context) error { if r.MagnetURI == "" { return nil diff --git a/web/src/components/data-table/Cells.tsx b/web/src/components/data-table/Cells.tsx index b6a71c4..fab165b 100644 --- a/web/src/components/data-table/Cells.tsx +++ b/web/src/components/data-table/Cells.tsx @@ -7,33 +7,110 @@ import * as React from "react"; import { toast } from "react-hot-toast"; import { formatDistanceToNowStrict } from "date-fns"; import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { CellProps } from "react-table"; import { ArrowPathIcon, CheckIcon } from "@heroicons/react/24/solid"; -import { ArrowDownTrayIcon, ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline"; import { ExternalLink } from "../ExternalLink"; -import { ClockIcon, XMarkIcon, NoSymbolIcon } from "@heroicons/react/24/outline"; +import { + ClockIcon, + XMarkIcon, + NoSymbolIcon, + ArrowDownTrayIcon, + ArrowTopRightOnSquareIcon, DocumentTextIcon +} from "@heroicons/react/24/outline"; import { APIClient } from "@api/APIClient"; -import { classNames, simplifyDate } from "@utils"; +import {classNames, humanFileSize, simplifyDate} from "@utils"; import { filterKeys } from "@screens/filters/List"; import Toast from "@components/notifications/Toast"; import { RingResizeSpinner } from "@components/Icons"; import { Tooltip } from "@components/tooltips/Tooltip"; -interface CellProps { - value: string; -} - -interface LinksCellProps { - value: Release; -} - -export const AgeCell = ({ value }: CellProps) => ( -