Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
anis
anis-client
Commits
bff8ac2c
Commit
bff8ac2c
authored
Nov 03, 2020
by
Tifenn Guillas
Browse files
Display public dataset only when no user logged in => DONE
parent
3a4758cb
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/app/metamodel/model/dataset.model.ts
View file @
bff8ac2c
...
...
@@ -8,6 +8,7 @@ export interface Dataset {
vo
:
boolean
;
project_name
:
string
;
id_dataset_family
:
number
;
public
:
boolean
;
config
:
{
cone_search
?:
{
enabled
:
boolean
;
...
...
src/app/metamodel/selectors/dataset.selector.spec.ts
View file @
bff8ac2c
...
...
@@ -3,7 +3,7 @@ import * as fromDataset from '../reducers/dataset.reducer';
import
{
Dataset
}
from
'
../model
'
;
import
{
DATASET_LIST
}
from
'
../../../settings/test-data
'
;
describe
(
'
[Metamodel] Dataset selector
'
,
()
=>
{
f
describe
(
'
[Metamodel] Dataset selector
'
,
()
=>
{
it
(
'
should get datasetSearchMetaIsLoading
'
,
()
=>
{
const
state
=
{
metamodel
:
{
dataset
:
{
...
fromDataset
.
initialState
}}};
expect
(
datasetSelector
.
getDatasetSearchMetaIsLoading
(
state
)).
toBeFalsy
();
...
...
@@ -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
:
{
...
...
src/app/metamodel/selectors/dataset.selector.ts
View file @
bff8ac2c
...
...
@@ -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
[])
=>
{
...
...
src/app/search/containers/dataset.component.html
View file @
bff8ac2c
...
...
@@ -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>
...
...
src/app/search/containers/dataset.component.ts
View file @
bff8ac2c
...
...
@@ -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
.
get
DatasetList
);
this
.
datasetList
=
store
.
select
(
metamodelSelector
.
get
UserAccessibleDatasetList
,
{
userLevel
:
null
}
);
this
.
datasetFamilyList
=
store
.
select
(
metamodelSelector
.
getDatasetFamilyList
);
this
.
currentStep
=
store
.
select
(
searchSelector
.
getCurrentStep
);
this
.
datasetName
=
store
.
select
(
searchSelector
.
getDatasetName
);
...
...
src/settings/test-data/dataset-list.ts
View file @
bff8ac2c
...
...
@@ -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
:
{}
}
];
src/settings/test-data/dataset.ts
View file @
bff8ac2c
...
...
@@ -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
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment