1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Implementing directory search guard #309 #304

Creates a settings that can enable and disable directories in search result
This commit is contained in:
Patrik J. Braun 2021-05-23 22:38:11 +02:00
parent 90aff86485
commit a33f983d16
13 changed files with 137 additions and 16 deletions

View File

@ -181,6 +181,7 @@ export class SearchManager implements ISearchManager {
result.resultOverflow = true;
}
if (Config.Client.Search.listDirectories === true) {
const dirQuery = this.filterDirectoryQuery(query);
if (dirQuery !== null) {
result.directories = await connection
@ -201,6 +202,7 @@ export class SearchManager implements ISearchManager {
result.resultOverflow = true;
}
}
}
return result;
}

View File

@ -29,6 +29,8 @@ export class ClientSearchConfig {
AutoComplete: AutoCompleteConfig = new AutoCompleteConfig();
@ConfigProperty({type: 'unsignedInt'})
maxMediaResult: number = 10000;
@ConfigProperty({description: 'Search returns also with directories, not just media'})
listDirectories: boolean = false;
@ConfigProperty({type: 'unsignedInt'})
maxDirectoryResult: number = 200;
}

View File

@ -44,6 +44,13 @@
required="true">
</app-settings-entry>
<app-settings-entry
name="List directories"
description="Search will also return with directories"
i18n-description i18n-name
[ngModel]="states.listDirectories"
[simplifiedMode]="simplifiedMode">
</app-settings-entry>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximum number of photos and videos that listed in one search result.</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Insert</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>List directories"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>Search will also return with directories"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximum number of photos and videos that listed in one search result.</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Insert</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>List directories"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>Search will also return with directories"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximum number of photos and videos that listed in one search result.</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Insert</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>List directories"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>Search will also return with directories"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximálisan ennyi képet és mappát listáz ki egy keresési eredménnyel</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Beillesztés</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>Mappák listázása"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>A keresési eredmény mappákat is fog tartalmazni"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximum number of photos and videos that listed in one search result.</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Insert</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>List directories"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>Search will also return with directories"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximum number of photos and videos that listed in one search result.</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Insert</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>List directories"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>Search will also return with directories"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximum number of photos and videos that listed in one search result.</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Insert</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>List directories"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>Search will also return with directories"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximum number of photos and videos that listed in one search result.</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Insert</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>List directories"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>Search will also return with directories"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -2772,6 +2772,18 @@
<source>Maximum number of photos and videos that listed in one search result.</source>
<target>Maximum number of photos and videos that listed in one search result.</target>
</trans-unit>
<trans-unit id="3200342440195656274" datatype="html">
<source>Insert</source>
<target>Insert</target>
</trans-unit>
<trans-unit id="5788628366491057479" datatype="html">
<source>List directories"</source>
<target>List directories"</target>
</trans-unit>
<trans-unit id="1627438365479766712" datatype="html">
<source>Search will also return with directories"</source>
<target>Search will also return with directories"</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -117,12 +117,14 @@ describe('SearchManager', (sqlHelper: DBTestHelper) => {
before(async () => {
Config.Client.Search.listDirectories = true;
await setUpSqlDB();
});
after(async () => {
await sqlHelper.clearDB();
Config.Client.Search.listDirectories = false;
});
it('should get autocomplete', async () => {