Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring

This commit is contained in:
Diamantis Tziotzios 2019-04-03 18:03:04 +03:00
commit bb666d91e4
10 changed files with 48 additions and 18 deletions

View File

@ -46,11 +46,17 @@ public class Projects extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, @RequestParam String fieldsGroup, Principal principal) throws Exception {
System.out.println(fieldsGroup);
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = this.projectManager.getPaged(projectTableRequest, principal, fieldsGroup);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest) throws Exception {
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = this.projectManager.getPublicPaged(projectTableRequest);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<eu.eudat.models.data.project.Project>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {

View File

@ -88,6 +88,22 @@ public class ProjectManager {
return dataTable;
}
public DataTableData<eu.eudat.models.data.project.ProjectListingModel> getPublicPaged(ProjectTableRequest projectTableRequest) throws Exception {
ProjectDao projectRepository = databaseRepository.getProjectDao();
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
QueryableList<eu.eudat.data.entities.Project> pagedItems = PaginationManager.applyPaging(items, projectTableRequest);
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = new DataTableData<>();
CompletableFuture projectsFuture;
projectsFuture = pagedItems.selectAsync(item -> new ProjectListingModel().fromDataModel(item))
.whenComplete((results, throwable) -> {
dataTable.setData(results);
});
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
CompletableFuture.allOf(projectsFuture, countFuture).join();
return dataTable;
}
public eu.eudat.models.data.project.Project getSingle(String id) throws InstantiationException, IllegalAccessException {
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
project.fromDataModel(databaseRepository.getProjectDao().find(UUID.fromString(id)));

View File

@ -29,6 +29,10 @@ export class ProjectService {
}
}
getPublicPaged(dataTableRequest: DataTableRequest<ProjectCriteria>): Observable<DataTableData<ProjectListingModel>> {
return this.http.post<DataTableData<ProjectListingModel>>(this.actionUrl + 'public/paged', dataTableRequest, { headers: this.headers });
}
getWithExternal(requestItem: RequestItem<ProjectCriteria>): Observable<ProjectListingModel[]> {
return this.http.post<ProjectListingModel[]>(this.actionUrl + 'external', requestItem, { headers: this.headers });
}
@ -45,5 +49,4 @@ export class ProjectService {
delete(id: String): Observable<ProjectListingModel> {
return this.http.delete<ProjectListingModel>(this.actionUrl + id, { headers: this.headers });
}
}

View File

@ -2,7 +2,7 @@
<mat-card>
<div>
<mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmp')" placeholder="{{'DATASET-EDITOR.FIELDS.DMP' | translate}}"
<app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmp')" placeholder="{{'DATASET-CREATE-WIZARD.FIRST-STEP.PLACEHOLDER' | translate}}"
[configuration]="dmpAutoCompleteConfiguration">
</app-single-auto-complete>
</mat-form-field>

View File

@ -67,12 +67,12 @@
</mat-form-field>
<mat-form-field class="col-md-12">
<textarea matInput class="description-area"
placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">
placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description">
</textarea>
<!-- <mat-error *ngIf="formGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
translate}}</mat-error>
translate}}</mat-error> -->
</mat-form-field>
<mat-form-field class="col-md-6">
<app-single-auto-complete required='true' [formControl]="formGroup.get('project')"

View File

@ -62,7 +62,7 @@ export class DmpEditorModel {
groupId: [{ value: this.groupId, disabled: disabled }, context.getValidation('groupId').validators],
version: [{ value: this.version, disabled: disabled }, context.getValidation('version').validators],
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
description: [{ value: this.description, disabled: disabled }],
project: [{ value: this.project, disabled: disabled }, context.getValidation('project').validators],
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators],
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],

View File

@ -62,7 +62,7 @@ export class DmpWizardEditorModel {
groupId: [{ value: this.groupId, disabled: disabled }, context.getValidation('groupId').validators],
version: [{ value: this.version, disabled: disabled }, context.getValidation('version').validators],
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
description: [{ value: this.description, disabled: disabled }],
project: [{ value: this.project, disabled: disabled }, context.getValidation('project').validators],
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators],
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],

View File

@ -24,8 +24,8 @@
<mat-form-field class="col-md-12">
<textarea matInput class="description-area"
placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
required></textarea>
placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description">
</textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">

View File

@ -16,6 +16,7 @@ import { ExternalSourcesService } from '../../../core/services/external-sources/
import { ProjectService } from '../../../core/services/project/project.service';
import { RequestItem } from '../../../core/query/request-item';
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
import { AuthService } from '../../../core/services/auth/auth.service';
@Component({
selector: 'app-explore-dataset-filters-component',
@ -60,7 +61,8 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
public projectService: ProjectService,
public languageService: TranslateService,
public datasetProfileService: DatasetService,
public externalSourcesService: ExternalSourcesService
public externalSourcesService: ExternalSourcesService,
private authentication: AuthService,
) { super(); }
ngOnInit() {
@ -96,7 +98,8 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
dataTableRequest.criteria = new ProjectCriteria();
dataTableRequest.criteria.projectStateType = this.facetCriteria.projectStatus;
dataTableRequest.criteria['length'] = 10;
this.projects = this.projectService.getPaged(dataTableRequest, "autocomplete").map(x => x.data);
this.projects = this.projectService.getPublicPaged(dataTableRequest).map(x => x.data);
this.facetCriteria.projects = [];
}
this.facetCriteriaChange.emit(this.facetCriteria);
@ -157,7 +160,8 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
const dataTableRequest: DataTableRequest<ProjectCriteria> = new DataTableRequest(0, null, { fields: fields });
dataTableRequest.criteria = projectCriteria;
//const dataTableRequest: RequestItem<ProjectCriteria> = { criteria: projectCriteria };
return this.projectService.getPaged(dataTableRequest, "autocomplete").map(x => x.data);
//return this.projectService.getPaged(dataTableRequest, "autocomplete").map(x => x.data);
return this.projectService.getPublicPaged(dataTableRequest).map(x => x.data);
}
public dmpOrganisationSearch(value: string): Observable<ExternalSourceItemModel[]> {

View File

@ -482,7 +482,8 @@
"SAVE": "Save"
},
"FIRST-STEP": {
"TITLE": "DMP"
"TITLE": "DMP",
"PLACEHOLDER": "Pick an existing DMP"
}
},
"INVITATION-EDITOR": {