From fe05ac9770eaf81cba9217ac8a82117ee6154186 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Thu, 24 Sep 2020 17:20:33 +0300 Subject: [PATCH 1/4] jenkins files --- Jenkinsfile | 66 ++++++++++++++++++++++++++++++++++++++ dmp-backend/Dockerfile.CI | 16 +++++++++ dmp-frontend/Dockerfile.CI | 31 ++++++++++++++++++ dmp-frontend/nginx.conf.CI | 28 ++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 Jenkinsfile create mode 100644 dmp-backend/Dockerfile.CI create mode 100644 dmp-frontend/Dockerfile.CI create mode 100644 dmp-frontend/nginx.conf.CI diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..fdaa2a542 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,66 @@ +def pipelineContext = [:] + +pipeline { + agent any + + options { + skipDefaultCheckout(true) + } + + stages { + stage('Checkout') { + steps { + checkout scm + } + } + stage('Build API') { + steps { + script { + pipelineContext.apiImage = docker.build("open-dmp-api:${env.BUILD_ID}", "-f dmp-backend/Dockerfile.CI dmp-backend/") + } + } + } + stage('Build WebApp') { + steps { + script { + pipelineContext.webappImage = docker.build("open-dmp-webapp:${env.BUILD_ID}", "-f dmp-frontend/Dockerfile.CI dmp-frontend/") + } + } + } + stage('SonarQube analysis') { + steps { + script { + def scannerHome = tool 'SonarQube Scanner 4.3'; + withSonarQubeEnv('SonarQube') { // If you have configured more than one global server connection, you can specify its name + sh "${scannerHome}/bin/sonar-scanner" + } + } + } + } + // waiting for sonar results based into the configured web hook in Sonar server which push the status back to jenkins + stage('SonarQube scan result check') { + steps { + timeout(time: 2, unit: 'MINUTES') { + retry(3) { + script { + def qg = waitForQualityGate() + if (qg.status != 'OK') { + error "Pipeline aborted due to quality gate failure: ${qg.status}" + } + } + } + } + } + } + stage('Pushing to Docker Registry') { + steps { + script { + docker.withRegistry('https://registry.home-server', '1e8e4c8e-c709-4475-ab14-8d079a36914a') { + pipelineContext.apiImage.push() + pipelineContext.webappImage.push() + } + } + } + } + } +} \ No newline at end of file diff --git a/dmp-backend/Dockerfile.CI b/dmp-backend/Dockerfile.CI new file mode 100644 index 000000000..323e2ba36 --- /dev/null +++ b/dmp-backend/Dockerfile.CI @@ -0,0 +1,16 @@ +FROM maven:3-jdk-8-alpine AS MAVEN_BUILD + +COPY pom.xml /build/ +COPY data /build/data/ +COPY elastic /build/elastic/ +COPY logging /build/logging/ +COPY queryable /build/queryable/ +COPY web /build/web/ + +WORKDIR /build/ +RUN mvn package + +FROM openjdk:8-jre-alpine +WORKDIR /app +COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app/app.jar +ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-Dspring.profiles.active=${PROF}","-jar","/app.jar"] \ No newline at end of file diff --git a/dmp-frontend/Dockerfile.CI b/dmp-frontend/Dockerfile.CI new file mode 100644 index 000000000..b9d0860ec --- /dev/null +++ b/dmp-frontend/Dockerfile.CI @@ -0,0 +1,31 @@ +# stage1 as builder +FROM node:12-alpine as builder + +# copy the package.json to install dependencies +COPY package.json ./ + +# Install the dependencies and make the folder +RUN npm install && mkdir /src && mv ./node_modules ./src + +WORKDIR /src + +COPY . . + +# Build the project and copy the files +RUN npm run ng build -- --deploy-url=/ --prod + +FROM nginx:alpine + +#!/bin/sh + +COPY nginx.conf.CI /etc/nginx/nginx.conf + +## Remove default nginx index page +RUN rm -rf /usr/share/nginx/html/* + +# Copy from the stahg 1 +COPY --from=builder /src/dist /usr/share/nginx/html + +EXPOSE 8080 + +ENTRYPOINT ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/dmp-frontend/nginx.conf.CI b/dmp-frontend/nginx.conf.CI new file mode 100644 index 000000000..63cee1859 --- /dev/null +++ b/dmp-frontend/nginx.conf.CI @@ -0,0 +1,28 @@ +server { + + listen 8080; + + sendfile on; + + default_type application/octet-stream; + + + gzip on; + gzip_http_version 1.1; + gzip_disable "MSIE [1-6]\."; + gzip_min_length 1100; + gzip_vary on; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; + gzip_comp_level 9; + + + root /usr/share/nginx/html; + + + location / { + try_files $uri $uri/ /index.html =404; + add_header Cache-Control "no-store, no-cache, must-revalidate"; + } + +} \ No newline at end of file From 28feacc7effd8ef9fedfc264d8fdee0c95c24704 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Thu, 24 Sep 2020 17:25:08 +0300 Subject: [PATCH 2/4] CI Update --- dmp-backend/Dockerfile.CI | 1 - 1 file changed, 1 deletion(-) diff --git a/dmp-backend/Dockerfile.CI b/dmp-backend/Dockerfile.CI index 323e2ba36..944713adf 100644 --- a/dmp-backend/Dockerfile.CI +++ b/dmp-backend/Dockerfile.CI @@ -3,7 +3,6 @@ FROM maven:3-jdk-8-alpine AS MAVEN_BUILD COPY pom.xml /build/ COPY data /build/data/ COPY elastic /build/elastic/ -COPY logging /build/logging/ COPY queryable /build/queryable/ COPY web /build/web/ From 38f550542a0646acc548f812c330d071c98b22b0 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Thu, 24 Sep 2020 17:37:32 +0300 Subject: [PATCH 3/4] CI update --- Jenkinsfile | 52 +++++++++++++++++++------------------- dmp-frontend/tsconfig.json | 1 + 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fdaa2a542..40de9c9ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,35 +27,35 @@ pipeline { } } } - stage('SonarQube analysis') { - steps { - script { - def scannerHome = tool 'SonarQube Scanner 4.3'; - withSonarQubeEnv('SonarQube') { // If you have configured more than one global server connection, you can specify its name - sh "${scannerHome}/bin/sonar-scanner" - } - } - } - } - // waiting for sonar results based into the configured web hook in Sonar server which push the status back to jenkins - stage('SonarQube scan result check') { - steps { - timeout(time: 2, unit: 'MINUTES') { - retry(3) { - script { - def qg = waitForQualityGate() - if (qg.status != 'OK') { - error "Pipeline aborted due to quality gate failure: ${qg.status}" - } - } - } - } - } - } + //stage('SonarQube analysis') { + // steps { + // script { + // def scannerHome = tool 'SonarQube Scanner 4.3'; + // withSonarQubeEnv('SonarQube') { // If you have configured more than one global server connection, you can specify its name + // sh "${scannerHome}/bin/sonar-scanner" + // } + // } + // } + //} + //// waiting for sonar results based into the configured web hook in Sonar server which push the status back to jenkins + //stage('SonarQube scan result check') { + // steps { + // timeout(time: 2, unit: 'MINUTES') { + // retry(3) { + // script { + // def qg = waitForQualityGate() + // if (qg.status != 'OK') { + // error "Pipeline aborted due to quality gate failure: ${qg.status}" + // } + // } + // } + // } + // } + //} stage('Pushing to Docker Registry') { steps { script { - docker.withRegistry('https://registry.home-server', '1e8e4c8e-c709-4475-ab14-8d079a36914a') { + docker.withRegistry('http://drepo.local.cite.gr', 'b2c651c1-9a3b-4a98-a6da-e1dd7a20f512') { pipelineContext.apiImage.push() pipelineContext.webappImage.push() } diff --git a/dmp-frontend/tsconfig.json b/dmp-frontend/tsconfig.json index 5d5ba689a..4d05665e4 100644 --- a/dmp-frontend/tsconfig.json +++ b/dmp-frontend/tsconfig.json @@ -10,6 +10,7 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "importHelpers": true, + "skipLibCheck": true, "target": "es2015", "typeRoots": [ "node_modules/@types" From 1caa40988d7a890d0cc894eeb998bc9a4c011db4 Mon Sep 17 00:00:00 2001 From: apapachristou Date: Thu, 24 Sep 2020 20:28:03 +0300 Subject: [PATCH 4/4] Restyles navigation buttons on editors, fixes bugs on discard changes on editors --- .../dataset-wizard.component.html | 7 +- .../app/ui/dmp/clone/dmp-clone.component.html | 2 +- .../app/ui/dmp/clone/dmp-clone.component.ts | 1 - dmp-frontend/src/app/ui/dmp/dmp.routing.ts | 36 ++--- .../dataset-editor-details.component.ts | 35 +++-- .../dataset-info/dataset-info.component.html | 10 +- .../dataset-info/dataset-info.component.ts | 35 +++-- .../ui/dmp/editor/dmp-editor.component.html | 98 +++--------- .../ui/dmp/editor/dmp-editor.component.scss | 6 + .../app/ui/dmp/editor/dmp-editor.component.ts | 143 ++++++++++-------- .../funding-info/funding-info.component.ts | 2 +- .../license-info/license-info.component.html | 12 +- .../license-info/license-info.component.ts | 3 +- .../editor/main-info/main-info.component.html | 13 +- .../editor/main-info/main-info.component.ts | 1 - .../dataset-description.component.ts | 14 +- .../table-of-contents.ts | 10 ++ 17 files changed, 189 insertions(+), 239 deletions(-) diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html index 79df062ed..ffbcc85c4 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html @@ -65,13 +65,12 @@ chevron_right
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
-
+
chevron_right
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
-
- add -
{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}
+
+
{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-ADD' | translate }}
diff --git a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.html b/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.html index 718543659..d98386bf5 100644 --- a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.html +++ b/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.html @@ -102,7 +102,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.ts b/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.ts index 1b26ef930..3c1092e6f 100644 --- a/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.ts +++ b/dmp-frontend/src/app/ui/dmp/clone/dmp-clone.component.ts @@ -48,7 +48,6 @@ export class DmpCloneComponent extends BaseComponent implements OnInit { isPublic: false; parentDmpLabel: string; isNewVersion: boolean = false; - isNewDataset: boolean = false; isClone: boolean = true; isNew: boolean = false; isUserOwner: boolean = true; diff --git a/dmp-frontend/src/app/ui/dmp/dmp.routing.ts b/dmp-frontend/src/app/ui/dmp/dmp.routing.ts index 05e858695..b3b8574f7 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp.routing.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp.routing.ts @@ -80,24 +80,24 @@ const routes: Routes = [ title: 'GENERAL.TITLES.DMP-NEW' } }, - { - path: 'new/dataset', - component: DmpEditorComponent, - canActivate: [AuthGuard], - data: { - breadcrumbs: 'new/dataset', - title: 'GENERAL.TITLES.DATASET-NEW' - } - }, - { - path: 'new/dataset/:dmpId', - component: DmpEditorComponent, - canActivate: [AuthGuard], - data: { - breadcrumbs: 'new/dataset', - title: 'GENERAL.TITLES.DATASET-NEW' - } - }, + // { + // path: 'new/dataset', + // component: DmpEditorComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumbs: 'new/dataset', + // title: 'GENERAL.TITLES.DATASET-NEW' + // } + // }, + // { + // path: 'new/dataset/:dmpId', + // component: DmpEditorComponent, + // canActivate: [AuthGuard], + // data: { + // breadcrumbs: 'new/dataset', + // title: 'GENERAL.TITLES.DATASET-NEW' + // } + // }, { path: 'new_version/:id', // component: DmpWizardComponent, diff --git a/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.ts index fe0262629..332354b43 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.ts @@ -67,7 +67,6 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn @Input() formGroup: FormGroup; @Input() dmpId: string; @Input() datasetId: string; - @Input() isNewDataset: boolean; @Input() availableProfiles: DatasetProfileModel[]; @Output() formChanged: EventEmitter = new EventEmitter(); readonly separatorKeysCodes: number[] = [ENTER, COMMA]; @@ -103,9 +102,9 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn this.datasetWizardModel = new DatasetWizardEditorModel(); this.registerFormListeners(); - if (this.isNewDataset) { - this.loadDatasetProfiles(); - } + // if (this.isNewDataset) { + // this.loadDatasetProfiles(); + // } this.profilesAutoCompleteConfiguration = { filterFn: this.filterProfiles.bind(this), @@ -198,20 +197,20 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn } registerFormListeners() { - this.formGroup.get('dmp').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.dmpValueChanged(x); - }); + // this.formGroup.get('dmp').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.dmpValueChanged(x); + // }); // if (this.isNewDataset) { - this.formGroup.get('profile').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - if (!isNullOrUndefined(x)) { - this.datasetProfileValueChanged(x.id); - } - }); + // this.formGroup.get('profile').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // if (!isNullOrUndefined(x)) { + // this.datasetProfileValueChanged(x.id); + // } + // }); // } } @@ -239,12 +238,12 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn this.formGroup.valueChanges .pipe(takeUntil(this._destroyed)) .subscribe(val => { - this.formChanged.emit(val); + // this.formChanged.emit(val); }); } onFormChanged(event) { - this.formChanged.emit(event); + // this.formChanged.emit(event); } getDefinition(profileId: string) { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.html b/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.html index 4fd69a994..bb630698e 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.html @@ -12,7 +12,7 @@
info {{'DMP-EDITOR.MAIN-INFO.TYPING' | translate}}
- + @@ -23,14 +23,6 @@ view_list - - - - {{profile.label}} - - - {{formGroup.get('profile').getError('backendError').message}} -
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.HELP' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.ts index a7ec8a171..f1b724541 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.ts @@ -40,7 +40,6 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit { @Input() isPublic: boolean; @Input() isFinalized: boolean; @Input() isNewVersion: boolean; - @Input() isNewDataset: boolean; @Input() isClone: boolean; @Output() onFormChanged: EventEmitter = new EventEmitter(); @@ -99,23 +98,23 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit { subtitleFn: (item) => item['description'] }; } - if (this.formGroup.get('datasets')['controls'][0]) { - this.formGroup.get('datasets')['controls'][0].get('dmp').valueChanges.pipe(takeUntil(this._destroyed)) - .subscribe(x => { - // this.registerFormListeners(); - if (this.formGroup.get('datasets')['controls'][0].get('dmp').value) { - this.loadDatasetProfiles(); - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'], - subtitleFn: (item) => item['description'] - }; - this.onFormChanged.emit(); - } - }); - } + // if (this.formGroup.get('datasets')['controls'][0]) { + // this.formGroup.get('datasets')['controls'][0].get('dmp').valueChanges.pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // //this.registerFormListeners(); + // if (this.formGroup.get('datasets')['controls'][0].get('dmp').value) { + // this.loadDatasetProfiles(); + // this.profilesAutoCompleteConfiguration = { + // filterFn: this.filterProfiles.bind(this), + // initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), + // displayFn: (item) => item['label'], + // titleFn: (item) => item['label'], + // subtitleFn: (item) => item['description'] + // }; + // this.onFormChanged.emit(); + // } + // }); + // } } // Researchers diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html index b1e6b11ce..2e535a1d5 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html @@ -2,7 +2,7 @@
-
+
@@ -28,113 +28,57 @@
- -
-
-
-
-
-
{{'DMP-EDITOR.TITLE.EDIT-DATASET' | translate}}
-
{{ dataset.get('label').value }} ({{'DMP-EDITOR.CHANGES' | translate}})
-
-
{{'DATASET-LISTING.TOOLTIP.PART-OF' | translate}} -
{{'DATASET-LISTING.TOOLTIP.DMP' | translate}}
-
-
{{ formGroup.get('label').value }}
- -
-
-
-
{{'DMP-EDITOR.TITLE.CREATE-DATASET' | translate}}
-
{{'DMP-EDITOR.TITLE.ADD-DATASET' | translate}} {{formGroup.get('datasets')['controls'][0].get('dmp').value.label}}
-
-
-
- -
-
- - - -
-
-
-
-
-
-
+
{{'DMP-EDITOR.STEPPER.USER-GUIDE' | translate}}
    -
  1. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (4)
  2. -
  3. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}}
  4. - -
  5. {{'DMP-EDITOR.STEPPER.FUNDING-INFO' | translate}} (3)
  6. - -
  7. {{'DMP-EDITOR.STEPPER.LICENSE-INFO' | translate}} (5)
  8. - -
  9. {{'DMP-EDITOR.STEPPER.DATASET-INFO' | translate}}
  10. -
  11. {{'DMP-EDITOR.STEPPER.DATASET-INFO' | translate}}
  12. +
  13. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (4)
  14. +
  15. {{'DMP-EDITOR.STEPPER.FUNDING-INFO' | translate}} (3)
  16. +
  17. {{'DMP-EDITOR.STEPPER.LICENSE-INFO' | translate}} (5)
  18. +
  19. {{'DMP-EDITOR.STEPPER.DATASET-INFO' | translate}}
  20. -
  21. +
  22. {{'DMP-EDITOR.STEPPER.DATASET' | translate}}: {{ dataset.get('label').value }}
    - close + close check
    -
- +
-
+
chevron_right
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
-
- chevron_right -
{{'DMP-EDITOR.STEPPER.NEXT' | translate}}
-
-
- add -
{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}
+ +
+ +
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}} & {{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}
- - - - - - - - + + + +
- +
diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss index 67566b300..7126fa67e 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss @@ -351,6 +351,12 @@ mat-icon.size-16 { cursor: pointer; } +.add-dataset-action { + display: flex; + align-items: center; + cursor: pointer; +} + .next { background: #129d99 0% 0% no-repeat padding-box; color: white; diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 74e29e842..ee934b36f 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -67,7 +67,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC isFinalized = false; hasChanges = false; isDiscarded = false; - isNewDataset = false; hasDmpId = false; isUserOwner: boolean = true; @@ -115,11 +114,11 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC } ngOnInit() { - if (this.router.url.toString().includes('/new/dataset')) { - this.isNewDataset = true; - this.stepsBeforeDatasets = 2; - this.maxStep = 2; - }; + // if (this.router.url.toString().includes('/new/dataset')) { + // this.isNewDataset = true; + // this.stepsBeforeDatasets = 2; + // this.maxStep = 2; + // }; this.route.params .pipe(takeUntil(this._destroyed)) .subscribe((params: Params) => { @@ -222,6 +221,10 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC } this.associatedUsers = data.associatedUsers; this.people = data.users; + this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); + }); }) }); } else if (publicId != null) { @@ -276,46 +279,57 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC // }); // } // }) - }); - } else if (this.isNewDataset) { - this.dmp = new DmpEditorModel(); - this.dmp.grant = new GrantTabModel(); - this.dmp.project = new ProjectFormModel(); - this.dmp.funder = new FunderFormModel(); - this.dmp.extraProperties = new ExtraPropertiesFormModel(); - this.dmp.extraProperties.visible = false; - this.dmp.extraProperties.contact = this.authService.current().id; - this.datasetWizardEditorModel = new DatasetWizardEditorModel(); - - if (dmpId) { - this.hasDmpId = true; - this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - setTimeout(() => { - this.dmpModel = data; - this.datasetWizardEditorModel.dmp = data; - this.dmp.datasets.push(this.datasetWizardEditorModel); - this.formGroup = this.dmp.buildForm(); - this.formGroup.get('datasets')['controls'][0].get('dmp').disable(); - this.datasets = this.formGroup.get('datasets') as FormArray; - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; - // this.loadDatasetProfiles(); - // this.registerFormListeners(); + this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); }); - }); + }); + } + // else if (this.isNewDataset) { + // this.dmp = new DmpEditorModel(); + // this.dmp.grant = new GrantTabModel(); + // this.dmp.project = new ProjectFormModel(); + // this.dmp.funder = new FunderFormModel(); + // this.dmp.extraProperties = new ExtraPropertiesFormModel(); + // this.dmp.extraProperties.visible = false; + // this.dmp.extraProperties.contact = this.authService.current().id; + // this.datasetWizardEditorModel = new DatasetWizardEditorModel(); - } else { - this.dmp.datasets.push(this.datasetWizardEditorModel); - this.formGroup = this.dmp.buildForm(); - this.datasets = this.formGroup.get('datasets') as FormArray; - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; - } + // if (dmpId) { + // this.hasDmpId = true; + // this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel)) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // setTimeout(() => { + // this.dmpModel = data; + // this.datasetWizardEditorModel.dmp = data; + // this.dmp.datasets.push(this.datasetWizardEditorModel); + // this.formGroup = this.dmp.buildForm(); + // this.formGroup.get('datasets')['controls'][0].get('dmp').disable(); + // this.datasets = this.formGroup.get('datasets') as FormArray; + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; + // // this.loadDatasetProfiles(); + // // this.registerFormListeners(); + // }); + // }); - this.registerFormEventsForNewItem(); - } else { + // } else { + // this.dmp.datasets.push(this.datasetWizardEditorModel); + // this.formGroup = this.dmp.buildForm(); + // this.datasets = this.formGroup.get('datasets') as FormArray; + // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + // this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; + // this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // console.log(x); + // this.formChanged(); + // }); + // } + + // this.registerFormEventsForNewItem(); + // } + else { this.dmp = new DmpEditorModel(); this.dmp.grant = new GrantTabModel(); this.dmp.project = new ProjectFormModel(); @@ -345,6 +359,10 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC ]); }) } + this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); + }); } }); @@ -424,20 +442,20 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC formSubmit(addNew?: boolean, showAddDatasetDialog?: boolean): void { this.formService.touchAllFormFields(this.formGroup); - if (this.isNewDataset) { - if (!this.isDatasetFormValid) { - this.showValidationErrorsDialog(); - return; - } - this.onDatasetSubmit(); - } - else { + // if (this.isNewDataset) { + // if (!this.isDatasetFormValid) { + // this.showValidationErrorsDialog(); + // return; + // } + // this.onDatasetSubmit(); + // } + // else { if (!this.isFormValid()) { this.showValidationErrorsDialog(); return; } this.onSubmit(addNew, showAddDatasetDialog); - } + // } } public isFormValid() { @@ -823,22 +841,13 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC public discardChanges() { this.isDiscarded = true; this.hasChanges = false; - if (this.isNewDataset && !this.hasDmpId) { - this.formGroup.get('datasets')['controls'].forEach(element => { - element.removeControl('datasetProfileDefinition'); - }); - this.formGroup.reset(); - } else if (this.hasDmpId) { - Object.keys(this.formGroup.get('datasets')['controls'][0].controls).forEach((key: string) => { - if (key === 'datasetProfileDefinition') { - this.formGroup.get('datasets')['controls'][0].removeControl(key); - } - if (key !== 'dmp' && key !== 'datasetProfileDefinition') { - this.formGroup.get('datasets')['controls'][0].get(key).reset(); - } - }); - } else { + if (!this.isNew) { this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue))); + } else { + this.formGroup.reset(); + this.formGroup.get('extraProperties').get('visible').setValue(false); + this.formGroup.get('extraProperties').get('contact').setValue(this.authService.current().id); + this.formGroup.get('associatedUsers').setValue([]); } this.isDiscarded = false; } diff --git a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts index 11a74f5a2..aa0e6f215 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts @@ -81,7 +81,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) .subscribe(x => { this.configureAutoCompletes(); - this.onFormChanged.emit(); + // this.onFormChanged.emit(); }); } diff --git a/dmp-frontend/src/app/ui/dmp/editor/license-info/license-info.component.html b/dmp-frontend/src/app/ui/dmp/editor/license-info/license-info.component.html index 4c3527542..ed02d2bfa 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/license-info/license-info.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/license-info/license-info.component.html @@ -9,7 +9,7 @@
4.1 {{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}
- + {{ lang.name }} @@ -24,7 +24,7 @@
-
+
4.2 {{'DMP-EDITOR.FIELDS.LICENSE' | translate}}
{{'DMP-EDITOR.LICENSE-INFO.HINT' | translate}}
@@ -41,7 +41,7 @@
-
+
4.3 {{'DMP-EDITOR.FIELDS.VISIBILITY' | translate}}
@@ -61,7 +61,7 @@
-
+
4.4 {{'DMP-EDITOR.FIELDS.PUBLICATION' | translate}}
@@ -78,7 +78,7 @@
-
+
4.5 {{'DMP-EDITOR.FIELDS.CONTACT' | translate}}
@@ -97,7 +97,7 @@
-
- + {{formGroup.get('label').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} - - - -
-
+
1.2 {{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}
@@ -37,7 +32,7 @@
-
+
1.3 {{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}
@@ -62,7 +57,7 @@
-
+
1.4 {{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}
diff --git a/dmp-frontend/src/app/ui/dmp/editor/main-info/main-info.component.ts b/dmp-frontend/src/app/ui/dmp/editor/main-info/main-info.component.ts index 0a72a9fdc..217e5ab41 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/main-info/main-info.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/main-info/main-info.component.ts @@ -29,7 +29,6 @@ export class MainInfoComponent extends BaseComponent implements OnInit { @Input() formGroup: FormGroup = null; // @Input() datasetFormGroup: FormGroup; @Input() isNewVersion: boolean; - @Input() isNewDataset: boolean; @Input() isUserOwner: boolean; @Input() isClone: boolean; @Output() onFormChanged: EventEmitter = new EventEmitter(); diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts index 7f4f7c372..5ca786b8e 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts @@ -30,13 +30,13 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit ngOnInit() { this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.form); - if (this.form) { - this.form.valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(val => { - this.formChanged.emit(val); - }); - } + // if (this.form) { + // this.form.valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(val => { + // this.formChanged.emit(val); + // }); + // } } ngOnChanges(changes: SimpleChanges) { diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts index 73db8b415..7e1fe4e9f 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/tableOfContentsMaterial/table-of-contents.ts @@ -4,6 +4,7 @@ import { BaseComponent } from '@common/base/base.component'; import { interval, Subject, Subscription } from 'rxjs'; import { distinctUntilChanged } from 'rxjs/operators'; import { type } from 'os'; +import { SimpleChanges } from '@angular/core'; interface Link { /* id of the section*/ @@ -104,6 +105,15 @@ export class TableOfContents extends BaseComponent implements OnInit { }) } + ngOnChanges(changes: SimpleChanges) { + if (!this.isActive && this.links && this.links.length > 0) { + this.links.forEach(link => { + link.selected = false; + }) + this.links[0].selected = true; + } + } + goToStep(link: Link) { // this.selectedLinkId = link.id; this.stepFound.emit({