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
549f06f7
Commit
549f06f7
authored
Oct 12, 2020
by
Tifenn Guillas
Browse files
Order datasets by dataset family rather than project => DONE, Tests => DONE
parent
4116e383
Changes
26
Hide whitespace changes
Inline
Side-by-side
src/app/search-multiple/components/datasets/dataset-list.component.html
View file @
549f06f7
<div
class=
"row"
>
<div
*ngFor=
"let
project of getProjec
t()"
class=
"col-12 col-lg-6 col-xl-4 my-3 text-center"
>
<app-datasets-by-
project
[
project]=
"project
"
[datasetList]=
"getDatasetsBy
Project(project.name
)"
<div
*ngFor=
"let
datasetFamily of getDatasetFamilyLis
t()"
class=
"col-12 col-lg-6 col-xl-4 my-3 text-center"
>
<app-datasets-by-
family
[
datasetFamily]=
"datasetFamily
"
[datasetList]=
"getDatasetsBy
Family(datasetFamily.id
)"
[selectedDatasets]=
"selectedDatasets"
[isAllSelected]=
"getIsAllSelected(
project.name
)"
[isAllUnselected]=
"getIsAllUnselected(
project.name
)"
[isAllSelected]=
"getIsAllSelected(
datasetFamily.id
)"
[isAllUnselected]=
"getIsAllUnselected(
datasetFamily.id
)"
(updateSelectedDatasets)=
"updateSelectedDatasets.emit($event)"
>
</app-datasets-by-
project
>
</app-datasets-by-
family
>
</div>
</div>
\ No newline at end of file
src/app/search-multiple/components/datasets/dataset-list.component.spec.ts
View file @
549f06f7
...
...
@@ -2,15 +2,15 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import
{
Component
,
Input
,
ViewChild
}
from
'
@angular/core
'
;
import
{
DatasetListComponent
}
from
'
./dataset-list.component
'
;
import
{
Project
,
Dataset
}
from
'
../../../metamodel/model
'
;
import
{
PROJECT_LIST
,
DATASE
T
}
from
'
../../../../settings/test-data
'
;
import
{
Dataset
,
Family
}
from
'
../../../metamodel/model
'
;
import
{
DATASET
,
DATASET_FAMILY_LIS
T
}
from
'
../../../../settings/test-data
'
;
describe
(
'
[SearchMultiple][Datasets] Component: DatasetListComponent
'
,
()
=>
{
@
Component
({
selector
:
`app-host`
,
template
:
`
<app-dataset-list
[
projectList]="project
List"
[
datasetFamilyList]="datasetFamily
List"
[datasetList]="datasetList"
[selectedDatasets]="selectedDatasets">
</app-dataset-list>`
...
...
@@ -18,14 +18,14 @@ describe('[SearchMultiple][Datasets] Component: DatasetListComponent', () => {
class
TestHostComponent
{
@
ViewChild
(
DatasetListComponent
,
{
static
:
false
})
public
testedComponent
:
DatasetListComponent
;
public
projectList
:
Project
[]
=
PROJECT
_LIST
;
public
datasetFamilyList
:
Family
[]
=
DATASET_FAMILY
_LIST
;
public
datasetList
:
Dataset
[]
=
[
DATASET
];
public
selectedDatasets
:
string
[]
=
[];
}
@
Component
({
selector
:
'
app-datasets-by-
project
'
,
template
:
''
})
@
Component
({
selector
:
'
app-datasets-by-
family
'
,
template
:
''
})
class
DatasetsByProjectStubComponent
{
@
Input
()
project
:
string
;
@
Input
()
datasetFamily
:
number
;
@
Input
()
datasetList
:
Dataset
[];
@
Input
()
selectedDatasets
:
string
[];
@
Input
()
isAllSelected
:
boolean
;
...
...
@@ -54,36 +54,36 @@ describe('[SearchMultiple][Datasets] Component: DatasetListComponent', () => {
expect
(
testedComponent
).
toBeTruthy
();
});
it
(
'
#get
Projec
t() should return sorted project list
'
,
()
=>
{
const
sorted
ProjectList
:
Project
[]
=
testedComponent
.
get
Projec
t
();
expect
(
sorted
Project
List
.
length
).
toBe
(
1
);
expect
(
sorted
Project
List
[
0
].
name
).
toBe
(
'
project_1
'
);
it
(
'
#get
DatasetFamilyLis
t() should return sorted project list
'
,
()
=>
{
const
sorted
DatasetFamilyList
:
Family
[]
=
testedComponent
.
get
DatasetFamilyLis
t
();
expect
(
sorted
DatasetFamily
List
.
length
).
toBe
(
1
);
expect
(
sorted
DatasetFamily
List
[
0
].
label
).
toBe
(
'
Default dataset family
'
);
});
it
(
'
#getDatasetsBy
Project
() should return dataset list for the given
project
'
,
()
=>
{
const
datasetList
:
Dataset
[]
=
testedComponent
.
getDatasetsBy
Project
(
'
project_1
'
);
it
(
'
#getDatasetsBy
Family
() should return dataset list for the given
dataset family
'
,
()
=>
{
const
datasetList
:
Dataset
[]
=
testedComponent
.
getDatasetsBy
Family
(
1
);
expect
(
datasetList
.
length
).
toBe
(
1
);
expect
(
datasetList
[
0
].
name
).
toBe
(
'
cat_1
'
);
});
it
(
'
#getIsAllSelected() should return true if all datasets of the given
project
are selected
'
,
()
=>
{
it
(
'
#getIsAllSelected() should return true if all datasets of the given
dataset family
are selected
'
,
()
=>
{
testHostComponent
.
selectedDatasets
=
[
'
cat_1
'
];
testHostFixture
.
detectChanges
();
expect
(
testedComponent
.
getIsAllSelected
(
'
project_1
'
)).
toBeTruthy
();
expect
(
testedComponent
.
getIsAllSelected
(
1
)).
toBeTruthy
();
});
it
(
'
#getIsAllSelected() should return false if not all datasets of the given
project
are selected
'
,
()
=>
{
expect
(
testedComponent
.
getIsAllSelected
(
'
project_1
'
)).
toBeFalsy
();
it
(
'
#getIsAllSelected() should return false if not all datasets of the given
dataset family
are selected
'
,
()
=>
{
expect
(
testedComponent
.
getIsAllSelected
(
1
)).
toBeFalsy
();
});
it
(
'
#getIsAllUnselected() should return true if all datasets of the given
project
are not selected
'
,
()
=>
{
expect
(
testedComponent
.
getIsAllUnselected
(
'
project_1
'
)).
toBeTruthy
();
it
(
'
#getIsAllUnselected() should return true if all datasets of the given
dataset family
are not selected
'
,
()
=>
{
expect
(
testedComponent
.
getIsAllUnselected
(
1
)).
toBeTruthy
();
});
it
(
'
#getIsAllUnselected() should return false if not all datasets of the given
project
are not selected
'
,
()
=>
{
it
(
'
#getIsAllUnselected() should return false if not all datasets of the given
dataset family
are not selected
'
,
()
=>
{
testHostComponent
.
selectedDatasets
=
[
'
cat_1
'
];
testHostFixture
.
detectChanges
();
expect
(
testedComponent
.
getIsAllUnselected
(
'
project_1
'
)).
toBeFalsy
();
expect
(
testedComponent
.
getIsAllUnselected
(
1
)).
toBeFalsy
();
});
});
src/app/search-multiple/components/datasets/dataset-list.component.ts
View file @
549f06f7
import
{
Component
,
Input
,
Output
,
EventEmitter
,
ChangeDetectionStrategy
}
from
'
@angular/core
'
;
import
{
Dataset
,
Project
}
from
'
../../../metamodel/model
'
;
import
{
Dataset
,
Family
}
from
'
../../../metamodel/model
'
;
import
{
sortByDisplay
}
from
'
../../../shared/utils
'
;
@
Component
({
selector
:
'
app-dataset-list
'
,
...
...
@@ -8,38 +9,38 @@ import { Dataset, Project } from '../../../metamodel/model';
changeDetection
:
ChangeDetectionStrategy
.
OnPush
})
export
class
DatasetListComponent
{
@
Input
()
projectList
:
Project
[];
@
Input
()
datasetFamilyList
:
Family
[];
@
Input
()
datasetList
:
Dataset
[];
@
Input
()
selectedDatasets
:
string
[];
@
Output
()
updateSelectedDatasets
:
EventEmitter
<
string
[]
>
=
new
EventEmitter
();
// Return
project
that contains datasets with cone search enabled
// Return
project
s are sorted by
name
get
Project
():
Project
[]
{
const
projectNames
:
string
[]
=
[];
// Return
dataset families
that contains datasets with cone search enabled
// Return
dataset familie
s are sorted by
display
get
DatasetFamilyList
():
Family
[]
{
const
familyId
:
number
[]
=
[];
this
.
datasetList
.
forEach
(
d
=>
{
if
(
!
projectNames
.
includes
(
d
.
projec
t_
n
am
e
))
{
projectNames
.
push
(
d
.
projec
t_
n
am
e
);
if
(
!
familyId
.
includes
(
d
.
id_datase
t_
f
am
ily
))
{
familyId
.
push
(
d
.
id_datase
t_
f
am
ily
);
}
});
return
[...
this
.
project
List
]
.
filter
(
p
=>
projectNames
.
includes
(
p
.
name
))
.
sort
(
(
a
,
b
)
=>
a
.
name
.
localeCompare
(
b
.
name
)
);
return
this
.
datasetFamily
List
.
filter
(
f
=>
familyId
.
includes
(
f
.
id
))
.
sort
(
sortByDisplay
);
}
getDatasetsBy
Project
(
projectName
:
string
):
Dataset
[]
{
return
this
.
datasetList
.
filter
(
d
=>
d
.
projec
t_
n
am
e
===
projectName
);
getDatasetsBy
Family
(
familyId
:
number
):
Dataset
[]
{
return
this
.
datasetList
.
filter
(
d
=>
d
.
id_datase
t_
f
am
ily
===
familyId
);
}
getIsAllSelected
(
projectName
:
string
):
boolean
{
const
datasetListName
=
this
.
getDatasetsBy
Project
(
projectName
).
map
(
d
=>
d
.
name
);
getIsAllSelected
(
familyId
:
number
):
boolean
{
const
datasetListName
=
this
.
getDatasetsBy
Family
(
familyId
).
map
(
d
=>
d
.
name
);
const
filteredSelectedDatasets
=
this
.
selectedDatasets
.
filter
(
name
=>
datasetListName
.
indexOf
(
name
)
>
-
1
);
return
datasetListName
.
length
===
filteredSelectedDatasets
.
length
;
}
getIsAllUnselected
(
projectName
:
string
):
boolean
{
const
datasetListName
=
this
.
getDatasetsBy
Project
(
projectName
).
map
(
d
=>
d
.
name
);
getIsAllUnselected
(
familyId
:
number
):
boolean
{
const
datasetListName
=
this
.
getDatasetsBy
Family
(
familyId
).
map
(
d
=>
d
.
name
);
const
filteredSelectedDatasets
=
this
.
selectedDatasets
.
filter
(
name
=>
datasetListName
.
indexOf
(
name
)
>
-
1
);
return
filteredSelectedDatasets
.
length
===
0
;
}
...
...
src/app/search-multiple/components/datasets/datasets-by-family.component.css
0 → 100644
View file @
549f06f7
.selectbox
{
height
:
200px
;
overflow-y
:
auto
;
border
:
1px
solid
#ced4da
;
border-radius
:
.25rem
;
}
.letter-spacing
{
letter-spacing
:
2px
;
}
.selectbox
button
:hover
{
background-color
:
#ECECEC
;
}
.selectbox
button
:focus
{
box-shadow
:
none
;
}
\ No newline at end of file
src/app/search-multiple/components/datasets/datasets-by-
project
.component.html
→
src/app/search-multiple/components/datasets/datasets-by-
family
.component.html
View file @
549f06f7
<p
class=
"mb-3"
><em>
{{
project
.label }}
</em></p>
<p
class=
"mb-3"
><em>
{{
datasetFamily
.label }}
</em></p>
<div
class=
"row mb-1"
>
<div
class=
"col pr-1"
>
<button
(click)=
"selectAll()"
[disabled]=
"isAllSelected"
...
...
src/app/search-multiple/components/datasets/datasets-by-
projet
.component.spec.ts
→
src/app/search-multiple/components/datasets/datasets-by-
family
.component.spec.ts
View file @
549f06f7
import
{
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
DatasetsBy
Project
Component
}
from
'
./datasets-by-
project
.component
'
;
import
{
DatasetsBy
Family
Component
}
from
'
./datasets-by-
family
.component
'
;
import
{
Dataset
}
from
'
../../../metamodel/model
'
;
import
{
DATASET_LIST
}
from
'
../../../../settings/test-data
'
;
describe
(
'
[SearchMultiple][Datasets] Component: DatasetsBy
Project
Component
'
,
()
=>
{
let
component
:
DatasetsBy
Project
Component
;
let
fixture
:
ComponentFixture
<
DatasetsBy
Project
Component
>
;
describe
(
'
[SearchMultiple][Datasets] Component: DatasetsBy
Family
Component
'
,
()
=>
{
let
component
:
DatasetsBy
Family
Component
;
let
fixture
:
ComponentFixture
<
DatasetsBy
Family
Component
>
;
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
DatasetsBy
Project
Component
]
declarations
:
[
DatasetsBy
Family
Component
]
});
fixture
=
TestBed
.
createComponent
(
DatasetsBy
Project
Component
);
fixture
=
TestBed
.
createComponent
(
DatasetsBy
Family
Component
);
component
=
fixture
.
componentInstance
;
});
...
...
@@ -20,12 +20,12 @@ describe('[SearchMultiple][Datasets] Component: DatasetsByProjectComponent', ()
expect
(
component
).
toBeTruthy
();
});
it
(
'
#getDatasetSortedByDisplay() should
s
return dataset list sorted by display
'
,
()
=>
{
component
.
datasetList
=
DATASET_LIST
.
filter
(
d
=>
d
.
projec
t_
n
am
e
===
'
project_1
'
);
it
(
'
#getDatasetSortedByDisplay() should return dataset list sorted by display
'
,
()
=>
{
component
.
datasetList
=
DATASET_LIST
.
filter
(
d
=>
d
.
id_datase
t_
f
am
ily
===
2
);
const
sortedDatasetList
:
Dataset
[]
=
component
.
getDatasetSortedByDisplay
();
expect
(
sortedDatasetList
.
length
).
toEqual
(
2
);
expect
(
sortedDatasetList
[
0
].
name
).
toBe
(
'
cat_
1
'
);
expect
(
sortedDatasetList
[
1
].
name
).
toBe
(
'
cat_
2
'
);
expect
(
sortedDatasetList
[
0
].
name
).
toBe
(
'
cat_
2
'
);
expect
(
sortedDatasetList
[
1
].
name
).
toBe
(
'
cat_
3
'
);
});
it
(
'
#isSelected() should return true if the given dataset is selected
'
,
()
=>
{
...
...
@@ -53,16 +53,16 @@ describe('[SearchMultiple][Datasets] Component: DatasetsByProjectComponent', ()
});
it
(
'
#selectAll() should add all datasets to selectedDatasets and raise updateSelectedDatasets event
'
,
()
=>
{
component
.
datasetList
=
DATASET_LIST
.
filter
(
d
=>
d
.
projec
t_
n
am
e
===
'
project_1
'
);
component
.
datasetList
=
DATASET_LIST
.
filter
(
d
=>
d
.
id_datase
t_
f
am
ily
===
2
);
component
.
selectedDatasets
=
[];
const
expectedSelectedDatasets
=
[
'
cat_
1
'
,
'
cat_2
'
];
const
expectedSelectedDatasets
=
[
'
cat_
3
'
,
'
cat_2
'
];
component
.
updateSelectedDatasets
.
subscribe
((
event
:
string
[])
=>
expect
(
event
).
toEqual
(
expectedSelectedDatasets
));
component
.
selectAll
();
});
it
(
'
#unselectAll() should remove all datasets to selectedDatasets and raise updateSelectedDatasets event
'
,
()
=>
{
component
.
datasetList
=
DATASET_LIST
.
filter
(
d
=>
d
.
projec
t_
n
am
e
===
'
project_1
'
);
component
.
selectedDatasets
=
[
'
cat_
1
'
,
'
cat_2
'
];
component
.
datasetList
=
DATASET_LIST
.
filter
(
d
=>
d
.
id_datase
t_
f
am
ily
===
2
);
component
.
selectedDatasets
=
[
'
cat_
3
'
,
'
cat_2
'
];
const
expectedSelectedDatasets
=
[];
component
.
updateSelectedDatasets
.
subscribe
((
event
:
string
[])
=>
expect
(
event
).
toEqual
(
expectedSelectedDatasets
));
component
.
unselectAll
();
...
...
src/app/search-multiple/components/datasets/datasets-by-
project
.component.ts
→
src/app/search-multiple/components/datasets/datasets-by-
family
.component.ts
View file @
549f06f7
import
{
Component
,
Input
,
Output
,
EventEmitter
,
ChangeDetectionStrategy
}
from
'
@angular/core
'
;
import
{
Dataset
,
Project
}
from
'
../../../metamodel/model
'
;
import
{
Dataset
,
Family
}
from
'
../../../metamodel/model
'
;
import
{
sortByDisplay
}
from
'
../../../shared/utils
'
;
@
Component
({
selector
:
'
app-datasets-by-project
'
,
templateUrl
:
'
datasets-by-project.component.html
'
,
selector
:
'
app-datasets-by-family
'
,
templateUrl
:
'
datasets-by-family.component.html
'
,
styleUrls
:
[
'
datasets-by-family.component.css
'
],
changeDetection
:
ChangeDetectionStrategy
.
OnPush
})
export
class
DatasetsBy
Project
Component
{
@
Input
()
project
:
Project
;
export
class
DatasetsBy
Family
Component
{
@
Input
()
datasetFamily
:
Family
;
@
Input
()
datasetList
:
Dataset
[];
@
Input
()
selectedDatasets
:
string
[];
@
Input
()
isAllSelected
:
boolean
;
...
...
src/app/search-multiple/components/index.ts
View file @
549f06f7
import
{
ProgressBarMultipleComponent
}
from
'
./progress-bar-multiple.component
'
;
import
{
SummaryMultipleComponent
}
from
'
./summary-multiple.component
'
;
import
{
DatasetListComponent
}
from
'
./datasets/dataset-list.component
'
;
import
{
DatasetsBy
Project
Component
}
from
'
./datasets/datasets-by-
project
.component
'
;
import
{
DatasetsBy
Family
Component
}
from
'
./datasets/datasets-by-
family
.component
'
;
import
{
OverviewComponent
}
from
'
./result/overview.component
'
;
import
{
DatasetsResultComponent
}
from
'
./result/datasets-result.component
'
;
import
{
DownloadSectionComponent
}
from
"
./result/download-section.component
"
;
...
...
@@ -10,7 +10,7 @@ export const dummiesComponents = [
ProgressBarMultipleComponent
,
SummaryMultipleComponent
,
DatasetListComponent
,
DatasetsBy
Project
Component
,
DatasetsBy
Family
Component
,
OverviewComponent
,
DatasetsResultComponent
,
DownloadSectionComponent
...
...
src/app/search-multiple/components/result/datasets-result.component.html
View file @
549f06f7
...
...
@@ -3,7 +3,7 @@
<ng-container
*ngFor=
"let dataset of getOrderedDatasetWithResults()"
>
<accordion-group
(isOpenChange)=
"loadData($event, dataset.name)"
#ag
[panelClass]=
"'custom-accordion'"
[isOpen]=
"false"
class=
"my-2"
>
<button
class=
"btn btn-link btn-block clearfix"
accordion-heading
>
<
div
class=
"pull-left float-left"
>
<
span
class=
"pull-left float-left"
>
{{ dataset.label }}
<span
class=
"badge badge-pill badge-primary"
>
{{ getCount(dataset.name) }}
</span>
<span
*ngIf=
"getCount(dataset.name) < 2"
>
object found
</span>
...
...
@@ -15,7 +15,7 @@
<span
*ngIf=
"!ag.isOpen"
>
<span
class=
"fas fa-chevron-down"
></span>
</span>
</
div
>
</
span
>
</button>
<div
*ngIf=
"!attributeListIsLoaded(dataset.name)"
class=
"text-center"
>
<span
class=
"fas fa-circle-notch fa-spin fa-3x"
></span>
...
...
src/app/search-multiple/components/result/datasets-result.component.spec.ts
View file @
549f06f7
...
...
@@ -4,7 +4,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import
{
DatasetsResultComponent
}
from
'
./datasets-result.component
'
;
import
{
Attribute
,
Dataset
}
from
'
../../../metamodel/model
'
;
import
{
Pagination
,
PaginationOrder
}
from
'
../../../shared/datatable/model
'
;
import
{
ATTRIBUTE_LIST
,
DATASET_
LIST
,
PROJEC
T_LIST
}
from
'
../../../../settings/test-data
'
;
import
{
ATTRIBUTE_LIST
,
DATASET_
FAMILY_LIST
,
DATASE
T_LIST
}
from
'
../../../../settings/test-data
'
;
describe
(
'
[SearchMultiple][Result] Component: DatasetsResultComponent
'
,
()
=>
{
@
Component
({
selector
:
'
app-datatable
'
,
template
:
''
})
...
...
@@ -36,7 +36,7 @@ describe('[SearchMultiple][Result] Component: DatasetsResultComponent', () => {
});
it
(
'
#getOrderedDatasetWithResults() should return datasetList with results, ordered by project and display
'
,
()
=>
{
component
.
projectList
=
PROJECT
_LIST
;
component
.
datasetFamilyList
=
DATASET_FAMILY
_LIST
;
component
.
datasetList
=
DATASET_LIST
;
component
.
datasetsCount
=
[{
dname
:
'
cat_1
'
,
count
:
1
},
{
dname
:
'
cat_3
'
,
count
:
1
}];
expect
(
component
.
getOrderedDatasetWithResults
().
length
).
toEqual
(
2
);
...
...
src/app/search-multiple/components/result/datasets-result.component.ts
View file @
549f06f7
...
...
@@ -3,10 +3,10 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from
import
{
Dictionary
}
from
'
@ngrx/entity
'
;
import
{
DataByDataset
,
DatasetCount
}
from
'
../../store/model
'
;
import
{
Attribute
,
AttributesByDataset
,
Dataset
,
Project
}
from
'
../../../metamodel/model
'
;
import
{
sortByDisplay
}
from
'
../../../shared/utils
'
;
import
{
Attribute
,
AttributesByDataset
,
Dataset
,
Family
}
from
'
../../../metamodel/model
'
;
import
{
Pagination
,
PaginationOrder
}
from
'
../../../shared/datatable/model
'
;
import
{
ConeSearch
}
from
'
../../../shared/cone-search/store/model
'
;
import
{
sortByDisplay
}
from
'
../../../shared/utils
'
;
@
Component
({
selector
:
'
app-datasets-result
'
,
...
...
@@ -15,7 +15,7 @@ import { ConeSearch } from '../../../shared/cone-search/store/model';
})
export
class
DatasetsResultComponent
{
@
Input
()
datasetsCountIsLoaded
:
boolean
;
@
Input
()
projectList
:
Project
[];
@
Input
()
datasetFamilyList
:
Family
[];
@
Input
()
datasetList
:
Dataset
[];
@
Input
()
coneSearch
:
ConeSearch
;
@
Input
()
selectedDatasets
:
string
[];
...
...
@@ -31,9 +31,9 @@ export class DatasetsResultComponent {
getOrderedDatasetWithResults
():
Dataset
[]
{
let
datasets
:
Dataset
[]
=
[];
const
projectOrderedByName
:
Project
[]
=
[...
this
.
projectList
].
sort
((
a
,
b
)
=>
a
.
name
.
localeCompare
(
b
.
name
)
);
projectOrderedByName
.
forEach
(
p
=>
{
this
.
datasetList
.
filter
(
d
=>
d
.
projec
t_
n
am
e
===
p
.
name
)
const
sortedDatasetFamilyList
:
Family
[]
=
[...
this
.
datasetFamilyList
].
sort
(
sortByDisplay
);
sortedDatasetFamilyList
.
forEach
(
f
=>
{
this
.
datasetList
.
filter
(
d
=>
d
.
id_datase
t_
f
am
ily
===
f
.
id
)
.
sort
(
sortByDisplay
)
.
forEach
(
d
=>
{
this
.
datasetsCount
.
forEach
(
c
=>
{
...
...
src/app/search-multiple/components/result/overview.component.html
View file @
549f06f7
...
...
@@ -17,10 +17,10 @@
<li>
radius = {{ coneSearch.radius }} arcsecond
</li>
</ul>
</div>
<div
*ngFor=
"let
project of getProjectSortedByName
()"
class=
"col-auto"
>
<span
class=
"title"
>
{{
project
.label }}
</span>
<div
*ngFor=
"let
datasetFamily of getSortedDatasetFamilyList
()"
class=
"col-auto"
>
<span
class=
"title"
>
{{
datasetFamily
.label }}
</span>
<ul
class=
"list-unstyled pl-3"
>
<li
*ngFor=
"let dataset of getSelectedDatasetsBy
Project(project.name
)"
>
<li
*ngFor=
"let dataset of getSelectedDatasetsBy
Family(datasetFamily.id
)"
>
{{ dataset.label }}
<span
class=
"badge badge-pill badge-light text-danger"
>
0
</span>
</li>
</ul>
...
...
@@ -55,10 +55,10 @@
<li>
radius = {{ coneSearch.radius }} arcsecond
</li>
</ul>
</div>
<div
*ngFor=
"let
project of getProjectSortedByName
()"
class=
"col-auto"
>
<span
class=
"title"
>
{{
project
.label }}
</span>
<div
*ngFor=
"let
datasetFamily of getSortedDatasetFamilyList
()"
class=
"col-auto"
>
<span
class=
"title"
>
{{
datasetFamily
.label }}
</span>
<ul
class=
"list-unstyled pl-3"
>
<li
*ngFor=
"let dataset of getSelectedDatasetsBy
Project(project.name
)"
>
<li
*ngFor=
"let dataset of getSelectedDatasetsBy
Family(datasetFamily.id
)"
>
{{ dataset.label }}
<span
class=
"badge badge-pill badge-light"
[ngClass]=
"{'text-primary': getCountByDataset(dataset.name) !== 0}"
>
{{ getCountByDataset(dataset.name) }}
...
...
src/app/search-multiple/components/result/overview.component.spec.ts
View file @
549f06f7
...
...
@@ -3,9 +3,9 @@ import { Component, ViewChild } from '@angular/core';
import
{
OverviewComponent
}
from
'
./overview.component
'
;
import
{
DatasetCount
,
SearchMultipleQueryParams
}
from
'
../../store/model
'
;
import
{
Dataset
,
Project
}
from
'
../../../metamodel/model
'
;
import
{
Dataset
,
Family
}
from
'
../../../metamodel/model
'
;
import
{
ConeSearch
}
from
'
../../../shared/cone-search/store/model
'
;
import
{
DATASET_
LIST
,
PROJEC
T_LIST
}
from
'
../../../../settings/test-data
'
;
import
{
DATASET_
FAMILY_LIST
,
DATASE
T_LIST
}
from
'
../../../../settings/test-data
'
;
describe
(
'
[SearchMultiple][Result] Component: OverviewComponent
'
,
()
=>
{
@
Component
({
...
...
@@ -14,7 +14,7 @@ describe('[SearchMultiple][Result] Component: OverviewComponent', () => {
<app-overview
[datasetSearchMetaIsLoaded]='datasetSearchMetaIsLoaded'
[coneSearch]='coneSearch'
[
projectList]='project
List'
[
datasetFamilyList]='datasetFamily
List'
[datasetList]='datasetList'
[selectedDatasets]='selectedDatasets'
[queryParams]='queryParams'
...
...
@@ -27,7 +27,7 @@ describe('[SearchMultiple][Result] Component: OverviewComponent', () => {
public
testedComponent
:
OverviewComponent
;
public
datasetSearchMetaIsLoaded
:
boolean
=
false
;
public
coneSearch
:
ConeSearch
;
public
projectList
:
Project
[]
=
PROJECT
_LIST
;
public
datasetFamilyList
:
Family
[]
=
DATASET_FAMILY
_LIST
;
public
datasetList
:
Dataset
[]
=
DATASET_LIST
;
public
selectedDatasets
:
string
[];
public
queryParams
:
SearchMultipleQueryParams
;
...
...
@@ -64,17 +64,17 @@ describe('[SearchMultiple][Result] Component: OverviewComponent', () => {
expect
(
testedComponent
.
getTotalDatasets
()).
toEqual
(
2
);
});
it
(
'
#get
ProjectSortedByName
() should return sorted
projectL
ist with selected datasets in it
'
,
()
=>
{
it
(
'
#get
SortedDatasetFamilyList
() should return sorted
dataset family l
ist with selected datasets in it
'
,
()
=>
{
testedComponent
.
selectedDatasets
=
[
'
cat_1
'
,
'
cat_2
'
,
'
cat_3
'
];
const
sorted
ProjectList
:
Project
[]
=
testedComponent
.
get
ProjectSortedByName
();
expect
(
sorted
Project
List
.
length
).
toEqual
(
2
);
expect
(
sorted
Project
List
[
0
].
name
).
toBe
(
'
project_1
'
);
expect
(
sorted
Project
List
[
1
].
name
).
toBe
(
'
project_2
'
);
const
sorted
DatasetFamilyList
:
Family
[]
=
testedComponent
.
get
SortedDatasetFamilyList
();
expect
(
sorted
DatasetFamily
List
.
length
).
toEqual
(
2
);
expect
(
sorted
DatasetFamily
List
[
0
].
label
).
toBe
(
'
Default dataset family
'
);
expect
(
sorted
DatasetFamily
List
[
1
].
label
).
toBe
(
'
Another dataset family
'
);
});
it
(
'
#getSelectedDatasetsBy
Project
() should return selected dataset that belongs to the given
project
'
,
()
=>
{
it
(
'
#getSelectedDatasetsBy
Family
() should return selected dataset that belongs to the given
dataset family
'
,
()
=>
{
testedComponent
.
selectedDatasets
=
[
'
cat_1
'
];
const
selectedDatasets
:
Dataset
[]
=
testedComponent
.
getSelectedDatasetsBy
Project
(
'
project_1
'
);
const
selectedDatasets
:
Dataset
[]
=
testedComponent
.
getSelectedDatasetsBy
Family
(
1
);
expect
(
selectedDatasets
.
length
).
toEqual
(
1
);
});
...
...
src/app/search-multiple/components/result/overview.component.ts
View file @
549f06f7
import
{
Component
,
EventEmitter
,
Input
,
Output
}
from
'
@angular/core
'
;
import
{
DatasetCount
,
SearchMultipleQueryParams
}
from
'
../../store/model
'
;
import
{
Dataset
,
Project
}
from
'
../../../metamodel/model
'
;
import
{
Dataset
,
Family
}
from
'
../../../metamodel/model
'
;
import
{
ConeSearch
}
from
'
../../../shared/cone-search/store/model
'
;
import
{
sortByDisplay
}
from
'
../../../shared/utils
'
;
@
Component
({
selector
:
'
app-overview
'
,
...
...
@@ -15,7 +16,7 @@ export class OverviewComponent {
}
}
@
Input
()
coneSearch
:
ConeSearch
;
@
Input
()
projectList
:
Project
[];
@
Input
()
datasetFamilyList
:
Family
[];
@
Input
()
datasetList
:
Dataset
[];
@
Input
()
selectedDatasets
:
string
[];
@
Input
()
queryParams
:
SearchMultipleQueryParams
;
...
...
@@ -36,21 +37,23 @@ export class OverviewComponent {
return
this
.
datasetsCount
.
filter
(
c
=>
c
.
count
>
0
).
length
;
}
getProjectSortedByName
():
Project
[]
{
let
projectWithSelectedDataset
:
Project
[]
=
[];
// Return dataset families that contains datasets with cone search enabled
// Returned dataset families are sorted by display
getSortedDatasetFamilyList
():
Family
[]
{
let
datasetFamiliesWithSelectedDataset
:
Family
[]
=
[];
this
.
selectedDatasets
.
forEach
(
dname
=>
{
const
dataset
:
Dataset
=
this
.
datasetList
.
find
(
d
=>
d
.
name
===
dname
);
const
project
:
Project
=
this
.
project
List
.
find
(
p
=>
p
.
name
===
dataset
.
projec
t_
n
am
e
);
if
(
!
project
WithSelectedDataset
.
includes
(
project
))
{
project
WithSelectedDataset
.
push
(
project
);
const
datasetFamily
:
Family
=
this
.
datasetFamily
List
.
find
(
f
=>
f
.
id
===
dataset
.
id_datase
t_
f
am
ily
);
if
(
!
datasetFamilies
WithSelectedDataset
.
includes
(
datasetFamily
))
{
datasetFamilies
WithSelectedDataset
.
push
(
datasetFamily
);
}
});
return
project
WithSelectedDataset
.
sort
(
(
a
,
b
)
=>
a
.
name
.
localeCompare
(
b
.
name
)
);
return
datasetFamilies
WithSelectedDataset
.
sort
(
sortByDisplay
);
}
getSelectedDatasetsBy
Project
(
projectName
:
string
):
Dataset
[]
{
getSelectedDatasetsBy
Family
(
familyId
:
number
):
Dataset
[]
{
return
this
.
datasetList
.
filter
(
d
=>
d
.
projec
t_
n
am
e
===
projectName
)
.
filter
(
d
=>
d
.
id_datase
t_
f
am
ily
===
familyId
)
.
filter
(
d
=>
this
.
selectedDatasets
.
includes
(
d
.
name
));
}
...
...
src/app/search-multiple/components/summary-multiple.component.html
View file @
549f06f7
...
...
@@ -31,12 +31,12 @@
At least 1 dataset required!
</p>
<div
*ngIf=
"!noSelectedDatasets"
>
<!-- Accordion
project
s -->
<!-- Accordion
Dataset familie
s -->
<accordion
[isAnimated]=
"true"
>
<accordion-group
*ngFor=
"let
project of getProjec
t()"
#ag
panelClass=
"abstract-accordion"
[isOpen]=
"accordion
Project
IsOpen"
class=
"pl-5"
>
<accordion-group
*ngFor=
"let
datasetFamily of getDatasetFamilyLis
t()"
#ag
panelClass=
"abstract-accordion"
[isOpen]=
"accordion
Family
IsOpen"
class=
"pl-5"
>
<button
class=
"btn btn-link btn-block clearfix pb-1 text-primary"
accordion-heading
>
<div
class=
"pull-left float-left"
>
{{
project
.label }}
{{
datasetFamily
.label }}
<span
*ngIf=
"ag.isOpen"
>
<span
class=
"fas fa-chevron-up"
></span>
...
...
@@ -48,8 +48,8 @@
</button>
<!-- Selected Datasets -->
<ul
*ngIf=
"getSelectedDatasetsBy
Project(project.name
).length > 0; else noDataset"
class=
"mb-0 pl-4 list-unstyled"
>
<li
*ngFor=
"let dataset of getSelectedDatasetsBy
Project(project.name
)"
class=
"pb-1"
>
<ul
*ngIf=
"getSelectedDatasetsBy
Family(datasetFamily.id
).length > 0; else noDataset"
class=
"mb-0 pl-4 list-unstyled"
>
<li
*ngFor=
"let dataset of getSelectedDatasetsBy
Family(datasetFamily.id
)"
class=
"pb-1"
>
{{ dataset.label }}
</li>
</ul>
...
...
src/app/search-multiple/components/summary-multiple.component.spec.ts
View file @
549f06f7
...
...
@@ -4,7 +4,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import
{
AccordionModule
}
from
'
ngx-bootstrap/accordion
'
;
import
{
SummaryMultipleComponent
}
from
'
./summary-multiple.component
'
;
import
{
DATASET
,
DATASET_
LIST
,
PROJEC
T_LIST
}
from
'
../../../settings/test-data
'
;
import
{
DATASET
,
DATASET_
FAMILY_LIST
,
DATASE
T_LIST
}
from
'
../../../settings/test-data
'
;
describe
(
'
[SearchMultiple] Component: SummaryMultipleComponent
'
,
()
=>
{
let
component
:
SummaryMultipleComponent
;
...
...
@@ -23,17 +23,17 @@ describe('[SearchMultiple] Component: SummaryMultipleComponent', () => {
expect
(
component
).
toBeTruthy
();
});