merging changes

This commit is contained in:
Diamantis Tziotzios 2019-05-17 10:44:16 +03:00
parent 6714ba99ee
commit 151656386a
5 changed files with 10 additions and 341 deletions
dmp-backend/web/src/main/java/eu/eudat/controllers
dmp-frontend/src/app
dataset-profile-form/form
services/datasetProfileAdmin
ui/dmp/listing/criteria

View File

@ -48,17 +48,5 @@ public class DatasetProfiles extends BaseController {
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/datasetprofiles/delete/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id, Principal principal) {
try {
new DatasetProfileManager().delete(this.getApiContext(), id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Dataset Profile Plan"));
} catch (DMPWithDatasetsDeleteException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
}

View File

@ -1,73 +0,0 @@
<div class="container" *ngIf="form" [formGroup]='form'>
<mat-form-field class="full-width">
<input matInput formControlName="label" placeholder="{{'DYNAMIC-FORM.FIELDS.LABEL' | translate}}" required>
<mat-error *ngIf="form.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-horizontal-stepper [linear]="true" #stepper>
<mat-step>
<ng-template matStepLabel>{{'DATASET-PROFILE.PAGES-DESCRIPTION' | translate}}</ng-template>
<div>
<div class="panel-group">
<mat-expansion-panel *ngFor="let page of dataModel.pages; let i=index;" #panel>
<mat-expansion-panel-header>
<mat-panel-title *ngIf="form.get('pages').at(i).get('title').value && !panel.expanded">{{i +
1}}.{{form.get('pages').at(i).get('title').value}}</mat-panel-title>
<div class="btn-group pull-right">
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeletePage(i);">
<span class="glyphicon glyphicon-erase"></span>
</button>
</div>
</mat-expansion-panel-header>
<div id="{{'p' + i}}" *ngIf="panel.expanded">
<div>
<app-page-form [form]="form.get('pages').at(i)" [dataModel]="page"></app-page-form>
</div>
</div>
</mat-expansion-panel>
</div>
<div style="margin-top:20px; padding-left: 15px;" class="row">
<button mat-button (click)="addPage()" style="cursor: pointer">
{{'DYNAMIC-FORM.ACTIONS.ADD-PAGE' | translate}}
</button>
</div>
</div>
</mat-step>
<mat-step>
<ng-template matStepLabel>{{'DATASET-PROFILE.FORM-DESCRIPTION' | translate}}</ng-template>
<div>
<div>
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
<mat-expansion-panel-header>
<mat-panel-title *ngIf="form.get('sections').get(''+i).get('title').value && !panel.expanded">{{i + 1}}.
{{form.get('sections').get(''+i).get('title').value}}</mat-panel-title>
<div class="btn-group pull-right">
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteSection(i);">
<span class="glyphicon glyphicon-erase"></span>
</button>
</div>
</mat-expansion-panel-header>
<div id="{{'s' + i}}" *ngIf="panel.expanded">
<div>
<app-section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="'s' + i"></app-section-form>
</div>
</div>
</mat-expansion-panel>
</div>
<div style="margin-top:20px; padding-left: 15px;" class="row">
<button mat-button (click)="addSection()" style="cursor: pointer">
{{'DYNAMIC-FORM.ACTIONS.ADD-SECTION' | translate}}
</button>
</div>
</div>
</mat-step>
<mat-step>
<ng-template matStepLabel>{{'DATASET-PROFILE.PREVIEW' | translate}}</ng-template>
<div *ngIf='this.isStepActive(2)'>
<app-dynamic-form *ngIf="dataWizardModel && previewerFormGroup" [form]="this.previewerFormGroup" [dataModel]="dataWizardModel"></app-dynamic-form>
</div>
</mat-step>
</mat-horizontal-stepper>
<button mat-raised-button color="primary" type="button" (click)='onSubmit()' [disabled]="!form.valid">{{'DATASET-PROFILE.SAVE' | translate}}</button>
<button mat-raised-button *ngIf="!isNew" color="primary" type="button" (click)="openConfirm(form.get('label').value, form.get('id').value)">{{'DATASET-PROFILE.DELETE' | translate}}</button>
</div>

View File

@ -1,185 +0,0 @@
import { AfterViewInit, Component, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { MatDialog, MatHorizontalStepper } from '@angular/material';
import { ActivatedRoute, Router } from '@angular/router';
import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../core/common/base/base.component';
import { DatasetProfileModelAdmin } from '../../models/datasetProfileAdmin/DatasetProfileModelAdmin';
import { Page } from '../../models/datasetProfileAdmin/Page';
import { Section } from '../../models/datasetProfileAdmin/Section';
import { DatasetProfileDefinitionModel } from '../../models/DatasetProfileDefinitionModel';
import { DatasetWizardModel } from '../../models/datasets/DatasetWizardModel';
import { DatasetProfileService } from '../../services/dataset-profile.service';
import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { TdDialogService } from '@covalent/core';
@Component({
selector: 'app-form-component',
templateUrl: './form.component.html',
providers: [DatasetProfileAdmin, DatasetProfileService],
styleUrls: ['./form.component.scss']
})
export class FormComponent extends BaseComponent implements OnInit, AfterViewInit {
dataModel: DatasetProfileModelAdmin;
form: FormGroup;
previewerFormGroup: FormGroup;
private profileID: string;
private cloneId: string;
dataWizardModel: DatasetWizardModel;
isNew = true;
@ViewChild('stepper') stepper: MatHorizontalStepper;
constructor(
public datasetprofileAdmin: DatasetProfileAdmin,
private datasetProfileService: DatasetProfileService,
private datasetProfileAdminService: DatasetProfileAdmin,
private route: ActivatedRoute,
private router: Router,
private _dialogService: TdDialogService,
private _viewContainerRef: ViewContainerRef,
public dialog: MatDialog,
) {
super();
this.profileID = route.snapshot.params['id'];
this.cloneId = route.snapshot.params['cloneid'];
}
ngAfterViewInit(): void {
console.log(this.stepper);
}
ngOnInit() {
this.dataModel = JsonSerializer.fromJSONObject(new DatasetProfileModelAdmin(), DatasetProfileModelAdmin);
if (this.profileID) {
this.datasetProfileService.getDatasetProfileById(this.profileID)
.pipe(takeUntil(this._destroyed))
.subscribe((data) => {
this.isNew = false;
this.dataModel = JsonSerializer.fromJSONObject(data, DatasetProfileModelAdmin);
this.form = this.dataModel.buildForm();
this.form.valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(change => {
this.datasetProfileAdminService.preview(this.dataModel)
.pipe(takeUntil(this._destroyed))
.subscribe(dataset => {
const datasetModel = new DatasetWizardModel();
datasetModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(dataset, DatasetProfileDefinitionModel);
this.dataWizardModel = datasetModel;
this.previewerFormGroup = <FormGroup>this.dataWizardModel.buildForm().get('datasetProfileDefinition');
});
});
this.form.updateValueAndValidity();
});
} else if (this.cloneId) {
this.datasetprofileAdmin.clone(this.cloneId)
.pipe(takeUntil(this._destroyed))
.subscribe((data) => {
this.isNew = false;
this.dataModel = JsonSerializer.fromJSONObject(data, DatasetProfileModelAdmin);
this.form = this.dataModel.buildForm();
this.form.valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(change => {
this.datasetProfileAdminService.preview(this.dataModel)
.pipe(takeUntil(this._destroyed))
.subscribe(dataset => {
const datasetModel = new DatasetWizardModel();
datasetModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(dataset, DatasetProfileDefinitionModel);
this.dataWizardModel = datasetModel;
this.previewerFormGroup = <FormGroup>this.dataWizardModel.buildForm().get('datasetProfileDefinition');
});
});
this.form.updateValueAndValidity();
});
} else {
this.addSection();
this.addPage();
}
}
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
if (!isMultiplicityEnabled) {
(<FormControl>this.form.get('multiplicity').get('min')).setValue(0);
(<FormControl>this.form.get('multiplicity').get('max')).setValue(0);
}
}
addSection() {
const section: Section = new Section();
this.dataModel.sections.push(section);
(<FormArray>this.form.get('sections')).push(section.buildForm());
}
addPage() {
const page: Page = new Page(this.dataModel.pages.length);
this.dataModel.pages.push(page);
(<FormArray>this.form.get('pages')).push(page.buildForm());
}
DeleteSection(index) {
this.dataModel.sections.splice(index, 1);
(<FormArray>this.form.get('sections')).removeAt(index);
}
DeletePage(index) {
this.dataModel.pages.splice(index, 1);
(<FormArray>this.form.get('pages')).removeAt(index);
}
createForm(data) {
return this.datasetprofileAdmin.createForm(data);
}
updateForm(id, data) {
return this.datasetprofileAdmin.updateForm(id, data);
}
onSubmit() {
const data = this.form.value;
if (this.profileID) {
this.updateForm(this.profileID, data)
.pipe(takeUntil(this._destroyed))
.subscribe(() => {
this.router.navigate(['/dataset-profile']);
});
} else {
this.createForm(data)
.pipe(takeUntil(this._destroyed))
.subscribe(() => {
this.router.navigate(['/dataset-profile']);
});
}
}
isStepActive(step: number) {
return this.stepper && this.stepper.selectedIndex === step;
}
openConfirm(dmpLabel, id): void {
this._dialogService.openConfirm({
message: 'Are you sure you want to delete the "' + dmpLabel + '"',
disableClose: true || false,
viewContainerRef: this._viewContainerRef,
title: 'Confirm',
cancelButton: 'No',
acceptButton: 'Yes'
}).afterClosed()
.pipe(takeUntil(this._destroyed))
.subscribe((accept: boolean) => {
if (accept) {
this.datasetprofileAdmin.delete(id)
.pipe(takeUntil(this._destroyed))
.subscribe(() => {
this.router.navigate(['/datasets']);
});
} else {
// DO SOMETHING ELSE
}
});
}
}

View File

@ -1,55 +0,0 @@
import { HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment';
import { DatasetProfileCriteria } from '../../models/criteria/dataset-profile/DatasetProfileCriteria';
import { DataTableData } from '../../models/data-table/DataTableData';
import { DataTableRequest } from '../../models/data-table/DataTableRequest';
import { DatasetProfileModelAdmin } from '../../models/datasetProfileAdmin/DatasetProfileModelAdmin';
import { DatasetListingModel } from '../../models/datasets/DatasetListingModel';
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
@Injectable()
export class DatasetProfileAdmin {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'admin/';
this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json');
this.headers = this.headers.set('Accept', 'application/json');
}
createForm(data) {
return this.http.post<DatasetProfileModelAdmin>(this.actionUrl + 'addDmp', data, { headers: this.headers });
}
updateForm(id, data) {
return this.http.post<DatasetProfileModelAdmin>(this.actionUrl + 'addDmp/' + id, data, { headers: this.headers });
}
getDatasetProfileById(datasetProfileID) {
return this.http.get<DatasetProfileModelAdmin>(this.actionUrl + 'get/' + datasetProfileID, { headers: this.headers });
}
getPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>): Observable<DataTableData<DatasetListingModel>> {
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest, { headers: this.headers });
}
preview(data: DatasetProfileModelAdmin): Observable<DatasetProfileModelAdmin> {
return this.http.post<DatasetProfileModelAdmin>(this.actionUrl + 'preview', data, { headers: this.headers });
}
clone(id: string): Observable<DatasetProfileModelAdmin> {
return this.http.post<DatasetProfileModelAdmin>(environment.Server + 'datasetprofile/clone/' + id, {}, { headers: this.headers });
}
delete(id: string): Observable<DatasetProfileModelAdmin> {
return this.http.delete<DatasetProfileModelAdmin>(environment.Server + 'datasetprofile/delete/' + id, { headers: this.headers });
}
}

View File

@ -1,28 +1,22 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { FormBuilder, FormControl } from '@angular/forms';
import { MatDialog } from '@angular/material';
import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from 'rxjs/operators';
import { ValidationErrorModel } from '../../../../common/forms/validation/error-model/validation-error-model';
import { DataTableRequest } from '../../../../core/model/data-table/data-table-request';
import { ProjectListingModel } from '../../../../core/model/project/project-listing';
import { DmpCriteria } from '../../../../core/query/dmp/dmp-criteria';
import { ProjectCriteria } from '../../../../core/query/project/project-criteria';
import { ProjectService } from '../../../../core/services/project/project.service';
import { MultipleAutoCompleteConfiguration } from '../../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
import { RequestItem } from '../../../../core/query/request-item';
import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.component';
import { DataTableRequest } from '../../../../core/model/data-table/data-table-request';
import { DmpService } from '../../../../core/services/dmp/dmp.service';
import { MatDialog } from '@angular/material';
import { DmpUploadDialogue } from './upload-dialogue/dmp-upload-dialogue.component';
import { Observable } from 'rxjs';
import { ExternalSourceItemModel } from '../../../../core/model/external-sources/external-source-item';
import { ExternalSourcesService } from '../../../../core/services/external-sources/external-sources.service';
import { OrganisationService } from '../../../../core/services/organisation/organisation.service';
import { OrganisationCriteria } from '../../../../core/query/organisation/organisation-criteria';
import { OrganizationModel } from '../../../../core/model/organisation/organization';
import { DataTableData } from '../../../../core/model/data-table/data-table-data';
import { ProjectCriteria } from '../../../../core/query/project/project-criteria';
import { UserCriteria } from '../../../../core/query/user/user-criteria';
import { DmpService } from '../../../../core/services/dmp/dmp.service';
import { OrganisationService } from '../../../../core/services/organisation/organisation.service';
import { ProjectService } from '../../../../core/services/project/project.service';
import { UserService } from '../../../../core/services/user/user.service';
import { MultipleAutoCompleteConfiguration } from '../../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.component';
import { DmpUploadDialogue } from './upload-dialogue/dmp-upload-dialogue.component';
@Component({
selector: 'app-dmp-criteria-component',