Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stable21' into stable21
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Aug 10, 2021
2 parents 7701286 + b3738c2 commit 281b283
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 10 deletions.
4 changes: 4 additions & 0 deletions css/navigate.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
background-image: url('/apps/fulltextsearch/img/fulltextsearch_black.svg');
}

A.icon-fts {
text-indent: 25px;
}

a.ulsub {
padding: 0px 12px 0 12px !important;
}
Expand Down
2 changes: 1 addition & 1 deletion js/navigate.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Navigate.prototype = {
href: '#',
class: (icon !== undefined) ? icon : 'search_icon'
});
aIcon.text(title);
aIcon.addClass('icon-fts').text(title);

var ul = $('<ul>');
// if (nav.options !== undefined) {
Expand Down
1 change: 1 addition & 0 deletions l10n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ OC.L10N.register(
"fulltextsearch",
{
"the search returned {total} results in {time} ms" : "la recherche a retourné {total} résultats en {time} ms",
"the search in {title} for \"{search}\" returned {total} results in {time} ms" : "La recherche dans {title} pour les mots clés {search} a retourné {total} résultats en {time} ms",
"Search" : "Recherche",
"Index not found" : "Index non trouvé",
"Process timed out" : "Processus expiré",
Expand Down
1 change: 1 addition & 0 deletions l10n/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ "translations": {
"the search returned {total} results in {time} ms" : "la recherche a retourné {total} résultats en {time} ms",
"the search in {title} for \"{search}\" returned {total} results in {time} ms" : "La recherche dans {title} pour les mots clés {search} a retourné {total} résultats en {time} ms",
"Search" : "Recherche",
"Index not found" : "Index non trouvé",
"Process timed out" : "Processus expiré",
Expand Down
1 change: 1 addition & 0 deletions l10n/hr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ OC.L10N.register(
"fulltextsearch",
{
"the search returned {total} results in {time} ms" : "pretraživanjem je pronađeno {total} rezultata za {time} ms",
"the search in {title} for \"{search}\" returned {total} results in {time} ms" : "pretraživanjem u {title} za „{search}“ pronađeno je {total} rezultata za {time} ms",
"Search" : "Traži",
"Index not found" : "Indeks nije pronađen",
"Process timed out" : "Isteklo vrijeme postupka",
Expand Down
1 change: 1 addition & 0 deletions l10n/hr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ "translations": {
"the search returned {total} results in {time} ms" : "pretraživanjem je pronađeno {total} rezultata za {time} ms",
"the search in {title} for \"{search}\" returned {total} results in {time} ms" : "pretraživanjem u {title} za „{search}“ pronađeno je {total} rezultata za {time} ms",
"Search" : "Traži",
"Index not found" : "Indeks nije pronađen",
"Process timed out" : "Isteklo vrijeme postupka",
Expand Down
7 changes: 4 additions & 3 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
use OCP\IServerContainer;
use OCP\IURLGenerator;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Psr\Container\ContainerInterface;
use Throwable;

require_once __DIR__ . '/../../vendor/autoload.php';
Expand Down Expand Up @@ -76,6 +77,7 @@ public function __construct(array $params = []) {
public function register(IRegistrationContext $context): void {
$context->registerCapability(Capabilities::class);
$context->registerSearchProvider(UnifiedSearchProvider::class);
$this->registerServices($this->getContainer());
}

/**
Expand All @@ -84,17 +86,16 @@ public function register(IRegistrationContext $context): void {
* @throws Throwable
*/
public function boot(IBootContext $context): void {
$context->injectFn(Closure::fromCallable([$this, 'registerServices']));
$context->injectFn(Closure::fromCallable([$this, 'registerNavigation']));
}


/**
* Register Navigation Tab
*
* @param IServerContainer $container
* @param ContainerInterface $container
*/
protected function registerServices(IServerContainer $container) {
protected function registerServices(ContainerInterface $container) {
/** @var IFullTextSearchManager $fullTextSearchManager */
$fullTextSearchManager = $container->get(IFullTextSearchManager::class);

Expand Down
13 changes: 11 additions & 2 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use OCP\IUserSession;


/**
Expand All @@ -54,6 +55,9 @@ class ApiController extends Controller {
use TNCDataResponse;


/** @var IUserSession */
private $userSession;

/** @var SearchService */
private $searchService;

Expand All @@ -68,15 +72,19 @@ class ApiController extends Controller {
* NavigationController constructor.
*
* @param IRequest $request
* @param IUserSession $userSession
* @param ConfigService $configService
* @param SearchService $searchService
* @param MiscService $miscService
*/
public function __construct(
IRequest $request, ConfigService $configService, SearchService $searchService,
IRequest $request, IUserSession $userSession, ConfigService $configService,
SearchService $searchService,
MiscService $miscService
) {
parent::__construct(Application::APP_ID, $request);

$this->userSession = $userSession;
$this->searchService = $searchService;
$this->configService = $configService;
$this->miscService = $miscService;
Expand Down Expand Up @@ -117,7 +125,8 @@ public function searchFromRemote(string $request): DataResponse {
*/
private function searchDocuments(SearchRequest $request): DataResponse {
try {
$result = $this->searchService->search('', $request);
$user = $this->userSession->getUser();
$result = $this->searchService->search($user->getUID(), $request);

return $this->success(
$result,
Expand Down
4 changes: 0 additions & 4 deletions lib/Service/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ public function generateSearchRequest(array $request): ISearchRequest {
public function search(string $userId, ISearchRequest $request): array {
$this->searchRequestCannotBeEmpty($request);

if ($userId === '') {
$userId = $this->userId;
}

$user = $this->userManager->get($userId);
if ($user === null) {
throw new NoUserException('User does not exist');
Expand Down

0 comments on commit 281b283

Please sign in to comment.