Commit ef6d4d90 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Merge branch '145-search-display-dataset-depending-on-authentication' into 'develop'

Resolve "[Search] Display dataset depending on authentication"

Closes #145

See merge request !157
parents 3a4758cb 773dc6fb
Pipeline #3327 passed with stages
in 10 minutes and 40 seconds
......@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Changed
- #145 => Display public datasets only when no user logged in
- #134 => Result search summary into accordion
- #139 => Datasets selected in search multiple is a configurable option in anis-admin
- #138 => Sort attributes and put scrollbar if table too long in Documentation module
......
......@@ -8,6 +8,7 @@ export interface Dataset {
vo: boolean;
project_name: string;
id_dataset_family: number;
public: boolean;
config: {
cone_search?: {
enabled: boolean;
......
......@@ -24,6 +24,20 @@ describe('[Metamodel] Dataset selector', () => {
expect(datasetSelector.getDatasetList(state).length).toEqual(0);
});
it('should get datasetList if no user logged in', () => {
const state = {
metamodel: {
dataset: {
...fromDataset.initialState,
datasetList: DATASET_LIST
}
}
};
const publicDatasetList: Dataset[] = datasetSelector.getUserAccessibleDatasetList(state, { userLevel: null });
expect(publicDatasetList.length).toEqual(1);
expect(publicDatasetList[0].name).toEqual('cat_1');
});
it('should get datasetList with cone search enabled', () => {
const state = {
metamodel: {
......
......@@ -29,6 +29,14 @@ export const getDatasetList = createSelector(
dataset.getDatasetList
);
export const getUserAccessibleDatasetList = createSelector(
getDatasetList,
// TODO: Change any type
(datasetList: Dataset[], props: { userLevel: any }) => {
return datasetList.filter(d => d.public === true);
}
);
export const getDatasetWithConeSearchList = createSelector(
getDatasetList,
(datasetList: Dataset[]) => {
......
......@@ -3,37 +3,47 @@
<span class="sr-only">Loading...</span>
</div>
<div *ngIf="datasetSearchMetaIsLoaded | async" class="row mt-4">
<div class="col-12 col-md-8 col-lg-9">
<app-dataset-tabs
[projectList]="projectList | async"
[datasetList]="datasetList | async"
[datasetFamilyList]="datasetFamilyList | async"
[datasetSelected]="datasetName | async"
(select)="selectDataset($event)">
</app-dataset-tabs>
</div>
<div class="col-12 col-md-4 col-lg-3 pt-2">
<div *ngIf="attributeListIsLoading | async" class="row justify-content-center mt-5">
<span class="fas fa-circle-notch fa-spin fa-3x"></span>
<span class="sr-only">Loading...</span>
<ng-container *ngIf="(datasetList | async).length === 0">
<div class="col-12 lead text-center">
Oops! No dataset available...
<span *ngIf="!(isUserAuthenticated | async)">
Try to sign in to access to protected datasets.
</span>
</div>
<app-summary *ngIf="attributeListIsLoaded | async"
[currentStep]="currentStep | async"
[datasetName]="datasetName | async"
[datasetList]="datasetList | async"
[criteriaFamilyList]="criteriaFamilyList | async"
[criteriaList]="criteriaList | async"
[attributeList]="attributeList | async"
[outputFamilyList]="outputFamilyList | async"
[categoryList]="categoryList | async"
[outputList]="outputList | async"
[queryParams]="queryParams | async">
</app-summary>
</div>
</ng-container>
<ng-container *ngIf="(datasetList | async).length > 0">
<div class="col-12 col-md-8 col-lg-9">
<app-dataset-tabs
[projectList]="projectList | async"
[datasetList]="datasetList | async"
[datasetFamilyList]="datasetFamilyList | async"
[datasetSelected]="datasetName | async"
(select)="selectDataset($event)">
</app-dataset-tabs>
</div>
<div class="col-12 col-md-4 col-lg-3 pt-2">
<div *ngIf="attributeListIsLoading | async" class="row justify-content-center mt-5">
<span class="fas fa-circle-notch fa-spin fa-3x"></span>
<span class="sr-only">Loading...</span>
</div>
<app-summary *ngIf="attributeListIsLoaded | async"
[currentStep]="currentStep | async"
[datasetName]="datasetName | async"
[datasetList]="datasetList | async"
[criteriaFamilyList]="criteriaFamilyList | async"
[criteriaList]="criteriaList | async"
[attributeList]="attributeList | async"
[outputFamilyList]="outputFamilyList | async"
[categoryList]="categoryList | async"
[outputList]="outputList | async"
[queryParams]="queryParams | async">
</app-summary>
</div>
</ng-container>
</div>
<div *ngIf="datasetName | async" class="row mt-5 justify-content-end">
<div class="col col-auto">
<a routerLink="/search/criteria/{{datasetName | async}}" [queryParams]="queryParams | async"
<a routerLink="/search/criteria/{{ datasetName | async }}" [queryParams]="queryParams | async"
class="btn btn-outline-primary">
Next <span class="fas fa-arrow-right"></span>
</a>
......
......@@ -7,6 +7,8 @@ import * as fromSearch from '../store/search.reducer';
import * as searchActions from '../store/search.action';
import * as searchSelector from '../store/search.selector';
import { Criterion, SearchQueryParams } from '../store/model';
import * as fromLogin from '../../login/store/login.reducer';
import * as loginSelector from '../../login/store/login.selector';
import * as fromMetamodel from '../../metamodel/reducers';
import * as datasetActions from '../../metamodel/action/dataset.action';
import * as attributeActions from '../../metamodel/action/attribute.action';
......@@ -17,8 +19,9 @@ import { Project, Family, Dataset, Attribute, Category } from '../../metamodel/m
import { ScrollTopService } from '../../shared/service/sroll-top.service';
interface StoreState {
search: fromSearch.State;
login: fromLogin.State;
metamodel: fromMetamodel.State;
search: fromSearch.State;
}
@Component({
......@@ -26,6 +29,7 @@ interface StoreState {
templateUrl: 'dataset.component.html'
})
export class DatasetComponent implements OnInit {
public isUserAuthenticated: Observable<boolean>;
public datasetSearchMetaIsLoading: Observable<boolean>;
public datasetSearchMetaIsLoaded: Observable<boolean>;
public attributeListIsLoading: Observable<boolean>;
......@@ -45,10 +49,12 @@ export class DatasetComponent implements OnInit {
public queryParams: Observable<SearchQueryParams>;
constructor(private store: Store<StoreState>, private scrollTopService: ScrollTopService) {
this.isUserAuthenticated = store.select(loginSelector.isAuthenticated);
this.datasetSearchMetaIsLoading = store.select(metamodelSelector.getDatasetSearchMetaIsLoading);
this.datasetSearchMetaIsLoading = store.select(metamodelSelector.getDatasetSearchMetaIsLoading);
this.datasetSearchMetaIsLoaded = store.select(metamodelSelector.getDatasetSearchMetaIsLoaded);
this.projectList = store.select(metamodelSelector.getProjectList);
this.datasetList = store.select(metamodelSelector.getDatasetList);
this.datasetList = store.select(metamodelSelector.getUserAccessibleDatasetList, { userLevel: null });
this.datasetFamilyList = store.select(metamodelSelector.getDatasetFamilyList);
this.currentStep = store.select(searchSelector.getCurrentStep);
this.datasetName = store.select(searchSelector.getDatasetName);
......
......@@ -11,6 +11,7 @@ export const DATASET_LIST: Dataset[] = [
vo: false,
project_name: 'project_1',
id_dataset_family: 1,
public: true,
config: {
cone_search: {
enabled: true,
......@@ -40,6 +41,7 @@ export const DATASET_LIST: Dataset[] = [
vo: false,
project_name: 'project_2',
id_dataset_family: 2,
public: false,
config: {}
},
{
......@@ -52,6 +54,7 @@ export const DATASET_LIST: Dataset[] = [
vo: false,
project_name: 'project_1',
id_dataset_family: 2,
public: false,
config: {}
}
];
......@@ -10,6 +10,7 @@ export const DATASET: Dataset = {
vo: false,
project_name: 'project_1',
id_dataset_family: 1,
public: true,
config: {
cone_search: {
enabled: true,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment