1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
import {
faCheck,
faExclamationTriangle,
faWrench,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { FunctionComponent, useMemo } from "react";
import { Badge, ProgressBar } from "react-bootstrap";
import { Link } from "react-router-dom";
import { Column } from "react-table";
import { seriesUpdateByRange, seriesUpdateInfoAll } from "../@redux/actions";
import { useRawSeries } from "../@redux/hooks";
import { useReduxAction } from "../@redux/hooks/base";
import { SeriesApi } from "../apis";
import { ActionBadge } from "../components";
import BaseItemView from "../generic/BaseItemView";
import { BuildKey } from "../utilites";
interface Props {}
const SeriesView: FunctionComponent<Props> = () => {
const [series] = useRawSeries();
const load = useReduxAction(seriesUpdateByRange);
const columns: Column<Item.Series>[] = useMemo<Column<Item.Series>[]>(
() => [
{
Header: "Name",
accessor: "title",
className: "text-nowrap",
Cell: ({ row, value, isSelecting: select }) => {
if (select) {
return value;
} else {
const target = `/series/${row.original.sonarrSeriesId}`;
return (
<Link to={target}>
<span>{value}</span>
</Link>
);
}
},
},
{
Header: "Exist",
accessor: "exist",
selectHide: true,
Cell: (row) => {
const exist = row.value;
const { path } = row.row.original;
return (
<FontAwesomeIcon
title={path}
icon={exist ? faCheck : faExclamationTriangle}
></FontAwesomeIcon>
);
},
},
{
Header: "Audio",
accessor: "audio_language",
Cell: (row) => {
return row.value.map((v) => (
<Badge
variant="secondary"
className="mr-2"
key={BuildKey(v.code2, v.forced, v.hi)}
>
{v.name}
</Badge>
));
},
},
{
Header: "Languages Profile",
accessor: "profileId",
Cell: ({ value, loose }) => {
if (loose) {
// Define in generic/BaseItemView/table.tsx
const profiles = loose[0] as Profile.Languages[];
return profiles.find((v) => v.profileId === value)?.name ?? null;
} else {
return null;
}
},
},
{
Header: "Episodes",
accessor: "episodeFileCount",
selectHide: true,
Cell: (row) => {
const {
episodeFileCount,
episodeMissingCount,
profileId,
} = row.row.original;
let progress = 0;
let label = "";
if (episodeFileCount === 0 || !profileId) {
progress = 0.0;
} else {
progress = episodeFileCount - episodeMissingCount;
label = `${
episodeFileCount - episodeMissingCount
}/${episodeFileCount}`;
}
const color = episodeMissingCount === 0 ? "primary" : "warning";
return (
<ProgressBar
className="my-a"
variant={color}
min={0}
max={episodeFileCount}
now={progress}
label={label}
></ProgressBar>
);
},
},
{
accessor: "sonarrSeriesId",
selectHide: true,
Cell: ({ row, externalUpdate }) => (
<ActionBadge
icon={faWrench}
onClick={() => {
externalUpdate && externalUpdate(row, "edit");
}}
></ActionBadge>
),
},
],
[]
);
return (
<BaseItemView
state={series}
name="Series"
updateAction={seriesUpdateInfoAll}
loader={load}
columns={columns as Column<Item.Base>[]}
modify={(form) => SeriesApi.modify(form)}
></BaseItemView>
);
};
export default SeriesView;
|