Integrate Public Dataset Listing to regular Dataset Listing

This commit is contained in:
George Kalampokis 2020-03-16 18:50:29 +02:00
parent d34d8a692c
commit 35b89edabc
21 changed files with 275 additions and 30 deletions

View File

@ -2,6 +2,7 @@ package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Dataset;
import eu.eudat.elastic.entities.Tag;
import eu.eudat.types.grant.GrantStateType;
import java.util.Date;
import java.util.List;
@ -22,6 +23,8 @@ public class DatasetCriteria extends Criteria<Dataset> {
private List<UUID> collaborators;
private List<UUID> datasetTemplates;
private List<UUID> groupIds;
private Boolean isPublic;
private Short grantStatus;
public boolean getAllVersions() {
return allVersions;
@ -113,4 +116,20 @@ public class DatasetCriteria extends Criteria<Dataset> {
public void setGroupIds(List<UUID> groupIds) {
this.groupIds = groupIds;
}
public Boolean getIsPublic() {
return isPublic;
}
public void setIsPublic(Boolean isPublic) {
this.isPublic = isPublic;
}
public Short getGrantStatus() {
return grantStatus;
}
public void setGrantStatus(Short grantStatus) {
this.grantStatus = grantStatus;
}
}

View File

@ -10,6 +10,7 @@ import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import eu.eudat.types.grant.GrantStateType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
@ -17,6 +18,7 @@ import org.springframework.stereotype.Component;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@ -30,6 +32,13 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
@Override
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
if (criteria.getIsPublic()) {
query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true));
query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()));
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
}
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.or(
builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
@ -57,6 +66,14 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
query.where((builder, root) -> root.join("dmp").join("organisations").get("reference").in(criteria.getOrganisations()));
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
query.where((builder, root) -> root.join("dmp").join("grant").get("id").in(criteria.getGrants()));
if (criteria.getGrantStatus() != null) {
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
query.where((builder, root) -> builder.lessThan(root.get("dmp").get("grant").get("enddate"), new Date()));
if (criteria.getGrantStatus().equals(GrantStateType.ONGOING.getValue().shortValue()))
query.where((builder, root) ->
builder.or(builder.greaterThan(root.get("dmp").get("grant").get("enddate"), new Date())
, builder.isNull(root.get("dmp").get("grant").get("enddate"))));
}
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty())
query.where((builder, root) -> root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty())

View File

@ -18,7 +18,9 @@ public class DatasetCriteria extends Criteria {
private List<UUID> collaborators;
private Boolean allowAllVersions;
private List<String> organiztions;
public List<Tag> tags;
private List<Tag> tags;
private boolean isPublic;
private Short grantStatus;
public String getLabel() {
return label;
@ -99,4 +101,20 @@ public class DatasetCriteria extends Criteria {
public void setTags(List<Tag> tags) {
this.tags = tags;
}
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
public Short getGrantStatus() {
return grantStatus;
}
public void setGrantStatus(Short grantStatus) {
this.grantStatus = grantStatus;
}
}

View File

@ -54,6 +54,8 @@ public class Dataset implements ElasticEntity<Dataset> {
private List<Collaborator> collaborators;
private Boolean lastVersion;
private List<Organization> organizations;
private Boolean isPublic;
private Short grantStatus;
public String getId() {
return id;
@ -143,6 +145,22 @@ public class Dataset implements ElasticEntity<Dataset> {
this.organizations = organizations;
}
public Boolean getPublic() {
return isPublic;
}
public void setPublic(Boolean aPublic) {
isPublic = aPublic;
}
public Short getGrantStatus() {
return grantStatus;
}
public void setGrantStatus(Short grantStatus) {
this.grantStatus = grantStatus;
}
@Override
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
builder.startObject();
@ -191,6 +209,12 @@ public class Dataset implements ElasticEntity<Dataset> {
});
builder.endArray();
}
if (this.isPublic != null) {
builder.field("public", this.isPublic.toString());
}
if (this.grantStatus != null) {
builder.field("grantStatus", this.grantStatus.toString());
}
builder.endObject();
return builder;
}
@ -215,6 +239,12 @@ public class Dataset implements ElasticEntity<Dataset> {
if (fields.get("organizations") != null) {
this.organizations = ((List<HashMap>) fields.get("organizations")).stream().map(hashMap -> new Organization().fromElasticEntity(hashMap)).collect(Collectors.toList());
}
if (fields.get("public") != null) {
this.isPublic = Boolean.valueOf((String) fields.get("public"));
}
if (fields.get("grantStatus") != null) {
this.grantStatus = Short.valueOf((String) fields.get("grantStatus"));
}
}
return this;
}

View File

@ -58,13 +58,16 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
CountRequest countRequest = new CountRequest("datasets");
countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("status.keyword", Dataset.Status.DELETED.getValue())));
countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", new short[]{Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()})));
CountResponse countResponse = getClient().count(countRequest, RequestOptions.DEFAULT);
Long count = countResponse.getCount();
searchSourceBuilder.size(count.intValue());
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("status.keyword", Dataset.Status.DELETED.getValue()));
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", new short[]{Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()}));
if (criteria.isPublic()) {
boolQuery = boolQuery.should(QueryBuilders.termQuery("public.keyword", "true"));
}
if (criteria.getLabel() != null && !criteria.getLabel().isEmpty()) {
boolQuery = boolQuery.should(QueryBuilders.matchPhrasePrefixQuery("label", criteria.getLabel()));
}
@ -89,6 +92,10 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
boolQuery = boolQuery.should(QueryBuilders.termsQuery("grant.keyword", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getGrantStatus() != null) {
boolQuery = boolQuery.should(QueryBuilders.termQuery("grantStatus.keyword", criteria.getGrantStatus().toString()));
}
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
boolQuery = boolQuery.should(QueryBuilders.termsQuery("collaborators.id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
}

View File

@ -39,7 +39,7 @@ public class Datasets extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) throws Exception {
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}

View File

@ -73,6 +73,7 @@ public class DashBoardManager {
user.setId(principal.getId());
DatasetCriteria datasetCriteria = new DatasetCriteria();
datasetCriteria.setAllVersions(false);
datasetCriteria.setIsPublic(false);
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
dataManagementPlanCriteria.setAllVersions(false);
GrantCriteria grantCriteria = new GrantCriteria();

View File

@ -948,6 +948,8 @@ public class DataManagementPlanManager {
return organization;
}).collect(Collectors.toList()));
}
datasetElastic.setPublic(dataset1.getDmp().isPublic());
datasetElastic.setGrantStatus(dataset1.getDmp().getGrant().getStatus());
try {
apiContext.getOperationsContext().getDatasetRepository().createOrUpdate(datasetElastic);
} catch (IOException e) {
@ -1313,6 +1315,13 @@ public class DataManagementPlanManager {
throw new Exception("DMP is not finalized");
dmp.setPublic(true);
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
dmp.getDataset().forEach(dataset -> {
try {
datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(dataset));
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
});
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
sendNotification(dmp, user, NotificationType.DMP_PUBLISH);
}

View File

@ -121,6 +121,12 @@ public class DatasetManager {
datasetCriteria.setAllowAllVersions(datasetTableRequest.getCriteria().getAllVersions());
datasetCriteria.setOrganiztions(datasetTableRequest.getCriteria().getOrganisations());
datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags());
if (datasetTableRequest.getCriteria().getIsPublic() != null) {
datasetCriteria.setPublic(datasetTableRequest.getCriteria().getIsPublic());
}
if (datasetTableRequest.getCriteria().getGrantStatus() != null) {
datasetCriteria.setGrantStatus(datasetTableRequest.getCriteria().getGrantStatus());
}
List<eu.eudat.elastic.entities.Dataset> datasets;
try {
datasets = datasetRepository.exists() ?
@ -147,9 +153,29 @@ public class DatasetManager {
items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));
}
List<Integer> roles = new LinkedList<>();
if (datasetTableRequest.getCriteria().getRole() != null) roles.add(datasetTableRequest.getCriteria().getRole());
QueryableList<eu.eudat.data.entities.Dataset> authItems = databaseRepository.getDatasetDao().getAuthenticated(items, userInfo, roles);
QueryableList<eu.eudat.data.entities.Dataset> pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
QueryableList<eu.eudat.data.entities.Dataset> pagedItems;
QueryableList<eu.eudat.data.entities.Dataset> authItems;
if (!datasetTableRequest.getCriteria().getIsPublic()) {
if (principal.getId() == null) {
throw new UnauthorisedException();
}
if (datasetTableRequest.getCriteria().getRole() != null)
roles.add(datasetTableRequest.getCriteria().getRole());
authItems = databaseRepository.getDatasetDao().getAuthenticated(items, userInfo, roles);
pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
} else {
if (principal.getId() != null && datasetTableRequest.getCriteria().getRole() != null) {
items.where((builder, root) -> {
Join userJoin = root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT);
return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal.getId()), builder.equal(userJoin.get("role"), datasetTableRequest.getCriteria().getRole()));
});
}
String[] strings = new String[1];
strings[0] = "-dmp:publishedAt|join|";
datasetTableRequest.getOrderings().setFields(strings);
authItems = items;
pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
}
DataTableData<DatasetListingModel> dataTable = new DataTableData<>();
@ -490,7 +516,9 @@ public class DatasetManager {
Dataset dataset1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
datasetWizardModel.setId(dataset1.getId());
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dataset1.getDmp()));
if (datasetWizardModel.getDmp() == null) {
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dataset1.getDmp()));
}
updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel);
if (sendNotification) {
if (dataset1.getStatus() != Dataset.Status.FINALISED.getValue()) {
@ -594,6 +622,8 @@ public class DatasetManager {
return organization;
}).collect(Collectors.toList()));
}
dataset.setPublic(datasetWizardModel.getDmp().getPublic());
dataset.setGrantStatus(datasetWizardModel.getDmp().getGrant().getStatus());
datasetRepository.createOrUpdate(dataset);
// }
}

View File

@ -42,6 +42,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
private String doi;
private Project project;
private Funder funder;
private Boolean isPublic;
public UUID getId() {
return id;
@ -211,6 +212,14 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.funder = funder;
}
public Boolean getPublic() {
return isPublic;
}
public void setPublic(Boolean aPublic) {
isPublic = aPublic;
}
@Override
public DataManagementPlan fromDataModel(DMP entity) {
this.id = entity.getId();
@ -269,6 +278,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.funder = new Funder();
this.funder.fromDataModel(entity.getGrant().getFunder());
}
this.isPublic = entity.isPublic();
return this;
}
@ -308,6 +318,9 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
if (this.dynamicFields != null)
dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
if (this.isPublic != null) {
dataManagementPlanEntity.setPublic(this.isPublic);
}
return dataManagementPlanEntity;
}
@ -358,6 +371,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.funder = new Funder();
this.funder.fromDataModel(entity.getGrant().getFunder());
}
this.isPublic = entity.isPublic();
return this;
}

View File

@ -23,7 +23,8 @@ const appRoutes: Routes = [
},
{
path: 'explore',
loadChildren: () => import('./ui/explore-dataset/explore-dataset.module').then(m => m.ExploreDatasetModule),
// loadChildren: () => import('./ui/explore-dataset/explore-dataset.module').then(m => m.ExploreDatasetModule),
loadChildren: () => import('./ui/dataset/dataset.module').then(m => m.DatasetModule),
data: {
breadcrumb: true,
title: 'GENERAL.TITLES.EXPLORE'

View File

@ -12,4 +12,6 @@ export class DatasetCriteria extends BaseCriteria {
public collaborators?: string[] = [];
public datasetTemplates?: string[] = [];
public groupIds?: string[] = [];
public isPublic?: boolean = false;
public grantStatus?: number;
}

View File

@ -412,7 +412,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
if (!isNullOrUndefined(this.lock)) {
this.lockService.unlockTarget(this.datasetWizardModel.id).pipe(takeUntil(this._destroyed)).subscribe(
complete => {
this.router.navigate(['/datasets']);
this.location.back();
},
error => {
this.formGroup.get('status').setValue(DmpStatus.Draft);
@ -421,7 +421,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
)
} else {
this.router.navigate(['/datasets']);
this.location.back();
}
}

View File

@ -45,7 +45,7 @@ const routes: Routes = [
{
path: '',
component: DatasetListingComponent,
canActivate: [AuthGuard],
// canActivate: [AuthGuard],
data: {
breadcrumb: true
},

View File

@ -13,7 +13,7 @@
<!-- End of Search Filter -->
<!-- Status Filter-->
<div class="col-10 gray-container" >
<div class="col-10 gray-container" *ngIf="!isPublic" >
<h6 class="category-title">{{'CRITERIA.DATA-SETS.STATUS'| translate}}</h6>
<mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('status')">
<mat-list-item><mat-radio-button checked value="null">{{ 'TYPES.DATASET-STATUS.ANY' | translate }}</mat-radio-button></mat-list-item>
@ -23,6 +23,17 @@
</div>
<!-- End of Status Filter-->
<!-- Grant Status -->
<div class="col-10 gray-container" *ngIf="isPublic">
<h6 class="category-title">{{ 'FACET-SEARCH.GRANT-STATUS.TITLE' | translate }}</h6>
<mat-radio-group [formControl]="formGroup.get('grantStatus')">
<mat-list-item><mat-radio-button checked value="null">{{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ANY' | translate }}</mat-radio-button></mat-list-item>
<mat-list-item><mat-radio-button value="0">{{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE' | translate }}</mat-radio-button></mat-list-item>
<mat-list-item><mat-radio-button value="1">{{ 'FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE' | translate }}</mat-radio-button></mat-list-item>
</mat-radio-group>
</div>
<!-- End of Grant Status -->
<!-- Related Dataset Templates Filters -->
<div class="col-10 gray-container">
<h6 class="category-title">{{'CRITERIA.DATA-SETS.RELATED-DATASET-TEMPLATES' | translate}}</h6>
@ -48,7 +59,7 @@
<!-- End of Related DMP Filters -->
<!-- All Versions Filter-->
<div class="col-10 gray-container" >
<div class="col-10 gray-container" *ngIf="!isPublic">
<h6 class="category-title">{{'CRITERIA.DATA-SETS.ALL-VERSIONS'| translate}}</h6>
<mat-slide-toggle [formControl]="formGroup.get('allVersions')"></mat-slide-toggle>
</div>
@ -67,7 +78,7 @@
<!-- End of Related Grants Filters -->
<!-- Related Collaborators Filters -->
<div class="col-10 gray-container">
<div class="col-10 gray-container" *ngIf="!isPublic">
<h6 class="category-title">{{'CRITERIA.DATA-SETS.RELATED-COLLABORATORS' | translate}}</h6>
<mat-form-field>
<app-multiple-auto-complete [formControl]="formGroup.get('collaborators')"
@ -79,7 +90,7 @@
<!-- End of Related Collaborators Filters -->
<!-- Role Filter -->
<div class="col-10 gray-container">
<div class="col-10 gray-container" *ngIf="isAuthenticated()">
<h6 class="category-title">{{'CRITERIA.DATA-SETS.ROLE' | translate }}</h6>
<mat-radio-group aria-label="Select an option" [formControl]="formGroup.get('role')">
<mat-list-item><mat-radio-button checked value="null">{{ 'TYPES.DATASET-ROLE.ANY' | translate }}</mat-radio-button></mat-list-item>

View File

@ -33,6 +33,10 @@ import { ValidationErrorModel } from '@common/forms/validation/error-model/valid
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { AuthService } from '@app/core/services/auth/auth.service';
import { isNullOrUndefined } from 'util';
import { ExploreDmpCriteriaModel } from '@app/core/query/explore-dmp/explore-dmp-criteria';
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
@Component({
selector: 'app-dataset-criteria-component',
@ -43,6 +47,7 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
@Input() dmpSearchEnabled;
@Input() status;
@Input() isPublic: boolean;
public criteria: any;
public filteringTagsAsync = false;
public filteredTags: ExternalSourceItemModel[];
@ -60,7 +65,8 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
collaborators: new FormControl(),
datasetTemplates: new FormControl(),
tags: new FormControl(),
allVersions: new FormControl()
allVersions: new FormControl(),
grantStatus: new FormControl()
});
tagsAutoCompleteConfiguration = {
@ -120,7 +126,9 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
private organisationService: OrganisationService,
private userService: UserService,
private datasetService: DatasetService,
fb: FormBuilder
fb: FormBuilder,
private authService: AuthService
) {
super(new ValidationErrorModel());
// this.options = fb.group({
@ -161,6 +169,9 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
this.formGroup.get('tags').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.controlModified());
this.formGroup.get('grantStatus').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.controlModified());
// if (this.criteria == null) { this.criteria = {}; }
}
@ -174,6 +185,7 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
this.formGroup.get('datasetTemplates').patchValue(criteria.datasetTemplates);
this.formGroup.get('allVersions').patchValue(criteria.allVersions);
this.formGroup.get('tags').patchValue(criteria.tags);
this.formGroup.get('grantStatus').patchValue(criteria.grantStatus);
// this.criteria = criteria;
}
@ -202,22 +214,34 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
return this.externalSourcesService.searchDatasetTags(requestItem);
}
filterDatasetTemplate(query: string) {
filterDatasetTemplate(query: string): Observable<any[]> {
const fields: Array<string> = new Array<string>();
fields.push('asc');
const datasetTemplateRequestItem: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest(0, null, { fields: fields });
datasetTemplateRequestItem.criteria = new DatasetProfileCriteria();
datasetTemplateRequestItem.criteria.like = query;
if (this.isPublic) {
return this.datasetService.getDatasetProfiles(datasetTemplateRequestItem);
} else {
return this.datasetService.getDatasetProfilesUsedPaged(datasetTemplateRequestItem).pipe(map(x => x.data));
}
}
filterDmps(value: string): Observable<DataTableData<DmpListingModel>> {
const fields: Array<string> = new Array<string>();
fields.push('asc');
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, null, { fields: fields });
if (this.isPublic) {
const dmpDataTableRequest: DataTableRequest<ExploreDmpCriteriaModel> = new DataTableRequest(0, null, { fields: fields });
dmpDataTableRequest.criteria = new ExploreDmpCriteriaModel();
dmpDataTableRequest.criteria.like = value;
return this.dmpService.getPublicPaged(dmpDataTableRequest, "autocomplete");
} else {
const dmpDataTableRequest: DataTableRequest<DmpCriteria> = new DataTableRequest(0, null, { fields: fields });
dmpDataTableRequest.criteria = new DmpCriteria();
dmpDataTableRequest.criteria.like = value;
return this.dmpService.getPaged(dmpDataTableRequest, "autocomplete");
}
}
filterGrant(query: string) {
@ -226,7 +250,11 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
const grantRequestItem: DataTableRequest<GrantCriteria> = new DataTableRequest(0, null, { fields: fields });
grantRequestItem.criteria = new GrantCriteria();
grantRequestItem.criteria.like = query;
return this.grantService.getPaged(grantRequestItem, "autocomplete").pipe(map(x => x.data));
if (this.isPublic) {
return this.grantService.getPublicPaged(grantRequestItem).pipe(map(x => x.data));
} else {
return this.grantService.getPaged(grantRequestItem, "autocomplete").pipe(map(x => x.data));
}
}
filterOrganisations(value: string) {
@ -235,7 +263,12 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
const dataTableRequest: DataTableRequest<OrganisationCriteria> = new DataTableRequest(0, null, { fields: fields });
dataTableRequest.criteria = new OrganisationCriteria();
dataTableRequest.criteria.labelLike = value;
return this.organisationService.searchInternalOrganisations(dataTableRequest).pipe(map(x => x.data));
if (this.isPublic) {
return this.organisationService.searchPublicOrganisations(dataTableRequest).pipe(map(x => x.data));
} else {
return this.organisationService.searchInternalOrganisations(dataTableRequest).pipe(map(x => x.data));
}
}
filterCollaborators(query: string) {
@ -279,4 +312,8 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
onCallbackError(error: any) {
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Success);
}
isAuthenticated(): boolean {
return !isNullOrUndefined(this.authService.current());
}
}

View File

@ -1,12 +1,18 @@
<div class="main-content">
<div class="header-image" *ngIf="isPublic">
<div class="header-text-container">
<h3>{{ 'ABOUT.WELCOME' | translate }}</h3>
<h4>{{ 'ABOUT.WELCOME-MESSAGE' | translate }}</h4>
</div>
</div>
<div [ngClass]="isPublic ? 'explore-dmp-content': 'main-content'">
<div class="container-fluid">
<div class="card">
<div class="row card-header card-header-plain d-flex">
<div class="card-header card-header-plain d-flex">
<div class="card-desc d-flex flex-column justify-content-center">
<h4 class="card-title">{{'DASHBOARD.DATASETS' | translate}} {{titlePrefix}}</h4>
<!-- <p class="card-category">{{'DATASET-LISTING.SUBTITLE' | translate}}</p> -->
</div>
<div class="row ml-auto p-2">
<div class="row ml-auto p-2" *ngIf="!isPublic">
<button mat-raised-button color="primary" class="text-uppercase lightblue-btn" [routerLink]="['/datasets/new']">
<mat-icon>add</mat-icon> {{'DATASET-LISTING.ACTIONS.NEW' | translate}}
</button>
@ -15,11 +21,11 @@
<div class="card-body table-responsive">
<div class="listing row pb-2">
<div class="col-12 col-sm-12 col-md-3">
<app-dataset-criteria-component [status]="status" class="col-auto"></app-dataset-criteria-component>
<app-dataset-criteria-component [isPublic]="isPublic" [status]="status" class="col-auto"></app-dataset-criteria-component>
</div>
<div class="col-12 col-sm-12 col-md-9 pt-4">
<div *ngFor="let item of listingItems; let i = index">
<app-dataset-listing-item-component [dataset]="item" [showDivider]="i != (listingItems.length - 1)"></app-dataset-listing-item-component>
<app-dataset-listing-item-component [isPublic]="isPublic" [dataset]="item" [showDivider]="i != (listingItems.length - 1)"></app-dataset-listing-item-component>
</div>
</div>
</div>

View File

@ -11,6 +11,28 @@
}
}
.header-image {
background: url("/assets/images/new-dashboard-bg.png") no-repeat;
background-size: cover;
margin-top: 70px;
min-height: 15em;
position: relative;
}
.header-text-container {
background: rgba(255, 255, 255, 0.7);
position: absolute;
bottom: 0px;
padding-left: 5em;
padding-right: 10em;
padding-top: 2em;
padding-bottom: 2em;
}
.explore-dmp-content {
padding: 30px 15px;
}
::ng-deep .mat-paginator-container {
flex-direction: row-reverse !important;
justify-content: space-between !important;

View File

@ -17,6 +17,8 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable, of as observableOf } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { ExternalTagEditorModel } from '../dataset-wizard/dataset-wizard-editor.model';
import { AuthService } from '@app/core/services/auth/auth.service';
import { isNullOrUndefined } from 'util';
@Component({
selector: 'app-dataset-listing-component',
@ -38,17 +40,24 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
dmpSearchEnabled = true;
listingItems: DatasetListingModel[] = [];
isPublic: boolean = false;
constructor(
private datasetService: DatasetService,
private router: Router,
private route: ActivatedRoute,
private dmpService: DmpService,
private language: TranslateService,
private authService: AuthService
) {
super();
}
ngOnInit() {
this.isPublic = this.router.url === '/explore';
if (!this.isPublic && isNullOrUndefined(this.authService.current())) {
this.router.navigateByUrl("/explore");
}
this.route.params
.pipe(takeUntil(this._destroyed))
.subscribe(async (params: Params) => {
@ -78,7 +87,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
this.breadCrumbs = observableOf([{
parentComponentName: null,
label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'),
url: "/datasets"
url: this.isPublic ? "/explore" : "/datasets"
}]);
}
@ -126,6 +135,13 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
if (value.datasetTemplates) {
request.criteria.datasetTemplates = value.datasetTemplates.map(x => x.id)
}
if(value.grantStatus) {
request.criteria.grantStatus = value.grantStatus;
}
request.criteria.isPublic = this.isPublic;
if (this.isPublic) {
request.criteria.allVersions = true;
}
// if (this.itemId) {
// // request.criteria.groupIds = [this.itemId];
// request.criteria.allVersions = true;

View File

@ -1,5 +1,5 @@
<div class="listing-item" *ngIf="!isDeleted">
<a [routerLink]="['/datasets/edit/' + dataset.id]">
<a [routerLink]="getItemLink()">
<div class="col">
<div class="row">
<div class="col-12 gray-container container-header">
@ -59,7 +59,7 @@
<div matTooltip="{{ dataset.profile }}" class="chip ml-2 mr-2">{{ dataset.profile }}</div>
</div>
</div>
<div class="row">
<div class="row" *ngIf="!isPublic">
<mat-icon matTooltip="{{'DATASET-LISTING.TOOLTIP.VERSION' | translate}}" class="col-auto gray-icon pr-0 pt-2">
history
</mat-icon>

View File

@ -12,6 +12,7 @@ export class DatasetListingItemComponent implements OnInit {
@Input() dataset: DatasetListingModel;
@Input() showDivider: boolean = true;
@Input() isPublic: boolean = false;
@Output() onClick: EventEmitter<DatasetListingModel> = new EventEmitter();
isDraft: boolean;
@ -32,6 +33,10 @@ export class DatasetListingItemComponent implements OnInit {
}
}
getItemLink(): string[] {
return this.isPublic ? [`/datasets/publicEdit/${this.dataset.id}`] : [`/datasets/edit/${this.dataset.id}`];
}
// grantClicked(dataset: DatasetListingModel) {
// this.router.navigate(['/grants/edit/' + dataset.grantId]);