mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 20:59:56 -05:00
Fixing changes before merge.
Moving FilesRefreshButton and DirectoryRefreshButton out of browser file. Moving file fetching tino FileBrowser. Removing sub-folders from Files display when any parent folder is clicked. Using closed captioning for vtt/srt file icon. Using my own react-semantic-toasts-2 to use toasts in Node 18. Fixing bug where more than the last page was displayed. Upgrading yt-dlp. Fixing sub-folder file selection. Adding rowKey to SortableTable to give React a key for each row. Renaming key to path. Removing duplicate urls. Unifying file modals. Displaying modals for image and text files. Handling refresh loading in FileBrowser. Creating refreshing_directory flag. Removing accidental commit. Sorting by url_count. Using SortableTable on Domains page. Using SortableTable for Channels page. Created new FileBrowser which allows browsing of files in the media directory. Using Node 18 in pi-gen. Creating new FileBrowser to replace outdated react-keyed-file-browser. Returning mimetype with file list. Do not display 'Do not download' on Channel download in Dashboard. Allowing null channel download frequency so user can stop downloading a channel. Bumping version for Node 18. Using my own semantic-ui-offline to avoid pulling Google fonts. Upgrading app docker container to use Node 18. This requires the removal of several npm packages. File browser will require re-write. It now pulls fonts from Google, this will need to be fixed. Testing DownloadsToggle click. Testing trinary states of DownloadsToggle. Installing @testing-library/user-event for testing App.
This commit is contained in:
parent
5da0fe4f2d
commit
81d80238be
43 changed files with 16148 additions and 19032 deletions
73
app/src/components/SortableTable.js
Normal file
73
app/src/components/SortableTable.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import React from "react";
|
||||
import _ from "lodash";
|
||||
import {TableBody, TableHeader, TableHeaderCell, TableRow} from "semantic-ui-react";
|
||||
import {Table} from "./Theme";
|
||||
|
||||
export class SortableTable extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {sortColumn: null, direction: 'ascending'};
|
||||
}
|
||||
|
||||
changeSort = (key) => {
|
||||
const {sortColumn, direction} = this.state;
|
||||
if (key === sortColumn) {
|
||||
this.setState({direction: direction === 'ascending' ? 'descending' : 'ascending'});
|
||||
} else {
|
||||
this.setState({sortColumn: key, direction: 'ascending'});
|
||||
}
|
||||
}
|
||||
|
||||
sortData = (data) => {
|
||||
let {tableHeaders, defaultSortColumn} = this.props;
|
||||
let {sortColumn, direction} = this.state;
|
||||
|
||||
const sortKey = sortColumn || defaultSortColumn;
|
||||
const sortHeader = _.find(tableHeaders, {key: sortKey});
|
||||
if (sortHeader === undefined) {
|
||||
// No sort header, probably no default defined.
|
||||
return data;
|
||||
}
|
||||
data = _.sortBy(data, sortHeader['sortBy']);
|
||||
data = direction === 'descending' ? data.reverse() : data;
|
||||
return data;
|
||||
}
|
||||
|
||||
render() {
|
||||
let {rowFunc, tableHeaders, rowKey} = this.props;
|
||||
let {direction} = this.state;
|
||||
rowKey = rowKey || 'key';
|
||||
|
||||
const data = this.sortData(this.props['data']);
|
||||
|
||||
const tableHeader = (spec) => {
|
||||
const {key, text, sortBy, width} = spec;
|
||||
if (sortBy) {
|
||||
return <TableHeaderCell
|
||||
key={key}
|
||||
sorted={this.state['sortColumn'] === key ? direction : null}
|
||||
onClick={() => this.changeSort(key)}
|
||||
width={width || undefined}
|
||||
>
|
||||
{text}
|
||||
</TableHeaderCell>;
|
||||
} else {
|
||||
return <TableHeaderCell key={key} width={width}>{text}</TableHeaderCell>
|
||||
}
|
||||
}
|
||||
|
||||
const rows = data.map(i => <React.Fragment key={i[rowKey]}>{rowFunc(i, this.sortData)}</React.Fragment>);
|
||||
|
||||
return <Table sortable {...this.props.tableProps}>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{tableHeaders.map(tableHeader)}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{rows}
|
||||
</TableBody>
|
||||
{this.props.footer}
|
||||
</Table>
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue