diff --git a/client/src/app/instance/search/components/result/datatable-actions.component.html b/client/src/app/instance/search/components/result/datatable-actions.component.html index a412b0e08dfd57bf0b2a2a6e65dfbf12e54492c8..a1ff010a95fbcfa5304aadb79791f8841c341466 100644 --- a/client/src/app/instance/search/components/result/datatable-actions.component.html +++ b/client/src/app/instance/search/components/result/datatable-actions.component.html @@ -1,4 +1,4 @@ -<div class="btn-group mb-2" dropdown [isDisabled]="selectedData.length < 1"> +<div *ngIf="getDataset().config.datatable.datatable_selectable_rows" class="btn-group mb-2" dropdown [isDisabled]="selectedData.length < 1"> <button id="button-basic" dropdownToggle type="button" class="btn btn-primary dropdown-toggle" aria-controls="dropdown-basic"> Actions <span class="caret"></span> </button> diff --git a/client/src/app/instance/search/components/result/datatable-actions.component.ts b/client/src/app/instance/search/components/result/datatable-actions.component.ts index fcd508e6f621b282e253704f93f56f049d2ea5c9..70e64e95affb137011a054a176925dca4ac946ec 100644 --- a/client/src/app/instance/search/components/result/datatable-actions.component.ts +++ b/client/src/app/instance/search/components/result/datatable-actions.component.ts @@ -31,11 +31,15 @@ export class DatatableActionsComponent { * * @return boolean */ - getConfigDownloadResultFormat(format: string): boolean { - const dataset = this.datasetList.find(d => d.name === this.datasetSelected); + getConfigDownloadResultFormat(format: string): boolean { + const dataset = this.getDataset(); return dataset.config.download[format]; } + getDataset() { + return this.datasetList.find(d => d.name === this.datasetSelected); + } + /** * Returns URL to download file for the given format. * @@ -43,7 +47,7 @@ export class DatatableActionsComponent { * * @return string */ - getUrl(format: string): string { + getUrl(format: string): string { let query: string = `${getHost(this.appConfig.apiUrl)}/search/${this.datasetSelected}?a=${this.outputList.join(';')}`; if (this.criteriaList.length > 0) { query += `&c=${this.criteriaList.map(criterion => criterionToString(criterion)).join(';')};${this.getCriterionSelectedData()}`; diff --git a/server/app/dependencies.php b/server/app/dependencies.php index 2ba1d1681c1f8c71cb792a2c0ff90614ef782108..9fe363d692e79627b5dc6aea9e37acf9bce6371c 100644 --- a/server/app/dependencies.php +++ b/server/app/dependencies.php @@ -203,7 +203,7 @@ $container->set('App\Action\SearchAction', function (ContainerInterface $c) { $container->set('App\Action\ArchiveAction', function (ContainerInterface $c) { $anisQueryBuilder = (new App\Search\Query\AnisQueryBuilder()) ->addQueryPart(new App\Search\Query\From()) - ->addQueryPart(new App\Search\Query\SelectFile()) + ->addQueryPart(new App\Search\Query\Select()) ->addQueryPart(new App\Search\Query\ConeSearch()) ->addQueryPart(new App\Search\Query\Where(new App\Search\Query\Operator\OperatorFactory())) ->addQueryPart(new App\Search\Query\Order()) diff --git a/server/src/Action/ArchiveAction.php b/server/src/Action/ArchiveAction.php index 431a3648685b4d5ae588af229e5448ab0586a0ed..a40045c1d12de8b5c144c003844b6edc6d79902d 100644 --- a/server/src/Action/ArchiveAction.php +++ b/server/src/Action/ArchiveAction.php @@ -150,7 +150,7 @@ final class ArchiveAction extends AbstractAction while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { foreach ($attributesSelected as $attribute) { $attributeLabel = $attribute->getLabel(); - $filePath = $this->dataPath . $dataset->getDataPath() . DIRECTORY_SEPARATOR . $row[$attributeLabel]; + $filePath = $this->dataPath . $dataset->getFullDataPath() . DIRECTORY_SEPARATOR . $row[$attributeLabel]; if (file_exists($filePath)) { $zip->addFile($filePath, $row[$attributeLabel]); } diff --git a/server/src/Search/Query/SelectFile.php b/server/src/Search/Query/SelectFile.php deleted file mode 100644 index 24d71445599a30058f1052b04043752e1fb71fa5..0000000000000000000000000000000000000000 --- a/server/src/Search/Query/SelectFile.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/* - * This file is part of Anis Server. - * - * (c) Laboratoire d'Astrophysique de Marseille / CNRS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -declare(strict_types=1); - -namespace App\Search\Query; - -use App\Entity\Dataset; - -/** - * Represents the Anis Select File attributes Query Part - * - * @author François Agneray <francois.agneray@lam.fr> - * @package App\Search\Query - */ -class SelectFile extends AbstractQueryPart -{ - /** - * Adds the select clause to the request and set only attribute with search_flag = FILE - * - * @param AnisQueryBuilder $anisQueryBuilder Represents the query being built - * @param Dataset $dataset Represents the requested dataset - * @param string[] $queryParams The query params of the url (after ?) - */ - public function __invoke(AnisQueryBuilder $anisQueryBuilder, Dataset $dataset, array $queryParams): void - { - if ($queryParams['a'] === 'all') { - $listOfIds = array_map(fn($attribute) => $attribute->getId(), $dataset->getAttributes()); - } else { - $listOfIds = explode(';', $queryParams['a']); - } - - $columns = array(); - $attributes = array(); - foreach ($listOfIds as $id) { - $attribute = $this->getAttribute($dataset, (int) $id); - if ($attribute->getSearchFlag() === 'FILE') { - $columns[] = $dataset->getTableRef() . '.' . $attribute->getName() . ' as ' . $attribute->getLabel(); - $attributes[] = $attribute; - } - } - $anisQueryBuilder->getDoctrineQueryBuilder()->select($columns); - $anisQueryBuilder->setAttributesSelected($attributes); - } -}