mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-03 21:29:59 -05:00
Replacing icon property when icon has been requested.
Creating <APIButton/> which handles success/failure/pending during API calls.
This commit is contained in:
parent
237b429cbf
commit
59c4ab2502
24 changed files with 483 additions and 334 deletions
|
|
@ -3,7 +3,7 @@ import './App.css';
|
||||||
import {NavBar} from "./components/Nav";
|
import {NavBar} from "./components/Nav";
|
||||||
import {createBrowserRouter, createRoutesFromElements, Link, Outlet, Route, RouterProvider} from "react-router-dom";
|
import {createBrowserRouter, createRoutesFromElements, Link, Outlet, Route, RouterProvider} from "react-router-dom";
|
||||||
import {VideosRoute, VideoWrapper} from "./components/Videos";
|
import {VideosRoute, VideoWrapper} from "./components/Videos";
|
||||||
import Admin from "./components/admin/Admin";
|
import AdminRoute from "./components/admin/AdminRoute";
|
||||||
import {Container} from "semantic-ui-react";
|
import {Container} from "semantic-ui-react";
|
||||||
import 'semantic-ui-offline/semantic.min.css';
|
import 'semantic-ui-offline/semantic.min.css';
|
||||||
import {MoreRoute} from "./components/Apps";
|
import {MoreRoute} from "./components/Apps";
|
||||||
|
|
@ -14,8 +14,8 @@ import {StatusProvider} from "./hooks/customHooks";
|
||||||
import {MapRoute} from "./components/Map";
|
import {MapRoute} from "./components/Map";
|
||||||
import {MediaContextProvider, mediaStyles, StatusContext, ThemeContext} from "./contexts/contexts";
|
import {MediaContextProvider, mediaStyles, StatusContext, ThemeContext} from "./contexts/contexts";
|
||||||
import {Header, ThemeProvider} from "./components/Theme";
|
import {Header, ThemeProvider} from "./components/Theme";
|
||||||
import {Dashboard} from "./Dashboard";
|
import {DashboardPage} from "./DashboardPage";
|
||||||
import {Donate} from "./components/Donate";
|
import {DonatePage} from "./components/DonatePage";
|
||||||
import {useEventsInterval} from "./Events";
|
import {useEventsInterval} from "./Events";
|
||||||
import {SemanticToastContainer} from "react-semantic-toasts-2";
|
import {SemanticToastContainer} from "react-semantic-toasts-2";
|
||||||
import {FilePreviewProvider} from "./components/FilePreview";
|
import {FilePreviewProvider} from "./components/FilePreview";
|
||||||
|
|
@ -63,13 +63,13 @@ const router = createBrowserRouter(createRoutesFromElements(<Route
|
||||||
element={<Root/>}
|
element={<Root/>}
|
||||||
errorElement={<PageNotFound/>}
|
errorElement={<PageNotFound/>}
|
||||||
>
|
>
|
||||||
<Route index element={<Dashboard/>}/>
|
<Route index element={<DashboardPage/>}/>
|
||||||
<Route path='search/*' element={<Dashboard/>}/>
|
<Route path='search/*' element={<DashboardPage/>}/>
|
||||||
<Route path='donate' element={<Donate/>}/>
|
<Route path='donate' element={<DonatePage/>}/>
|
||||||
<Route path='videos/video/:videoId' exact element={<VideoWrapper/>}/>
|
<Route path='videos/video/:videoId' exact element={<VideoWrapper/>}/>
|
||||||
<Route path='videos/channel/:channelId/video/:videoId' exact element={<VideoWrapper/>}/>
|
<Route path='videos/channel/:channelId/video/:videoId' exact element={<VideoWrapper/>}/>
|
||||||
<Route path="videos/*" element={<VideosRoute/>}/>
|
<Route path="videos/*" element={<VideosRoute/>}/>
|
||||||
<Route path="admin/*" element={<Admin/>}/>
|
<Route path="admin/*" element={<AdminRoute/>}/>
|
||||||
<Route path="more/*" element={<MoreRoute/>}/>
|
<Route path="more/*" element={<MoreRoute/>}/>
|
||||||
<Route path="inventory/*" element={<InventoryRoute/>}/>
|
<Route path="inventory/*" element={<InventoryRoute/>}/>
|
||||||
<Route path='archive/*' element={<ArchiveRoute/>}/>
|
<Route path='archive/*' element={<ArchiveRoute/>}/>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import {TagsDashboard} from "./Tags";
|
||||||
import {Upload} from "./components/Upload";
|
import {Upload} from "./components/Upload";
|
||||||
import {SearchView, useSearch} from "./components/Search";
|
import {SearchView, useSearch} from "./components/Search";
|
||||||
import {KiwixRestartMessage, OutdatedZimsMessage} from "./components/Zim";
|
import {KiwixRestartMessage, OutdatedZimsMessage} from "./components/Zim";
|
||||||
import {useSettings} from "./hooks/customHooks";
|
import {useSettings, useWROLMode} from "./hooks/customHooks";
|
||||||
|
|
||||||
function FlagsMessages({flags}) {
|
function FlagsMessages({flags}) {
|
||||||
const {settings, fetchSettings} = useSettings();
|
const {settings, fetchSettings} = useSettings();
|
||||||
|
|
@ -82,13 +82,14 @@ function FlagsMessages({flags}) {
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Dashboard() {
|
export function DashboardPage() {
|
||||||
useTitle('Dashboard');
|
useTitle('Dashboard');
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const {searchStr, setSearchStr, activeTags} = useSearch();
|
const {searchStr, setSearchStr, activeTags} = useSearch();
|
||||||
const {status} = useContext(StatusContext);
|
const {status} = useContext(StatusContext);
|
||||||
const navigate = useNavigate();
|
const wrolModeEnabled = useWROLMode();
|
||||||
const wrol_mode = status ? status['wrol_mode'] : null;
|
|
||||||
|
|
||||||
// Getters are Downloads or Uploads.
|
// Getters are Downloads or Uploads.
|
||||||
const [selectedGetter, setSelectedGetter] = useState(null);
|
const [selectedGetter, setSelectedGetter] = useState(null);
|
||||||
|
|
@ -150,7 +151,7 @@ export function Dashboard() {
|
||||||
body = <SearchView/>;
|
body = <SearchView/>;
|
||||||
} else {
|
} else {
|
||||||
body = <>
|
body = <>
|
||||||
{!wrol_mode && getter}
|
{!wrolModeEnabled && getter}
|
||||||
{getterModal}
|
{getterModal}
|
||||||
<TagsDashboard/>
|
<TagsDashboard/>
|
||||||
<DashboardStatus/>
|
<DashboardStatus/>
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import React, {useEffect, useState} from "react";
|
import React, {useEffect} from "react";
|
||||||
import {deleteTag, getTags, saveTag} from "./api";
|
import {deleteTag, getTags, saveTag} from "./api";
|
||||||
import {
|
import {
|
||||||
Confirm,
|
|
||||||
Dimmer,
|
Dimmer,
|
||||||
Divider,
|
Divider,
|
||||||
Dropdown,
|
|
||||||
Form,
|
Form,
|
||||||
Grid,
|
Grid,
|
||||||
Label,
|
Label,
|
||||||
|
|
@ -15,7 +13,7 @@ import {
|
||||||
TableHeaderCell,
|
TableHeaderCell,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import {contrastingColor, scrollToTopOfElement} from "./components/Common";
|
import {APIButton, contrastingColor, scrollToTopOfElement} from "./components/Common";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
FormInput,
|
FormInput,
|
||||||
|
|
@ -150,18 +148,15 @@ export const useTagsInterval = () => {
|
||||||
|
|
||||||
function EditTagRow({tag, onDelete, onEdit}) {
|
function EditTagRow({tag, onDelete, onEdit}) {
|
||||||
const {NameToTagLabel} = React.useContext(TagsContext);
|
const {NameToTagLabel} = React.useContext(TagsContext);
|
||||||
const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);
|
|
||||||
const {name, color, id, count} = tag;
|
const {name, color, id, count} = tag;
|
||||||
|
|
||||||
const deleteConfirm = <>
|
const deleteConfirm = <>
|
||||||
<Button color='red' onClick={() => setConfirmDeleteOpen(true)} icon='trash'/>
|
<APIButton
|
||||||
<Confirm
|
icon='trash'
|
||||||
id={`confirm${name}`}
|
color='red'
|
||||||
open={confirmDeleteOpen}
|
confirmContent={`Are you sure you want to delete: ${name}?`}
|
||||||
content={`Are you sure you want to delete: ${name}?`}
|
|
||||||
confirmButton='Delete'
|
confirmButton='Delete'
|
||||||
onCancel={() => setConfirmDeleteOpen(false)}
|
onClick={async () => onDelete(id, name)}
|
||||||
onConfirm={async () => onDelete(id, name)}
|
|
||||||
/>
|
/>
|
||||||
</>;
|
</>;
|
||||||
const editButton = <Button primary onClick={() => onEdit(name, color, id)} icon='edit'/>;
|
const editButton = <Button primary onClick={() => onEdit(name, color, id)} icon='edit'/>;
|
||||||
|
|
@ -259,14 +254,13 @@ function EditTagsModal() {
|
||||||
|
|
||||||
<HexColorPicker color={tagColor} onChange={setTagColor} style={{marginTop: '1em'}}/>
|
<HexColorPicker color={tagColor} onChange={setTagColor} style={{marginTop: '1em'}}/>
|
||||||
|
|
||||||
<Button color='violet'
|
<APIButton
|
||||||
size='big'
|
color='violet'
|
||||||
onClick={localSaveTag}
|
size='big'
|
||||||
style={{marginTop: '2em'}}
|
onClick={localSaveTag}
|
||||||
disabled={!!!tagName}
|
style={{marginTop: '2em'}}
|
||||||
>
|
disabled={!!!tagName}
|
||||||
Save
|
>Save</APIButton>
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Divider/>
|
<Divider/>
|
||||||
<Table striped basic='very' unstackable>
|
<Table striped basic='very' unstackable>
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,13 @@ export async function createChannel(channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteChannel(channelId) {
|
export async function deleteChannel(channelId) {
|
||||||
return apiDelete(`${VIDEOS_API}/channels/${channelId}`);
|
const response = await apiDelete(`${VIDEOS_API}/channels/${channelId}`);
|
||||||
|
if (response.status !== 204) {
|
||||||
|
const content = await response.json();
|
||||||
|
console.error(content);
|
||||||
|
throw Error(content);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getChannels() {
|
export async function getChannels() {
|
||||||
|
|
@ -155,16 +161,13 @@ export async function deleteVideos(videoIds) {
|
||||||
time: 5000,
|
time: 5000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.debug(`Deleting Videos: ${videoIds}`);
|
console.info(`Deleting Videos: ${videoIds}`);
|
||||||
const i = videoIds.join(',');
|
const i = videoIds.join(',');
|
||||||
let response = await apiDelete(`${VIDEOS_API}/video/${i}`);
|
let response = await apiDelete(`${VIDEOS_API}/video/${i}`);
|
||||||
if (response.status !== 204) {
|
if (response.status !== 204) {
|
||||||
toast({
|
const content = response.json();
|
||||||
type: 'error',
|
console.error(content);
|
||||||
title: 'Unexpected server response',
|
throw Error(content);
|
||||||
description: 'Failed to delete videos. See server logs.',
|
|
||||||
time: 5000,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,7 +252,7 @@ export async function downloadChannel(channelId) {
|
||||||
|
|
||||||
export async function refreshChannel(channelId) {
|
export async function refreshChannel(channelId) {
|
||||||
let url = `${VIDEOS_API}/channels/refresh/${channelId}`;
|
let url = `${VIDEOS_API}/channels/refresh/${channelId}`;
|
||||||
await fetch(url, {method: 'POST'});
|
return await fetch(url, {method: 'POST'});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function encryptOTP(otp, plaintext) {
|
export async function encryptOTP(otp, plaintext) {
|
||||||
|
|
@ -361,15 +364,13 @@ export async function deleteArchives(archiveIds) {
|
||||||
time: 5000,
|
time: 5000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.debug(`Deleting Archives: ${archiveIds}`);
|
console.log(`Deleting Archives: ${archiveIds}`);
|
||||||
let i = archiveIds.join(',');
|
let i = archiveIds.join(',');
|
||||||
try {
|
const response = await apiDelete(`${API_URI}/archive/${i}`);
|
||||||
return await apiDelete(`${API_URI}/archive/${i}`);
|
if (response.status !== 204) {
|
||||||
} catch (e) {
|
const content = await response.json();
|
||||||
console.error(e);
|
console.debug(content);
|
||||||
toast({
|
throw Error(content['error']);
|
||||||
type: 'error', title: 'Unexpected server response', description: 'Unable to delete archives', time: 5000,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -462,7 +463,11 @@ export async function postDownload(urls, downloader, frequency, sub_downloader,
|
||||||
body['tag_names'] = tagNames;
|
body['tag_names'] = tagNames;
|
||||||
}
|
}
|
||||||
let response = await apiPost(`${API_URI}/download`, body);
|
let response = await apiPost(`${API_URI}/download`, body);
|
||||||
return response;
|
if (response.status !== 204) {
|
||||||
|
const content = await response.json();
|
||||||
|
console.error(content);
|
||||||
|
throw Error(content['error']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function killDownload(download_id) {
|
export async function killDownload(download_id) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, {useContext} from 'react';
|
||||||
import {Divider, Input, SegmentGroup, StatisticLabel, StatisticValue, TableCell, TableRow} from "semantic-ui-react";
|
import {Divider, Input, SegmentGroup, StatisticLabel, StatisticValue, TableCell, TableRow} from "semantic-ui-react";
|
||||||
import {Link, Route, Routes} from "react-router-dom";
|
import {Link, Route, Routes} from "react-router-dom";
|
||||||
import {decryptOTP, encryptOTP} from "../api";
|
import {decryptOTP, encryptOTP} from "../api";
|
||||||
import {humanFileSize, mimetypeColor, PageContainer, toLocaleString, useTitle} from "./Common";
|
import {APIButton, humanFileSize, mimetypeColor, PageContainer, toLocaleString, useTitle} from "./Common";
|
||||||
import {ThemeContext} from "../contexts/contexts";
|
import {ThemeContext} from "../contexts/contexts";
|
||||||
import {Button, Header, Loader, Segment, Statistic, StatisticGroup, Table, TextArea} from "./Theme";
|
import {Button, Header, Loader, Segment, Statistic, StatisticGroup, Table, TextArea} from "./Theme";
|
||||||
import {useStatistics, useVINDecoder} from "../hooks/customHooks";
|
import {useStatistics, useVINDecoder} from "../hooks/customHooks";
|
||||||
|
|
@ -15,14 +15,9 @@ class Encrypt extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit = async (e) => {
|
handleSubmit = async () => {
|
||||||
e.preventDefault();
|
let {otp, plaintext, ciphertext} = await encryptOTP(this.state.otp, this.state.plaintext);
|
||||||
try {
|
this.setState({otp, plaintext, ciphertext});
|
||||||
let {otp, plaintext, ciphertext} = await encryptOTP(this.state.otp, this.state.plaintext);
|
|
||||||
this.setState({otp, plaintext, ciphertext});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleInputChange = async (event, {name, value}) => {
|
handleInputChange = async (event, {name, value}) => {
|
||||||
|
|
@ -30,6 +25,8 @@ class Encrypt extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const disabled = !(this.state.otp && this.state.plaintext);
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Header as='h2'>Encrypt</Header>
|
<Header as='h2'>Encrypt</Header>
|
||||||
<SegmentGroup>
|
<SegmentGroup>
|
||||||
|
|
@ -59,7 +56,10 @@ class Encrypt extends React.Component {
|
||||||
</Segment>
|
</Segment>
|
||||||
</SegmentGroup>
|
</SegmentGroup>
|
||||||
<br/>
|
<br/>
|
||||||
<Button color='violet' onClick={this.handleSubmit}>Encrypt</Button>
|
<APIButton
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={this.handleSubmit}
|
||||||
|
>Encrypt</APIButton>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,18 +68,13 @@ class Decrypt extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
otp: '', plaintext: '', ciphertext: '',
|
otp: '', plaintext: '', ciphertext: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit = async (e) => {
|
handleSubmit = async () => {
|
||||||
e.preventDefault();
|
let {otp, plaintext, ciphertext} = await decryptOTP(this.state.otp, this.state.ciphertext);
|
||||||
try {
|
this.setState({otp, plaintext, ciphertext});
|
||||||
let {otp, plaintext, ciphertext} = await decryptOTP(this.state.otp, this.state.ciphertext);
|
|
||||||
this.setState({otp, plaintext, ciphertext});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleInputChange = async (event, {name, value}) => {
|
handleInputChange = async (event, {name, value}) => {
|
||||||
|
|
@ -87,6 +82,8 @@ class Decrypt extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const disabled = !(this.state.otp && this.state.ciphertext);
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Header as='h2'>Decrypt</Header>
|
<Header as='h2'>Decrypt</Header>
|
||||||
<SegmentGroup>
|
<SegmentGroup>
|
||||||
|
|
@ -115,8 +112,13 @@ class Decrypt extends React.Component {
|
||||||
<pre>{this.state.plaintext || 'Enter the encrypted message above'}</pre>
|
<pre>{this.state.plaintext || 'Enter the encrypted message above'}</pre>
|
||||||
</Segment>
|
</Segment>
|
||||||
</SegmentGroup>
|
</SegmentGroup>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<Button color='violet' onClick={this.handleSubmit}>Decrypt</Button>
|
|
||||||
|
<APIButton
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={this.handleSubmit}
|
||||||
|
>Decrypt</APIButton>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import {
|
||||||
TableRow
|
TableRow
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import {
|
import {
|
||||||
|
APIButton,
|
||||||
BackButton,
|
BackButton,
|
||||||
CardLink,
|
CardLink,
|
||||||
cardTitleWrapper,
|
cardTitleWrapper,
|
||||||
|
|
@ -45,10 +46,9 @@ import {Media, ThemeContext} from "../contexts/contexts";
|
||||||
import {Button, Card, CardIcon, Header, Loader, Placeholder, Segment} from "./Theme";
|
import {Button, Card, CardIcon, Header, Loader, Placeholder, Segment} from "./Theme";
|
||||||
import {SortableTable} from "./SortableTable";
|
import {SortableTable} from "./SortableTable";
|
||||||
import {taggedImageLabel, TagsSelector} from "../Tags";
|
import {taggedImageLabel, TagsSelector} from "../Tags";
|
||||||
|
import {toast} from "react-semantic-toasts-2";
|
||||||
|
|
||||||
function ArchivePage() {
|
function ArchivePage() {
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
||||||
const [updateOpen, setUpdateOpen] = useState(false);
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const {archiveId} = useParams();
|
const {archiveId} = useParams();
|
||||||
const {archiveFile, history, fetchArchive} = useArchive(archiveId);
|
const {archiveFile, history, fetchArchive} = useArchive(archiveId);
|
||||||
|
|
@ -88,35 +88,41 @@ function ArchivePage() {
|
||||||
null;
|
null;
|
||||||
|
|
||||||
const localDeleteArchive = async () => {
|
const localDeleteArchive = async () => {
|
||||||
setDeleteOpen(false);
|
|
||||||
await deleteArchives([data.id]);
|
await deleteArchives([data.id]);
|
||||||
|
toast({
|
||||||
|
type: 'success',
|
||||||
|
title: 'Archive Deleted',
|
||||||
|
description: 'Archive was successfully deleted.',
|
||||||
|
time: 2000,
|
||||||
|
})
|
||||||
navigate(-1);
|
navigate(-1);
|
||||||
}
|
}
|
||||||
const localUpdateArchive = async () => {
|
const localUpdateArchive = async () => {
|
||||||
setUpdateOpen(false);
|
|
||||||
await postDownload(data.url, 'archive');
|
await postDownload(data.url, 'archive');
|
||||||
|
toast({
|
||||||
|
type: 'success',
|
||||||
|
title: 'Archive Downloading',
|
||||||
|
description: 'Archive update has been scheduled.',
|
||||||
|
time: 2000,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateButton = (<>
|
const updateButton = <APIButton
|
||||||
<Button color='green' onClick={() => setUpdateOpen(true)} content='Update'/>
|
text='Update'
|
||||||
<Confirm
|
color='green'
|
||||||
open={updateOpen}
|
confirmContent='Download the latest version of this URL?'
|
||||||
content='Download the latest version of this URL?'
|
confirmButton='Update'
|
||||||
confirmButton='Update'
|
onClick={localUpdateArchive}
|
||||||
onCancel={() => setUpdateOpen(false)}
|
obeyWROLMode={true}
|
||||||
onConfirm={localUpdateArchive}
|
>Update</APIButton>;
|
||||||
/>
|
const deleteButton = <APIButton
|
||||||
</>);
|
text='Delete'
|
||||||
const deleteButton = (<>
|
color='red'
|
||||||
<Button color='red' onClick={() => setDeleteOpen(true)} content='Delete' aria-label='Delete'/>
|
confirmContent='Are you sure you want to delete this archive? All files will be deleted'
|
||||||
<Confirm
|
confirmButton='Delete'
|
||||||
open={deleteOpen}
|
onClick={localDeleteArchive}
|
||||||
content='Are you sure you want to delete this archive? All files will be deleted'
|
obeyWROLMode={true}
|
||||||
confirmButton='Delete'
|
>Delete</APIButton>;
|
||||||
onCancel={() => setDeleteOpen(false)}
|
|
||||||
onConfirm={localDeleteArchive}
|
|
||||||
/>
|
|
||||||
</>);
|
|
||||||
|
|
||||||
let historyList = <Loader active/>;
|
let historyList = <Loader active/>;
|
||||||
if (history && history.length === 0) {
|
if (history && history.length === 0) {
|
||||||
|
|
@ -323,7 +329,7 @@ export function SearchDomain() {
|
||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
|
|
||||||
function Archives() {
|
function ArchivesPage() {
|
||||||
const [selectedArchives, setSelectedArchives] = useState([]);
|
const [selectedArchives, setSelectedArchives] = useState([]);
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
|
|
||||||
|
|
@ -497,7 +503,7 @@ export function ArchiveRoute() {
|
||||||
return <PageContainer>
|
return <PageContainer>
|
||||||
<TabLinks links={links}/>
|
<TabLinks links={links}/>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path='/' element={<Archives/>}/>
|
<Route path='/' element={<ArchivesPage/>}/>
|
||||||
<Route path='domains' element={<DomainsPage/>}/>
|
<Route path='domains' element={<DomainsPage/>}/>
|
||||||
<Route path=':archiveId' element={<ArchivePage/>}/>
|
<Route path=':archiveId' element={<ArchivePage/>}/>
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import {
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import {createChannel, deleteChannel, downloadChannel, refreshChannel, updateChannel, validateRegex} from "../api";
|
import {createChannel, deleteChannel, downloadChannel, refreshChannel, updateChannel, validateRegex} from "../api";
|
||||||
import {
|
import {
|
||||||
|
APIButton,
|
||||||
BackButton,
|
BackButton,
|
||||||
DirectoryInput,
|
DirectoryInput,
|
||||||
frequencyOptions,
|
frequencyOptions,
|
||||||
|
|
@ -26,7 +27,6 @@ import {
|
||||||
} from "./Common";
|
} from "./Common";
|
||||||
import {Link, useNavigate, useParams} from "react-router-dom";
|
import {Link, useNavigate, useParams} from "react-router-dom";
|
||||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||||
import Confirm from "semantic-ui-react/dist/commonjs/addons/Confirm";
|
|
||||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||||
import {useChannel, useChannels} from "../hooks/customHooks";
|
import {useChannel, useChannels} from "../hooks/customHooks";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
|
@ -75,7 +75,6 @@ function ChannelStatistics({statistics}) {
|
||||||
|
|
||||||
function ChannelPage({create, header}) {
|
function ChannelPage({create, header}) {
|
||||||
const [disabled, setDisabled] = useState(false);
|
const [disabled, setDisabled] = useState(false);
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
||||||
const [validRegex, setValidRegex] = useState(true);
|
const [validRegex, setValidRegex] = useState(true);
|
||||||
const [activeIndex, setActiveIndex] = useState(-1);
|
const [activeIndex, setActiveIndex] = useState(-1);
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
|
|
@ -133,7 +132,9 @@ function ChannelPage({create, header}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
const body = {
|
const body = {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
directory: channel.directory,
|
directory: channel.directory,
|
||||||
|
|
@ -180,7 +181,11 @@ function ChannelPage({create, header}) {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await fetchChannel();
|
await fetchChannel();
|
||||||
setSuccessMessage('Channel updated', 'Your channel was updated');
|
toast({
|
||||||
|
type: 'success',
|
||||||
|
title: 'Channel updated',
|
||||||
|
description: 'The channel was updated',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (response) {
|
} else if (response) {
|
||||||
|
|
@ -218,7 +223,9 @@ function ChannelPage({create, header}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDownloadChannel = async (e) => {
|
const handleDownloadChannel = async (e) => {
|
||||||
e.preventDefault();
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const response = await downloadChannel(channelId);
|
const response = await downloadChannel(channelId);
|
||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
|
|
@ -235,23 +242,29 @@ function ChannelPage({create, header}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRefreshChannel = async (e) => {
|
const handleRefreshChannel = async (e) => {
|
||||||
e.preventDefault();
|
if (e) {
|
||||||
return await refreshChannel(channelId);
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
const response = await refreshChannel(channelId);
|
||||||
const handleDeleteConfirm = async () => {
|
if (response.status !== 204) {
|
||||||
setDeleteOpen(false);
|
toast({
|
||||||
let response = await deleteChannel(channelId);
|
type: 'error',
|
||||||
if (response.status === 204) {
|
title: 'Failed to refresh',
|
||||||
navigate('/videos/channel');
|
description: "Failed to refresh this channel's directory",
|
||||||
} else {
|
time: 5000,
|
||||||
setSuccessMessage('Failed to delete', 'Failed to delete this channel, check logs.');
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDeleteButton = (e) => {
|
const handleDelete = async () => {
|
||||||
e.preventDefault();
|
try {
|
||||||
setDeleteOpen(true);
|
let response = await deleteChannel(channelId);
|
||||||
|
if (response.status === 204) {
|
||||||
|
navigate('/videos/channel');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
setErrorMessage('Failed to delete', 'Failed to delete this channel, check logs.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
|
|
@ -266,7 +279,6 @@ function ChannelPage({create, header}) {
|
||||||
<WROLModeMessage content='Channel page is disabled while WROL Mode is enabled.'/>
|
<WROLModeMessage content='Channel page is disabled while WROL Mode is enabled.'/>
|
||||||
<Form
|
<Form
|
||||||
id="editChannel"
|
id="editChannel"
|
||||||
onSubmit={handleSubmit}
|
|
||||||
error={error}
|
error={error}
|
||||||
success={success}
|
success={success}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
|
|
@ -391,39 +403,39 @@ function ChannelPage({create, header}) {
|
||||||
<Grid.Column>
|
<Grid.Column>
|
||||||
{!create &&
|
{!create &&
|
||||||
<>
|
<>
|
||||||
<Button color='red' onClick={handleDeleteButton} size='small'>
|
<APIButton
|
||||||
Delete
|
color='red'
|
||||||
</Button>
|
size='small'
|
||||||
<Confirm
|
confirmContent='Are you sure you want to delete this channel? No video files will be deleted.'
|
||||||
open={deleteOpen}
|
|
||||||
content='Are you sure you want to delete this channel? No video files will be deleted.'
|
|
||||||
confirmButton='Delete'
|
confirmButton='Delete'
|
||||||
onCancel={() => setDeleteOpen(false)}
|
onClick={handleDelete}
|
||||||
onConfirm={handleDeleteConfirm}
|
obeyWROLMode={true}
|
||||||
/>
|
>Delete</APIButton>
|
||||||
<Button
|
<APIButton
|
||||||
color='green'
|
color='green'
|
||||||
size='small'
|
size='small'
|
||||||
onClick={handleDownloadChannel}
|
onClick={handleDownloadChannel}
|
||||||
disabled={!channel.url || !channel.download_frequency}
|
disabled={!channel.url || !channel.download_frequency}
|
||||||
>
|
obeyWROLMode={true}
|
||||||
Download
|
>Download</APIButton>
|
||||||
</Button>
|
<APIButton
|
||||||
<Button color='blue' size='small' onClick={handleRefreshChannel}>
|
color='blue'
|
||||||
Refresh
|
size='small'
|
||||||
</Button>
|
onClick={handleRefreshChannel}
|
||||||
|
obeyWROLMode={true}
|
||||||
|
>Refresh</APIButton>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
<Grid.Column>
|
<Grid.Column>
|
||||||
<Button
|
<APIButton
|
||||||
color='violet'
|
color='violet'
|
||||||
size='big'
|
size='big'
|
||||||
type="submit"
|
|
||||||
floated='right'
|
floated='right'
|
||||||
>
|
onClick={handleSubmit}
|
||||||
{disabled ? <Loader active inline/> : 'Save'}
|
disabled={disabled}
|
||||||
</Button>
|
obeyWROLMode={true}
|
||||||
|
>Save</APIButton>
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,17 @@
|
||||||
import React, {useContext, useEffect, useState} from "react";
|
import React, {useContext, useEffect, useState} from "react";
|
||||||
import {ButtonGroup, Card, Container, IconGroup, Input, Label, Pagination, Search} from 'semantic-ui-react';
|
import {
|
||||||
|
Button as SButton,
|
||||||
|
ButtonGroup,
|
||||||
|
Card,
|
||||||
|
Confirm,
|
||||||
|
Container,
|
||||||
|
IconGroup,
|
||||||
|
Input,
|
||||||
|
Label,
|
||||||
|
Pagination,
|
||||||
|
Search,
|
||||||
|
Transition
|
||||||
|
} from 'semantic-ui-react';
|
||||||
import {Link, NavLink, useNavigate, useSearchParams} from "react-router-dom";
|
import {Link, NavLink, useNavigate, useSearchParams} from "react-router-dom";
|
||||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||||
import {
|
import {
|
||||||
|
|
@ -8,7 +20,8 @@ import {
|
||||||
useSearchDirectories,
|
useSearchDirectories,
|
||||||
useSearchOrder,
|
useSearchOrder,
|
||||||
useSettings,
|
useSettings,
|
||||||
useThrottle
|
useThrottle,
|
||||||
|
useWROLMode
|
||||||
} from "../hooks/customHooks";
|
} from "../hooks/customHooks";
|
||||||
import {Media, StatusContext, ThemeContext} from "../contexts/contexts";
|
import {Media, StatusContext, ThemeContext} from "../contexts/contexts";
|
||||||
import {
|
import {
|
||||||
|
|
@ -419,10 +432,9 @@ export function SearchInput({
|
||||||
}
|
}
|
||||||
|
|
||||||
export function WROLModeMessage({content}) {
|
export function WROLModeMessage({content}) {
|
||||||
const {status} = useContext(StatusContext);
|
const wrolModeEnabled = useWROLMode();
|
||||||
const wrol_mode = status ? status.wrol_mode : null;
|
|
||||||
|
|
||||||
if (wrol_mode) {
|
if (wrolModeEnabled) {
|
||||||
return <Message icon='lock' header='WROL Mode Enabled' content={content}/>
|
return <Message icon='lock' header='WROL Mode Enabled' content={content}/>
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -674,6 +686,7 @@ export function DisableDownloadsToggle() {
|
||||||
const {status, fetchStatus} = React.useContext(StatusContext);
|
const {status, fetchStatus} = React.useContext(StatusContext);
|
||||||
|
|
||||||
const {downloads} = status ? status : {downloads: null};
|
const {downloads} = status ? status : {downloads: null};
|
||||||
|
const wrolModeEnabled = useWROLMode();
|
||||||
|
|
||||||
const setDownloads = async (enable) => {
|
const setDownloads = async (enable) => {
|
||||||
setPending(true);
|
setPending(true);
|
||||||
|
|
@ -690,7 +703,7 @@ export function DisableDownloadsToggle() {
|
||||||
return <Form>
|
return <Form>
|
||||||
<Toggle
|
<Toggle
|
||||||
label={on === true ? 'Downloading Enabled' : 'Downloading Disabled'}
|
label={on === true ? 'Downloading Enabled' : 'Downloading Disabled'}
|
||||||
disabled={pending || downloads === null}
|
disabled={wrolModeEnabled || pending || downloads === null}
|
||||||
checked={on === true}
|
checked={on === true}
|
||||||
onChange={setDownloads}
|
onChange={setDownloads}
|
||||||
/>
|
/>
|
||||||
|
|
@ -1190,4 +1203,166 @@ export function TagIcon() {
|
||||||
|
|
||||||
export function normalizeEstimate(estimate) {
|
export function normalizeEstimate(estimate) {
|
||||||
return estimate > 999 ? '>999' : estimate;
|
return estimate > 999 ? '>999' : estimate;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAPIButton(
|
||||||
|
color = 'violet',
|
||||||
|
size = 'medium',
|
||||||
|
floated,
|
||||||
|
onClick,
|
||||||
|
disabled,
|
||||||
|
confirmContent,
|
||||||
|
confirmButton,
|
||||||
|
themed = true,
|
||||||
|
obeyWROLMode = false,
|
||||||
|
icon = null,
|
||||||
|
props
|
||||||
|
) {
|
||||||
|
props = props || {};
|
||||||
|
const ref = React.useRef();
|
||||||
|
|
||||||
|
const [confirmOpen, setConfirmOpen] = React.useState(false);
|
||||||
|
const [pending, setPending] = React.useState(false);
|
||||||
|
const [animation, setAnimation] = React.useState('jiggle');
|
||||||
|
const [animationVisible, setAnimationVisible] = React.useState(true);
|
||||||
|
const [showSuccess, setShowSuccess] = React.useState(false);
|
||||||
|
const [showFailure, setShowFailure] = React.useState(false);
|
||||||
|
|
||||||
|
const wrolModeEnabled = useWROLMode();
|
||||||
|
|
||||||
|
// Disable when API call is pending, or button is disabled.
|
||||||
|
disabled = pending || disabled;
|
||||||
|
// Disable when WROL Mode is enabled, otherwise normal disabled.
|
||||||
|
disabled = obeyWROLMode ? wrolModeEnabled || disabled : disabled;
|
||||||
|
|
||||||
|
const reset = () => {
|
||||||
|
setShowSuccess(false);
|
||||||
|
setShowFailure(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const setSuccess = () => {
|
||||||
|
setShowSuccess(true);
|
||||||
|
setAnimation('pulse');
|
||||||
|
setAnimationVisible(!animationVisible);
|
||||||
|
setTimeout(reset, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
const setFailure = () => {
|
||||||
|
setShowFailure(true);
|
||||||
|
setAnimation('shake');
|
||||||
|
setAnimationVisible(!animationVisible);
|
||||||
|
setTimeout(reset, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleAPICall = async () => {
|
||||||
|
// Handle when user clicks button, or clicks confirm.
|
||||||
|
setPending(true);
|
||||||
|
try {
|
||||||
|
await onClick();
|
||||||
|
setSuccess();
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
setFailure();
|
||||||
|
}
|
||||||
|
setPending(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const localOnClick = async (e) => {
|
||||||
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (confirmContent) {
|
||||||
|
// Clicking button opens confirm.
|
||||||
|
setConfirmOpen(true);
|
||||||
|
} else if (onClick) {
|
||||||
|
// No <Confirm/> send the API request.
|
||||||
|
await handleAPICall();
|
||||||
|
} else {
|
||||||
|
throw Error('No onClick defined!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const localOnConfirm = async () => {
|
||||||
|
// User clicked the "OK" button in the <Confirm/>.
|
||||||
|
setConfirmOpen(false);
|
||||||
|
|
||||||
|
if (onClick) {
|
||||||
|
await handleAPICall();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create button with or without theme. Pass all props to the <Button/> (except props.children).
|
||||||
|
const buttonArgs = {color, onClick: localOnClick, disabled, loading: pending, size, floated, ...props};
|
||||||
|
|
||||||
|
let buttonContent = <>{props.children}</>;
|
||||||
|
if (icon) {
|
||||||
|
// Send Icon as Button properties.
|
||||||
|
buttonContent = null;
|
||||||
|
buttonArgs['icon'] = showSuccess ? 'check' : showFailure ? 'close' : icon;
|
||||||
|
} else if (showSuccess || showFailure) {
|
||||||
|
// Show ✔ or ✖ overtop the contents after API call has completed.
|
||||||
|
buttonContent = <>
|
||||||
|
<Icon style={{position: 'absolute'}} name={showSuccess ? 'check' : 'close'}/>
|
||||||
|
{/* Keep contents to avoid resizing button */}
|
||||||
|
<div style={{opacity: 0}}>{buttonContent}</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
|
let button = themed ?
|
||||||
|
<Button ref={ref} {...buttonArgs}>{buttonContent}</Button>
|
||||||
|
: <SButton ref={ref} {...buttonArgs}>{buttonContent}</SButton>;
|
||||||
|
// Wrap button in <Transition/> to show success or failure animations.
|
||||||
|
button = <Transition animation={animation} duration={500} visible={animationVisible}>
|
||||||
|
{button}
|
||||||
|
</Transition>;
|
||||||
|
|
||||||
|
if (confirmContent) {
|
||||||
|
// Wrap button with <Confirm/>
|
||||||
|
button = <>
|
||||||
|
{button}
|
||||||
|
<Confirm open={confirmOpen}
|
||||||
|
content={confirmContent}
|
||||||
|
onClose={() => setConfirmOpen(false)}
|
||||||
|
onCancel={() => setConfirmOpen(false)}
|
||||||
|
onConfirm={localOnConfirm}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
|
button = <>
|
||||||
|
{button}
|
||||||
|
</>
|
||||||
|
|
||||||
|
return {button, ref}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function APIButton({
|
||||||
|
color,
|
||||||
|
size,
|
||||||
|
floated,
|
||||||
|
onClick,
|
||||||
|
disabled,
|
||||||
|
confirmContent,
|
||||||
|
confirmButton,
|
||||||
|
themed,
|
||||||
|
obeyWROLMode,
|
||||||
|
icon,
|
||||||
|
...props
|
||||||
|
}) {
|
||||||
|
const {button} = useAPIButton(
|
||||||
|
color,
|
||||||
|
size,
|
||||||
|
floated,
|
||||||
|
onClick,
|
||||||
|
disabled,
|
||||||
|
confirmContent,
|
||||||
|
confirmButton,
|
||||||
|
themed,
|
||||||
|
obeyWROLMode,
|
||||||
|
icon,
|
||||||
|
props
|
||||||
|
);
|
||||||
|
|
||||||
|
return button;
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ function CoinRow({header, qrCodeValue, address, buttonColor}) {
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Donate() {
|
export function DonatePage() {
|
||||||
useTitle('Donate');
|
useTitle('Donate');
|
||||||
|
|
||||||
return <PageContainer>
|
return <PageContainer>
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import React, {useContext, useState} from "react";
|
import React, {useContext, useState} from "react";
|
||||||
import {getDownloaders, postDownload} from "../api";
|
import {getDownloaders, postDownload} from "../api";
|
||||||
import {DirectorySearch, frequencyOptions, HelpPopup, rssFrequencyOptions, WROLModeMessage} from "./Common";
|
import {APIButton, DirectorySearch, frequencyOptions, HelpPopup, rssFrequencyOptions, WROLModeMessage} from "./Common";
|
||||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||||
import {ThemeContext} from "../contexts/contexts";
|
import {ThemeContext} from "../contexts/contexts";
|
||||||
|
|
@ -146,7 +146,11 @@ class Downloader extends React.Component {
|
||||||
{withSearchDirectory ? destinationRequired ? directorySearch : advancedAccordion : null}
|
{withSearchDirectory ? destinationRequired ? directorySearch : advancedAccordion : null}
|
||||||
|
|
||||||
<Button content='Cancel' onClick={this.props.clearSelected}/>
|
<Button content='Cancel' onClick={this.props.clearSelected}/>
|
||||||
<Button primary style={{marginTop: '1em'}} disabled={disabled}>Download</Button>
|
<APIButton
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={this.submitDownload}
|
||||||
|
style={{marginTop: '0.5em'}}
|
||||||
|
>Download</APIButton>
|
||||||
{submitted && viewDownloads}
|
{submitted && viewDownloads}
|
||||||
</Form>)}
|
</Form>)}
|
||||||
</ThemeContext.Consumer>
|
</ThemeContext.Consumer>
|
||||||
|
|
@ -230,12 +234,10 @@ class ChannelDownload extends React.Component {
|
||||||
{frequency === 0 && onceMessage}
|
{frequency === 0 && onceMessage}
|
||||||
|
|
||||||
<Button content='Cancel' onClick={this.props.clearSelected}/>
|
<Button content='Cancel' onClick={this.props.clearSelected}/>
|
||||||
<Button
|
<APIButton
|
||||||
color='blue'
|
|
||||||
content='Download'
|
|
||||||
onClick={this.handleSubmit}
|
onClick={this.handleSubmit}
|
||||||
disabled={buttonDisabled}
|
disabled={buttonDisabled}
|
||||||
/>
|
>Download</APIButton>
|
||||||
{pending && <Loader active={pending}/>}
|
{pending && <Loader active={pending}/>}
|
||||||
{success && <Icon name='check'/>}
|
{success && <Icon name='check'/>}
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {Button, Header, Icon, Modal, ModalActions, ModalContent, ModalHeader, Placeholder, Table} from "./Theme";
|
import {Button, Header, Icon, Modal, ModalActions, ModalContent, ModalHeader, Placeholder, Table} from "./Theme";
|
||||||
import {
|
import {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Confirm,
|
|
||||||
IconGroup,
|
IconGroup,
|
||||||
Input,
|
Input,
|
||||||
PlaceholderLine,
|
PlaceholderLine,
|
||||||
|
|
@ -12,14 +11,15 @@ import {
|
||||||
TableHeaderCell,
|
TableHeaderCell,
|
||||||
TableRow
|
TableRow
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import {DirectorySearch, FileIcon, humanFileSize} from "./Common";
|
import {APIButton, DirectorySearch, FileIcon, humanFileSize} from "./Common";
|
||||||
import React, {useEffect, useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import {deleteFile, makeDirectory, movePaths, renamePath} from "../api";
|
import {deleteFile, makeDirectory, movePaths, renamePath} from "../api";
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import {SortableTable} from "./SortableTable";
|
import {SortableTable} from "./SortableTable";
|
||||||
import {useBrowseFiles, useMediaDirectory} from "../hooks/customHooks";
|
import {useBrowseFiles, useMediaDirectory, useWROLMode} from "../hooks/customHooks";
|
||||||
import {DirectoryRefreshButton, FileRowTagIcon, FilesRefreshButton} from "./Files";
|
import {DirectoryRefreshButton, FileRowTagIcon, FilesRefreshButton} from "./Files";
|
||||||
import {FilePreviewContext} from "./FilePreview";
|
import {FilePreviewContext} from "./FilePreview";
|
||||||
|
import {StatusContext} from "../contexts/contexts";
|
||||||
|
|
||||||
function depthIndentation(path) {
|
function depthIndentation(path) {
|
||||||
// Repeated spaces for every folder a path is in.
|
// Repeated spaces for every folder a path is in.
|
||||||
|
|
@ -139,6 +139,7 @@ export function FileBrowser() {
|
||||||
const selectedPathsCount = selectedPaths ? selectedPaths.length : 0;
|
const selectedPathsCount = selectedPaths ? selectedPaths.length : 0;
|
||||||
|
|
||||||
const {browseFiles, openFolders, setOpenFolders, fetchFiles} = useBrowseFiles();
|
const {browseFiles, openFolders, setOpenFolders, fetchFiles} = useBrowseFiles();
|
||||||
|
const wrolModeEnabled = useWROLMode();
|
||||||
|
|
||||||
const headers = [
|
const headers = [
|
||||||
{key: 'select', text: ''},
|
{key: 'select', text: ''},
|
||||||
|
|
@ -195,21 +196,19 @@ export function FileBrowser() {
|
||||||
<DirectoryRefreshButton paths={selectedPaths}/>
|
<DirectoryRefreshButton paths={selectedPaths}/>
|
||||||
: <FilesRefreshButton/>
|
: <FilesRefreshButton/>
|
||||||
}
|
}
|
||||||
<Button icon='trash'
|
<APIButton
|
||||||
color='red'
|
icon='trash'
|
||||||
onClick={() => setDeleteOpen(true)}
|
color='red'
|
||||||
disabled={selectedPathsCount === 0}
|
confirmContent='Are you sure you want to delete these files?'
|
||||||
/>
|
confirmButton='Delete'
|
||||||
<Confirm
|
onClick={onDelete}
|
||||||
open={deleteOpen}
|
disabled={selectedPathsCount === 0}
|
||||||
content='Are you sure you want to delete these files?'
|
obeyWROLMode={true}
|
||||||
onConfirm={onDelete}
|
|
||||||
onCancel={() => setDeleteOpen(false)}
|
|
||||||
/>
|
/>
|
||||||
<Button icon='text cursor'
|
<Button icon='text cursor'
|
||||||
color='yellow'
|
color='yellow'
|
||||||
onClick={() => setRenameOpen(true)}
|
onClick={() => setRenameOpen(true)}
|
||||||
disabled={selectedPathsCount !== 1}
|
disabled={wrolModeEnabled || selectedPathsCount !== 1}
|
||||||
/>
|
/>
|
||||||
{selectedPathsCount === 1 ?
|
{selectedPathsCount === 1 ?
|
||||||
<RenameModal
|
<RenameModal
|
||||||
|
|
@ -221,7 +220,7 @@ export function FileBrowser() {
|
||||||
/> : null}
|
/> : null}
|
||||||
<Button icon='move'
|
<Button icon='move'
|
||||||
color='violet'
|
color='violet'
|
||||||
disabled={selectedPathsCount === 0}
|
disabled={wrolModeEnabled || selectedPathsCount === 0}
|
||||||
onClick={() => setMoveOpen(true)}
|
onClick={() => setMoveOpen(true)}
|
||||||
/>
|
/>
|
||||||
{selectedPathsCount > 0 ?
|
{selectedPathsCount > 0 ?
|
||||||
|
|
@ -233,7 +232,7 @@ export function FileBrowser() {
|
||||||
<Button
|
<Button
|
||||||
color='blue'
|
color='blue'
|
||||||
onClick={() => setMakeDirectoryOpen(true)}
|
onClick={() => setMakeDirectoryOpen(true)}
|
||||||
disabled={selectedPaths && selectedPaths.length > 1}
|
disabled={wrolModeEnabled || selectedPaths && selectedPaths.length > 1}
|
||||||
style={{paddingLeft: '1em', paddingRight: '0.8em'}}
|
style={{paddingLeft: '1em', paddingRight: '0.8em'}}
|
||||||
>
|
>
|
||||||
<IconGroup>
|
<IconGroup>
|
||||||
|
|
@ -246,6 +245,7 @@ export function FileBrowser() {
|
||||||
onClose={() => setMakeDirectoryOpen(false)}
|
onClose={() => setMakeDirectoryOpen(false)}
|
||||||
parent={selectedPaths.length ? selectedPaths[0] : null}
|
parent={selectedPaths.length ? selectedPaths[0] : null}
|
||||||
onSubmit={handleMakeDirectory}
|
onSubmit={handleMakeDirectory}
|
||||||
|
disabled={wrolModeEnabled}
|
||||||
/>
|
/>
|
||||||
</TableHeaderCell>
|
</TableHeaderCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ import {
|
||||||
useQuery,
|
useQuery,
|
||||||
useSearchFiles,
|
useSearchFiles,
|
||||||
useSearchFilter,
|
useSearchFilter,
|
||||||
useSearchView
|
useSearchView,
|
||||||
|
useWROLMode
|
||||||
} from "../hooks/customHooks";
|
} from "../hooks/customHooks";
|
||||||
import {Route, Routes} from "react-router-dom";
|
import {Route, Routes} from "react-router-dom";
|
||||||
import {CardPlaceholder} from "./Placeholder";
|
import {CardPlaceholder} from "./Placeholder";
|
||||||
|
|
@ -572,6 +573,7 @@ export function FilesRoute() {
|
||||||
|
|
||||||
export function FilesRefreshButton() {
|
export function FilesRefreshButton() {
|
||||||
const {status} = useContext(StatusContext);
|
const {status} = useContext(StatusContext);
|
||||||
|
const wrolModeEnabled = useWROLMode();
|
||||||
const refreshing = status && status['flags'] && status['flags'].indexOf('refreshing') >= 0;
|
const refreshing = status && status['flags'] && status['flags'].indexOf('refreshing') >= 0;
|
||||||
const refreshingDirectory = status && status['flags'] && status['flags'].indexOf('refreshing_directory') >= 0;
|
const refreshingDirectory = status && status['flags'] && status['flags'].indexOf('refreshing_directory') >= 0;
|
||||||
|
|
||||||
|
|
@ -589,7 +591,7 @@ export function FilesRefreshButton() {
|
||||||
labelPosition='left'
|
labelPosition='left'
|
||||||
loading={loading || refreshing || refreshingDirectory}
|
loading={loading || refreshing || refreshingDirectory}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
disabled={loading || refreshing}>
|
disabled={wrolModeEnabled || loading || refreshing}>
|
||||||
<Icon name='refresh'/>
|
<Icon name='refresh'/>
|
||||||
Refresh All
|
Refresh All
|
||||||
</Button>;
|
</Button>;
|
||||||
|
|
@ -599,6 +601,7 @@ export function DirectoryRefreshButton({paths}) {
|
||||||
const {status} = useContext(StatusContext);
|
const {status} = useContext(StatusContext);
|
||||||
const refreshing = status && status['flags'] && status['flags'].indexOf('refreshing') >= 0;
|
const refreshing = status && status['flags'] && status['flags'].indexOf('refreshing') >= 0;
|
||||||
const refreshingDirectory = status && status['flags'] && status['flags'].indexOf('refreshing_directory') >= 0;
|
const refreshingDirectory = status && status['flags'] && status['flags'].indexOf('refreshing_directory') >= 0;
|
||||||
|
const wrolModeEnabled = useWROLMode();
|
||||||
|
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(false);
|
||||||
|
|
||||||
|
|
@ -615,7 +618,7 @@ export function DirectoryRefreshButton({paths}) {
|
||||||
labelPosition='left'
|
labelPosition='left'
|
||||||
loading={loading || refreshing || refreshingDirectory}
|
loading={loading || refreshing || refreshingDirectory}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
disabled={loading || refreshing || refreshingDirectory}
|
disabled={wrolModeEnabled || loading || refreshing || refreshingDirectory}
|
||||||
>
|
>
|
||||||
<Icon name='refresh'/>
|
<Icon name='refresh'/>
|
||||||
Refresh
|
Refresh
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ class ManageMap extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function MapApp() {
|
function MapPage() {
|
||||||
return <iframe
|
return <iframe
|
||||||
title='map'
|
title='map'
|
||||||
src={`http://${window.location.hostname}:8084/`}
|
src={`http://${window.location.hostname}:8084/`}
|
||||||
|
|
@ -290,7 +290,7 @@ export function MapRoute() {
|
||||||
return <div style={{marginTop: '2em'}}>
|
return <div style={{marginTop: '2em'}}>
|
||||||
<TabLinks links={links}/>
|
<TabLinks links={links}/>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path='/' exact element={<MapApp/>}/>
|
<Route path='/' exact element={<MapPage/>}/>
|
||||||
<Route path='manage' exact element={<ManageMap/>}/>
|
<Route path='manage' exact element={<ManageMap/>}/>
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {Media, StatusContext, ThemeContext} from "../contexts/contexts";
|
||||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||||
import {DarkModeToggle, HotspotStatusIcon, NAME} from "./Common";
|
import {DarkModeToggle, HotspotStatusIcon, NAME} from "./Common";
|
||||||
import {ShareButton} from "./Share";
|
import {ShareButton} from "./Share";
|
||||||
|
import {useWROLMode} from "../hooks/customHooks";
|
||||||
|
|
||||||
const links = [
|
const links = [
|
||||||
{text: 'Videos', to: '/videos', key: 'videos'},
|
{text: 'Videos', to: '/videos', key: 'videos'},
|
||||||
|
|
@ -56,11 +57,10 @@ function NavIcon(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NavBar() {
|
export function NavBar() {
|
||||||
const {status} = React.useContext(StatusContext);
|
const wrolModeEnabled = useWROLMode();
|
||||||
const wrol_mode = status ? status['wrol_mode'] : null;
|
|
||||||
const wrolpiIcon = <img src='/icon.svg' height='32px' width='32px' alt='WROLPi Home Icon'/>;
|
const wrolpiIcon = <img src='/icon.svg' height='32px' width='32px' alt='WROLPi Home Icon'/>;
|
||||||
const name = NAME || wrolpiIcon;
|
const name = NAME || wrolpiIcon;
|
||||||
const topNavText = wrol_mode ? <>{name} <Icon name='lock'/></> : name;
|
const topNavText = wrolModeEnabled ? <>{name} <Icon name='lock'/></> : name;
|
||||||
const {i} = React.useContext(ThemeContext);
|
const {i} = React.useContext(ThemeContext);
|
||||||
|
|
||||||
const homeLink = <NavLink className='item' to='/' style={{paddingTop: 0, paddingBottom: 0}}>
|
const homeLink = <NavLink className='item' to='/' style={{paddingTop: 0, paddingBottom: 0}}>
|
||||||
|
|
|
||||||
|
|
@ -173,11 +173,11 @@ export function Accordion(props) {
|
||||||
return <SAccordion {...props}/>
|
return <SAccordion {...props}/>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Button(props) {
|
export const Button = React.forwardRef((props, ref) => {
|
||||||
const {i, inverted} = useContext(ThemeContext);
|
const {i, inverted} = useContext(ThemeContext);
|
||||||
props = defaultGrey({...i, ...props}, inverted);
|
props = defaultGrey({...i, ...props}, inverted);
|
||||||
return <SButton {...props}/>
|
return <SButton ref={ref} {...props}/>
|
||||||
}
|
});
|
||||||
|
|
||||||
export function Divider({...props}) {
|
export function Divider({...props}) {
|
||||||
const {i} = useContext(ThemeContext);
|
const {i} = useContext(ThemeContext);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import React, {useContext, useState} from 'react';
|
import React, {useContext} from 'react';
|
||||||
import {tagFileGroup, deleteVideos, untagFileGroup} from "../api";
|
import {deleteVideos, tagFileGroup, untagFileGroup} from "../api";
|
||||||
import {Link, useNavigate, useParams} from "react-router-dom";
|
import {Link, useNavigate, useParams} from "react-router-dom";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import {
|
import {
|
||||||
|
APIButton,
|
||||||
BackButton,
|
BackButton,
|
||||||
encodeMediaPath,
|
encodeMediaPath,
|
||||||
humanFileSize,
|
humanFileSize,
|
||||||
|
|
@ -12,7 +13,6 @@ import {
|
||||||
PreviewPath,
|
PreviewPath,
|
||||||
useTitle
|
useTitle
|
||||||
} from "./Common";
|
} from "./Common";
|
||||||
import {Confirm} from "semantic-ui-react";
|
|
||||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||||
import Container from "semantic-ui-react/dist/commonjs/elements/Container";
|
import Container from "semantic-ui-react/dist/commonjs/elements/Container";
|
||||||
import {VideoPlaceholder} from "./Placeholder";
|
import {VideoPlaceholder} from "./Placeholder";
|
||||||
|
|
@ -44,7 +44,6 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const videoRef = React.useRef();
|
const videoRef = React.useRef();
|
||||||
let [deleteOpen, setDeleteOpen] = useState(false);
|
|
||||||
|
|
||||||
useTitle(videoFile === null || videoFile === undefined ? null : videoFile.video.title);
|
useTitle(videoFile === null || videoFile === undefined ? null : videoFile.video.title);
|
||||||
let video;
|
let video;
|
||||||
|
|
@ -69,13 +68,7 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDeleteVideo = async (video_id) => {
|
const handleDeleteVideo = async (video_id) => {
|
||||||
try {
|
await deleteVideos([video_id])
|
||||||
await deleteVideos([video_id])
|
|
||||||
setDeleteOpen(false);
|
|
||||||
} catch (e) {
|
|
||||||
setDeleteOpen(false);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
navigate(-1);
|
navigate(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,24 +191,17 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a href={downloadUrl} target='_blank' rel='noopener noreferrer'>
|
<Button as='a' href={downloadUrl}>
|
||||||
<Button style={{margin: '0.5em'}}>
|
<Icon name='download'/>
|
||||||
<Icon name='download'/>
|
Download
|
||||||
Download
|
</Button>
|
||||||
</Button>
|
<APIButton
|
||||||
</a>
|
|
||||||
<Button
|
|
||||||
color='red'
|
color='red'
|
||||||
onClick={() => setDeleteOpen(true)}
|
confirmContent='Are you sure you want to delete this video? All files related to this video will be deleted. It will not be downloaded again!'
|
||||||
style={{margin: '0.5em'}}
|
|
||||||
>Delete</Button>
|
|
||||||
<Confirm
|
|
||||||
open={deleteOpen}
|
|
||||||
content='Are you sure you want to delete this video? All files related to this video will be deleted. It will not be downloaded again!'
|
|
||||||
confirmButton='Delete'
|
confirmButton='Delete'
|
||||||
onCancel={() => setDeleteOpen(false)}
|
onClick={async () => await handleDeleteVideo(video.id)}
|
||||||
onConfirm={() => handleDeleteVideo(video.id)}
|
obeyWROLMode={true}
|
||||||
/>
|
>Delete</APIButton>
|
||||||
</p>
|
</p>
|
||||||
<br/>
|
<br/>
|
||||||
</Segment>
|
</Segment>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {useOutdatedZims, useSearchZim} from "../hooks/customHooks";
|
import {useOutdatedZims, useSearchZim, useWROLMode} from "../hooks/customHooks";
|
||||||
import {
|
import {
|
||||||
Accordion,
|
Accordion,
|
||||||
Button,
|
Button,
|
||||||
|
|
@ -31,6 +31,7 @@ import {
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import React, {useContext, useState} from "react";
|
import React, {useContext, useState} from "react";
|
||||||
import {
|
import {
|
||||||
|
APIButton,
|
||||||
encodeMediaPath,
|
encodeMediaPath,
|
||||||
humanFileSize,
|
humanFileSize,
|
||||||
normalizeEstimate,
|
normalizeEstimate,
|
||||||
|
|
@ -55,7 +56,7 @@ import {
|
||||||
} from "../api";
|
} from "../api";
|
||||||
import {useSearch} from "./Search";
|
import {useSearch} from "./Search";
|
||||||
import {TagsQuerySelector} from "./Files";
|
import {TagsQuerySelector} from "./Files";
|
||||||
import {ThemeContext} from "../contexts/contexts";
|
import {StatusContext, ThemeContext} from "../contexts/contexts";
|
||||||
import {Link, Route, Routes} from "react-router-dom";
|
import {Link, Route, Routes} from "react-router-dom";
|
||||||
import {SortableTable} from "./SortableTable";
|
import {SortableTable} from "./SortableTable";
|
||||||
import {toast} from "react-semantic-toasts-2";
|
import {toast} from "react-semantic-toasts-2";
|
||||||
|
|
@ -70,10 +71,7 @@ export const OutdatedZimsMessage = ({onClick}) => {
|
||||||
const onOpen = () => setOpen(true);
|
const onOpen = () => setOpen(true);
|
||||||
const onClose = () => setOpen(false);
|
const onClose = () => setOpen(false);
|
||||||
|
|
||||||
const handleDelete = async (e) => {
|
const handleDelete = async () => {
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const success = await deleteOutdatedZims();
|
const success = await deleteOutdatedZims();
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
@ -96,10 +94,7 @@ export const OutdatedZimsMessage = ({onClick}) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleIgnore = async (e) => {
|
const handleIgnore = async () => {
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
const config = {ignore_outdated_zims: true};
|
const config = {ignore_outdated_zims: true};
|
||||||
await saveSettings(config);
|
await saveSettings(config);
|
||||||
if (onClick) {
|
if (onClick) {
|
||||||
|
|
@ -138,13 +133,19 @@ export const OutdatedZimsMessage = ({onClick}) => {
|
||||||
{modalContent}
|
{modalContent}
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ModalActions>
|
<ModalActions>
|
||||||
<Button color='red' floated='left' onClick={handleDelete}>Delete</Button>
|
<APIButton
|
||||||
|
color='red'
|
||||||
|
floated='left'
|
||||||
|
onClick={handleDelete}
|
||||||
|
>Delete</APIButton>
|
||||||
<Button onClick={onClose}>Close</Button>
|
<Button onClick={onClose}>Close</Button>
|
||||||
</ModalActions>
|
</ModalActions>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Link to='/files?folders=zims'><SButton>Delete Manually</SButton></Link>
|
<Link to='/files?folders=zims'><SButton>Delete Manually</SButton></Link>
|
||||||
<SButton secondary onClick={handleIgnore}>Ignore Forever</SButton>
|
<APIButton secondary
|
||||||
|
onClick={handleIgnore}
|
||||||
|
>Ignore Forever</APIButton>
|
||||||
</Message.Content>
|
</Message.Content>
|
||||||
</Message>
|
</Message>
|
||||||
}
|
}
|
||||||
|
|
@ -333,10 +334,9 @@ const ZimCatalogItemRow = ({item, subscriptions, iso_639_codes, fetchSubscriptio
|
||||||
const [pending, setPending] = useState(false);
|
const [pending, setPending] = useState(false);
|
||||||
const languageChange = subscription ? langauge !== subscription['language'] : false;
|
const languageChange = subscription ? langauge !== subscription['language'] : false;
|
||||||
|
|
||||||
const handleButton = async (e) => {
|
const wrolModeEnabled = useWROLMode();
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
const handleButton = async () => {
|
||||||
}
|
|
||||||
let success = false;
|
let success = false;
|
||||||
try {
|
try {
|
||||||
setPending(true);
|
setPending(true);
|
||||||
|
|
@ -375,14 +375,18 @@ const ZimCatalogItemRow = ({item, subscriptions, iso_639_codes, fetchSubscriptio
|
||||||
placeholder='Language'
|
placeholder='Language'
|
||||||
options={languageOptions}
|
options={languageOptions}
|
||||||
value={langauge}
|
value={langauge}
|
||||||
|
disabled={wrolModeEnabled}
|
||||||
onChange={handleLanguageChange}
|
onChange={handleLanguageChange}
|
||||||
/>;
|
/>;
|
||||||
|
|
||||||
const subscribeButton = <Button
|
const subscribeButton = <APIButton
|
||||||
|
color='grey'
|
||||||
disabled={pending}
|
disabled={pending}
|
||||||
onClick={handleButton}>
|
onClick={handleButton}
|
||||||
|
obeyWROLMode={true}
|
||||||
|
>
|
||||||
{subscription && !languageChange ? 'Unsubscribe' : 'Subscribe'}
|
{subscription && !languageChange ? 'Unsubscribe' : 'Subscribe'}
|
||||||
</Button>
|
</APIButton>
|
||||||
|
|
||||||
return <TableRow key={name}>
|
return <TableRow key={name}>
|
||||||
<TableCell>{name}</TableCell>
|
<TableCell>{name}</TableCell>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {PageContainer, TabLinks, Toggle} from "../Common";
|
||||||
import {Route, Routes} from "react-router-dom";
|
import {Route, Routes} from "react-router-dom";
|
||||||
import {ThemeContext} from "../../contexts/contexts";
|
import {ThemeContext} from "../../contexts/contexts";
|
||||||
import {Header, Loader, Segment} from "../Theme";
|
import {Header, Loader, Segment} from "../Theme";
|
||||||
import {Downloads} from "./Downloads";
|
import {DownloadsPage} from "./Downloads";
|
||||||
import {Settings} from "./Settings";
|
import {Settings} from "./Settings";
|
||||||
import {Status} from "./Status";
|
import {Status} from "./Status";
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ class WROLMode extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Admin() {
|
export default function AdminRoute() {
|
||||||
|
|
||||||
const links = [
|
const links = [
|
||||||
{text: 'Downloads', to: '/admin', key: 'admin', end: true},
|
{text: 'Downloads', to: '/admin', key: 'admin', end: true},
|
||||||
|
|
@ -77,7 +77,7 @@ export default function Admin() {
|
||||||
return <PageContainer>
|
return <PageContainer>
|
||||||
<TabLinks links={links}/>
|
<TabLinks links={links}/>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path='/' exact element={<Downloads/>}/>
|
<Route path='/' exact element={<DownloadsPage/>}/>
|
||||||
<Route path='settings' exact element={<Settings/>}/>
|
<Route path='settings' exact element={<Settings/>}/>
|
||||||
<Route path='status' exact element={<Status/>}/>
|
<Route path='status' exact element={<Status/>}/>
|
||||||
<Route path='wrol' exact element={<WROLMode/>}/>
|
<Route path='wrol' exact element={<WROLMode/>}/>
|
||||||
|
|
@ -2,6 +2,7 @@ import React from "react";
|
||||||
import {clearCompletedDownloads, clearFailedDownloads, deleteDownload, killDownload, postDownload} from "../../api";
|
import {clearCompletedDownloads, clearFailedDownloads, deleteDownload, killDownload, postDownload} from "../../api";
|
||||||
import {Link} from "react-router-dom";
|
import {Link} from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
|
APIButton,
|
||||||
DisableDownloadsToggle,
|
DisableDownloadsToggle,
|
||||||
isoDatetimeToElapsedPopup,
|
isoDatetimeToElapsedPopup,
|
||||||
secondsToFrequency,
|
secondsToFrequency,
|
||||||
|
|
@ -40,45 +41,35 @@ function ClearCompleteDownloads({callback}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Button
|
<APIButton
|
||||||
onClick={localClearDownloads}
|
onClick={localClearDownloads}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
color='yellow'
|
color='yellow'
|
||||||
>Clear Completed</Button>
|
obeyWROLMode={true}
|
||||||
|
>Clear Completed</APIButton>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
function ClearFailedDownloads({callback}) {
|
function ClearFailedDownloads({callback}) {
|
||||||
const [open, setOpen] = React.useState(false);
|
|
||||||
const [disabled, setDisabled] = React.useState(false);
|
|
||||||
|
|
||||||
async function localDeleteFailed() {
|
async function localDeleteFailed() {
|
||||||
setDisabled(true);
|
|
||||||
try {
|
try {
|
||||||
await clearFailedDownloads();
|
await clearFailedDownloads();
|
||||||
} finally {
|
} finally {
|
||||||
setDisabled(false);
|
|
||||||
setOpen(false);
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>
|
return <APIButton
|
||||||
<Button
|
color='red'
|
||||||
onClick={() => setOpen(true)}
|
onClick={localDeleteFailed}
|
||||||
disabled={disabled}
|
confirmContent='Are you sure you want to delete failed downloads? They will not be retried.'
|
||||||
color='red'
|
confirmButton='Delete'
|
||||||
>Clear Failed</Button>
|
obeyWROLMode={true}
|
||||||
<Confirm
|
>
|
||||||
open={open}
|
Clear Failed
|
||||||
content='Are you sure you want to delete failed downloads? They will not be retried.'
|
</APIButton>
|
||||||
confirmButton='Delete'
|
|
||||||
onCancel={() => setOpen(false)}
|
|
||||||
onConfirm={localDeleteFailed}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DownloadRow extends React.Component {
|
class DownloadRow extends React.Component {
|
||||||
|
|
@ -104,10 +95,7 @@ class DownloadRow extends React.Component {
|
||||||
this.setState({deleteOpen: false});
|
this.setState({deleteOpen: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDelete = async (e) => {
|
handleDelete = async () => {
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
const {id} = this.props;
|
const {id} = this.props;
|
||||||
try {
|
try {
|
||||||
await deleteDownload(id);
|
await deleteDownload(id);
|
||||||
|
|
@ -144,13 +132,13 @@ class DownloadRow extends React.Component {
|
||||||
</Modal>;
|
</Modal>;
|
||||||
|
|
||||||
const deleteButton = <>
|
const deleteButton = <>
|
||||||
<Button icon='trash' onClick={this.openDelete} color='red'/>
|
<APIButton
|
||||||
<Confirm
|
color='red'
|
||||||
open={deleteOpen}
|
icon='trash'
|
||||||
content='Are you sure you want to delete this download?'
|
confirmContent='Are you sure you want to delete this download?'
|
||||||
confirmButton='Delete'
|
confirmButton='Delete'
|
||||||
onCancel={this.closeDelete}
|
onClick={this.handleDelete}
|
||||||
onConfirm={this.handleDelete}
|
obeyWROLMode={true}
|
||||||
/>
|
/>
|
||||||
</>;
|
</>;
|
||||||
|
|
||||||
|
|
@ -184,62 +172,29 @@ class StoppableRow extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
stopOpen: false,
|
|
||||||
startOpen: false,
|
|
||||||
errorModalOpen: false,
|
errorModalOpen: false,
|
||||||
deleteOpen: false,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
openDelete = () => {
|
handleDelete = async () => {
|
||||||
this.setState({deleteOpen: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
closeDelete = () => {
|
|
||||||
this.setState({deleteOpen: false});
|
|
||||||
}
|
|
||||||
|
|
||||||
openStop = () => {
|
|
||||||
this.setState({stopOpen: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
closeStop = () => {
|
|
||||||
this.setState({stopOpen: false});
|
|
||||||
}
|
|
||||||
|
|
||||||
openStart = () => {
|
|
||||||
this.setState({startOpen: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
closeStart = () => {
|
|
||||||
this.setState({startOpen: false});
|
|
||||||
}
|
|
||||||
|
|
||||||
handleDelete = async (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
await deleteDownload(this.props.id);
|
await deleteDownload(this.props.id);
|
||||||
this.closeDelete();
|
|
||||||
await this.props.fetchDownloads();
|
await this.props.fetchDownloads();
|
||||||
};
|
};
|
||||||
|
|
||||||
handleStop = async (e) => {
|
handleStop = async () => {
|
||||||
e.preventDefault();
|
|
||||||
await killDownload(this.props.id);
|
await killDownload(this.props.id);
|
||||||
this.closeStop();
|
|
||||||
await this.props.fetchDownloads();
|
await this.props.fetchDownloads();
|
||||||
};
|
};
|
||||||
|
|
||||||
handleStart = async (e) => {
|
handleStart = async () => {
|
||||||
e.preventDefault();
|
|
||||||
let downloader = this.props.downloader;
|
let downloader = this.props.downloader;
|
||||||
await postDownload(`${this.props.url}`, downloader);
|
await postDownload(`${this.props.url}`, downloader);
|
||||||
this.closeStart();
|
|
||||||
await this.props.fetchDownloads();
|
await this.props.fetchDownloads();
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let {url, last_successful_download, status, location, error} = this.props;
|
let {url, last_successful_download, status, location, error} = this.props;
|
||||||
let {stopOpen, startOpen, errorModalOpen, deleteOpen} = this.state;
|
let {errorModalOpen} = this.state;
|
||||||
|
|
||||||
// Open downloads (/download), or external links in an anchor.
|
// Open downloads (/download), or external links in an anchor.
|
||||||
const link = location && !location.startsWith('/download') ?
|
const link = location && !location.startsWith('/download') ?
|
||||||
|
|
@ -251,38 +206,33 @@ class StoppableRow extends React.Component {
|
||||||
if (status === 'pending' || status === 'new') {
|
if (status === 'pending' || status === 'new') {
|
||||||
buttonCell = (
|
buttonCell = (
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Button
|
<APIButton
|
||||||
onClick={this.openStop}
|
|
||||||
color='red'
|
color='red'
|
||||||
>Stop</Button>
|
onClick={this.handleStop}
|
||||||
<Confirm
|
confirmContent='Are you sure you want to stop this download? It will not be retried.'
|
||||||
open={stopOpen}
|
|
||||||
content='Are you sure you want to stop this download? It will not be retried.'
|
|
||||||
confirmButton='Stop'
|
confirmButton='Stop'
|
||||||
onCancel={this.closeStop}
|
obeyWROLMode={true}
|
||||||
onConfirm={this.handleStop}
|
>Stop</APIButton>
|
||||||
/>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
);
|
);
|
||||||
} else if (status === 'failed' || status === 'deferred') {
|
} else if (status === 'failed' || status === 'deferred') {
|
||||||
buttonCell = (
|
buttonCell = (
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Button icon='trash' onClick={this.openDelete} color='red'/>
|
<APIButton
|
||||||
<Confirm
|
color='red'
|
||||||
open={deleteOpen}
|
icon='trash'
|
||||||
content='Are you sure you want to delete this download?'
|
onClick={this.handleDelete}
|
||||||
|
confirmContent='Are you sure you want to delete this download?'
|
||||||
confirmButton='Delete'
|
confirmButton='Delete'
|
||||||
onCancel={this.closeDelete}
|
obeyWROLMode={true}
|
||||||
onConfirm={this.handleDelete}
|
|
||||||
/>
|
/>
|
||||||
<Button onClick={this.openStart} color='green'>Retry</Button>
|
<APIButton
|
||||||
<Confirm
|
color='green'
|
||||||
open={startOpen}
|
confirmContent='Are you sure you want to restart this download?'
|
||||||
content='Are you sure you want to restart this download?'
|
|
||||||
confirmButton='Start'
|
confirmButton='Start'
|
||||||
onCancel={this.closeStart}
|
onClick={this.handleStart}
|
||||||
onConfirm={this.handleStart}
|
obeyWROLMode={true}
|
||||||
/>
|
>Retry</APIButton>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
);
|
);
|
||||||
} else if (status === 'complete' && location) {
|
} else if (status === 'complete' && location) {
|
||||||
|
|
@ -296,18 +246,12 @@ class StoppableRow extends React.Component {
|
||||||
completedAtCell = (
|
completedAtCell = (
|
||||||
<Modal
|
<Modal
|
||||||
closeIcon
|
closeIcon
|
||||||
onClose={() => this.setState({errorModalOpen: false})}
|
|
||||||
onOpen={() => this.setState({errorModalOpen: true})}
|
|
||||||
open={errorModalOpen}
|
|
||||||
trigger={<Button icon='exclamation circle' color='red'/>}
|
trigger={<Button icon='exclamation circle' color='red'/>}
|
||||||
>
|
>
|
||||||
<ModalHeader>Download Error</ModalHeader>
|
<ModalHeader>Download Error</ModalHeader>
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<pre style={{overflowX: 'scroll'}}>{error}</pre>
|
<pre style={{overflowX: 'scroll'}}>{error}</pre>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
<ModalActions>
|
|
||||||
<SButton onClick={() => this.setState({errorModalOpen: false})}>Close</SButton>
|
|
||||||
</ModalActions>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +323,7 @@ export function RecurringDownloadsTable({downloads, fetchDownloads}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Downloads() {
|
export function DownloadsPage() {
|
||||||
useTitle('Downloads');
|
useTitle('Downloads');
|
||||||
|
|
||||||
const {onceDownloads, recurringDownloads, fetchDownloads} = useDownloads();
|
const {onceDownloads, recurringDownloads, fetchDownloads} = useDownloads();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import {getSettings, saveSettings} from "../../api";
|
||||||
import {Button, Form, FormGroup, FormInput, Header, Loader, Modal, ModalContent, ModalHeader, Segment} from "../Theme";
|
import {Button, Form, FormGroup, FormInput, Header, Loader, Modal, ModalContent, ModalHeader, Segment} from "../Theme";
|
||||||
import {Container, Dimmer, Icon} from "semantic-ui-react";
|
import {Container, Dimmer, Icon} from "semantic-ui-react";
|
||||||
import {ThemeContext} from "../../contexts/contexts";
|
import {ThemeContext} from "../../contexts/contexts";
|
||||||
import {HelpPopup, HotspotToggle, ThrottleToggle, Toggle, WROLModeMessage} from "../Common";
|
import {APIButton, HelpPopup, HotspotToggle, ThrottleToggle, Toggle, WROLModeMessage} from "../Common";
|
||||||
import QRCode from "react-qr-code";
|
import QRCode from "react-qr-code";
|
||||||
|
|
||||||
export class Settings extends React.Component {
|
export class Settings extends React.Component {
|
||||||
|
|
@ -57,7 +57,9 @@ export class Settings extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleSubmit(e) {
|
async handleSubmit(e) {
|
||||||
e.preventDefault();
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
this.setState({disabled: true, pending: true});
|
this.setState({disabled: true, pending: true});
|
||||||
let settings = {
|
let settings = {
|
||||||
download_on_startup: this.state.download_on_startup,
|
download_on_startup: this.state.download_on_startup,
|
||||||
|
|
@ -228,9 +230,13 @@ export class Settings extends React.Component {
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<Button color='violet' type="submit" disabled={disabled} size='large'>
|
<APIButton
|
||||||
Save
|
color='violet'
|
||||||
</Button>
|
size='big'
|
||||||
|
onClick={this.handleSubmit}
|
||||||
|
obeyWROLMode={true}
|
||||||
|
disabled={disabled}
|
||||||
|
>Save</APIButton>
|
||||||
|
|
||||||
<Dimmer active={pending}>
|
<Dimmer active={pending}>
|
||||||
<Loader active={pending} size='large'/>
|
<Loader active={pending} size='large'/>
|
||||||
|
|
|
||||||
|
|
@ -1064,3 +1064,9 @@ export const useVINDecoder = (defaultVINNumber = '') => {
|
||||||
|
|
||||||
return {value, setValue, vin}
|
return {value, setValue, vin}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const useWROLMode = () => {
|
||||||
|
// Returns the current boolean WROL Mode, during fetch this returns null.
|
||||||
|
const {status} = useContext(StatusContext);
|
||||||
|
return status ? status.wrol_mode : null;
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import asyncio
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from sanic import response, Request
|
from sanic import response, Request
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ from wrolpi.captions import FFMPEG_BIN
|
||||||
from wrolpi.cmd import FFPROBE_BIN
|
from wrolpi.cmd import FFPROBE_BIN
|
||||||
from wrolpi.common import logger, get_media_directory
|
from wrolpi.common import logger, get_media_directory
|
||||||
from wrolpi.db import get_db_session, get_db_curs
|
from wrolpi.db import get_db_session, get_db_curs
|
||||||
from .errors import ChannelNameConflict, ChannelURLConflict, ChannelDirectoryConflict, ChannelSourceIdConflict
|
|
||||||
from wrolpi.vars import DEFAULT_FILE_PERMISSIONS
|
from wrolpi.vars import DEFAULT_FILE_PERMISSIONS
|
||||||
|
from .errors import ChannelNameConflict, ChannelURLConflict, ChannelDirectoryConflict, ChannelSourceIdConflict
|
||||||
from .models import Channel
|
from .models import Channel
|
||||||
|
|
||||||
logger = logger.getChild(__name__)
|
logger = logger.getChild(__name__)
|
||||||
|
|
@ -80,9 +80,10 @@ def check_for_channel_conflicts(session: Session, id_=None, url=None, name=None,
|
||||||
raise ChannelSourceIdConflict()
|
raise ChannelSourceIdConflict()
|
||||||
|
|
||||||
# Assure that this Channel's directory is not in another Channel's directory.
|
# Assure that this Channel's directory is not in another Channel's directory.
|
||||||
directory_str = str(directory)
|
directory = f'{directory}/'
|
||||||
for channel in session.query(Channel).filter(Channel.id != id_):
|
for channel in session.query(Channel).filter(Channel.id != id_):
|
||||||
if directory_str.startswith(str(channel.directory)) or str(channel.directory).startswith(directory_str):
|
channel_directory = f'{channel.directory}/'
|
||||||
|
if directory.startswith(channel_directory) or channel_directory.startswith(directory):
|
||||||
raise ChannelDirectoryConflict()
|
raise ChannelDirectoryConflict()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import asyncio
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from sanic import response, Blueprint
|
from sanic import response, Blueprint
|
||||||
|
|
@ -60,7 +61,7 @@ async def search(_: Request, body: schema.VideoSearchRequest):
|
||||||
@openapi.response(HTTPStatus.NOT_FOUND, JSONErrorResponse)
|
@openapi.response(HTTPStatus.NOT_FOUND, JSONErrorResponse)
|
||||||
@wrol_mode_check
|
@wrol_mode_check
|
||||||
@run_after(lib.save_channels_config)
|
@run_after(lib.save_channels_config)
|
||||||
def video_delete(_: Request, video_ids: str):
|
async def video_delete(_: Request, video_ids: str):
|
||||||
try:
|
try:
|
||||||
video_ids = [int(i) for i in str(video_ids).split(',')]
|
video_ids = [int(i) for i in str(video_ids).split(',')]
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
@ -69,4 +70,4 @@ def video_delete(_: Request, video_ids: str):
|
||||||
lib.delete_videos(*video_ids)
|
lib.delete_videos(*video_ids)
|
||||||
|
|
||||||
Events.send_deleted(f'Deleted {len(video_ids)} videos')
|
Events.send_deleted(f'Deleted {len(video_ids)} videos')
|
||||||
return response.raw('', HTTPStatus.NO_CONTENT)
|
return response.empty()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue