diff --git a/app/src/api.js b/app/src/api.js
index b4772a40..b25dfc24 100644
--- a/app/src/api.js
+++ b/app/src/api.js
@@ -2239,7 +2239,7 @@ export async function deleteDocs(docIds) {
return await apiDelete(`${DOCS_API}/${ids}`);
}
-export async function searchDocs(offset, limit, searchStr, order, tagNames, author, subject) {
+export async function searchDocs(offset, limit, searchStr, order, tagNames, author, subject, mimetype) {
offset = parseInt(offset || 0);
limit = parseInt(limit || DEFAULT_LIMIT);
let body = {offset, limit};
@@ -2258,6 +2258,9 @@ export async function searchDocs(offset, limit, searchStr, order, tagNames, auth
if (subject) {
body['subject'] = subject;
}
+ if (mimetype) {
+ body['mimetype'] = mimetype;
+ }
console.debug('searching docs', body);
const response = await apiPost(`${DOCS_API}/search`, body);
diff --git a/app/src/components/Docs.js b/app/src/components/Docs.js
index 021ad121..4e7a309a 100644
--- a/app/src/components/Docs.js
+++ b/app/src/components/Docs.js
@@ -21,7 +21,7 @@ import {
} from "./Common";
import {Button, darkTheme, Header, Icon, Segment, Statistic, Tab} from "./Theme";
import {BulkTagModal} from "./BulkTagModal";
-import {FilesView} from "./Files";
+import {DocSearchFilterButton, FilesView} from "./Files";
import {useAuthors, useDoc, useOneQuery, useSearchDocs, useSubjects} from "../hooks/customHooks";
import {TagsSelector} from "../Tags";
import {toast} from "react-semantic-toasts-2";
@@ -140,7 +140,8 @@ function DocsPage() {
{viewButton}
{limitDropdown}
{tagQuerySelector}
-
+
+
{searchInput}
@@ -153,8 +154,9 @@ function DocsPage() {
{viewButton}
{limitDropdown}
{tagQuerySelector}
+
- {searchInput}
+ {searchInput}
diff --git a/app/src/components/Files.js b/app/src/components/Files.js
index ad83f959..dcb02692 100644
--- a/app/src/components/Files.js
+++ b/app/src/components/Files.js
@@ -520,6 +520,17 @@ export function FileSearchFilterButton({size = 'medium'}) {
return
}
+export function DocSearchFilterButton({size = 'medium'}) {
+ const filterOptions = [
+ {key: 'pdf', text: 'PDF', value: 'pdf'},
+ {key: 'epub', text: 'EPUB', value: 'epub'},
+ {key: 'comic', text: 'Comic', value: 'comic'},
+ {key: 'mobi', text: 'MOBI', value: 'mobi'},
+ ];
+
+ return
+}
+
export function FilesSearchView({
showView = true,
emptySearch = false,
diff --git a/app/src/hooks/customHooks.js b/app/src/hooks/customHooks.js
index 07cd1468..4188740c 100644
--- a/app/src/hooks/customHooks.js
+++ b/app/src/hooks/customHooks.js
@@ -536,6 +536,14 @@ export const useSearchArchives = (defaultLimit) => {
}
}
+const docFilterToMimetype = (filter) => {
+ if (filter === 'pdf') return 'application/pdf';
+ if (filter === 'epub') return 'application/epub';
+ if (filter === 'comic') return 'application/x-cb';
+ if (filter === 'mobi') return 'application/x-mobipocket-ebook';
+ return null;
+}
+
export const useSearchDocs = (defaultLimit) => {
const {offset, limit, setLimit, activePage, setPage} = usePages(defaultLimit);
const {searchParams, updateQuery} = React.useContext(QueryContext);
@@ -544,6 +552,7 @@ export const useSearchDocs = (defaultLimit) => {
const activeTags = searchParams.getAll('tag');
const author = searchParams.get('author') || '';
const subject = searchParams.get('subject') || '';
+ const filter = searchParams.get('filter') || '';
const [docs, setDocs] = useState(null);
const [totalPages, setTotalPages] = useState(0);
@@ -552,7 +561,8 @@ export const useSearchDocs = (defaultLimit) => {
setDocs(null);
setTotalPages(0);
try {
- let [docs_, total] = await searchDocs(offset, limit, searchStr, order, activeTags, author, subject);
+ const mimetype = docFilterToMimetype(filter);
+ let [docs_, total] = await searchDocs(offset, limit, searchStr, order, activeTags, author, subject, mimetype);
setDocs(docs_);
setTotalPages(calculateTotalPages(total, limit));
} catch (e) {
@@ -563,7 +573,7 @@ export const useSearchDocs = (defaultLimit) => {
useEffect(() => {
localSearchDocs();
- }, [searchStr, limit, order, offset, JSON.stringify(activeTags), author, subject]);
+ }, [searchStr, limit, order, offset, JSON.stringify(activeTags), author, subject, filter]);
const setSearchStr = (value) => {
updateQuery({q: value, o: 0, order: undefined});