diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-06-06 17:49:58 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-06-06 17:49:58 -0500 |
| commit | d7abce6360907738c29999f6b2700f7fe64b998d (patch) | |
| tree | 7712dd1859a3d615ced20d994d68fcf4fbd5c257 /src | |
| parent | 62b196d7a4f01dfe74ea272b6753607f9f93ad5a (diff) | |
| download | slskd-d7abce6360907738c29999f6b2700f7fe64b998d.tar.gz | |
stub filter input and filtering code
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/components/Search/Search.css | 5 | ||||
| -rw-r--r-- | src/web/src/components/Search/Search.js | 64 |
2 files changed, 42 insertions, 27 deletions
diff --git a/src/web/src/components/Search/Search.css b/src/web/src/components/Search/Search.css index eb421948..7c91a08b 100644 --- a/src/web/src/components/Search/Search.css +++ b/src/web/src/components/Search/Search.css @@ -58,4 +58,9 @@ .search-loader { margin-top: 50px !important; +} + +.search-filter { + width: 100%; + margin-top: 1rem; }
\ No newline at end of file diff --git a/src/web/src/components/Search/Search.js b/src/web/src/components/Search/Search.js index 60720c1a..42b26195 100644 --- a/src/web/src/components/Search/Search.js +++ b/src/web/src/components/Search/Search.js @@ -32,6 +32,7 @@ const initialState = { hiddenResults: [], hideLocked: true, fetching: false, + resultFilters: undefined }; const sortOptions = { @@ -151,9 +152,11 @@ class Search extends Component { } sortAndFilterResults = () => { - const { results = [], hideNoFreeSlots, resultSort, hideLocked, hiddenResults = [] } = this.state; + const { results = [], hideNoFreeSlots, resultSort, resultFilters = '', hideLocked, hiddenResults = [] } = this.state; const { field, order } = sortOptions[resultSort]; + const filters = search.parseFiltersFromString(resultFilters); + return results .filter(r => !hiddenResults.includes(r.username)) .map(r => { @@ -162,6 +165,7 @@ class Search extends Component { } return r; }) + .map(response => search.filterResponse({ response, filters })) .filter(r => r.fileCount + r.lockedFileCount > 0) .filter(r => !(hideNoFreeSlots && r.freeUploadSlots === 0)) .sort((a, b) => { @@ -220,34 +224,40 @@ class Search extends Component { </Loader> : <div> - {(results && results.length > 0) ? <Segment className='search-options' raised> - <Dropdown - button - className='search-options-sort icon' - floating - labeled - icon='sort' - options={sortDropdownOptions} - onChange={(e, { value }) => this.setState({ resultSort: value }, () => this.saveState())} - text={sortDropdownOptions.find(o => o.value === resultSort).text} - /> - <div className='search-option-toggles'> - <Checkbox - className='search-options-hide-locked' - toggle - onChange={() => this.setState({ hideLocked: !hideLocked }, () => this.saveState())} - checked={hideLocked} - label='Hide Locked Results' + {(results && results.length > 0) ? + <Segment className='search-options' raised> + <Dropdown + button + className='search-options-sort icon' + floating + labeled + icon='sort' + options={sortDropdownOptions} + onChange={(e, { value }) => this.setState({ resultSort: value }, () => this.saveState())} + text={sortDropdownOptions.find(o => o.value === resultSort).text} /> - <Checkbox - className='search-options-hide-no-slots' - toggle - onChange={() => this.setState({ hideNoFreeSlots: !hideNoFreeSlots }, () => this.saveState())} - checked={hideNoFreeSlots} - label='Hide Results with No Free Slots' + <div className='search-option-toggles'> + <Checkbox + className='search-options-hide-locked' + toggle + onChange={() => this.setState({ hideLocked: !hideLocked }, () => this.saveState())} + checked={hideLocked} + label='Hide Locked Results' + /> + <Checkbox + className='search-options-hide-no-slots' + toggle + onChange={() => this.setState({ hideNoFreeSlots: !hideNoFreeSlots }, () => this.saveState())} + checked={hideNoFreeSlots} + label='Hide Results with No Free Slots' + /> + </div> + <Input + label='Filters' + className='search-filter' /> - </div> - </Segment> : <PlaceholderSegment icon='search'/>} + </Segment> : <PlaceholderSegment icon='search'/> + } {sortedAndFilteredResults.slice(0, displayCount).map((r, i) => <Response key={i} |
