This commit is contained in:
Infinite
2020-01-20 21:56:23 +01:00
parent 9827647122
commit 244c8ff234
82 changed files with 3729 additions and 2304 deletions

View File

@@ -1,9 +1,9 @@
import React, { useState, useEffect } from "react";
import { Button, Form, ProgressBar } from 'react-bootstrap';
import { Button, Form, ProgressBar } from "react-bootstrap";
import { Link } from "react-router-dom";
import { StashService } from "src/core/StashService";
import { useToast } from 'src/hooks';
import { Modal } from 'src/components/Shared';
import { useToast } from "src/hooks";
import { Modal } from "src/components/Shared";
import { GenerateButton } from "./GenerateButton";
export const SettingsTasksPanel: React.FC = () => {
@@ -22,7 +22,7 @@ export const SettingsTasksPanel: React.FC = () => {
const metadataUpdate = StashService.useMetadataUpdate();
function statusToText(s: string) {
switch(s) {
switch (s) {
case "Idle":
return "Idle";
case "Scan":
@@ -38,7 +38,7 @@ export const SettingsTasksPanel: React.FC = () => {
case "Auto Tag":
return "Auto tagging scenes";
default:
return "Idle"
return "Idle";
}
}
@@ -68,7 +68,9 @@ export const SettingsTasksPanel: React.FC = () => {
function onImport() {
setIsImportAlertOpen(false);
StashService.queryMetadataImport().then(() => { jobStatus.refetch()});
StashService.queryMetadataImport().then(() => {
jobStatus.refetch();
});
}
function renderImportAlert() {
@@ -76,12 +78,12 @@ export const SettingsTasksPanel: React.FC = () => {
<Modal
show={isImportAlertOpen}
icon="trash-alt"
accept={{ text: 'Import', variant: 'danger', onClick: onImport }}
accept={{ text: "Import", variant: "danger", onClick: onImport }}
cancel={{ onClick: () => setIsImportAlertOpen(false) }}
>
<p>
Are you sure you want to import? This will delete the database and re-import from
your exported metadata.
Are you sure you want to import? This will delete the database and
re-import from your exported metadata.
</p>
</Modal>
);
@@ -89,7 +91,9 @@ export const SettingsTasksPanel: React.FC = () => {
function onClean() {
setIsCleanAlertOpen(false);
StashService.queryMetadataClean().then(() => { jobStatus.refetch()});
StashService.queryMetadataClean().then(() => {
jobStatus.refetch();
});
}
function renderCleanAlert() {
@@ -97,13 +101,13 @@ export const SettingsTasksPanel: React.FC = () => {
<Modal
show={isCleanAlertOpen}
icon="trash-alt"
accept={{ text: 'Clean', variant: 'danger', onClick: onClean }}
accept={{ text: "Clean", variant: "danger", onClick: onClean }}
cancel={{ onClick: () => setIsCleanAlertOpen(false) }}
>
<p>
Are you sure you want to Clean?
This will delete db information and generated content
for all scenes that are no longer found in the filesystem.
Are you sure you want to Clean? This will delete db information and
generated content for all scenes that are no longer found in the
filesystem.
</p>
</Modal>
);
@@ -111,7 +115,7 @@ export const SettingsTasksPanel: React.FC = () => {
async function onScan() {
try {
await StashService.queryMetadataScan({useFileMetadata});
await StashService.queryMetadataScan({ useFileMetadata });
Toast.success({ content: "Started scan" });
jobStatus.refetch();
} catch (e) {
@@ -125,7 +129,7 @@ export const SettingsTasksPanel: React.FC = () => {
performers: autoTagPerformers ? wildcard : [],
studios: autoTagStudios ? wildcard : [],
tags: autoTagTags ? wildcard : []
}
};
}
async function onAutoTag() {
@@ -145,7 +149,15 @@ export const SettingsTasksPanel: React.FC = () => {
return (
<Form.Group>
<Button id="stop" variant="danger" onClick={() => StashService.queryStopJob().then(() => jobStatus.refetch())}>Stop</Button>
<Button
id="stop"
variant="danger"
onClick={() =>
StashService.queryStopJob().then(() => jobStatus.refetch())
}
>
Stop
</Button>
</Form.Group>
);
}
@@ -153,11 +165,15 @@ export const SettingsTasksPanel: React.FC = () => {
function renderJobStatus() {
return (
<>
<Form.Group>
<h5>Status: {status}</h5>
{ status !== "Idle" ? <ProgressBar now={progress} label={`${progress}%`} /> : '' }
</Form.Group>
{maybeRenderStop()}
<Form.Group>
<h5>Status: {status}</h5>
{status !== "Idle" ? (
<ProgressBar now={progress} label={`${progress}%`} />
) : (
""
)}
</Form.Group>
{maybeRenderStop()}
</>
);
}
@@ -180,8 +196,12 @@ export const SettingsTasksPanel: React.FC = () => {
label="Set name, date, details from metadata (if present)"
onChange={() => setUseFileMetadata(!useFileMetadata)}
/>
<Button id="scan" type="submit" onClick={() => onScan()}>Scan</Button>
<Form.Text className="text-muted">Scan for new content and add it to the database.</Form.Text>
<Button id="scan" type="submit" onClick={() => onScan()}>
Scan
</Button>
<Form.Text className="text-muted">
Scan for new content and add it to the database.
</Form.Text>
</Form.Group>
<hr />
@@ -204,8 +224,12 @@ export const SettingsTasksPanel: React.FC = () => {
label="Tags"
onChange={() => setAutoTagTags(!autoTagTags)}
/>
<Button id="autoTag" type="submit" onClick={() => onAutoTag()}>Auto Tag</Button>
<Form.Text className="text-muted">Auto-tag content based on filenames.</Form.Text>
<Button id="autoTag" type="submit" onClick={() => onAutoTag()}>
Auto Tag
</Button>
<Form.Text className="text-muted">
Auto-tag content based on filenames.
</Form.Text>
</Form.Group>
<Form.Group>
@@ -219,21 +243,50 @@ export const SettingsTasksPanel: React.FC = () => {
<h4>Generated Content</h4>
<GenerateButton />
<Form.Group>
<Button id="clean" variant="danger" onClick={() => setIsCleanAlertOpen(true)}>Clean</Button>
<Form.Text className="text-muted">Check for missing files and remove them from the database. This is a destructive action.</Form.Text>
<Button
id="clean"
variant="danger"
onClick={() => setIsCleanAlertOpen(true)}
>
Clean
</Button>
<Form.Text className="text-muted">
Check for missing files and remove them from the database. This is a
destructive action.
</Form.Text>
</Form.Group>
<hr />
<h4>Metadata</h4>
<Form.Group>
<Button id="export" type="submit"onClick={() => StashService.queryMetadataExport().then(() => { jobStatus.refetch()})}>Export</Button>
<Form.Text className="text-muted">Export the database content into JSON format.</Form.Text>
<Button
id="export"
type="submit"
onClick={() =>
StashService.queryMetadataExport().then(() => {
jobStatus.refetch();
})
}
>
Export
</Button>
<Form.Text className="text-muted">
Export the database content into JSON format.
</Form.Text>
</Form.Group>
<Form.Group>
<Button id="import" variant="danger" onClick={() => setIsImportAlertOpen(true)}>Import</Button>
<Form.Text className="text-muted">Import from exported JSON. This is a destructive action.</Form.Text>
<Button
id="import"
variant="danger"
onClick={() => setIsImportAlertOpen(true)}
>
Import
</Button>
<Form.Text className="text-muted">
Import from exported JSON. This is a destructive action.
</Form.Text>
</Form.Group>
</>
);