mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-22 14:00:52 +00:00
Move scan and search action to background
This commit is contained in:
parent
03156f2981
commit
9765c5713c
3 changed files with 71 additions and 27 deletions
|
@ -11,7 +11,9 @@ import React, { FunctionComponent, useState } from "react";
|
||||||
import { Alert, Container, Row } from "react-bootstrap";
|
import { Alert, Container, Row } from "react-bootstrap";
|
||||||
import { Helmet } from "react-helmet";
|
import { Helmet } from "react-helmet";
|
||||||
import { Redirect, RouteComponentProps, withRouter } from "react-router-dom";
|
import { Redirect, RouteComponentProps, withRouter } from "react-router-dom";
|
||||||
|
import { dispatchTask } from "../../@modules/task";
|
||||||
import { useIsAnyTaskRunningWithId } from "../../@modules/task/hooks";
|
import { useIsAnyTaskRunningWithId } from "../../@modules/task/hooks";
|
||||||
|
import { createTask } from "../../@modules/task/utilites";
|
||||||
import { useMovieBy, useProfileBy } from "../../@redux/hooks";
|
import { useMovieBy, useProfileBy } from "../../@redux/hooks";
|
||||||
import { MoviesApi, ProvidersApi } from "../../apis";
|
import { MoviesApi, ProvidersApi } from "../../apis";
|
||||||
import {
|
import {
|
||||||
|
@ -83,27 +85,39 @@ const MovieDetailView: FunctionComponent<Props> = ({ match }) => {
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<ContentHeader>
|
<ContentHeader>
|
||||||
<ContentHeader.Group pos="start">
|
<ContentHeader.Group pos="start">
|
||||||
<ContentHeader.AsyncButton
|
<ContentHeader.Button
|
||||||
icon={faSync}
|
icon={faSync}
|
||||||
disabled={hasTask}
|
disabled={hasTask}
|
||||||
promise={() =>
|
onClick={() => {
|
||||||
MoviesApi.action({ action: "scan-disk", radarrid: item.radarrId })
|
const task = createTask(
|
||||||
}
|
item.title,
|
||||||
|
id,
|
||||||
|
MoviesApi.action.bind(MoviesApi),
|
||||||
|
{ action: "scan-disk", radarrid: id }
|
||||||
|
);
|
||||||
|
dispatchTask("Scaning Disk...", [task], "Scaning...");
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Scan Disk
|
Scan Disk
|
||||||
</ContentHeader.AsyncButton>
|
</ContentHeader.Button>
|
||||||
<ContentHeader.AsyncButton
|
<ContentHeader.Button
|
||||||
icon={faSearch}
|
icon={faSearch}
|
||||||
disabled={item.profileId === null || hasTask}
|
disabled={item.profileId === null || hasTask}
|
||||||
promise={() =>
|
onClick={() => {
|
||||||
MoviesApi.action({
|
const task = createTask(
|
||||||
action: "search-missing",
|
item.title,
|
||||||
radarrid: item.radarrId,
|
id,
|
||||||
})
|
MoviesApi.action.bind(MoviesApi),
|
||||||
}
|
{
|
||||||
|
action: "search-missing",
|
||||||
|
radarrid: id,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
dispatchTask("Searching subtitles...", [task], "Searching...");
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Search
|
Search
|
||||||
</ContentHeader.AsyncButton>
|
</ContentHeader.Button>
|
||||||
<ContentHeader.Button
|
<ContentHeader.Button
|
||||||
icon={faUser}
|
icon={faUser}
|
||||||
disabled={item.profileId === null || hasTask}
|
disabled={item.profileId === null || hasTask}
|
||||||
|
|
|
@ -11,7 +11,9 @@ import React, { FunctionComponent, useMemo, useState } from "react";
|
||||||
import { Alert, Container, Row } from "react-bootstrap";
|
import { Alert, Container, Row } from "react-bootstrap";
|
||||||
import { Helmet } from "react-helmet";
|
import { Helmet } from "react-helmet";
|
||||||
import { Redirect, RouteComponentProps, withRouter } from "react-router-dom";
|
import { Redirect, RouteComponentProps, withRouter } from "react-router-dom";
|
||||||
|
import { dispatchTask } from "../../@modules/task";
|
||||||
import { useIsAnyTaskRunningWithId } from "../../@modules/task/hooks";
|
import { useIsAnyTaskRunningWithId } from "../../@modules/task/hooks";
|
||||||
|
import { createTask } from "../../@modules/task/utilites";
|
||||||
import { useEpisodesBy, useProfileBy, useSerieBy } from "../../@redux/hooks";
|
import { useEpisodesBy, useProfileBy, useSerieBy } from "../../@redux/hooks";
|
||||||
import { SeriesApi } from "../../apis";
|
import { SeriesApi } from "../../apis";
|
||||||
import {
|
import {
|
||||||
|
@ -86,20 +88,38 @@ const SeriesEpisodesView: FunctionComponent<Props> = (props) => {
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<ContentHeader>
|
<ContentHeader>
|
||||||
<ContentHeader.Group pos="start">
|
<ContentHeader.Group pos="start">
|
||||||
<ContentHeader.AsyncButton
|
<ContentHeader.Button
|
||||||
icon={faSync}
|
icon={faSync}
|
||||||
disabled={!available || hasTask}
|
disabled={!available || hasTask}
|
||||||
promise={() =>
|
onClick={() => {
|
||||||
SeriesApi.action({ action: "scan-disk", seriesid: id })
|
const task = createTask(
|
||||||
}
|
serie.title,
|
||||||
|
id,
|
||||||
|
SeriesApi.action.bind(SeriesApi),
|
||||||
|
{
|
||||||
|
action: "scan-disk",
|
||||||
|
seriesid: id,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
dispatchTask("Scaning disk...", [task], "Scaning...");
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Scan Disk
|
Scan Disk
|
||||||
</ContentHeader.AsyncButton>
|
</ContentHeader.Button>
|
||||||
<ContentHeader.AsyncButton
|
<ContentHeader.Button
|
||||||
icon={faSearch}
|
icon={faSearch}
|
||||||
promise={() =>
|
onClick={() => {
|
||||||
SeriesApi.action({ action: "search-missing", seriesid: id })
|
const task = createTask(
|
||||||
}
|
serie.title,
|
||||||
|
id,
|
||||||
|
SeriesApi.action.bind(SeriesApi),
|
||||||
|
{
|
||||||
|
action: "search-missing",
|
||||||
|
seriesid: id,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
dispatchTask("Searching subtitles...", [task], "Searching...");
|
||||||
|
}}
|
||||||
disabled={
|
disabled={
|
||||||
serie.episodeFileCount === 0 ||
|
serie.episodeFileCount === 0 ||
|
||||||
serie.profileId === null ||
|
serie.profileId === null ||
|
||||||
|
@ -108,7 +128,7 @@ const SeriesEpisodesView: FunctionComponent<Props> = (props) => {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Search
|
Search
|
||||||
</ContentHeader.AsyncButton>
|
</ContentHeader.Button>
|
||||||
</ContentHeader.Group>
|
</ContentHeader.Group>
|
||||||
<ContentHeader.Group pos="end">
|
<ContentHeader.Group pos="end">
|
||||||
<ContentHeader.Button
|
<ContentHeader.Button
|
||||||
|
|
|
@ -4,6 +4,9 @@ import React from "react";
|
||||||
import { Container, Row } from "react-bootstrap";
|
import { Container, Row } from "react-bootstrap";
|
||||||
import { Helmet } from "react-helmet";
|
import { Helmet } from "react-helmet";
|
||||||
import { Column } from "react-table";
|
import { Column } from "react-table";
|
||||||
|
import { dispatchTask } from "../../@modules/task";
|
||||||
|
import { useIsGroupTaskRunning } from "../../@modules/task/hooks";
|
||||||
|
import { createTask } from "../../@modules/task/utilites";
|
||||||
import { AsyncPageTable, ContentHeader } from "../../components";
|
import { AsyncPageTable, ContentHeader } from "../../components";
|
||||||
|
|
||||||
interface Props<T extends Wanted.Base> {
|
interface Props<T extends Wanted.Base> {
|
||||||
|
@ -14,6 +17,8 @@ interface Props<T extends Wanted.Base> {
|
||||||
searchAll: () => Promise<void>;
|
searchAll: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TaskGroupName = "Searching wanted subtitles...";
|
||||||
|
|
||||||
function GenericWantedView<T extends Wanted.Base>({
|
function GenericWantedView<T extends Wanted.Base>({
|
||||||
type,
|
type,
|
||||||
columns,
|
columns,
|
||||||
|
@ -25,19 +30,24 @@ function GenericWantedView<T extends Wanted.Base>({
|
||||||
|
|
||||||
const dataCount = Object.keys(state.content.entities).length;
|
const dataCount = Object.keys(state.content.entities).length;
|
||||||
|
|
||||||
|
const hasTask = useIsGroupTaskRunning(TaskGroupName);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container fluid>
|
<Container fluid>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<title>Wanted {typeName} - Bazarr</title>
|
<title>Wanted {typeName} - Bazarr</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
<ContentHeader>
|
<ContentHeader>
|
||||||
<ContentHeader.AsyncButton
|
<ContentHeader.Button
|
||||||
disabled={dataCount === 0}
|
disabled={dataCount === 0 || hasTask}
|
||||||
promise={searchAll}
|
onClick={() => {
|
||||||
|
const task = createTask(type, undefined, searchAll);
|
||||||
|
dispatchTask(TaskGroupName, [task], "Searching...");
|
||||||
|
}}
|
||||||
icon={faSearch}
|
icon={faSearch}
|
||||||
>
|
>
|
||||||
Search All
|
Search All
|
||||||
</ContentHeader.AsyncButton>
|
</ContentHeader.Button>
|
||||||
</ContentHeader>
|
</ContentHeader>
|
||||||
<Row>
|
<Row>
|
||||||
<AsyncPageTable
|
<AsyncPageTable
|
||||||
|
|
Loading…
Reference in a new issue