Changed Published dataset descriptions page to include Datatable Criteria in Facet Search Component

This commit is contained in:
Ioannis Kalyvas 2018-10-15 13:17:54 +03:00
parent 099a839e80
commit 6a52950e1d
11 changed files with 156 additions and 111 deletions

View File

@ -1,6 +1,7 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Dataset;
import eu.eudat.elastic.entities.Tag;
import eu.eudat.types.project.ProjectStateType;
import java.util.List;
@ -14,6 +15,7 @@ public class DatasetPublicCriteria extends Criteria<Dataset>{
public List<UUID> projects;
public List<UUID> datasetProfile;
public List<String> dmpOrganisations;
public List<Tag> tags;
public ProjectStateType getProjectStatus() {
return projectStatus;
@ -46,4 +48,12 @@ public class DatasetPublicCriteria extends Criteria<Dataset>{
public void setDmpOrganisations(List<String> dmpOrganisations) {
this.dmpOrganisations = dmpOrganisations;
}
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
}

View File

@ -78,8 +78,20 @@ public class DatasetManager {
}
public DataTableData<DatasetListingModel> getPaged(ApiContext apiContext, DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception {
DatasetCriteria datasetCriteria = new DatasetCriteria();
datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags());
List<eu.eudat.elastic.entities.Dataset> datasets = apiContext.getOperationsContext().getDatasetRepository().exists() ?
apiContext.getOperationsContext().getDatasetRepository().query(datasetCriteria) : new LinkedList<>();
datasetTableRequest.setQuery(apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
QueryableList<eu.eudat.data.entities.Dataset> pagedItems = PaginationManager.applyPaging(datasetTableRequest.applyCriteria(), datasetTableRequest);
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();
if (datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()) {
if (!datasets.isEmpty())
items.where((builder, root) -> root.get("id").in(datasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())));
else
items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
}
QueryableList<eu.eudat.data.entities.Dataset> pagedItems = PaginationManager.applyPaging(items , datasetTableRequest);
DataTableData<DatasetListingModel> dataTable = new DataTableData<>();
CompletableFuture<List<DatasetListingModel>> itemsFuture = pagedItems.

View File

@ -1,97 +1,97 @@
<div class="container ">
<h3 class="text-center">{{'DATASET-PUBLIC-LISTING.TITLE' | translate}} {{titlePrefix}}</h3>
<div class="row">
<div class="col-md-3">
<app-facet (facetCriteriaChange)="onCriteriaChange($event)">
<h3 class="text-center">{{'DATASET-PUBLIC-LISTING.TITLE' | translate}} {{titlePrefix}}</h3>
<div class="row">
<div class="col-md-3">
<app-facet (facetCriteriaChange)="onCriteriaChange($event)">
</app-facet>
</div>
<div class="col-md-9">
<div>
<app-datasets-criteria-component [isPublic]='true'></app-datasets-criteria-component>
<mat-card class="mat-card">
<mat-card-header>
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
</mat-card-header>
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
</app-facet>
</div>
<div class="col-md-9">
<div>
<!-- <app-datasets-criteria-component [isPublic]='true'></app-datasets-criteria-component> -->
<mat-card class="mat-card">
<mat-card-header>
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
</mat-card-header>
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
<!-- Column Definition: Name -->
<ng-container cdkColumnDef="label">
<mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DATASET-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
</ng-container>
<!-- Column Definition: Name -->
<ng-container cdkColumnDef="label">
<mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DATASET-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
</ng-container>
<!-- Column Definition: Dmp -->
<ng-container cdkColumnDef="project">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.PROJECT' |
translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.project}} </mat-cell>
</ng-container>
<!-- Column Definition: Dmp -->
<ng-container cdkColumnDef="project">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.PROJECT' |
translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.project}} </mat-cell>
</ng-container>
<!-- Column Definition: Profile -->
<ng-container cdkColumnDef="profile">
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|profile:label">{{'DATASET-LISTING.COLUMNS.PROFILE'
| translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
</ng-container>
<!-- Column Definition: Profile -->
<ng-container cdkColumnDef="profile">
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|profile:label">{{'DATASET-LISTING.COLUMNS.PROFILE'
| translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
</ng-container>
<!-- Column Definition: Status -->
<ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.status}} </mat-cell>
</ng-container>
<!-- Column Definition: Status -->
<ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.status}} </mat-cell>
</ng-container>
<!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="dataRepositories">
<!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="dataRepositories">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DATAREPOSITORIES' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.dataRepositories}} </mat-cell>
</ng-container> -->
<!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="registries">
<!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="registries">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.REGISTRIES' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.registries}} </mat-cell>
</ng-container> -->
<!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="services">
<!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="services">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.SERVICES' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.services}} </mat-cell>
</ng-container> -->
<!-- Column Definition: Status -->
<!-- <ng-container cdkColumnDef="status">
<!-- Column Definition: Status -->
<!-- <ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.status}}
</mat-cell>
</ng-container> -->
<!-- Column Definition: Description -->
<ng-container cdkColumnDef="description">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.description}} </mat-cell>
</ng-container>
<!-- Column Definition: Description -->
<ng-container cdkColumnDef="description">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.description}} </mat-cell>
</ng-container>
<!-- Column Definition: Created -->
<ng-container cdkColumnDef="created">
<mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DATASET-LISTING.COLUMNS.CREATED' |
translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell>
</ng-container>
<!-- Column Definition: Created -->
<ng-container cdkColumnDef="created">
<mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DATASET-LISTING.COLUMNS.CREATED' |
translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
<!-- (click)="rowClick(row.id)" -->
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
<!-- (click)="rowClick(row.id)" -->
</mat-table>
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
</mat-paginator>
</mat-card>
</mat-table>
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
</mat-paginator>
</mat-card>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -24,7 +24,7 @@ export class DatasetPublicListingComponent implements OnInit {
@ViewChild(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
@ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
criteria: FacetSearchCriteriaModel;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'project', 'profile', 'status', 'description', 'created'];
@ -43,13 +43,10 @@ export class DatasetPublicListingComponent implements OnInit {
}
ngOnInit() {
this.route.params.subscribe(async (params: Params) => {
this.dmpId = params['dmpId'];
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
this.refresh();
this.criteria.setRefreshCallback(() => this.refresh());
if (this.dmpId != null) {
const dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise();
if (params['dmpLabel'] !== undefined) {
@ -59,9 +56,9 @@ export class DatasetPublicListingComponent implements OnInit {
});
}
onCriteriaChange(event) {
onCriteriaChange(event: FacetSearchCriteriaModel) {
//console.log(event)
this.criteria.setCriteria(event);
this.criteria = event;
this.refresh();
}
@ -97,7 +94,7 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
private _sort: MatSort,
private _languageService: TranslateService,
private _snackBar: MatSnackBar,
private _criteria: DatasetCriteriaComponent,
private _criteria: FacetSearchCriteriaModel,
private dmpId: String
) {
super();
@ -121,7 +118,7 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
let fields: Array<string> = new Array();
if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; }
const request = new DataTableRequest<FacetSearchCriteriaModel>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria;
request.criteria = this._criteria;
//if (this.dmpId) request.criteria.allVersions = true;
return this._service.getPublicPaged(request);
})

View File

@ -131,12 +131,12 @@
<div class="right-button">
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' |
translate}}</button>
<button *ngIf="dataManagementPlan.status != 1" mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE'
<button *ngIf="this.formGroup.enabled" mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE'
| translate}}</button>
<button *ngIf="dataManagementPlan.lockable && dataManagementPlan.status != 1" type="button" mat-raised-button
<button *ngIf="dataManagementPlan.lockable && this.formGroup.enabled" type="button" mat-raised-button
color="primary" (click)="saveAndFinalize()">{{'DMP-EDITOR.ACTIONS.FINALISE'
| translate}}</button>
<button *ngIf="!isNew && dataManagementPlan.status != 1" mat-raised-button color="primary" type="button" (click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)">{{'DMP-EDITOR.ACTIONS.DELETE'
<button *ngIf="!isNew && this.formGroup.enabled" mat-raised-button color="primary" type="button" (click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)">{{'DMP-EDITOR.ACTIONS.DELETE'
| translate}}</button>
</div>
</div>

View File

@ -368,6 +368,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadC
} else {
this.dataManagementPlanService.unlock(this.formGroup.get('id').value).subscribe(x => {
this.editMode = true;
this.formGroup.get('status').patchValue(DataManagementPlanStatus.Draft);
this.formGroup.enable();
});
}

View File

@ -1,8 +1,11 @@
import { ProjectStateType } from '../projects/ProjectStateType';
import { BaseCriteria } from '../criteria/BaseCriteria';
import { TagModel } from '../tags/TagModel';
export class FacetSearchCriteriaModel {
export class FacetSearchCriteriaModel extends BaseCriteria {
public projectStatus: ProjectStateType;
public projects: string[] = [];
public datasetProfile: string[] = [];
public dmpOrganisations: string[] = [];
public tags = [];
}

View File

@ -6,28 +6,14 @@
</mat-card-title>
</mat-card-header>
<div class="row">
<!-- <div class="col-sm-6 col-md-2">
<mat-form-field>
<input matInput
(focus)="periodStartPicker.open()"
(click)="periodStartPicker.open()"
placeholder=" {{'CRITERIA.FORMS.PERIOD-FROM'| translate}}"
[matDatepicker]="periodStartPicker"
name="projectCriteriaPeriodStart"
[ngModel]="this.criteria.PeriodStart" (ngModelChange)="controlModified()">
<mat-error *ngIf="getFormControl('created').errors?.backendError">{{baseErrorModel['Criteria.PeriodStart']}}</mat-error>
<mat-datepicker-toggle matSuffix [for]="periodStartPicker"></mat-datepicker-toggle>
<mat-datepicker #periodStartPicker></mat-datepicker>
</mat-form-field>
</div> -->
<div [ngClass]="isPublic ? 'col-md-6' : 'col-md-4'">
<div>
<mat-form-field>
<input matInput placeholder=" {{'CRITERIA.PROJECTS.LIKE'| translate}}" name="datasetCriteriaName" [(ngModel)]="criteria.like"
(ngModelChange)="controlModified()">
<mat-error *ngIf="baseErrorModel['name']">{{baseErrorModel['Criteria.like']}}</mat-error>
</mat-form-field>
</div>
<div *ngIf="!isPublic" class="col-md-4">
<div class="col-md-4">
<mat-form-field>
<mat-select placeholder=" {{'CRITERIA.DATA-SETS.STATUS'| translate}}" name="datasetCriteriastatus" [(ngModel)]="criteria.status"
(ngModelChange)="controlModified()">
@ -38,7 +24,7 @@
<mat-error *ngIf="baseErrorModel['status']">{{baseErrorModel['Criteria.status']}}</mat-error>
</mat-form-field>
</div>
<div [ngClass]="isPublic ? 'col-md-6' : 'col-md-4'">
<div>
<td-chips color="accent" [items]="filteredTags" [(ngModel)]="criteria.tags" (ngModelChange)="controlModified()"
placeholder="{{'CRITERIA.DATA-SETS.TAGS' | translate}}" (inputChange)="filterTags($event)" name="tags"
requireMatch>
@ -57,8 +43,3 @@
</div>
</mat-card>
</form>
<!--matInput
(focus)="periodEndPicker.open()"
(click)="periodEndPicker.open()"
[matDatepicker]="periodEndPicker" -->

View File

@ -23,10 +23,6 @@ import { ExternalSourcesItemModel } from '../../../../models/external-sources/Ex
export class DatasetCriteriaComponent extends BaseCriteriaComponent implements OnInit {
// public form: ProjectType;
// public formStatus: ProjectStatus;
@Input()
public isPublic = false;
public criteria: any;
public filteringTagsAsync = false;
public filteredTags: ExternalSourcesItemModel[];

View File

@ -1,4 +1,32 @@
<mat-accordion #facetAccordion="matAccordion" [multi]="true">
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
</mat-panel-title>
</mat-expansion-panel-header>
<div>
<mat-form-field>
<input matInput placeholder=" {{'CRITERIA.PROJECTS.LIKE'| translate}}" name="datasetCriteriaName" [(ngModel)]="facetCriteria.like"
(ngModelChange)="controlModified()">
</mat-form-field>
</div>
<div>
<td-chips color="accent" [items]="filteredTags" [(ngModel)]="facetCriteria.tags" (ngModelChange)="controlModified()"
placeholder="{{'CRITERIA.DATA-SETS.TAGS' | translate}}" (inputChange)="filterTags($event)" name="tags" requireMatch>
<ng-template td-chip let-chip="chip">
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.name.substring(0, 1).toUpperCase()}}</div>
{{chip.name}}
</ng-template>
<ng-template td-autocomplete-option let-option="option">
<div layout="row" layout-align="start center">
{{option.name}}
</div>
</ng-template>
<mat-progress-bar [style.height.px]="2" *ngIf="filteringTagsAsync" mode="indeterminate"></mat-progress-bar>
</td-chips>
</div>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>

View File

@ -7,19 +7,14 @@ import { ProjectStateType } from '../../../models/projects/ProjectStateType';
import { ProjectModel } from '../../../models/projects/ProjectModel';
import { ProjectService } from '../../../services/project/project.service';
import { ProjectCriteria } from '../../../models/criteria/project/ProjectCriteria';
import { DataTableRequest } from '../../../models/data-table/DataTableRequest';
import { ProjectListingModel } from '../../../models/projects/ProjectListingModel';
import { MatSelectionList, MatListOption, MatSelectionListChange, MatAccordion } from '@angular/material';
import { SelectionModel } from '@angular/cdk/collections';
import { DatasetProfileService } from '../../../services/dataset-profile.service';
import { DatasetService } from '../../../services/dataset/dataset.service';
import { DatasetProfileModel } from '../../../models/datasetprofile/DatasetProfileModel';
import { RequestItem } from '../../../models/criteria/RequestItem';
import { ExternalSourcesService } from '../../../services/external-sources/external-sources.service';
import { ExternalSourcesItemModel } from '../../../models/external-sources/ExternalSourcesItemModel';
import { FormControl } from '@angular/forms';
import { LanguageService } from '../../../services/language/language.service';
import { TranslateService } from '@ngx-translate/core';
import { MatAccordion } from '@angular/material';
import { TagsCriteria } from '../../../models/criteria/tags/TagsCriteria';
@Component({
selector: 'app-facet',
@ -32,6 +27,8 @@ export class FacetSearchComponent implements OnInit, AfterViewInit {
@Input() facetCriteria = new FacetSearchCriteriaModel();
@Output() facetCriteriaChange = new EventEmitter();
public filteringTagsAsync = false;
public filteredTags: ExternalSourcesItemModel[];
ProjectStateType = ProjectStateType;
projects: Observable<ProjectModel[]>;
profiles: Observable<DatasetProfileModel[]>;
@ -157,4 +154,24 @@ export class FacetSearchComponent implements OnInit, AfterViewInit {
public profileSearch(value: string) {
return this.datasetProfileService.getDatasetProfiles();
}
public controlModified() {
this.facetCriteriaChange.emit(this.facetCriteria);
}
filterTags(value: string): void {
this.filteredTags = undefined;
if (value) {
this.filteringTagsAsync = true;
const requestItem: RequestItem<TagsCriteria> = new RequestItem();
const criteria: TagsCriteria = new TagsCriteria();
criteria.like = value;
requestItem.criteria = criteria;
this.externalSourcesService.searchDatasetTags(requestItem).subscribe(items => {
this.filteredTags = items;
this.filteringTagsAsync = false;
});
}
}
}