Stuff stuff stuff #44

Merged
PouuleT merged 24 commits from update-node into master 2021-08-30 12:59:08 +00:00
4 changed files with 85 additions and 0 deletions
Showing only changes of commit 26cae1aa1f - Show all commits

View File

@ -0,0 +1,77 @@
import React from "react";
import PropTypes from "prop-types";
import { useSelector } from "react-redux";
import { useHistory } from "react-router-dom";
export const DownloadProgress = ({ imdbId, season, episode }) => {
let history = useHistory();
const torrentGroup = useSelector((state) =>
state.torrents.torrents.get(imdbId)
);
if (!torrentGroup || torrentGroup.length === 0) {
return null;
}
let torrent;
const type = torrentGroup[0].type;
switch (type) {
case "movie":
torrent = torrentGroup[0];
break;
case "episode": {
if (!season || !episode) {
return null;
}
const torrents = torrentGroup.filter(
(torrent) => torrent.episode === episode && torrent.season === season
);
if (torrents.length !== 1) {
return null;
}
torrent = torrents[0];
break;
}
default:
return null;
}
if (!torrent || !torrent.status) {
return null;
}
const progress = Number(torrent.status.percent_done).toFixed(1);
if (progress === 0) {
return null;
}
const handleClick = () => {
history.push("/torrents/list");
};
return (
<div className="w-100 mt-n2 clickable" onClick={handleClick}>
<small className="text text-muted">Downloading...</small>
<div
className="progress"
style={{
height: "0.2rem",
}}
>
<div
className="progress-bar bg-warning"
style={{
width: `${progress}%`,
}}
/>
</div>
</div>
);
};
DownloadProgress.propTypes = {
imdbId: PropTypes.string.isRequired,
season: PropTypes.number,
episode: PropTypes.number,
};

View File

@ -12,6 +12,7 @@ import { Rating } from "../details/rating";
import { ReleaseDate } from "../details/releaseDate"; import { ReleaseDate } from "../details/releaseDate";
import { Runtime } from "../details/runtime"; import { Runtime } from "../details/runtime";
import { Title } from "../details/title"; import { Title } from "../details/title";
import { DownloadProgress } from "../details/downloadProgress";
const ListDetails = (props) => { const ListDetails = (props) => {
if (!props.data || Object.keys(props.data).length === 0) { if (!props.data || Object.keys(props.data).length === 0) {
@ -41,6 +42,7 @@ const ListDetails = (props) => {
subtitles={props.data.subtitles} subtitles={props.data.subtitles}
/> />
</div> </div>
<DownloadProgress imdbId={props.data.imdb_id} />
<TrackingLabel <TrackingLabel
wishlisted={props.data.wishlisted} wishlisted={props.data.wishlisted}
inLibrary={props.data.polochon_url !== ""} inLibrary={props.data.polochon_url !== ""}

View File

@ -20,6 +20,7 @@ import { PolochonMetadata } from "../details/polochon";
import { TrackingLabel } from "../details/tracking"; import { TrackingLabel } from "../details/tracking";
import { Genres } from "../details/genres"; import { Genres } from "../details/genres";
import { Runtime } from "../details/runtime"; import { Runtime } from "../details/runtime";
import { DownloadProgress } from "../details/downloadProgress";
import { DownloadAndStream } from "../buttons/download"; import { DownloadAndStream } from "../buttons/download";
import { ImdbBadge } from "../buttons/imdb"; import { ImdbBadge } from "../buttons/imdb";
@ -122,6 +123,9 @@ export const Header = () => {
subtitles={subtitles} subtitles={subtitles}
/> />
</div> </div>
<div className="card-text mt-2">
<DownloadProgress imdbId={imdbId} />
</div>
<p className="card-text"> <p className="card-text">
<TrackingLabel inLibrary={inLibrary} wishlisted={wishlisted} /> <TrackingLabel inLibrary={inLibrary} wishlisted={wishlisted} />
</p> </p>

View File

@ -11,6 +11,7 @@ import { PolochonMetadata } from "../../details/polochon";
import { ReleaseDate } from "../../details/releaseDate"; import { ReleaseDate } from "../../details/releaseDate";
import { Runtime } from "../../details/runtime"; import { Runtime } from "../../details/runtime";
import { Title } from "../../details/title"; import { Title } from "../../details/title";
import { DownloadProgress } from "../../details/downloadProgress";
import { DownloadAndStream } from "../../buttons/download"; import { DownloadAndStream } from "../../buttons/download";
import { ShowMore } from "../../buttons/showMore"; import { ShowMore } from "../../buttons/showMore";
@ -62,6 +63,7 @@ export const Episode = ({ season, episode }) => {
/> />
<ReleaseDate date={data.aired} /> <ReleaseDate date={data.aired} />
<Runtime runtime={data.runtime} /> <Runtime runtime={data.runtime} />
<DownloadProgress imdbId={imdbId} season={season} episode={episode} />
<Plot plot={data.plot} /> <Plot plot={data.plot} />
<DownloadAndStream <DownloadAndStream
name={prettyEpisodeName(showTitle, season, episode)} name={prettyEpisodeName(showTitle, season, episode)}