diff --git a/dmp-frontend/src/app/about/about.module.ts b/dmp-frontend/src/app/about/about.module.ts index 21e9526f3..3d2ee1a61 100644 --- a/dmp-frontend/src/app/about/about.module.ts +++ b/dmp-frontend/src/app/about/about.module.ts @@ -1,51 +1,51 @@ -import { BaseHttpService } from "../utilities/cite-http-service-module/base-http.service"; -import { HttpClient, HttpClientModule } from "@angular/common/http"; -import { TranslateLoader } from "@ngx-translate/core"; -import { TranslateModule } from "@ngx-translate/core"; -import { SharedModule } from "../shared/shared.module"; -import { FormsModule } from "@angular/forms"; -import { CommonModule } from "@angular/common"; -import { NgModule } from "@angular/core"; -import { TranslateService } from "@ngx-translate/core"; -import { TranslateHttpLoader } from "@ngx-translate/http-loader"; -import { AboutRoutes } from "./about.routes"; -import { AboutComponent } from "./components/about.component"; +import { BaseHttpService } from '../utilities/cite-http-service-module/base-http.service'; +import { HttpClient, HttpClientModule } from '@angular/common/http'; +import { TranslateLoader } from '@ngx-translate/core'; +import { TranslateModule } from '@ngx-translate/core'; +import { SharedModule } from '../shared/shared.module'; +import { FormsModule } from '@angular/forms'; +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { TranslateHttpLoader } from '@ngx-translate/http-loader'; +import { AboutRoutes } from './about.routes'; +import { AboutComponent } from './components/about.component'; @NgModule({ - imports: [ - CommonModule, - FormsModule, - SharedModule, - HttpClientModule, - AboutRoutes, - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [HttpClient] - } - }), - ], + imports: [ + CommonModule, + FormsModule, + SharedModule, + HttpClientModule, + AboutRoutes, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + ], - declarations: [ - AboutComponent - ], + declarations: [ + AboutComponent + ], - exports: [ - AboutComponent - ], - providers: [ - BaseHttpService - ] + exports: [ + AboutComponent + ], + providers: [ + BaseHttpService + ] }) export class AboutModule { - constructor(private translate: TranslateService) { - translate.setDefaultLang('en'); - translate.use('en'); - } + constructor(private translate: TranslateService) { + translate.setDefaultLang('en'); + translate.use('en'); + } } export function HttpLoaderFactory(httpClient: HttpClient) { - return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); -} \ No newline at end of file + return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); +} diff --git a/dmp-frontend/src/app/about/about.routes.ts b/dmp-frontend/src/app/about/about.routes.ts index 1b433bef6..02fde24c3 100644 --- a/dmp-frontend/src/app/about/about.routes.ts +++ b/dmp-frontend/src/app/about/about.routes.ts @@ -1,8 +1,8 @@ -import { AboutComponent } from "./components/about.component"; -import { Routes, RouterModule } from "@angular/router"; +import { AboutComponent } from './components/about.component'; +import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ - { path: '', component: AboutComponent }, + { path: '', component: AboutComponent }, ]; export const AboutRoutes = RouterModule.forChild(routes); diff --git a/dmp-frontend/src/app/about/components/about.component.ts b/dmp-frontend/src/app/about/components/about.component.ts index 94c736cd3..586736b5a 100644 --- a/dmp-frontend/src/app/about/components/about.component.ts +++ b/dmp-frontend/src/app/about/components/about.component.ts @@ -1,6 +1,6 @@ -import { Component, ViewEncapsulation, OnInit } from "@angular/core"; -import { ActivatedRoute, Router } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; +import { Component, ViewEncapsulation, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-about', diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index ed97b22db..157a6fafd 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -31,7 +31,7 @@ const appRoutes: Routes = [ canActivate: [AuthGuard] }, { - path: "dmps", + path: 'dmps', loadChildren: './dmps/dmps.module#DataManagementPlanModule', data: { breadcrumb: true @@ -39,7 +39,7 @@ const appRoutes: Routes = [ canActivate: [AuthGuard] }, { - path: "dmp-profiles", + path: 'dmp-profiles', loadChildren: './dmp-profiles/dmp-profile.module#DataManagamentPlanProfileModule', data: { breadcrumb: true @@ -71,32 +71,32 @@ const appRoutes: Routes = [ pathMatch: 'full' }, { - path: "unauthorized", + path: 'unauthorized', loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule', data: { breadcrumb: true }, }, { - path: "users", + path: 'users', loadChildren: './users/users.module#UsersModule' }, { - path: "datasetsProfiles", + path: 'datasetsProfiles', loadChildren: './datasets-admin-listing/dataset-admin.module#DatasetAdminModule', data: { breadcrumb: true }, }, { - path: "welcome", + path: 'welcome', component: WelcomepageComponent, data: { breadcrumb: false }, }, { - path: "api/oauth/authorized/b2access", + path: 'api/oauth/authorized/b2access', component: B2AccessLoginComponent, data: { }, diff --git a/dmp-frontend/src/app/app.component.html b/dmp-frontend/src/app/app.component.html index 8cb5a9933..662e2e50e 100644 --- a/dmp-frontend/src/app/app.component.html +++ b/dmp-frontend/src/app/app.component.html @@ -1,22 +1,22 @@
-
- -
-
-
- -
-
- - -
-
- -
-
-
- -
+
+ +
+
+
+ +
+
+ + +
+
+ +
+
+
+ +
diff --git a/dmp-frontend/src/app/app.component.ts b/dmp-frontend/src/app/app.component.ts index facfb9061..79b220003 100644 --- a/dmp-frontend/src/app/app.component.ts +++ b/dmp-frontend/src/app/app.component.ts @@ -13,74 +13,74 @@ declare const gapi: any; declare var $: any; @Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'], - providers: [], - encapsulation: ViewEncapsulation.None + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.scss'], + providers: [], + encapsulation: ViewEncapsulation.None }) export class AppComponent implements OnInit { - hasBreadCrumb = Observable.of(false); - sideNavOpen = false; + hasBreadCrumb = Observable.of(false); + sideNavOpen = false; - constructor( - private router: Router, - private route: ActivatedRoute, - private authentication: AuthService, - private translate: TranslateService, - private languageService: LanguageResolverService, - private breadCrumbResolverService: BreadCrumbResolverService, - private cultureService: CultureService - ) { - this.initializeServices() - } + constructor( + private router: Router, + private route: ActivatedRoute, + private authentication: AuthService, + private translate: TranslateService, + private languageService: LanguageResolverService, + private breadCrumbResolverService: BreadCrumbResolverService, + private cultureService: CultureService + ) { + this.initializeServices(); + } - onActivate(event: any) { - this.breadCrumbResolverService.push(event) - } + onActivate(event: any) { + this.breadCrumbResolverService.push(event); + } - onDeactivate(event: any) { - //this.breadCrumbResolverService.clear() - } + onDeactivate(event: any) { + //this.breadCrumbResolverService.clear() + } - ngOnInit() { - this.hasBreadCrumb = this.router.events - .filter(event => event instanceof NavigationEnd) - .map(() => this.route) - .map(route => route.firstChild) - .switchMap(route => route.data) - .map(data => data['breadcrumb']) - } + ngOnInit() { + this.hasBreadCrumb = this.router.events + .filter(event => event instanceof NavigationEnd) + .map(() => this.route) + .map(route => route.firstChild) + .switchMap(route => route.data) + .map(data => data['breadcrumb']); + } - login() { - //redirect to login page - this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } }); - } + login() { + //redirect to login page + this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } }); + } - logout() { + logout() { - } + } - public isAuthenticated(): boolean { - return !(!this.authentication.current()) - } + public isAuthenticated(): boolean { + return !(!this.authentication.current()); + } - goToDMPs() { - this.router.navigate(['/dmps'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } }); - } + goToDMPs() { + this.router.navigate(['/dmps'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } }); + } - goToProjects() { - this.router.navigate(['/projects'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } }); - } + goToProjects() { + this.router.navigate(['/projects'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } }); + } - initializeServices() { - // this language will be used as a fallback when a translation isn't found in the current language - this.translate.setDefaultLang('en'); + initializeServices() { + // this language will be used as a fallback when a translation isn't found in the current language + this.translate.setDefaultLang('en'); - this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(environment.defaultCulture); + this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(environment.defaultCulture); - //this.setupChangeListeners(); - } + //this.setupChangeListeners(); + } } diff --git a/dmp-frontend/src/app/app.constants.ts b/dmp-frontend/src/app/app.constants.ts index e761addbd..84b37f334 100644 --- a/dmp-frontend/src/app/app.constants.ts +++ b/dmp-frontend/src/app/app.constants.ts @@ -4,4 +4,4 @@ export const HostConfiguration = { App: environment.App, CacheLifeTimeMillis: 30000, HelpServiceUrl: environment.HelpServiceUrl -} \ No newline at end of file +}; diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index 0e1f6d8b1..44c26f898 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -106,18 +106,18 @@ import { CultureService } from './utilities/culture/culture-service'; HelpContentService, LanguageService, LanguageResolverService, - BreadCrumbResolverService, - CultureService, - { - provide: MAT_DATE_LOCALE, - deps: [CultureService], - useFactory: (cultureService) => cultureService.getCurrentCulture() - }, - { - provide: LOCALE_ID, - deps: [CultureService], - useFactory: (cultureService) => cultureService.getCurrentCulture() - }, + BreadCrumbResolverService, + CultureService, + { + provide: MAT_DATE_LOCALE, + deps: [CultureService], + useFactory: (cultureService) => cultureService.getCurrentCulture() + }, + { + provide: LOCALE_ID, + deps: [CultureService], + useFactory: (cultureService) => cultureService.getCurrentCulture() + }, ], bootstrap: [AppComponent] }) diff --git a/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html b/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html index 809c046c0..32f903310 100644 --- a/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html +++ b/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html @@ -57,8 +57,8 @@ - +
@@ -71,7 +71,7 @@
- +
diff --git a/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts b/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts index 7fd4c235e..3b48e17d7 100644 --- a/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts +++ b/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts @@ -1,57 +1,59 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { FormArray, FormControl } from '@angular/forms'; import { FieldSet } from '../../models/datasetProfileAdmin/FieldSet'; import { Field } from '../../models/datasetProfileAdmin/Field'; @Component({ - selector: 'compositefield-form', - templateUrl: './compositefield-form.component.html', - styleUrls: ['./compositefield-form.component.scss'] + selector: 'app-compositefield-form', + templateUrl: './compositefield-form.component.html', + styleUrls: ['./compositefield-form.component.scss'] }) -export class CompositeFieldFormComponent { - @Input() form: FormGroup; - @Input() dataModel: FieldSet; - @Input() indexPath: string; +export class CompositeFieldFormComponent implements OnInit { + @Input() form: FormGroup; + @Input() dataModel: FieldSet; + @Input() indexPath: string; - isComposite: boolean = false; - isMultiplicityEnabled: boolean = false; + isComposite = false; + isMultiplicityEnabled = false; - constructon() { } + constructon() { } - ngOnInit() { - //this.addNewField(); - if (this.form.get("multiplicity")) - if (this.form.get("multiplicity").value.min > 1 || this.form.get("multiplicity").value.max > 1) - this.isMultiplicityEnabled = true; - this.isComposite = this.dataModel.fields.length > 1; - } + ngOnInit() { + //this.addNewField(); + if (this.form.get('multiplicity')) { + if (this.form.get('multiplicity').value.min > 1 || this.form.get('multiplicity').value.max > 1) { + this.isMultiplicityEnabled = true; + } + } + this.isComposite = this.dataModel.fields.length > 1; + } - onIsCompositeChange(isComposite: boolean) { - if (!isComposite && (this.form.get("fields")).length > 1) { - for (let i = 0; i < (this.form.get("fields")).length - 1; i++) { - (this.form.get("fields")).removeAt(1); - } - this.dataModel.fields.splice(1); - } - } + onIsCompositeChange(isComposite: boolean) { + if (!isComposite && (this.form.get('fields')).length > 1) { + for (let i = 0; i < (this.form.get('fields')).length - 1; i++) { + (this.form.get('fields')).removeAt(1); + } + this.dataModel.fields.splice(1); + } + } - onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { - if (!isMultiplicityEnabled) { - (this.form.get('multiplicity').get("min")).setValue(0); - (this.form.get('multiplicity').get("max")).setValue(0); - } - } + onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { + if (!isMultiplicityEnabled) { + (this.form.get('multiplicity').get('min')).setValue(0); + (this.form.get('multiplicity').get('max')).setValue(0); + } + } - addNewField() { - let field: Field = new Field(); - this.dataModel.fields.push(field); - (this.form.get("fields")).push(field.buildForm()); - } + addNewField() { + const field: Field = new Field(); + this.dataModel.fields.push(field); + (this.form.get('fields')).push(field.buildForm()); + } - DeleteField(index) { - this.dataModel.fields.splice(index, 1); - (this.form.get("fields")).removeAt(index); - } + DeleteField(index) { + this.dataModel.fields.splice(index, 1); + (this.form.get('fields')).removeAt(index); + } } diff --git a/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts b/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts index c63b11d83..2e8f4628a 100644 --- a/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts +++ b/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts @@ -1,14 +1,14 @@ import { RouterModule, Routes } from '@angular/router'; -import { FormComponent } from 'app/dataset-profile-form/form/form.component'; +import { FormComponent } from './form/form.component'; export const DatasetProfileRoutes: Routes = [ - { - path: ':id', - component: FormComponent - }, - { - path: '', - component: FormComponent - } + { + path: ':id', + component: FormComponent + }, + { + path: '', + component: FormComponent + } ]; diff --git a/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.html b/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.html index 3847213c0..5f24cec85 100644 --- a/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.html +++ b/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.html @@ -64,22 +64,22 @@
- +
- +
- +
- +
- +
- +
Multiplicity @@ -99,7 +99,7 @@ - + diff --git a/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.ts b/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.ts index 50840e3e0..37dd1ea4b 100644 --- a/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.ts +++ b/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.ts @@ -1,54 +1,56 @@  -import { Component, Input } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { FormGroup, FormControl, FormArray } from '@angular/forms'; import { ValidationTypes } from '../../models/common/ValidationTypes'; import { Field } from '../../models/datasetProfileAdmin/Field'; import { Rule } from '../../models/datasetProfileAdmin/Rule'; @Component({ - selector: 'field-form', - templateUrl: './field-form.component.html', - styleUrls: ['./field-form.component.scss'] + selector: 'app-field-form', + templateUrl: './field-form.component.html', + styleUrls: ['./field-form.component.scss'] }) -export class FieldFormComponent { - @Input() form: FormGroup; - @Input() dataModel: Field; - @Input() showMultiplicity: boolean = true; - @Input() indexPath: string; - validationsOptions: Array; - isFieldMultiplicityEnabled: boolean = false; +export class FieldFormComponent implements OnInit { + @Input() form: FormGroup; + @Input() dataModel: Field; + @Input() showMultiplicity = true; + @Input() indexPath: string; + validationsOptions: Array; + isFieldMultiplicityEnabled = false; - constructon() { - } + constructon() { + } - ngOnInit() { - if (this.form.get("multiplicity")) - if (this.form.get("multiplicity").value.min > 1 || this.form.get("multiplicity").value.max > 1) - this.isFieldMultiplicityEnabled = true; - this.validationsOptions = [{ key: 0, value: ValidationTypes[0] }, { key: 1, value: ValidationTypes[1] }] - // this.addNewRule(); - } + ngOnInit() { + if (this.form.get('multiplicity')) { + if (this.form.get('multiplicity').value.min > 1 || this.form.get('multiplicity').value.max > 1) { + this.isFieldMultiplicityEnabled = true; + } + } + this.validationsOptions = [{ key: 0, value: ValidationTypes[0] }, { key: 1, value: ValidationTypes[1] }]; + // this.addNewRule(); + } - onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) { - if (!isFieldMultiplicityEnabled) { - (this.form.get('multiplicity').get("min")).setValue(0); - (this.form.get('multiplicity').get("max")).setValue(0); - } - } + onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) { + if (!isFieldMultiplicityEnabled) { + (this.form.get('multiplicity').get('min')).setValue(0); + (this.form.get('multiplicity').get('max')).setValue(0); + } + } - addNewRule() { - let rule: Rule = new Rule(); - this.dataModel.visible.rules.push(rule); - (this.form.get("visible").get("rules")).push(rule.buildForm()); - } + addNewRule() { + const rule: Rule = new Rule(); + this.dataModel.visible.rules.push(rule); + (this.form.get('visible').get('rules')).push(rule.buildForm()); + } - DeleteRule(index) { - this.dataModel.visible.rules.splice(index, 1); - (this.form.get("visible").get("rules")).removeAt(index); - } + DeleteRule(index) { + this.dataModel.visible.rules.splice(index, 1); + (this.form.get('visible').get('rules')).removeAt(index); + } - onchangeCombo() { - if (this.form.get("data")) this.form.removeControl("data"); - } -} \ No newline at end of file + onchangeCombo() { + if (this.form.get('data')) { this.form.removeControl('data'); } + } +} diff --git a/dmp-frontend/src/app/dataset-profile-form/form/form.component.html b/dmp-frontend/src/app/dataset-profile-form/form/form.component.html index ae734b017..f8583da0e 100644 --- a/dmp-frontend/src/app/dataset-profile-form/form/form.component.html +++ b/dmp-frontend/src/app/dataset-profile-form/form/form.component.html @@ -30,7 +30,7 @@
- +
@@ -56,7 +56,7 @@
- +
diff --git a/dmp-frontend/src/app/dataset-profile-form/form/form.component.ts b/dmp-frontend/src/app/dataset-profile-form/form/form.component.ts index c5ae9308f..4ed709e25 100644 --- a/dmp-frontend/src/app/dataset-profile-form/form/form.component.ts +++ b/dmp-frontend/src/app/dataset-profile-form/form/form.component.ts @@ -4,108 +4,108 @@ import { DatasetProfileModelAdmin } from '../../models/datasetProfileAdmin/Datas import { Page } from '../../models/datasetProfileAdmin/Page'; import { Component, OnInit } from '@angular/core'; import { FormGroup, FormControl } from '@angular/forms'; -import { SectionFormComponent } from '../section-form/section-form.component'; import { FormArray } from '@angular/forms'; -import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router'; -import { PageFormComponent } from '../page-form/page-component' +import { Router, ActivatedRoute } from '@angular/router'; import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service'; import { Section } from '../../models/datasetProfileAdmin/Section'; import { MatDialog } from '@angular/material'; import { DatasetProfilePreviewerComponent } from '../previewer/dataset-profile-previewer.component'; @Component({ - selector: 'form-comp', - templateUrl: './form.component.html', - providers: [DatasetProfileAdmin, DatasetProfileService], - styleUrls: ['./form.component.scss'] + selector: 'app-form-comp', + templateUrl: './form.component.html', + providers: [DatasetProfileAdmin, DatasetProfileService], + styleUrls: ['./form.component.scss'] }) -export class FormComponent { +export class FormComponent implements OnInit { - dataModel: DatasetProfileModelAdmin; - form: FormGroup; - private profileID: string; + dataModel: DatasetProfileModelAdmin; + form: FormGroup; + private profileID: string; - constructor( - public datasetprofileAdmin: DatasetProfileAdmin, - private datasetProfileService: DatasetProfileService, - private route: ActivatedRoute, - private router: Router, - public dialog: MatDialog, - ) { - this.profileID = route.snapshot.params['id']; - } + constructor( + public datasetprofileAdmin: DatasetProfileAdmin, + private datasetProfileService: DatasetProfileService, + private route: ActivatedRoute, + private router: Router, + public dialog: MatDialog, + ) { + this.profileID = route.snapshot.params['id']; + } - ngOnInit() { + ngOnInit() { - this.dataModel = JsonSerializer.fromJSONObject(new DatasetProfileModelAdmin(), DatasetProfileModelAdmin); - this.form = this.dataModel.buildForm(); - if (this.profileID) { - this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => { - this.dataModel = JsonSerializer.fromJSONObject(data, DatasetProfileModelAdmin); - this.form = this.dataModel.buildForm(); - }); - } - else { - this.addSection(); - this.addPage(); - } - } + this.dataModel = JsonSerializer.fromJSONObject(new DatasetProfileModelAdmin(), DatasetProfileModelAdmin); + this.form = this.dataModel.buildForm(); + if (this.profileID) { + this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => { + this.dataModel = JsonSerializer.fromJSONObject(data, DatasetProfileModelAdmin); + this.form = this.dataModel.buildForm(); + }); + } else { + this.addSection(); + this.addPage(); + } + } - onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { - if (!isMultiplicityEnabled) { - (this.form.get('multiplicity').get("min")).setValue(0); - (this.form.get('multiplicity').get("max")).setValue(0); - } - } + onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { + if (!isMultiplicityEnabled) { + (this.form.get('multiplicity').get('min')).setValue(0); + (this.form.get('multiplicity').get('max')).setValue(0); + } + } - addSection() { - let section: Section = new Section(); - this.dataModel.sections.push(section); - (this.form.get("sections")).push(section.buildForm()); - } + addSection() { + const section: Section = new Section(); + this.dataModel.sections.push(section); + (this.form.get('sections')).push(section.buildForm()); + } - addPage() { - let page: Page = new Page(this.dataModel.pages.length); - this.dataModel.pages.push(page); - (this.form.get("pages")).push(page.buildForm()); - } + addPage() { + const page: Page = new Page(this.dataModel.pages.length); + this.dataModel.pages.push(page); + (this.form.get('pages')).push(page.buildForm()); + } - DeleteSection(index) { - this.dataModel.sections.splice(index, 1); - (this.form.get("sections")).removeAt(index) - } + DeleteSection(index) { + this.dataModel.sections.splice(index, 1); + (this.form.get('sections')).removeAt(index); + } - DeletePage(index) { - this.dataModel.pages.splice(index, 1); - (this.form.get("pages")).removeAt(index) - } + DeletePage(index) { + this.dataModel.pages.splice(index, 1); + (this.form.get('pages')).removeAt(index); + } - createForm(data) { - return this.datasetprofileAdmin.createForm(data); - } - updateForm(id, data) { - return this.datasetprofileAdmin.updateForm(id, data); - } - onSubmit() { - let data = this.form.value; + 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).subscribe(() => { - this.router.navigate(['/datasetsProfiles']) - }); - else this.createForm(data).subscribe(() => { - this.router.navigate(['/datasetsProfiles']) - }); - } + if (this.profileID) { + this.updateForm(this.profileID, data).subscribe(() => { + this.router.navigate(['/datasetsProfiles']); + }); + } else { + this.createForm(data).subscribe(() => { + this.router.navigate(['/datasetsProfiles']); + }); + } + } - preview() { - let dialogRef = this.dialog.open(DatasetProfilePreviewerComponent, { - height: '355px', - width: '700px', - data: { - model: this.dataModel - } - }); - } + preview() { + const dialogRef = this.dialog.open(DatasetProfilePreviewerComponent, { + height: '355px', + width: '700px', + data: { + model: this.dataModel + } + }); + } } diff --git a/dmp-frontend/src/app/dataset-profile-form/page-form/page-component.ts b/dmp-frontend/src/app/dataset-profile-form/page-form/page-component.ts index 6acf891e0..c1d58f859 100644 --- a/dmp-frontend/src/app/dataset-profile-form/page-form/page-component.ts +++ b/dmp-frontend/src/app/dataset-profile-form/page-form/page-component.ts @@ -1,10 +1,10 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; -import { FormGroup } from '@angular/forms' +import { FormGroup } from '@angular/forms'; import { Page } from '../../models/datasetProfileAdmin/Page'; @Component({ - selector: 'page-form', + selector: 'app-page-form', templateUrl: './page-component.html', styleUrls: ['./page-component.scss'] }) diff --git a/dmp-frontend/src/app/dataset-profile-form/previewer/dataset-profile-previewer.component.html b/dmp-frontend/src/app/dataset-profile-form/previewer/dataset-profile-previewer.component.html index fa2852aa3..ab5c6c43b 100644 --- a/dmp-frontend/src/app/dataset-profile-form/previewer/dataset-profile-previewer.component.html +++ b/dmp-frontend/src/app/dataset-profile-form/previewer/dataset-profile-previewer.component.html @@ -1,2 +1,2 @@ - + diff --git a/dmp-frontend/src/app/dataset-profile-form/previewer/dataset-profile-previewer.component.ts b/dmp-frontend/src/app/dataset-profile-form/previewer/dataset-profile-previewer.component.ts index cc3543842..ba3b492fb 100644 --- a/dmp-frontend/src/app/dataset-profile-form/previewer/dataset-profile-previewer.component.ts +++ b/dmp-frontend/src/app/dataset-profile-form/previewer/dataset-profile-previewer.component.ts @@ -1,36 +1,36 @@ -import { ViewEncapsulation, Component, Inject } from "@angular/core"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material"; -import { FormGroup } from "@angular/forms"; -import { DatasetProfileDefinitionModel } from "../../models/DatasetProfileDefinitionModel"; -import { JsonSerializer } from "../../utilities/JsonSerializer"; -import { DatasetModel } from "../../models/datasets/DatasetModel"; -import { DatasetWizardModel } from "../../models/datasets/DatasetWizardModel"; -import { DatasetProfileService } from "../../services/dataset-profile.service"; -import { DatasetProfileAdmin } from "../../services/datasetProfileAdmin/datasetProfileAfmin.service"; +import { ViewEncapsulation, Component, Inject, OnInit } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { FormGroup } from '@angular/forms'; +import { DatasetProfileDefinitionModel } from '../../models/DatasetProfileDefinitionModel'; +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { DatasetModel } from '../../models/datasets/DatasetModel'; +import { DatasetWizardModel } from '../../models/datasets/DatasetWizardModel'; +import { DatasetProfileService } from '../../services/dataset-profile.service'; +import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service'; @Component({ - selector: 'dataset-profile-previewer', - templateUrl: './dataset-profile-previewer.component.html', - styleUrls: ['./dataset-profile-previewer.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-dataset-profile-previewer', + templateUrl: './dataset-profile-previewer.component.html', + styleUrls: ['./dataset-profile-previewer.component.scss'], + encapsulation: ViewEncapsulation.None }) -export class DatasetProfilePreviewerComponent { - formGroup: FormGroup - datasetWizardModel: DatasetWizardModel - constructor( - private datasetProfileAdminService: DatasetProfileAdmin, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } +export class DatasetProfilePreviewerComponent implements OnInit { + formGroup: FormGroup; + datasetWizardModel: DatasetWizardModel; + constructor( + private datasetProfileAdminService: DatasetProfileAdmin, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } - ngOnInit(): void { + ngOnInit(): void { - this.datasetProfileAdminService.preview(this.data['model']).subscribe(x => { - this.datasetWizardModel = new DatasetWizardModel(); - this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(x, DatasetProfileDefinitionModel) - this.formGroup = this.datasetWizardModel.buildForm(); - }) + this.datasetProfileAdminService.preview(this.data['model']).subscribe(x => { + this.datasetWizardModel = new DatasetWizardModel(); + this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(x, DatasetProfileDefinitionModel); + this.formGroup = this.datasetWizardModel.buildForm(); + }); - } + } } diff --git a/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.html b/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.html index b0d76ae8b..6f6db96f9 100644 --- a/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.html +++ b/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.html @@ -54,7 +54,7 @@
- +
@@ -92,7 +92,7 @@ - + diff --git a/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.ts b/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.ts index dde7db951..405f84636 100644 --- a/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.ts +++ b/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.ts @@ -9,54 +9,56 @@ import { Page } from '../../models/datasetProfileAdmin/Page'; import { JsonSerializer } from '../../utilities/JsonSerializer'; @Component({ - selector: 'section-form', - templateUrl: './section-form.component.html', - styleUrls: ['./section-form.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-section-form', + templateUrl: './section-form.component.html', + styleUrls: ['./section-form.component.scss'], + encapsulation: ViewEncapsulation.None }) -export class SectionFormComponent { - @Input() form: FormGroup; - @Input() dataModel: Section; - @Input() indexPath: string; +export class SectionFormComponent implements OnInit { + @Input() form: FormGroup; + @Input() dataModel: Section; + @Input() indexPath: string; - constructor() { } + constructor() { } - ngOnInit() { - this.form.root.get("pages").valueChanges.subscribe(x => - this.keepPageSelectionValid(x) - ); - } + ngOnInit() { + this.form.root.get('pages').valueChanges.subscribe(x => + this.keepPageSelectionValid(x) + ); + } - addField() { - let fieldSet: FieldSet = new FieldSet(); - let field: Field = new Field(); - fieldSet.fields.push(field); - if (this.dataModel.fieldSets) - this.dataModel.fieldSets.push(fieldSet); - (this.form.get("fieldSets")).push(fieldSet.buildForm()); - } + addField() { + const fieldSet: FieldSet = new FieldSet(); + const field: Field = new Field(); + fieldSet.fields.push(field); + if (this.dataModel.fieldSets) { + this.dataModel.fieldSets.push(fieldSet); + } + (this.form.get('fieldSets')).push(fieldSet.buildForm()); + } - addSectioninSection() { - let section: Section = new Section(); - this.dataModel.sections.push(section); - (this.form.get("sections")).push(section.buildForm()); - } + addSectioninSection() { + const section: Section = new Section(); + this.dataModel.sections.push(section); + (this.form.get('sections')).push(section.buildForm()); + } - DeleteSectionInSection(index) { - this.dataModel.sections.splice(index); - (this.form.get("sections")).removeAt(index); - } + DeleteSectionInSection(index) { + this.dataModel.sections.splice(index); + (this.form.get('sections')).removeAt(index); + } - DeleteFieldSet(index) { - this.dataModel.fieldSets.splice(index, 1); - (this.form.get("fieldSets")).removeAt(index); - } + DeleteFieldSet(index) { + this.dataModel.fieldSets.splice(index, 1); + (this.form.get('fieldSets')).removeAt(index); + } - keepPageSelectionValid(pagesJson: Array) { - let selectedPage = this.form.get("page").value as String; - let pages: Array = JsonSerializer.fromJSONArray(pagesJson, Page); - if (pages.find(elem => elem.id === selectedPage) === undefined) - this.form.get("page").reset(); - } + keepPageSelectionValid(pagesJson: Array) { + const selectedPage = this.form.get('page').value as String; + const pages: Array = JsonSerializer.fromJSONArray(pagesJson, Page); + if (pages.find(elem => elem.id === selectedPage) === undefined) { + this.form.get('page').reset(); + } + } } diff --git a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.ts b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.ts index 48c4d0744..74b314f81 100644 --- a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.ts +++ b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.ts @@ -1,156 +1,156 @@ import { DataTableRequest } from '../models/data-table/DataTableRequest'; import { DatasetListingModel } from '../models/datasets/DatasetListingModel'; import { DatasetCriteria } from '../models/criteria/dataset/DatasetCriteria'; -import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { Router, Params, ActivatedRoute } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; +import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core'; +import { MatPaginator, MatSort, MatSnackBar } from '@angular/material'; +import { Router, Params, ActivatedRoute } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; -import { Observable } from "rxjs/Observable"; +import { Observable } from 'rxjs/Observable'; import { PageEvent } from '@angular/material'; -import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service"; -import { DataManagementPlanModel } from "../models/data-managemnt-plans/DataManagementPlanModel"; +import { DataManagementPlanService } from '../services/data-management-plan/data-management-plan.service'; +import { DataManagementPlanModel } from '../models/data-managemnt-plans/DataManagementPlanModel'; import { DatasetCriteriaComponent } from '../shared/components/criteria/datasets/datasets-criteria.component'; import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service'; @Component({ - selector: 'app-dataset-admin-listing-component', - templateUrl: 'dataset-admin-listing.component.html', - styleUrls: ['./dataset-admin-listing.component.scss'], - providers: [DatasetProfileAdmin, DataManagementPlanService] + selector: 'app-dataset-admin-listing-component', + templateUrl: 'dataset-admin-listing.component.html', + styleUrls: ['./dataset-admin-listing.component.scss'], + providers: [DatasetProfileAdmin, DataManagementPlanService] }) export class DatasetAdminListingComponent implements OnInit { - @ViewChild(MatPaginator) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; + @ViewChild(MatPaginator) _paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; - dataSource: DatasetDataSource | null; - displayedColumns: String[] = ['label', 'dmp', 'profile', 'dataRepositories', 'registries', 'services', 'description', 'created', 'actions']; - pageEvent: PageEvent; - titlePrefix: String; - dmpId: String; + dataSource: DatasetDataSource | null; + displayedColumns: String[] = ['label', 'dmp', 'profile', 'dataRepositories', 'registries', 'services', 'description', 'created', 'actions']; + pageEvent: PageEvent; + titlePrefix: String; + dmpId: String; - statuses = [ - { value: '0', viewValue: 'Active' }, - { value: '1', viewValue: 'Inactive' } - ]; + statuses = [ + { value: '0', viewValue: 'Active' }, + { value: '1', viewValue: 'Inactive' } + ]; - constructor( - private datasetService: DatasetProfileAdmin, - private router: Router, - private languageService: TranslateService, - public snackBar: MatSnackBar, - public route: ActivatedRoute, - public dataManagementPlanService: DataManagementPlanService - ) { + constructor( + private datasetService: DatasetProfileAdmin, + private router: Router, + private languageService: TranslateService, + public snackBar: MatSnackBar, + public route: ActivatedRoute, + public dataManagementPlanService: DataManagementPlanService + ) { - } + } - ngOnInit() { - this.route.params.subscribe((params: Params) => { - this.dmpId = params['dmpId']; - if (this.dmpId != null) this.setDmpTitle(this.dmpId); - this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId)); - this.refresh(); - this.criteria.setRefreshCallback(() => this.refresh()); - }); - } + ngOnInit() { + this.route.params.subscribe((params: Params) => { + this.dmpId = params['dmpId']; + if (this.dmpId != null) { this.setDmpTitle(this.dmpId); } + this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId)); + this.refresh(); + this.criteria.setRefreshCallback(() => this.refresh()); + }); + } - setDmpTitle(dmpId: String) { - this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel) - .subscribe(data => { - this.titlePrefix = data.label; - }); - } + setDmpTitle(dmpId: String) { + this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel) + .subscribe(data => { + this.titlePrefix = data.label; + }); + } - refresh() { - this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); - } + refresh() { + this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); + } - rowClick(rowId: String) { - this.router.navigate(['form/' + rowId]); - } + rowClick(rowId: String) { + this.router.navigate(['form/' + rowId]); + } - getDefaultCriteria(dmpId: String): DatasetCriteria { - const defaultCriteria = new DatasetCriteria(); - if (dmpId != null) { - defaultCriteria.dmpIds.push(dmpId); - } - return defaultCriteria; - } + getDefaultCriteria(dmpId: String): DatasetCriteria { + const defaultCriteria = new DatasetCriteria(); + if (dmpId != null) { + defaultCriteria.dmpIds.push(dmpId); + } + return defaultCriteria; + } - // makeItPublic(id: String) { - // debugger; - // this.datasetService.makeDatasetPublic(id).subscribe(); - // } + // makeItPublic(id: String) { + // debugger; + // this.datasetService.makeDatasetPublic(id).subscribe(); + // } } export class DatasetDataSource extends DataSource { - totalCount = 0; - isLoadingResults = false; + totalCount = 0; + isLoadingResults = false; - constructor( - private _service: DatasetProfileAdmin, - private _paginator: MatPaginator, - private _sort: MatSort, - private _languageService: TranslateService, - private _snackBar: MatSnackBar, - private _criteria: DatasetCriteriaComponent - ) { - super(); + constructor( + private _service: DatasetProfileAdmin, + private _paginator: MatPaginator, + private _sort: MatSort, + private _languageService: TranslateService, + private _snackBar: MatSnackBar, + private _criteria: DatasetCriteriaComponent + ) { + super(); - } + } - connect(): Observable { - const displayDataChanges = [ - this._paginator.page - //this._sort.matSortChange - ]; + connect(): Observable { + const displayDataChanges = [ + this._paginator.page + //this._sort.matSortChange + ]; - return Observable.merge(...displayDataChanges) - .startWith(null) - .switchMap(() => { - setTimeout(() => { - this.isLoadingResults = true; - }); - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array() - if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria.criteria; - return this._service.getPaged(request); - }) - /*.catch((error: any) => { - this._snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, - duration: 3000, - extraClasses: ['snackbar-warning'] - }); - //this._criteria.criteria.onCallbackError(error); - return Observable.of(null); - })*/ - .map(result => { - setTimeout(() => { - this.isLoadingResults = false; - }); - return result; - }) - .map(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - return result.data; - }); - } + return Observable.merge(...displayDataChanges) + .startWith(null) + .switchMap(() => { + setTimeout(() => { + this.isLoadingResults = true; + }); + const startIndex = this._paginator.pageIndex * this._paginator.pageSize; + let fields: Array = new Array(); + if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); + request.criteria = this._criteria.criteria; + return this._service.getPaged(request); + }) + /*.catch((error: any) => { + this._snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, + duration: 3000, + extraClasses: ['snackbar-warning'] + }); + //this._criteria.criteria.onCallbackError(error); + return Observable.of(null); + })*/ + .map(result => { + setTimeout(() => { + this.isLoadingResults = false; + }); + return result; + }) + .map(result => { + if (!result) { return []; } + if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } + return result.data; + }); + } - disconnect() { - // No-op - } -} \ No newline at end of file + disconnect() { + // No-op + } +} diff --git a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.module.ts b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.module.ts index c678fc47d..9570196bc 100644 --- a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.module.ts +++ b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.module.ts @@ -10,45 +10,45 @@ import { HttpClient, HttpClientModule } from '@angular/common/http'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { SharedModule } from '../shared/shared.module' +import { SharedModule } from '../shared/shared.module'; @NgModule({ - imports: [ - CommonModule, - FormsModule, - HttpClientModule, - SharedModule, - RouterModule.forChild(DatasetAdminRoutes), - ReactiveFormsModule, - DynamicFormModule, - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [HttpClient] - } - }), - ], + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + SharedModule, + RouterModule.forChild(DatasetAdminRoutes), + ReactiveFormsModule, + DynamicFormModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + ], - declarations: [ - DatasetAdminListingComponent, - ], + declarations: [ + DatasetAdminListingComponent, + ], - exports: [ - DatasetAdminListingComponent, - RouterModule - ], - providers: [ - DatasetService - ] + exports: [ + DatasetAdminListingComponent, + RouterModule + ], + providers: [ + DatasetService + ] }) export class DatasetAdminModule { - constructor(private translate: TranslateService) { - translate.setDefaultLang('en'); - translate.use('en'); - } + constructor(private translate: TranslateService) { + translate.setDefaultLang('en'); + translate.use('en'); + } } export function HttpLoaderFactory(httpClient: HttpClient) { - return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); -} \ No newline at end of file + return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); +} diff --git a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.routes.ts b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.routes.ts index 0a2ebb325..9ef78c520 100644 --- a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.routes.ts +++ b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.routes.ts @@ -3,5 +3,5 @@ import { RouterModule, Routes } from '@angular/router'; import { AuthGuard } from '../shared/guards/auth.guard'; export const DatasetAdminRoutes: Routes = [ - { path: '', component: DatasetAdminListingComponent, canActivate: [AuthGuard] }, + { path: '', component: DatasetAdminListingComponent, canActivate: [AuthGuard] }, ]; diff --git a/dmp-frontend/src/app/datasets/dataset-public/dataset-public-listing.component.ts b/dmp-frontend/src/app/datasets/dataset-public/dataset-public-listing.component.ts index ea6cffc57..f5d023ca3 100644 --- a/dmp-frontend/src/app/datasets/dataset-public/dataset-public-listing.component.ts +++ b/dmp-frontend/src/app/datasets/dataset-public/dataset-public-listing.component.ts @@ -1,152 +1,153 @@ -import { OnInit, Component, ViewChild } from "@angular/core"; -import { MatSort, MatPaginator, PageEvent, MatSnackBar } from "@angular/material"; -import { DatasetCriteriaComponent } from "../../shared/components/criteria/datasets/datasets-criteria.component"; -import { Observable } from "rxjs"; -import { BreadcrumbItem } from "../../shared/components/breadcrumb/definition/breadcrumb-item"; -import { DatasetService } from "../../services/dataset/dataset.service"; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service"; -import { DatasetCriteria } from "../../models/criteria/dataset/DatasetCriteria"; -import { DataSource } from "@angular/cdk/table"; -import { DatasetListingModel } from "../../models/datasets/DatasetListingModel"; -import { DataTableRequest } from "../../models/data-table/DataTableRequest"; -import { FacetSearchCriteriaModel } from "../../models/facet-search/FacetSearchCriteriaModel"; +import { OnInit, Component, ViewChild } from '@angular/core'; +import { MatSort, MatPaginator, PageEvent, MatSnackBar } from '@angular/material'; +import { DatasetCriteriaComponent } from '../../shared/components/criteria/datasets/datasets-criteria.component'; +import { Observable } from 'rxjs'; +import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item'; +import { DatasetService } from '../../services/dataset/dataset.service'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service'; +import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria'; +import { DataSource } from '@angular/cdk/table'; +import { DatasetListingModel } from '../../models/datasets/DatasetListingModel'; +import { DataTableRequest } from '../../models/data-table/DataTableRequest'; +import { FacetSearchCriteriaModel } from '../../models/facet-search/FacetSearchCriteriaModel'; @Component({ - selector: 'app-dataset-public-listing-component', - templateUrl: 'dataset-public-listing.component.html', - styleUrls: ['./dataset-public-listing.component.scss'], + selector: 'app-dataset-public-listing-component', + templateUrl: 'dataset-public-listing.component.html', + styleUrls: ['./dataset-public-listing.component.scss'], }) export class DatasetPublicListingComponent implements OnInit { - @ViewChild(MatPaginator) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; + @ViewChild(MatPaginator) _paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; - dataSource: DatasetDataSource | null; - displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created']; - pageEvent: PageEvent; - titlePrefix: String; - dmpId: string; + dataSource: DatasetDataSource | null; + displayedColumns: String[] = ['label', 'dmp', 'profile', 'status', 'description', 'created']; + pageEvent: PageEvent; + titlePrefix: String; + dmpId: string; - constructor( - private datasetService: DatasetService, - private router: Router, - private languageService: TranslateService, - public snackBar: MatSnackBar, - public route: ActivatedRoute, - public dataManagementPlanService: DataManagementPlanService - ) { + constructor( + private datasetService: DatasetService, + private router: Router, + private languageService: TranslateService, + public snackBar: MatSnackBar, + public route: ActivatedRoute, + public dataManagementPlanService: DataManagementPlanService + ) { - } + } - 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) { - let dmp = await this.dataManagementPlanService.getSingle(this.dmpId).toPromise() - if (params['dmpLabel'] != undefined) - this.titlePrefix = "for " + params['dmpLabel']; - } - }); - } + 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) { + this.titlePrefix = 'for ' + params['dmpLabel']; + } + } + }); + } - onCriteriaChange(event){ - //console.log(event) - this.criteria.setCriteria(event); - this.refresh(); - } + onCriteriaChange(event) { + //console.log(event) + this.criteria.setCriteria(event); + this.refresh(); + } - refresh() { - this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId); - } + refresh() { + this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId); + } - rowClick(rowId: String) { - this.router.navigate(['/datasets/publicEdit/' + rowId]); - } + rowClick(rowId: String) { + this.router.navigate(['/datasets/publicEdit/' + rowId]); + } - getDefaultCriteria(dmpId: String): DatasetCriteria { - const defaultCriteria = new DatasetCriteria(); - if (dmpId != null) { - defaultCriteria.dmpIds.push(dmpId); - } - return defaultCriteria; - } + getDefaultCriteria(dmpId: String): DatasetCriteria { + const defaultCriteria = new DatasetCriteria(); + if (dmpId != null) { + defaultCriteria.dmpIds.push(dmpId); + } + return defaultCriteria; + } - makeItPublic(id: String) { - this.datasetService.makeDatasetPublic(id).subscribe(); - } + makeItPublic(id: String) { + this.datasetService.makeDatasetPublic(id).subscribe(); + } } export class DatasetDataSource extends DataSource { - totalCount = 0; - isLoadingResults = false; - constructor( - private _service: DatasetService, - private _paginator: MatPaginator, - private _sort: MatSort, - private _languageService: TranslateService, - private _snackBar: MatSnackBar, - private _criteria: DatasetCriteriaComponent, - private dmpId: String - ) { - super(); + totalCount = 0; + isLoadingResults = false; + constructor( + private _service: DatasetService, + private _paginator: MatPaginator, + private _sort: MatSort, + private _languageService: TranslateService, + private _snackBar: MatSnackBar, + private _criteria: DatasetCriteriaComponent, + private dmpId: String + ) { + super(); - } + } - connect(): Observable { - const displayDataChanges = [ - this._paginator.page - //this._sort.matSortChange - ]; + connect(): Observable { + const displayDataChanges = [ + this._paginator.page + //this._sort.matSortChange + ]; - return Observable.merge(...displayDataChanges) - .startWith(null) - .switchMap(() => { - setTimeout(() => { - this.isLoadingResults = true; - }); - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array() - if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria.criteria; - //if (this.dmpId) request.criteria.allVersions = true; - return this._service.getPublicPaged(request); - }) - /*.catch((error: any) => { - this._snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, - duration: 3000, - extraClasses: ['snackbar-warning'] - }); - //this._criteria.criteria.onCallbackError(error); - return Observable.of(null); - })*/ - .map(result => { - setTimeout(() => { - this.isLoadingResults = false; - }); - return result; - }) - .map(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - return result.data; - }); - } + return Observable.merge(...displayDataChanges) + .startWith(null) + .switchMap(() => { + setTimeout(() => { + this.isLoadingResults = true; + }); + const startIndex = this._paginator.pageIndex * this._paginator.pageSize; + let fields: Array = new Array(); + if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); + request.criteria = this._criteria.criteria; + //if (this.dmpId) request.criteria.allVersions = true; + return this._service.getPublicPaged(request); + }) + /*.catch((error: any) => { + this._snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, + duration: 3000, + extraClasses: ['snackbar-warning'] + }); + //this._criteria.criteria.onCallbackError(error); + return Observable.of(null); + })*/ + .map(result => { + setTimeout(() => { + this.isLoadingResults = false; + }); + return result; + }) + .map(result => { + if (!result) { return []; } + if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } + return result.data; + }); + } - disconnect() { - // No-op - } + disconnect() { + // No-op + } } diff --git a/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/datarepository/datarepository-referenced-model-helper.component.ts b/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/datarepository/datarepository-referenced-model-helper.component.ts index 8d9268114..f79d69d12 100644 --- a/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/datarepository/datarepository-referenced-model-helper.component.ts +++ b/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/datarepository/datarepository-referenced-model-helper.component.ts @@ -1,36 +1,36 @@ -import { Component, ViewEncapsulation, OnInit, Inject } from "@angular/core"; -import { FormGroup } from "@angular/forms"; -import { DataRepositoryService } from "../../../services/datarepository/datarepository.service"; -import { Router, ActivatedRoute } from "@angular/router"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material"; -import { DataRepositoryModel } from "../../../models/dataRepositories/DataRepositoryModel"; +import { Component, ViewEncapsulation, OnInit, Inject } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { DataRepositoryService } from '../../../services/datarepository/datarepository.service'; +import { Router, ActivatedRoute } from '@angular/router'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { DataRepositoryModel } from '../../../models/dataRepositories/DataRepositoryModel'; @Component({ - selector: 'app-datarepository-referenced-model-helper', - templateUrl: 'datarepository-referenced-model-helper.component.html', - styleUrls: ['./datarepository-referenced-model-helper.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-datarepository-referenced-model-helper', + templateUrl: 'datarepository-referenced-model-helper.component.html', + styleUrls: ['./datarepository-referenced-model-helper.component.scss'], + encapsulation: ViewEncapsulation.None }) export class DataRepositoryReferencedModelHelperComponent implements OnInit { - public formGroup: FormGroup; + public formGroup: FormGroup; - constructor( - private dataRepositoryService: DataRepositoryService, - private route: ActivatedRoute, - public router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } + constructor( + private dataRepositoryService: DataRepositoryService, + private route: ActivatedRoute, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } - ngOnInit(): void { - let datarepo = new DataRepositoryModel(); - this.formGroup = datarepo.buildForm(); - } + ngOnInit(): void { + const datarepo = new DataRepositoryModel(); + this.formGroup = datarepo.buildForm(); + } - send(value: any) { - this.dataRepositoryService.create(this.formGroup.value).subscribe( - (item)=> this.dialogRef.close(item) - ); - } + send(value: any) { + this.dataRepositoryService.create(this.formGroup.value).subscribe( + (item) => this.dialogRef.close(item) + ); + } } diff --git a/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/externalDataset/externaldataset-referenced-model-helper.component.ts b/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/externalDataset/externaldataset-referenced-model-helper.component.ts index 910be61b3..688180ba8 100644 --- a/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/externalDataset/externaldataset-referenced-model-helper.component.ts +++ b/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/externalDataset/externaldataset-referenced-model-helper.component.ts @@ -1,36 +1,36 @@ -import { ExternalDatasetModel } from "../../../models/external-dataset/ExternalDatasetModel"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material"; -import { Inject, ViewEncapsulation, Component, OnInit } from "@angular/core"; -import { ActivatedRoute, Router } from "@angular/router"; -import { ExternalDatasetService } from "../../../services/external-dataset/external-dataset.service"; -import { FormGroup } from "@angular/forms"; +import { ExternalDatasetModel } from '../../../models/external-dataset/ExternalDatasetModel'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { Inject, ViewEncapsulation, Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { ExternalDatasetService } from '../../../services/external-dataset/external-dataset.service'; +import { FormGroup } from '@angular/forms'; @Component({ - selector: 'app-externaldataset-referenced-model-helper', - templateUrl: 'externaldataset-referenced-model-helper.component.html', - styleUrls: ['./externaldataset-referenced-model-helper.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-externaldataset-referenced-model-helper', + templateUrl: 'externaldataset-referenced-model-helper.component.html', + styleUrls: ['./externaldataset-referenced-model-helper.component.scss'], + encapsulation: ViewEncapsulation.None }) export class ExternalDatasetReferencedModelHelperComponent implements OnInit { - public formGroup: FormGroup; + public formGroup: FormGroup; - constructor( - private externalDatasetService: ExternalDatasetService, - private route: ActivatedRoute, - public router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } + constructor( + private externalDatasetService: ExternalDatasetService, + private route: ActivatedRoute, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } - ngOnInit(): void { - let externalDatasetModel = new ExternalDatasetModel(); - this.formGroup = externalDatasetModel.buildForm(); - } + ngOnInit(): void { + const externalDatasetModel = new ExternalDatasetModel(); + this.formGroup = externalDatasetModel.buildForm(); + } - send(value: any) { - this.externalDatasetService.create(this.formGroup.value).subscribe( - (item)=> this.dialogRef.close(item) - ); - } + send(value: any) { + this.externalDatasetService.create(this.formGroup.value).subscribe( + (item) => this.dialogRef.close(item) + ); + } } diff --git a/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/registry/registry-referenced-model-helper.component.ts b/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/registry/registry-referenced-model-helper.component.ts index a37442f1e..aa77fc6af 100644 --- a/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/registry/registry-referenced-model-helper.component.ts +++ b/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/registry/registry-referenced-model-helper.component.ts @@ -1,36 +1,36 @@ -import { Component, ViewEncapsulation, OnInit, Inject } from "@angular/core"; -import { FormGroup } from "@angular/forms"; -import { ActivatedRoute, Router } from "@angular/router"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material"; -import { RegisterModel } from "../../../models/registers/RegisterModel"; -import { RegistryService } from "../../../services/registries/registry.service"; +import { Component, ViewEncapsulation, OnInit, Inject } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { RegisterModel } from '../../../models/registers/RegisterModel'; +import { RegistryService } from '../../../services/registries/registry.service'; @Component({ - selector: 'app-registry-referenced-model-helper', - templateUrl: 'registry-referenced-model-helper.component.html', - styleUrls: ['./registry-referenced-model-helper.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-registry-referenced-model-helper', + templateUrl: 'registry-referenced-model-helper.component.html', + styleUrls: ['./registry-referenced-model-helper.component.scss'], + encapsulation: ViewEncapsulation.None }) export class RegistryReferencedModelHelperComponent implements OnInit { - public formGroup: FormGroup; + public formGroup: FormGroup; - constructor( - private registryService: RegistryService, - private route: ActivatedRoute, - public router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } + constructor( + private registryService: RegistryService, + private route: ActivatedRoute, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } - ngOnInit(): void { - let registryModel = new RegisterModel(); - this.formGroup = registryModel.buildForm(); - } + ngOnInit(): void { + const registryModel = new RegisterModel(); + this.formGroup = registryModel.buildForm(); + } - send(value: any) { - this.registryService.create(this.formGroup.value).subscribe( - (item)=> this.dialogRef.close(item) - ); - } + send(value: any) { + this.registryService.create(this.formGroup.value).subscribe( + (item) => this.dialogRef.close(item) + ); + } } diff --git a/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/services/services-referenced-model-helper.component.ts b/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/services/services-referenced-model-helper.component.ts index 468e2abe8..83cc04d4b 100644 --- a/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/services/services-referenced-model-helper.component.ts +++ b/dmp-frontend/src/app/datasets/dataset-referenced-models-helper/services/services-referenced-model-helper.component.ts @@ -1,36 +1,36 @@ -import { ViewEncapsulation, Component, OnInit, Inject } from "@angular/core"; -import { FormGroup } from "@angular/forms"; -import { ActivatedRoute, Router } from "@angular/router"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material"; -import { ServiceModel } from "../../../models/services/ServiceModel"; -import { ServicesDataService } from "../../../services/services/services-data.service"; +import { ViewEncapsulation, Component, OnInit, Inject } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { ServiceModel } from '../../../models/services/ServiceModel'; +import { ServicesDataService } from '../../../services/services/services-data.service'; @Component({ - selector: 'app-services-referenced-model-helper', - templateUrl: 'services-referenced-model-helper.component.html', - styleUrls: ['./services-referenced-model-helper.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-services-referenced-model-helper', + templateUrl: 'services-referenced-model-helper.component.html', + styleUrls: ['./services-referenced-model-helper.component.scss'], + encapsulation: ViewEncapsulation.None }) export class ServicesReferencedModelHelperComponent implements OnInit { - public formGroup: FormGroup; + public formGroup: FormGroup; - constructor( - private registryService: ServicesDataService, - private route: ActivatedRoute, - public router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } + constructor( + private registryService: ServicesDataService, + private route: ActivatedRoute, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } - ngOnInit(): void { - let serviceModel = new ServiceModel(); - this.formGroup = serviceModel.buildForm(); - } + ngOnInit(): void { + const serviceModel = new ServiceModel(); + this.formGroup = serviceModel.buildForm(); + } - send() { - this.registryService.create(this.formGroup.value).subscribe( - (item)=> this.dialogRef.close(item) - ); - } + send() { + this.registryService.create(this.formGroup.value).subscribe( + (item) => this.dialogRef.close(item) + ); + } } diff --git a/dmp-frontend/src/app/datasets/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/datasets/dataset-wizard/dataset-wizard.component.html index 947bd3cd5..1a641beb8 100644 --- a/dmp-frontend/src/app/datasets/dataset-wizard/dataset-wizard.component.html +++ b/dmp-frontend/src/app/datasets/dataset-wizard/dataset-wizard.component.html @@ -225,8 +225,8 @@ {{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}} - + diff --git a/dmp-frontend/src/app/dmp-profiles/dmp-profile-editor/dmp-profile-editor.component.ts b/dmp-frontend/src/app/dmp-profiles/dmp-profile-editor/dmp-profile-editor.component.ts index d8c059fbf..5c95a77c8 100644 --- a/dmp-frontend/src/app/dmp-profiles/dmp-profile-editor/dmp-profile-editor.component.ts +++ b/dmp-frontend/src/app/dmp-profiles/dmp-profile-editor/dmp-profile-editor.component.ts @@ -1,177 +1,175 @@ -import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; -import { Observable } from "rxjs/Observable"; -import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service"; -import { ProjectModel } from "../../models/projects/ProjectModel"; -import { JsonSerializer } from "../../utilities/JsonSerializer"; -import { FormGroup, AbstractControl, FormControl, FormArray } from "@angular/forms"; -import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component"; -import { BaseErrorModel } from "../../models/error/BaseErrorModel"; -import { TdDialogService } from "@covalent/core"; -import { HostConfiguration } from "../../app.constants"; -import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service"; -import { DataManagementPlanProfileModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileModel"; -import { DMPProfileFieldDataType, DMPProfileType, DataManagementProfileField } from "../../models/data-management-plan-profile/DataManagementProfileField"; -import { Utilities } from "../../utilities/utilities"; -import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel"; +import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core'; +import { MatPaginator, MatSort, MatSnackBar } from '@angular/material'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; +import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service'; +import { ProjectModel } from '../../models/projects/ProjectModel'; +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms'; +import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component'; +import { BaseErrorModel } from '../../models/error/BaseErrorModel'; +import { TdDialogService } from '@covalent/core'; +import { HostConfiguration } from '../../app.constants'; +import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service'; +import { DataManagementPlanProfileModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileModel'; +import { DMPProfileFieldDataType, DMPProfileType, DataManagementProfileField } from '../../models/data-management-plan-profile/DataManagementProfileField'; +import { Utilities } from '../../utilities/utilities'; +import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel'; @Component({ - selector: 'app-dmp-profile-editor-component', - templateUrl: 'dmp-profile-editor.component.html', - styleUrls: ['./dmp-profile-editor.component.scss'], - providers: [DataManagementPlanProfileService], - encapsulation: ViewEncapsulation.None + selector: 'app-dmp-profile-editor-component', + templateUrl: 'dmp-profile-editor.component.html', + styleUrls: ['./dmp-profile-editor.component.scss'], + providers: [DataManagementPlanProfileService, Utilities], + encapsulation: ViewEncapsulation.None }) export class DataManagementPlanProfileEditorComponent implements AfterViewInit { - isNew = true; - dataManagementPlanProfileModel: DataManagementPlanProfileModel; - formGroup: FormGroup = null; - host = HostConfiguration.Server; - baseErrorModel: BaseErrorModel; - constructor( - private dmpProfileService: DataManagementPlanProfileService, - private route: ActivatedRoute, - public snackBar: MatSnackBar, - public router: Router, - public language: TranslateService, - private dialogService: TdDialogService, - private utilities: Utilities - ) { - } + isNew = true; + dataManagementPlanProfileModel: DataManagementPlanProfileModel; + formGroup: FormGroup = null; + host = HostConfiguration.Server; + baseErrorModel: BaseErrorModel; + constructor( + private dmpProfileService: DataManagementPlanProfileService, + private route: ActivatedRoute, + public snackBar: MatSnackBar, + public router: Router, + public language: TranslateService, + private dialogService: TdDialogService, + private utilities: Utilities + ) { + } - ngAfterViewInit() { - this.route.params.subscribe((params: Params) => { - const itemId = params['id']; + ngAfterViewInit() { + this.route.params.subscribe((params: Params) => { + const itemId = params['id']; - if (itemId != null) { - this.isNew = false; - this.dmpProfileService.getSingle(itemId).map(data => data as DataManagementPlanProfileModel) - .subscribe(data => { - this.dataManagementPlanProfileModel = JsonSerializer.fromJSONObject(data, DataManagementPlanProfileModel); - this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel; - this.formGroup = this.dataManagementPlanProfileModel.buildForm(); - }); - } else { - this.dataManagementPlanProfileModel = new DataManagementPlanProfileModel(); - this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel; + if (itemId != null) { + this.isNew = false; + this.dmpProfileService.getSingle(itemId).map(data => data as DataManagementPlanProfileModel) + .subscribe(data => { + this.dataManagementPlanProfileModel = JsonSerializer.fromJSONObject(data, DataManagementPlanProfileModel); + this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel; + this.formGroup = this.dataManagementPlanProfileModel.buildForm(); + }); + } else { + this.dataManagementPlanProfileModel = new DataManagementPlanProfileModel(); + this.baseErrorModel = this.dataManagementPlanProfileModel.errorModel; - setTimeout(() => { - this.formGroup = this.dataManagementPlanProfileModel.buildForm(); - }); - } - }); - } + setTimeout(() => { + this.formGroup = this.dataManagementPlanProfileModel.buildForm(); + }); + } + }); + } - formSubmit(): void { - this.touchAllFormFields(this.formGroup); - if (!this.isFormValid()) { return; } - this.onSubmit(); - } + formSubmit(): void { + this.touchAllFormFields(this.formGroup); + if (!this.isFormValid()) { return; } + this.onSubmit(); + } - public isFormValid() { - return this.formGroup.valid; - } + public isFormValid() { + return this.formGroup.valid; + } - onSubmit(): void { - this.dmpProfileService.createDataManagementPlan(this.formGroup.value).subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } + onSubmit(): void { + this.dmpProfileService.createDataManagementPlan(this.formGroup.value).subscribe( + complete => this.onCallbackSuccess(), + error => this.onCallbackError(error) + ); + } - onCallbackSuccess(): void { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, - duration: 3000, - }) - this.router.navigate(['/dmp-profiles']); - } + onCallbackSuccess(): void { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, + duration: 3000, + }); + this.router.navigate(['/dmp-profiles']); + } - onCallbackError(errorResponse: any) { - this.setErrorModel(errorResponse.error); - this.validateAllFormFields(this.formGroup); - } + onCallbackError(errorResponse: any) { + this.setErrorModel(errorResponse.error); + this.validateAllFormFields(this.formGroup); + } - public setErrorModel(errorModel: BaseErrorModel) { - Object.keys(errorModel).forEach(item => { - (this.dataManagementPlanProfileModel.errorModel)[item] = (errorModel)[item]; - }) - } + public setErrorModel(errorModel: BaseErrorModel) { + Object.keys(errorModel).forEach(item => { + (this.dataManagementPlanProfileModel.errorModel)[item] = (errorModel)[item]; + }); + } - public cancel(): void { - this.router.navigate(['/dmp-profiles']); - } + public cancel(): void { + this.router.navigate(['/dmp-profiles']); + } - public touchAllFormFields(formControl: AbstractControl) { - if (formControl instanceof FormControl) { - formControl.markAsTouched(); - } else if (formControl instanceof FormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.touchAllFormFields(control); - }) - } - else if (formControl instanceof FormArray) { - formControl.controls.forEach(item => { - this.touchAllFormFields(item); - }) - } - } + public touchAllFormFields(formControl: AbstractControl) { + if (formControl instanceof FormControl) { + formControl.markAsTouched(); + } else if (formControl instanceof FormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + this.touchAllFormFields(control); + }); + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + this.touchAllFormFields(item); + }); + } + } - public validateAllFormFields(formControl: AbstractControl) { - if (formControl instanceof FormControl) { - formControl.updateValueAndValidity({ emitEvent: false }) - } else if (formControl instanceof FormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.validateAllFormFields(control); - }) - } - else if (formControl instanceof FormArray) { - formControl.controls.forEach(item => { - this.validateAllFormFields(item); - }) - } - } + public validateAllFormFields(formControl: AbstractControl) { + if (formControl instanceof FormControl) { + formControl.updateValueAndValidity({ emitEvent: false }); + } else if (formControl instanceof FormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + this.validateAllFormFields(control); + }); + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + this.validateAllFormFields(item); + }); + } + } - addField() { - (this.formGroup.get("definition").get("fields")).push(new DataManagementProfileField().buildForm()) - } + addField() { + (this.formGroup.get('definition').get('fields')).push(new DataManagementProfileField().buildForm()); + } - getDMPProfileFieldDataTypeValues(): Number[] { - let keys: string[] = Object.keys(DMPProfileFieldDataType); - keys = keys.slice(0, keys.length / 2); - const values: Number[] = keys.map(Number); - return values; - } + getDMPProfileFieldDataTypeValues(): Number[] { + let keys: string[] = Object.keys(DMPProfileFieldDataType); + keys = keys.slice(0, keys.length / 2); + const values: Number[] = keys.map(Number); + return values; + } - getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string { - let result = ''; - this.language.get(this.utilities.convertFromDMPProfileDataType(role)).subscribe((value: string) => { - result = value; - }); - return result; - } + getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string { + let result = ''; + this.language.get(this.utilities.convertFromDMPProfileDataType(role)).subscribe((value: string) => { + result = value; + }); + return result; + } - getDMPProfileFieldTypeValues(): Number[] { - let keys: string[] = Object.keys(DMPProfileType); - keys = keys.slice(0, keys.length / 2); - const values: Number[] = keys.map(Number); - return values; - } + getDMPProfileFieldTypeValues(): Number[] { + let keys: string[] = Object.keys(DMPProfileType); + keys = keys.slice(0, keys.length / 2); + const values: Number[] = keys.map(Number); + return values; + } - getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string { - let result = ''; - this.language.get(this.utilities.convertFromDMPProfileType(role)).subscribe((value: string) => { - result = value; - }); - return result; - } + getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string { + let result = ''; + this.language.get(this.utilities.convertFromDMPProfileType(role)).subscribe((value: string) => { + result = value; + }); + return result; + } } diff --git a/dmp-frontend/src/app/dmp-profiles/dmp-profile-listing/dmp-profile-listing.component.ts b/dmp-frontend/src/app/dmp-profiles/dmp-profile-listing/dmp-profile-listing.component.ts index b62e3d766..dc368bbe8 100644 --- a/dmp-frontend/src/app/dmp-profiles/dmp-profile-listing/dmp-profile-listing.component.ts +++ b/dmp-frontend/src/app/dmp-profiles/dmp-profile-listing/dmp-profile-listing.component.ts @@ -1,117 +1,117 @@ -import { Component, ViewChild, OnInit } from "@angular/core"; -import { MatPaginator, MatSort, PageEvent, MatSnackBar } from "@angular/material"; -import { DataManagementPlanProfileCriteriaComponent } from "../../shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component"; -import { ActivatedRoute, Router, Params } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; -import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria"; -import { Observable } from "rxjs"; -import { DataTableRequest } from "../../models/data-table/DataTableRequest"; -import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel"; -import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service"; +import { Component, ViewChild, OnInit } from '@angular/core'; +import { MatPaginator, MatSort, PageEvent, MatSnackBar } from '@angular/material'; +import { DataManagementPlanProfileCriteriaComponent } from '../../shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component'; +import { ActivatedRoute, Router, Params } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; +import { DataManagementPlanProfileCriteria } from '../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria'; +import { Observable } from 'rxjs'; +import { DataTableRequest } from '../../models/data-table/DataTableRequest'; +import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel'; +import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service'; @Component({ - selector: 'app-dmp-profile-listing-component', - templateUrl: 'dmp-profile-listing.component.html', - styleUrls: ['./dmp-profile-listing.component.scss'], - providers: [DataManagementPlanProfileService] + selector: 'app-dmp-profile-listing-component', + templateUrl: 'dmp-profile-listing.component.html', + styleUrls: ['./dmp-profile-listing.component.scss'], + providers: [DataManagementPlanProfileService] }) export class DataManagementPlanProfileListingComponent implements OnInit { - @ViewChild(MatPaginator) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - @ViewChild(DataManagementPlanProfileCriteriaComponent) criteria: DataManagementPlanProfileCriteriaComponent; + @ViewChild(MatPaginator) _paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + @ViewChild(DataManagementPlanProfileCriteriaComponent) criteria: DataManagementPlanProfileCriteriaComponent; - dataSource: DatasetDataSource | null; - displayedColumns: String[] = ['label', 'status', 'created']; - pageEvent: PageEvent; - titlePrefix: String; - dmpId: String; + dataSource: DatasetDataSource | null; + displayedColumns: String[] = ['label', 'status', 'created']; + pageEvent: PageEvent; + titlePrefix: String; + dmpId: String; - statuses = [ - { value: '0', viewValue: 'Active' }, - { value: '1', viewValue: 'Inactive' } - ]; + statuses = [ + { value: '0', viewValue: 'Active' }, + { value: '1', viewValue: 'Inactive' } + ]; - constructor( - private router: Router, - private languageService: TranslateService, - public snackBar: MatSnackBar, - public route: ActivatedRoute, - public dataManagementPlanService: DataManagementPlanProfileService - ) { + constructor( + private router: Router, + private languageService: TranslateService, + public snackBar: MatSnackBar, + public route: ActivatedRoute, + public dataManagementPlanService: DataManagementPlanProfileService + ) { - } + } - ngOnInit() { - this.route.params.subscribe((params: Params) => { - this.dmpId = params['dmpId']; - this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - this.criteria.setRefreshCallback(() => this.refresh()); - }); - } + ngOnInit() { + this.route.params.subscribe((params: Params) => { + this.dmpId = params['dmpId']; + this.criteria.setCriteria(this.getDefaultCriteria()); + this.refresh(); + this.criteria.setRefreshCallback(() => this.refresh()); + }); + } - refresh() { - this.dataSource = new DatasetDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); - } + refresh() { + this.dataSource = new DatasetDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); + } - rowClick(rowId: String) { - this.router.navigate(['dmp-profiles/' + rowId]); - } + rowClick(rowId: String) { + this.router.navigate(['dmp-profiles/' + rowId]); + } - getDefaultCriteria(): DataManagementPlanProfileCriteria { - const defaultCriteria = new DataManagementPlanProfileCriteria(); - return defaultCriteria; - } + getDefaultCriteria(): DataManagementPlanProfileCriteria { + const defaultCriteria = new DataManagementPlanProfileCriteria(); + return defaultCriteria; + } - // makeItPublic(id: String) { - // debugger; - // this.datasetService.makeDatasetPublic(id).subscribe(); - // } + // makeItPublic(id: String) { + // debugger; + // this.datasetService.makeDatasetPublic(id).subscribe(); + // } } export class DatasetDataSource extends DataSource { - totalCount = 0; - isLoadingResults = false; + totalCount = 0; + isLoadingResults = false; - constructor( - private _service: DataManagementPlanProfileService, - private _paginator: MatPaginator, - private _sort: MatSort, - private _languageService: TranslateService, - private _snackBar: MatSnackBar, - private _criteria: DataManagementPlanProfileCriteriaComponent - ) { - super(); + constructor( + private _service: DataManagementPlanProfileService, + private _paginator: MatPaginator, + private _sort: MatSort, + private _languageService: TranslateService, + private _snackBar: MatSnackBar, + private _criteria: DataManagementPlanProfileCriteriaComponent + ) { + super(); - } + } - connect(): Observable { - const displayDataChanges = [ - this._paginator.page - //this._sort.matSortChange - ]; + connect(): Observable { + const displayDataChanges = [ + this._paginator.page + //this._sort.matSortChange + ]; - return Observable.merge(...displayDataChanges) - .startWith(null) - .switchMap(() => { - setTimeout(() => { - this.isLoadingResults = true; - }); - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array() - if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria.criteria; - return this._service.getPaged(request); - }) - /*.catch((error: any) => { + return Observable.merge(...displayDataChanges) + .startWith(null) + .switchMap(() => { + setTimeout(() => { + this.isLoadingResults = true; + }); + const startIndex = this._paginator.pageIndex * this._paginator.pageSize; + let fields: Array = new Array(); + if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); + request.criteria = this._criteria.criteria; + return this._service.getPaged(request); + }) + /*.catch((error: any) => { this._snackBar.openFromComponent(SnackBarNotificationComponent, { data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, duration: 3000, @@ -120,20 +120,20 @@ export class DatasetDataSource extends DataSource { - setTimeout(() => { - this.isLoadingResults = false; - }); - return result; - }) - .map(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - return result.data; - }); - } + .map(result => { + setTimeout(() => { + this.isLoadingResults = false; + }); + return result; + }) + .map(result => { + if (!result) { return []; } + if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } + return result.data; + }); + } - disconnect() { - // No-op - } -} \ No newline at end of file + disconnect() { + // No-op + } +} diff --git a/dmp-frontend/src/app/dmp-profiles/dmp-profile.module.ts b/dmp-frontend/src/app/dmp-profiles/dmp-profile.module.ts index a0b96af77..c3185ea3e 100644 --- a/dmp-frontend/src/app/dmp-profiles/dmp-profile.module.ts +++ b/dmp-frontend/src/app/dmp-profiles/dmp-profile.module.ts @@ -8,50 +8,50 @@ import { HttpClient, HttpClientModule } from '@angular/common/http'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { SharedModule } from '../shared/shared.module' +import { SharedModule } from '../shared/shared.module'; import { DataManagementPlanProfileRoutes } from './dmp-profile.routes'; import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/dmp-profile-editor.component'; import { DataManagementPlanProfileListingComponent } from './dmp-profile-listing/dmp-profile-listing.component'; @NgModule({ - imports: [ - CommonModule, - FormsModule, - HttpClientModule, - SharedModule, - RouterModule.forChild(DataManagementPlanProfileRoutes), - ReactiveFormsModule, - DynamicFormModule, - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [HttpClient] - } - }), - ], + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + SharedModule, + RouterModule.forChild(DataManagementPlanProfileRoutes), + ReactiveFormsModule, + DynamicFormModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + ], - declarations: [ - DataManagementPlanProfileEditorComponent, - DataManagementPlanProfileListingComponent - ], + declarations: [ + DataManagementPlanProfileEditorComponent, + DataManagementPlanProfileListingComponent + ], - exports: [ - DataManagementPlanProfileEditorComponent, - DataManagementPlanProfileListingComponent, - RouterModule - ], - providers: [ - DatasetService - ] + exports: [ + DataManagementPlanProfileEditorComponent, + DataManagementPlanProfileListingComponent, + RouterModule + ], + providers: [ + DatasetService + ] }) export class DataManagamentPlanProfileModule { - constructor(private translate: TranslateService) { - translate.setDefaultLang('en'); - translate.use('en'); - } + constructor(private translate: TranslateService) { + translate.setDefaultLang('en'); + translate.use('en'); + } } export function HttpLoaderFactory(httpClient: HttpClient) { - return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); -} \ No newline at end of file + return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); +} diff --git a/dmp-frontend/src/app/dmp-profiles/dmp-profile.routes.ts b/dmp-frontend/src/app/dmp-profiles/dmp-profile.routes.ts index d218aa830..5b0a4c02a 100644 --- a/dmp-frontend/src/app/dmp-profiles/dmp-profile.routes.ts +++ b/dmp-frontend/src/app/dmp-profiles/dmp-profile.routes.ts @@ -4,7 +4,7 @@ import { DataManagementPlanProfileEditorComponent } from './dmp-profile-editor/d import { AuthGuard } from '../shared/guards/auth.guard'; export const DataManagementPlanProfileRoutes: Routes = [ - { path: '', component: DataManagementPlanProfileListingComponent, canActivate: [AuthGuard] }, - { path: 'new', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] }, - { path: ':id', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] }, + { path: '', component: DataManagementPlanProfileListingComponent, canActivate: [AuthGuard] }, + { path: 'new', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] }, + { path: ':id', component: DataManagementPlanProfileEditorComponent, canActivate: [AuthGuard] }, ]; diff --git a/dmp-frontend/src/app/dmps/dmps.module.ts b/dmp-frontend/src/app/dmps/dmps.module.ts index f4da43ccf..7e0244f97 100644 --- a/dmp-frontend/src/app/dmps/dmps.module.ts +++ b/dmp-frontend/src/app/dmps/dmps.module.ts @@ -15,10 +15,10 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; import { CovalentDialogsModule } from '@covalent/core'; -import { SharedModule } from '../shared/shared.module' +import { SharedModule } from '../shared/shared.module'; import { NgModule } from '@angular/core'; import { AvailableProfilesComponent } from '../shared/components/available-profiles/available-profiles.component'; -import { DynamicDmpFieldResolver } from './editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component'; +import { DynamicDmpFieldResolverComponent } from './editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component'; import { DynamicFieldsProjectComponent } from './editor/dynamic-fields-project/dynamic-fields-project.component'; import { DynamicFieldProjectComponent } from './editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component'; import { BaseHttpModule } from '../utilities/cite-http-service-module/cite-http.module'; @@ -34,76 +34,76 @@ import { DatasetService } from '../services/dataset/dataset.service'; import { FlexLayoutModule } from '@angular/flex-layout'; @NgModule({ - imports: [ - CommonModule, - FormsModule, - HttpClientModule, - SharedModule, - MaterialModule, - RouterModule.forChild(DataManagementPlanRoutes), - ReactiveFormsModule, - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [HttpClient] - } - }), - CovalentDialogsModule - ], + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + SharedModule, + MaterialModule, + RouterModule.forChild(DataManagementPlanRoutes), + ReactiveFormsModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + CovalentDialogsModule + ], - declarations: [ - DataManagementPlanListingComponent, - DataManagementPlanEditorComponent, - InvitationComponent, - InvitationAcceptedComponent, - DataManagementPlanWizardComponent, - DataManagementPlanWizardEditorComponent, - DatasetWizardListingComponent, - AddResearchersComponent, - AvailableProfilesComponent, - DynamicDmpFieldResolver, - DynamicFieldsProjectComponent, - DynamicFieldProjectComponent - ], + declarations: [ + DataManagementPlanListingComponent, + DataManagementPlanEditorComponent, + InvitationComponent, + InvitationAcceptedComponent, + DataManagementPlanWizardComponent, + DataManagementPlanWizardEditorComponent, + DatasetWizardListingComponent, + AddResearchersComponent, + AvailableProfilesComponent, + DynamicDmpFieldResolverComponent, + DynamicFieldsProjectComponent, + DynamicFieldProjectComponent + ], - exports: [ - DataManagementPlanListingComponent, - DataManagementPlanEditorComponent, - InvitationComponent, - InvitationAcceptedComponent, - DataManagementPlanWizardComponent, - DataManagementPlanWizardEditorComponent, - DatasetWizardListingComponent, - AddResearchersComponent, - AvailableProfilesComponent, - DynamicFieldsProjectComponent, - DynamicFieldProjectComponent, - RouterModule - ], - entryComponents: [ - InvitationComponent, - AddResearchersComponent, - AvailableProfilesComponent - ], - providers: [ - ProjectService, - ResearcherService, - DatasetService, - InvitationService, - DataManagementPlanService, - ExternalSourcesService, - DataManagementPlanProfileService - ] + exports: [ + DataManagementPlanListingComponent, + DataManagementPlanEditorComponent, + InvitationComponent, + InvitationAcceptedComponent, + DataManagementPlanWizardComponent, + DataManagementPlanWizardEditorComponent, + DatasetWizardListingComponent, + AddResearchersComponent, + AvailableProfilesComponent, + DynamicFieldsProjectComponent, + DynamicFieldProjectComponent, + RouterModule + ], + entryComponents: [ + InvitationComponent, + AddResearchersComponent, + AvailableProfilesComponent + ], + providers: [ + ProjectService, + ResearcherService, + DatasetService, + InvitationService, + DataManagementPlanService, + ExternalSourcesService, + DataManagementPlanProfileService + ] }) export class DataManagementPlanModule { - constructor(private translate: TranslateService) { - translate.setDefaultLang('en'); - translate.use('en'); - } + constructor(private translate: TranslateService) { + translate.setDefaultLang('en'); + translate.use('en'); + } } export function HttpLoaderFactory(httpClient: HttpClient) { - return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); + return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); } diff --git a/dmp-frontend/src/app/dmps/dmps.routes.ts b/dmp-frontend/src/app/dmps/dmps.routes.ts index b1469ff98..b11423076 100644 --- a/dmp-frontend/src/app/dmps/dmps.routes.ts +++ b/dmp-frontend/src/app/dmps/dmps.routes.ts @@ -6,62 +6,62 @@ import { RouterModule, Routes } from '@angular/router'; import { InvitationAcceptedComponent } from '../shared/components/invitation-accepted/invitation-accepted.component'; export const DataManagementPlanRoutes: Routes = [ - { - path: '', - component: DataManagementPlanListingComponent, - data: { - breadcrumb: true - }, - }, - { - path: 'viewversions/:groupId', - component: DataManagementPlanListingComponent, - data: { - breadcrumb: true - }, - }, - { - path: 'project/:projectId', - component: DataManagementPlanListingComponent, - data: { - breadcrumb: true - }, - }, - { - path: 'edit/:id', - component: DataManagementPlanEditorComponent, - data: { - breadcrumb: true - }, - }, - { - path: 'new', - component: DataManagementPlanEditorComponent, - data: { - breadcrumbs: 'new' - } - }, - { - path: 'new_version/:id', - component: DataManagementPlanWizardComponent, - data: { - clone: false, - breadcrumb: true - }, - }, - { - path: 'clone/:id', - component: DataManagementPlanWizardComponent, - data: { - clone: false, - breadcrumb: true - }, - }, - { - path: "invitation/:id", - component: InvitationAcceptedComponent, - data: { - breadcrumb: true - }, - } + { + path: '', + component: DataManagementPlanListingComponent, + data: { + breadcrumb: true + }, + }, + { + path: 'viewversions/:groupId', + component: DataManagementPlanListingComponent, + data: { + breadcrumb: true + }, + }, + { + path: 'project/:projectId', + component: DataManagementPlanListingComponent, + data: { + breadcrumb: true + }, + }, + { + path: 'edit/:id', + component: DataManagementPlanEditorComponent, + data: { + breadcrumb: true + }, + }, + { + path: 'new', + component: DataManagementPlanEditorComponent, + data: { + breadcrumbs: 'new' + } + }, + { + path: 'new_version/:id', + component: DataManagementPlanWizardComponent, + data: { + clone: false, + breadcrumb: true + }, + }, + { + path: 'clone/:id', + component: DataManagementPlanWizardComponent, + data: { + clone: false, + breadcrumb: true + }, + }, + { + path: 'invitation/:id', + component: InvitationAcceptedComponent, + data: { + breadcrumb: true + }, + } ]; diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html index bd422c4d3..bfade42ce 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html @@ -1,129 +1,138 @@
- {{'DMP-EDITOR.TITLE.NEW' | translate}} - -

{{formGroup?.get('label')?.value}}

-
-
- - -
-
- -
- -
- - - - - -
- -
-
-
- -
- - - {{baseErrorModel.label}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - +
+ +
+ + + + + +
+ +
+
+ + +
+ + + {{baseErrorModel.label}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + - - - {{errorModel.description}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + + + {{errorModel.description}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + -
- - -
- -
-
- - -
- -
-
-
- +
+ + +
+ +
+
+ + +
+ +
+
+
+ -
- - -
-
-
-
- - -
-
- -
-
-
+
+ + +
+
+
+
+ + +
+
+ +
+
+
-

{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}

+

{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}

- - - - - {{ option.label }} - - - - + + + + + {{ option.label }} + + + + - - - + + + -
- -

Associated Users

- - person -
{{user.name}}
-
-
-
+
+ +

Associated Users

+ + person +
{{user.name}}
+
+
+
-
-
- - - - -
-
-
-
-
-
- +
+
+ + + + +
+
+
+ + + + diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts index ecc539027..131051862 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts @@ -1,331 +1,331 @@ -import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar, MatDialog, MatChipList, MatChip } from "@angular/material"; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; -import { Observable } from "rxjs/Observable"; -import { JsonSerializer } from "../../utilities/JsonSerializer"; -import { FormGroup, FormControl } from "@angular/forms"; -import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component"; -import { BaseErrorModel } from "../../models/error/BaseErrorModel"; -import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service"; -import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataManagementPlanModel"; -import { ExternalSourcesService } from "../../services/external-sources/external-sources.service"; -import { ExternalSourcesItemModel } from "../../models/external-sources/ExternalSourcesItemModel"; -import { RequestItem } from "../../models/criteria/RequestItem"; -import { DatasetProfileCriteria } from "../../models/criteria/dataset/DatasetProfileCriteria"; -import { DataManagementPlanCriteriaComponent } from "../../shared/components/criteria/data-management-plan/dmp-criteria.component"; -import { DatasetProfileModel } from "../../models/datasets/DatasetProfileModel"; -import { ProjectCriteria } from "../../models/criteria/project/ProjectCriteria"; -import { ProjectService } from "../../services/project/project.service"; -import { DmpUsersModel } from "../../models/dmpUsers/DmpUsersModel"; -import { AddResearchersComponent } from "../../shared/components/add-researchers/add-researchers.component"; +import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core'; +import { MatPaginator, MatSort, MatSnackBar, MatDialog, MatChipList, MatChip } from '@angular/material'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { FormGroup, FormControl } from '@angular/forms'; +import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component'; +import { BaseErrorModel } from '../../models/error/BaseErrorModel'; +import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service'; +import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel'; +import { ExternalSourcesService } from '../../services/external-sources/external-sources.service'; +import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel'; +import { RequestItem } from '../../models/criteria/RequestItem'; +import { DatasetProfileCriteria } from '../../models/criteria/dataset/DatasetProfileCriteria'; +import { DataManagementPlanCriteriaComponent } from '../../shared/components/criteria/data-management-plan/dmp-criteria.component'; +import { DatasetProfileModel } from '../../models/datasets/DatasetProfileModel'; +import { ProjectCriteria } from '../../models/criteria/project/ProjectCriteria'; +import { ProjectService } from '../../services/project/project.service'; +import { DmpUsersModel } from '../../models/dmpUsers/DmpUsersModel'; +import { AddResearchersComponent } from '../../shared/components/add-researchers/add-researchers.component'; import { ViewContainerRef } from '@angular/core'; import { TdDialogService } from '@covalent/core'; -import { AvailableProfilesComponent } from "../../shared/components/available-profiles/available-profiles.component"; -import { BaseCriteria } from "../../models/criteria/BaseCriteria"; -import { DataManagementPlanProfileService } from "../../services/data-management-plan-profile/datamanagement-profile.service"; -import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel"; -import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria"; -import { DataManagementPlanProfile } from "../../models/data-management-plan-profile/DataManagementPlanProfile"; -import { LanguageResolverService } from "../../services/language-resolver/language-resolver.service"; -import { IBreadCrumbComponent } from "../../shared/components/breadcrumb/definition/IBreadCrumbComponent"; -import { BreadcrumbItem } from "../../shared/components/breadcrumb/definition/breadcrumb-item"; -import { SingleAutoCompleteConfiguration } from "../../shared/components/autocompletes/single/single-auto-complete-configuration"; -import { MultipleAutoCompleteConfiguration } from "../../shared/components/autocompletes/multiple/multiple-auto-complete-configuration"; +import { AvailableProfilesComponent } from '../../shared/components/available-profiles/available-profiles.component'; +import { BaseCriteria } from '../../models/criteria/BaseCriteria'; +import { DataManagementPlanProfileService } from '../../services/data-management-plan-profile/datamanagement-profile.service'; +import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel'; +import { DataManagementPlanProfileCriteria } from '../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria'; +import { DataManagementPlanProfile } from '../../models/data-management-plan-profile/DataManagementPlanProfile'; +import { LanguageResolverService } from '../../services/language-resolver/language-resolver.service'; +import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent'; +import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item'; +import { SingleAutoCompleteConfiguration } from '../../shared/components/autocompletes/single/single-auto-complete-configuration'; +import { MultipleAutoCompleteConfiguration } from '../../shared/components/autocompletes/multiple/multiple-auto-complete-configuration'; @Component({ - selector: 'app-dmp-editor-component', - templateUrl: 'dmp-editor.component.html', - styleUrls: ['./dmp-editor.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-dmp-editor-component', + templateUrl: 'dmp-editor.component.html', + styleUrls: ['./dmp-editor.component.scss'], + encapsulation: ViewEncapsulation.None }) export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadCrumbComponent { - breadCrumbs: Observable; - isNew = true; - textCtrl = new FormControl(); - dataManagementPlan: DataManagementPlanModel; - formGroup: FormGroup = null; + breadCrumbs: Observable; + isNew = true; + textCtrl = new FormControl(); + dataManagementPlan: DataManagementPlanModel; + formGroup: FormGroup = null; - filteringOrganisationsAsync: boolean = false; - filteringResearchersAsync: boolean = false; - filteredProfilesAsync: boolean = false; - filteredOrganisations: ExternalSourcesItemModel[]; - filteredResearchers: ExternalSourcesItemModel[]; - filteredProfiles: DatasetProfileModel[]; + filteringOrganisationsAsync = false; + filteringResearchersAsync = false; + filteredProfilesAsync = false; + filteredOrganisations: ExternalSourcesItemModel[]; + filteredResearchers: ExternalSourcesItemModel[]; + filteredProfiles: DatasetProfileModel[]; - projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - createNewVersion; - associatedUsers: Array - filteredOptions: Observable + createNewVersion; + associatedUsers: Array; + filteredOptions: Observable; - constructor( - private dmpProfileService: DataManagementPlanProfileService, - private dataManagementPlanService: DataManagementPlanService, - private projectService: ProjectService, - private externalSourcesService: ExternalSourcesService, - private route: ActivatedRoute, - public snackBar: MatSnackBar, - public router: Router, - public language: TranslateService, - private _service: DataManagementPlanService, - public dialog: MatDialog, - private _dialogService: TdDialogService, - private _viewContainerRef: ViewContainerRef, - private languageResolverService: LanguageResolverService - ) { - this.filteredOptions = dmpProfileService.getAll({ criteria: new DataManagementPlanProfileCriteria() }); - } + constructor( + private dmpProfileService: DataManagementPlanProfileService, + private dataManagementPlanService: DataManagementPlanService, + private projectService: ProjectService, + private externalSourcesService: ExternalSourcesService, + private route: ActivatedRoute, + public snackBar: MatSnackBar, + public router: Router, + public language: TranslateService, + private _service: DataManagementPlanService, + public dialog: MatDialog, + private _dialogService: TdDialogService, + private _viewContainerRef: ViewContainerRef, + private languageResolverService: LanguageResolverService + ) { + this.filteredOptions = dmpProfileService.getAll({ criteria: new DataManagementPlanProfileCriteria() }); + } - ngAfterViewInit() { - this.route.params.subscribe((params: Params) => { - const itemId = params['id']; + ngAfterViewInit() { + this.route.params.subscribe((params: Params) => { + const itemId = params['id']; - let projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new ProjectCriteria(); - let organisationRequestItem: RequestItem = new RequestItem(); - organisationRequestItem.criteria = new BaseCriteria(); - //this.projectAutoCompleteConfiguration = new AutoCompleteConfiguration(this.projectService.getWithExternal.bind(this.projectService), projectRequestItem); + const projectRequestItem: RequestItem = new RequestItem(); + projectRequestItem.criteria = new ProjectCriteria(); + const organisationRequestItem: RequestItem = new RequestItem(); + organisationRequestItem.criteria = new BaseCriteria(); + //this.projectAutoCompleteConfiguration = new AutoCompleteConfiguration(this.projectService.getWithExternal.bind(this.projectService), projectRequestItem); - this.projectAutoCompleteConfiguration = { - filterFn: this.searchProject.bind(this), - items: this.searchProject(''), - displayFn: (item) => item["label"], - titleFn: (item) => item["label"], - //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), - loadDataOnStart: true - }; + this.projectAutoCompleteConfiguration = { + filterFn: this.searchProject.bind(this), + items: this.searchProject(''), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'], + //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), + loadDataOnStart: true + }; - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)), - displayFn: (item) => item["label"], - titleFn: (item) => item["label"], - //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), - loadDataOnStart: true - }; + this.profilesAutoCompleteConfiguration = { + filterFn: this.filterProfiles.bind(this), + initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'], + //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), + loadDataOnStart: true + }; - this.organisationsAutoCompleteConfiguration = { - filterFn: this.filterOrganisations.bind(this), - initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)), - displayFn: (item) => item["name"], - titleFn: (item) => item["name"], - loadDataOnStart: true - }; + this.organisationsAutoCompleteConfiguration = { + filterFn: this.filterOrganisations.bind(this), + initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['name'], + titleFn: (item) => item['name'], + loadDataOnStart: true + }; - this.researchersAutoCompleteConfiguration = { - filterFn: this.filterResearchers.bind(this), - initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)), - displayFn: (item) => item["name"], - titleFn: (item) => item["name"], - loadDataOnStart: true - }; + this.researchersAutoCompleteConfiguration = { + filterFn: this.filterResearchers.bind(this), + initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['name'], + titleFn: (item) => item['name'], + loadDataOnStart: true + }; - if (itemId != null) { - this.isNew = false; - this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel) - .subscribe(async data => { - this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel); - this.formGroup = this.dataManagementPlan.buildForm(); - if (this.formGroup.get("profile") && this.formGroup.get("profile").value) { - this.textCtrl.patchValue(this.formGroup.get("profile").value); - } - this.breadCrumbs = Observable.of([ - { - parentComponentName: "DataManagementPlanListingComponent", - label: 'DMPs', - url: "dmps", - notFoundResolver: [await this.projectService.getSingle(this.dataManagementPlan.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()] - } - ] - ) - this.associatedUsers = data.associatedUsers; - }); - } else { - this.dataManagementPlan = new DataManagementPlanModel(); - setTimeout(async () => { - this.formGroup = this.dataManagementPlan.buildForm(); - if (this.formGroup.get("profile") && this.formGroup.get("profile").value) { - this.textCtrl.patchValue(this.formGroup.get("profile").value); - } - this.breadCrumbs = Observable.of([ - { - parentComponentName: "DataManagementPlanListingComponent", - label: 'DMPs', - url: "dmps", - } - ]) - }); - } + if (itemId != null) { + this.isNew = false; + this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel) + .subscribe(async data => { + this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel); + this.formGroup = this.dataManagementPlan.buildForm(); + if (this.formGroup.get('profile') && this.formGroup.get('profile').value) { + this.textCtrl.patchValue(this.formGroup.get('profile').value); + } + this.breadCrumbs = Observable.of([ + { + parentComponentName: 'DataManagementPlanListingComponent', + label: 'DMPs', + url: 'dmps', + notFoundResolver: [await this.projectService.getSingle(this.dataManagementPlan.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()] + } + ] + ); + this.associatedUsers = data.associatedUsers; + }); + } else { + this.dataManagementPlan = new DataManagementPlanModel(); + setTimeout(async () => { + this.formGroup = this.dataManagementPlan.buildForm(); + if (this.formGroup.get('profile') && this.formGroup.get('profile').value) { + this.textCtrl.patchValue(this.formGroup.get('profile').value); + } + this.breadCrumbs = Observable.of([ + { + parentComponentName: 'DataManagementPlanListingComponent', + label: 'DMPs', + url: 'dmps', + } + ]); + }); + } - }); - this.route - .queryParams - .subscribe(params => { - this.createNewVersion = params["clone"]; - }); - } + }); + this.route + .queryParams + .subscribe(params => { + this.createNewVersion = params['clone']; + }); + } - searchProject(query: string) { - let projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new ProjectCriteria(); - projectRequestItem.criteria.like = query; - return this.projectService.getWithExternal(projectRequestItem); - } + searchProject(query: string) { + const projectRequestItem: RequestItem = new RequestItem(); + projectRequestItem.criteria = new ProjectCriteria(); + projectRequestItem.criteria.like = query; + return this.projectService.getWithExternal(projectRequestItem); + } - formSubmit(): void { - //this.touchAllFormFields(this.formGroup); - if (!this.isFormValid()) { return; } - this.onSubmit(); - } + formSubmit(): void { + //this.touchAllFormFields(this.formGroup); + if (!this.isFormValid()) { return; } + this.onSubmit(); + } - public isFormValid() { - return this.formGroup.valid; - } + public isFormValid() { + return this.formGroup.valid; + } - onSubmit(): void { - this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ) - } + onSubmit(): void { + this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe( + complete => this.onCallbackSuccess(), + error => this.onCallbackError(error) + ); + } - onCallbackSuccess(): void { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, - duration: 3000, - }) - this.router.navigate(['/dmps']); - } + onCallbackSuccess(): void { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, + duration: 3000, + }); + this.router.navigate(['/dmps']); + } - onCallbackError(error: any) { - this.setErrorModel(error.error); - //this.validateAllFormFields(this.formGroup); - } + onCallbackError(error: any) { + this.setErrorModel(error.error); + //this.validateAllFormFields(this.formGroup); + } - public setErrorModel(errorModel: BaseErrorModel) { - Object.keys(errorModel).forEach(item => { - (this.dataManagementPlan.errorModel)[item] = (errorModel)[item]; - }) - } + public setErrorModel(errorModel: BaseErrorModel) { + Object.keys(errorModel).forEach(item => { + (this.dataManagementPlan.errorModel)[item] = (errorModel)[item]; + }); + } - public cancel(): void { - this.router.navigate(['/dmps']); - } + public cancel(): void { + this.router.navigate(['/dmps']); + } - public invite(): void { - this.router.navigate(['/invite/' + this.dataManagementPlan.id]); - } + public invite(): void { + this.router.navigate(['/invite/' + this.dataManagementPlan.id]); + } - filterOrganisations(value: string): Observable { + filterOrganisations(value: string): Observable { - this.filteredOrganisations = undefined; - this.filteringOrganisationsAsync = true; + this.filteredOrganisations = undefined; + this.filteringOrganisationsAsync = true; - return this.externalSourcesService.searchDMPOrganizations(value) - } + return this.externalSourcesService.searchDMPOrganizations(value); + } - filterResearchers(value: string): Observable { + filterResearchers(value: string): Observable { - this.filteredResearchers = undefined; - this.filteringResearchersAsync = true; + this.filteredResearchers = undefined; + this.filteringResearchersAsync = true; - return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }) - } + return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }); + } - filterProfiles(value: string): Observable { + filterProfiles(value: string): Observable { - this.filteredProfiles = undefined; - this.filteredProfilesAsync = true; + this.filteredProfiles = undefined; + this.filteredProfilesAsync = true; - const request = new RequestItem(); - let criteria = new DatasetProfileCriteria(); - criteria.like = value; - request.criteria = criteria; - return this._service.searchDMPProfiles(request) - } + const request = new RequestItem(); + const criteria = new DatasetProfileCriteria(); + criteria.like = value; + request.criteria = criteria; + return this._service.searchDMPProfiles(request); + } - addResearcher(rowId: any, rowName: any) { - let dialogRef = this.dialog.open(AddResearchersComponent, { - height: '255px', - width: '700px', - data: { - dmpId: rowId, - dmpName: rowName - } - }); + addResearcher(rowId: any, rowName: any) { + const dialogRef = this.dialog.open(AddResearchersComponent, { + height: '255px', + width: '700px', + data: { + dmpId: rowId, + dmpName: rowName + } + }); - } + } - availableProfiles() { - let dialogRef = this.dialog.open(AvailableProfilesComponent, { - height: '355px', - width: '700px', - data: { - profiles: this.formGroup.get("profiles") - } - }); + availableProfiles() { + const dialogRef = this.dialog.open(AvailableProfilesComponent, { + height: '355px', + width: '700px', + data: { + profiles: this.formGroup.get('profiles') + } + }); - return false; - } + return false; + } - openConfirm(dmpLabel, id): void { - this._dialogService.openConfirm({ - message: 'Are you sure you want to delete the "' + dmpLabel + '"', - disableClose: true || false, // defaults to false - viewContainerRef: this._viewContainerRef, //OPTIONAL - title: 'Confirm', //OPTIONAL, hides if not provided - cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL' - acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT' - // width: '500px', //OPTIONAL, defaults to 400px - }).afterClosed().subscribe((accept: boolean) => { - if (accept) { - this.dataManagementPlanService.delete(id).subscribe(() => { - this.router.navigate(['/dmps']) - }); - } else { - // DO SOMETHING ELSE - } - }); - } + openConfirm(dmpLabel, id): void { + this._dialogService.openConfirm({ + message: 'Are you sure you want to delete the "' + dmpLabel + '"', + disableClose: true || false, // defaults to false + viewContainerRef: this._viewContainerRef, //OPTIONAL + title: 'Confirm', //OPTIONAL, hides if not provided + cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL' + acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT' + // width: '500px', //OPTIONAL, defaults to 400px + }).afterClosed().subscribe((accept: boolean) => { + if (accept) { + this.dataManagementPlanService.delete(id).subscribe(() => { + this.router.navigate(['/dmps']); + }); + } else { + // DO SOMETHING ELSE + } + }); + } - selectOption(option: any) { - this.dataManagementPlan.definition = null; - this.formGroup.get("profile").patchValue(option, { emitEvent: false }) - this.dmpProfileService.getSingle(option.id).subscribe(result => { - this.dataManagementPlan.definition = result.definition; - }) - } + selectOption(option: any) { + this.dataManagementPlan.definition = null; + this.formGroup.get('profile').patchValue(option, { emitEvent: false }); + this.dmpProfileService.getSingle(option.id).subscribe(result => { + this.dataManagementPlan.definition = result.definition; + }); + } - displayWith(item: any) { - if (!item) return null; - return item["label"]; - } + displayWith(item: any) { + if (!item) { return null; } + return item['label']; + } - redirectToProject() { - this.router.navigate(["projects/edit/" + this.dataManagementPlan.project.id]) - } + redirectToProject() { + this.router.navigate(['projects/edit/' + this.dataManagementPlan.project.id]); + } - redirectToDatasets() { - this.router.navigate(["datasets/dmp/" + this.dataManagementPlan.id]) - } + redirectToDatasets() { + this.router.navigate(['datasets/dmp/' + this.dataManagementPlan.id]); + } - newVersion(id: String, label: String) { - this.router.navigate(['/dmps/new_version/' + id, { dmpLabel: label }]); - } + newVersion(id: String, label: String) { + this.router.navigate(['/dmps/new_version/' + id, { dmpLabel: label }]); + } - clone(id: String) { - this.router.navigate(['/dmps/clone/' + id]); - } - viewVersions(rowId: String, rowLabel: String) { - this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } + clone(id: String) { + this.router.navigate(['/dmps/clone/' + id]); + } + viewVersions(rowId: String, rowLabel: String) { + this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } }); + } } diff --git a/dmp-frontend/src/app/dmps/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component.ts b/dmp-frontend/src/app/dmps/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component.ts index 8120092ca..ae779c2ff 100644 --- a/dmp-frontend/src/app/dmps/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component.ts +++ b/dmp-frontend/src/app/dmps/editor/dynamic-field-resolver/dynamic-dmp-field-resolver.component.ts @@ -1,40 +1,40 @@ -import { Component, ViewEncapsulation, AfterViewInit, Input, OnInit, OnDestroy } from "@angular/core"; -import { DataManagementPlanProfile } from "../../../models/data-management-plan-profile/DataManagementPlanProfile"; -import { DMPProfileFieldDataType, DMPProfileType } from "../../../models/data-management-plan-profile/DataManagementProfileField"; -import { FormGroup, FormBuilder, FormArray } from "@angular/forms"; -import { LanguageResolverService } from "../../../services/language-resolver/language-resolver.service"; +import { Component, ViewEncapsulation, AfterViewInit, Input, OnInit, OnDestroy } from '@angular/core'; +import { DataManagementPlanProfile } from '../../../models/data-management-plan-profile/DataManagementPlanProfile'; +import { DMPProfileFieldDataType, DMPProfileType } from '../../../models/data-management-plan-profile/DataManagementProfileField'; +import { FormGroup, FormBuilder, FormArray } from '@angular/forms'; +import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service'; @Component({ - selector: 'app-dynamic-dmp-field-resolver', - templateUrl: 'dynamic-dmp-field-resolver.component.html', - styleUrls: ['./dynamic-dmp-field-resolver.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-dynamic-dmp-field-resolver', + templateUrl: 'dynamic-dmp-field-resolver.component.html', + styleUrls: ['./dynamic-dmp-field-resolver.component.scss'], + encapsulation: ViewEncapsulation.None }) -export class DynamicDmpFieldResolver implements OnInit, OnDestroy { +export class DynamicDmpFieldResolverComponent implements OnInit, OnDestroy { - DMPProfileFieldDataType = DMPProfileFieldDataType; - DMPProfileType = DMPProfileType; + DMPProfileFieldDataType = DMPProfileFieldDataType; + DMPProfileType = DMPProfileType; - @Input() - dataManagementPlanProfile: DataManagementPlanProfile; + @Input() + dataManagementPlanProfile: DataManagementPlanProfile; - @Input() - formGroup: FormGroup + @Input() + formGroup: FormGroup; - ngOnInit(): void { - this.formGroup.addControl("properties", new FormBuilder().group([])); - (this.formGroup.get("properties")).addControl("fields", new FormBuilder().array([])) + ngOnInit(): void { + this.formGroup.addControl('properties', new FormBuilder().group([])); + (this.formGroup.get('properties')).addControl('fields', new FormBuilder().array([])); - this.dataManagementPlanProfile.fields.forEach(item => { - (this.formGroup.get("properties").get("fields")).push(new FormBuilder().group({ - id: [item.id], - value: [item.value] - })) - }) - } + this.dataManagementPlanProfile.fields.forEach(item => { + (this.formGroup.get('properties').get('fields')).push(new FormBuilder().group({ + id: [item.id], + value: [item.value] + })); + }); + } - ngOnDestroy(): void { - this.formGroup.removeControl("properties") - } + ngOnDestroy(): void { + this.formGroup.removeControl('properties'); + } } diff --git a/dmp-frontend/src/app/dmps/editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component.ts b/dmp-frontend/src/app/dmps/editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component.ts index f394def31..63c93bcca 100644 --- a/dmp-frontend/src/app/dmps/editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component.ts +++ b/dmp-frontend/src/app/dmps/editor/dynamic-fields-project/dynamic-field-project/dynamic-field-project.component.ts @@ -1,84 +1,84 @@ -import { Component, ViewEncapsulation, OnInit, Input, ViewChild } from "@angular/core"; -import { FormGroup } from "@angular/forms"; -import { DataManagementPlanService } from "../../../../services/data-management-plan/data-management-plan.service"; -import { RequestItem } from "../../../../models/criteria/RequestItem"; -import { DynamicFieldProjectCriteria, DynamicFieldProjectCriteriaDependencies } from "../../../../models/dynamic-field-project/DynamicFieldProjectCriteria"; -import { AutoCompleteComponent } from "../../../../shared/components/auto-complete/auto-complete.component"; -import { DynamicFieldDependency } from "../../../../models/data-managemnt-plans/DynamicFieldDependency"; -import { LanguageResolverService } from "../../../../services/language-resolver/language-resolver.service"; -import { AutoCompleteConfiguration } from "../../../../shared/components/auto-complete/AutoCompleteConfiguration"; +import { Component, ViewEncapsulation, OnInit, Input, ViewChild } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { DataManagementPlanService } from '../../../../services/data-management-plan/data-management-plan.service'; +import { RequestItem } from '../../../../models/criteria/RequestItem'; +import { DynamicFieldProjectCriteria, DynamicFieldProjectCriteriaDependencies } from '../../../../models/dynamic-field-project/DynamicFieldProjectCriteria'; +import { AutoCompleteComponent } from '../../../../shared/components/auto-complete/auto-complete.component'; +import { DynamicFieldDependency } from '../../../../models/data-managemnt-plans/DynamicFieldDependency'; +import { LanguageResolverService } from '../../../../services/language-resolver/language-resolver.service'; +import { AutoCompleteConfiguration } from '../../../../shared/components/auto-complete/AutoCompleteConfiguration'; @Component({ - selector: 'app-dynamic-field-project', - templateUrl: 'dynamic-field-project.component.html', - styleUrls: ['./dynamic-field-project.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-dynamic-field-project', + templateUrl: 'dynamic-field-project.component.html', + styleUrls: ['./dynamic-field-project.component.scss'], + encapsulation: ViewEncapsulation.None }) export class DynamicFieldProjectComponent implements OnInit { - constructor(private languageResolverService: LanguageResolverService, private dmpService: DataManagementPlanService) { } + constructor(private languageResolverService: LanguageResolverService, private dmpService: DataManagementPlanService) { } - @Input() - dependencies: Array + @Input() + dependencies: Array; - @Input() - formGroup: FormGroup; + @Input() + formGroup: FormGroup; - @ViewChild(AutoCompleteComponent) - autocomplete: AutoCompleteComponent + @ViewChild(AutoCompleteComponent) + autocomplete: AutoCompleteComponent; - autoCompleteConfiguration: AutoCompleteConfiguration + autoCompleteConfiguration: AutoCompleteConfiguration; - ngOnInit(): void { - let requestItem = new RequestItem() - requestItem.criteria = { id: this.formGroup.get("id").value, dynamicFields: this.buildDependencies() } - this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem); - } + ngOnInit(): void { + const requestItem = new RequestItem(); + requestItem.criteria = { id: this.formGroup.get('id').value, dynamicFields: this.buildDependencies() }; + this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem); + } - hasUnResolvedDependencies() { - if (this.dependencies == null || this.dependencies.length == 0) { - if (this.formGroup.get("value").disabled) { - this.updateConfiguration(); - this.formGroup.get("value").enable({ onlySelf: true, emitEvent: false }) - } - return false; - } - for (let i = 0; i < this.dependencies.length; i++) { - if (!this.dependencies[i].get("value").value) { - this.formGroup.get("value").disable({ onlySelf: true, emitEvent: false }) - return true; - } - } - if (this.formGroup.get("value").disabled) { - this.updateConfiguration(); - this.formGroup.get("value").enable({ onlySelf: true, emitEvent: false }) - } - return false; - } + hasUnResolvedDependencies() { + if (this.dependencies == null || this.dependencies.length === 0) { + if (this.formGroup.get('value').disabled) { + this.updateConfiguration(); + this.formGroup.get('value').enable({ onlySelf: true, emitEvent: false }); + } + return false; + } + for (let i = 0; i < this.dependencies.length; i++) { + if (!this.dependencies[i].get('value').value) { + this.formGroup.get('value').disable({ onlySelf: true, emitEvent: false }); + return true; + } + } + if (this.formGroup.get('value').disabled) { + this.updateConfiguration(); + this.formGroup.get('value').enable({ onlySelf: true, emitEvent: false }); + } + return false; + } - updateConfiguration() { - let requestItem = new RequestItem() - requestItem.criteria = { id: this.formGroup.get("id").value, dynamicFields: this.buildDependencies() } - this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem); - this.autocomplete.inputData = this.autoCompleteConfiguration; - } + updateConfiguration() { + const requestItem = new RequestItem(); + requestItem.criteria = { id: this.formGroup.get('id').value, dynamicFields: this.buildDependencies() }; + this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.dmpService.getDynamicField.bind(this.dmpService), requestItem); + this.autocomplete.inputData = this.autoCompleteConfiguration; + } - buildDependencies(): Array { - if (!this.dependencies || this.dependencies.length == 0) return [] - let dependencies = new Array(); - for (let i = 0; i < this.dependencies.length; i++) { - dependencies.push({ property: this.dependencies[i].get("id").value, value: this.assignFunction(this.dependencies[i].get("value").value) }) - } - return dependencies; - } + buildDependencies(): Array { + if (!this.dependencies || this.dependencies.length === 0) { return []; } + const dependencies = new Array(); + for (let i = 0; i < this.dependencies.length; i++) { + dependencies.push({ property: this.dependencies[i].get('id').value, value: this.assignFunction(this.dependencies[i].get('value').value) }); + } + return dependencies; + } - displayFunction(item: any): any { - if (!item) return null; - return item["label"]; - } + displayFunction(item: any): any { + if (!item) { return null; } + return item['label']; + } - assignFunction(item: any): any { - if (!item) return null; - return item["id"]; - } + assignFunction(item: any): any { + if (!item) { return null; } + return item['id']; + } } diff --git a/dmp-frontend/src/app/dmps/editor/dynamic-fields-project/dynamic-fields-project.component.ts b/dmp-frontend/src/app/dmps/editor/dynamic-fields-project/dynamic-fields-project.component.ts index a42e9f721..d862b8ba6 100644 --- a/dmp-frontend/src/app/dmps/editor/dynamic-fields-project/dynamic-fields-project.component.ts +++ b/dmp-frontend/src/app/dmps/editor/dynamic-fields-project/dynamic-fields-project.component.ts @@ -1,33 +1,33 @@ -import { Component, ViewEncapsulation, OnInit, OnDestroy, Input } from "@angular/core"; -import { FormGroup, FormArray } from "@angular/forms"; -import { DynamicFieldDependency } from "../../../models/data-managemnt-plans/DynamicFieldDependency"; +import { Component, ViewEncapsulation, OnInit, OnDestroy, Input } from '@angular/core'; +import { FormGroup, FormArray } from '@angular/forms'; +import { DynamicFieldDependency } from '../../../models/data-managemnt-plans/DynamicFieldDependency'; @Component({ - selector: 'app-dynamic-fields-project', - templateUrl: 'dynamic-fields-project.component.html', - styleUrls: ['./dynamic-fields-project.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-dynamic-fields-project', + templateUrl: 'dynamic-fields-project.component.html', + styleUrls: ['./dynamic-fields-project.component.scss'], + encapsulation: ViewEncapsulation.None }) export class DynamicFieldsProjectComponent implements OnInit { - @Input() - formGroup: FormGroup; + @Input() + formGroup: FormGroup; - ngOnInit(): void { - } + ngOnInit(): void { + } - findDependencies(id: number) { - let formGroupDependencies: Array = new Array(); - let dynamicFieldDependency: DynamicFieldDependency[] = (this.formGroup.get("dynamicFields")).at(id).get("dependencies").value - if (dynamicFieldDependency.length > 0) { - dynamicFieldDependency.forEach(item => { - let length = (this.formGroup.get("dynamicFields")).length; - for (let i = 0; i < length; i++) { - let formGroup = (this.formGroup.get("dynamicFields")).at(i); - if (formGroup.get("id").value === item.id) formGroupDependencies.push(formGroup); - } - }) - } - return formGroupDependencies; - } + findDependencies(id: number) { + const formGroupDependencies: Array = new Array(); + const dynamicFieldDependency: DynamicFieldDependency[] = (this.formGroup.get('dynamicFields')).at(id).get('dependencies').value; + if (dynamicFieldDependency.length > 0) { + dynamicFieldDependency.forEach(item => { + const length = (this.formGroup.get('dynamicFields')).length; + for (let i = 0; i < length; i++) { + const formGroup = (this.formGroup.get('dynamicFields')).at(i); + if (formGroup.get('id').value === item.id) { formGroupDependencies.push(formGroup); } + } + }); + } + return formGroupDependencies; + } } diff --git a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts index 1191f00c8..a61e91e1c 100644 --- a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.ts @@ -3,15 +3,15 @@ import { DataManagementPlanListingModel } from '../../models/data-managemnt-plan import { InvitationComponent } from '../../shared/components/invitation/invitation.component'; import { DataManagementPlanCriteria } from '../../models/criteria/data-management-plan/DataManagementPlanCriteria'; import { - DataManagementPlanCriteriaComponent, + DataManagementPlanCriteriaComponent, } from '../../shared/components/criteria/data-management-plan/dmp-criteria.component'; import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service'; -import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar, MatDialog } from "@angular/material"; -import { Router, ActivatedRoute, ActivatedRouteSnapshot } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; -import { Observable } from "rxjs/Observable"; +import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core'; +import { MatPaginator, MatSort, MatSnackBar, MatDialog } from '@angular/material'; +import { Router, ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; import { DataManagementPlanRoutes } from '../../dmps/dmps.routes'; import { DatasetRoutes } from '../../datasets/dataset.routes'; import { ProjectModel } from '../../models/projects/ProjectModel'; @@ -22,182 +22,184 @@ import { JsonSerializer } from '../../utilities/JsonSerializer'; @Component({ - selector: 'app-dmp-listing-component', - templateUrl: 'dmp-listing.component.html', - styleUrls: ['./dmp-listing.component.scss'], + selector: 'app-dmp-listing-component', + templateUrl: 'dmp-listing.component.html', + styleUrls: ['./dmp-listing.component.scss'], }) export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbComponent { - @ViewChild(MatPaginator) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - @ViewChild(DataManagementPlanCriteriaComponent) criteria: DataManagementPlanCriteriaComponent; + @ViewChild(MatPaginator) _paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + @ViewChild(DataManagementPlanCriteriaComponent) criteria: DataManagementPlanCriteriaComponent; - breadCrumbs: Observable = Observable.of([]); - dataSource: DataManagementPlanDataSource | null; - displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'datasets', 'actions']; - itemId: string; - projectId: string; - showProject: boolean; - titlePrefix: string; - constructor( - private dataManagementPlanService: DataManagementPlanService, - private router: Router, - private route: ActivatedRoute, - private languageService: TranslateService, - public snackBar: MatSnackBar, - public dialog: MatDialog - ) { + breadCrumbs: Observable = Observable.of([]); + dataSource: DataManagementPlanDataSource | null; + displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'datasets', 'actions']; + itemId: string; + projectId: string; + showProject: boolean; + titlePrefix: string; + constructor( + private dataManagementPlanService: DataManagementPlanService, + private router: Router, + private route: ActivatedRoute, + private languageService: TranslateService, + public snackBar: MatSnackBar, + public dialog: MatDialog + ) { - } + } - ngOnInit() { - this.route.params.subscribe(async params => { - let projectLabel; - if (params["projectId"]) { - this.projectId = params["projectId"]; - this.showProject = false; - let project = new ProjectModel(); - project.id = this.projectId; - this.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false }) - this.refresh(); - projectLabel = this.route.snapshot.queryParams.projectLabel - this.breadCrumbs = Observable.of([{ parentComponentName: "ProjectEditorComponent", label: projectLabel, url: "/projects/edit/" + this.projectId }]) - this.criteria.setRefreshCallback(() => this.refresh()); - } else { - this.itemId = params['groupId']; - this.showProject = true; - let breadCrumbs = []; + ngOnInit() { + this.route.params.subscribe(async params => { + let projectLabel; + if (params['projectId']) { + this.projectId = params['projectId']; + this.showProject = false; + const project = new ProjectModel(); + project.id = this.projectId; + this.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false }); + this.refresh(); + projectLabel = this.route.snapshot.queryParams.projectLabel; + this.breadCrumbs = Observable.of([{ parentComponentName: 'ProjectEditorComponent', label: projectLabel, url: '/projects/edit/' + this.projectId }]); + this.criteria.setRefreshCallback(() => this.refresh()); + } else { + this.itemId = params['groupId']; + this.showProject = true; + const breadCrumbs = []; - if (this.itemId) { - let dmplabel = this.route.snapshot.queryParams.groupLabel - breadCrumbs.push( - { parentComponentName: null, label: 'DMPs', url: "/dmps" }, - ) - } - //else breadCrumbs.push({ parentComponentName: null, label: 'DMPs', url: "/dmps" }) - this.breadCrumbs = Observable.of(breadCrumbs) + if (this.itemId) { + const dmplabel = this.route.snapshot.queryParams.groupLabel; + breadCrumbs.push( + { parentComponentName: null, label: 'DMPs', url: '/dmps' }, + ); + } + //else breadCrumbs.push({ parentComponentName: null, label: 'DMPs', url: "/dmps" }) + this.breadCrumbs = Observable.of(breadCrumbs); - this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - this.criteria.setRefreshCallback(() => this.refresh()); - } + this.criteria.setCriteria(this.getDefaultCriteria()); + this.refresh(); + this.criteria.setRefreshCallback(() => this.refresh()); + } - if (this.projectId != null) - if (projectLabel != undefined) - this.titlePrefix = "for " + projectLabel; - }) + if (this.projectId != null) { + if (projectLabel !== undefined) { + this.titlePrefix = 'for ' + projectLabel; + } + } + }); - } + } - refresh() { - this.dataSource = new DataManagementPlanDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.itemId); - } + refresh() { + this.dataSource = new DataManagementPlanDataSource(this.dataManagementPlanService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.itemId); + } - rowClick(rowId: String) { - this.router.navigate(['/dmps/edit/' + rowId]); - } + rowClick(rowId: String) { + this.router.navigate(['/dmps/edit/' + rowId]); + } - addDataset(rowId: String) { - this.router.navigate(['/datasets/new/' + rowId]); - } + addDataset(rowId: String) { + this.router.navigate(['/datasets/new/' + rowId]); + } - showDatasets(rowId: String, rowLabel: String) { - this.router.navigate(['/datasets/dmp/' + rowId, { dmpLabel: rowLabel }]); - } + showDatasets(rowId: String, rowLabel: String) { + this.router.navigate(['/datasets/dmp/' + rowId, { dmpLabel: rowLabel }]); + } - viewVersions(rowId: String, rowLabel: String) { - this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } + viewVersions(rowId: String, rowLabel: String) { + this.router.navigate(['/dmps/viewversions/' + rowId], { queryParams: { groupLabel: rowLabel } }); + } - getDefaultCriteria(): DataManagementPlanCriteria { - const defaultCriteria = new DataManagementPlanCriteria(); - return defaultCriteria; - } + getDefaultCriteria(): DataManagementPlanCriteria { + const defaultCriteria = new DataManagementPlanCriteria(); + return defaultCriteria; + } - openShareDialog(rowId: any, rowName: any) { - let dialogRef = this.dialog.open(InvitationComponent, { - height: '200px', - width: '700px', - data: { - dmpId: rowId, - dmpName: rowName - } - }); - } + openShareDialog(rowId: any, rowName: any) { + const dialogRef = this.dialog.open(InvitationComponent, { + height: '200px', + width: '700px', + data: { + dmpId: rowId, + dmpName: rowName + } + }); + } } export class DataManagementPlanDataSource extends DataSource { - totalCount = 0; - isLoadingResults = false; - constructor( - private _service: DataManagementPlanService, - private _paginator: MatPaginator, - private _sort: MatSort, - private _languageService: TranslateService, - private _snackBar: MatSnackBar, - private _criteria: DataManagementPlanCriteriaComponent, - private itemId - ) { - super(); - } + totalCount = 0; + isLoadingResults = false; + constructor( + private _service: DataManagementPlanService, + private _paginator: MatPaginator, + private _sort: MatSort, + private _languageService: TranslateService, + private _snackBar: MatSnackBar, + private _criteria: DataManagementPlanCriteriaComponent, + private itemId + ) { + super(); + } - connect(): Observable { - const displayDataChanges = [ - this._paginator.page - ]; + connect(): Observable { + const displayDataChanges = [ + this._paginator.page + ]; - return Observable.merge(...displayDataChanges) - .startWith(null) - .switchMap(() => { - setTimeout(() => { - this.isLoadingResults = true; - }); - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array() - if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria.formGroup.value; - if (this.itemId) { - request.criteria.groupIds = [this.itemId]; - request.criteria.allVersions = true; - } - return this._service.getPaged(request); - }) - /*.catch((error: any) => { - this._snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, - duration: 3000, - extraClasses: ['snackbar-warning'] - }); - return Observable.of(null); - })*/ - .map(result => { - result.data = JsonSerializer.fromJSONArray(result.data, DataManagementPlanListingModel) - return result; - }) - .map(result => { - setTimeout(() => { - this.isLoadingResults = false; - }); - return result; - }) - .map(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - return result.data.map(item => { - item["datasets"].map(dmp => { - dmp.url = "datasets/edit/" + dmp.url; - dmp.all = "datasets/dmp/" + item.id - return dmp; - }) - return item; - }); - }); - } + return Observable.merge(...displayDataChanges) + .startWith(null) + .switchMap(() => { + setTimeout(() => { + this.isLoadingResults = true; + }); + const startIndex = this._paginator.pageIndex * this._paginator.pageSize; + let fields: Array = new Array(); + if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); + request.criteria = this._criteria.formGroup.value; + if (this.itemId) { + request.criteria.groupIds = [this.itemId]; + request.criteria.allVersions = true; + } + return this._service.getPaged(request); + }) + /*.catch((error: any) => { + this._snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, + duration: 3000, + extraClasses: ['snackbar-warning'] + }); + return Observable.of(null); + })*/ + .map(result => { + result.data = JsonSerializer.fromJSONArray(result.data, DataManagementPlanListingModel); + return result; + }) + .map(result => { + setTimeout(() => { + this.isLoadingResults = false; + }); + return result; + }) + .map(result => { + if (!result) { return []; } + if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } + return result.data.map(item => { + item['datasets'].map(dmp => { + dmp.url = 'datasets/edit/' + dmp.url; + dmp.all = 'datasets/dmp/' + item.id; + return dmp; + }); + return item; + }); + }); + } - disconnect() { - } + disconnect() { + } } diff --git a/dmp-frontend/src/app/dmps/wizard/dmp-wizard.component.ts b/dmp-frontend/src/app/dmps/wizard/dmp-wizard.component.ts index 2b2b8cc42..8c76b14b5 100644 --- a/dmp-frontend/src/app/dmps/wizard/dmp-wizard.component.ts +++ b/dmp-frontend/src/app/dmps/wizard/dmp-wizard.component.ts @@ -12,73 +12,72 @@ import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definit import { Observable } from 'rxjs/Observable'; import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item'; @Component({ - selector: 'app-dmp-wizard-component', - templateUrl: 'dmp-wizard.component.html', - styleUrls: ['./dmp-wizard.component.scss'], + selector: 'app-dmp-wizard-component', + templateUrl: 'dmp-wizard.component.html', + styleUrls: ['./dmp-wizard.component.scss'], }) export class DataManagementPlanWizardComponent implements OnInit, IBreadCrumbComponent { - breadCrumbs: Observable; - constructor( - private dataManagementPlanService: DataManagementPlanService, - private language: TranslateService, - public snackBar: MatSnackBar, - public route: ActivatedRoute, - private router: Router - ) { } + breadCrumbs: Observable; + constructor( + private dataManagementPlanService: DataManagementPlanService, + private language: TranslateService, + public snackBar: MatSnackBar, + public route: ActivatedRoute, + private router: Router + ) { } - public itemId: string - public dataManagementPlan: DataManagementPlanModel; - public formGroup: FormGroup - public isClone: boolean + public itemId: string; + public dataManagementPlan: DataManagementPlanModel; + public formGroup: FormGroup; + public isClone: boolean; - ngOnInit(): void { + ngOnInit(): void { - this.route.params.subscribe((params: Params) => { - this.itemId = params['id']; - this.dataManagementPlanService.getSingle(this.itemId).map(data => data as DataManagementPlanModel) - .subscribe(data => { - this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel); - this.isClone = this.route.snapshot.data.clone; - if (this.isClone == false) this.dataManagementPlan.version = this.dataManagementPlan.version + 1; - this.formGroup = this.dataManagementPlan.buildForm(); - - }); - }) - } + this.route.params.subscribe((params: Params) => { + this.itemId = params['id']; + this.dataManagementPlanService.getSingle(this.itemId).map(data => data as DataManagementPlanModel) + .subscribe(data => { + this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel); + this.isClone = this.route.snapshot.data.clone; + if (this.isClone === false) { this.dataManagementPlan.version = this.dataManagementPlan.version + 1; } + this.formGroup = this.dataManagementPlan.buildForm(); + }); + }); + } - submit() { - if (this.isClone) { - this.dataManagementPlanService.clone(this.formGroup.getRawValue(), this.itemId).subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } else { - this.dataManagementPlanService.newVersion(this.formGroup.getRawValue(), this.itemId).subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } - } + submit() { + if (this.isClone) { + this.dataManagementPlanService.clone(this.formGroup.getRawValue(), this.itemId).subscribe( + complete => this.onCallbackSuccess(), + error => this.onCallbackError(error) + ); + } else { + this.dataManagementPlanService.newVersion(this.formGroup.getRawValue(), this.itemId).subscribe( + complete => this.onCallbackSuccess(), + error => this.onCallbackError(error) + ); + } + } - onCallbackSuccess(): void { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, - duration: 3000, - }) - this.router.navigate(['/dmps']); - } + onCallbackSuccess(): void { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, + duration: 3000, + }); + this.router.navigate(['/dmps']); + } - onCallbackError(error: any) { - this.setErrorModel(error.error); - //this.validateAllFormFields(this.formGroup); - } + onCallbackError(error: any) { + this.setErrorModel(error.error); + //this.validateAllFormFields(this.formGroup); + } - public setErrorModel(errorModel: BaseErrorModel) { - Object.keys(errorModel).forEach(item => { - // (this.dataManagementPlan.errorModel)[item] = (errorModel)[item]; - }) - } + public setErrorModel(errorModel: BaseErrorModel) { + Object.keys(errorModel).forEach(item => { + // (this.dataManagementPlan.errorModel)[item] = (errorModel)[item]; + }); + } } diff --git a/dmp-frontend/src/app/dmps/wizard/editor/dmp-wizard-editor.component.html b/dmp-frontend/src/app/dmps/wizard/editor/dmp-wizard-editor.component.html index ae5bb3266..420b2fbc6 100644 --- a/dmp-frontend/src/app/dmps/wizard/editor/dmp-wizard-editor.component.html +++ b/dmp-frontend/src/app/dmps/wizard/editor/dmp-wizard-editor.component.html @@ -1,79 +1,79 @@
-
- - - - - {{baseErrorModel.label}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + + + + + + {{baseErrorModel.label}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + - - - {{errorModel.description}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + + + {{errorModel.description}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + -
- - -
- -
-
- - -
- -
-
-
- +
+ + +
+ +
+
+ + +
+ +
+
+
+ -
- - -
-
-
-
- - -
-
- -
-
-
+
+ + +
+
+
+
+ + +
+
+ +
+
+
- - - - + + + + - -

Associated Users

- - person -
{{user.name}}
-
-
-
-
- - + +

Associated Users

+ + person +
{{user.name}}
+
+
+
+
+ +
diff --git a/dmp-frontend/src/app/dmps/wizard/editor/dmp-wizard-editor.component.ts b/dmp-frontend/src/app/dmps/wizard/editor/dmp-wizard-editor.component.ts index fcc3e5f21..591f4b69a 100644 --- a/dmp-frontend/src/app/dmps/wizard/editor/dmp-wizard-editor.component.ts +++ b/dmp-frontend/src/app/dmps/wizard/editor/dmp-wizard-editor.component.ts @@ -11,12 +11,12 @@ import { DataManagementPlanModel } from '../../../models/data-managemnt-plans/Da import { ProjectService } from '../../../services/project/project.service'; import { ExternalSourcesService } from '../../../services/external-sources/external-sources.service'; import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service'; -import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, Input } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; -import { Observable } from "rxjs/Observable"; +import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, Input } from '@angular/core'; +import { MatPaginator, MatSort, MatSnackBar } from '@angular/material'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; import { FormGroup } from '@angular/forms'; import { BaseCriteria } from '../../../models/criteria/BaseCriteria'; import { SingleAutoCompleteConfiguration } from '../../../shared/components/autocompletes/single/single-auto-complete-configuration'; @@ -25,168 +25,168 @@ import { MultipleAutoCompleteConfiguration } from '../../../shared/components/au @Component({ - selector: 'app-dmp-wizard-editor-component', - templateUrl: 'dmp-wizard-editor.component.html', - styleUrls: ['./dmp-wizard-editor.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-dmp-wizard-editor-component', + templateUrl: 'dmp-wizard-editor.component.html', + styleUrls: ['./dmp-wizard-editor.component.scss'], + encapsulation: ViewEncapsulation.None }) export class DataManagementPlanWizardEditorComponent implements OnInit { - isNew = true; - @Input() formGroup: FormGroup = null; + isNew = true; + @Input() formGroup: FormGroup = null; - filteringOrganisationsAsync: boolean = false; - filteringResearchersAsync: boolean = false; - filteredProfilesAsync: boolean = false; - filteredOrganisations: ExternalSourcesItemModel[]; - filteredResearchers: ExternalSourcesItemModel[]; - filteredProfiles: DatasetProfileModel[]; + filteringOrganisationsAsync = false; + filteringResearchersAsync = false; + filteredProfilesAsync = false; + filteredOrganisations: ExternalSourcesItemModel[]; + filteredResearchers: ExternalSourcesItemModel[]; + filteredProfiles: DatasetProfileModel[]; - projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - createNewVersion; - associatedUsers: Array - labelDisabled: boolean = false; + projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + createNewVersion; + associatedUsers: Array; + labelDisabled = false; - constructor( - private dataManagementPlanService: DataManagementPlanService, - private projectService: ProjectService, - private externalSourcesService: ExternalSourcesService, - private route: ActivatedRoute, - public snackBar: MatSnackBar, - public router: Router, - public language: TranslateService, - private _service: DataManagementPlanService, - private languageResolverService: LanguageResolverService - ) { + constructor( + private dataManagementPlanService: DataManagementPlanService, + private projectService: ProjectService, + private externalSourcesService: ExternalSourcesService, + private route: ActivatedRoute, + public snackBar: MatSnackBar, + public router: Router, + public language: TranslateService, + private _service: DataManagementPlanService, + private languageResolverService: LanguageResolverService + ) { - } + } - ngOnInit() { + ngOnInit() { - let projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new ProjectCriteria(); - this.projectAutoCompleteConfiguration = { - filterFn: this.searchProject.bind(this.projectService), - items: this.searchProject(''), - displayFn: (item) => item["label"], - titleFn: (item) => item["label"], - //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), - loadDataOnStart: true - }; + const projectRequestItem: RequestItem = new RequestItem(); + projectRequestItem.criteria = new ProjectCriteria(); + this.projectAutoCompleteConfiguration = { + filterFn: this.searchProject.bind(this.projectService), + items: this.searchProject(''), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'], + //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), + loadDataOnStart: true + }; - this.profilesAutoCompleteConfiguration = { - filterFn: this.filterProfiles.bind(this), - initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)), - displayFn: (item) => item["label"], - titleFn: (item) => item["label"], - //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), - loadDataOnStart: true - }; + this.profilesAutoCompleteConfiguration = { + filterFn: this.filterProfiles.bind(this), + initialItems: (excludedItems: any[]) => this.filterProfiles('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'], + //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), + loadDataOnStart: true + }; - this.organisationsAutoCompleteConfiguration = { - filterFn: this.filterOrganisations.bind(this), - initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)), - displayFn: (item) => item["name"], - titleFn: (item) => item["name"], - loadDataOnStart: true - }; + this.organisationsAutoCompleteConfiguration = { + filterFn: this.filterOrganisations.bind(this), + initialItems: (excludedItems: any[]) => this.filterOrganisations('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['name'], + titleFn: (item) => item['name'], + loadDataOnStart: true + }; - this.researchersAutoCompleteConfiguration = { - filterFn: this.filterResearchers.bind(this), - initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)), - displayFn: (item) => item["name"], - titleFn: (item) => item["name"], - loadDataOnStart: true - }; + this.researchersAutoCompleteConfiguration = { + filterFn: this.filterResearchers.bind(this), + initialItems: (excludedItems: any[]) => this.filterResearchers('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['name'], + titleFn: (item) => item['name'], + loadDataOnStart: true + }; - let organisationRequestItem: RequestItem = new RequestItem(); - organisationRequestItem.criteria = new BaseCriteria(); + const organisationRequestItem: RequestItem = new RequestItem(); + organisationRequestItem.criteria = new BaseCriteria(); - this.route.data.subscribe(value => { - if (value.clone == false && this.formGroup.get("label").value) { - this.labelDisabled = true; - } - this.formGroup.controls["version"].disable(); - }) - } + this.route.data.subscribe(value => { + if (value.clone === false && this.formGroup.get('label').value) { + this.labelDisabled = true; + } + this.formGroup.controls['version'].disable(); + }); + } - searchProject(query: string) { - let projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new ProjectCriteria(); - projectRequestItem.criteria.like = query; - return this.projectService.getWithExternal(projectRequestItem); - } + searchProject(query: string) { + const projectRequestItem: RequestItem = new RequestItem(); + projectRequestItem.criteria = new ProjectCriteria(); + projectRequestItem.criteria.like = query; + return this.projectService.getWithExternal(projectRequestItem); + } - formSubmit(): void { - //this.touchAllFormFields(this.formGroup); - if (!this.isFormValid()) { return; } - this.onSubmit(); - } + formSubmit(): void { + //this.touchAllFormFields(this.formGroup); + if (!this.isFormValid()) { return; } + this.onSubmit(); + } - public isFormValid() { - return this.formGroup.valid; - } + public isFormValid() { + return this.formGroup.valid; + } - onSubmit(): void { - this.dataManagementPlanService.createDataManagementPlan(this.formGroup.getRawValue()).subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } + onSubmit(): void { + this.dataManagementPlanService.createDataManagementPlan(this.formGroup.getRawValue()).subscribe( + complete => this.onCallbackSuccess(), + error => this.onCallbackError(error) + ); + } - onCallbackSuccess(): void { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, - duration: 3000, - }) - this.router.navigate(['/dmps']); - } + onCallbackSuccess(): void { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, + duration: 3000, + }); + this.router.navigate(['/dmps']); + } - onCallbackError(error: any) { - this.setErrorModel(error.error); - //this.validateAllFormFields(this.formGroup); - } + onCallbackError(error: any) { + this.setErrorModel(error.error); + //this.validateAllFormFields(this.formGroup); + } - public setErrorModel(errorModel: BaseErrorModel) { - Object.keys(errorModel).forEach(item => { - // (this.dataManagementPlan.errorModel)[item] = (errorModel)[item]; - }) - } + public setErrorModel(errorModel: BaseErrorModel) { + Object.keys(errorModel).forEach(item => { + // (this.dataManagementPlan.errorModel)[item] = (errorModel)[item]; + }); + } - public cancel(): void { - this.router.navigate(['/dmps']); - } + public cancel(): void { + this.router.navigate(['/dmps']); + } - filterOrganisations(value: string): Observable { + filterOrganisations(value: string): Observable { - this.filteredOrganisations = undefined; - this.filteringOrganisationsAsync = true; + this.filteredOrganisations = undefined; + this.filteringOrganisationsAsync = true; - return this.externalSourcesService.searchDMPOrganizations(value) - } + return this.externalSourcesService.searchDMPOrganizations(value); + } - filterResearchers(value: string): Observable { + filterResearchers(value: string): Observable { - this.filteredResearchers = undefined; - this.filteringResearchersAsync = true; + this.filteredResearchers = undefined; + this.filteringResearchersAsync = true; - return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }) - } + return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } }); + } - filterProfiles(value: string): Observable { + filterProfiles(value: string): Observable { - this.filteredProfiles = undefined; - this.filteredProfilesAsync = true; + this.filteredProfiles = undefined; + this.filteredProfilesAsync = true; - const request = new RequestItem(); - let criteria = new DatasetProfileCriteria(); - criteria.like = value; - request.criteria = criteria; - return this._service.searchDMPProfiles(request) - } + const request = new RequestItem(); + const criteria = new DatasetProfileCriteria(); + criteria.like = value; + request.criteria = criteria; + return this._service.searchDMPProfiles(request); + } } diff --git a/dmp-frontend/src/app/dmps/wizard/listing/dataset-wizard-listing.component.ts b/dmp-frontend/src/app/dmps/wizard/listing/dataset-wizard-listing.component.ts index 97f74830f..e64a490e6 100644 --- a/dmp-frontend/src/app/dmps/wizard/listing/dataset-wizard-listing.component.ts +++ b/dmp-frontend/src/app/dmps/wizard/listing/dataset-wizard-listing.component.ts @@ -7,74 +7,76 @@ import { DataManagementPlanModel } from '../../../models/data-managemnt-plans/Da import { DatasetCriteriaComponent } from '../../../shared/components/criteria/datasets/datasets-criteria.component'; import { DataManagementPlanService } from '../../../services/data-management-plan/data-management-plan.service'; import { DatasetService } from '../../../services/dataset/dataset.service'; -import { Component, ViewChild, OnInit, AfterViewInit, Input } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { Router, Params, ActivatedRoute } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; -import { FormGroup, FormBuilder, FormControl, FormArray } from "@angular/forms" -import { Observable } from "rxjs/Observable"; +import { Component, ViewChild, OnInit, AfterViewInit, Input } from '@angular/core'; +import { MatPaginator, MatSort, MatSnackBar } from '@angular/material'; +import { Router, Params, ActivatedRoute } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; +import { FormGroup, FormBuilder, FormControl, FormArray } from '@angular/forms'; +import { Observable } from 'rxjs/Observable'; import { PageEvent } from '@angular/material'; import { SelectionModel } from '@angular/cdk/collections'; @Component({ - selector: 'app-dataset-wizard-listing-component', - templateUrl: 'dataset-wizard-listing.component.html', - styleUrls: ['./dataset-wizard-listing.component.scss'], + selector: 'app-dataset-wizard-listing-component', + templateUrl: 'dataset-wizard-listing.component.html', + styleUrls: ['./dataset-wizard-listing.component.scss'], }) export class DatasetWizardListingComponent implements OnInit { - @ViewChild(MatPaginator) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; + @ViewChild(MatPaginator) _paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; - titlePrefix: String; - datasets: DatasetListingModel[] = [] + titlePrefix: String; + datasets: DatasetListingModel[] = []; - @Input() dmpId: String; - @Input() formGroup: FormGroup - selection = new SelectionModel(true, []); + @Input() dmpId: String; + @Input() formGroup: FormGroup; + selection = new SelectionModel(true, []); - statuses = [ - { value: '0', viewValue: 'Active' }, - { value: '1', viewValue: 'Inactive' } - ]; + statuses = [ + { value: '0', viewValue: 'Active' }, + { value: '1', viewValue: 'Inactive' } + ]; - constructor( - private datasetService: DatasetService, - private router: Router, - private languageService: TranslateService, - public snackBar: MatSnackBar, - public route: ActivatedRoute, - public dataManagementPlanService: DataManagementPlanService - ) { + constructor( + private datasetService: DatasetService, + private router: Router, + private languageService: TranslateService, + public snackBar: MatSnackBar, + public route: ActivatedRoute, + public dataManagementPlanService: DataManagementPlanService + ) { - } + } - ngOnInit() { - this.route.params.subscribe((params: Params) => { - if (this.dmpId != null) - if (params['dmpLabel'] != undefined) - this.titlePrefix = "for " + params['dmpLabel']; - }); - let request: DataTableRequest = new DataTableRequest(null, null, null); - request.criteria = new DatasetCriteria(); - request.criteria.dmpIds = [this.dmpId]; - this.datasetService.getPaged(request).subscribe(items => { - this.datasets = JsonSerializer.fromJSONArray(items.data, DatasetListingModel) - }) - this.formGroup.addControl("datasets", new FormBuilder().array(new Array())) - } + ngOnInit() { + this.route.params.subscribe((params: Params) => { + if (this.dmpId != null) { + if (params['dmpLabel'] !== undefined) { + this.titlePrefix = 'for ' + params['dmpLabel']; + } + } + }); + const request: DataTableRequest = new DataTableRequest(null, null, null); + request.criteria = new DatasetCriteria(); + request.criteria.dmpIds = [this.dmpId]; + this.datasetService.getPaged(request).subscribe(items => { + this.datasets = JsonSerializer.fromJSONArray(items.data, DatasetListingModel); + }); + this.formGroup.addControl('datasets', new FormBuilder().array(new Array())); + } - selectionChanged(event, selectedItems) { - this.formGroup.removeControl("datasets"); - this.formGroup.addControl("datasets", new FormBuilder().array(new Array())) - selectedItems.selectedOptions.selected.forEach(element => { - (this.formGroup.get("datasets")).push(new FormBuilder().group({ id: element.value })) - }); - } + selectionChanged(event, selectedItems) { + this.formGroup.removeControl('datasets'); + this.formGroup.addControl('datasets', new FormBuilder().array(new Array())); + selectedItems.selectedOptions.selected.forEach(element => { + (this.formGroup.get('datasets')).push(new FormBuilder().group({ id: element.value })); + }); + } } diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.ts index c0ab5edd7..6bcf5401e 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component.ts @@ -11,52 +11,51 @@ declare var $: any; @Component({ - selector: 'df-autocomplete', - templateUrl: './autocomplete-remote.component.html', - styleUrls: ['./autocomplete-remote.component.css'], - encapsulation: ViewEncapsulation.None, + selector: 'app-df-autocomplete', + templateUrl: './autocomplete-remote.component.html', + styleUrls: ['./autocomplete-remote.component.css'], + encapsulation: ViewEncapsulation.None, }) export class AutocompleteRemoteComponent implements OnInit/* , ControlValueAccessor */ { - @Input() field: Field; - @Input() disabled = false - @Input() form: FormGroup; + @Input() field: Field; + @Input() disabled = false; + @Input() form: FormGroup; - public autoCompleteConfiguration: AutoCompleteConfiguration; - public loading: boolean; - public datasetId; - public values: any[] = new Array(); - public typeaheadMS: number = 1400; + public autoCompleteConfiguration: AutoCompleteConfiguration; + public loading: boolean; + public datasetId; + public values: any[] = new Array(); + public typeaheadMS = 1400; - constructor(private datasetProfileService: DatasetProfileService, route: ActivatedRoute) { - this.datasetId = route.snapshot.params['id']; - } + constructor(private datasetProfileService: DatasetProfileService, route: ActivatedRoute) { + this.datasetId = route.snapshot.params['id']; + } - ngOnInit() { - let autocompleteRequestItem: RequestItem = new RequestItem(); - autocompleteRequestItem.criteria = new AutocompleteLookupItem(); - autocompleteRequestItem.criteria.fieldID = this.field.id; - autocompleteRequestItem.criteria.profileID = this.datasetId; - this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetProfileService.queryAutocomplete.bind(this.datasetProfileService), autocompleteRequestItem); + ngOnInit() { + const autocompleteRequestItem: RequestItem = new RequestItem(); + autocompleteRequestItem.criteria = new AutocompleteLookupItem(); + autocompleteRequestItem.criteria.fieldID = this.field.id; + autocompleteRequestItem.criteria.profileID = this.datasetId; + this.autoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetProfileService.queryAutocomplete.bind(this.datasetProfileService), autocompleteRequestItem); - } + } - displayWith(item: any) { - if (!item) return null; - if (typeof item === 'string') item = this.transform(item); - return item["label"]; - } + displayWith(item: any) { + if (!item) { return null; } + if (typeof item === 'string') { item = this.transform(item); } + return item['label']; + } - assign(item: any) { - if (!item) return null; - return this.transform(item); - } + assign(item: any) { + if (!item) { return null; } + return this.transform(item); + } - transform(item: any) { - if (typeof item === 'string') return JSON.parse(item) - else return JSON.stringify(item); - } + transform(item: any) { + if (typeof item === 'string') { return JSON.parse(item); } else { return JSON.stringify(item); } + } } diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.ts index 1d70c749f..7f9b166da 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.ts @@ -3,18 +3,18 @@ import { Field } from '../../../models/Field'; import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'df-booleanDecision', - templateUrl: './dynamic-field-boolean-decision.component.html', - styleUrls: [ - './dynamic-field-boolean-decision.component.css' - ], - encapsulation: ViewEncapsulation.None + selector: 'app-df-boolean-decision', + templateUrl: './dynamic-field-boolean-decision.component.html', + styleUrls: [ + './dynamic-field-boolean-decision.component.css' + ], + encapsulation: ViewEncapsulation.None }) export class DynamicFieldBooleanDecisionComponent implements OnInit { - @Input() field: Field; - @Input() form: FormGroup; + @Input() field: Field; + @Input() form: FormGroup; - ngOnInit() { + ngOnInit() { - } + } } diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.ts index e676abf16..1cfb626d6 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-checkbox/dynamic-field-checkbox.ts @@ -3,15 +3,15 @@ import { FormGroup } from '@angular/forms'; import { Component, Input, ViewEncapsulation, OnInit } from '@angular/core'; @Component({ - selector: 'df-checkbox', - templateUrl: './dynamic-field-checkbox.html', - styleUrls: [ - './dynamic-field-checkbox.css' - ], - encapsulation: ViewEncapsulation.None + selector: 'app-df-checkbox', + templateUrl: './dynamic-field-checkbox.html', + styleUrls: [ + './dynamic-field-checkbox.css' + ], + encapsulation: ViewEncapsulation.None }) export class DynamicFieldCheckBoxComponent { - @Input() field: Field; - @Input() form: FormGroup; + @Input() field: Field; + @Input() form: FormGroup; } diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts index a38e75bd1..dcca8a330 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown.ts @@ -3,18 +3,18 @@ import { Field } from '../../../models/Field'; import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'df-dropdown', - templateUrl: './dynamic-field-dropdown.html', - styleUrls: [ - './dynamic-field-dropdown.css' - ], - encapsulation: ViewEncapsulation.None + selector: 'app-df-dropdown', + templateUrl: './dynamic-field-dropdown.html', + styleUrls: [ + './dynamic-field-dropdown.css' + ], + encapsulation: ViewEncapsulation.None }) export class DynamicFieldDropdownComponent implements OnInit { - @Input() field: Field; - @Input() form: FormGroup; + @Input() field: Field; + @Input() form: FormGroup; - ngOnInit() { + ngOnInit() { - } + } } diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.ts index 9bf45b962..3985106e7 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component.ts @@ -4,18 +4,18 @@ import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'df-radiobox', - templateUrl: './dynamic-field-radiobox.component.html', - styleUrls: [ - './dynamic-field-radiobox.component.css' - ], - encapsulation: ViewEncapsulation.None + selector: 'app-df-radiobox', + templateUrl: './dynamic-field-radiobox.component.html', + styleUrls: [ + './dynamic-field-radiobox.component.css' + ], + encapsulation: ViewEncapsulation.None }) export class DynamicFieldRadioBoxComponent implements OnInit { - @Input() field: Field; - @Input() form: FormGroup; + @Input() field: Field; + @Input() form: FormGroup; - ngOnInit() { + ngOnInit() { - } + } } diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html index cddd89e79..0c07d6226 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.html @@ -19,16 +19,16 @@
- +
- +
- +
@@ -44,11 +44,11 @@
- +
- +
diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.ts b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.ts index 0b325c337..e95360327 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.ts +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-form-field.component.ts @@ -1,5 +1,5 @@ import { Field } from '../../models/Field'; -import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core'; +import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy, OnChanges, OnDestroy } from '@angular/core'; import { FormGroup, ValidatorFn, AbstractControl, Validators } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service'; @@ -7,60 +7,58 @@ import { Subscription } from 'rxjs'; @Component({ - selector: 'df-field', - templateUrl: './dynamic-form-field.component.html', - // styles: ['.checkBoxLabelCustom {font-weight: 700;}'] - styleUrls: [ - './dynamic-form-field.component.css' - ], - encapsulation: ViewEncapsulation.None + selector: 'app-df-field', + templateUrl: './dynamic-form-field.component.html', + // styles: ['.checkBoxLabelCustom {font-weight: 700;}'] + styleUrls: [ + './dynamic-form-field.component.css' + ], + encapsulation: ViewEncapsulation.None }) -export class DynamicFormFieldComponent implements OnInit { - @Input() field: Field; - form: FormGroup; - @Input() pathName: string; - @Input() path: string; - change: Subscription; - trackByFn = (index, item) => item ? item["id"] : null - constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) { +export class DynamicFormFieldComponent implements OnInit, OnChanges, OnDestroy { + @Input() field: Field; + form: FormGroup; + @Input() pathName: string; + @Input() path: string; + change: Subscription; + trackByFn = (index, item) => item ? item['id'] : null; + constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) { - } + } - ngOnInit() { - if (this.field) { - this.form = this.visibilityRulesService.getFormGroup(this.field.id) - if (!this.form) debugger; - if (!this.form.get('value')) debugger; - this.change = this.form.get('value').valueChanges.subscribe(item => { - this.visibilityRulesService.updateValueAndVisibility(this.field.id) - }) - } - } + ngOnInit() { + if (this.field) { + this.form = this.visibilityRulesService.getFormGroup(this.field.id); + this.change = this.form.get('value').valueChanges.subscribe(item => { + this.visibilityRulesService.updateValueAndVisibility(this.field.id); + }); + } + } - ngOnChanges(changeRecord) { + ngOnChanges(changeRecord) { - } + } - ngOnDestroy(): void { - //Called once, before the instance is destroyed. - //Add 'implements OnDestroy' to the class. - if(this.change) this.change.unsubscribe() - } + ngOnDestroy(): void { + //Called once, before the instance is destroyed. + //Add 'implements OnDestroy' to the class. + if (this.change) { this.change.unsubscribe(); } + } - clearInput() { - } + clearInput() { + } - get isValid() { - return this.form.get("value").valid; - } - get isValidRequired() { - return this.form.get("value").hasError("required"); - } - get isValidPattern() { - return this.form.get("value").hasError("pattern"); - } - get isValidCustom() { - return this.form.get("value").hasError("forbiddenName"); - } + get isValid() { + return this.form.get('value').valid; + } + get isValidRequired() { + return this.form.get('value').hasError('required'); + } + get isValidPattern() { + return this.form.get('value').hasError('pattern'); + } + get isValidCustom() { + return this.form.get('value').hasError('forbiddenName'); + } } diff --git a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.html b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.html index d69af5092..e89c495e8 100644 --- a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.html +++ b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.html @@ -1,40 +1,40 @@
-
-
{{compositeField.title}}
-
-
{{compositeField.description}}
-
- {{compositeField.extendedDescription}} -
- -
-
+
+
{{compositeField.title}}
+
+
{{compositeField.description}}
+
+ {{compositeField.extendedDescription}} +
+ +
+
-
-
{{compositeField.title}}
-
-
{{compositeField.description}}
-
- {{compositeField.extendedDescription}} -
-
- +
+
{{compositeField.title}}
+
+
{{compositeField.description}}
+
+ {{compositeField.extendedDescription}} +
+
+ - -
-
- -
-
-
-
-
+ +
+
+ +
+
+
+
+
diff --git a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts index d9306881a..3a8745dcf 100644 --- a/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts +++ b/dmp-frontend/src/app/form/dynamic-form-composite-field/dynamic-form-composite-field.ts @@ -4,34 +4,34 @@ import { FormGroup, FormArray } from '@angular/forms'; import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core'; import { Field } from '../../models/Field'; @Component({ - selector: 'df-composite-field', - templateUrl: './dynamic-form-composite-field.html', - styleUrls: [ - './dynamic-form-composite-field.css' - ], - encapsulation: ViewEncapsulation.None, + selector: 'app-df-composite-field', + templateUrl: './dynamic-form-composite-field.html', + styleUrls: [ + './dynamic-form-composite-field.css' + ], + encapsulation: ViewEncapsulation.None, }) export class DynamicFormCompositeFieldComponent implements OnInit { - @Input() compositeField: CompositeField - form: FormGroup; - @Input() pathName: string; - @Input() path: string; - trackByFn = (index, item) => item ? item["id"] : null + @Input() compositeField: CompositeField; + form: FormGroup; + @Input() pathName: string; + @Input() path: string; + trackByFn = (index, item) => item ? item['id'] : null; - constructor(private visibilityRulesService: VisibilityRulesService) { - } + constructor(private visibilityRulesService: VisibilityRulesService) { + } - ngOnInit() { - if (this.compositeField) { - this.form = this.visibilityRulesService.getFormGroup(this.compositeField.id) - } - } + ngOnInit() { + if (this.compositeField) { + this.form = this.visibilityRulesService.getFormGroup(this.compositeField.id); + } + } - addMultipleField(fieldIndex: number) { - let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex, ""); - this.compositeField.fields[fieldIndex].multiplicityItems.push(field); - ((this.form.get("fields").get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm()); - } + addMultipleField(fieldIndex: number) { + const field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex, ''); + this.compositeField.fields[fieldIndex].multiplicityItems.push(field); + ((this.form.get('fields').get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm()); + } } diff --git a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.html b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.html index 28db509eb..fa169e6ec 100644 --- a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.html +++ b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.html @@ -9,10 +9,10 @@ - +
- +
diff --git a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts index 04173391f..d37bde531 100644 --- a/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts +++ b/dmp-frontend/src/app/form/dynamic-form-group/dynamic-form-group.component.ts @@ -8,36 +8,36 @@ import { CompositeField } from '../../models/CompositeField'; @Component({ - selector: 'df-group', - templateUrl: './dynamic-form-group.component.html', - styleUrls: ['./dynamic-form-group.component.css'], - encapsulation: ViewEncapsulation.None, + selector: 'app-df-group', + templateUrl: './dynamic-form-group.component.html', + styleUrls: ['./dynamic-form-group.component.css'], + encapsulation: ViewEncapsulation.None, }) export class DynamicFormGroupComponent implements OnInit { - @Input() group: FieldGroup - form: FormGroup; - @Input() pathName: string; + @Input() group: FieldGroup; + form: FormGroup; + @Input() pathName: string; - @Input() path: string; - trackByFn = (index, item) => item ? item["id"] : null - constructor(public visibilityRulesService: VisibilityRulesService) { - } + @Input() path: string; + trackByFn = (index, item) => item ? item['id'] : null; + constructor(public visibilityRulesService: VisibilityRulesService) { + } - ngOnInit() { - if (this.group) { - this.form = this.visibilityRulesService.getFormGroup(this.group.id) - } - } + ngOnInit() { + if (this.group) { + this.form = this.visibilityRulesService.getFormGroup(this.group.id); + } + } - addMultipleField(fieldsetIndex: number) { - let compositeField: CompositeField = this.group.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex); - this.group.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField); - ((this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm()); - } + addMultipleField(fieldsetIndex: number) { + const compositeField: CompositeField = this.group.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex); + this.group.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField); + ((this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm()); + } - addFieldSet() { + addFieldSet() { - } + } } diff --git a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.html b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.html index 2a77b69b7..fd089e764 100644 --- a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.html +++ b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.html @@ -18,10 +18,10 @@ Add one more fieldset + - +
- +
@@ -35,7 +35,7 @@
- +
diff --git a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts index e8527dcbc..b310216fc 100644 --- a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts +++ b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts @@ -1,49 +1,50 @@ import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service'; import { FormGroup, Form, FormArray } from '@angular/forms'; -import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core'; +import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy, AfterViewInit } from '@angular/core'; import { CompositeField } from '../../models/CompositeField'; import { Section } from '../../models/Section'; @Component({ - selector: 'df-section', - templateUrl: './dynamic-form-section.html', - styleUrls: [ - './dynamic-form-section.css' - ], - encapsulation: ViewEncapsulation.None, + selector: 'app-df-section', + templateUrl: './dynamic-form-section.html', + styleUrls: [ + './dynamic-form-section.css' + ], + encapsulation: ViewEncapsulation.None, }) -export class DynamicFormSectionComponent implements OnInit { +export class DynamicFormSectionComponent implements OnInit, AfterViewInit { - @Input() section: Section - form: FormGroup; - @Input() pathName: string; - @Input() path: string; - trackByFn = (index, item) => item ? item["id"] : null - constructor(public visibilityRulesService: VisibilityRulesService) { } + @Input() section: Section; + form: FormGroup; + @Input() pathName: string; + @Input() path: string; + trackByFn = (index, item) => item ? item['id'] : null; + constructor(public visibilityRulesService: VisibilityRulesService) { } - ngOnInit() { - if (this.section) { - this.form = this.visibilityRulesService.getFormGroup(this.section.id) - } - } + ngOnInit() { + if (this.section) { + this.form = this.visibilityRulesService.getFormGroup(this.section.id); + } + } - ngAfterViewInit() { - this.visibilityRulesService.triggerVisibilityEvaluation() - } + ngAfterViewInit() { + this.visibilityRulesService.triggerVisibilityEvaluation(); + } - addMultipleField(fieldsetIndex: number) { - let compositeField: CompositeField = this.section.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex); - this.section.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField); - ((this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm()); - } + addMultipleField(fieldsetIndex: number) { + const compositeField: CompositeField = this.section.compositeFields[fieldsetIndex].cloneForMultiplicity(fieldsetIndex); + this.section.compositeFields[fieldsetIndex].multiplicityItems.push(compositeField); + ((this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm()); + } - isElementVisible(fieldSet: CompositeField): boolean { - if (!fieldSet) return false; - for (var i = 0; i < fieldSet.fields.length; i++) { - if (fieldSet.fields[i]) - return true; - } - return false; - } + isElementVisible(fieldSet: CompositeField): boolean { + if (!fieldSet) { return false; } + for (let i = 0; i < fieldSet.fields.length; i++) { + if (fieldSet.fields[i]) { + return true; + } + } + return false; + } } diff --git a/dmp-frontend/src/app/form/dynamic-form.module.ts b/dmp-frontend/src/app/form/dynamic-form.module.ts index 112a5771c..890146a3b 100644 --- a/dmp-frontend/src/app/form/dynamic-form.module.ts +++ b/dmp-frontend/src/app/form/dynamic-form.module.ts @@ -8,16 +8,16 @@ import { DynamicFormSectionComponent } from './dynamic-form-section/dynamic-form import { DynamicFieldDropdownComponent } from './dynamic-fields/dynamic-field-dropdown/dynamic-field-dropdown'; import { AutocompleteRemoteComponent } from './dynamic-fields/dynamic-field-autocomplete/autocomplete-remote.component'; import { - TableOfContentsSectionComponent, + TableOfContentsSectionComponent, } from './tableOfContents/table-of-content-section/table-of-content-section.component'; import { TableOfContentsGroupComponent } from './tableOfContents/table-of-content-group/table-of-content-group.component'; import { - TableOfContentsFieldSetComponent, + TableOfContentsFieldSetComponent, } from './tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component'; import { DynamicFieldRadioBoxComponent } from './dynamic-fields/dynamic-field-radiobox/dynamic-field-radiobox.component'; import { TableOfContentsComponent } from './tableOfContents/table-of-contents.component'; import { - DynamicFieldBooleanDecisionComponent, + DynamicFieldBooleanDecisionComponent, } from './dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component'; import { DynamicFormGroupComponent } from './dynamic-form-group/dynamic-form-group.component'; import { DynamicFormCompositeFieldComponent } from './dynamic-form-composite-field/dynamic-form-composite-field'; @@ -28,76 +28,76 @@ import { SharedModule } from '../shared/shared.module'; import { HttpClient, HttpClientModule } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; -import { NgModule } from "@angular/core"; +import { NgModule } from '@angular/core'; import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service'; import { DatasetProfileService } from '../services/dataset-profile.service'; import { DatasetWizardService } from '../services/dataset-wizard/dataset-wizard.service'; @NgModule({ - imports: [ - CommonModule, - FormsModule, - HttpClientModule, - SharedModule, - ReactiveFormsModule, - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [HttpClient] - } - }), - ], + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + SharedModule, + ReactiveFormsModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + ], - declarations: [ - DynamicFormComponent, - DynamicFormFieldComponent, - DynamicFormGroupComponent, - DynamicFormCompositeFieldComponent, - DynamicFieldBooleanDecisionComponent, - DynamicFieldRadioBoxComponent, - TableOfContentsComponent, - TableOfContentsFieldSetComponent, - TableOfContentsGroupComponent, - TableOfContentsSectionComponent, - AutocompleteRemoteComponent, - DynamicFieldDropdownComponent, - DynamicFormSectionComponent, - TableOfContentsFieldComponent, - ProgressBarComponent, - DynamicFieldCheckBoxComponent, - ], + declarations: [ + DynamicFormComponent, + DynamicFormFieldComponent, + DynamicFormGroupComponent, + DynamicFormCompositeFieldComponent, + DynamicFieldBooleanDecisionComponent, + DynamicFieldRadioBoxComponent, + TableOfContentsComponent, + TableOfContentsFieldSetComponent, + TableOfContentsGroupComponent, + TableOfContentsSectionComponent, + AutocompleteRemoteComponent, + DynamicFieldDropdownComponent, + DynamicFormSectionComponent, + TableOfContentsFieldComponent, + ProgressBarComponent, + DynamicFieldCheckBoxComponent, + ], - exports: [ - DynamicFormComponent, - DynamicFormFieldComponent, - DynamicFormGroupComponent, - DynamicFormCompositeFieldComponent, - DynamicFieldBooleanDecisionComponent, - DynamicFieldRadioBoxComponent, - TableOfContentsComponent, - TableOfContentsFieldSetComponent, - TableOfContentsGroupComponent, - TableOfContentsSectionComponent, - AutocompleteRemoteComponent, - DynamicFieldDropdownComponent, - DynamicFormSectionComponent, - TableOfContentsFieldComponent, - ProgressBarComponent, - DynamicFieldCheckBoxComponent, - ], - providers: [ - VisibilityRulesService, - PaginationService, - DatasetProfileService, - DatasetProfileAdmin, - DatasetWizardService - ] + exports: [ + DynamicFormComponent, + DynamicFormFieldComponent, + DynamicFormGroupComponent, + DynamicFormCompositeFieldComponent, + DynamicFieldBooleanDecisionComponent, + DynamicFieldRadioBoxComponent, + TableOfContentsComponent, + TableOfContentsFieldSetComponent, + TableOfContentsGroupComponent, + TableOfContentsSectionComponent, + AutocompleteRemoteComponent, + DynamicFieldDropdownComponent, + DynamicFormSectionComponent, + TableOfContentsFieldComponent, + ProgressBarComponent, + DynamicFieldCheckBoxComponent, + ], + providers: [ + VisibilityRulesService, + PaginationService, + DatasetProfileService, + DatasetProfileAdmin, + DatasetWizardService + ] }) export class DynamicFormModule { } export function HttpLoaderFactory(httpClient: HttpClient) { - return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); + return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); } diff --git a/dmp-frontend/src/app/form/dynamic-form/dynamic-form.component.html b/dmp-frontend/src/app/form/dynamic-form/dynamic-form.component.html index bf9b7237a..797a20220 100644 --- a/dmp-frontend/src/app/form/dynamic-form/dynamic-form.component.html +++ b/dmp-frontend/src/app/form/dynamic-form/dynamic-form.component.html @@ -1,44 +1,44 @@ 
- - + - - -
- + + + -
-
- - -
-
+
+
+ + +
+
-
- - -
-
- - {{page.title}} -
- -
-
-
-
-
- + +
+
+ + {{page.title}} +
+ +
+
+
+
+
+ -
-
-
diff --git a/dmp-frontend/src/app/form/dynamic-form/dynamic-form.component.ts b/dmp-frontend/src/app/form/dynamic-form/dynamic-form.component.ts index 98dedac09..488a2e329 100644 --- a/dmp-frontend/src/app/form/dynamic-form/dynamic-form.component.ts +++ b/dmp-frontend/src/app/form/dynamic-form/dynamic-form.component.ts @@ -17,122 +17,123 @@ import { MatSidenavModule } from '@angular/material/sidenav'; declare function simple_notifier(type: string, title: string, message: string): any; @Component({ - selector: 'dynamic-form', - templateUrl: './dynamic-form.component.html', - styleUrls: [ - './dynamic-form.component.scss' - ], - providers: [ - ], - encapsulation: ViewEncapsulation.None, + selector: 'app-dynamic-form', + templateUrl: './dynamic-form.component.html', + styleUrls: [ + './dynamic-form.component.scss' + ], + providers: [ + ], + encapsulation: ViewEncapsulation.None, }) export class DynamicFormComponent implements OnInit, AfterViewInit { + pathName: string; + pages: Array; + activeStepperIndex = 1; + visibleSidebar = false; + datasetProfileDefinitionModel: DatasetProfileDefinitionModel; + private progressbar = false; + private currentPageIndex = 0; - @Input() dataModel: DatasetWizardModel = new DatasetWizardModel(); - @Input() path: string; - @Input() form: FormGroup; - id: string; - trackByFn = (index, item) => item ? item["id"] : null - pageTrackByFn = (index, item) => item["id"] + private fragment: string; + @Input() dataModel: DatasetWizardModel = new DatasetWizardModel(); + @Input() path: string; + @Input() form: FormGroup; + id: string; + trackByFn = (index, item) => item ? item['id'] : null; + pageTrackByFn = (index, item) => item['id']; - // @Input() datasetId: string; - pathName: string; - pages: Array; - activeStepperIndex: number = 1; - visibleSidebar: boolean = false; - datasetProfileDefinitionModel: DatasetProfileDefinitionModel - private progressbar: boolean = false; - private currentPageIndex: number = 0; + // @Input() datasetId: string; - private fragment: string; - constructor(private router: Router, - private _location: Location, - private route: ActivatedRoute, - private visibilityRulesService: VisibilityRulesService, - private http: BaseHttpService, - private datasetWizardService: DatasetWizardService, - ) { - //this.datasetId = route.snapshot.params['id']; - } + constructor(private router: Router, + private _location: Location, + private route: ActivatedRoute, + private visibilityRulesService: VisibilityRulesService, + private http: BaseHttpService, + private datasetWizardService: DatasetWizardService, + ) { + //this.datasetId = route.snapshot.params['id']; + } - getSubForm(subformName) { - return this.form.controls[subformName]; - } + getSubForm(subformName) { + return this.form.controls[subformName]; + } - ngOnInit() { + ngOnInit() { - let rules: Rule[] = JsonSerializer.fromJSONArray(this.dataModel.datasetProfileDefinition.rules, Rule); - this.visibilityRulesService.formGroup = this.form; - this.visibilityRulesService.buildVisibilityRules(rules) - this.datasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition - this.visibilityRulesService.setModel(this.datasetProfileDefinitionModel) - this.createPagination(); - this.progressbar = true; + const rules: Rule[] = JsonSerializer.fromJSONArray(this.dataModel.datasetProfileDefinition.rules, Rule); + this.visibilityRulesService.formGroup = this.form; + this.visibilityRulesService.buildVisibilityRules(rules); + this.datasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition; + this.visibilityRulesService.setModel(this.datasetProfileDefinitionModel); + this.createPagination(); + this.progressbar = true; - this.route.fragment.subscribe((fragment: string) => { - var self = this; - setTimeout(function () { self.scrollTo(fragment) }); - }); + this.route.fragment.subscribe((fragment: string) => { + const self = this; + setTimeout(function () { self.scrollTo(fragment); }); + }); - this.route.queryParams.subscribe((params) => { - if (params && "page" in params) - this.changeCurrentPage(params["page"]); - }); - } + this.route.queryParams.subscribe((params) => { + if (params && 'page' in params) { + this.changeCurrentPage(params['page']); + } + }); + } - ngAfterViewInit() { - this.visibilityRulesService.triggerVisibilityEvaluation() - } + ngAfterViewInit() { + this.visibilityRulesService.triggerVisibilityEvaluation(); + } - toggleSidebar() { - this.visibleSidebar = !this.visibleSidebar; - } + toggleSidebar() { + this.visibleSidebar = !this.visibleSidebar; + } - // getPages(model: DatasetProfileDefinitionModel): Array { - // let pageSet = new Set(); + // getPages(model: DatasetProfileDefinitionModel): Array { + // let pageSet = new Set(); - // model.sections.forEach(section => { - // pageSet.add(section.page); - // }); + // model.sections.forEach(section => { + // pageSet.add(section.page); + // }); - // return Array.from(pageSet).sort((a, b) => a - b); - // } + // return Array.from(pageSet).sort((a, b) => a - b); + // } - shouldDisplaySection(section: Section): Boolean { - return (section.page) == this.currentPageIndex; - } + shouldDisplaySection(section: Section): Boolean { + return (section.page) === this.currentPageIndex; + } - createPagination() { - /*this.pages.forEach(item => { - this.stepperItems.push({ - label: '', - }) - });*/ - } + createPagination() { + /*this.pages.forEach(item => { + this.stepperItems.push({ + label: '', + }) + });*/ + } - changePageIndex(index: any) { - this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { queryParams: { page: this.pages[index - 1] } }); - } + changePageIndex(index: any) { + this.router.navigate([this.route.snapshot.url[0] + '/' + this.route.snapshot.url[1]], { queryParams: { page: this.pages[index - 1] } }); + } - scrollTo(sectionID: string) { - if (!sectionID) return; - var element = document.querySelector('#' + sectionID); - if (!element) return; - element.scrollIntoView(); - this.visibleSidebar = true; - var scrollElement = document.querySelector('.scrollableContent'); - //scrollElement.scrollTop = topElement.offsetTop; - } + scrollTo(sectionID: string) { + if (!sectionID) { return; } + const element = document.querySelector('#' + sectionID); + if (!element) { return; } + element.scrollIntoView(); + this.visibleSidebar = true; + const scrollElement = document.querySelector('.scrollableContent'); + //scrollElement.scrollTop = topElement.offsetTop; + } - changeCurrentPage(pageString: string) { - if (!pageString) return; - var page = parseInt(pageString); - if (isNaN(page)) return; - var pageIndex = this.pages.indexOf(page); - if (pageIndex === -1) return; - this.currentPageIndex = page; - } + changeCurrentPage(pageString: string) { + if (!pageString) { return; } + const page = parseInt(pageString); + if (isNaN(page)) { return; } + const pageIndex = this.pages.indexOf(page); + if (pageIndex === -1) { return; } + this.currentPageIndex = page; + } } diff --git a/dmp-frontend/src/app/form/fields/dropdown/field-dropdown.ts b/dmp-frontend/src/app/form/fields/dropdown/field-dropdown.ts index 51155bff6..1c5d760d6 100644 --- a/dmp-frontend/src/app/form/fields/dropdown/field-dropdown.ts +++ b/dmp-frontend/src/app/form/fields/dropdown/field-dropdown.ts @@ -1,9 +1,9 @@ export class DropdownField { - controlType = 'dropdown'; - options: {key: string, value: string}[] =[]; + controlType = 'dropdown'; + options: { key: string, value: string }[] = []; - constructor(options: {} = {}){ - this.options = options['options'] || []; - } -} \ No newline at end of file + constructor(options: {} = {}) { + this.options = options['options'] || []; + } +} diff --git a/dmp-frontend/src/app/form/pagination/pagination-service.ts b/dmp-frontend/src/app/form/pagination/pagination-service.ts index 31b452b2b..87e3d6e4d 100644 --- a/dmp-frontend/src/app/form/pagination/pagination-service.ts +++ b/dmp-frontend/src/app/form/pagination/pagination-service.ts @@ -1,18 +1,18 @@ -import { Injectable } from '@angular/core' +import { Injectable } from '@angular/core'; @Injectable() export class PaginationService { - private currentPageIndex: number; + private currentPageIndex: number; - public setCurrentIndex(currentPageIndex: number): void { - this.currentPageIndex = currentPageIndex; - } + public setCurrentIndex(currentPageIndex: number): void { + this.currentPageIndex = currentPageIndex; + } - public getCurrentIndex():number{ - return this.currentPageIndex; - } + public getCurrentIndex(): number { + return this.currentPageIndex; + } - public isElementVisible(elementPage: number):boolean { - return elementPage == this.currentPageIndex ; //TODO - } -} \ No newline at end of file + public isElementVisible(elementPage: number): boolean { + return elementPage === this.currentPageIndex; //TODO + } +} diff --git a/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts b/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts index 287205057..502507d2b 100644 --- a/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts +++ b/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts @@ -2,68 +2,65 @@ import { ViewEncapsulation } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core'; -import { FormGroup, FormControl, FormArray } from '@angular/forms' +import { FormGroup, FormControl, FormArray } from '@angular/forms'; @Component({ - selector: 'progress-bar', - templateUrl: './progress-bar.component.html', - styles: ['.alwaysVisible .ui-progressbar-label { display:block!important; }'], - encapsulation: ViewEncapsulation.None + selector: 'app-progress-bar', + templateUrl: './progress-bar.component.html', + styles: ['.alwaysVisible .ui-progressbar-label { display:block!important; }'], + encapsulation: ViewEncapsulation.None }) export class ProgressBarComponent implements OnInit { - @Input() formGroup: FormGroup - @Input("progressValueAccuracy") public accuracy: number = 1; - determinateProgressValue: number; + @Input() formGroup: FormGroup; + @Input() public progressValueAccuracy = 1; + determinateProgressValue: number; - constructor(private visibilityRulesService: VisibilityRulesService) { } + constructor(private visibilityRulesService: VisibilityRulesService) { } - public value: number = 0; - ngOnInit() { - this.calculateValueForProgressbar() - this.formGroup - .valueChanges - .subscribe(control => { - this.calculateValueForProgressbar(); - }); - } + public value = 0; + ngOnInit() { + this.calculateValueForProgressbar(); + this.formGroup + .valueChanges + .subscribe(control => { + this.calculateValueForProgressbar(); + }); + } - calculateValueForProgressbar() { - var progressSoFar = this.countFormControlsWithValue(this.formGroup); - var total = this.getFormControlDepthLength(this.formGroup); - var perc = (progressSoFar / total) * 100; - this.value = Number.parseFloat(perc.toPrecision(this.accuracy)); - } + calculateValueForProgressbar() { + const progressSoFar = this.countFormControlsWithValue(this.formGroup); + const total = this.getFormControlDepthLength(this.formGroup); + const perc = (progressSoFar / total) * 100; + this.value = Number.parseFloat(perc.toPrecision(this.progressValueAccuracy)); + } - countFormControlsWithValue(form: FormGroup): number { - let value = 0; - Object.keys(form.controls).forEach(key => { - let control = form.controls[key] - if (control instanceof FormGroup) value += this.countFormControlsWithValue(control); - else if (control instanceof FormArray) { - let formArray = (control); - for (let i = 0; i < formArray.length; i++) { - value += this.countFormControlsWithValue(formArray.get("" + i)) - } - } - else if (key === "value" && control.value != null && control.value != "") value++; - }); - return value; - } + countFormControlsWithValue(form: FormGroup): number { + let value = 0; + Object.keys(form.controls).forEach(key => { + const control = form.controls[key]; + if (control instanceof FormGroup) { value += this.countFormControlsWithValue(control); } else if (control instanceof FormArray) { + const formArray = (control); + for (let i = 0; i < formArray.length; i++) { + value += this.countFormControlsWithValue(formArray.get('' + i)); + } + } else if (key === 'value' && control.value != null && control.value !== '') { value++; } + }); + return value; + } - getFormControlDepthLength(form: FormGroup): number { - let value = 0; - Object.keys(form.controls).forEach(key => { - let control = form.controls[key]; - if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); } - else if (control instanceof FormArray) { - let formArray = (control); - for (let i = 0; i < formArray.length; i++) { - //if (formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id)) - //value += this.getFormControlDepthLength(formArray.get("" + i)) - } - } - //else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value)) - //value++; - }); - return value; - } + getFormControlDepthLength(form: FormGroup): number { + let value = 0; + Object.keys(form.controls).forEach(key => { + const control = form.controls[key]; + if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); } else if (control instanceof FormArray) { + const formArray = (control); + for (let i = 0; i < formArray.length; i++) { + //if (formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id)) + //value += this.getFormControlDepthLength(formArray.get("" + i)) + } + } + //else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value)) + //value++; + }); + return value; + } } diff --git a/dmp-frontend/src/app/form/tableOfContents/base-table-of-content.component.ts b/dmp-frontend/src/app/form/tableOfContents/base-table-of-content.component.ts index f9f2e730a..05a0bd107 100644 --- a/dmp-frontend/src/app/form/tableOfContents/base-table-of-content.component.ts +++ b/dmp-frontend/src/app/form/tableOfContents/base-table-of-content.component.ts @@ -1,10 +1,10 @@ import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router'; export class BaseTableOfContent { - constructor(public router: Router, public route: ActivatedRoute) { } + constructor(public router: Router, public route: ActivatedRoute) { } - scrollToId(elementId, page: number) { - //this.paginationService.setCurrentIndex(page-1); - this.router.navigate([this.route.snapshot.url[0] + "/" + this.route.snapshot.url[1]], { fragment: elementId, queryParams: { page: page } }); - } -} \ No newline at end of file + scrollToId(elementId, page: number) { + //this.paginationService.setCurrentIndex(page-1); + this.router.navigate([this.route.snapshot.url[0] + '/' + this.route.snapshot.url[1]], { fragment: elementId, queryParams: { page: page } }); + } +} diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-field/table-of-content-field.component.ts b/dmp-frontend/src/app/form/tableOfContents/table-of-content-field/table-of-content-field.component.ts index 739f159e2..41915ee23 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-field/table-of-content-field.component.ts +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-field/table-of-content-field.component.ts @@ -4,20 +4,20 @@ import { CompositeField } from '../../../models/CompositeField'; import { Field } from '../../../models/Field'; import { Section } from '../../../models/Section'; import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import { Router, ActivatedRoute } from '@angular/router' +import { Router, ActivatedRoute } from '@angular/router'; @Component({ - selector: 'table-of-contents-field', - templateUrl: './table-of-content-field.component.html', - providers: [] + selector: 'app-table-of-contents-field', + templateUrl: './table-of-content-field.component.html', + providers: [] }) export class TableOfContentsFieldComponent extends BaseTableOfContent { - @Input() model: Field; - @Input() index: number; - @Input() public path: string; - @Input() public page: number; - constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) { - super(router, route) - } + @Input() model: Field; + @Input() index: number; + @Input() public path: string; + @Input() public page: number; + constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) { + super(router, route); + } } diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.ts b/dmp-frontend/src/app/form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.ts index 4a3235336..9d6fe2f96 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.ts +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-fieldset/table-of-content-fieldset.component.ts @@ -4,23 +4,23 @@ import { CompositeField } from '../../../models/CompositeField'; import { FieldGroup } from '../../../models/FieldGroup'; import { Section } from '../../../models/Section'; import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import { Router, ActivatedRoute } from '@angular/router' +import { Router, ActivatedRoute } from '@angular/router'; //import * as $ from '../../../../node_modules/jquery/dist/jquery' @Component({ - selector: 'table-of-contents-fieldset', - templateUrl: './table-of-content-fieldset.component.html', - providers: [] + selector: 'app-table-of-contents-fieldset', + templateUrl: './table-of-content-fieldset.component.html', + providers: [] }) export class TableOfContentsFieldSetComponent extends BaseTableOfContent { - @Input() model: CompositeField; - @Input() index: number; - @Input() public path: string; - @Input() public page: number; - constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) { - super(router, route) - } + @Input() model: CompositeField; + @Input() index: number; + @Input() public path: string; + @Input() public page: number; + constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) { + super(router, route); + } } diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-group/table-of-content-group.component.ts b/dmp-frontend/src/app/form/tableOfContents/table-of-content-group/table-of-content-group.component.ts index 71a88dac1..265156ff2 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-group/table-of-content-group.component.ts +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-group/table-of-content-group.component.ts @@ -3,28 +3,28 @@ import { BaseTableOfContent } from '../base-table-of-content.component'; import { FieldGroup } from '../../../models/FieldGroup'; import { Section } from '../../../models/Section'; import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import { Router, ActivatedRoute } from '@angular/router' +import { Router, ActivatedRoute } from '@angular/router'; //import * as $ from '../../../../node_modules/jquery/dist/jquery' @Component({ - selector: 'table-of-contents-group', - templateUrl: './table-of-content-group.component.html', - providers: [] + selector: 'app-table-of-contents-group', + templateUrl: './table-of-content-group.component.html', + providers: [] }) export class TableOfContentsGroupComponent extends BaseTableOfContent { - @Input() model: FieldGroup; - @Input() index: number; - @Input() public path: string; - @Input() public page: number; - /* @Output() - setPage:EventEmitter = new EventEmitter(); + @Input() model: FieldGroup; + @Input() index: number; + @Input() public path: string; + @Input() public page: number; + /* @Output() + setPage:EventEmitter = new EventEmitter(); - */ - constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) { - super(router, route) - } + */ + constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) { + super(router, route); + } } diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.html b/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.html index 1dde97aeb..8c8c36131 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.html +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.html @@ -5,6 +5,6 @@
  • - +
  • -
\ No newline at end of file + diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.ts b/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.ts index fc62e6eb2..103dc8580 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.ts +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-content-section/table-of-content-section.component.ts @@ -8,21 +8,21 @@ import { ActivatedRouteSnapshot, Router, ActivatedRoute } from '@angular/router' @Component({ - selector: 'table-of-contents-section', - templateUrl: './table-of-content-section.component.html', - providers: [] + selector: 'app-table-of-contents-section', + templateUrl: './table-of-content-section.component.html', + providers: [] }) export class TableOfContentsSectionComponent extends BaseTableOfContent implements OnInit { - @Input() model: Section; - @Input() index: number; - @Input() public path: string; - @Input() public page: number; - constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) { - super(router, route) - } - ngOnInit() { + @Input() model: Section; + @Input() index: number; + @Input() public path: string; + @Input() public page: number; + constructor(public router: Router, public route: ActivatedRoute, private visibilityRulesService: VisibilityRulesService) { + super(router, route); + } + ngOnInit() { - } + } } diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-contents.component.html b/dmp-frontend/src/app/form/tableOfContents/table-of-contents.component.html index 7fb7c520d..d4bf4f719 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-contents.component.html +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-contents.component.html @@ -2,6 +2,6 @@
  • - +
diff --git a/dmp-frontend/src/app/form/tableOfContents/table-of-contents.component.ts b/dmp-frontend/src/app/form/tableOfContents/table-of-contents.component.ts index aa06c3338..3f0063158 100644 --- a/dmp-frontend/src/app/form/tableOfContents/table-of-contents.component.ts +++ b/dmp-frontend/src/app/form/tableOfContents/table-of-contents.component.ts @@ -6,21 +6,21 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; //import * as scroll from '../../../assets/jquery.scrollTo.min.js'; @Component({ - selector: 'table-of-content', - templateUrl: './table-of-contents.component.html', - styleUrls: ['./toc.component.css'], - providers: [] + selector: 'app-table-of-content', + templateUrl: './table-of-contents.component.html', + styleUrls: ['./toc.component.css'], + providers: [] }) export class TableOfContentsComponent implements OnInit { - @Input() - public model: DatasetProfileDefinitionModel; - public path: string = ""; + @Input() + public model: DatasetProfileDefinitionModel; + public path = ''; /* @Output() setPage:EventEmitter = new EventEmitter(); */ ngOnInit() { - } + } } diff --git a/dmp-frontend/src/app/homepage/homepage.component.ts b/dmp-frontend/src/app/homepage/homepage.component.ts index 89010c367..a73022676 100644 --- a/dmp-frontend/src/app/homepage/homepage.component.ts +++ b/dmp-frontend/src/app/homepage/homepage.component.ts @@ -16,110 +16,110 @@ import { SearchBarItem } from '../models/dashboard/SearchBarItem'; import { SearchBarType } from '../shared/components/search-bar/types/search-bar-type'; @Component({ - selector: 'homepage', - templateUrl: './homepage.component.html', - styleUrls: ['./homepage.component.scss'], - providers: [ProjectService, UserReferenceService] + selector: 'app-homepage', + templateUrl: './homepage.component.html', + styleUrls: ['./homepage.component.scss'], + providers: [ProjectService, UserReferenceService] }) export class HomepageComponent implements OnInit { - public userInfo: any; - datasetActivities: any[]; - projectActivities: any[]; - dmpActivities: any[]; - public dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel(); - public formControl = new FormControl(); - projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - public searchControl = new FormControl(); - filteredOptions: Observable; - RecentActivityTypes = RecentActivityTypes - public search = false; + public userInfo: any; + datasetActivities: any[]; + projectActivities: any[]; + dmpActivities: any[]; + public dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel(); + public formControl = new FormControl(); + projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + public searchControl = new FormControl(); + filteredOptions: Observable; + RecentActivityTypes = RecentActivityTypes; + public search = false; - constructor( - private route: ActivatedRoute, - private router: Router, - private projectService: ProjectService, - private dashBoardService: DashboardService, - private authentication: AuthService, - private userReferenceService: UserReferenceService + constructor( + private route: ActivatedRoute, + private router: Router, + private projectService: ProjectService, + private dashBoardService: DashboardService, + private authentication: AuthService, + private userReferenceService: UserReferenceService - ) { - this.dashboardStatisticsData.totalDataManagementPlanCount = 0; - this.dashboardStatisticsData.totalDataSetCount = 0; - this.dashboardStatisticsData.totalProjectCount = 0; - } + ) { + this.dashboardStatisticsData.totalDataManagementPlanCount = 0; + this.dashboardStatisticsData.totalDataSetCount = 0; + this.dashboardStatisticsData.totalProjectCount = 0; + } - ngOnInit() { + ngOnInit() { - if (this.isAuthenticated()) { - this.userReferenceService.getRecentActivity().subscribe(response => { - this.datasetActivities = response["recentDatasetActivities"]; - this.dmpActivities = response["recentDmpActivities"]; - this.projectActivities = response["recentProjectActivities"]; - }) - } + if (this.isAuthenticated()) { + this.userReferenceService.getRecentActivity().subscribe(response => { + this.datasetActivities = response['recentDatasetActivities']; + this.dmpActivities = response['recentDmpActivities']; + this.projectActivities = response['recentProjectActivities']; + }); + } - this.projectAutoCompleteConfiguration = { - filterFn: this.searchProject.bind(this), - items: this.searchProject(''), - displayFn: (item) => item["label"], - titleFn: (item) => item["label"], - //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), - loadDataOnStart: true - }; + this.projectAutoCompleteConfiguration = { + filterFn: this.searchProject.bind(this), + items: this.searchProject(''), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'], + //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), + loadDataOnStart: true + }; - if (!this.isAuthenticated()) { - this.dashBoardService.getStatistics().subscribe(results => { - //let data = results['payload']; - this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); - }) - } else { - this.dashBoardService.getStatisticsSpecificuser().subscribe(results => { - this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); - }) - } + if (!this.isAuthenticated()) { + this.dashBoardService.getStatistics().subscribe(results => { + //let data = results['payload']; + this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); + }); + } else { + this.dashBoardService.getStatisticsSpecificuser().subscribe(results => { + this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel); + }); + } - this.filteredOptions = this.searchControl.valueChanges.flatMap(x => { - return this.dashBoardService.searchUserItems(x); - }) + this.filteredOptions = this.searchControl.valueChanges.flatMap(x => { + return this.dashBoardService.searchUserItems(x); + }); - } + } - public isAuthenticated(): boolean { - return !(!this.authentication.current()) - } + public isAuthenticated(): boolean { + return !(!this.authentication.current()); + } - searchProject(query: string) { - let projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new ProjectCriteria(); - projectRequestItem.criteria.like = query; - return this.projectService.getWithExternal(projectRequestItem); - } + searchProject(query: string) { + const projectRequestItem: RequestItem = new RequestItem(); + projectRequestItem.criteria = new ProjectCriteria(); + projectRequestItem.criteria.like = query; + return this.projectService.getWithExternal(projectRequestItem); + } - redirect(id: string, type: RecentActivityTypes) { - switch (type) { - case RecentActivityTypes.PROJECT: { - this.router.navigate(["projects/edit/" + id]); - return; - } - case RecentActivityTypes.DATASET: { - this.router.navigate(["datasets/edit/" + id]); - return; - } - case RecentActivityTypes.DMP: { - this.router.navigate(["dmps/edit/" + id]); - return; - } - default: throw new Error("Unsupported Activity Type ") - } + redirect(id: string, type: RecentActivityTypes) { + switch (type) { + case RecentActivityTypes.PROJECT: { + this.router.navigate(['projects/edit/' + id]); + return; + } + case RecentActivityTypes.DATASET: { + this.router.navigate(['datasets/edit/' + id]); + return; + } + case RecentActivityTypes.DMP: { + this.router.navigate(['dmps/edit/' + id]); + return; + } + default: throw new Error('Unsupported Activity Type '); + } - } + } - onOptionSelected(event: any) { - let selectedSearchBarItem = event.option.value; - if (selectedSearchBarItem.type == SearchBarType.DATASET) this.router.navigate(["datasets/edit/" + selectedSearchBarItem.id]) - if (selectedSearchBarItem.type == SearchBarType.PROJECT) this.router.navigate(["projects/edit/" + selectedSearchBarItem.id]) - if (selectedSearchBarItem.type == SearchBarType.DATAMANAGEMENTPLAN) this.router.navigate(["dmps/edit/" + selectedSearchBarItem.id]) - } + onOptionSelected(event: any) { + const selectedSearchBarItem = event.option.value; + if (selectedSearchBarItem.type === SearchBarType.DATASET) { this.router.navigate(['datasets/edit/' + selectedSearchBarItem.id]); } + if (selectedSearchBarItem.type === SearchBarType.PROJECT) { this.router.navigate(['projects/edit/' + selectedSearchBarItem.id]); } + if (selectedSearchBarItem.type === SearchBarType.DATAMANAGEMENTPLAN) { this.router.navigate(['dmps/edit/' + selectedSearchBarItem.id]); } + } } diff --git a/dmp-frontend/src/app/models/BaseModel.ts b/dmp-frontend/src/app/models/BaseModel.ts index c4cfd9e90..50f9540fd 100644 --- a/dmp-frontend/src/app/models/BaseModel.ts +++ b/dmp-frontend/src/app/models/BaseModel.ts @@ -1,4 +1,4 @@ import { FormBuilder } from '@angular/forms'; -export abstract class BaseModel{ - public formBuilder:FormBuilder = new FormBuilder(); -} \ No newline at end of file +export abstract class BaseModel { + public formBuilder: FormBuilder = new FormBuilder(); +} diff --git a/dmp-frontend/src/app/models/CompositeField.ts b/dmp-frontend/src/app/models/CompositeField.ts index c91f9f504..dc0f2dd7a 100644 --- a/dmp-frontend/src/app/models/CompositeField.ts +++ b/dmp-frontend/src/app/models/CompositeField.ts @@ -2,73 +2,73 @@ import { FormGroup } from '@angular/forms'; import { JsonSerializer } from '../utilities/JsonSerializer'; import { Serializable } from './interfaces/Serializable'; import { BaseModel } from './BaseModel'; -import { Field } from './Field' +import { Field } from './Field'; import { Multiplicity } from './Multiplicity'; export class CompositeField extends BaseModel implements Serializable { - public fields: Array = new Array(); - public ordinal: number - public id: string - public multiplicity: Multiplicity; - public multiplicityItems: Array = new Array(); - public title: string - public description: string - public extendedDescription: string - public hasCommentField: boolean; - public commentFieldValue: string; + public fields: Array = new Array(); + public ordinal: number; + public id: string; + public multiplicity: Multiplicity; + public multiplicityItems: Array = new Array(); + public title: string; + public description: string; + public extendedDescription: string; + public hasCommentField: boolean; + public commentFieldValue: string; - fromJSONObject(item: any): CompositeField { + fromJSONObject(item: any): CompositeField { - this.fields = JsonSerializer.fromJSONArray(item.fields, Field); - this.ordinal = item.ordinal; - this.id = item.id; - this.title = item.title; - this.description = item.description; - this.extendedDescription = item.extendedDescription; - this.hasCommentField = item.hasCommentField; - this.commentFieldValue = item.commentFieldValue; - this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity); - //this.multiplicity = new Multiplicity(); - //this.multiplicity.max = 2; - if(item.multiplicityItems)this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, CompositeField); - return this; - } + this.fields = JsonSerializer.fromJSONArray(item.fields, Field); + this.ordinal = item.ordinal; + this.id = item.id; + this.title = item.title; + this.description = item.description; + this.extendedDescription = item.extendedDescription; + this.hasCommentField = item.hasCommentField; + this.commentFieldValue = item.commentFieldValue; + this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity); + //this.multiplicity = new Multiplicity(); + //this.multiplicity.max = 2; + if (item.multiplicityItems) {this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, CompositeField); } + return this; + } - buildForm(): FormGroup { - let formGroup = this.formBuilder.group({ - id: this.id, - ordinal: this.ordinal, - title: this.title, - description: this.description, - extendedDescription: this.extendedDescription, - hasCommentField: this.hasCommentField, - commentFieldValue: this.commentFieldValue - }); + buildForm(): FormGroup { + const formGroup = this.formBuilder.group({ + id: this.id, + ordinal: this.ordinal, + title: this.title, + description: this.description, + extendedDescription: this.extendedDescription, + hasCommentField: this.hasCommentField, + commentFieldValue: this.commentFieldValue + }); - let fieldsFormArray = new Array(); - this.fields.forEach(item => { - let form: FormGroup = item.buildForm(); - fieldsFormArray.push(form) - }) - formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray)); + const fieldsFormArray = new Array(); + this.fields.forEach(item => { + const form: FormGroup = item.buildForm(); + fieldsFormArray.push(form); + }); + formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray)); - let multiplicityItemsFormArray = new Array(); - this.multiplicityItems.forEach(item => { - let form: FormGroup = item.buildForm(); - multiplicityItemsFormArray.push(form) - }) - formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray)); + const multiplicityItemsFormArray = new Array(); + this.multiplicityItems.forEach(item => { + const form: FormGroup = item.buildForm(); + multiplicityItemsFormArray.push(form); + }); + formGroup.addControl('multiplicityItems', this.formBuilder.array(multiplicityItemsFormArray)); - return formGroup; - } + return formGroup; + } - cloneForMultiplicity(index: number): CompositeField { - let newItem: CompositeField = new CompositeField(); - newItem.id = 'multiple_' + this.id + '_' + index; - this.fields.forEach(field => { - newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + "_")); - }); - newItem.ordinal = this.ordinal; + cloneForMultiplicity(index: number): CompositeField { + const newItem: CompositeField = new CompositeField(); + newItem.id = 'multiple_' + this.id + '_' + index; + this.fields.forEach(field => { + newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + '_')); + }); + newItem.ordinal = this.ordinal; - return newItem; - } -} \ No newline at end of file + return newItem; + } +} diff --git a/dmp-frontend/src/app/models/DataField/AutocompleteData.ts b/dmp-frontend/src/app/models/DataField/AutocompleteData.ts index 38372df5d..e59ee0cde 100644 --- a/dmp-frontend/src/app/models/DataField/AutocompleteData.ts +++ b/dmp-frontend/src/app/models/DataField/AutocompleteData.ts @@ -1,32 +1,32 @@ import { DataField } from './DataField'; -import { FormGroup } from '@angular/forms' +import { FormGroup } from '@angular/forms'; import { ListingItem } from '../common/ListingItem'; import { JsonSerializer } from '../../utilities/JsonSerializer'; -export class AutocompleteData extends DataField{ +export class AutocompleteData extends DataField { - public type: string; - public url: string; - public optionsRoot: string; - public autoCompleteOptions: ListingItem = new ListingItem(); + public type: string; + public url: string; + public optionsRoot: string; + public autoCompleteOptions: ListingItem = new ListingItem(); - buildForm(): FormGroup { - let formGroup = this.formBuilder.group({ - label: [this.label], - type: [this.type], - url: [this.url], - optionsRoot: [this.optionsRoot] - }) - formGroup.addControl("autoCompleteOptions", this.autoCompleteOptions.buildForm()); - return formGroup; - } + buildForm(): FormGroup { + const formGroup = this.formBuilder.group({ + label: [this.label], + type: [this.type], + url: [this.url], + optionsRoot: [this.optionsRoot] + }); + formGroup.addControl('autoCompleteOptions', this.autoCompleteOptions.buildForm()); + return formGroup; + } - fromJSONObject(item: any): AutocompleteData { - this.type = item.type; - this.url = item.url; - this.label = item.label; - this.optionsRoot = item.optionsRoot; - this.autoCompleteOptions = JsonSerializer.fromJSONObject(item.autoCompleteOptions, ListingItem); - return this; - } + fromJSONObject(item: any): AutocompleteData { + this.type = item.type; + this.url = item.url; + this.label = item.label; + this.optionsRoot = item.optionsRoot; + this.autoCompleteOptions = JsonSerializer.fromJSONObject(item.autoCompleteOptions, ListingItem); + return this; + } } diff --git a/dmp-frontend/src/app/models/DataField/BooleanDecisionData.ts b/dmp-frontend/src/app/models/DataField/BooleanDecisionData.ts index f8d8c9dd6..39287bcf2 100644 --- a/dmp-frontend/src/app/models/DataField/BooleanDecisionData.ts +++ b/dmp-frontend/src/app/models/DataField/BooleanDecisionData.ts @@ -1,16 +1,16 @@ import { DataField } from './DataField'; import { FormGroup } from '@angular/forms'; -export class BooleanDecisionData extends DataField{ - - buildForm():FormGroup{ - let formGroup = this.formBuilder.group({ - label:this.label - }); - return formGroup; - } +export class BooleanDecisionData extends DataField { - fromJSONObject(item:any):BooleanDecisionData{ - this.label = item.label - return this; - } -} \ No newline at end of file + buildForm(): FormGroup { + const formGroup = this.formBuilder.group({ + label: this.label + }); + return formGroup; + } + + fromJSONObject(item: any): BooleanDecisionData { + this.label = item.label; + return this; + } +} diff --git a/dmp-frontend/src/app/models/DataField/CheckBoxData.ts b/dmp-frontend/src/app/models/DataField/CheckBoxData.ts index ab3713697..13fbb82b6 100644 --- a/dmp-frontend/src/app/models/DataField/CheckBoxData.ts +++ b/dmp-frontend/src/app/models/DataField/CheckBoxData.ts @@ -1,16 +1,16 @@ import { DataField } from './DataField'; import { FormGroup } from '@angular/forms'; -export class CheckBoxData extends DataField{ +export class CheckBoxData extends DataField { - buildForm():FormGroup{ - let formGroup = this.formBuilder.group({ - label:this.label - }); - return formGroup; - } + buildForm(): FormGroup { + const formGroup = this.formBuilder.group({ + label: this.label + }); + return formGroup; + } - fromJSONObject(item:any):CheckBoxData{ - this.label = item.label - return this; - } -} \ No newline at end of file + fromJSONObject(item: any): CheckBoxData { + this.label = item.label; + return this; + } +} diff --git a/dmp-frontend/src/app/models/DataField/DataField.ts b/dmp-frontend/src/app/models/DataField/DataField.ts index e520408df..ec3a64563 100644 --- a/dmp-frontend/src/app/models/DataField/DataField.ts +++ b/dmp-frontend/src/app/models/DataField/DataField.ts @@ -1,16 +1,16 @@ import { BaseModel } from '../BaseModel'; import { FormGenerator } from '../interfaces/FormGenerator'; import { Serializable } from '../interfaces/Serializable'; -import { FormGroup } from '@angular/forms' -export abstract class DataField extends BaseModel implements Serializable,FormGenerator{ - public label:string; - - buildForm():FormGroup{ - throw new Error("Build Form Is not not correctly overriden"); - } +import { FormGroup } from '@angular/forms'; +export abstract class DataField extends BaseModel implements Serializable, FormGenerator { + public label: string; - fromJSONObject(item:any):T{ - throw new Error("From Json Object is not correctly overriden") - } + buildForm(): FormGroup { + throw new Error('Build Form Is not not correctly overriden'); + } -} \ No newline at end of file + fromJSONObject(item: any): T { + throw new Error('From Json Object is not correctly overriden'); + } + +} diff --git a/dmp-frontend/src/app/models/DataField/FreeTextData.ts b/dmp-frontend/src/app/models/DataField/FreeTextData.ts index f32703ec0..b6e5ccb2f 100644 --- a/dmp-frontend/src/app/models/DataField/FreeTextData.ts +++ b/dmp-frontend/src/app/models/DataField/FreeTextData.ts @@ -1,16 +1,16 @@ import { DataField } from './DataField'; import { FormGroup } from '@angular/forms'; -export class FreeTextData extends DataField{ - - buildForm():FormGroup{ - let formGroup = this.formBuilder.group({ - label:this.label - }); - return formGroup; - } +export class FreeTextData extends DataField { - fromJSONObject(item:any):FreeTextData{ - this.label = item.label - return this; - } -} \ No newline at end of file + buildForm(): FormGroup { + const formGroup = this.formBuilder.group({ + label: this.label + }); + return formGroup; + } + + fromJSONObject(item: any): FreeTextData { + this.label = item.label; + return this; + } +} diff --git a/dmp-frontend/src/app/models/DataField/RadioBoxData.ts b/dmp-frontend/src/app/models/DataField/RadioBoxData.ts index c52255ded..1c131bca1 100644 --- a/dmp-frontend/src/app/models/DataField/RadioBoxData.ts +++ b/dmp-frontend/src/app/models/DataField/RadioBoxData.ts @@ -1,29 +1,29 @@ import { JsonSerializer } from '../../utilities/JsonSerializer'; import { DataField } from './DataField'; import { ListingItem } from '../common/ListingItem'; -import { FormGroup } from '@angular/forms' +import { FormGroup } from '@angular/forms'; -export class RadioBoxData extends DataField{ - public options: Array; +export class RadioBoxData extends DataField { + public options: Array; - buildForm(): FormGroup { - let formGroup = this.formBuilder.group({ - label: [this.label] - }); - let optionsFormArray = new Array(); - if (this.options) { - this.options.forEach(item => { - let form: FormGroup = item.buildForm(); - optionsFormArray.push(form) - }) - } - formGroup.addControl('options', this.formBuilder.array(optionsFormArray)); - return formGroup; - } + buildForm(): FormGroup { + const formGroup = this.formBuilder.group({ + label: [this.label] + }); + const optionsFormArray = new Array(); + if (this.options) { + this.options.forEach(item => { + const form: FormGroup = item.buildForm(); + optionsFormArray.push(form); + }); + } + formGroup.addControl('options', this.formBuilder.array(optionsFormArray)); + return formGroup; + } - fromJSONObject(item: any): RadioBoxData { - this.options = JsonSerializer.fromJSONArray(item.options, ListingItem); - this.label = item.label - return this; - } + fromJSONObject(item: any): RadioBoxData { + this.options = JsonSerializer.fromJSONArray(item.options, ListingItem); + this.label = item.label; + return this; + } } diff --git a/dmp-frontend/src/app/models/DataField/TextArea.ts b/dmp-frontend/src/app/models/DataField/TextArea.ts index f5e24dbcc..316765a56 100644 --- a/dmp-frontend/src/app/models/DataField/TextArea.ts +++ b/dmp-frontend/src/app/models/DataField/TextArea.ts @@ -1,16 +1,16 @@ import { DataField } from './DataField'; import { FormGroup } from '@angular/forms'; -export class TextArea extends DataField - {{errorModel.description}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
- -
-
-
- -
-
- -
-
- -
-
-
-
- - - + + + + + {{baseErrorModel.endDate}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + + {{errorModel.description}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ + + diff --git a/dmp-frontend/src/app/projects/editor/project-editor.component.ts b/dmp-frontend/src/app/projects/editor/project-editor.component.ts index dc11d6f66..1e445dbbb 100644 --- a/dmp-frontend/src/app/projects/editor/project-editor.component.ts +++ b/dmp-frontend/src/app/projects/editor/project-editor.component.ts @@ -1,203 +1,201 @@ -import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; -import { Observable } from "rxjs/Observable"; -import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service"; -import { ProjectModel, ProjectType } from "../../models/projects/ProjectModel"; -import { ProjectService } from "../../services/project/project.service"; -import { JsonSerializer } from "../../utilities/JsonSerializer"; -import { FormGroup, AbstractControl, FormControl, FormArray } from "@angular/forms"; -import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component"; -import { BaseErrorModel } from "../../models/error/BaseErrorModel"; -import { TdDialogService } from "@covalent/core"; -import { ProjectFileUploaderService } from "../../services/files/project-file-uploader.service"; -import { HostConfiguration } from "../../app.constants"; -import { LanguageResolverService } from "../../services/language-resolver/language-resolver.service"; -import { THIS_EXPR } from "@angular/compiler/src/output/output_ast"; -import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service"; -import { IBreadCrumbComponent } from "../../shared/components/breadcrumb/definition/IBreadCrumbComponent"; -import { BreadcrumbItem } from "../../shared/components/breadcrumb/definition/breadcrumb-item"; +import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core'; +import { MatPaginator, MatSort, MatSnackBar } from '@angular/material'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; +import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service'; +import { ProjectModel, ProjectType } from '../../models/projects/ProjectModel'; +import { ProjectService } from '../../services/project/project.service'; +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms'; +import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component'; +import { BaseErrorModel } from '../../models/error/BaseErrorModel'; +import { TdDialogService } from '@covalent/core'; +import { ProjectFileUploaderService } from '../../services/files/project-file-uploader.service'; +import { HostConfiguration } from '../../app.constants'; +import { LanguageResolverService } from '../../services/language-resolver/language-resolver.service'; +import { THIS_EXPR } from '@angular/compiler/src/output/output_ast'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent'; +import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item'; @Component({ - selector: 'app-project-editor-component', - templateUrl: 'project-editor.component.html', - styleUrls: ['./project-editor.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-project-editor-component', + templateUrl: 'project-editor.component.html', + styleUrls: ['./project-editor.component.scss'], + encapsulation: ViewEncapsulation.None }) export class ProjectEditorComponent implements OnInit, IBreadCrumbComponent { - breadCrumbs: Observable = Observable.of([]);; - isNew = true; - project: ProjectModel; - formGroup: FormGroup = null; - host = HostConfiguration.Server; - editMode = false; - constructor( - private projectService: ProjectService, - private route: ActivatedRoute, - public snackBar: MatSnackBar, - public router: Router, - public language: TranslateService, - private dialogService: TdDialogService, - private uploaderService: ProjectFileUploaderService, - private languageResolverService: LanguageResolverService - ) { + breadCrumbs: Observable = Observable.of([]); + isNew = true; + project: ProjectModel; + formGroup: FormGroup = null; + host = HostConfiguration.Server; + editMode = false; + constructor( + private projectService: ProjectService, + private route: ActivatedRoute, + public snackBar: MatSnackBar, + public router: Router, + public language: TranslateService, + private dialogService: TdDialogService, + private uploaderService: ProjectFileUploaderService, + private languageResolverService: LanguageResolverService + ) { - } + } - ngOnInit() { - this.route.params.subscribe((params: Params) => { - const itemId = params['id']; + ngOnInit() { + this.route.params.subscribe((params: Params) => { + const itemId = params['id']; - if (itemId != null) { - this.isNew = false; - this.projectService.getSingle(itemId).map(data => data as ProjectModel) - .subscribe(data => { - this.project = JsonSerializer.fromJSONObject(data, ProjectModel); - this.formGroup = this.project.buildForm(null, this.project.type == ProjectType.External || !this.editMode); - this.breadCrumbs = Observable.of([ - { parentComponentName: "ProjectListingComponent", label: 'Projects', url: "/projects" }, - ]) - }); - } else { - this.breadCrumbs = Observable.of([ - { parentComponentName: "ProjectListingComponent", label: 'Projects', url: "/projects" }, - ]) - this.project = new ProjectModel(); - setTimeout(() => { - this.formGroup = this.project.buildForm(); - }); - } - }); - } + if (itemId != null) { + this.isNew = false; + this.projectService.getSingle(itemId).map(data => data as ProjectModel) + .subscribe(data => { + this.project = JsonSerializer.fromJSONObject(data, ProjectModel); + this.formGroup = this.project.buildForm(null, this.project.type === ProjectType.External || !this.editMode); + this.breadCrumbs = Observable.of([ + { parentComponentName: 'ProjectListingComponent', label: 'Projects', url: '/projects' }, + ]); + }); + } else { + this.breadCrumbs = Observable.of([ + { parentComponentName: 'ProjectListingComponent', label: 'Projects', url: '/projects' }, + ]); + this.project = new ProjectModel(); + setTimeout(() => { + this.formGroup = this.project.buildForm(); + }); + } + }); + } - formSubmit(): void { - this.touchAllFormFields(this.formGroup); - if (!this.isFormValid()) { return; } - this.onSubmit(); - } + formSubmit(): void { + this.touchAllFormFields(this.formGroup); + if (!this.isFormValid()) { return; } + this.onSubmit(); + } - public isFormValid() { - return this.formGroup.valid; - } + public isFormValid() { + return this.formGroup.valid; + } - onSubmit(): void { - this.projectService.createProject(this.formGroup.value).subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) - ); - } + onSubmit(): void { + this.projectService.createProject(this.formGroup.value).subscribe( + complete => this.onCallbackSuccess(), + error => this.onCallbackError(error) + ); + } - onCallbackSuccess(): void { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, - duration: 3000, - }) - this.router.navigate(['/projects']); - } + onCallbackSuccess(): void { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, + duration: 3000, + }); + this.router.navigate(['/projects']); + } - onCallbackError(errorResponse: any) { - this.setErrorModel(errorResponse.error.payload); - this.validateAllFormFields(this.formGroup); - } + onCallbackError(errorResponse: any) { + this.setErrorModel(errorResponse.error.payload); + this.validateAllFormFields(this.formGroup); + } - public setErrorModel(errorModel: BaseErrorModel) { - Object.keys(errorModel).forEach(item => { - (this.project.errorModel)[item] = (errorModel)[item]; - }) - } + public setErrorModel(errorModel: BaseErrorModel) { + Object.keys(errorModel).forEach(item => { + (this.project.errorModel)[item] = (errorModel)[item]; + }); + } - public cancel(): void { - this.router.navigate(['/projects']); - } + public cancel(): void { + this.router.navigate(['/projects']); + } - public delete(): void { - this.language.get('GENERAL.DELETE-CONFIRMATION').subscribe((messages: any) => { - this.dialogService.openConfirm({ - message: messages.MESSAGE, - title: messages.TITLE, - cancelButton: messages.NEGATIVE, - acceptButton: messages.POSITIVE - }).afterClosed().subscribe((accept: boolean) => { - if (accept) { - this.projectService.inactivate(this.project.id).subscribe( - complete => { this.router.navigate(['/projects']); }, - error => this.onCallbackError(error) - ); - } - }); - }); - } + public delete(): void { + this.language.get('GENERAL.DELETE-CONFIRMATION').subscribe((messages: any) => { + this.dialogService.openConfirm({ + message: messages.MESSAGE, + title: messages.TITLE, + cancelButton: messages.NEGATIVE, + acceptButton: messages.POSITIVE + }).afterClosed().subscribe((accept: boolean) => { + if (accept) { + this.projectService.inactivate(this.project.id).subscribe( + complete => { this.router.navigate(['/projects']); }, + error => this.onCallbackError(error) + ); + } + }); + }); + } - public touchAllFormFields(formControl: AbstractControl) { - if (formControl instanceof FormControl) { - formControl.markAsTouched(); - } else if (formControl instanceof FormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.touchAllFormFields(control); - }) - } - else if (formControl instanceof FormArray) { - formControl.controls.forEach(item => { - this.touchAllFormFields(item); - }) - } - } + public touchAllFormFields(formControl: AbstractControl) { + if (formControl instanceof FormControl) { + formControl.markAsTouched(); + } else if (formControl instanceof FormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + this.touchAllFormFields(control); + }); + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + this.touchAllFormFields(item); + }); + } + } - public validateAllFormFields(formControl: AbstractControl) { - if (formControl instanceof FormControl) { - formControl.updateValueAndValidity({ emitEvent: false }) - } else if (formControl instanceof FormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.validateAllFormFields(control); - }) - } - else if (formControl instanceof FormArray) { - formControl.controls.forEach(item => { - this.validateAllFormFields(item); - }) - } - } + public validateAllFormFields(formControl: AbstractControl) { + if (formControl instanceof FormControl) { + formControl.updateValueAndValidity({ emitEvent: false }); + } else if (formControl instanceof FormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + this.validateAllFormFields(control); + }); + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + this.validateAllFormFields(item); + }); + } + } - public enableForm() { - if (!this.isExternalProject()) { - this.editMode = true; - this.formGroup.enable() - } + public enableForm() { + if (!this.isExternalProject()) { + this.editMode = true; + this.formGroup.enable(); + } - } + } - public disableForm() { - this.editMode = false; - this.formGroup.disable(); - } + public disableForm() { + this.editMode = false; + this.formGroup.disable(); + } - public goToProjectDmps() { - this.router.navigate(["dmps/project/" + this.project.id], { queryParams: { projectLabel: this.project.label } }) - } + public goToProjectDmps() { + this.router.navigate(['dmps/project/' + this.project.id], { queryParams: { projectLabel: this.project.label } }); + } - public isExternalProject() { - return this.project.type === ProjectType.External; - } + public isExternalProject() { + return this.project.type === ProjectType.External; + } - public previewImage(event): void { - let fileList: FileList | File = event.target.files; + public previewImage(event): void { + const fileList: FileList | File = event.target.files; - let formdata: FormData = new FormData(); + const formdata: FormData = new FormData(); - if (fileList instanceof FileList) { - for (let i: number = 0; i < fileList.length; i++) { - formdata.append('file', fileList[i]); - } - } else { - formdata.append('file', fileList); - } - this.uploaderService.uploadFile(formdata).subscribe(files => this.formGroup.get('files').patchValue(files)); - } + if (fileList instanceof FileList) { + for (let i = 0; i < fileList.length; i++) { + formdata.append('file', fileList[i]); + } + } else { + formdata.append('file', fileList); + } + this.uploaderService.uploadFile(formdata).subscribe(files => this.formGroup.get('files').patchValue(files)); + } } diff --git a/dmp-frontend/src/app/projects/listing/project-listing.component.ts b/dmp-frontend/src/app/projects/listing/project-listing.component.ts index b4db8bad1..b3ac3dce7 100644 --- a/dmp-frontend/src/app/projects/listing/project-listing.component.ts +++ b/dmp-frontend/src/app/projects/listing/project-listing.component.ts @@ -2,12 +2,12 @@ import { DataTableRequest } from '../../models/data-table/DataTableRequest'; import { ProjectListingModel } from '../../models/projects/ProjectListingModel'; import { ProjectCriteria } from '../../models/criteria/project/ProjectCriteria'; import { ProjectService } from '../../services/project/project.service'; -import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { Router } from "@angular/router"; -import { TranslateService } from "@ngx-translate/core"; -import { DataSource } from "@angular/cdk/table"; -import { Observable } from "rxjs/Observable"; +import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core'; +import { MatPaginator, MatSort, MatSnackBar } from '@angular/material'; +import { Router } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; import { ProjectCriteriaComponent } from '../../shared/components/criteria/projects/projects-criteria.component'; import { HostConfiguration } from '../../app.constants'; import { LanguageService } from '../../services/language/language.service'; @@ -18,135 +18,135 @@ import { ProjectStateType } from '../../models/projects/ProjectStateType'; import { JsonSerializer } from '../../utilities/JsonSerializer'; @Component({ - selector: 'app-project-listing-component', - templateUrl: 'project-listing.component.html', - styleUrls: ['./project-listing.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'app-project-listing-component', + templateUrl: 'project-listing.component.html', + styleUrls: ['./project-listing.component.scss'], + encapsulation: ViewEncapsulation.None }) export class ProjectListingComponent implements OnInit, IBreadCrumbComponent { - public breadCrumbs: Observable = Observable.of([]); + public breadCrumbs: Observable = Observable.of([]); - @ViewChild(MatPaginator) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - @ViewChild(ProjectCriteriaComponent) criteria: ProjectCriteriaComponent; + @ViewChild(MatPaginator) _paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + @ViewChild(ProjectCriteriaComponent) criteria: ProjectCriteriaComponent; - host = HostConfiguration.Server; - dataSource: ProjectDataSource | null; - displayedColumns: String[] = ['avatar', 'name', 'abbreviation', 'start', 'end', "dmps"]; + host = HostConfiguration.Server; + dataSource: ProjectDataSource | null; + displayedColumns: String[] = ['avatar', 'name', 'abbreviation', 'start', 'end', 'dmps']; - constructor( - public projectService: ProjectService, - public router: Router, - public languageService: TranslateService, - public snackBar: MatSnackBar, - public languageResolverService: LanguageResolverService - ) { + constructor( + public projectService: ProjectService, + public router: Router, + public languageService: TranslateService, + public snackBar: MatSnackBar, + public languageResolverService: LanguageResolverService + ) { - } + } - ngOnInit() { - this.breadCrumbs = Observable.of([]) + ngOnInit() { + this.breadCrumbs = Observable.of([]); - this.criteria.setCriteria(this.getDefaultCriteria()); - this.refresh(); - this.criteria.setRefreshCallback(() => this.refresh()); - } + this.criteria.setCriteria(this.getDefaultCriteria()); + this.refresh(); + this.criteria.setRefreshCallback(() => this.refresh()); + } - refresh() { - this.dataSource = new ProjectDataSource(this.projectService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); - } + refresh() { + this.dataSource = new ProjectDataSource(this.projectService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); + } - rowClick(rowId: String) { - this.router.navigate(['/projects/edit/' + rowId]); - } + rowClick(rowId: String) { + this.router.navigate(['/projects/edit/' + rowId]); + } - getDefaultCriteria(): ProjectCriteria { - const defaultCriteria = new ProjectCriteria(); - defaultCriteria.projectStateType = ProjectStateType.OnGoing; - return defaultCriteria; - } + getDefaultCriteria(): ProjectCriteria { + const defaultCriteria = new ProjectCriteria(); + defaultCriteria.projectStateType = ProjectStateType.OnGoing; + return defaultCriteria; + } } export class ProjectDataSource extends DataSource { - totalCount = 0; - isLoadingResults = false; + totalCount = 0; + isLoadingResults = false; - constructor( - private _service: ProjectService, - private _paginator: MatPaginator, - private _sort: MatSort, - private _languageService: TranslateService, - private _snackBar: MatSnackBar, - private _criteria: ProjectCriteriaComponent - ) { - super(); + constructor( + private _service: ProjectService, + private _paginator: MatPaginator, + private _sort: MatSort, + private _languageService: TranslateService, + private _snackBar: MatSnackBar, + private _criteria: ProjectCriteriaComponent + ) { + super(); - //this._paginator.page.subscribe((pageEvent: PageEvent) => { - // this.store.dispatch(new LoadPhotosRequestAction(pageEvent.pageIndex, pageEvent.pageSize)) - //}) - } + //this._paginator.page.subscribe((pageEvent: PageEvent) => { + // this.store.dispatch(new LoadPhotosRequestAction(pageEvent.pageIndex, pageEvent.pageSize)) + //}) + } - connect(): Observable { - const displayDataChanges = [ - this._paginator.page - //this._sort.matSortChange - ]; + connect(): Observable { + const displayDataChanges = [ + this._paginator.page + //this._sort.matSortChange + ]; - // If the user changes the sort order, reset back to the first page. - //this._sort.matSortChange.subscribe(() => { - // this._paginator.pageIndex = 0; - //}) + // If the user changes the sort order, reset back to the first page. + //this._sort.matSortChange.subscribe(() => { + // this._paginator.pageIndex = 0; + //}) - return Observable.merge(...displayDataChanges) - .startWith(null) - .switchMap(() => { - setTimeout(() => { - this.isLoadingResults = true; - }); - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array() - if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria.criteria; - return this._service.getPaged(request); - }) - /*.catch((error: any) => { - this._snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, - duration: 3000, - extraClasses: ['snackbar-warning'] - }); - this._criteria.onCallbackError(error.error); - return Observable.of(null); - })*/ - .map(result => { - result.data = JsonSerializer.fromJSONArray(result.data, ProjectListingModel) - return result; - }) - .map(result => { - setTimeout(() => { - this.isLoadingResults = false; - }); - return result; - }) - .map(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - return result.data.map(item => { - item.dmps.map(dmp => { - dmp.url = "dmps/edit/" + dmp.url; - dmp.all = "dmps/project/" + item.id - return dmp; - }) - return item; - }); - }) + return Observable.merge(...displayDataChanges) + .startWith(null) + .switchMap(() => { + setTimeout(() => { + this.isLoadingResults = true; + }); + const startIndex = this._paginator.pageIndex * this._paginator.pageSize; + let fields: Array = new Array(); + if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); + request.criteria = this._criteria.criteria; + return this._service.getPaged(request); + }) + /*.catch((error: any) => { + this._snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, + duration: 3000, + extraClasses: ['snackbar-warning'] + }); + this._criteria.onCallbackError(error.error); + return Observable.of(null); + })*/ + .map(result => { + result.data = JsonSerializer.fromJSONArray(result.data, ProjectListingModel); + return result; + }) + .map(result => { + setTimeout(() => { + this.isLoadingResults = false; + }); + return result; + }) + .map(result => { + if (!result) { return []; } + if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } + return result.data.map(item => { + item.dmps.map(dmp => { + dmp.url = 'dmps/edit/' + dmp.url; + dmp.all = 'dmps/project/' + item.id; + return dmp; + }); + return item; + }); + }); - } + } - disconnect() { - // No-op - } + disconnect() { + // No-op + } } diff --git a/dmp-frontend/src/app/projects/project.routes.ts b/dmp-frontend/src/app/projects/project.routes.ts index 40d1feaf8..ad3527607 100644 --- a/dmp-frontend/src/app/projects/project.routes.ts +++ b/dmp-frontend/src/app/projects/project.routes.ts @@ -3,29 +3,29 @@ import { ProjectListingComponent } from './listing/project-listing.component'; import { RouterModule, Routes } from '@angular/router'; export const ProjectRoutes: Routes = [ - { - path: '', - component: ProjectListingComponent, - data: { - breadcrumb: true - }, - }, - { - path: 'edit/:id', - component: ProjectEditorComponent, - data: { - breadcrumb: true - }, - /* resolve: { - project: ProjectResolver - } */ - }, - { - path: 'new', - component: ProjectEditorComponent, - data: { - breadcrumb: true - }, - }, + { + path: '', + component: ProjectListingComponent, + data: { + breadcrumb: true + }, + }, + { + path: 'edit/:id', + component: ProjectEditorComponent, + data: { + breadcrumb: true + }, + /* resolve: { + project: ProjectResolver + } */ + }, + { + path: 'new', + component: ProjectEditorComponent, + data: { + breadcrumb: true + }, + }, ]; diff --git a/dmp-frontend/src/app/projects/projects.module.ts b/dmp-frontend/src/app/projects/projects.module.ts index 615e34586..61b1b7821 100644 --- a/dmp-frontend/src/app/projects/projects.module.ts +++ b/dmp-frontend/src/app/projects/projects.module.ts @@ -9,7 +9,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; -import { SharedModule } from '../shared/shared.module' +import { SharedModule } from '../shared/shared.module'; import { NgModule, LOCALE_ID } from '@angular/core'; import { ProjectService } from '../services/project/project.service'; import { ProjectFileUploaderService } from '../services/files/project-file-uploader.service'; @@ -20,49 +20,49 @@ import { CultureService } from '../utilities/culture/culture-service'; import { MAT_DATE_LOCALE } from '@angular/material'; @NgModule({ - imports: [ - CommonModule, - FormsModule, - HttpClientModule, - SharedModule, - MaterialModule, - RouterModule.forChild(ProjectRoutes), - ReactiveFormsModule, - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [HttpClient] - } - }), - BaseHttpModule.forRoot() - ], + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + SharedModule, + MaterialModule, + RouterModule.forChild(ProjectRoutes), + ReactiveFormsModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + BaseHttpModule.forRoot() + ], - declarations: [ - ProjectListingComponent, - ProjectEditorComponent - ], + declarations: [ + ProjectListingComponent, + ProjectEditorComponent + ], - exports: [ - ProjectListingComponent, - ProjectEditorComponent, - RouterModule - ], - providers: [ - ProjectService, - ProjectFileUploaderService, - /* ProjectResolver */ + exports: [ + ProjectListingComponent, + ProjectEditorComponent, + RouterModule + ], + providers: [ + ProjectService, + ProjectFileUploaderService, + /* ProjectResolver */ - ] + ] }) export class ProjectsModule { - constructor(private translate: TranslateService) { - translate.setDefaultLang('en'); - translate.use('en'); - } + constructor(private translate: TranslateService) { + translate.setDefaultLang('en'); + translate.use('en'); + } } export function HttpLoaderFactory(httpClient: HttpClient) { - return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); + return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); } diff --git a/dmp-frontend/src/app/services/auth/auth.service.ts b/dmp-frontend/src/app/services/auth/auth.service.ts index ab52c0f5f..6793676c8 100644 --- a/dmp-frontend/src/app/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/services/auth/auth.service.ts @@ -14,134 +14,134 @@ import { SnackBarNotificationComponent } from '../../shared/components/notificai @Injectable() export class AuthService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor( - private http: HttpClient, - public snackBar: MatSnackBar, - public language: TranslateService, - public router: Router - ) { + constructor( + private http: HttpClient, + public snackBar: MatSnackBar, + public language: TranslateService, + public router: Router + ) { - this.actionUrl = HostConfiguration.Server + 'auth/'; + this.actionUrl = HostConfiguration.Server + 'auth/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - private clear(): void { - localStorage.removeItem('principal'); - } + private clear(): void { + localStorage.removeItem('principal'); + } - public current(principal?: Principal): Principal { - if (principal) { - localStorage.setItem('principal', JSON.stringify(principal)); - return principal; - } - const principalJson = localStorage.getItem('principal'); - if (!principalJson) { return null; } - const principalObj = JSON.parse(principalJson) as Principal; - return principalObj; - } + public current(principal?: Principal): Principal { + if (principal) { + localStorage.setItem('principal', JSON.stringify(principal)); + return principal; + } + const principalJson = localStorage.getItem('principal'); + if (!principalJson) { return null; } + const principalObj = JSON.parse(principalJson) as Principal; + return principalObj; + } - //public login(credential: Credential): Observable { - // const url = this.actionUrl + 'login'; + //public login(credential: Credential): Observable { + // const url = this.actionUrl + 'login'; - // return this.http.post(url, credential, { headers: this.headers }) - // .map((res: Response) => { - // let principal = this.current(new JsonSerializer().fromJSONObject(res, Principal)); - // //this.loginContextSubject.next(true); - // return principal; - // }) - // .catch((error: any) => { - // //this.loginContextSubject.next(false); - // return Observable.throw(error); - // }); - //} + // return this.http.post(url, credential, { headers: this.headers }) + // .map((res: Response) => { + // let principal = this.current(new JsonSerializer().fromJSONObject(res, Principal)); + // //this.loginContextSubject.next(true); + // return principal; + // }) + // .catch((error: any) => { + // //this.loginContextSubject.next(false); + // return Observable.throw(error); + // }); + //} - public login(loginInfo: LoginInfo): Observable { - const url = this.actionUrl + 'externallogin'; + public login(loginInfo: LoginInfo): Observable { + const url = this.actionUrl + 'externallogin'; - return this.http.post(url, loginInfo, { headers: this.headers }) - .map((res: any) => { - const principal = this.current(JsonSerializer.fromJSONObject(res.payload, Principal)); - //this.loginContextSubject.next(true); - return principal; - }) - .catch((error: any) => { - //this.loginContextSubject.next(false); - return Observable.throw(error); - }); - } + return this.http.post(url, loginInfo, { headers: this.headers }) + .map((res: any) => { + const principal = this.current(JsonSerializer.fromJSONObject(res.payload, Principal)); + //this.loginContextSubject.next(true); + return principal; + }) + .catch((error: any) => { + //this.loginContextSubject.next(false); + return Observable.throw(error); + }); + } - public nativeLogin(credentials: Credential): Observable { - const url = this.actionUrl + 'nativelogin'; + public nativeLogin(credentials: Credential): Observable { + const url = this.actionUrl + 'nativelogin'; - return this.http.post(url, credentials, { headers: this.headers }) - .map((res: any) => { - const principal = this.current(JsonSerializer.fromJSONObject(res.payload, Principal)); - //this.loginContextSubject.next(true); - return principal; - }) - .catch((error: any) => { - //this.loginContextSubject.next(false); - return Observable.throw(error); - }); - } + return this.http.post(url, credentials, { headers: this.headers }) + .map((res: any) => { + const principal = this.current(JsonSerializer.fromJSONObject(res.payload, Principal)); + //this.loginContextSubject.next(true); + return principal; + }) + .catch((error: any) => { + //this.loginContextSubject.next(false); + return Observable.throw(error); + }); + } - public logout(): void { - const url = this.actionUrl + 'logout'; - const principal = this.current(); - this.clear(); + public logout(): void { + const url = this.actionUrl + 'logout'; + const principal = this.current(); + this.clear(); - if (!principal) { return; } - let headers = this.headers; - headers = headers.set('AuthToken', principal.token) - this.http.post(url, null, { headers: headers }).subscribe( - res => this.onLogOutSuccess(res), - error => this.onLogOutError(error) - ) - } + if (!principal) { return; } + let headers = this.headers; + headers = headers.set('AuthToken', principal.token); + this.http.post(url, null, { headers: headers }).subscribe( + res => this.onLogOutSuccess(res), + error => this.onLogOutError(error) + ); + } - public me(): Observable { - const url = this.actionUrl + '/me'; - const principal = this.current(); - if (!principal) { - this.clear(); - return Observable.of(); - } - let headers = this.headers; - headers = headers.set('AuthToken', principal.token) - return this.http.post(url, null, { headers: headers }) - .map((res: any) => { - const princ = this.current(JsonSerializer.fromJSONObject(res.payload, Principal)); - return princ; - }) - .catch((error: any) => { - console.warn('could not retrieve me info:\n', error); - this.clear(); - const princ = this.current(); - this.router.navigate(['/login']); - return Observable.of(princ); - }); - } + public me(): Observable { + const url = this.actionUrl + '/me'; + const principal = this.current(); + if (!principal) { + this.clear(); + return Observable.of(); + } + let headers = this.headers; + headers = headers.set('AuthToken', principal.token); + return this.http.post(url, null, { headers: headers }) + .map((res: any) => { + const princ = this.current(JsonSerializer.fromJSONObject(res.payload, Principal)); + return princ; + }) + .catch((error: any) => { + console.warn('could not retrieve me info:\n', error); + this.clear(); + const princ = this.current(); + this.router.navigate(['/login']); + return Observable.of(princ); + }); + } - public onLogOutSuccess(logoutMessage: any) { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT', language: this.language }, - duration: 3000, - }) - this.router.navigate(['/login']); - } + public onLogOutSuccess(logoutMessage: any) { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT', language: this.language }, + duration: 3000, + }); + this.router.navigate(['/login']); + } - public onLogOutError(errorMessage: string) { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGOUT', language: this.language }, - duration: 3000, - }) - this.router.navigate(['/login']); - } + public onLogOutError(errorMessage: string) { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGOUT', language: this.language }, + duration: 3000, + }); + this.router.navigate(['/login']); + } } diff --git a/dmp-frontend/src/app/services/breadcrumb/breadcrumb-resolver.service.ts b/dmp-frontend/src/app/services/breadcrumb/breadcrumb-resolver.service.ts index 5913414c7..949a56ab3 100644 --- a/dmp-frontend/src/app/services/breadcrumb/breadcrumb-resolver.service.ts +++ b/dmp-frontend/src/app/services/breadcrumb/breadcrumb-resolver.service.ts @@ -9,75 +9,75 @@ import { Observable } from 'rxjs/Observable'; @Injectable() export class BreadCrumbResolverService { - private activeComponents = []; - private parentComponents = []; - private breadCrumbs: Observable = Observable.of([]); - constructor( - private router: Router, - private zone: NgZone - ) { } + private activeComponents = []; + private parentComponents = []; + private breadCrumbs: Observable = Observable.of([]); + constructor( + private router: Router, + private zone: NgZone + ) { } - public push(component: any) { - const existingComponentIndex = this.activeComponents.map(x => x.constructor.name).indexOf(component.constructor.name); - if (existingComponentIndex !== -1) { this.activeComponents.splice(existingComponentIndex, 1); } - this.activeComponents.push(component); - } - - public clear() { - this.activeComponents.length = 0; - this.breadCrumbs = Observable.of([]); - } - - public resolve(activatedRoute: ActivatedRoute): Observable { - this.breadCrumbs = Observable.of([]); - const routeComponents = this.getComponentsFromRoute(activatedRoute, []); - this.activeComponents.filter(x => routeComponents.indexOf(x.constructor.name) !== -1).forEach(x => { - if (x.hasOwnProperty('breadCrumbs')) { - const componentItems = this.resolveDependentComponents((x).breadCrumbs, []); - this.breadCrumbs = Observable.of(componentItems); - } - }); - return this.breadCrumbs; - } - - private getComponentsFromRoute(activatedRoute: ActivatedRoute, routeComponents: any[]): any[] { - activatedRoute.children.forEach(x => { - if (x.children.length > 0) { this.getComponentsFromRoute(x.children[0], routeComponents); } - if (x.component) { routeComponents.push(x.component['name']); } - }); - if (activatedRoute.component) { routeComponents.push(activatedRoute.component['name']); } - - return routeComponents; - } - - resolveDependentComponents(items: Observable, components: any[]): any[] { - items.subscribe(breadCrumbs => { - breadCrumbs.forEach(async item => { - const parentComponent = item.parentComponentName ? this.findComponent(item.parentComponentName) : null; - if (parentComponent && parentComponent.hasOwnProperty('breadCrumbs')) { - components = this.pushToStart(components, this.resolveDependentComponents((parentComponent).breadCrumbs, components)); - } else if (item.notFoundResolver) { - components = this.pushToStart(components, item.notFoundResolver); - //components = this.pushToStart(components, [unresolvedComponentItems]) - } - }); - components = this.pushToEnd(components, breadCrumbs); - }); - return components; - } - - private findComponent(componentName: string): any { - for (let i = 0; i < this.activeComponents.length; i++) { - if (this.activeComponents[i].constructor.name === componentName) { return this.activeComponents[i]; } + public push(component: any) { + const existingComponentIndex = this.activeComponents.map(x => x.constructor.name).indexOf(component.constructor.name); + if (existingComponentIndex !== -1) { this.activeComponents.splice(existingComponentIndex, 1); } + this.activeComponents.push(component); } - return null; - } - pushToStart(first: any[], second: any[]) { - return [].concat(second.filter(x => first.map(firstX => firstX.label).indexOf(x.label) === -1), first); - } + public clear() { + this.activeComponents.length = 0; + this.breadCrumbs = Observable.of([]); + } - pushToEnd(first: any[], second: any[]) { - return [].concat(first, second.filter(x => first.map(firstX => firstX.label).indexOf(x.label) === -1)); - } + public resolve(activatedRoute: ActivatedRoute): Observable { + this.breadCrumbs = Observable.of([]); + const routeComponents = this.getComponentsFromRoute(activatedRoute, []); + this.activeComponents.filter(x => routeComponents.indexOf(x.constructor.name) !== -1).forEach(x => { + if (x.hasOwnProperty('breadCrumbs')) { + const componentItems = this.resolveDependentComponents((x).breadCrumbs, []); + this.breadCrumbs = Observable.of(componentItems); + } + }); + return this.breadCrumbs; + } + + private getComponentsFromRoute(activatedRoute: ActivatedRoute, routeComponents: any[]): any[] { + activatedRoute.children.forEach(x => { + if (x.children.length > 0) { this.getComponentsFromRoute(x.children[0], routeComponents); } + if (x.component) { routeComponents.push(x.component['name']); } + }); + if (activatedRoute.component) { routeComponents.push(activatedRoute.component['name']); } + + return routeComponents; + } + + resolveDependentComponents(items: Observable, components: any[]): any[] { + items.subscribe(breadCrumbs => { + breadCrumbs.forEach(async item => { + const parentComponent = item.parentComponentName ? this.findComponent(item.parentComponentName) : null; + if (parentComponent && parentComponent.hasOwnProperty('breadCrumbs')) { + components = this.pushToStart(components, this.resolveDependentComponents((parentComponent).breadCrumbs, components)); + } else if (item.notFoundResolver) { + components = this.pushToStart(components, item.notFoundResolver); + //components = this.pushToStart(components, [unresolvedComponentItems]) + } + }); + components = this.pushToEnd(components, breadCrumbs); + }); + return components; + } + + private findComponent(componentName: string): any { + for (let i = 0; i < this.activeComponents.length; i++) { + if (this.activeComponents[i].constructor.name === componentName) { return this.activeComponents[i]; } + } + return null; + } + + pushToStart(first: any[], second: any[]) { + return [].concat(second.filter(x => first.map(firstX => firstX.label).indexOf(x.label) === -1), first); + } + + pushToEnd(first: any[], second: any[]) { + return [].concat(first, second.filter(x => first.map(firstX => firstX.label).indexOf(x.label) === -1)); + } } diff --git a/dmp-frontend/src/app/services/dashboard/dashboard.service.ts b/dmp-frontend/src/app/services/dashboard/dashboard.service.ts index 8a987093a..76b4a69ef 100644 --- a/dmp-frontend/src/app/services/dashboard/dashboard.service.ts +++ b/dmp-frontend/src/app/services/dashboard/dashboard.service.ts @@ -13,28 +13,28 @@ import { SearchBarItem } from '../../models/dashboard/SearchBarItem'; @Injectable() export class DashboardService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'dashboard/'; + this.actionUrl = HostConfiguration.Server + 'dashboard/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - getStatistics(): Observable { - return this.http.get(this.actionUrl + 'getStatistics', { headers: this.headers }); - } + getStatistics(): Observable { + return this.http.get(this.actionUrl + 'getStatistics', { headers: this.headers }); + } - getStatisticsSpecificuser(): Observable { - return this.http.get(this.actionUrl + 'me/getStatistics', { headers: this.headers }); - } + getStatisticsSpecificuser(): Observable { + return this.http.get(this.actionUrl + 'me/getStatistics', { headers: this.headers }); + } - searchUserItems(like: string): Observable { - return this.http.get(this.actionUrl + 'search?like=' + like, { headers: this.headers }); - } + searchUserItems(like: string): Observable { + return this.http.get(this.actionUrl + 'search?like=' + like, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/data-management-plan-profile/datamanagement-profile.service.ts b/dmp-frontend/src/app/services/data-management-plan-profile/datamanagement-profile.service.ts index 0d07d28dd..294ec4202 100644 --- a/dmp-frontend/src/app/services/data-management-plan-profile/datamanagement-profile.service.ts +++ b/dmp-frontend/src/app/services/data-management-plan-profile/datamanagement-profile.service.ts @@ -1,43 +1,43 @@ -import { Injectable } from "@angular/core"; -import { HttpHeaders } from "@angular/common/http"; -import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service"; -import { HostConfiguration } from "../../app.constants"; -import { DataTableRequest } from "../../models/data-table/DataTableRequest"; -import { DataTableData } from "../../models/data-table/DataTableData"; -import { Observable } from "rxjs/Observable"; -import { DataManagementPlanProfileCriteria } from "../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria"; -import { DataManagementPlanProfileListingModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileListingModel"; -import { DataManagementPlanProfileModel } from "../../models/data-management-plan-profile/DataManagementPlanProfileModel"; -import { RequestItem } from "../../models/criteria/RequestItem"; +import { Injectable } from '@angular/core'; +import { HttpHeaders } from '@angular/common/http'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { HostConfiguration } from '../../app.constants'; +import { DataTableRequest } from '../../models/data-table/DataTableRequest'; +import { DataTableData } from '../../models/data-table/DataTableData'; +import { Observable } from 'rxjs/Observable'; +import { DataManagementPlanProfileCriteria } from '../../models/criteria/dmp-profile/DataManagementPlanProfileCriteria'; +import { DataManagementPlanProfileListingModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileListingModel'; +import { DataManagementPlanProfileModel } from '../../models/data-management-plan-profile/DataManagementPlanProfileModel'; +import { RequestItem } from '../../models/criteria/RequestItem'; @Injectable() export class DataManagementPlanProfileService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'dmpprofile/'; + this.actionUrl = HostConfiguration.Server + 'dmpprofile/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); - } + getPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); + } - getSingle(id: String): Observable { - return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); - } + getSingle(id: String): Observable { + return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); + } - createDataManagementPlan(dataManagementPlanModel: DataManagementPlanProfileModel): Observable { + createDataManagementPlan(dataManagementPlanModel: DataManagementPlanProfileModel): Observable { return this.http.post(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers }); - } + } - getAll(criteria: RequestItem): Observable { - return this.http.post(this.actionUrl + 'get/' ,criteria, { headers: this.headers }); - } + getAll(criteria: RequestItem): Observable { + return this.http.post(this.actionUrl + 'get/', criteria, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/data-management-plan/data-management-plan.service.ts b/dmp-frontend/src/app/services/data-management-plan/data-management-plan.service.ts index 48c086fa5..0083e58fb 100644 --- a/dmp-frontend/src/app/services/data-management-plan/data-management-plan.service.ts +++ b/dmp-frontend/src/app/services/data-management-plan/data-management-plan.service.ts @@ -17,55 +17,55 @@ import { DatasetProfileModel } from '../../models/datasets/DatasetProfileModel'; @Injectable() export class DataManagementPlanService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'dmps/'; + this.actionUrl = HostConfiguration.Server + 'dmps/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); - } + getPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); + } - getSingle(id: String): Observable { - return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); - } + getSingle(id: String): Observable { + return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); + } - createDataManagementPlan(dataManagementPlanModel: DataManagementPlanModel): Observable { - return this.http.post(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers }); - } + createDataManagementPlan(dataManagementPlanModel: DataManagementPlanModel): Observable { + return this.http.post(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers }); + } - inactivate(id: String): Observable { - return this.http.delete(this.actionUrl + 'inactivate/' + id, { headers: this.headers }); - } + inactivate(id: String): Observable { + return this.http.delete(this.actionUrl + 'inactivate/' + id, { headers: this.headers }); + } - searchDMPProfiles(dataSetProfileRequest: RequestItem): Observable { - return this.http.post(this.actionUrl + "datasetprofiles/get", dataSetProfileRequest, { headers: this.headers }); - } + searchDMPProfiles(dataSetProfileRequest: RequestItem): Observable { + return this.http.post(this.actionUrl + 'datasetprofiles/get', dataSetProfileRequest, { headers: this.headers }); + } - newVersion(dataManagementPlanModel: DataManagementPlanModel, id: String): Observable { - return this.http.post(this.actionUrl + 'new/' + id, dataManagementPlanModel, { headers: this.headers }); - } + newVersion(dataManagementPlanModel: DataManagementPlanModel, id: String): Observable { + return this.http.post(this.actionUrl + 'new/' + id, dataManagementPlanModel, { headers: this.headers }); + } - clone(dataManagementPlanModel: DataManagementPlanModel, id: String): Observable { - return this.http.post(this.actionUrl + 'clone/' + id, dataManagementPlanModel, { headers: this.headers }); - } + clone(dataManagementPlanModel: DataManagementPlanModel, id: String): Observable { + return this.http.post(this.actionUrl + 'clone/' + id, dataManagementPlanModel, { headers: this.headers }); + } - delete(id: String): Observable { - return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); - } + delete(id: String): Observable { + return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); + } - getDynamicField(requestItem: RequestItem): any { - return this.http.post(this.actionUrl + "dynamic", requestItem, { headers: this.headers }) - } + getDynamicField(requestItem: RequestItem): any { + return this.http.post(this.actionUrl + 'dynamic', requestItem, { headers: this.headers }); + } - get(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'get', requestItem, { headers: this.headers }); - } + get(requestItem: RequestItem): Observable { + return this.http.post(this.actionUrl + 'get', requestItem, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/datarepository/datarepository.service.ts b/dmp-frontend/src/app/services/datarepository/datarepository.service.ts index 241977128..315723a3c 100644 --- a/dmp-frontend/src/app/services/datarepository/datarepository.service.ts +++ b/dmp-frontend/src/app/services/datarepository/datarepository.service.ts @@ -1,27 +1,27 @@ -import { DataRepositoryModel } from "../../models/dataRepositories/DataRepositoryModel"; -import { Observable } from "rxjs"; -import { HttpHeaders } from "@angular/common/http"; -import { HostConfiguration } from "../../app.constants"; -import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service"; -import { Injectable } from "@angular/core"; +import { DataRepositoryModel } from '../../models/dataRepositories/DataRepositoryModel'; +import { Observable } from 'rxjs'; +import { HttpHeaders } from '@angular/common/http'; +import { HostConfiguration } from '../../app.constants'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { Injectable } from '@angular/core'; @Injectable() export class DataRepositoryService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'datarepos/'; + this.actionUrl = HostConfiguration.Server + 'datarepos/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - create(dataRepoModel: DataRepositoryModel): Observable { - return this.http.post(this.actionUrl + 'create', dataRepoModel, { headers: this.headers }) - } + create(dataRepoModel: DataRepositoryModel): Observable { + return this.http.post(this.actionUrl + 'create', dataRepoModel, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/dataset-profile.service.ts b/dmp-frontend/src/app/services/dataset-profile.service.ts index 81009cb85..df489fce4 100644 --- a/dmp-frontend/src/app/services/dataset-profile.service.ts +++ b/dmp-frontend/src/app/services/dataset-profile.service.ts @@ -10,40 +10,40 @@ import { AutocompleteLookupItem } from '../models/auto-complete/AutocompleteLook @Injectable() export class DatasetProfileService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private httpClient: HttpClient, private datasetProfileAdmin: DatasetProfileAdmin) { - this.actionUrl = HostConfiguration.Server + 'datasetwizard/'; + constructor(private httpClient: HttpClient, private datasetProfileAdmin: DatasetProfileAdmin) { + this.actionUrl = HostConfiguration.Server + 'datasetwizard/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - fetchAllDatasetProfiles() { - // return this.restBase.get("datasetprofiles/getAll"); - } + fetchAllDatasetProfiles() { + // return this.restBase.get("datasetprofiles/getAll"); + } - getDatasetProfileById(datasetProfileID) { - return this.datasetProfileAdmin.getDatasetProfileById(datasetProfileID); - } + getDatasetProfileById(datasetProfileID) { + return this.datasetProfileAdmin.getDatasetProfileById(datasetProfileID); + } - createDatasetProfile(datasetProfile) { - // return this.restBase.post("datasetprofile/create", datasetProfile); - } + createDatasetProfile(datasetProfile) { + // return this.restBase.post("datasetprofile/create", datasetProfile); + } - updateDatasetProfile(datasetProfile) { - // return this.restBase.post("datasetprofile/update", datasetProfile); - } + updateDatasetProfile(datasetProfile) { + // return this.restBase.post("datasetprofile/update", datasetProfile); + } - delete(datasetProfile) { - // return this.restBase.post("datasetprofile/delete", datasetProfile); - } + delete(datasetProfile) { + // return this.restBase.post("datasetprofile/delete", datasetProfile); + } - queryAutocomplete(lookUpItem: RequestItem): Observable { - return this.httpClient.post(HostConfiguration.Server + "search/autocomplete", lookUpItem) - } + queryAutocomplete(lookUpItem: RequestItem): Observable { + return this.httpClient.post(HostConfiguration.Server + 'search/autocomplete', lookUpItem); + } } diff --git a/dmp-frontend/src/app/services/dataset-wizard/dataset-wizard.service.ts b/dmp-frontend/src/app/services/dataset-wizard/dataset-wizard.service.ts index 2ef2ef5be..9f4bef195 100644 --- a/dmp-frontend/src/app/services/dataset-wizard/dataset-wizard.service.ts +++ b/dmp-frontend/src/app/services/dataset-wizard/dataset-wizard.service.ts @@ -17,43 +17,43 @@ import { ResponseContentType } from '@angular/http'; @Injectable() export class DatasetWizardService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService, private httpClient: HttpClient) { + constructor(private http: BaseHttpService, private httpClient: HttpClient) { - this.actionUrl = HostConfiguration.Server + 'datasetwizard/'; + this.actionUrl = HostConfiguration.Server + 'datasetwizard/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - public userDmps(criteria: RequestItem): Observable { - return this.http.post(this.actionUrl + 'userDmps', criteria, { headers: this.headers }); - } + public userDmps(criteria: RequestItem): Observable { + return this.http.post(this.actionUrl + 'userDmps', criteria, { headers: this.headers }); + } - public getAvailableProfiles(criteria: RequestItem): Observable { - return this.http.post(this.actionUrl + 'getAvailableProfiles/', criteria, { headers: this.headers }); - } + public getAvailableProfiles(criteria: RequestItem): Observable { + return this.http.post(this.actionUrl + 'getAvailableProfiles/', criteria, { headers: this.headers }); + } - public getSingle(id: String): Observable { - return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); - } + public getSingle(id: String): Observable { + return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); + } - createDataset(datasetModel: DatasetWizardModel): Observable { - return this.http.post(this.actionUrl + 'createOrUpdate', datasetModel, { headers: this.headers }); - } + createDataset(datasetModel: DatasetWizardModel): Observable { + return this.http.post(this.actionUrl + 'createOrUpdate', datasetModel, { headers: this.headers }); + } - public downloadPDF(id: string): Observable> { - return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response' }) - } + public downloadPDF(id: string): Observable> { + return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response' }); + } - public downloadXML(id: string): Observable> { - return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response' }) - } + public downloadXML(id: string): Observable> { + return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response' }); + } - public getDefinition(id: String): Observable { - return this.http.get(this.actionUrl + 'get/' + id, { headers: this.headers }); - } + public getDefinition(id: String): Observable { + return this.http.get(this.actionUrl + 'get/' + id, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/dataset/dataset.service.ts b/dmp-frontend/src/app/services/dataset/dataset.service.ts index 0736bef01..38541af23 100644 --- a/dmp-frontend/src/app/services/dataset/dataset.service.ts +++ b/dmp-frontend/src/app/services/dataset/dataset.service.ts @@ -17,32 +17,32 @@ import { FacetSearchCriteriaModel } from '../../models/facet-search/FacetSearchC @Injectable() export class DatasetService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'datasets/'; + this.actionUrl = HostConfiguration.Server + 'datasets/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); - } + getPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); + } - getPublicPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'public/paged', dataTableRequest, { headers: this.headers }); - } + getPublicPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'public/paged', dataTableRequest, { headers: this.headers }); + } - makeDatasetPublic(id: String) { - return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }); - } + makeDatasetPublic(id: String) { + return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }); + } - getDatasetProfiles(): Observable { - return this.http.get(HostConfiguration.Server + 'datasetprofiles/getAll', { headers: this.headers }); - } + getDatasetProfiles(): Observable { + return this.http.get(HostConfiguration.Server + 'datasetprofiles/getAll', { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts b/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts index b3778ec59..af068c265 100644 --- a/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts +++ b/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts @@ -15,35 +15,35 @@ import { DatasetListingModel } from '../../models/datasets/DatasetListingModel'; @Injectable() export class DatasetProfileAdmin { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'admin/'; + this.actionUrl = HostConfiguration.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(this.actionUrl + 'addDmp', data, { headers: this.headers }); - } + 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(this.actionUrl + 'addDmp', data, { headers: this.headers }); + } - updateForm(id, data) { - return this.http.post(this.actionUrl + 'addDmp/' + id, data, { headers: this.headers }) - } + updateForm(id, data) { + return this.http.post(this.actionUrl + 'addDmp/' + id, data, { headers: this.headers }); + } - getDatasetProfileById(datasetProfileID) { - return this.http.get(this.actionUrl + 'get/' + datasetProfileID, { headers: this.headers }) - } + getDatasetProfileById(datasetProfileID) { + return this.http.get(this.actionUrl + 'get/' + datasetProfileID, { headers: this.headers }); + } - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest, { headers: this.headers }); - } + getPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest, { headers: this.headers }); + } - preview(data: DatasetProfileModelAdmin): Observable { - return this.http.post(this.actionUrl + 'preview', data, { headers: this.headers }); - } + preview(data: DatasetProfileModelAdmin): Observable { + return this.http.post(this.actionUrl + 'preview', data, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/external-dataset/external-dataset.service.ts b/dmp-frontend/src/app/services/external-dataset/external-dataset.service.ts index 0bd747320..9bb94c73d 100644 --- a/dmp-frontend/src/app/services/external-dataset/external-dataset.service.ts +++ b/dmp-frontend/src/app/services/external-dataset/external-dataset.service.ts @@ -14,35 +14,35 @@ import { Observable } from 'rxjs/Observable'; @Injectable() export class ExternalDatasetService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'externaldatasets/'; + this.actionUrl = HostConfiguration.Server + 'externaldatasets/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); - } + getPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); + } - /* get(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'get', requestItem, { headers: this.headers }); - }*/ + /* get(requestItem: RequestItem): Observable { + return this.http.post(this.actionUrl + 'get', requestItem, { headers: this.headers }); + }*/ - getWithExternal(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'getWithExternal', requestItem, { headers: this.headers }); - } + getWithExternal(requestItem: RequestItem): Observable { + return this.http.post(this.actionUrl + 'getWithExternal', requestItem, { headers: this.headers }); + } - getSingle(id: string): Observable { - return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); - } + getSingle(id: string): Observable { + return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); + } - create(externalDatasetModel: ExternalDatasetModel): Observable { - return this.http.post(this.actionUrl + 'create', externalDatasetModel, { headers: this.headers }) - } + create(externalDatasetModel: ExternalDatasetModel): Observable { + return this.http.post(this.actionUrl + 'create', externalDatasetModel, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/external-sources/external-sources-configuration.service.ts b/dmp-frontend/src/app/services/external-sources/external-sources-configuration.service.ts index e31098525..fdac51be1 100644 --- a/dmp-frontend/src/app/services/external-sources/external-sources-configuration.service.ts +++ b/dmp-frontend/src/app/services/external-sources/external-sources-configuration.service.ts @@ -1,28 +1,28 @@ -import { ExternalSourcesConfiguration } from "../../models/external-sources/ExternalSourcesConfiguration"; -import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service"; -import { HostConfiguration } from "../../app.constants"; -import { HttpHeaders } from "@angular/common/http"; -import { Injectable } from "@angular/core"; -import { Observable } from "rxjs/Observable"; +import { ExternalSourcesConfiguration } from '../../models/external-sources/ExternalSourcesConfiguration'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { HostConfiguration } from '../../app.constants'; +import { HttpHeaders } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; @Injectable() export class ExternalSourcesConfigurationService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'common/'; + this.actionUrl = HostConfiguration.Server + 'common/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - public getExternalSourcesConfiguration(): Observable { - return this.http.get(this.actionUrl + "externalSourcesConfiguration", { headers: this.headers }); - } + public getExternalSourcesConfiguration(): Observable { + return this.http.get(this.actionUrl + 'externalSourcesConfiguration', { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/external-sources/external-sources.service.ts b/dmp-frontend/src/app/services/external-sources/external-sources.service.ts index acd404778..05bbe1e01 100644 --- a/dmp-frontend/src/app/services/external-sources/external-sources.service.ts +++ b/dmp-frontend/src/app/services/external-sources/external-sources.service.ts @@ -18,58 +18,58 @@ import { TagsCriteria } from '../../models/criteria/tags/TagsCriteria'; @Injectable() export class ExternalSourcesService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'external/'; + this.actionUrl = HostConfiguration.Server + 'external/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - public searchDatasetRegistry(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'registries' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } + public searchDatasetRegistry(requestItem: RequestItem): Observable { + return this.http.get(this.actionUrl + 'registries' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); + } - public searchDatasetRepository(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'datarepos' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } + public searchDatasetRepository(requestItem: RequestItem): Observable { + return this.http.get(this.actionUrl + 'datarepos' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); + } - public searchDatasetService(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'services' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } + public searchDatasetService(requestItem: RequestItem): Observable { + return this.http.get(this.actionUrl + 'services' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); + } - public searchDatasetTags(requestItem: RequestItem): Observable { - return Observable.of([ - { id: '1', name: 'Tag 1', description: '' }, - { id: '2', name: 'Tag 2', description: '' }, - { id: '3', name: 'Tag 3', description: '' }, - { id: '4', name: 'Tag 4', description: '' }, - { id: '5', name: 'Tag 5', description: '' }, - { id: '6', name: 'Tag 6', description: '' }, - { id: '7', name: 'Tag 7', description: '' }, - { id: '8', name: 'Tag 8', description: '' }, - ]); - //return this.http.get(this.actionUrl + "tags" + "?query=" + requestItem.criteria.like + "&type=" + requestItem.criteria.type, { headers: this.headers }); - } + public searchDatasetTags(requestItem: RequestItem): Observable { + return Observable.of([ + { id: '1', name: 'Tag 1', description: '' }, + { id: '2', name: 'Tag 2', description: '' }, + { id: '3', name: 'Tag 3', description: '' }, + { id: '4', name: 'Tag 4', description: '' }, + { id: '5', name: 'Tag 5', description: '' }, + { id: '6', name: 'Tag 6', description: '' }, + { id: '7', name: 'Tag 7', description: '' }, + { id: '8', name: 'Tag 8', description: '' }, + ]); + //return this.http.get(this.actionUrl + "tags" + "?query=" + requestItem.criteria.like + "&type=" + requestItem.criteria.type, { headers: this.headers }); + } - public searchDatasetSExternalDatasetservice(requestItem: RequestItem): Observable { - return this.http.get(this.actionUrl + 'datasets' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); - } + public searchDatasetSExternalDatasetservice(requestItem: RequestItem): Observable { + return this.http.get(this.actionUrl + 'datasets' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); + } - public searchDMPResearchers(requestItem: RequestItem): Observable { - return this.http.post(HostConfiguration.Server + '/researchers/getWithExternal', requestItem, { headers: this.headers }); - } + public searchDMPResearchers(requestItem: RequestItem): Observable { + return this.http.post(HostConfiguration.Server + '/researchers/getWithExternal', requestItem, { headers: this.headers }); + } - public searchDMPOrganizations(like: string): Observable { - return this.http.get(this.actionUrl + 'organisations' + '?query=' + like, { headers: this.headers }); - }//organizationscriteria.criteria.like + public searchDMPOrganizations(like: string): Observable { + return this.http.get(this.actionUrl + 'organisations' + '?query=' + like, { headers: this.headers }); + }//organizationscriteria.criteria.like - public searchDMPProfiles(like: string): Observable { - return this.http.get(this.actionUrl + 'datasetprofiles/get' + '?query=' + like, { headers: this.headers }); - } + public searchDMPProfiles(like: string): Observable { + return this.http.get(this.actionUrl + 'datasetprofiles/get' + '?query=' + like, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/files/project-file-uploader.service.ts b/dmp-frontend/src/app/services/files/project-file-uploader.service.ts index 4a4ce12fa..562fda857 100644 --- a/dmp-frontend/src/app/services/files/project-file-uploader.service.ts +++ b/dmp-frontend/src/app/services/files/project-file-uploader.service.ts @@ -16,19 +16,19 @@ import { ContentFile } from '../../models/files/ContentFile'; export class ProjectFileUploaderService implements FileUploader { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'files/'; + this.actionUrl = HostConfiguration.Server + 'files/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - uploadFile(formData: FormData): Observable { - return this.http.post(this.actionUrl + "upload", formData, this.headers); - } + uploadFile(formData: FormData): Observable { + return this.http.post(this.actionUrl + 'upload', formData, this.headers); + } } diff --git a/dmp-frontend/src/app/services/help-content/CachedContentItem.ts b/dmp-frontend/src/app/services/help-content/CachedContentItem.ts index 10974b759..91cc899b7 100644 --- a/dmp-frontend/src/app/services/help-content/CachedContentItem.ts +++ b/dmp-frontend/src/app/services/help-content/CachedContentItem.ts @@ -1,6 +1,6 @@ -import { PageHelpContent } from "../../models/help-content/page-help-content"; +import { PageHelpContent } from '../../models/help-content/page-help-content'; export class CachedContentItem { - public timestamp: number; - public content: PageHelpContent; -} \ No newline at end of file + public timestamp: number; + public content: PageHelpContent; +} diff --git a/dmp-frontend/src/app/services/help-content/help-content.service.ts b/dmp-frontend/src/app/services/help-content/help-content.service.ts index f14e70982..ce8d16f73 100644 --- a/dmp-frontend/src/app/services/help-content/help-content.service.ts +++ b/dmp-frontend/src/app/services/help-content/help-content.service.ts @@ -9,47 +9,46 @@ import { CachedContentItem } from './CachedContentItem'; import { HostConfiguration } from '../../app.constants'; @Injectable() export class HelpContentService { - private _helpServiceUrl = HostConfiguration.HelpServiceUrl; - cache = new Map(); + private _helpServiceUrl = HostConfiguration.HelpServiceUrl; + cache = new Map(); - constructor(private http: Http) { - } + constructor(private http: Http) { + } - getActivePageContent(route: string) { - if (!this.cache.get(route) || !this.isValidCachedItem(route)) { - return this.http.get(this._helpServiceUrl + "/page/route?q=" + route) - .map(res => { - this.cache.set(route, { timestamp: Date.now(), content: res.json() }) - return res.json(); - }) - .catch(this.handleError) - } - return Observable.create(observer => observer.next(this.cache.get(route).content)); - } - private extractData(res: Response) { - let body = res.json(); - return body.data || {}; - } - private handleError(error: Response | any) { - // In a real world app, we might use a remote logging infrastructure - // We'd also dig deeper into the error to get a better message - let errMsg = ""; - if (error instanceof Response) { - const body = error.text() || ''; - //const err = body.error || JSON.stringify(body); - errMsg = `${error.status} - ${error.statusText || ''} ${body}`; - } else { - errMsg = (error.message) ? error.message : - error.status ? `${error.status} - ${error.statusText}` : 'Server error'; - console.error(errMsg); // log to console instead - } - return Observable.throw(errMsg); - } + getActivePageContent(route: string) { + if (!this.cache.get(route) || !this.isValidCachedItem(route)) { + return this.http.get(this._helpServiceUrl + '/page/route?q=' + route) + .map(res => { + this.cache.set(route, { timestamp: Date.now(), content: res.json() }); + return res.json(); + }) + .catch(this.handleError); + } + return Observable.create(observer => observer.next(this.cache.get(route).content)); + } + private extractData(res: Response) { + const body = res.json(); + return body.data || {}; + } + private handleError(error: Response | any) { + // In a real world app, we might use a remote logging infrastructure + // We'd also dig deeper into the error to get a better message + let errMsg = ''; + if (error instanceof Response) { + const body = error.text() || ''; + //const err = body.error || JSON.stringify(body); + errMsg = `${error.status} - ${error.statusText || ''} ${body}`; + } else { + errMsg = (error.message) ? error.message : + error.status ? `${error.status} - ${error.statusText}` : 'Server error'; + console.error(errMsg); // log to console instead + } + return Observable.throw(errMsg); + } - isValidCachedItem(route) { - let cachedTimestamp = this.cache.get(route).timestamp; - let currentTimestamp = Date.now(); - if (currentTimestamp - cachedTimestamp > HostConfiguration.CacheLifeTimeMillis) return false; - else return true; - } + isValidCachedItem(route) { + const cachedTimestamp = this.cache.get(route).timestamp; + const currentTimestamp = Date.now(); + if (currentTimestamp - cachedTimestamp > HostConfiguration.CacheLifeTimeMillis) { return false; } else { return true; } + } } diff --git a/dmp-frontend/src/app/services/invitation/invitation.service.ts b/dmp-frontend/src/app/services/invitation/invitation.service.ts index 321c8d00d..e376a25c1 100644 --- a/dmp-frontend/src/app/services/invitation/invitation.service.ts +++ b/dmp-frontend/src/app/services/invitation/invitation.service.ts @@ -3,7 +3,7 @@ import { UserInvitationCriteria } from '../../models/criteria/invitation/UserInv import { User } from '../../models/invitation/User'; import { HostConfiguration } from '../../app.constants'; import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; -import { Injectable } from "@angular/core"; +import { Injectable } from '@angular/core'; import { HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { RequestItem } from '../../models/criteria/RequestItem'; @@ -11,27 +11,27 @@ import { RequestItem } from '../../models/criteria/RequestItem'; @Injectable() export class InvitationService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'invite/'; + this.actionUrl = HostConfiguration.Server + 'invite/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - public inviteUsers(invitation: Invitation): Observable { - return this.http.post(this.actionUrl + "users", invitation, { headers: this.headers }); - } + public inviteUsers(invitation: Invitation): Observable { + return this.http.post(this.actionUrl + 'users', invitation, { headers: this.headers }); + } - public getUsers(usersInvitationRequestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + "getUsers", usersInvitationRequestItem, { headers: this.headers }); - } + public getUsers(usersInvitationRequestItem: RequestItem): Observable { + return this.http.post(this.actionUrl + 'getUsers', usersInvitationRequestItem, { headers: this.headers }); + } - public exchange(id:String): Observable { - return this.http.get(this.actionUrl + "exchange/"+id, { headers: this.headers }); - } -} \ No newline at end of file + public exchange(id: String): Observable { + return this.http.get(this.actionUrl + 'exchange/' + id, { headers: this.headers }); + } +} diff --git a/dmp-frontend/src/app/services/language-resolver/language-resolver.service.ts b/dmp-frontend/src/app/services/language-resolver/language-resolver.service.ts index 0ead09628..268098d74 100644 --- a/dmp-frontend/src/app/services/language-resolver/language-resolver.service.ts +++ b/dmp-frontend/src/app/services/language-resolver/language-resolver.service.ts @@ -1,23 +1,23 @@ -import { Injectable } from "@angular/core"; -import { LanguageService } from "../language/language.service"; +import { Injectable } from '@angular/core'; +import { LanguageService } from '../language/language.service'; @Injectable() export class LanguageResolverService { - private languageData = {}; + private languageData = {}; - constructor(private language: LanguageService) { - if (Object.keys(this.languageData).length == 0) { - this.language.getLang().subscribe(result => { - result.forEach(item => { - this.languageData[item.key] = item.languageKey; - }) - }) - } - } + constructor(private language: LanguageService) { + if (Object.keys(this.languageData).length === 0) { + this.language.getLang().subscribe(result => { + result.forEach(item => { + this.languageData[item.key] = item.languageKey; + }); + }); + } + } - public getBy(key: string): string { - return this.languageData[key]; - } + public getBy(key: string): string { + return this.languageData[key]; + } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/services/language/language.service.ts b/dmp-frontend/src/app/services/language/language.service.ts index f49479601..4c59b6484 100644 --- a/dmp-frontend/src/app/services/language/language.service.ts +++ b/dmp-frontend/src/app/services/language/language.service.ts @@ -1,31 +1,31 @@ -import { Injectable } from "@angular/core"; -import { HttpHeaders } from "@angular/common/http"; -import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service"; -import { HostConfiguration } from "../../app.constants"; -import { Observable } from "rxjs/Observable"; -import { Invitation } from "../../models/invitation/Invitation"; -import { User } from "../../models/invitation/User"; -import { RequestItem } from "../../models/criteria/RequestItem"; -import { UserInvitationCriteria } from "../../models/criteria/invitation/UserInvitationCriteria"; -import { Language } from "../../models/language/Language"; +import { Injectable } from '@angular/core'; +import { HttpHeaders } from '@angular/common/http'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { HostConfiguration } from '../../app.constants'; +import { Observable } from 'rxjs/Observable'; +import { Invitation } from '../../models/invitation/Invitation'; +import { User } from '../../models/invitation/User'; +import { RequestItem } from '../../models/criteria/RequestItem'; +import { UserInvitationCriteria } from '../../models/criteria/invitation/UserInvitationCriteria'; +import { Language } from '../../models/language/Language'; @Injectable() export class LanguageService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'common/'; + this.actionUrl = HostConfiguration.Server + 'common/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - public getLang(): Observable { - return this.http.get(this.actionUrl + "language", { headers: this.headers }); - } + public getLang(): Observable { + return this.http.get(this.actionUrl + 'language', { headers: this.headers }); + } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/services/pagination.service.ts b/dmp-frontend/src/app/services/pagination.service.ts index 98b68dc78..72f238384 100644 --- a/dmp-frontend/src/app/services/pagination.service.ts +++ b/dmp-frontend/src/app/services/pagination.service.ts @@ -1,53 +1,55 @@ export class PaginationService { - getPagination(groups, totalGroups: number, currentPage: number = 1, pageSize: number = 3) { - // calculate total pages - //let totalPages = Math.ceil(totalGroups / pageSize); + getPagination(groups, totalGroups: number, currentPage: number = 1, pageSize: number = 3) { + // calculate total pages + //let totalPages = Math.ceil(totalGroups / pageSize); - let totalPages = 0 ; //totalpages based on pages from xml, each group and section has each one page - groups.forEach(group => { - if (group.page > totalPages) - totalPages = parseInt(group.page); - }); + let totalPages = 0 ; //totalpages based on pages from xml, each group and section has each one page + groups.forEach(group => { + if (group.page > totalPages) { + totalPages = parseInt(group.page); + } + }); - let startPage: number, endPage: number; - if (totalPages <= 10) { - // less than 10 total pages so show all - startPage = 1; - endPage = totalPages; - } else { - // more than 10 total pages so calculate start and end pages - if (currentPage <= 6) { - startPage = 1; - endPage = 10; - } else if (currentPage + 4 >= totalPages) { - startPage = totalPages - 9; - endPage = totalPages; - } else { - startPage = currentPage - 5; - endPage = currentPage + 4; - } - } + let startPage: number, endPage: number; + if (totalPages <= 10) { + // less than 10 total pages so show all + startPage = 1; + endPage = totalPages; + } else { + // more than 10 total pages so calculate start and end pages + if (currentPage <= 6) { + startPage = 1; + endPage = 10; + } else if (currentPage + 4 >= totalPages) { + startPage = totalPages - 9; + endPage = totalPages; + } else { + startPage = currentPage - 5; + endPage = currentPage + 4; + } + } - // calculate start and end item indexes - let startIndex = (currentPage - 1) * pageSize; - let endIndex = Math.min(startIndex + pageSize - 1, totalGroups - 1); + // calculate start and end item indexes + const startIndex = (currentPage - 1) * pageSize; + const endIndex = Math.min(startIndex + pageSize - 1, totalGroups - 1); - // create an array of pages to ng-repeat in the pagination control - let pages = []; - for (var i = 1; i < endPage + 1; i++) - pages.push(i); + // create an array of pages to ng-repeat in the pagination control + const pages = []; + for (let i = 1; i < endPage + 1; i++) { + pages.push(i); + } - // return object with all pagination properties required by the view - return { - totalGroups: totalGroups, - currentPage: currentPage, - pageSize: pageSize, - totalPages: totalPages, - startPage: startPage, - endPage: endPage, - startIndex: startIndex, - endIndex: endIndex, - pages: pages - }; - } -} \ No newline at end of file + // return object with all pagination properties required by the view + return { + totalGroups: totalGroups, + currentPage: currentPage, + pageSize: pageSize, + totalPages: totalPages, + startPage: startPage, + endPage: endPage, + startIndex: startIndex, + endIndex: endIndex, + pages: pages + }; + } +} diff --git a/dmp-frontend/src/app/services/project/project.service.ts b/dmp-frontend/src/app/services/project/project.service.ts index b2b053c26..b5e3e5618 100644 --- a/dmp-frontend/src/app/services/project/project.service.ts +++ b/dmp-frontend/src/app/services/project/project.service.ts @@ -16,39 +16,39 @@ import { RequestItem } from '../../models/criteria/RequestItem'; @Injectable() export class ProjectService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'projects/'; + this.actionUrl = HostConfiguration.Server + 'projects/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); - } + getPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); + } - get(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'get', requestItem, { headers: this.headers }); - } + get(requestItem: RequestItem): Observable { + return this.http.post(this.actionUrl + 'get', requestItem, { headers: this.headers }); + } - getWithExternal(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'getWithExternal', requestItem, { headers: this.headers }); - } + getWithExternal(requestItem: RequestItem): Observable { + return this.http.post(this.actionUrl + 'getWithExternal', requestItem, { headers: this.headers }); + } - getSingle(id: string): Observable { - return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); - } + getSingle(id: string): Observable { + return this.http.get(this.actionUrl + 'getSingle/' + id, { headers: this.headers }); + } - createProject(projectModel: ProjectModel): Observable { - return this.http.post(this.actionUrl + 'createOrUpdate', projectModel, { headers: this.headers }); - } + createProject(projectModel: ProjectModel): Observable { + return this.http.post(this.actionUrl + 'createOrUpdate', projectModel, { headers: this.headers }); + } - inactivate(id: String): Observable { - return this.http.delete(this.actionUrl + 'inactivate/' + id, { headers: this.headers }); - } + inactivate(id: String): Observable { + return this.http.delete(this.actionUrl + 'inactivate/' + id, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/registries/registry.service.ts b/dmp-frontend/src/app/services/registries/registry.service.ts index 8077ff61a..f282a1f25 100644 --- a/dmp-frontend/src/app/services/registries/registry.service.ts +++ b/dmp-frontend/src/app/services/registries/registry.service.ts @@ -1,26 +1,26 @@ -import { RegisterModel } from "../../models/registers/RegisterModel"; -import { Observable } from "rxjs"; -import { HttpHeaders } from "@angular/common/http"; -import { HostConfiguration } from "../../app.constants"; -import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service"; -import { Injectable } from "@angular/core"; +import { RegisterModel } from '../../models/registers/RegisterModel'; +import { Observable } from 'rxjs'; +import { HttpHeaders } from '@angular/common/http'; +import { HostConfiguration } from '../../app.constants'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { Injectable } from '@angular/core'; @Injectable() export class RegistryService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'registries/'; + this.actionUrl = HostConfiguration.Server + 'registries/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - create(registerModel: RegisterModel): Observable { - return this.http.post(this.actionUrl + 'create', registerModel, { headers: this.headers }) - } + create(registerModel: RegisterModel): Observable { + return this.http.post(this.actionUrl + 'create', registerModel, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/researchers/researchers.service.ts b/dmp-frontend/src/app/services/researchers/researchers.service.ts index 6daccbaba..bb74fcbda 100644 --- a/dmp-frontend/src/app/services/researchers/researchers.service.ts +++ b/dmp-frontend/src/app/services/researchers/researchers.service.ts @@ -3,7 +3,7 @@ import { UserInvitationCriteria } from '../../models/criteria/invitation/UserInv import { User } from '../../models/invitation/User'; import { HostConfiguration } from '../../app.constants'; import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; -import { Injectable } from "@angular/core"; +import { Injectable } from '@angular/core'; import { HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { RequestItem } from '../../models/criteria/RequestItem'; @@ -12,20 +12,20 @@ import { ResearcherModel } from '../../models/researcher/ResearcherModel'; @Injectable() export class ResearcherService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'researchers/'; + this.actionUrl = HostConfiguration.Server + 'researchers/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - public createResearcher(researcher: ResearcherModel) { - return this.http.post(this.actionUrl + "create", researcher, { headers: this.headers }); - } + public createResearcher(researcher: ResearcherModel) { + return this.http.post(this.actionUrl + 'create', researcher, { headers: this.headers }); + } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/services/services/services-data.service.ts b/dmp-frontend/src/app/services/services/services-data.service.ts index cb476df2c..aa8bf6ada 100644 --- a/dmp-frontend/src/app/services/services/services-data.service.ts +++ b/dmp-frontend/src/app/services/services/services-data.service.ts @@ -1,27 +1,27 @@ -import { Injectable } from "@angular/core"; -import { HttpHeaders } from "@angular/common/http"; -import { BaseHttpService } from "../../utilities/cite-http-service-module/base-http.service"; -import { HostConfiguration } from "../../app.constants"; -import { ServiceModel } from "../../models/services/ServiceModel"; -import { Observable } from "rxjs"; +import { Injectable } from '@angular/core'; +import { HttpHeaders } from '@angular/common/http'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { HostConfiguration } from '../../app.constants'; +import { ServiceModel } from '../../models/services/ServiceModel'; +import { Observable } from 'rxjs'; @Injectable() export class ServicesDataService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + 'services/'; + this.actionUrl = HostConfiguration.Server + 'services/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - create(serviceModel: ServiceModel): Observable { - return this.http.post(this.actionUrl + 'create', serviceModel, { headers: this.headers }) - } + create(serviceModel: ServiceModel): Observable { + return this.http.post(this.actionUrl + 'create', serviceModel, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/services/user-reference/user-reference-data.service.ts b/dmp-frontend/src/app/services/user-reference/user-reference-data.service.ts index 2344de3be..f5bc0300d 100644 --- a/dmp-frontend/src/app/services/user-reference/user-reference-data.service.ts +++ b/dmp-frontend/src/app/services/user-reference/user-reference-data.service.ts @@ -14,45 +14,45 @@ import { HostConfiguration } from '../../app.constants'; @Injectable() export class UserReferenceService { - private actionUrl: string; - private headers: HttpHeaders; + private actionUrl: string; + private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService) { - this.actionUrl = HostConfiguration.Server + '/user/'; + this.actionUrl = HostConfiguration.Server + '/user/'; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('Content-Type', 'application/json'); - this.headers = this.headers.set('Accept', 'application/json'); - } + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } - // formatItem(utilities: Utilities, item: ConfigurationModel): ConfigurationModel { - // item.validFrom = new Date(item.validFrom); - // item.validTo = new Date(item.validTo); - // return item - // } + // formatItem(utilities: Utilities, item: ConfigurationModel): ConfigurationModel { + // item.validFrom = new Date(item.validFrom); + // item.validTo = new Date(item.validTo); + // return item + // } - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', JSON.stringify(dataTableRequest), { headers: this.headers }); - } + getPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'getPaged', JSON.stringify(dataTableRequest), { headers: this.headers }); + } - getUser(id: String): Observable { - return this.http.get(this.actionUrl + id, { headers: this.headers }); - } + getUser(id: String): Observable { + return this.http.get(this.actionUrl + id, { headers: this.headers }); + } - updateRoles(itemToUpdate: UserListingModel): Observable { - return this.http.post(this.actionUrl + 'updateRoles', JSON.stringify(itemToUpdate), { headers: this.headers }); - } + updateRoles(itemToUpdate: UserListingModel): Observable { + return this.http.post(this.actionUrl + 'updateRoles', JSON.stringify(itemToUpdate), { headers: this.headers }); + } - delete(id: String): Observable { - return this.http.delete(this.actionUrl + id, { headers: this.headers }); - } + delete(id: String): Observable { + return this.http.delete(this.actionUrl + id, { headers: this.headers }); + } - getRecentActivity(): Observable { - return this.http.get(this.actionUrl + "recentActivity", { headers: this.headers }); - } + getRecentActivity(): Observable { + return this.http.get(this.actionUrl + 'recentActivity', { headers: this.headers }); + } - updateUserSettings(value: any): Observable { - return this.http.post(this.actionUrl + "settings", value, { headers: this.headers }); - } + updateUserSettings(value: any): Observable { + return this.http.post(this.actionUrl + 'settings', value, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/shared/components/add-researchers/add-researchers.component.html b/dmp-frontend/src/app/shared/components/add-researchers/add-researchers.component.html index 9c13f0eea..17c05f341 100644 --- a/dmp-frontend/src/app/shared/components/add-researchers/add-researchers.component.html +++ b/dmp-frontend/src/app/shared/components/add-researchers/add-researchers.component.html @@ -14,6 +14,6 @@
-
+ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/shared/components/add-researchers/add-researchers.component.ts b/dmp-frontend/src/app/shared/components/add-researchers/add-researchers.component.ts index bbb50bf56..dad2638f3 100644 --- a/dmp-frontend/src/app/shared/components/add-researchers/add-researchers.component.ts +++ b/dmp-frontend/src/app/shared/components/add-researchers/add-researchers.component.ts @@ -1,6 +1,6 @@ import { JsonSerializer } from '../../../utilities/JsonSerializer'; import { RequestItem } from '../../../models/criteria/RequestItem'; -import { Component, OnInit, Inject } from "@angular/core"; +import { Component, OnInit, Inject } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Params, ActivatedRoute, Router } from '@angular/router'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; @@ -8,31 +8,31 @@ import { ResearcherModel } from '../../../models/researcher/ResearcherModel'; import { ResearcherService } from '../../../services/researchers/researchers.service'; @Component({ - selector: 'add-researchers-component', - templateUrl: 'add-researchers.component.html', + selector: 'app-add-researchers-component', + templateUrl: 'add-researchers.component.html', }) export class AddResearchersComponent implements OnInit { - public formGroup: FormGroup; + public formGroup: FormGroup; - constructor( - private researcherService: ResearcherService, - private route: ActivatedRoute, - public router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } + constructor( + private researcherService: ResearcherService, + private route: ActivatedRoute, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } - ngOnInit(): void { - let researcher = new ResearcherModel(); - this.formGroup = researcher.buildForm(); - } + ngOnInit(): void { + const researcher = new ResearcherModel(); + this.formGroup = researcher.buildForm(); + } - send(value: any) { - this.researcherService.createResearcher(this.formGroup.value).subscribe( - null, null, () => this.dialogRef.close() - ); - } + send(value: any) { + this.researcherService.createResearcher(this.formGroup.value).subscribe( + null, null, () => this.dialogRef.close() + ); + } } diff --git a/dmp-frontend/src/app/shared/components/auto-complete/AutoCompleteConfiguration.ts b/dmp-frontend/src/app/shared/components/auto-complete/AutoCompleteConfiguration.ts index 7dd457ec4..d12a66192 100644 --- a/dmp-frontend/src/app/shared/components/auto-complete/AutoCompleteConfiguration.ts +++ b/dmp-frontend/src/app/shared/components/auto-complete/AutoCompleteConfiguration.ts @@ -1,11 +1,11 @@ -import { BaseCriteria } from "../../../models/criteria/BaseCriteria"; -import { RequestItem } from "../../../models/criteria/RequestItem"; +import { BaseCriteria } from '../../../models/criteria/BaseCriteria'; +import { RequestItem } from '../../../models/criteria/RequestItem'; export class AutoCompleteConfiguration { - public callback: Function; - public requestItem: RequestItem; - constructor(callback: Function, requestItem: RequestItem) { - this.callback = callback; - this.requestItem = requestItem; - } + public callback: Function; + public requestItem: RequestItem; + constructor(callback: Function, requestItem: RequestItem) { + this.callback = callback; + this.requestItem = requestItem; + } } diff --git a/dmp-frontend/src/app/shared/components/auto-complete/auto-complete.component.html b/dmp-frontend/src/app/shared/components/auto-complete/auto-complete.component.html index 2fbdd576c..5116f42b1 100644 --- a/dmp-frontend/src/app/shared/components/auto-complete/auto-complete.component.html +++ b/dmp-frontend/src/app/shared/components/auto-complete/auto-complete.component.html @@ -9,7 +9,6 @@ {{ this.printText(option) }} | {{subtitleFn(option)}} - diff --git a/dmp-frontend/src/app/shared/components/auto-complete/auto-complete.component.ts b/dmp-frontend/src/app/shared/components/auto-complete/auto-complete.component.ts index 5dbe8b5ec..f414f9b00 100644 --- a/dmp-frontend/src/app/shared/components/auto-complete/auto-complete.component.ts +++ b/dmp-frontend/src/app/shared/components/auto-complete/auto-complete.component.ts @@ -4,117 +4,113 @@ import { ErrorStateMatcher } from '@angular/material'; import { AutoCompleteConfiguration } from './AutoCompleteConfiguration'; @Component({ - selector: 'app-auto-complete', - templateUrl: './auto-complete.component.html', - styleUrls: ['./auto-complete.component.scss'] + selector: 'app-auto-complete', + templateUrl: './auto-complete.component.html', + styleUrls: ['./auto-complete.component.scss'] }) export class AutoCompleteComponent implements OnInit, ErrorStateMatcher { - @Input() placeholder: String; - @Input() disabled: boolean; + @Input() placeholder: String; + @Input() disabled: boolean; - @Input() typeaheadMS: number; - @Input() formCtrl: FormControl; - @Input() required = false; - @Input() displayFunction: Function; - @Input() _subtitleFn: Function; + @Input() typeaheadMS: number; + @Input() formCtrl: FormControl; + @Input() required = false; + @Input() displayFunction: Function; + @Input() _subtitleFn: Function; - @Input() assignValueFunction: Function; - @Input() transformFunction: Function; - @Input() inputData: AutoCompleteConfiguration; - @Input() validationErrorString: String; - @Input() clear = false; + @Input() assignValueFunction: Function; + @Input() transformFunction: Function; + @Input() inputData: AutoCompleteConfiguration; + @Input() validationErrorString: String; + @Input() clear = false; - @Output() onItemChange = new EventEmitter(); + @Output() onItemChange = new EventEmitter(); - public textFormCtrl: FormControl; - public options: any[]; + public textFormCtrl: FormControl; + public options: any[]; - loading = false; - hasSelectedItem = false; - isUnchanged = true; + loading = false; + hasSelectedItem = false; + isUnchanged = true; - constructor() { + constructor() { - } + } - ngOnInit() { + ngOnInit() { - this.textFormCtrl = new FormControl(); - if (this.disabled) this.textFormCtrl.disable(); - this.formCtrl.registerOnDisabledChange(isDisabled => { - if (isDisabled) this.textFormCtrl.disable({ onlySelf: true, emitEvent: false }); - else this.textFormCtrl.enable({ onlySelf: true, emitEvent: false }); - }) - if (this.formCtrl && this.formCtrl.value) { - this.textFormCtrl.patchValue(this.formCtrl.value, { emitEvent: false }); - this.hasSelectedItem = true; - } + this.textFormCtrl = new FormControl(); + if (this.disabled) { this.textFormCtrl.disable(); } + this.formCtrl.registerOnDisabledChange(isDisabled => { + if (isDisabled) { this.textFormCtrl.disable({ onlySelf: true, emitEvent: false }); } else { this.textFormCtrl.enable({ onlySelf: true, emitEvent: false }); } + }); + if (this.formCtrl && this.formCtrl.value) { + this.textFormCtrl.patchValue(this.formCtrl.value, { emitEvent: false }); + this.hasSelectedItem = true; + } - const valueChanges = this.textFormCtrl.valueChanges.share(); + const valueChanges = this.textFormCtrl.valueChanges.share(); - valueChanges.subscribe(searchTerm => { // reset value of input control every time the user starts typing - if (this.hasSelectedItem) { - this.hasSelectedItem = false; - this.onItemChange.emit(null); - if (this.formCtrl && this.formCtrl.value) { - this.formCtrl.patchValue(null, { emitEvent: false }); - } - } - this.isUnchanged = false; - }); + valueChanges.subscribe(searchTerm => { // reset value of input control every time the user starts typing + if (this.hasSelectedItem) { + this.hasSelectedItem = false; + this.onItemChange.emit(null); + if (this.formCtrl && this.formCtrl.value) { + this.formCtrl.patchValue(null, { emitEvent: false }); + } + } + this.isUnchanged = false; + }); - valueChanges.debounceTime(this.typeaheadMS) - .do(value => { - if (this.hasSelectedItem) { this.loading = false; } - if (typeof value === 'string') { - this.loading = true; - this.inputData.requestItem.criteria["like"] = value; - this.inputData.callback(this.inputData.requestItem).map(res => { - this.options = res; - this.loading = false; - }).subscribe(); - } else { - this.loading = false; - } - }) - .subscribe(); - } + valueChanges.debounceTime(this.typeaheadMS) + .do(value => { + if (this.hasSelectedItem) { this.loading = false; } + if (typeof value === 'string') { + this.loading = true; + this.inputData.requestItem.criteria['like'] = value; + this.inputData.callback(this.inputData.requestItem).map(res => { + this.options = res; + this.loading = false; + }).subscribe(); + } else { + this.loading = false; + } + }) + .subscribe(); + } - printText(item: any): string { - if (this.displayFunction) { - return this.displayFunction(item) - } - else return item; - } + printText(item: any): string { + if (this.displayFunction) { + return this.displayFunction(item); + } else { return item; } + } - subtitleFn(item) { - return this._subtitleFn(item); - } + subtitleFn(item) { + return this._subtitleFn(item); + } - getValue(item: any): string { - if (this.assignValueFunction) { - if (this.transformFunction) return this.assignValueFunction(this.transformFunction(item)) - else return this.assignValueFunction(item) - } - else return item; - } + getValue(item: any): string { + if (this.assignValueFunction) { + if (this.transformFunction) { return this.assignValueFunction(this.transformFunction(item)); } else { return this.assignValueFunction(item); } + } else { return item; } + } - optionSelected(event: any) { - if (this.formCtrl) { this.formCtrl.patchValue(this.assignValueFunction ? this.assignValueFunction(event.option.value) : event.option.value, { emitEvent: false }); } - this.hasSelectedItem = true; - this.onItemChange.emit(this.assignValueFunction ? this.assignValueFunction(event.option.value) : event.option.value); - if (this.clear) { - this.options = []; - this.loading = false; - this.textFormCtrl.patchValue(null) - }; - } + optionSelected(event: any) { + if (this.formCtrl) { this.formCtrl.patchValue(this.assignValueFunction ? this.assignValueFunction(event.option.value) : event.option.value, { emitEvent: false }); } + this.hasSelectedItem = true; + this.onItemChange.emit(this.assignValueFunction ? this.assignValueFunction(event.option.value) : event.option.value); + if (this.clear) { + this.options = []; + this.loading = false; + this.textFormCtrl.patchValue(null); + } + } - isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { - const isFormSubmitted = form && form.submitted; - const isControlInvalid = (control && control.invalid && (control.dirty || control.touched || isFormSubmitted)) || (!this.hasSelectedItem && !this.isUnchanged); - const isFormInvalid = form && form.enabled && form.invalid && (form.dirty || form.touched || isFormSubmitted); - return !!((isControlInvalid || isFormInvalid) && this.required); - } + isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { + const isFormSubmitted = form && form.submitted; + const isControlInvalid = (control && control.invalid && (control.dirty || control.touched || isFormSubmitted)) || (!this.hasSelectedItem && !this.isUnchanged); + const isFormInvalid = form && form.enabled && form.invalid && (form.dirty || form.touched || isFormSubmitted); + return !!((isControlInvalid || isFormInvalid) && this.required); + } } diff --git a/dmp-frontend/src/app/shared/components/autocompletes/multiple/multiple-auto-complete.component.ts b/dmp-frontend/src/app/shared/components/autocompletes/multiple/multiple-auto-complete.component.ts index e33c9e693..930ad5580 100644 --- a/dmp-frontend/src/app/shared/components/autocompletes/multiple/multiple-auto-complete.component.ts +++ b/dmp-frontend/src/app/shared/components/autocompletes/multiple/multiple-auto-complete.component.ts @@ -22,7 +22,7 @@ export class MultipleAutoCompleteComponent implements OnInit { @Input() placeholder: string; @Input() validationErrorString: string; @Input() configuration: MultipleAutoCompleteConfiguration; - @Input() required: boolean; + @Input() required: boolean; // Selected Option Event @Output() optionSelected: EventEmitter = new EventEmitter(); @@ -135,11 +135,11 @@ export class MultipleAutoCompleteComponent implements OnInit { } _removeSelectedItem(item: any): void { - let autocompleteValue = this.reactiveFormControl.value; + const autocompleteValue = this.reactiveFormControl.value; const index = autocompleteValue.indexOf(item); if (index >= 0) { - autocompleteValue.splice(index, 1); - this.reactiveFormControl.patchValue(autocompleteValue) + autocompleteValue.splice(index, 1); + this.reactiveFormControl.patchValue(autocompleteValue); } } diff --git a/dmp-frontend/src/app/shared/components/autocompletes/single/single-auto-complete.component.ts b/dmp-frontend/src/app/shared/components/autocompletes/single/single-auto-complete.component.ts index 39273fe8d..a52d55164 100644 --- a/dmp-frontend/src/app/shared/components/autocompletes/single/single-auto-complete.component.ts +++ b/dmp-frontend/src/app/shared/components/autocompletes/single/single-auto-complete.component.ts @@ -2,7 +2,7 @@ import { Input, OnInit, Component, Output, EventEmitter, ViewChild, ElementRef, import { FormControl, FormGroupDirective, NgForm, FormArray, AbstractControl, FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ErrorStateMatcher, MatChipInputEvent, MatAutocompleteSelectedEvent, MatChipList } from '@angular/material'; import { TranslateService } from '@ngx-translate/core'; -import { Subject , Observable } from 'rxjs'; +import { Subject, Observable } from 'rxjs'; import { map, startWith, merge, mapTo, mergeMap, timeout } from 'rxjs/operators'; import { SingleAutoCompleteConfiguration } from './single-auto-complete-configuration'; @@ -16,7 +16,7 @@ export class SingleAutoCompleteComponent implements OnInit { @Input() reactiveFormControl: FormControl; @Input() placeholder: string; @Input() validationErrorString: string; - @Input() required: boolean; + @Input() required: boolean; @Input() configuration: SingleAutoCompleteConfiguration; // Selected Option Event diff --git a/dmp-frontend/src/app/shared/components/available-profiles/available-profiles.component.ts b/dmp-frontend/src/app/shared/components/available-profiles/available-profiles.component.ts index 004a1bd62..ca4c22867 100644 --- a/dmp-frontend/src/app/shared/components/available-profiles/available-profiles.component.ts +++ b/dmp-frontend/src/app/shared/components/available-profiles/available-profiles.component.ts @@ -1,6 +1,6 @@ import { JsonSerializer } from '../../../utilities/JsonSerializer'; import { RequestItem } from '../../../models/criteria/RequestItem'; -import { Component, OnInit, Inject } from "@angular/core"; +import { Component, OnInit, Inject } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Params, ActivatedRoute, Router } from '@angular/router'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; @@ -9,43 +9,43 @@ import { DatasetProfileModel } from '../../../models/datasetprofile/DatasetProfi import { DatasetProfileModule } from '../../../dataset-profile-form/dataset-profile.module'; @Component({ - selector: 'available-profiles-component', - templateUrl: 'available-profiles.component.html', + selector: 'app-available-profiles-component', + templateUrl: 'available-profiles.component.html', }) export class AvailableProfilesComponent implements OnInit { - public formGroup: FormGroup; - public profiles: DatasetProfileModel[] = []; - public selectedProfiles: DatasetProfileModel[] = []; - public selectedOptions: any - constructor( - private datasetService: DatasetService, - private route: ActivatedRoute, - public router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } + public formGroup: FormGroup; + public profiles: DatasetProfileModel[] = []; + public selectedProfiles: DatasetProfileModel[] = []; + public selectedOptions: any; + constructor( + private datasetService: DatasetService, + private route: ActivatedRoute, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } - ngOnInit(): void { - this.formGroup = this.data["profiles"]; - this.datasetService.getDatasetProfiles().subscribe(data => { - this.profiles = JsonSerializer.fromJSONArray(data, DatasetProfileModel) - }) - } + ngOnInit(): void { + this.formGroup = this.data['profiles']; + this.datasetService.getDatasetProfiles().subscribe(data => { + this.profiles = JsonSerializer.fromJSONArray(data, DatasetProfileModel); + }); + } - addProfiles(profiles) { - profiles.selectedOptions.selected.forEach(element => { - let selectedElement = new DatasetProfileModel(); - selectedElement.id = element.value.id; - selectedElement.label = element.value.label; - this.selectedProfiles.push(selectedElement) - }) - this.formGroup.setValue(this.selectedProfiles) - this.dialogRef.close(); - } + addProfiles(profiles) { + profiles.selectedOptions.selected.forEach(element => { + const selectedElement = new DatasetProfileModel(); + selectedElement.id = element.value.id; + selectedElement.label = element.value.label; + this.selectedProfiles.push(selectedElement); + }); + this.formGroup.setValue(this.selectedProfiles); + this.dialogRef.close(); + } - isOptionSelected(profile: any){ - return this.formGroup.value.map(x=> x.id).indexOf(profile.id) !== -1 - } + isOptionSelected(profile: any) { + return this.formGroup.value.map(x => x.id).indexOf(profile.id) !== -1; + } } diff --git a/dmp-frontend/src/app/shared/components/breadcrumb/definition/IBreadCrumbComponent.ts b/dmp-frontend/src/app/shared/components/breadcrumb/definition/IBreadCrumbComponent.ts index 1af00cb84..d01bb6d94 100644 --- a/dmp-frontend/src/app/shared/components/breadcrumb/definition/IBreadCrumbComponent.ts +++ b/dmp-frontend/src/app/shared/components/breadcrumb/definition/IBreadCrumbComponent.ts @@ -1,6 +1,6 @@ -import { BreadcrumbItem } from "./breadcrumb-item"; -import { Observable } from "rxjs/Observable"; +import { BreadcrumbItem } from './breadcrumb-item'; +import { Observable } from 'rxjs/Observable'; export interface IBreadCrumbComponent { - breadCrumbs: Observable + breadCrumbs: Observable; } diff --git a/dmp-frontend/src/app/shared/components/breadcrumb/definition/breadcrumb-item.ts b/dmp-frontend/src/app/shared/components/breadcrumb/definition/breadcrumb-item.ts index 661f1237c..88f8c318a 100644 --- a/dmp-frontend/src/app/shared/components/breadcrumb/definition/breadcrumb-item.ts +++ b/dmp-frontend/src/app/shared/components/breadcrumb/definition/breadcrumb-item.ts @@ -1,9 +1,9 @@ -import { Observable } from "rxjs/Observable"; +import { Observable } from 'rxjs/Observable'; export class BreadcrumbItem { - parentComponentName?: string; - label: string; - url: string; - params?: any = {}; - notFoundResolver?: any[] + parentComponentName?: string; + label: string; + url: string; + params?: any = {}; + notFoundResolver?: any[]; } diff --git a/dmp-frontend/src/app/shared/components/criteria/base/base-criteria.component.ts b/dmp-frontend/src/app/shared/components/criteria/base/base-criteria.component.ts index 4b187e1d1..bcd2f1a56 100644 --- a/dmp-frontend/src/app/shared/components/criteria/base/base-criteria.component.ts +++ b/dmp-frontend/src/app/shared/components/criteria/base/base-criteria.component.ts @@ -3,100 +3,100 @@ import { FormControl, FormGroup, NgForm, FormArray, AbstractControl } from '@ang import { BaseCriteriaErrorModel } from '../../../../models/criteria/BaseCriteriaErrorModel'; @Component({ - selector: 'base-criteria-component', - template: '', - providers: [ + selector: 'app-base-criteria-component', + template: '', + providers: [ - ] + ] }) export class BaseCriteriaComponent implements OnInit { - public refreshCallback: Function = null; - public formGroup: FormGroup = null; + public refreshCallback: Function = null; + public formGroup: FormGroup = null; - constructor( - public baseErrorModel?: BaseCriteriaErrorModel, - ) { - } + constructor( + public baseErrorModel?: BaseCriteriaErrorModel, + ) { + } - ngOnInit() { - if (this.baseErrorModel == null) { this.baseErrorModel = new BaseCriteriaErrorModel(); } - } + ngOnInit() { + if (this.baseErrorModel == null) { this.baseErrorModel = new BaseCriteriaErrorModel(); } + } - controlModified(): void { - this.clearErrorModel(); - if (!this.isFormValid()) { return; } - if (this.refreshCallback != null) { this.refreshCallback(); } - } + controlModified(): void { + this.clearErrorModel(); + if (!this.isFormValid()) { return; } + if (this.refreshCallback != null) { this.refreshCallback(); } + } - public isFormValid(): boolean { - this.touchAllFormFields(this.formGroup); - this.validateAllFormFields(this.formGroup); - return this.formGroup.valid; - } + public isFormValid(): boolean { + this.touchAllFormFields(this.formGroup); + this.validateAllFormFields(this.formGroup); + return this.formGroup.valid; + } - public getFormData(): any { - return this.formGroup.value; - } + public getFormData(): any { + return this.formGroup.value; + } - public getFormControl(controlName: string): AbstractControl { - return this.formGroup.get(controlName); - } + public getFormControl(controlName: string): AbstractControl { + return this.formGroup.get(controlName); + } - public disableFormFields(formControl: AbstractControl) { - formControl.disable(); - } + public disableFormFields(formControl: AbstractControl) { + formControl.disable(); + } - public validateAllFormFields(formControl: AbstractControl) { - if (formControl instanceof FormControl) { - formControl.updateValueAndValidity({ emitEvent: false }) - } else if (formControl instanceof FormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.validateAllFormFields(control); - }) - } else if (formControl instanceof FormArray) { - formControl.controls.forEach(item => { - this.validateAllFormFields(item); - }) - } - } + public validateAllFormFields(formControl: AbstractControl) { + if (formControl instanceof FormControl) { + formControl.updateValueAndValidity({ emitEvent: false }); + } else if (formControl instanceof FormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + this.validateAllFormFields(control); + }); + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + this.validateAllFormFields(item); + }); + } + } - public touchAllFormFields(formControl: AbstractControl) { - if (formControl instanceof FormControl) { - formControl.markAsTouched(); - } else if (formControl instanceof FormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.touchAllFormFields(control); - }) - } else if (formControl instanceof FormArray) { - formControl.controls.forEach(item => { - this.touchAllFormFields(item); - }) - } - } + public touchAllFormFields(formControl: AbstractControl) { + if (formControl instanceof FormControl) { + formControl.markAsTouched(); + } else if (formControl instanceof FormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + this.touchAllFormFields(control); + }); + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + this.touchAllFormFields(item); + }); + } + } - setRefreshCallback(callback: Function): void { - this.refreshCallback = callback; - } + setRefreshCallback(callback: Function): void { + this.refreshCallback = callback; + } - onCallbackError(error: any) { - this.setErrorModel(error.error); - this.validateAllFormFields(this.formGroup); - } + onCallbackError(error: any) { + this.setErrorModel(error.error); + this.validateAllFormFields(this.formGroup); + } - public setErrorModel(errorModel: BaseCriteriaErrorModel) { - Object.keys(errorModel).forEach(item => { - (this.baseErrorModel)[item] = (errorModel)[item]; - }) - } + public setErrorModel(errorModel: BaseCriteriaErrorModel) { + Object.keys(errorModel).forEach(item => { + (this.baseErrorModel)[item] = (errorModel)[item]; + }); + } - public clearErrorModel() { - Object.keys(this.baseErrorModel).forEach(item => { - (this.baseErrorModel)[item] = ''; - }) - } + public clearErrorModel() { + Object.keys(this.baseErrorModel).forEach(item => { + (this.baseErrorModel)[item] = ''; + }); + } } diff --git a/dmp-frontend/src/app/shared/components/criteria/data-management-plan/dmp-criteria.component.html b/dmp-frontend/src/app/shared/components/criteria/data-management-plan/dmp-criteria.component.html index 4969c6817..cdc0b7a6b 100644 --- a/dmp-frontend/src/app/shared/components/criteria/data-management-plan/dmp-criteria.component.html +++ b/dmp-frontend/src/app/shared/components/criteria/data-management-plan/dmp-criteria.component.html @@ -1,22 +1,23 @@
- - - -

{{'CRITERIA.FILTERS'| translate}}

-
-
-
-
- - - {{baseErrorModel['Criteria.like']}} - -
-
- - -
-
-
+ + + +

{{'CRITERIA.FILTERS'| translate}}

+
+
+
+
+ + + {{baseErrorModel['Criteria.like']}} + +
+
+ + +
+
+
diff --git a/dmp-frontend/src/app/shared/components/criteria/data-management-plan/dmp-criteria.component.ts b/dmp-frontend/src/app/shared/components/criteria/data-management-plan/dmp-criteria.component.ts index 9c97e857e..173c83abc 100644 --- a/dmp-frontend/src/app/shared/components/criteria/data-management-plan/dmp-criteria.component.ts +++ b/dmp-frontend/src/app/shared/components/criteria/data-management-plan/dmp-criteria.component.ts @@ -14,70 +14,70 @@ import { create } from 'domain'; import { MultipleAutoCompleteConfiguration } from '../../autocompletes/multiple/multiple-auto-complete-configuration'; @Component({ - selector: 'app-dmp-criteria-component', - templateUrl: './dmp-criteria.component.html', - styleUrls: ['./dmp-criteria.component.scss'], + selector: 'app-dmp-criteria-component', + templateUrl: './dmp-criteria.component.html', + styleUrls: ['./dmp-criteria.component.scss'], }) export class DataManagementPlanCriteriaComponent extends BaseCriteriaComponent implements OnInit { - @Input() - showProject: boolean; - filteringProjectsAsync: boolean = false; - filteredProjects: ProjectModel[]; - projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; - public formGroup = new FormBuilder().group({ - like: new FormControl(), - projects: new FormControl() - }); + @Input() + showProject: boolean; + filteringProjectsAsync = false; + filteredProjects: ProjectModel[]; + projectAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + public formGroup = new FormBuilder().group({ + like: new FormControl(), + projects: new FormControl() + }); - constructor( - public language: TranslateService, - public projectService: ProjectService, - public formBuilder: FormBuilder - ) { - super(new DataManagementPlanCriteriaErrorModel()); - } + constructor( + public language: TranslateService, + public projectService: ProjectService, + public formBuilder: FormBuilder + ) { + super(new DataManagementPlanCriteriaErrorModel()); + } - ngOnInit() { - super.ngOnInit(); + ngOnInit() { + super.ngOnInit(); - this.projectAutoCompleteConfiguration = { - filterFn: this.filterProject.bind(this), - initialItems: (excludedItems: any[]) => this.filterProject('').map(result => result.filter(x => excludedItems.map(x => x.id).indexOf(x.id) == -1)), - displayFn: (item) => item["label"], - titleFn: (item) => item["label"], - //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), - loadDataOnStart: true - }; + this.projectAutoCompleteConfiguration = { + filterFn: this.filterProject.bind(this), + initialItems: (excludedItems: any[]) => this.filterProject('').map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1)), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'], + //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), + loadDataOnStart: true + }; - this.formGroup.get('projects').valueChanges.subscribe(x => this.controlModified()) - this.formGroup.get('like').valueChanges.subscribe(x => this.controlModified()) - //if (this.criteria == null) { this.criteria = new DataManagementPlanCriteria(); } - } + this.formGroup.get('projects').valueChanges.subscribe(x => this.controlModified()); + this.formGroup.get('like').valueChanges.subscribe(x => this.controlModified()); + //if (this.criteria == null) { this.criteria = new DataManagementPlanCriteria(); } + } - setCriteria(criteria: DataManagementPlanCriteria): void { - this.formGroup.get('like').patchValue(criteria.like) - this.formGroup.get('projects').patchValue(criteria.projects) - } + setCriteria(criteria: DataManagementPlanCriteria): void { + this.formGroup.get('like').patchValue(criteria.like); + this.formGroup.get('projects').patchValue(criteria.projects); + } - onCallbackError(error: any) { - this.setErrorModel(error.error); - } + onCallbackError(error: any) { + this.setErrorModel(error.error); + } - controlModified(): void { - this.clearErrorModel(); - if (this.refreshCallback != null && - (this.formGroup.get('like').value == null || this.formGroup.get('like').value.length == 0 || this.formGroup.get('like').value.length > 2) - ) { - this.refreshCallback(); - } - } + controlModified(): void { + this.clearErrorModel(); + if (this.refreshCallback != null && + (this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2) + ) { + this.refreshCallback(); + } + } - filterProject(query: string) { - let projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new ProjectCriteria(); - projectRequestItem.criteria.like = query; - return this.projectService.getWithExternal(projectRequestItem); - } + filterProject(query: string) { + const projectRequestItem: RequestItem = new RequestItem(); + projectRequestItem.criteria = new ProjectCriteria(); + projectRequestItem.criteria.like = query; + return this.projectService.getWithExternal(projectRequestItem); + } } diff --git a/dmp-frontend/src/app/shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component.html b/dmp-frontend/src/app/shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component.html index 907de7938..d1f2e79a7 100644 --- a/dmp-frontend/src/app/shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component.html +++ b/dmp-frontend/src/app/shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component.html @@ -1,13 +1,13 @@
- -
-
- - - {{baseErrorModel['Criteria.like']}} - -
-
-
-
\ No newline at end of file + +
+
+ + + {{baseErrorModel['Criteria.like']}} + +
+
+
+ diff --git a/dmp-frontend/src/app/shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component.ts b/dmp-frontend/src/app/shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component.ts index fc8fa0827..195ed8fe3 100644 --- a/dmp-frontend/src/app/shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component.ts +++ b/dmp-frontend/src/app/shared/components/criteria/datamanagementplanprofile/dmp-profile-criteria.component.ts @@ -14,45 +14,45 @@ import { DataManagementPlanProfileCriteria } from '../../../../models/criteria/d import { DataManagementPlanProfileCriteriaErrorModel } from '../../../../models/criteria/dmp-profile/DataManagementPlanProfileCriteriaErrorModel'; @Component({ - selector: 'app-dmp-profile-criteria-component', - templateUrl: './dmp-profile-criteria.component.html', - styleUrls: ['./dmp-profile-criteria.component.scss'], + selector: 'app-dmp-profile-criteria-component', + templateUrl: './dmp-profile-criteria.component.html', + styleUrls: ['./dmp-profile-criteria.component.scss'], }) export class DataManagementPlanProfileCriteriaComponent extends BaseCriteriaComponent implements OnInit { - @Input() - showProject: boolean; - public criteria: DataManagementPlanProfileCriteria = new DataManagementPlanProfileCriteria(); - filteringProjectsAsync: boolean = false; - filteredProjects: ProjectModel[]; + @Input() + showProject: boolean; + public criteria: DataManagementPlanProfileCriteria = new DataManagementPlanProfileCriteria(); + filteringProjectsAsync = false; + filteredProjects: ProjectModel[]; - constructor( - public language: TranslateService, - public formBuilder: FormBuilder - ) { - super(new DataManagementPlanProfileCriteriaErrorModel()); - } + constructor( + public language: TranslateService, + public formBuilder: FormBuilder + ) { + super(new DataManagementPlanProfileCriteriaErrorModel()); + } - ngOnInit() { - super.ngOnInit(); - if (this.criteria == null) { this.criteria = new DataManagementPlanCriteria(); } - } + ngOnInit() { + super.ngOnInit(); + if (this.criteria == null) { this.criteria = new DataManagementPlanCriteria(); } + } - setCriteria(criteria: DataManagementPlanProfileCriteria): void { - this.criteria = criteria; - } + setCriteria(criteria: DataManagementPlanProfileCriteria): void { + this.criteria = criteria; + } - onCallbackError(error: any) { - this.setErrorModel(error.error); - } + onCallbackError(error: any) { + this.setErrorModel(error.error); + } - controlModified(): void { - this.clearErrorModel(); - if (this.refreshCallback != null && - (this.criteria.like == null || this.criteria.like.length == 0 || this.criteria.like.length > 2) - ) { - this.refreshCallback(); - } - } + controlModified(): void { + this.clearErrorModel(); + if (this.refreshCallback != null && + (this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2) + ) { + this.refreshCallback(); + } + } } diff --git a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html index 6bc35ab95..4c769a7c5 100644 --- a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html +++ b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html @@ -1,12 +1,12 @@
- - - -

{{'CRITERIA.FILTERS'| translate}}

-
-
-
- -
- - - {{baseErrorModel['Criteria.like']}} - -
-
- - - - {{status.viewValue}} - - - {{baseErrorModel['Criteria.status']}} - -
-
- - -
{{chip.name.substring(0, 1).toUpperCase()}}
- {{chip.name}} -
- -
- {{option.name}} -
-
- -
-
-
-
+
+ + + {{baseErrorModel['Criteria.like']}} + +
+
+ + + + {{status.viewValue}} + + + {{baseErrorModel['Criteria.status']}} + +
+
+ + +
{{chip.name.substring(0, 1).toUpperCase()}}
+ {{chip.name}} +
+ +
+ {{option.name}} +
+
+ +
+
+ +
- - - {{baseErrorModel['criteria.like']}} - - - - - - - {{baseErrorModel['criteria.periodStart']}} + + + + {{baseErrorModel['criteria.like']}} + + + + + + + {{baseErrorModel['criteria.periodStart']}} - - - {{baseErrorModel['criteria.periodEnd']}} - - - + + + {{baseErrorModel['criteria.periodEnd']}} + + + - - - - {{ 'CRITERIA.PROJECTS.TYPES.ON-GOING' | translate}} - - - {{ 'CRITERIA.PROJECTS.TYPES.FINISHED' | translate}} - - - + + + + {{ 'CRITERIA.PROJECTS.TYPES.ON-GOING' | translate}} + + + {{ 'CRITERIA.PROJECTS.TYPES.FINISHED' | translate}} + + + diff --git a/dmp-frontend/src/app/shared/components/criteria/projects/projects-criteria.component.ts b/dmp-frontend/src/app/shared/components/criteria/projects/projects-criteria.component.ts index cea6985e9..df5a08b52 100644 --- a/dmp-frontend/src/app/shared/components/criteria/projects/projects-criteria.component.ts +++ b/dmp-frontend/src/app/shared/components/criteria/projects/projects-criteria.component.ts @@ -47,7 +47,7 @@ export class ProjectCriteriaComponent extends BaseCriteriaComponent implements O controlModified(): void { this.clearErrorModel(); if (this.refreshCallback != null && - (this.criteria.like == null || this.criteria.like.length == 0 || this.criteria.like.length > 2) + (this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2) ) { this.refreshCallback(); } diff --git a/dmp-frontend/src/app/shared/components/criteria/users/users-criteria.component.html b/dmp-frontend/src/app/shared/components/criteria/users/users-criteria.component.html index 7d363fe99..7e8ab3fbc 100644 --- a/dmp-frontend/src/app/shared/components/criteria/users/users-criteria.component.html +++ b/dmp-frontend/src/app/shared/components/criteria/users/users-criteria.component.html @@ -3,22 +3,17 @@
- +
- + {{getPrincipalAppRoleWithLanguage(role)}}
- \ No newline at end of file + diff --git a/dmp-frontend/src/app/shared/components/criteria/users/users-criteria.component.ts b/dmp-frontend/src/app/shared/components/criteria/users/users-criteria.component.ts index 7728c0bab..a625a0ab6 100644 --- a/dmp-frontend/src/app/shared/components/criteria/users/users-criteria.component.ts +++ b/dmp-frontend/src/app/shared/components/criteria/users/users-criteria.component.ts @@ -9,76 +9,76 @@ import { Principal } from '../../../../models/login/Principal'; import { FormBuilder, FormGroup } from '@angular/forms'; @Component({ - selector: 'users-criteria-component', - templateUrl: './users-criteria.component.html', - styleUrls: ['./users-criteria.component.scss'], - providers:[Utilities] + selector: 'app-users-criteria-component', + templateUrl: './users-criteria.component.html', + styleUrls: ['./users-criteria.component.scss'], + providers: [Utilities] }) export class UsersCriteriaComponent extends BaseCriteriaComponent implements OnInit { - public role: Principal.AppRole; - public criteria: UserCriteria = new UserCriteria(); + public role: Principal.AppRole; + public criteria: UserCriteria = new UserCriteria(); - constructor( - public language: TranslateService, - public formBuilder: FormBuilder, - public utilities: Utilities - ) { - super(new UserCriteriaErrorModel()); - } + constructor( + public language: TranslateService, + public formBuilder: FormBuilder, + public utilities: Utilities + ) { + super(new UserCriteriaErrorModel()); + } - ngOnInit() { - super.ngOnInit(); - if (this.criteria == null) { this.criteria = new UserCriteria(); } - if (this.formGroup == null) { this.formGroup = this.buildForm(); } - } + ngOnInit() { + super.ngOnInit(); + if (this.criteria == null) { this.criteria = new UserCriteria(); } + if (this.formGroup == null) { this.formGroup = this.buildForm(); } + } - setCriteria(criteria: UserCriteria): void { - this.criteria = criteria; - this.formGroup = this.buildForm(); - } + setCriteria(criteria: UserCriteria): void { + this.criteria = criteria; + this.formGroup = this.buildForm(); + } - public fromJSONObject(item: any): UserCriteria { - this.criteria = new UserCriteria(); - this.criteria.label = item.Label; - this.criteria.appRoles = item.appRoles; - return this.criteria; - } + public fromJSONObject(item: any): UserCriteria { + this.criteria = new UserCriteria(); + this.criteria.label = item.Label; + this.criteria.appRoles = item.appRoles; + return this.criteria; + } - buildForm(): FormGroup { - const context: ValidationContext = this.createValidationContext(); + buildForm(): FormGroup { + const context: ValidationContext = this.createValidationContext(); - return this.formBuilder.group({ - like: [this.criteria.label, context.getValidation('label').validators], - appRoles: [this.criteria.appRoles, context.getValidation('appRoles').validators], - }); - } + return this.formBuilder.group({ + like: [this.criteria.label, context.getValidation('label').validators], + appRoles: [this.criteria.appRoles, context.getValidation('appRoles').validators], + }); + } - createValidationContext(): ValidationContext { - const validationContext: ValidationContext = new ValidationContext(); - const validationArray: Validation[] = new Array(); + createValidationContext(): ValidationContext { + const validationContext: ValidationContext = new ValidationContext(); + const validationArray: Validation[] = new Array(); - validationArray.push({ key: 'label' }); - validationArray.push({ key: 'appRoles' }); + validationArray.push({ key: 'label' }); + validationArray.push({ key: 'appRoles' }); - validationContext.validation = validationArray; - return validationContext; - } + validationContext.validation = validationArray; + return validationContext; + } - getPrincipalAppRoleValues(): Number[] { - let keys: string[] = Object.keys(Principal.AppRole); - keys = keys.slice(0, keys.length / 2); - const values: Number[] = keys.map(Number); - return values; - } + getPrincipalAppRoleValues(): Number[] { + let keys: string[] = Object.keys(Principal.AppRole); + keys = keys.slice(0, keys.length / 2); + const values: Number[] = keys.map(Number); + return values; + } - getPrincipalAppRoleWithLanguage(role: Principal.AppRole): string { - let result = ''; - this.language.get(this.utilities.convertFromPrincipalAppRole(role)).subscribe((value: string) => { - result = value; - }); - return result; - } + getPrincipalAppRoleWithLanguage(role: Principal.AppRole): string { + let result = ''; + this.language.get(this.utilities.convertFromPrincipalAppRole(role)).subscribe((value: string) => { + result = value; + }); + return result; + } } diff --git a/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.component.html b/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.component.html index 53af92904..1facf7b0f 100644 --- a/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.component.html +++ b/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.component.html @@ -1,25 +1,25 @@
-
-
-
- - - - {{ option.label }} - - - -
-
- - -
-
-
- - -
-
+
+
+
+ + + + {{ option.label }} + + + +
+
+ + +
+
+
+ + +
+
diff --git a/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.component.ts b/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.component.ts index 4c970f813..1f305ce82 100644 --- a/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.component.ts +++ b/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.component.ts @@ -1,7 +1,7 @@ -import { Component, OnInit, Input, ContentChild, TemplateRef, ViewChild, Output, EventEmitter } from "@angular/core"; -import { FormGroup, FormControl, FormArray, AbstractControl } from "@angular/forms"; -import { ExternalSourcesUrlModel } from "../../../../models/external-sources/ExternalSourcesUrlModel"; -import { AutoCompleteConfiguration } from "../../auto-complete/AutoCompleteConfiguration"; +import { Component, OnInit, Input, ContentChild, TemplateRef, ViewChild, Output, EventEmitter } from '@angular/core'; +import { FormGroup, FormControl, FormArray, AbstractControl } from '@angular/forms'; +import { ExternalSourcesUrlModel } from '../../../../models/external-sources/ExternalSourcesUrlModel'; +import { AutoCompleteConfiguration } from '../../auto-complete/AutoCompleteConfiguration'; @Component({ selector: 'app-external-item-listing', @@ -37,7 +37,7 @@ export class ExternalItemListingComponent implements OnInit { parentTemplate; @Input() - public options: Array + public options: Array; @Output() public onItemChange = new EventEmitter(); @@ -47,20 +47,20 @@ export class ExternalItemListingComponent implements OnInit { ngOnInit() { - if (this.disabled) this.formControl.disable(); + if (this.disabled) { this.formControl.disable(); } } onItemChangeFunc(event) { - if (event) this.onItemChange.emit(event); + if (event) { this.onItemChange.emit(event); } } selectionChange(event) { - if (this.formControl.disabled) this.formControl.enable(); - this.autoCompleteConfiguration.requestItem.criteria["type"] = event.value; + if (this.formControl.disabled) { this.formControl.enable(); } + this.autoCompleteConfiguration.requestItem.criteria['type'] = event.value; } deleteItem(name: number) { - (this.formGroup).removeAt(name) + (this.formGroup).removeAt(name); } } diff --git a/dmp-frontend/src/app/shared/components/external-items/external-item/external-item.component.html b/dmp-frontend/src/app/shared/components/external-items/external-item/external-item.component.html index 564a2d0bc..13cf4f779 100644 --- a/dmp-frontend/src/app/shared/components/external-items/external-item/external-item.component.html +++ b/dmp-frontend/src/app/shared/components/external-items/external-item/external-item.component.html @@ -1,4 +1,4 @@ + titleKey="titleKey" [formCtrl]="formCtrl" [_subtitleFn]="subtitleFunction" [displayFunction]="displayFunction" + [disabled]="disabled" (onItemChange)="this.onItemChangeFunc($event)" [clear]="true" [required]="false"> diff --git a/dmp-frontend/src/app/shared/components/external-items/external-item/external-item.component.ts b/dmp-frontend/src/app/shared/components/external-items/external-item/external-item.component.ts index 30b549e5e..c69ba080a 100644 --- a/dmp-frontend/src/app/shared/components/external-items/external-item/external-item.component.ts +++ b/dmp-frontend/src/app/shared/components/external-items/external-item/external-item.component.ts @@ -1,46 +1,46 @@ -import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; -import { Placeholder } from "@angular/compiler/src/i18n/i18n_ast"; -import { FormGroup, FormControl } from "@angular/forms"; -import { AutoCompleteConfiguration } from "../../auto-complete/AutoCompleteConfiguration"; +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { Placeholder } from '@angular/compiler/src/i18n/i18n_ast'; +import { FormGroup, FormControl } from '@angular/forms'; +import { AutoCompleteConfiguration } from '../../auto-complete/AutoCompleteConfiguration'; @Component({ - selector: 'app-external-item', - templateUrl: './external-item.component.html', - styleUrls: ['./external-item.component.scss'] + selector: 'app-external-item', + templateUrl: './external-item.component.html', + styleUrls: ['./external-item.component.scss'] }) export class ExternalItemComponent implements OnInit { - @Input() - public placeholder: string; + @Input() + public placeholder: string; - @Input() - public formGroup: FormGroup; + @Input() + public formGroup: FormGroup; - @Input() - public autoCompleteConfiguration: AutoCompleteConfiguration; + @Input() + public autoCompleteConfiguration: AutoCompleteConfiguration; - @Input() - public displayFunction: Function; + @Input() + public displayFunction: Function; - @Input() - public subtitleFunction: Function; + @Input() + public subtitleFunction: Function; - @Input() - public disabled = false; + @Input() + public disabled = false; - @Input() - public titleKey: string; + @Input() + public titleKey: string; - @Output() - public onItemChange = new EventEmitter(); + @Output() + public onItemChange = new EventEmitter(); - @Input() - public formCtrl: FormControl; + @Input() + public formCtrl: FormControl; - ngOnInit() { - } + ngOnInit() { + } - onItemChangeFunc(event) { - this.onItemChange.emit(event); - } + onItemChangeFunc(event) { + this.onItemChange.emit(event); + } } diff --git a/dmp-frontend/src/app/shared/components/facets/facet-search-component/facet-search-section.component.html b/dmp-frontend/src/app/shared/components/facets/facet-search-component/facet-search-section.component.html index 90e27f291..c99067eae 100644 --- a/dmp-frontend/src/app/shared/components/facets/facet-search-component/facet-search-section.component.html +++ b/dmp-frontend/src/app/shared/components/facets/facet-search-component/facet-search-section.component.html @@ -4,7 +4,8 @@ - {{ displayLabel(option) }} + {{ + displayLabel(option) }} cancel diff --git a/dmp-frontend/src/app/shared/components/figurecard/figurecard.component.html b/dmp-frontend/src/app/shared/components/figurecard/figurecard.component.html index fff8412fe..9106d0fea 100644 --- a/dmp-frontend/src/app/shared/components/figurecard/figurecard.component.html +++ b/dmp-frontend/src/app/shared/components/figurecard/figurecard.component.html @@ -1,12 +1,14 @@
-
- {{ headerIcon }} -
-
-

{{ category | translate }}

-

{{ title }}

- -
- +
+ {{ headerIcon }} +
+
+

{{ category | translate }}

+

{{ title }}

+ +
+
diff --git a/dmp-frontend/src/app/shared/components/file-uploader/FileUploader.ts b/dmp-frontend/src/app/shared/components/file-uploader/FileUploader.ts index 92547f4fa..e87e040ad 100644 --- a/dmp-frontend/src/app/shared/components/file-uploader/FileUploader.ts +++ b/dmp-frontend/src/app/shared/components/file-uploader/FileUploader.ts @@ -1,6 +1,6 @@ -import { Observable } from "rxjs"; -import { ContentFile } from "../../../models/files/ContentFile"; +import { Observable } from 'rxjs'; +import { ContentFile } from '../../../models/files/ContentFile'; export interface FileUploader { - uploadFile(formData: FormData): Observable; -} \ No newline at end of file + uploadFile(formData: FormData): Observable; +} diff --git a/dmp-frontend/src/app/shared/components/file-uploader/file-uploader.component.html b/dmp-frontend/src/app/shared/components/file-uploader/file-uploader.component.html index 5d9d21af0..7aa8c8ab3 100644 --- a/dmp-frontend/src/app/shared/components/file-uploader/file-uploader.component.html +++ b/dmp-frontend/src/app/shared/components/file-uploader/file-uploader.component.html @@ -1,11 +1,11 @@ - file_upload - {{ files['name'] }} - - attach_file - - {{label | translate}} - - + (upload)="uploadEvent($event)" (cancel)="cancelEvent()" accept=".jpg,.png" [disabled]="disabled" multiple> + file_upload + {{ files['name'] }} + + attach_file + + {{label | translate}} + + diff --git a/dmp-frontend/src/app/shared/components/file-uploader/file-uploader.component.ts b/dmp-frontend/src/app/shared/components/file-uploader/file-uploader.component.ts index 0619c446a..9ea0400bc 100644 --- a/dmp-frontend/src/app/shared/components/file-uploader/file-uploader.component.ts +++ b/dmp-frontend/src/app/shared/components/file-uploader/file-uploader.component.ts @@ -1,56 +1,56 @@ -import { Component, Input, OnInit } from "@angular/core"; -import { FileUploader } from "../../../shared/components/file-uploader/FileUploader"; -import { FormControl } from "@angular/forms"; +import { Component, Input, OnInit } from '@angular/core'; +import { FileUploader } from '../../../shared/components/file-uploader/FileUploader'; +import { FormControl } from '@angular/forms'; @Component({ - selector: 'app-fileuploader-component', - templateUrl: './file-uploader.component.html' + selector: 'app-fileuploader-component', + templateUrl: './file-uploader.component.html' }) export class FileUploaderComponent implements OnInit { - files: File | FileList; - disabled: boolean = false; + files: File | FileList; + disabled = false; - fileSelectMultipleMsg: string = 'No file(s) selected yet.'; + fileSelectMultipleMsg = 'No file(s) selected yet.'; - @Input() - public label: string = 'FILE-UPLOADER.DEFAULT'; + @Input() + public label = 'FILE-UPLOADER.DEFAULT'; - @Input() - public fileUploader: FileUploader; + @Input() + public fileUploader: FileUploader; - @Input() - form: FormControl; + @Input() + form: FormControl; - ngOnInit(): void { - } + ngOnInit(): void { + } - selectEvent(files: FileList | File): void { - this.label = 'FILE-UPLOADER.UPLOAD' - if (files instanceof FileList) { - let names: string[] = []; - for (let i: number = 0; i < files.length; i++) { - names.push(files[i].name); - } - this.fileSelectMultipleMsg = names.join(','); - } else { - this.fileSelectMultipleMsg = files.name; - } - } + selectEvent(files: FileList | File): void { + this.label = 'FILE-UPLOADER.UPLOAD'; + if (files instanceof FileList) { + const names: string[] = []; + for (let i = 0; i < files.length; i++) { + names.push(files[i].name); + } + this.fileSelectMultipleMsg = names.join(','); + } else { + this.fileSelectMultipleMsg = files.name; + } + } - uploadEvent(files: FileList | File): void { - let formdata: FormData = new FormData(); + uploadEvent(files: FileList | File): void { + const formdata: FormData = new FormData(); - if (files instanceof FileList) { - for (let i: number = 0; i < files.length; i++) { - formdata.append('file', files[i]); - } - } else { - formdata.append('file', files); - } - this.fileUploader.uploadFile(formdata).subscribe(files => this.form.patchValue(files)); - } + if (files instanceof FileList) { + for (let i = 0; i < files.length; i++) { + formdata.append('file', files[i]); + } + } else { + formdata.append('file', files); + } + this.fileUploader.uploadFile(formdata).subscribe(fileitem => this.form.patchValue(fileitem)); + } - cancelEvent(): void { - } + cancelEvent(): void { + } } diff --git a/dmp-frontend/src/app/shared/components/invitation-accepted/invitation-accepted.component.ts b/dmp-frontend/src/app/shared/components/invitation-accepted/invitation-accepted.component.ts index 3680c0f3d..d38aa8bd3 100644 --- a/dmp-frontend/src/app/shared/components/invitation-accepted/invitation-accepted.component.ts +++ b/dmp-frontend/src/app/shared/components/invitation-accepted/invitation-accepted.component.ts @@ -4,30 +4,29 @@ import { RequestItem } from '../../../models/criteria/RequestItem'; import { Invitation } from '../../../models/invitation/Invitation'; import { InvitationService } from '../../../services/invitation/invitation.service'; import { User } from '../../../models/invitation/User'; -import { Component, OnInit, Inject } from "@angular/core"; +import { Component, OnInit, Inject } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Params, ActivatedRoute, Router } from '@angular/router'; import { MAT_DIALOG_DATA } from '@angular/material'; @Component({ - selector: 'app-invitation-accepted-component', - templateUrl: 'invitation-accepted.component.html', + selector: 'app-invitation-accepted-component', + templateUrl: 'invitation-accepted.component.html', }) export class InvitationAcceptedComponent implements OnInit { - constructor( - private invitationService: InvitationService, - private route: ActivatedRoute, - public router: Router - ) { } + constructor( + private invitationService: InvitationService, + private route: ActivatedRoute, + public router: Router + ) { } - ngOnInit(): void { - this.route.params.subscribe(params => { - let id = params["id"] - this.invitationService.exchange(id).subscribe(id => { - this.router.navigate(["dmps/edit/" + id]) - }) - } - ) - } + ngOnInit(): void { + this.route.params.subscribe(params => { + const id = params['id']; + this.invitationService.exchange(id).subscribe(result => { + this.router.navigate(['dmps/edit/' + result]); + }); + }); + } } diff --git a/dmp-frontend/src/app/shared/components/invitation/invitation.component.html b/dmp-frontend/src/app/shared/components/invitation/invitation.component.html index eaa942967..10e752ae2 100644 --- a/dmp-frontend/src/app/shared/components/invitation/invitation.component.html +++ b/dmp-frontend/src/app/shared/components/invitation/invitation.component.html @@ -1,23 +1,24 @@
-

{{'INVITATION-EDITOR.TITLE' | translate}} {{data.dmpName}}

-
- - -
{{chip.name.substring(0, 1).toUpperCase()}}
- {{chip.name}} -
- -
- {{option.name}} -
-
- -
-
-
-
- -
-
-
\ No newline at end of file +

{{'INVITATION-EDITOR.TITLE' | translate}} {{data.dmpName}}

+
+ + +
{{chip.name.substring(0, 1).toUpperCase()}}
+ {{chip.name}} +
+ +
+ {{option.name}} +
+
+ +
+
+
+
+ +
+
+ diff --git a/dmp-frontend/src/app/shared/components/invitation/invitation.component.ts b/dmp-frontend/src/app/shared/components/invitation/invitation.component.ts index 35b743f67..bcd610440 100644 --- a/dmp-frontend/src/app/shared/components/invitation/invitation.component.ts +++ b/dmp-frontend/src/app/shared/components/invitation/invitation.component.ts @@ -4,7 +4,7 @@ import { RequestItem } from '../../../models/criteria/RequestItem'; import { Invitation } from '../../../models/invitation/Invitation'; import { InvitationService } from '../../../services/invitation/invitation.service'; import { User } from '../../../models/invitation/User'; -import { Component, OnInit, Inject } from "@angular/core"; +import { Component, OnInit, Inject } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Params, ActivatedRoute, Router } from '@angular/router'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; @@ -18,47 +18,47 @@ export class InvitationComponent implements OnInit { public formGroup: FormGroup; - public filteredUsersAsync: boolean = false; + public filteredUsersAsync = false; public filteredUsers: User[]; constructor( - public invitationService: InvitationService, - public route: ActivatedRoute, - public router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any + public invitationService: InvitationService, + public route: ActivatedRoute, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any ) { } ngOnInit(): void { - let invitation = new Invitation(); - invitation.dataManagementPlan = this.data.dmpId; - this.formGroup = invitation.buildForm(); + const invitation = new Invitation(); + invitation.dataManagementPlan = this.data.dmpId; + this.formGroup = invitation.buildForm(); } send(value: any) { - this.invitationService.inviteUsers(this.formGroup.value).subscribe( - null, null, () => this.dialogRef.close() - ); + this.invitationService.inviteUsers(this.formGroup.value).subscribe( + null, null, () => this.dialogRef.close() + ); } filterUsers(value: string): void { - this.filteredUsers = undefined; - if (value) { - this.filteredUsersAsync = true; - let request = new RequestItem(); - request.criteria = { like: value } - this.invitationService.getUsers(request).subscribe(items => { - this.filteredUsers = JsonSerializer.fromJSONArray(items, User); - if (!this.filteredUsers || this.filteredUsers.length == 0) { - let user = new User(); - user.email = value; - user.name = value; - this.filteredUsers.push(user) - } - this.filteredUsersAsync = false; - }); - } + this.filteredUsers = undefined; + if (value) { + this.filteredUsersAsync = true; + const request = new RequestItem(); + request.criteria = { like: value }; + this.invitationService.getUsers(request).subscribe(items => { + this.filteredUsers = JsonSerializer.fromJSONArray(items, User); + if (!this.filteredUsers || this.filteredUsers.length === 0) { + const user = new User(); + user.email = value; + user.name = value; + this.filteredUsers.push(user); + } + this.filteredUsersAsync = false; + }); + } } } diff --git a/dmp-frontend/src/app/shared/components/navigation/navigation.component.html b/dmp-frontend/src/app/shared/components/navigation/navigation.component.html index 9915b4b18..9e65ca99b 100644 --- a/dmp-frontend/src/app/shared/components/navigation/navigation.component.html +++ b/dmp-frontend/src/app/shared/components/navigation/navigation.component.html @@ -1,54 +1,56 @@ - - -
- -
- + + +
+ +
+ - -
- - - - - {{option.label}} -
- {{transformType(option.type)}} -
-
-
-
-
-
- -
+ +
+ + + + + {{option.label}} +
+ {{transformType(option.type)}} +
+
+
+
+
+
+ +
-
- -
-
- -
-
+
+ +
+
+ +
+
- - - + + +
diff --git a/dmp-frontend/src/app/shared/components/navigation/navigation.component.ts b/dmp-frontend/src/app/shared/components/navigation/navigation.component.ts index 3545529ce..306e38180 100644 --- a/dmp-frontend/src/app/shared/components/navigation/navigation.component.ts +++ b/dmp-frontend/src/app/shared/components/navigation/navigation.component.ts @@ -1,5 +1,5 @@ import { sample } from 'rxjs/operators'; -import { Component, EventEmitter, Input, Output, ElementRef } from '@angular/core'; +import { Component, EventEmitter, Input, Output, ElementRef, OnInit } from '@angular/core'; import { Principal } from '../../../models/login/Principal'; import { AuthService } from '../../../services/auth/auth.service'; import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service'; @@ -17,116 +17,115 @@ import { SearchBarType } from '../search-bar/types/search-bar-type'; import { Router } from '@angular/router'; @Component({ - selector: 'app-navigation', - templateUrl: 'navigation.component.html', - styleUrls: ['./navigation.component.scss'], - providers: [ProjectService] + selector: 'app-navigation', + templateUrl: 'navigation.component.html', + styleUrls: ['./navigation.component.scss'], + providers: [ProjectService] }) -export class NavigationComponent { - invert = false; - public search = false; - projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - public searchControl = new FormControl(); - filteredOptions: Observable; +export class NavigationComponent implements OnInit { + invert = false; + public search = false; + projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; + public searchControl = new FormControl(); + filteredOptions: Observable; + @Input() + sideNav: MatSidenav; - constructor( - private authentication: AuthService, - private languageResolver: LanguageResolverService, - public dialog: MatDialog, - private projectService: ProjectService, - private dashBoardService: DashboardService, - private router: Router, + @Output() + sidenavOpenChanges = new EventEmitter(); - ) { + events: string[] = []; + opened: boolean; + constructor( + private authentication: AuthService, + private languageResolver: LanguageResolverService, + public dialog: MatDialog, + private projectService: ProjectService, + private dashBoardService: DashboardService, + private router: Router, - } + ) { - ngOnInit() { - this.projectAutoCompleteConfiguration = { - filterFn: this.searchProject.bind(this), - items: this.searchProject(''), - displayFn: (item) => item["label"], - titleFn: (item) => item["label"], - //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), - loadDataOnStart: true - }; + } - this.filteredOptions = this.searchControl.valueChanges.debounceTime(500).distinctUntilChanged().flatMap(x => { - return this.dashBoardService.searchUserItems(x); - }) - } + // tslint:disable-next-line:use-life-cycle-interface + ngOnInit() { + this.projectAutoCompleteConfiguration = { + filterFn: this.searchProject.bind(this), + items: this.searchProject(''), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'], + //mapFn: (item) => new JsonSerializer().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()), + loadDataOnStart: true + }; - searchProject(query: string) { - let projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new ProjectCriteria(); - projectRequestItem.criteria.like = query; - return this.projectService.getWithExternal(projectRequestItem); - } + this.filteredOptions = this.searchControl.valueChanges.debounceTime(500).distinctUntilChanged().flatMap(x => { + return this.dashBoardService.searchUserItems(x); + }); + } - public logout(): void { - this.authentication.logout(); - } + searchProject(query: string) { + const projectRequestItem: RequestItem = new RequestItem(); + projectRequestItem.criteria = new ProjectCriteria(); + projectRequestItem.criteria.like = query; + return this.projectService.getWithExternal(projectRequestItem); + } - public isAuthenticated(): boolean { - return !(!this.authentication.current()) - } + public logout(): void { + this.authentication.logout(); + } - @Input() - sideNav: MatSidenav; + public isAuthenticated(): boolean { + return !(!this.authentication.current()); + } - @Output() - sidenavOpenChanges = new EventEmitter(); + public isAdmin(): boolean { + if (!this.authentication.current()) { return false; } + const principalRoles = this.authentication.current().appRoles; + for (let i = 0; i < principalRoles.length; i++) { + if (principalRoles[i] === Principal.AppRole.Admin) { + return true; + } + } + return false; + } - events: string[] = []; - opened: boolean; + public principalHasAvatar(): boolean { + return this.authentication.current().avatarUrl != null; + } - public isAdmin(): boolean { - if (!this.authentication.current()) { return false } - const principalRoles = this.authentication.current().appRoles; - for (let i = 0; i < principalRoles.length; i++) { - if (principalRoles[i] === Principal.AppRole.Admin) { - return true; - } - } - return false; - } + public getPrincipalAvatar(): string { + return this.authentication.current().avatarUrl; + } - public principalHasAvatar(): boolean { - return this.authentication.current().avatarUrl != null; - } + onSideNavClick() { + this.sideNav.toggle(); + } - public getPrincipalAvatar(): string { - return this.authentication.current().avatarUrl; - } + openProfile() { + const dialogRef = this.dialog.open(UserDialogComponent, { + hasBackdrop: true, + closeOnNavigation: true, + disableClose: false, + position: { top: '64px', left: '85%' } + }); + } - onSideNavClick() { - this.sideNav.toggle(); - } + onOptionSelected(event: any) { + this.search = false; + this.searchControl.patchValue(null); + const selectedSearchBarItem = event.option.value; + if (selectedSearchBarItem.type === SearchBarType.DATASET) { this.router.navigate(['datasets/edit/' + selectedSearchBarItem.id]); } + if (selectedSearchBarItem.type === SearchBarType.PROJECT) { this.router.navigate(['projects/edit/' + selectedSearchBarItem.id]); } + if (selectedSearchBarItem.type === SearchBarType.DATAMANAGEMENTPLAN) { this.router.navigate(['dmps/edit/' + selectedSearchBarItem.id]); } + } - openProfile() { - let dialogRef = this.dialog.open(UserDialogComponent, { - hasBackdrop: true, - closeOnNavigation: true, - disableClose: false, - position: { top: "64px", left: "85%" } - }); - } - - onOptionSelected(event: any) { - this.search = false; - this.searchControl.patchValue(null); - let selectedSearchBarItem = event.option.value; - if (selectedSearchBarItem.type == SearchBarType.DATASET) this.router.navigate(["datasets/edit/" + selectedSearchBarItem.id]) - if (selectedSearchBarItem.type == SearchBarType.PROJECT) this.router.navigate(["projects/edit/" + selectedSearchBarItem.id]) - if (selectedSearchBarItem.type == SearchBarType.DATAMANAGEMENTPLAN) this.router.navigate(["dmps/edit/" + selectedSearchBarItem.id]) - } - - transformType(type) { - switch(type){ - case SearchBarItemType.DATASET: return "Dataset" - case SearchBarItemType.DMP: return "DMP" - case SearchBarItemType.PROJECT: return "Project" - } - } + transformType(type) { + switch (type) { + case SearchBarItemType.DATASET: return 'Dataset'; + case SearchBarItemType.DMP: return 'DMP'; + case SearchBarItemType.PROJECT: return 'Project'; + } + } } diff --git a/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.html b/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.html index bd62cd6d1..75af56131 100644 --- a/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.html +++ b/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.html @@ -1 +1 @@ -{{message}} \ No newline at end of file +{{message}} diff --git a/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.ts b/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.ts index ac75c814b..b1be87392 100644 --- a/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.ts +++ b/dmp-frontend/src/app/shared/components/notificaiton/snack-bar-notification.component.ts @@ -2,20 +2,21 @@ import { TranslateService } from '@ngx-translate/core'; import { Component, Inject } from '@angular/core'; import { MAT_SNACK_BAR_DATA } from '@angular/material'; @Component({ - selector: 'snack-bar-notification', - templateUrl: 'snack-bar-notification.component.html' + selector: 'app-snack-bar-notification', + templateUrl: 'snack-bar-notification.component.html' }) export class SnackBarNotificationComponent { - message: string; - constructor( @Inject(MAT_SNACK_BAR_DATA) public data: any) { - this.parseMessage(data.message, data.language); - } + message: string; + constructor(@Inject(MAT_SNACK_BAR_DATA) public data: any) { + this.parseMessage(data.message, data.language); + } - parseMessage(message: any, language: TranslateService): void { - if(language) language.get(message).subscribe((value: string) => { - this.message = value; - }); - else this.message = message; - } + parseMessage(message: any, language: TranslateService): void { + if (language) { + language.get(message).subscribe((value: string) => { + this.message = value; + }); + } else { this.message = message; } + } } diff --git a/dmp-frontend/src/app/shared/components/search-bar/search-bar.component.ts b/dmp-frontend/src/app/shared/components/search-bar/search-bar.component.ts index dfeb80784..349394bf5 100644 --- a/dmp-frontend/src/app/shared/components/search-bar/search-bar.component.ts +++ b/dmp-frontend/src/app/shared/components/search-bar/search-bar.component.ts @@ -7,9 +7,9 @@ import { MatSidenav, MatDialog } from '@angular/material'; import { UserDialogComponent } from '../user-dialog/user-dialog.component'; @Component({ - selector: 'app-search', - templateUrl: 'search-bar.component.html', - styleUrls: ['./search-bar.component.scss'], + selector: 'app-search', + templateUrl: 'search-bar.component.html', + styleUrls: ['./search-bar.component.scss'], }) export class SearchBarComponent { diff --git a/dmp-frontend/src/app/shared/components/search-bar/types/search-bar-type.ts b/dmp-frontend/src/app/shared/components/search-bar/types/search-bar-type.ts index 5e36abd7c..0bf6b0d47 100644 --- a/dmp-frontend/src/app/shared/components/search-bar/types/search-bar-type.ts +++ b/dmp-frontend/src/app/shared/components/search-bar/types/search-bar-type.ts @@ -1,5 +1,5 @@ export enum SearchBarType { - DATASET = 0, - DATAMANAGEMENTPLAN = 1, - PROJECT = 2 + DATASET = 0, + DATAMANAGEMENTPLAN = 1, + PROJECT = 2 } diff --git a/dmp-frontend/src/app/shared/components/url-listing/UrlListingItem.ts b/dmp-frontend/src/app/shared/components/url-listing/UrlListingItem.ts index 40d5d047f..08f10bdb1 100644 --- a/dmp-frontend/src/app/shared/components/url-listing/UrlListingItem.ts +++ b/dmp-frontend/src/app/shared/components/url-listing/UrlListingItem.ts @@ -1,14 +1,14 @@ -import { Serializable } from "../../../models/Serializable"; +import { Serializable } from '../../../models/Serializable'; -export class UrlListingItem implements Serializable{ +export class UrlListingItem implements Serializable { - public label: string; - public url: string; - public all: string; + public label: string; + public url: string; + public all: string; - fromJSONObject(item: any): UrlListingItem { - this.label = item.label; - this.url = item.url; - return this; - } -} \ No newline at end of file + fromJSONObject(item: any): UrlListingItem { + this.label = item.label; + this.url = item.url; + return this; + } +} diff --git a/dmp-frontend/src/app/shared/components/url-listing/url-listing.component.html b/dmp-frontend/src/app/shared/components/url-listing/url-listing.component.html index 0ae5f8fc3..64c9e8dee 100644 --- a/dmp-frontend/src/app/shared/components/url-listing/url-listing.component.html +++ b/dmp-frontend/src/app/shared/components/url-listing/url-listing.component.html @@ -1,4 +1,4 @@ -{{'URL-LISTING-COMPONENT.SHOW-MORE'|translate}} \ No newline at end of file +{{'URL-LISTING-COMPONENT.SHOW-MORE'|translate}} diff --git a/dmp-frontend/src/app/shared/components/user-dialog/user-dialog.component.html b/dmp-frontend/src/app/shared/components/user-dialog/user-dialog.component.html index 56071b61e..41ca13e18 100644 --- a/dmp-frontend/src/app/shared/components/user-dialog/user-dialog.component.html +++ b/dmp-frontend/src/app/shared/components/user-dialog/user-dialog.component.html @@ -1,24 +1,24 @@
-
- - {{this.getPrincipalName()}} -
+
+ + {{this.getPrincipalName()}} +
-
- - {{'USER-DIALOG.USER-PROFILE' | translate}} - - +
+ + {{'USER-DIALOG.USER-PROFILE' | translate}} + + -
-
-
- {{'USER-DIALOG.EXIT' | translate}} - -
-
+
+
+
+ {{'USER-DIALOG.EXIT' | translate}} + +
+
diff --git a/dmp-frontend/src/app/shared/components/user-dialog/user-dialog.component.ts b/dmp-frontend/src/app/shared/components/user-dialog/user-dialog.component.ts index 9a59a921b..e0096b2c4 100644 --- a/dmp-frontend/src/app/shared/components/user-dialog/user-dialog.component.ts +++ b/dmp-frontend/src/app/shared/components/user-dialog/user-dialog.component.ts @@ -1,6 +1,6 @@ import { JsonSerializer } from '../../../utilities/JsonSerializer'; import { RequestItem } from '../../../models/criteria/RequestItem'; -import { Component, OnInit, Inject } from "@angular/core"; +import { Component, OnInit, Inject } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Params, ActivatedRoute, Router } from '@angular/router'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; @@ -10,46 +10,46 @@ import { AuthService } from '../../../services/auth/auth.service'; import { Principal } from '../../../models/login/Principal'; @Component({ - selector: 'user-dialog-component', - templateUrl: 'user-dialog.component.html', + selector: 'app-user-dialog-component', + templateUrl: 'user-dialog.component.html', }) export class UserDialogComponent implements OnInit { - public formGroup: FormGroup; + public formGroup: FormGroup; - constructor( - private route: ActivatedRoute, - private authentication: AuthService, - public router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } + constructor( + private route: ActivatedRoute, + private authentication: AuthService, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } - ngOnInit(): void { - } + ngOnInit(): void { + } - public logout(): void { - this.dialogRef.close(); - this.authentication.logout(); - } + public logout(): void { + this.dialogRef.close(); + this.authentication.logout(); + } - public getPrincipalName(): string { - const principal: Principal = this.authentication.current(); - if (principal) { return principal.name; } - return ''; - } + public getPrincipalName(): string { + const principal: Principal = this.authentication.current(); + if (principal) { return principal.name; } + return ''; + } - public principalHasAvatar(): boolean { - return this.authentication.current() && this.authentication.current().avatarUrl != null; - } + public principalHasAvatar(): boolean { + return this.authentication.current() && this.authentication.current().avatarUrl != null; + } - public getPrincipalAvatar(): string { - return this.authentication.current() && this.authentication.current().avatarUrl; - } + public getPrincipalAvatar(): string { + return this.authentication.current() && this.authentication.current().avatarUrl; + } - public navigateToProfile() { - this.dialogRef.close(); - this.router.navigate(["/users/" + this.authentication.current().id]); - } + public navigateToProfile() { + this.dialogRef.close(); + this.router.navigate(['/users/' + this.authentication.current().id]); + } } diff --git a/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.html b/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.html index a332a0b7e..c27e1329a 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.html +++ b/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.html @@ -1,34 +1,34 @@
Autocomplete Description
-
-
- - - -
-
-
-
- - - -
-
- - - -
-
-
-
- - - -
-
- - - -
-
-
+
+
+ + + +
+
+
+
+ + + +
+
+ + + +
+
+
+
+ + + +
+
+ + + +
+
+ diff --git a/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.ts index 4a1bd6e56..0ebd0f609 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.ts +++ b/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.ts @@ -6,24 +6,24 @@ import { Field } from '../../../models/datasetProfileAdmin/Field'; import { JsonSerializer } from '../../../utilities/JsonSerializer'; @Component({ - selector: 'autocomplete-component', - styleUrls: ["./autocomplete-component.scss"], - templateUrl: './autocomplete-component.html' + selector: 'app-autocomplete-component', + styleUrls: ['./autocomplete-component.scss'], + templateUrl: './autocomplete-component.html' }) export class AutocompleteComponent implements OnInit { - @Input() dataModel: Field; - @Input() form: FormGroup; - private data: AutocompleteData = new AutocompleteData(); + @Input() dataModel: Field; + @Input() form: FormGroup; + private data: AutocompleteData = new AutocompleteData(); - ngOnInit() { - this.data.type = "autocomplete"; - if (!this.form.get("data") || !this.form.get("data").get("autoCompleteOptions")) { - let autocomplete: AutocompleteData = new AutocompleteData(); - this.dataModel.data = JsonSerializer.fromJSONObject(this.data, AutocompleteData); - this.form.removeControl("data"); - this.form.addControl("data", autocomplete.buildForm()); - } else { - this.form.addControl("data", this.data.buildForm()); - } - } + ngOnInit() { + this.data.type = 'autocomplete'; + if (!this.form.get('data') || !this.form.get('data').get('autoCompleteOptions')) { + const autocomplete: AutocompleteData = new AutocompleteData(); + this.dataModel.data = JsonSerializer.fromJSONObject(this.data, AutocompleteData); + this.form.removeControl('data'); + this.form.addControl('data', autocomplete.buildForm()); + } else { + this.form.addControl('data', this.data.buildForm()); + } + } } diff --git a/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.html b/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.html index 474af493f..63bd2225c 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.html +++ b/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.html @@ -1,10 +1,10 @@
Boolean Decision Description
-
-
- - - -
-
+
+
+ + + +
+
diff --git a/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.ts index 046b87ddd..f1f2afb98 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.ts +++ b/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.ts @@ -6,16 +6,16 @@ import { FormArray } from '@angular/forms'; import { Field } from '../../../models/datasetProfileAdmin/Field'; @Component({ - selector: 'booleanDecision-component', - styleUrls: ["./booleanDecision-component.scss"], - templateUrl: './booleanDecision-component.html' + selector: 'app-boolean-decision-component', + styleUrls: ['./booleanDecision-component.scss'], + templateUrl: './booleanDecision-component.html' }) export class BooleanDecisionComponent implements OnInit { - @Input() dataModel: Field; - @Input() form: FormGroup; - private data: BooleanDecisionData = new BooleanDecisionData(); + @Input() dataModel: Field; + @Input() form: FormGroup; + private data: BooleanDecisionData = new BooleanDecisionData(); - ngOnInit() { - this.form.addControl("data", this.data.buildForm()); - } + ngOnInit() { + this.form.addControl('data', this.data.buildForm()); + } } diff --git a/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.html b/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.html index cfaef15d1..9819a0be1 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.html +++ b/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.html @@ -1,11 +1,11 @@
Checkbox Description
-
-
- - - -
-
+
+
+ + + +
+
diff --git a/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.ts index 13e83a530..141550e5d 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.ts +++ b/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.ts @@ -6,16 +6,16 @@ import { FormArray } from '@angular/forms'; import { Field } from '../../../models/datasetProfileAdmin/Field'; @Component({ - selector: 'checkbox-component', - styleUrls: ["./checkbox-component.scss"], - templateUrl: './checkbox-component.html' + selector: 'app-checkbox-component', + styleUrls: ['./checkbox-component.scss'], + templateUrl: './checkbox-component.html' }) export class CheckBoxComponent implements OnInit { - @Input() dataModel: Field; - @Input() form: FormGroup; - private data: CheckBoxData = new CheckBoxData(); + @Input() dataModel: Field; + @Input() form: FormGroup; + private data: CheckBoxData = new CheckBoxData(); - ngOnInit() { - this.form.addControl("data", this.data.buildForm()); - } + ngOnInit() { + this.form.addControl('data', this.data.buildForm()); + } } diff --git a/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.html b/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.html index 15ca02636..0cafdeda3 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.html +++ b/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.html @@ -1,17 +1,17 @@
-
- - - {{option.value}} - - -
+
+ + + {{option.value}} + + +
-
- -
-
- -
+
+ +
+
+ +
diff --git a/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.ts index 400bf8137..d1c6b5446 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.ts +++ b/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.ts @@ -3,24 +3,24 @@ import { Component, Input, OnInit } from '@angular/core'; import { Field } from '../../../models/datasetProfileAdmin/Field'; @Component({ - selector: 'combobox-component', - styleUrls: ["./combobox-component.scss"], - templateUrl: './combobox-component.html' + selector: 'app-combobox-component', + styleUrls: ['./combobox-component.scss'], + templateUrl: './combobox-component.html' }) export class ComboboxComponent implements OnInit { - @Input() dataModel: Field; - @Input() form: FormGroup; - type: string; - options = [{ id: "autocomplete", value: "autocomplete" }, { id: "wordlist", value: "wordlist" }]; + @Input() dataModel: Field; + @Input() form: FormGroup; + type: string; + options = [{ id: 'autocomplete', value: 'autocomplete' }, { id: 'wordlist', value: 'wordlist' }]; - ngOnInit() { - if (this.dataModel.data && this.form.get("data")) { - if (this.form.get("data").get("type")) this.type = this.form.get("data").get("type").value; - } + ngOnInit() { + if (this.dataModel.data && this.form.get('data')) { + if (this.form.get('data').get('type')) { this.type = this.form.get('data').get('type').value; } + } - } + } - onchangeCombo() { - if (this.form.get("data")) this.form.removeControl("data"); - } + onchangeCombo() { + if (this.form.get('data')) { this.form.removeControl('data'); } + } } diff --git a/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.html b/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.html index dad524573..be1c67e6c 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.html +++ b/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.html @@ -1,10 +1,10 @@
FreeText Description
-
-
- - - -
-
+
+
+ + + +
+
diff --git a/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.ts index 952e6e760..7fb64a252 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.ts +++ b/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.ts @@ -7,16 +7,16 @@ import { FormArray } from '@angular/forms'; import { Field } from '../../../models/datasetProfileAdmin/Field'; @Component({ - selector: 'freetext-component', - styleUrls: ["./freetext-component.scss"], - templateUrl: './freetext-component.html' + selector: 'app-freetext-component', + styleUrls: ['./freetext-component.scss'], + templateUrl: './freetext-component.html' }) export class FreeTextComponent implements OnInit { - @Input() dataModel: Field; - @Input() form: FormGroup; - private data: FreeTextData = new FreeTextData(); + @Input() dataModel: Field; + @Input() form: FormGroup; + private data: FreeTextData = new FreeTextData(); - ngOnInit() { - this.form.addControl("data", this.data.buildForm()); - } + ngOnInit() { + this.form.addControl('data', this.data.buildForm()); + } } diff --git a/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.html b/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.html index 43148d2c4..c69e24deb 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.html +++ b/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.html @@ -1,34 +1,34 @@
Radio Box Description
-
-
- - - -
-
-
-
-
-
-
- - - -
-
- - - -
-
-
-
-
-
- -
+
+
+ + + +
+
+
+
+
+
+
+ + + +
+
+ + + +
+
+
+
+
+
+ +
diff --git a/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.ts index d05abdb5c..0407d7154 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.ts +++ b/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.ts @@ -7,29 +7,30 @@ import { JsonSerializer } from '../../../utilities/JsonSerializer'; import { Field } from '../../../models/datasetProfileAdmin/Field'; @Component({ - selector: 'radiobox-component', - styleUrls: ["./radiobox-component.scss"], - templateUrl: './radiobox-component.html' + selector: 'app-radiobox-component', + styleUrls: ['./radiobox-component.scss'], + templateUrl: './radiobox-component.html' }) export class RadioBoxComponent implements OnInit { - @Input() dataModel: Field; - @Input() form: FormGroup; - private data: RadioBoxData = new RadioBoxData(); - private options = new Array(); + @Input() dataModel: Field; + @Input() form: FormGroup; + private data: RadioBoxData = new RadioBoxData(); + private options = new Array(); - ngOnInit() { - //if (this.form.get("data")) this.form.removeControl("data"); - if (!this.form.get("data")) - this.form.addControl("data", this.data.buildForm()); - if (!this.dataModel.data || !this.dataModel.data['options']) this.addNewRow(); - } + ngOnInit() { + //if (this.form.get("data")) this.form.removeControl("data"); + if (!this.form.get('data')) { + this.form.addControl('data', this.data.buildForm()); + } + if (!this.dataModel.data || !this.dataModel.data['options']) { this.addNewRow(); } + } - addNewRow() { - let radioListOptions: ListingItem = new ListingItem(); - if (!this.form.get("data").get("options")) (this.form.get('data')).addControl("options", new FormBuilder().array([])); - (this.form.get("data").get("options")).push(radioListOptions.buildForm()); - this.data.options = []; - this.data.options.push(radioListOptions); - this.dataModel.data = JsonSerializer.fromJSONObject(this.data, RadioBoxData); - } + addNewRow() { + const radioListOptions: ListingItem = new ListingItem(); + if (!this.form.get('data').get('options')) { (this.form.get('data')).addControl('options', new FormBuilder().array([])); } + (this.form.get('data').get('options')).push(radioListOptions.buildForm()); + this.data.options = []; + this.data.options.push(radioListOptions); + this.dataModel.data = JsonSerializer.fromJSONObject(this.data, RadioBoxData); + } } diff --git a/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.html b/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.html index aac3d10bb..632dcea4e 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.html +++ b/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.html @@ -1,11 +1,11 @@
TextArea Description
-
-
- - - -
-
+
+
+ + + +
+
diff --git a/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.ts index e2de5ff38..d99c720d5 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.ts +++ b/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.ts @@ -8,16 +8,16 @@ import { FormArray } from '@angular/forms'; import { Field } from '../../../models/datasetProfileAdmin/Field'; @Component({ - selector: 'textarea-component', - styleUrls: ["./textarea-component.scss"], - templateUrl: './textarea-component.html' + selector: 'app-textarea-component', + styleUrls: ['./textarea-component.scss'], + templateUrl: './textarea-component.html' }) export class TextAreaComponent implements OnInit { - @Input() dataModel: Field; - @Input() form: FormGroup; - private data: TextArea = new TextArea(); + @Input() dataModel: Field; + @Input() form: FormGroup; + private data: TextArea = new TextArea(); - ngOnInit() { - this.form.addControl("data", this.data.buildForm()); - } + ngOnInit() { + this.form.addControl('data', this.data.buildForm()); + } } diff --git a/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.html b/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.html index cdf08bf32..2cb397936 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.html +++ b/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.html @@ -1,35 +1,35 @@
Word List Description
-
-
-
- - - -
-
-
-
-
-
- - - -
-
- - - -
-
-
-
-
-
- -
+
+
+
+ + + +
+
+
+
+
+
+ + + +
+
+ + + +
+
+
+
+
+
+ +
diff --git a/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.ts index bee45bb90..06ad1aaff 100644 --- a/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.ts +++ b/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.ts @@ -7,29 +7,30 @@ import { JsonSerializer } from '../../../utilities/JsonSerializer'; import { Field } from '../../../models/datasetProfileAdmin/Field'; @Component({ - selector: 'wordlist-component', - styleUrls: ["./wordlist-component.scss"], - templateUrl: './wordlist-component.html' + selector: 'app-wordlist-component', + styleUrls: ['./wordlist-component.scss'], + templateUrl: './wordlist-component.html' }) export class WordlistComponent implements OnInit { - @Input() dataModel: Field; - @Input() form: FormGroup; - private data: WordListData = new WordListData(); - private options = new Array(); + @Input() dataModel: Field; + @Input() form: FormGroup; + private data: WordListData = new WordListData(); + private options = new Array(); - ngOnInit() { - this.data.type = "wordlist"; - // if (this.form.get("data")) this.form.removeControl("data"); - this.form.addControl("data", this.data.buildForm()); - if (!this.dataModel.data) - this.addNewRow(); - } + ngOnInit() { + this.data.type = 'wordlist'; + // if (this.form.get("data")) this.form.removeControl("data"); + this.form.addControl('data', this.data.buildForm()); + if (!this.dataModel.data) { + this.addNewRow(); + } + } - addNewRow() { - let wordListOptions: ListingItem = new ListingItem(); - (this.form.get("data").get("options")).push(wordListOptions.buildForm()); - this.data.options = []; - this.data.options.push(wordListOptions); - this.dataModel.data = JsonSerializer.fromJSONObject(this.data, WordListData); - } + addNewRow() { + const wordListOptions: ListingItem = new ListingItem(); + (this.form.get('data').get('options')).push(wordListOptions.buildForm()); + this.data.options = []; + this.data.options.push(wordListOptions); + this.dataModel.data = JsonSerializer.fromJSONObject(this.data, WordListData); + } } diff --git a/dmp-frontend/src/app/shared/guards/auth.guard.ts b/dmp-frontend/src/app/shared/guards/auth.guard.ts index 1988fd26e..653128626 100644 --- a/dmp-frontend/src/app/shared/guards/auth.guard.ts +++ b/dmp-frontend/src/app/shared/guards/auth.guard.ts @@ -5,14 +5,14 @@ import { AuthService } from '../../services/auth/auth.service'; @Injectable() export class AuthGuard implements CanActivate { - constructor(private auth: AuthService, private router: Router) { - } - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - let url: string = state.url; - if (!this.auth.current()) { - this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: url } }); - return false; - } - return true; - } + constructor(private auth: AuthService, private router: Router) { + } + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { + const url: string = state.url; + if (!this.auth.current()) { + this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: url } }); + return false; + } + return true; + } } diff --git a/dmp-frontend/src/app/shared/help-content/help-content.component.ts b/dmp-frontend/src/app/shared/help-content/help-content.component.ts index a3f91373d..9de3082f5 100644 --- a/dmp-frontend/src/app/shared/help-content/help-content.component.ts +++ b/dmp-frontend/src/app/shared/help-content/help-content.component.ts @@ -2,12 +2,12 @@ * Created by stefania on 7/17/17. */ import { Component, OnInit, Input } from '@angular/core'; -import { ActivatedRoute, Router, NavigationStart } from "@angular/router"; +import { ActivatedRoute, Router, NavigationStart } from '@angular/router'; import { PageHelpContent } from '../../models/help-content/page-help-content'; import { HelpContentService } from '../../services/help-content/help-content.service'; @Component({ - selector: 'help-content', - template: ` + selector: 'app-help-content', + template: `
@@ -16,37 +16,36 @@ import { HelpContentService } from '../../services/help-content/help-content.ser `, }) export class HelpContentComponent implements OnInit { - @Input('position') - position: string; - contents: any[]; - errorMessage: string = null; - constructor(private _helpContentService: HelpContentService, private route: ActivatedRoute, private router: Router) { - } - ngOnInit() { - this.errorMessage = null; - this.router.events.subscribe(event => { - if (event instanceof NavigationStart) { - this._helpContentService.getActivePageContent(event["url"]).subscribe( - pageContent => this.shiftThroughContent(pageContent), - error => this.handleError(error)) - } - }) - } - shiftThroughContent(pageContent: PageHelpContent) { - this.contents = pageContent.content[this.position]; - } - isPresent() { - return (this.contents && this.contents.length > 0); - } - handleError(error) { - this.contents = [] - this.errorMessage = 'System error retrieving page content (Server responded: ' + error + ')'; - } + @Input() position: string; + contents: any[]; + errorMessage: string = null; + constructor(private _helpContentService: HelpContentService, private route: ActivatedRoute, private router: Router) { + } + ngOnInit() { + this.errorMessage = null; + this.router.events.subscribe(event => { + if (event instanceof NavigationStart) { + this._helpContentService.getActivePageContent(event['url']).subscribe( + pageContent => this.shiftThroughContent(pageContent), + error => this.handleError(error)); + } + }); + } + shiftThroughContent(pageContent: PageHelpContent) { + this.contents = pageContent.content[this.position]; + } + isPresent() { + return (this.contents && this.contents.length > 0); + } + handleError(error) { + this.contents = []; + this.errorMessage = 'System error retrieving page content (Server responded: ' + error + ')'; + } } @Component({ - selector: 'aside-help-content', - template: ` + selector: 'app-aside-help-content', + template: `
diff --git a/dmp-frontend/src/app/shared/material/material.module.ts b/dmp-frontend/src/app/shared/material/material.module.ts index 4f067a2be..57f8e3ab7 100644 --- a/dmp-frontend/src/app/shared/material/material.module.ts +++ b/dmp-frontend/src/app/shared/material/material.module.ts @@ -1,37 +1,37 @@ import { NgModule, LOCALE_ID } from '@angular/core'; import { - MatToolbarModule, - MatIconModule, - MatSidenavModule, - MatButtonModule, - MatTableModule, - MatPaginatorModule, - MatSortModule, - MatDialogModule, - MatDatepickerModule, - MatNativeDateModule, - MatInputModule, - MatFormFieldModule, - MatSnackBarModule, - MatAutocompleteModule, - MatExpansionModule, - MatSelectModule, - MatOptionModule, - MatCardModule, - MatProgressBarModule, - MatProgressSpinnerModule, - DateAdapter, - MatTooltipModule, - MatCheckboxModule, - MatTabsModule, - MatStepperModule, - MatRadioModule, - MatMenuModule, - MatListModule, - MatChipsModule, - MatBadgeModule, - MAT_DATE_LOCALE, - MAT_DATE_FORMATS + MatToolbarModule, + MatIconModule, + MatSidenavModule, + MatButtonModule, + MatTableModule, + MatPaginatorModule, + MatSortModule, + MatDialogModule, + MatDatepickerModule, + MatNativeDateModule, + MatInputModule, + MatFormFieldModule, + MatSnackBarModule, + MatAutocompleteModule, + MatExpansionModule, + MatSelectModule, + MatOptionModule, + MatCardModule, + MatProgressBarModule, + MatProgressSpinnerModule, + DateAdapter, + MatTooltipModule, + MatCheckboxModule, + MatTabsModule, + MatStepperModule, + MatRadioModule, + MatMenuModule, + MatListModule, + MatChipsModule, + MatBadgeModule, + MAT_DATE_LOCALE, + MAT_DATE_FORMATS } from '@angular/material'; import { CdkTableModule } from '@angular/cdk/table'; import { SnackBarNotificationComponent } from '../components/notificaiton/snack-bar-notification.component'; @@ -40,58 +40,58 @@ import { CultureService } from '../../utilities/culture/culture-service'; import { MomentDateAdapter } from '@angular/material-moment-adapter'; @NgModule({ - imports: [ - ], + imports: [ + ], - exports: [ - MatToolbarModule, - MatIconModule, - MatSidenavModule, - MatButtonModule, - MatTableModule, - MatPaginatorModule, - CdkTableModule, - MatSortModule, - MatDialogModule, - MatDatepickerModule, - MatNativeDateModule, - MatInputModule, - MatFormFieldModule, - MatSnackBarModule, - MatAutocompleteModule, - MatExpansionModule, - MatSelectModule, - MatOptionModule, - MatCardModule, - MatProgressBarModule, - MatProgressSpinnerModule, - MatTooltipModule, - MatCheckboxModule, - MatTabsModule, - CovalentLayoutModule, - CovalentChipsModule, - CovalentDialogsModule, - CovalentFileModule, - MatStepperModule, - MatRadioModule, - MatMenuModule, - MatListModule, - MatChipsModule, - MatBadgeModule, + exports: [ + MatToolbarModule, + MatIconModule, + MatSidenavModule, + MatButtonModule, + MatTableModule, + MatPaginatorModule, + CdkTableModule, + MatSortModule, + MatDialogModule, + MatDatepickerModule, + MatNativeDateModule, + MatInputModule, + MatFormFieldModule, + MatSnackBarModule, + MatAutocompleteModule, + MatExpansionModule, + MatSelectModule, + MatOptionModule, + MatCardModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatTooltipModule, + MatCheckboxModule, + MatTabsModule, + CovalentLayoutModule, + CovalentChipsModule, + CovalentDialogsModule, + CovalentFileModule, + MatStepperModule, + MatRadioModule, + MatMenuModule, + MatListModule, + MatChipsModule, + MatBadgeModule, - ], + ], - providers: [ + providers: [ - ], + ], - entryComponents: [ - SnackBarNotificationComponent - ] + entryComponents: [ + SnackBarNotificationComponent + ] }) export class MaterialModule { - // constructor(dateAdapter: DateAdapter) { - // dateAdapter.setLocale('el-GR'); - // } + // constructor(dateAdapter: DateAdapter) { + // dateAdapter.setLocale('el-GR'); + // } } diff --git a/dmp-frontend/src/app/shared/pipes/ngforlimit/ngforlimit.pipe.ts b/dmp-frontend/src/app/shared/pipes/ngforlimit/ngforlimit.pipe.ts index c09eb38a4..b643f64aa 100644 --- a/dmp-frontend/src/app/shared/pipes/ngforlimit/ngforlimit.pipe.ts +++ b/dmp-frontend/src/app/shared/pipes/ngforlimit/ngforlimit.pipe.ts @@ -2,9 +2,9 @@ import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'limitTo' }) export class NgForLimitPipe implements PipeTransform { - transform(items: any[], limit: number) { - if (items.length > limit) { - return items.slice(0, limit); - } else return items; - } -} \ No newline at end of file + transform(items: any[], limit: number) { + if (items.length > limit) { + return items.slice(0, limit); + } else { return items; } + } +} diff --git a/dmp-frontend/src/app/unauthorized/unauthorized.component.html b/dmp-frontend/src/app/unauthorized/unauthorized.component.html index 1a1112d35..d2764554d 100644 --- a/dmp-frontend/src/app/unauthorized/unauthorized.component.html +++ b/dmp-frontend/src/app/unauthorized/unauthorized.component.html @@ -1 +1 @@ -

{{message}}

\ No newline at end of file +

{{message}}

diff --git a/dmp-frontend/src/app/unauthorized/unauthorized.component.ts b/dmp-frontend/src/app/unauthorized/unauthorized.component.ts index f8c067519..3153117f4 100644 --- a/dmp-frontend/src/app/unauthorized/unauthorized.component.ts +++ b/dmp-frontend/src/app/unauthorized/unauthorized.component.ts @@ -1,33 +1,31 @@ import { AuthService } from '../services/auth/auth.service'; -import { Component, Input } from "@angular/core"; -import { ActivatedRoute, Router } from "@angular/router"; +import { Component, Input, AfterViewInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; @Component({ - selector: 'unauthorized-component', - templateUrl: './unauthorized.component.html' + selector: 'app-unauthorized-component', + templateUrl: './unauthorized.component.html' }) -export class UnauthorizedComponent { - @Input() - public message: string; - constructor( - private authService: AuthService, - private route: ActivatedRoute, - private router: Router - ) { } +export class UnauthorizedComponent implements AfterViewInit { + @Input() + public message: string; + constructor( + private authService: AuthService, + private route: ActivatedRoute, + private router: Router + ) { } - ngAfterViewInit() { - let returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/'; - let principal = this.authService.current(); - if (!principal) { - this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } }); - } - else { - this.authService.me().subscribe( - principal => { - if (!principal) this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } }); - else this.router.navigate(["/"]) - }, - err => console.error('An error occurred', err)); - } - } -} \ No newline at end of file + ngAfterViewInit() { + const returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/'; + const principal = this.authService.current(); + if (!principal) { + this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } }); + } else { + this.authService.me().subscribe( + result => { + if (!result) { this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } }); } else { this.router.navigate(['/']); } + }, + err => console.error('An error occurred', err)); + } + } +} diff --git a/dmp-frontend/src/app/unauthorized/unauthorized.module.ts b/dmp-frontend/src/app/unauthorized/unauthorized.module.ts index 80afd4181..88f866139 100644 --- a/dmp-frontend/src/app/unauthorized/unauthorized.module.ts +++ b/dmp-frontend/src/app/unauthorized/unauthorized.module.ts @@ -5,23 +5,23 @@ import { FormsModule } from '@angular/forms'; import { UnauthorizedComponent } from './unauthorized.component'; import { UnauthorizedRoutes } from './unauthorized.routes'; -import { SharedModule } from '../shared/shared.module' +import { SharedModule } from '../shared/shared.module'; @NgModule({ - imports: [ - CommonModule, - FormsModule, - HttpClientModule, - UnauthorizedRoutes, - SharedModule - ], + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + UnauthorizedRoutes, + SharedModule + ], - declarations: [ - UnauthorizedComponent - ], + declarations: [ + UnauthorizedComponent + ], - exports: [ - UnauthorizedComponent - ] + exports: [ + UnauthorizedComponent + ] }) export class UnauthorizedModule { } diff --git a/dmp-frontend/src/app/unauthorized/unauthorized.routes.ts b/dmp-frontend/src/app/unauthorized/unauthorized.routes.ts index f8e4ebee4..e79aa982f 100644 --- a/dmp-frontend/src/app/unauthorized/unauthorized.routes.ts +++ b/dmp-frontend/src/app/unauthorized/unauthorized.routes.ts @@ -3,7 +3,7 @@ import { UnauthorizedComponent } from './unauthorized.component'; const routes: Routes = [ - { path: '', component: UnauthorizedComponent } + { path: '', component: UnauthorizedComponent } ]; export const UnauthorizedRoutes = RouterModule.forChild(routes); diff --git a/dmp-frontend/src/app/user-management/admin-login/admin-login.component.html b/dmp-frontend/src/app/user-management/admin-login/admin-login.component.html index b86b90b27..52c00de80 100644 --- a/dmp-frontend/src/app/user-management/admin-login/admin-login.component.html +++ b/dmp-frontend/src/app/user-management/admin-login/admin-login.component.html @@ -1,34 +1,34 @@
-
-
-
-
-
-

Login

- -
-
-
-
-
+
+
+
+
+
+

Login

+ +
+
+
+
+
diff --git a/dmp-frontend/src/app/user-management/admin-login/admin-login.component.ts b/dmp-frontend/src/app/user-management/admin-login/admin-login.component.ts index f4b9eb83e..7348cae3b 100644 --- a/dmp-frontend/src/app/user-management/admin-login/admin-login.component.ts +++ b/dmp-frontend/src/app/user-management/admin-login/admin-login.component.ts @@ -3,34 +3,33 @@ import { LoginOptions } from '../utilties/LoginOptions'; import { LoginService } from '../utilties/login-service'; import { HttpClient } from '@angular/common/http'; import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable, NgZone } from '@angular/core'; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { TranslateService } from "@ngx-translate/core"; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { MatPaginator, MatSort, MatSnackBar } from '@angular/material'; +import { TranslateService } from '@ngx-translate/core'; @Component({ - selector: 'admin-login', - templateUrl: './admin-login.component.html', - styleUrls: ['./admin-login.component.scss'] + selector: 'app-admin-login', + templateUrl: './admin-login.component.html', + styleUrls: ['./admin-login.component.scss'] }) export class AdminLoginComponent implements OnInit { - public auth2: any; - public credential: Credential = new Credential() + public auth2: any; + public credential: Credential = new Credential(); - constructor( - private loginService: LoginService - ) { - } + constructor( + private loginService: LoginService + ) { } - ngOnInit() { - } + ngOnInit() { + } - public nativeLogin() { - this.loginService.nativeLogin(this.credential); - } + public nativeLogin() { + this.loginService.nativeLogin(this.credential); + } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/user-management/login.module.ts b/dmp-frontend/src/app/user-management/login.module.ts index b03197782..7eb95e2a4 100644 --- a/dmp-frontend/src/app/user-management/login.module.ts +++ b/dmp-frontend/src/app/user-management/login.module.ts @@ -8,38 +8,38 @@ import { SharedModule } from '../shared/shared.module'; import { LoginServiceConfiguration } from './utilties/LoginServiceConfiguration'; import { LoginService } from './utilties/login-service'; import { LoginComponent } from './login/login.component'; -import { ModuleWithProviders, NgModule } from "@angular/core"; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { AdminLoginComponent } from '../user-management/admin-login/admin-login.component'; @NgModule({ - imports: [ - SharedModule, - CommonModule, - LoginRoutes, - FormsModule - ], - declarations: [ - LoginComponent, - LinkedInLoginComponent, - TwitterLoginComponent, - AdminLoginComponent - ], - exports: [ - LoginComponent, - LinkedInLoginComponent, - TwitterLoginComponent, - AdminLoginComponent - ], - providers: [LoginService] + imports: [ + SharedModule, + CommonModule, + LoginRoutes, + FormsModule + ], + declarations: [ + LoginComponent, + LinkedInLoginComponent, + TwitterLoginComponent, + AdminLoginComponent + ], + exports: [ + LoginComponent, + LinkedInLoginComponent, + TwitterLoginComponent, + AdminLoginComponent + ], + providers: [LoginService] }) export class LoginModule { - static forRoot(config: LoginServiceConfiguration): ModuleWithProviders { - return { - ngModule: LoginModule, - providers: [ - { provide: LoginServiceConfiguration, useValue: config } - ], - }; - } + static forRoot(config: LoginServiceConfiguration): ModuleWithProviders { + return { + ngModule: LoginModule, + providers: [ + { provide: LoginServiceConfiguration, useValue: config } + ], + }; + } } diff --git a/dmp-frontend/src/app/user-management/login.routes.ts b/dmp-frontend/src/app/user-management/login.routes.ts index 312993625..c4446518a 100644 --- a/dmp-frontend/src/app/user-management/login.routes.ts +++ b/dmp-frontend/src/app/user-management/login.routes.ts @@ -5,10 +5,10 @@ import { RouterModule, Routes } from '@angular/router'; import { AdminLoginComponent } from '../user-management/admin-login/admin-login.component'; const routes: Routes = [ - { path: 'login', component: LoginComponent }, - { path: 'login/admin', component: AdminLoginComponent }, - { path: 'login/linkedin', component: LinkedInLoginComponent }, - { path: 'login/twitter', component: TwitterLoginComponent } + { path: 'login', component: LoginComponent }, + { path: 'login/admin', component: AdminLoginComponent }, + { path: 'login/linkedin', component: LinkedInLoginComponent }, + { path: 'login/twitter', component: TwitterLoginComponent } ]; export const LoginRoutes = RouterModule.forChild(routes); diff --git a/dmp-frontend/src/app/user-management/login/b2access/b2access-login.component.ts b/dmp-frontend/src/app/user-management/login/b2access/b2access-login.component.ts index 71dc64b9f..6b0ec9583 100644 --- a/dmp-frontend/src/app/user-management/login/b2access/b2access-login.component.ts +++ b/dmp-frontend/src/app/user-management/login/b2access/b2access-login.component.ts @@ -1,26 +1,25 @@ import { LoginService } from '../../utilties/login-service'; -import { Component, OnInit } from '@angular/core' +import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute, Params } from '@angular/router'; @Component({ - selector: 'b2access-login', - templateUrl: './b2access-login.component.html', + selector: 'app-b2access-login', + templateUrl: './b2access-login.component.html', }) export class B2AccessLoginComponent implements OnInit { - constructor( - private router: Router, - private route: ActivatedRoute, - private loginService: LoginService - ) { + constructor( + private router: Router, + private route: ActivatedRoute, + private loginService: LoginService + ) { - } + } - ngOnInit(): void { - this.route.queryParams.subscribe((data: any) => { - if (!data["code"]) this.loginService.b2AccessGetAuthCode() - else this.loginService.b2AccessLogin(data["code"]) - }) - } + ngOnInit(): void { + this.route.queryParams.subscribe((data: any) => { + if (!data['code']) { this.loginService.b2AccessGetAuthCode(); } else { this.loginService.b2AccessLogin(data['code']); } + }); + } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/user-management/login/linkedin-login/linkedin-login.component.ts b/dmp-frontend/src/app/user-management/login/linkedin-login/linkedin-login.component.ts index af9ebe386..a738f9a66 100644 --- a/dmp-frontend/src/app/user-management/login/linkedin-login/linkedin-login.component.ts +++ b/dmp-frontend/src/app/user-management/login/linkedin-login/linkedin-login.component.ts @@ -1,26 +1,25 @@ import { LoginService } from '../../utilties/login-service'; -import { Component, OnInit } from '@angular/core' +import { Component, OnInit } from '@angular/core'; import { Router, ActivatedRoute, Params } from '@angular/router'; @Component({ - selector: 'linkedin-login', - templateUrl: './linkedin-login.component.html', + selector: 'app-linkedin-login', + templateUrl: './linkedin-login.component.html', }) export class LinkedInLoginComponent implements OnInit { - constructor( - private router: Router, - private route: ActivatedRoute, - private loginService: LoginService - ) { + constructor( + private router: Router, + private route: ActivatedRoute, + private loginService: LoginService + ) { - } + } - ngOnInit(): void { - this.route.queryParams.subscribe((data: any) => { - if (!data["code"]) this.loginService.linkedinAuthorize() - else this.loginService.linkedInloginUser(data["code"]) - }) - } + ngOnInit(): void { + this.route.queryParams.subscribe((data: any) => { + if (!data['code']) { this.loginService.linkedinAuthorize(); } else { this.loginService.linkedInloginUser(data['code']); } + }); + } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/user-management/login/login.component.html b/dmp-frontend/src/app/user-management/login/login.component.html index f3e6cd9a2..5effbf193 100644 --- a/dmp-frontend/src/app/user-management/login/login.component.html +++ b/dmp-frontend/src/app/user-management/login/login.component.html @@ -1,52 +1,52 @@
-
-
-
-
-
-

Login

- - -
-
- -
-
- email - - - -
-
- lock_outline - - - -
-
- -
-

You dont need to have a registered account for OpenDMP

-
-
-
-
+
+
+
+
+
+

Login

+ + +
+
+ +
+
+ email + + + +
+
+ lock_outline + + + +
+
+ +
+

You dont need to have a registered account for OpenDMP

+
+
+
+
diff --git a/dmp-frontend/src/app/user-management/login/login.component.ts b/dmp-frontend/src/app/user-management/login/login.component.ts index 37161d966..a3718aaa9 100644 --- a/dmp-frontend/src/app/user-management/login/login.component.ts +++ b/dmp-frontend/src/app/user-management/login/login.component.ts @@ -3,75 +3,73 @@ import { LoginOptions } from '../utilties/LoginOptions'; import { LoginService } from '../utilties/login-service'; import { HttpClient } from '@angular/common/http'; import { Component, OnInit, ElementRef, AfterViewInit, VERSION, Injectable, NgZone } from '@angular/core'; -import { Router, ActivatedRoute, Params } from "@angular/router"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; -import { TranslateService } from "@ngx-translate/core"; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { MatPaginator, MatSort, MatSnackBar } from '@angular/material'; +import { TranslateService } from '@ngx-translate/core'; @Component({ - selector: 'login', - templateUrl: './login.component.html', - styleUrls: ['./login.component.scss'] + selector: 'app-login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.scss'] }) export class LoginComponent implements AfterViewInit { - public auth2: any; - public credential: Credential = new Credential() + public auth2: any; + public credential: Credential = new Credential(); - constructor( - private loginService: LoginService - ) { - } + constructor( + private loginService: LoginService + ) { + } + ngAfterViewInit() { + this.loginService.initProviders(); + } + public facebookLogin() { + this.loginService.facebookLogin(); + } - ngAfterViewInit() { - this.loginService.initProviders(); - } + public linkedInLogin() { + this.loginService.linkedInInitialiseLogin(); + } - public facebookLogin() { - this.loginService.facebookLogin(); - } + public twitterLogin() { + this.loginService.twitterInitialiseLogin(); + } - public linkedInLogin() { - this.loginService.linkedInInitialiseLogin(); - } + public nativeLogin() { + this.loginService.nativeLogin(this.credential); + } - public twitterLogin() { - this.loginService.twitterInitialiseLogin(); - } + public b2AccessLogin() { + return this.loginService.b2AccessInitialiseLogin(); + } - public nativeLogin() { - this.loginService.nativeLogin(this.credential); - } + public hasFacebookOauth(): boolean { + return this.loginService.hasProvider(LoginOptions.facebookOauth); + } - public b2AccessLogin() { - return this.loginService.b2AccessInitialiseLogin(); - } + public hasLinkedInOauth(): boolean { + return this.loginService.hasProvider(LoginOptions.linkedInOauth); + } - public hasFacebookOauth(): boolean { - return this.loginService.hasProvider(LoginOptions.facebookOauth); - } + public hasTwitterOauth(): boolean { + return this.loginService.hasProvider(LoginOptions.twitterOauth); + } - public hasLinkedInOauth(): boolean { - return this.loginService.hasProvider(LoginOptions.linkedInOauth); - } + public hasGoogleOauth(): boolean { + return this.loginService.hasProvider(LoginOptions.googleOauth); + } - public hasTwitterOauth(): boolean { - return this.loginService.hasProvider(LoginOptions.twitterOauth); - } + public hasNativeLogin(): boolean { + return this.loginService.hasProvider(LoginOptions.nativeLogin); + } - public hasGoogleOauth(): boolean { - return this.loginService.hasProvider(LoginOptions.googleOauth); - } + public hasB2AccessOauth(): boolean { + return this.loginService.hasProvider(LoginOptions.b2Access); + } - public hasNativeLogin(): boolean { - return this.loginService.hasProvider(LoginOptions.nativeLogin); - } - - public hasB2AccessOauth(): boolean { - return this.loginService.hasProvider(LoginOptions.b2Access); - } - -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/user-management/login/twitter-login/twitter-login.component.ts b/dmp-frontend/src/app/user-management/login/twitter-login/twitter-login.component.ts index 6a53bf523..21d7039c5 100644 --- a/dmp-frontend/src/app/user-management/login/twitter-login/twitter-login.component.ts +++ b/dmp-frontend/src/app/user-management/login/twitter-login/twitter-login.component.ts @@ -1,24 +1,23 @@ import { LoginService } from '../../utilties/login-service'; -import { ActivatedRoute, Router } from '@angular/router' -import { Component } from '@angular/core' +import { ActivatedRoute, Router } from '@angular/router'; +import { Component, OnInit } from '@angular/core'; @Component({ - selector: 'twitter-login', - templateUrl: './twitter-login.component.html', + selector: 'app-twitter-login', + templateUrl: './twitter-login.component.html', }) -export class TwitterLoginComponent { - constructor( - private router: Router, - private route: ActivatedRoute, - private loginService: LoginService - ) { +export class TwitterLoginComponent implements OnInit { + constructor( + private router: Router, + private route: ActivatedRoute, + private loginService: LoginService + ) { - } + } - ngOnInit(): void { - this.route.queryParams.subscribe((data: any) => { - if (!data["oauth_token"] && !data["oauth_verifier"]) this.loginService.twitterAuthorize() - else this.loginService.twitterLogin(data["oauth_token"],data["oauth_verifier"]) - }) - } + ngOnInit(): void { + this.route.queryParams.subscribe((data: any) => { + if (!data['oauth_token'] && !data['oauth_verifier']) { this.loginService.twitterAuthorize(); } else { this.loginService.twitterLogin(data['oauth_token'], data['oauth_verifier']); } + }); + } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/user-management/utilties/LoginOptions.ts b/dmp-frontend/src/app/user-management/utilties/LoginOptions.ts index b2a328fc0..31923a66d 100644 --- a/dmp-frontend/src/app/user-management/utilties/LoginOptions.ts +++ b/dmp-frontend/src/app/user-management/utilties/LoginOptions.ts @@ -1,9 +1,9 @@ -export enum LoginOptions{ - linkedInOauth = 1, - facebookOauth = 2, - twitterOauth = 3, - googleOauth = 4, - nativeLogin = 5, - b2Access = 6, - all = 7, -} \ No newline at end of file +export enum LoginOptions { + linkedInOauth = 1, + facebookOauth = 2, + twitterOauth = 3, + googleOauth = 4, + nativeLogin = 5, + b2Access = 6, + all = 7, +} diff --git a/dmp-frontend/src/app/user-management/utilties/LoginProviderConfiguration.ts b/dmp-frontend/src/app/user-management/utilties/LoginProviderConfiguration.ts index 38a9f4745..ddf843a75 100644 --- a/dmp-frontend/src/app/user-management/utilties/LoginProviderConfiguration.ts +++ b/dmp-frontend/src/app/user-management/utilties/LoginProviderConfiguration.ts @@ -1,5 +1,5 @@ export abstract class LoginProviderConfiguration { - public clientId: string + public clientId: string; } export class FacebookLoginConfiguration extends LoginProviderConfiguration { @@ -9,19 +9,19 @@ export class GoogleLoginConfiguration extends LoginProviderConfiguration { } export class TwitterLoginConfiguration extends LoginProviderConfiguration { - public oauthUrl: string + public oauthUrl: string; } export class LinkedInConfiguration extends LoginProviderConfiguration { - public oauthUrl: string - public redirectUri: string - public accessTokenUri: string - public clientSecret: string + public oauthUrl: string; + public redirectUri: string; + public accessTokenUri: string; + public clientSecret: string; } export class B2AccessConfiguration extends LoginProviderConfiguration { - public oauthUrl: string - public redirectUri: string - public accessTokenUri: string - public clientSecret: string -} \ No newline at end of file + public oauthUrl: string; + public redirectUri: string; + public accessTokenUri: string; + public clientSecret: string; +} diff --git a/dmp-frontend/src/app/user-management/utilties/LoginServiceConfiguration.ts b/dmp-frontend/src/app/user-management/utilties/LoginServiceConfiguration.ts index 05aaa5e1d..87560c1ef 100644 --- a/dmp-frontend/src/app/user-management/utilties/LoginServiceConfiguration.ts +++ b/dmp-frontend/src/app/user-management/utilties/LoginServiceConfiguration.ts @@ -1,16 +1,16 @@ import { - FacebookLoginConfiguration, - GoogleLoginConfiguration, - LinkedInConfiguration, - TwitterLoginConfiguration, - B2AccessConfiguration, + FacebookLoginConfiguration, + GoogleLoginConfiguration, + LinkedInConfiguration, + TwitterLoginConfiguration, + B2AccessConfiguration, } from './LoginProviderConfiguration'; import { LoginOptions } from './LoginOptions'; export class LoginServiceConfiguration { - public loginProviders: LoginOptions[]; - public facebookConfiguration?: FacebookLoginConfiguration; - public googleConfiguration?: GoogleLoginConfiguration; - public twitterConfiguration?: TwitterLoginConfiguration; - public linkedInConfiguration?: LinkedInConfiguration; - public b2accessConfiguration?: B2AccessConfiguration; -} \ No newline at end of file + public loginProviders: LoginOptions[]; + public facebookConfiguration?: FacebookLoginConfiguration; + public googleConfiguration?: GoogleLoginConfiguration; + public twitterConfiguration?: TwitterLoginConfiguration; + public linkedInConfiguration?: LinkedInConfiguration; + public b2accessConfiguration?: B2AccessConfiguration; +} diff --git a/dmp-frontend/src/app/user-management/utilties/login-service.ts b/dmp-frontend/src/app/user-management/utilties/login-service.ts index aa3801953..368755cf0 100644 --- a/dmp-frontend/src/app/user-management/utilties/login-service.ts +++ b/dmp-frontend/src/app/user-management/utilties/login-service.ts @@ -21,215 +21,213 @@ declare const IN: any; @Injectable() export class LoginService { - private providers: LoginOptions[] - private auth2: any; - constructor( - private router: Router, - public authService: AuthService, - public route: ActivatedRoute, - public snackBar: MatSnackBar, - public language: TranslateService, - private zone: NgZone, - private httpClient: HttpClient, - private cultureService: CultureService, - @Optional() private config: LoginServiceConfiguration - ) { - if (config) { - this.providers = config.loginProviders; - } - else this.providers = [LoginOptions.nativeLogin]; - } + private providers: LoginOptions[]; + private auth2: any; + constructor( + private router: Router, + public authService: AuthService, + public route: ActivatedRoute, + public snackBar: MatSnackBar, + public language: TranslateService, + private zone: NgZone, + private httpClient: HttpClient, + private cultureService: CultureService, + @Optional() private config: LoginServiceConfiguration + ) { + if (config) { + this.providers = config.loginProviders; + } else { this.providers = [LoginOptions.nativeLogin]; } + } - public initProviders() { - if (this.hasProvider(LoginOptions.googleOauth)) this.initialiseGoogleOauth(); - if (this.hasProvider(LoginOptions.facebookOauth)) this.initialiseFacebookOauth(); - } + public initProviders() { + if (this.hasProvider(LoginOptions.googleOauth)) { this.initialiseGoogleOauth(); } + if (this.hasProvider(LoginOptions.facebookOauth)) { this.initialiseFacebookOauth(); } + } - public hasProvider(provider: LoginOptions) { - for (let i = 0; i < this.providers.length; i++) { - if (provider === this.providers[i]) return this.isProviderProperlyConfigured(provider) - } - return false; - } + public hasProvider(provider: LoginOptions) { + for (let i = 0; i < this.providers.length; i++) { + if (provider === this.providers[i]) { return this.isProviderProperlyConfigured(provider); } + } + return false; + } - private isProviderProperlyConfigured(provider: LoginOptions) { - switch (provider) { - case LoginOptions.facebookOauth: return this.hasAllRequiredFieldsConfigured(this.config.facebookConfiguration); - case LoginOptions.googleOauth: return this.hasAllRequiredFieldsConfigured(this.config.googleConfiguration) - case LoginOptions.linkedInOauth: return this.hasAllRequiredFieldsConfigured(this.config.linkedInConfiguration); - case LoginOptions.twitterOauth: return this.hasAllRequiredFieldsConfigured(this.config.twitterConfiguration); - case LoginOptions.b2Access: return this.hasAllRequiredFieldsConfigured(this.config.b2accessConfiguration); - case LoginOptions.nativeLogin: return true; - default: throw new Error("Unsupported Provider Type") - } - } + private isProviderProperlyConfigured(provider: LoginOptions) { + switch (provider) { + case LoginOptions.facebookOauth: return this.hasAllRequiredFieldsConfigured(this.config.facebookConfiguration); + case LoginOptions.googleOauth: return this.hasAllRequiredFieldsConfigured(this.config.googleConfiguration); + case LoginOptions.linkedInOauth: return this.hasAllRequiredFieldsConfigured(this.config.linkedInConfiguration); + case LoginOptions.twitterOauth: return this.hasAllRequiredFieldsConfigured(this.config.twitterConfiguration); + case LoginOptions.b2Access: return this.hasAllRequiredFieldsConfigured(this.config.b2accessConfiguration); + case LoginOptions.nativeLogin: return true; + default: throw new Error('Unsupported Provider Type'); + } + } - private hasAllRequiredFieldsConfigured(configuration: LoginProviderConfiguration) { - if (configuration != null && configuration.clientId != null) return true - return false; - } + private hasAllRequiredFieldsConfigured(configuration: LoginProviderConfiguration) { + if (configuration != null && configuration.clientId != null) { return true; } + return false; + } - /* - * GOOGLE SIGN IN + /* + * GOOGLE SIGN IN + */ + + private initialiseGoogleOauth(): void { + gapi.load('auth2', () => { + this.auth2 = gapi.auth2.init({ + client_id: this.config.googleConfiguration.clientId, + cookiepolicy: 'single_host_origin', + scope: 'profile email' + }); + this.attachGoogleSignin(document.getElementById('googleSignInButton')); + }); + } + + public attachGoogleSignin(element) { + if (!element) { return; } + this.auth2.attachClickHandler(element, {}, + (googleUser) => { + const id_token = googleUser.getAuthResponse().id_token; + if (id_token) { + this.authService.login({ ticket: id_token, provider: LoginProviders.Google }).subscribe( + res => this.onLogInSuccess(res), + error => this.onLogInError(error) + ); + } + }, (error) => { + }); + } + + + + /* + * FACEBOOK SIGN IN + */ + + + private initialiseFacebookOauth(): void { + FB.init({ + appId: this.config.facebookConfiguration.clientId, + cookie: false, + xfbml: true, + version: 'v2.8' + }); + } + + + + + public facebookLogin() { + FB.login((response: any) => { + if (response.status === 'connected' || 'not_authorized') { + this.authService.login({ ticket: response.authResponse.accessToken, provider: LoginProviders.Facebook }).subscribe( + res => this.onLogInSuccess(res), + error => this.onLogInError(error) + ); + } + }, { scope: 'user_friends,email' }); + } + + /* + * LINKEDIN SIGN IN + */ + + public linkedinAuthorize() { + window.location.href = this.config.linkedInConfiguration.oauthUrl + '?response_type=code&client_id=' + this.config.linkedInConfiguration.clientId + '&redirect_uri=' + this.config.linkedInConfiguration.redirectUri + '&state=987654321'; + } + + public linkedInInitialiseLogin() { + this.router.navigate(['/login/linkedin']); + } + + public linkedInloginUser(code: string) { + this.authService.login({ ticket: code, provider: LoginProviders.LinkedIn }).subscribe( + res => this.onLogInSuccess(res), + error => this.onLogInError(error) + ); + } + + /* + * TWITTER SIGN IN + */ + public twitterInitialiseLogin() { + this.router.navigate(['/login/twitter']); + } + + public twitterAuthorize() { + let headers = new HttpHeaders(); + headers = headers.set('Content-Type', 'application/json'); + headers = headers.set('Accept', 'application/json'); + this.httpClient.get(HostConfiguration.Server + 'auth/twitterRequestToken', { headers: headers }).subscribe((data: any) => { + window.location.href = this.config.twitterConfiguration.oauthUrl + '?oauth_token=' + data.payload.value; + }); + } + + public twitterLogin(token: string, verifier: string) { + this.authService.login({ ticket: token, provider: LoginProviders.Twitter, data: verifier }).subscribe( + res => this.onLogInSuccess(res), + error => this.onLogInError(error) + ); + } + + /* + * B2ACCESS LOG IN */ - private initialiseGoogleOauth(): void { - gapi.load('auth2', () => { - this.auth2 = gapi.auth2.init({ - client_id: this.config.googleConfiguration.clientId, - cookiepolicy: 'single_host_origin', - scope: 'profile email' - }); - this.attachGoogleSignin(document.getElementById('googleSignInButton')); - }); - } + public b2AccessInitialiseLogin() { + this.router.navigate(['/api/oauth/authorized/b2access']); + } - public attachGoogleSignin(element) { - if (!element) return - this.auth2.attachClickHandler(element, {}, - (googleUser) => { - var id_token = googleUser.getAuthResponse().id_token; - if (id_token) { - this.authService.login({ ticket: id_token, provider: LoginProviders.Google }).subscribe( - res => this.onLogInSuccess(res), - error => this.onLogInError(error) - ) - } - }, (error) => { - alert(JSON.stringify(error, undefined, 2)); - }); - } + public b2AccessGetAuthCode() { + window.location.href = this.config.b2accessConfiguration.oauthUrl + '?response_type=code&client_id=' + this.config.b2accessConfiguration.clientId + '&redirect_uri=' + this.config.b2accessConfiguration.redirectUri + '&state=987654321&scope=USER_PROFILE'; + } + + public b2AccessLogin(code: String) { + let headers = new HttpHeaders(); + headers = headers.set('Content-Type', 'application/json'); + headers = headers.set('Accept', 'application/json'); + this.httpClient.post(HostConfiguration.Server + 'auth/b2AccessRequestToken', { code: code }, { headers: headers }) + .subscribe((data: any) => { + this.authService.login({ ticket: data.payload.accessToken, provider: LoginProviders.B2Accesss, data: null }).subscribe( + res => this.onLogInSuccess(res), + error => this.onLogInError(error) + ); + }); + } + /* + * NATIVE LOGIN + */ - /* - * FACEBOOK SIGN IN - */ + public nativeLogin(credentials: Credential) { + this.authService.nativeLogin(credentials).subscribe( + res => this.onLogInSuccess(res), + error => this.onLogInError(error) + ); + } - private initialiseFacebookOauth(): void { - FB.init({ - appId: this.config.facebookConfiguration.clientId, - cookie: false, - xfbml: true, - version: 'v2.8' - }); - } + /* + * LOGIN HANDLERS + */ + public onLogInSuccess(logoutMessage: any) { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGIN', language: this.language }, + duration: 3000, + }); + if (this.authService.current().culture) { this.cultureService.cultureSelected(this.authService.current().culture); } + const params = this.router['rawUrlTree'].queryParams; + const redirectUrl = params['returnUrl'] ? params['returnUrl'] : '/'; + this.zone.run(() => this.router.navigate([redirectUrl])); + } - - public facebookLogin() { - FB.login((response: any) => { - if (response.status === 'connected' || 'not_authorized') { - this.authService.login({ ticket: response.authResponse.accessToken, provider: LoginProviders.Facebook }).subscribe( - res => this.onLogInSuccess(res), - error => this.onLogInError(error) - ) - } - }, { scope: 'user_friends,email' }); - } - - /* - * LINKEDIN SIGN IN - */ - - public linkedinAuthorize() { - window.location.href = this.config.linkedInConfiguration.oauthUrl + "?response_type=code&client_id=" + this.config.linkedInConfiguration.clientId + "&redirect_uri=" + this.config.linkedInConfiguration.redirectUri + "&state=987654321" - } - - public linkedInInitialiseLogin() { - this.router.navigate(["/login/linkedin"]) - } - - public linkedInloginUser(code: string) { - this.authService.login({ ticket: code, provider: LoginProviders.LinkedIn }).subscribe( - res => this.onLogInSuccess(res), - error => this.onLogInError(error) - ) - } - - /* - * TWITTER SIGN IN - */ - public twitterInitialiseLogin() { - this.router.navigate(["/login/twitter"]) - } - - public twitterAuthorize() { - let headers = new HttpHeaders(); - headers = headers.set('Content-Type', 'application/json'); - headers = headers.set('Accept', 'application/json'); - this.httpClient.get(HostConfiguration.Server + 'auth/twitterRequestToken', { headers: headers }).subscribe((data: any) => { - window.location.href = this.config.twitterConfiguration.oauthUrl + "?oauth_token=" + data.payload.value - }) - } - - public twitterLogin(token: string, verifier: string) { - this.authService.login({ ticket: token, provider: LoginProviders.Twitter, data: verifier }).subscribe( - res => this.onLogInSuccess(res), - error => this.onLogInError(error) - ) - } - - /* -* B2ACCESS LOG IN -*/ - - public b2AccessInitialiseLogin() { - this.router.navigate(["/api/oauth/authorized/b2access"]) - } - - public b2AccessGetAuthCode() { - window.location.href = this.config.b2accessConfiguration.oauthUrl + "?response_type=code&client_id=" + this.config.b2accessConfiguration.clientId + "&redirect_uri=" + this.config.b2accessConfiguration.redirectUri + "&state=987654321&scope=USER_PROFILE" - } - - public b2AccessLogin(code: String) { - let headers = new HttpHeaders(); - headers = headers.set('Content-Type', 'application/json'); - headers = headers.set('Accept', 'application/json'); - this.httpClient.post(HostConfiguration.Server + "auth/b2AccessRequestToken", { code: code }, { headers: headers }) - .subscribe((data: any) => { - this.authService.login({ ticket: data.payload.accessToken, provider: LoginProviders.B2Accesss, data: null }).subscribe( - res => this.onLogInSuccess(res), - error => this.onLogInError(error) - ) - }) - } - - - /* - * NATIVE LOGIN - */ - - public nativeLogin(credentials: Credential) { - this.authService.nativeLogin(credentials).subscribe( - res => this.onLogInSuccess(res), - error => this.onLogInError(error) - ) - } - - - /* - * LOGIN HANDLERS - */ - - - public onLogInSuccess(logoutMessage: any) { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGIN', language: this.language }, - duration: 3000, - }); - if (this.authService.current().culture) this.cultureService.cultureSelected(this.authService.current().culture) - let params = this.router["rawUrlTree"].queryParams; - let redirectUrl = params['returnUrl'] ? params['returnUrl'] : '/'; - this.zone.run(() => this.router.navigate([redirectUrl])); - } - - public onLogInError(errorMessage: string) { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGIN', language: this.language }, - duration: 3000, - }) - } + public onLogInError(errorMessage: string) { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGIN', language: this.language }, + duration: 3000, + }); + } } diff --git a/dmp-frontend/src/app/users/activity/RecentActivityTypes.ts b/dmp-frontend/src/app/users/activity/RecentActivityTypes.ts index a4dd4cbc8..bdf36f506 100644 --- a/dmp-frontend/src/app/users/activity/RecentActivityTypes.ts +++ b/dmp-frontend/src/app/users/activity/RecentActivityTypes.ts @@ -1,5 +1,5 @@ export enum RecentActivityTypes { - PROJECT = 0, - DATASET = 1, - DMP = 2 - } \ No newline at end of file + PROJECT = 0, + DATASET = 1, + DMP = 2 +} diff --git a/dmp-frontend/src/app/users/activity/recent-activity.component.html b/dmp-frontend/src/app/users/activity/recent-activity.component.html index 75e6aadc3..9ca9fac9f 100644 --- a/dmp-frontend/src/app/users/activity/recent-activity.component.html +++ b/dmp-frontend/src/app/users/activity/recent-activity.component.html @@ -1,67 +1,67 @@
-
- - - - {{'RECENT-ACTIVITY.MY-TITLE-DMP' | translate}} - - - - - -

- {{activity.label}} -

-

- {{activity.timestamp | date:'shortDate'}} -

-
-
-
-
-
-
- - - - {{'RECENT-ACTIVITY.MY-TITLE-PROJECT' | translate}} - - - - - -

- {{activity.label}} -

-

- {{activity.timestamp | date:'shortDate'}} -

-
-
-
+
+ + + + {{'RECENT-ACTIVITY.MY-TITLE-DMP' | translate}} + + + + + +

+ {{activity.label}} +

+

+ {{activity.timestamp | date:'shortDate'}} +

+
+
+
+
+
+
+ + + + {{'RECENT-ACTIVITY.MY-TITLE-PROJECT' | translate}} + + + + + +

+ {{activity.label}} +

+

+ {{activity.timestamp | date:'shortDate'}} +

+
+
+
-
-
-
- - - - {{'RECENT-ACTIVITY.MY-TITLE-DATASET' | translate}} - - - - - -

- {{activity.label}} -

-

- {{activity.timestamp | date:'shortDate'}} -

-
-
+
+
+
+ + + + {{'RECENT-ACTIVITY.MY-TITLE-DATASET' | translate}} + + + + + +

+ {{activity.label}} +

+

+ {{activity.timestamp | date:'shortDate'}} +

+
+
-
-
-
+ +
+
diff --git a/dmp-frontend/src/app/users/activity/recent-activity.component.ts b/dmp-frontend/src/app/users/activity/recent-activity.component.ts index 5aae16704..c6fea0098 100644 --- a/dmp-frontend/src/app/users/activity/recent-activity.component.ts +++ b/dmp-frontend/src/app/users/activity/recent-activity.component.ts @@ -37,28 +37,28 @@ export class RecentActivityComponent implements OnInit { ngOnInit() { this.userReferenceService.getRecentActivity().subscribe(response => { - this.datasetActivities = response["recentDatasetActivities"]; - this.dmpActivities = response["recentDmpActivities"]; - this.projectActivities = response["recentProjectActivities"]; - }) + this.datasetActivities = response['recentDatasetActivities']; + this.dmpActivities = response['recentDmpActivities']; + this.projectActivities = response['recentProjectActivities']; + }); } redirect(id: string, type: RecentActivityTypes) { switch (type) { case RecentActivityTypes.PROJECT: { - this.router.navigate(["projects/edit/" + id]); + this.router.navigate(['projects/edit/' + id]); return; } case RecentActivityTypes.DATASET: { - this.router.navigate(["datasets/edit/" + id]); + this.router.navigate(['datasets/edit/' + id]); return; } case RecentActivityTypes.DMP: { - this.router.navigate(["dmps/edit/" + id]); + this.router.navigate(['dmps/edit/' + id]); return; } - default: throw new Error("Unsupported Activity Type ") + default: throw new Error('Unsupported Activity Type '); } } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/users/components/roles/user-role-editor.component.html b/dmp-frontend/src/app/users/components/roles/user-role-editor.component.html index 30f8832d8..1e5662036 100644 --- a/dmp-frontend/src/app/users/components/roles/user-role-editor.component.html +++ b/dmp-frontend/src/app/users/components/roles/user-role-editor.component.html @@ -1,7 +1,6 @@ 
- + {{getPrincipalAppRoleWithLanguage(role)}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -13,4 +12,4 @@ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/users/components/roles/user-role-editor.component.ts b/dmp-frontend/src/app/users/components/roles/user-role-editor.component.ts index e9484151e..2ffc3f75f 100644 --- a/dmp-frontend/src/app/users/components/roles/user-role-editor.component.ts +++ b/dmp-frontend/src/app/users/components/roles/user-role-editor.component.ts @@ -11,153 +11,153 @@ import { Principal } from '../../../models/login/Principal'; import { MatSnackBar } from '@angular/material'; @Component({ - selector: 'user-role-editor-component', - templateUrl: './user-role-editor.component.html', - styleUrls: ['./user-role-editor.component.scss'], - providers:[Utilities] + selector: 'app-user-role-editor-component', + templateUrl: './user-role-editor.component.html', + styleUrls: ['./user-role-editor.component.scss'], + providers: [Utilities] }) export class UserRoleEditorComponent implements OnInit { - @Input() public item: UserListingModel; - public formGroup: FormGroup = null; - public nowEditing = false; - public errorModel: UserErrorModel; - constructor( - public language: TranslateService, - public userService: UserReferenceService, - public formBuilder: FormBuilder, - public snackBar: MatSnackBar, - public utilities: Utilities - ) { - } + @Input() public item: UserListingModel; + public formGroup: FormGroup = null; + public nowEditing = false; + public errorModel: UserErrorModel; + constructor( + public language: TranslateService, + public userService: UserReferenceService, + public formBuilder: FormBuilder, + public snackBar: MatSnackBar, + public utilities: Utilities + ) { + } - ngOnInit() { - if (this.errorModel == null) { this.errorModel = new UserErrorModel(); } - if (this.formGroup == null) { this.formGroup = this.buildForm(); } - } + ngOnInit() { + if (this.errorModel == null) { this.errorModel = new UserErrorModel(); } + if (this.formGroup == null) { this.formGroup = this.buildForm(); } + } - buildForm(): FormGroup { - const context: ValidationContext = this.createValidationContext(); + buildForm(): FormGroup { + const context: ValidationContext = this.createValidationContext(); - return this.formBuilder.group({ - appRoles: new FormControl({ value: this.item.appRoles, disabled: true }, context.getValidation('appRoles').validators) - }); - } + return this.formBuilder.group({ + appRoles: new FormControl({ value: this.item.appRoles, disabled: true }, context.getValidation('appRoles').validators) + }); + } - createValidationContext(): ValidationContext { - const validationContext: ValidationContext = new ValidationContext(); - const validationArray: Validation[] = new Array(); + createValidationContext(): ValidationContext { + const validationContext: ValidationContext = new ValidationContext(); + const validationArray: Validation[] = new Array(); - validationArray.push({ key: 'appRoles' }); + validationArray.push({ key: 'appRoles' }); - validationContext.validation = validationArray; - return validationContext; - } + validationContext.validation = validationArray; + return validationContext; + } - formSubmit(): void { - this.clearErrorModel(); + formSubmit(): void { + this.clearErrorModel(); - const modifiedItem = new UserListingModel().fromJSONObject(this.item); - modifiedItem.appRoles = this.getFormControl('appRoles').value; + const modifiedItem = new UserListingModel().fromJSONObject(this.item); + modifiedItem.appRoles = this.getFormControl('appRoles').value; - if (!this.isFormValid()) { return; } - this.userService.updateRoles(modifiedItem).subscribe( - (res) => this.onCallbackSuccess(), - (error) => this.onCallbackError(error) - ); - } + if (!this.isFormValid()) { return; } + this.userService.updateRoles(modifiedItem).subscribe( + (res) => this.onCallbackSuccess(), + (error) => this.onCallbackError(error) + ); + } - editItem(): void { - this.formGroup.enable(); - this.nowEditing = true; - } + editItem(): void { + this.formGroup.enable(); + this.nowEditing = true; + } - isFormValid(): boolean { - this.touchAllFormFields(this.formGroup); - this.validateAllFormFields(this.formGroup); - return this.formGroup.valid; - } + isFormValid(): boolean { + this.touchAllFormFields(this.formGroup); + this.validateAllFormFields(this.formGroup); + return this.formGroup.valid; + } - getFormData(): any { - return this.formGroup.value; - } + getFormData(): any { + return this.formGroup.value; + } - getFormControl(controlName: string): AbstractControl { - return this.formGroup.get(controlName); - } + getFormControl(controlName: string): AbstractControl { + return this.formGroup.get(controlName); + } - validateAllFormFields(formControl: AbstractControl) { - if (formControl instanceof FormControl) { - formControl.updateValueAndValidity({ emitEvent: false }) - } else if (formControl instanceof FormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.validateAllFormFields(control); - }) - } else if (formControl instanceof FormArray) { - formControl.controls.forEach(item => { - this.validateAllFormFields(item); - }) - } - } + validateAllFormFields(formControl: AbstractControl) { + if (formControl instanceof FormControl) { + formControl.updateValueAndValidity({ emitEvent: false }); + } else if (formControl instanceof FormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + this.validateAllFormFields(control); + }); + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + this.validateAllFormFields(item); + }); + } + } - touchAllFormFields(formControl: AbstractControl) { - if (formControl instanceof FormControl) { - formControl.markAsTouched(); - } else if (formControl instanceof FormGroup) { - Object.keys(formControl.controls).forEach(item => { - const control = formControl.get(item); - this.touchAllFormFields(control); - }) - } else if (formControl instanceof FormArray) { - formControl.controls.forEach(item => { - this.touchAllFormFields(item); - }) - } - } + touchAllFormFields(formControl: AbstractControl) { + if (formControl instanceof FormControl) { + formControl.markAsTouched(); + } else if (formControl instanceof FormGroup) { + Object.keys(formControl.controls).forEach(item => { + const control = formControl.get(item); + this.touchAllFormFields(control); + }); + } else if (formControl instanceof FormArray) { + formControl.controls.forEach(item => { + this.touchAllFormFields(item); + }); + } + } - setErrorModel(errorModel: UserErrorModel) { - Object.keys(errorModel).forEach(item => { - (this.errorModel)[item] = (errorModel)[item]; - }) - } + setErrorModel(errorModel: UserErrorModel) { + Object.keys(errorModel).forEach(item => { + (this.errorModel)[item] = (errorModel)[item]; + }); + } - clearErrorModel() { - Object.keys(this.errorModel).forEach(item => { - (this.errorModel)[item] = ''; - }) - } + clearErrorModel() { + Object.keys(this.errorModel).forEach(item => { + (this.errorModel)[item] = ''; + }); + } - onCallbackSuccess() { - this.nowEditing = false; - this.formGroup.disable(); - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, - duration: 3000, - }); - } - onCallbackError(error: any) { - this.setErrorModel(error.error); - this.validateAllFormFields(this.formGroup); - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE', language: this.language }, - duration: 3000, - }); - } + onCallbackSuccess() { + this.nowEditing = false; + this.formGroup.disable(); + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language }, + duration: 3000, + }); + } + onCallbackError(error: any) { + this.setErrorModel(error.error); + this.validateAllFormFields(this.formGroup); + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE', language: this.language }, + duration: 3000, + }); + } - getPrincipalAppRoleValues(): Number[] { - let keys: string[] = Object.keys(Principal.AppRole); - keys = keys.slice(0, keys.length / 2); - const values: Number[] = keys.map(Number); - return values; - } + getPrincipalAppRoleValues(): Number[] { + let keys: string[] = Object.keys(Principal.AppRole); + keys = keys.slice(0, keys.length / 2); + const values: Number[] = keys.map(Number); + return values; + } - getPrincipalAppRoleWithLanguage(role: Principal.AppRole): string { - let result = ''; - this.language.get(this.utilities.convertFromPrincipalAppRole(role)).subscribe((value: string) => { - result = value; - }); - return result; - } + getPrincipalAppRoleWithLanguage(role: Principal.AppRole): string { + let result = ''; + this.language.get(this.utilities.convertFromPrincipalAppRole(role)).subscribe((value: string) => { + result = value; + }); + return result; + } } diff --git a/dmp-frontend/src/app/users/components/users.component.html b/dmp-frontend/src/app/users/components/users.component.html index d04732a6c..da5367a74 100644 --- a/dmp-frontend/src/app/users/components/users.component.html +++ b/dmp-frontend/src/app/users/components/users.component.html @@ -1,7 +1,7 @@ 

{{'USERS.LISTING.TITLE' | translate}}

- + @@ -27,7 +27,7 @@ {{'USERS.LISTING.ROLES' | translate}} - + @@ -35,9 +35,7 @@ - +
diff --git a/dmp-frontend/src/app/users/components/users.component.ts b/dmp-frontend/src/app/users/components/users.component.ts index aad27d8cb..a5fb77e97 100644 --- a/dmp-frontend/src/app/users/components/users.component.ts +++ b/dmp-frontend/src/app/users/components/users.component.ts @@ -17,119 +17,119 @@ import { DataSource } from '@angular/cdk/table'; export class UsersDataSource extends DataSource { - totalCount = 0; - isLoadingResults = false; + totalCount = 0; + isLoadingResults = false; - constructor( - private _service: UserReferenceService, - private _paginator: MatPaginator, - private _sort: MatSort, - private _languageService: TranslateService, - private _snackBar: MatSnackBar, - private _criteria: UsersCriteriaComponent - ) { - super(); + constructor( + private _service: UserReferenceService, + private _paginator: MatPaginator, + private _sort: MatSort, + private _languageService: TranslateService, + private _snackBar: MatSnackBar, + private _criteria: UsersCriteriaComponent + ) { + super(); - //this._paginator.page.subscribe((pageEvent: PageEvent) => { - // this.store.dispatch(new LoadPhotosRequestAction(pageEvent.pageIndex, pageEvent.pageSize)) - //}) - } + //this._paginator.page.subscribe((pageEvent: PageEvent) => { + // this.store.dispatch(new LoadPhotosRequestAction(pageEvent.pageIndex, pageEvent.pageSize)) + //}) + } - connect(): Observable { - const displayDataChanges = [ - this._paginator.page - //this._sort.matSortChange - ]; + connect(): Observable { + const displayDataChanges = [ + this._paginator.page + //this._sort.matSortChange + ]; - // If the user changes the sort order, reset back to the first page. - //this._sort.matSortChange.subscribe(() => { - // this._paginator.pageIndex = 0; - //}) + // If the user changes the sort order, reset back to the first page. + //this._sort.matSortChange.subscribe(() => { + // this._paginator.pageIndex = 0; + //}) - return Observable.merge(...displayDataChanges) - .startWith(null) - .switchMap(() => { - setTimeout(() => { - this.isLoadingResults = true; - }); - const startIndex = this._paginator.pageIndex * this._paginator.pageSize; - let fields: Array = new Array() - if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; - const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); - request.criteria = this._criteria.getFormData(); - return this._service.getPaged(request); - }) - .catch((error: any) => { - this._snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, - duration: 3000, - }); - this._criteria.onCallbackError(error); - return Observable.of(null); - }) - .map(result => { - setTimeout(() => { - this.isLoadingResults = false; - }); - return result; - }) - .map(result => { - if (!result) { return []; } - if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } - //result.data.forEach((element: any) => { - // const roles: String[] = []; - // element.roles.forEach((role: any) => { - // this._languageService.get(this._utilities.convertFromPrincipalAppRole(role)).subscribe( - // value => roles.push(value) - // ); - // }); - // element.roles = roles; - //}); - return result.data; - }); - } + return Observable.merge(...displayDataChanges) + .startWith(null) + .switchMap(() => { + setTimeout(() => { + this.isLoadingResults = true; + }); + const startIndex = this._paginator.pageIndex * this._paginator.pageSize; + let fields: Array = new Array(); + if (this._sort.active) { fields = this._sort.direction === 'asc' ? ['+' + this._sort.active] : ['-' + this._sort.active]; } + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); + request.criteria = this._criteria.getFormData(); + return this._service.getPaged(request); + }) + .catch((error: any) => { + this._snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, + duration: 3000, + }); + this._criteria.onCallbackError(error); + return Observable.of(null); + }) + .map(result => { + setTimeout(() => { + this.isLoadingResults = false; + }); + return result; + }) + .map(result => { + if (!result) { return []; } + if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } + //result.data.forEach((element: any) => { + // const roles: String[] = []; + // element.roles.forEach((role: any) => { + // this._languageService.get(this._utilities.convertFromPrincipalAppRole(role)).subscribe( + // value => roles.push(value) + // ); + // }); + // element.roles = roles; + //}); + return result.data; + }); + } - disconnect() { - // No-op - } + disconnect() { + // No-op + } } @Component({ - selector: 'app-users-component', - templateUrl: './users.component.html', - styleUrls: ['./users.component.scss'] + selector: 'app-users-component', + templateUrl: './users.component.html', + styleUrls: ['./users.component.scss'] }) export class UsersComponent implements OnInit, AfterViewInit { - @ViewChild(MatPaginator) _paginator: MatPaginator; - @ViewChild(MatSort) sort: MatSort; - @ViewChild(UsersCriteriaComponent) criteria: UsersCriteriaComponent; + @ViewChild(MatPaginator) _paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + @ViewChild(UsersCriteriaComponent) criteria: UsersCriteriaComponent; - dataSource: UsersDataSource | null; - displayedColumns: String[] = ['name', 'email', 'lastloggedin', 'roles']; + dataSource: UsersDataSource | null; + displayedColumns: String[] = ['name', 'email', 'lastloggedin', 'roles']; - constructor(private userService: UserReferenceService, private router: Router, private languageService: TranslateService, public snackBar: MatSnackBar) { + constructor(private userService: UserReferenceService, private router: Router, private languageService: TranslateService, public snackBar: MatSnackBar) { - } + } - ngOnInit() { - //this.refresh(); //called on ngAfterViewInit with default criteria - } + ngOnInit() { + //this.refresh(); //called on ngAfterViewInit with default criteria + } - ngAfterViewInit() { - setTimeout(() => { - this.criteria.setRefreshCallback(() => this.refresh()); - this.criteria.setCriteria(this.getDefaultCriteria()); - this.criteria.controlModified(); - }); - } + ngAfterViewInit() { + setTimeout(() => { + this.criteria.setRefreshCallback(() => this.refresh()); + this.criteria.setCriteria(this.getDefaultCriteria()); + this.criteria.controlModified(); + }); + } - refresh() { - this.dataSource = new UsersDataSource(this.userService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, ); - } + refresh() { + this.dataSource = new UsersDataSource(this.userService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); + } - getDefaultCriteria(): UserCriteria { - const defaultCriteria = new UserCriteria(); - return defaultCriteria; - } + getDefaultCriteria(): UserCriteria { + const defaultCriteria = new UserCriteria(); + return defaultCriteria; + } } diff --git a/dmp-frontend/src/app/users/profile/user-profile.component.html b/dmp-frontend/src/app/users/profile/user-profile.component.html index 48336ea72..3c80a4002 100644 --- a/dmp-frontend/src/app/users/profile/user-profile.component.html +++ b/dmp-frontend/src/app/users/profile/user-profile.component.html @@ -1,90 +1,90 @@
- - -
-
- -
- {{userProfile.name}} - {{userProfile.email}} -
-
-
- - -
-
-

{{ 'USER-PROFILE.ASSOCIATED-DMPS' | translate}}

-
-
- - -
- {{ dmp.label }} -
-
- - {{ getUserRole(dmp) }} - -
-
-
- -
-
-
-
- - - -

{{ 'USER-PROFILE.SETTINGS.TITLE' | translate}}

- - -
-
- -
-
-
- - - - - {{ timezone | timezoneInfoDisplay }} - - - -
-
- - - - - {{ culture.displayName }} - {{ culture.nativeName }} - - - -
-
- - - - {{ language.label }} - - - -
-
-
-
-
+ + +
+
+ +
+ {{userProfile.name}} + {{userProfile.email}} +
+
+
+ + +
+
+

{{ 'USER-PROFILE.ASSOCIATED-DMPS' | translate}}

+
+
+ + +
+ {{ dmp.label }} +
+
+ + {{ getUserRole(dmp) }} + +
+
+
+ +
+
+
+
+ + + +

{{ 'USER-PROFILE.SETTINGS.TITLE' | translate}}

+ + +
+
+ +
+
+
+ + + + + {{ timezone | timezoneInfoDisplay }} + + + +
+
+ + + + + {{ culture.displayName }} - {{ culture.nativeName }} + + + +
+
+ + + + {{ language.label }} + + + +
+
+
+
+
diff --git a/dmp-frontend/src/app/users/profile/user-profile.component.ts b/dmp-frontend/src/app/users/profile/user-profile.component.ts index c5d6b4677..389b7c223 100644 --- a/dmp-frontend/src/app/users/profile/user-profile.component.ts +++ b/dmp-frontend/src/app/users/profile/user-profile.component.ts @@ -25,112 +25,111 @@ import { User } from '../../models/invitation/User'; const availableLanguages: any[] = require('../../../assets/resources/language.json'); @Component({ - selector: 'app-user-profile', - templateUrl: './user-profile.component.html', - styleUrls: ['./user-profile.component.scss'], - providers: [ - UserReferenceService, - CultureService - ] + selector: 'app-user-profile', + templateUrl: './user-profile.component.html', + styleUrls: ['./user-profile.component.scss'], + providers: [ + UserReferenceService, + CultureService + ] }) export class UserProfileComponent implements OnInit { - user: Observable; - currentUserId: string; - cultures: Observable; - timezones: Observable; - editMode = false; - languages = availableLanguages; + user: Observable; + currentUserId: string; + cultures: Observable; + timezones: Observable; + editMode = false; + languages = availableLanguages; - formGroup: FormGroup; - constructor( - private userReferenceService: UserReferenceService, - private route: ActivatedRoute, - private router: Router, - private authService: AuthService, - private language: TranslateService, - private cultureService: CultureService, - private translate: TranslateService, - ) { } + formGroup: FormGroup; + constructor( + private userReferenceService: UserReferenceService, + private route: ActivatedRoute, + private router: Router, + private authService: AuthService, + private language: TranslateService, + private cultureService: CultureService, + private translate: TranslateService, + ) { } - ngOnInit() { - this.route.params.subscribe((params: Params) => { - this.currentUserId = params['id']; - let userId = params['id'] === this.authService.current().id ? 'me' : params['id'] - this.user = this.userReferenceService.getUser(userId).map(result => { - result["additionalinfo"] = JSON.parse(result["additionalinfo"]); - this.formGroup = new FormBuilder().group({ - language: new FormControl(result["additionalinfo"]["language"] ? availableLanguages.filter(x => x.value === result["additionalinfo"]["language"]["value"]).pop() : ''), - timezone: new FormControl(result["additionalinfo"]["timezone"]), - culture: new FormControl(result["additionalinfo"]["culture"]) - }) - //this.formGroup.get('language').valueChanges.subscribe(x => { if (x) this.translate.use(x.value) }) - this.formGroup.get('timezone').valueChanges.subscribe(x => { if (x) this.timezones = this._filterTimezone(x) }); - this.formGroup.get('culture').valueChanges.subscribe(x => { if (x) this.cultures = this._filterCulture(x) }); - this.formGroup.disable() - return result; - }) - }) + ngOnInit() { + this.route.params.subscribe((params: Params) => { + this.currentUserId = params['id']; + const userId = params['id'] === this.authService.current().id ? 'me' : params['id']; + this.user = this.userReferenceService.getUser(userId).map(result => { + result['additionalinfo'] = JSON.parse(result['additionalinfo']); + this.formGroup = new FormBuilder().group({ + language: new FormControl(result['additionalinfo']['language'] ? availableLanguages.filter(x => x.value === result['additionalinfo']['language']['value']).pop() : ''), + timezone: new FormControl(result['additionalinfo']['timezone']), + culture: new FormControl(result['additionalinfo']['culture']) + }); + //this.formGroup.get('language').valueChanges.subscribe(x => { if (x) this.translate.use(x.value) }) + this.formGroup.get('timezone').valueChanges.subscribe(x => { if (x) { this.timezones = this._filterTimezone(x); } }); + this.formGroup.get('culture').valueChanges.subscribe(x => { if (x) { this.cultures = this._filterCulture(x); } }); + this.formGroup.disable(); + return result; + }); + }); - } + } - getUserRole(dmp: DataManagementPlanModel) { - if (dmp.creator.id === this.currentUserId) return this.language.instant('USER-PROFILE.DMPS.CREATOR') - else if (dmp.associatedUsers.map(x => x.id).indexOf(this.currentUserId) != -1) return this.language.instant('USER-PROFILE.DMPS.MEMBER'); - return '' - } + getUserRole(dmp: DataManagementPlanModel) { + if (dmp.creator.id === this.currentUserId) { return this.language.instant('USER-PROFILE.DMPS.CREATOR'); } else if (dmp.associatedUsers.map(x => x.id).indexOf(this.currentUserId) !== -1) { return this.language.instant('USER-PROFILE.DMPS.MEMBER'); } + return ''; + } - showAllDmps() { - this.router.navigate(["/dmps"]) - } + showAllDmps() { + this.router.navigate(['/dmps']); + } - navigateToDmp(dmp: DataManagementPlanModel) { - this.router.navigate(["/dmps/edit/" + dmp.id]) - } + navigateToDmp(dmp: DataManagementPlanModel) { + this.router.navigate(['/dmps/edit/' + dmp.id]); + } - private _filterTimezone(value: string): Observable { - if (value && typeof value === 'string') { - const filterValue = value.toLowerCase(); - return Observable.of(moment.tz.names().filter(option => option.toLowerCase().includes(filterValue))); - } else { - return Observable.of(moment.tz.names()); - } - } + private _filterTimezone(value: string): Observable { + if (value && typeof value === 'string') { + const filterValue = value.toLowerCase(); + return Observable.of(moment.tz.names().filter(option => option.toLowerCase().includes(filterValue))); + } else { + return Observable.of(moment.tz.names()); + } + } - private _filterCulture(value: string): Observable { - if (value && typeof value === 'string') { - const filterValue = value.toLowerCase(); - return Observable.of(this.cultureService.getCultureValues().filter(option => option.displayName.toLowerCase().includes(filterValue))); - } else { - return Observable.of(this.cultureService.getCultureValues()); - } - } + private _filterCulture(value: string): Observable { + if (value && typeof value === 'string') { + const filterValue = value.toLowerCase(); + return Observable.of(this.cultureService.getCultureValues().filter(option => option.displayName.toLowerCase().includes(filterValue))); + } else { + return Observable.of(this.cultureService.getCultureValues()); + } + } - displayFn(culture?: CultureInfo): string | undefined { - return culture ? culture.displayName + '-' + culture.nativeName : undefined; - } + displayFn(culture?: CultureInfo): string | undefined { + return culture ? culture.displayName + '-' + culture.nativeName : undefined; + } - save() { + save() { - } + } - public unlock() { - this.editMode = true; - this.formGroup.enable() - } + public unlock() { + this.editMode = true; + this.formGroup.enable(); + } - public lock() { - this.userReferenceService.updateUserSettings(this.formGroup.value).subscribe( - x => { - this.editMode = false; - this.translate.use(this.formGroup.value.language) - this.authService.current().culture = this.formGroup.value.culture.name - this.formGroup.disable(); - this.authService.me().subscribe(x=> window.location.reload()) - }, - error => { - console.log(error) - }) - } + public lock() { + this.userReferenceService.updateUserSettings(this.formGroup.value).subscribe( + x => { + this.editMode = false; + this.translate.use(this.formGroup.value.language); + this.authService.current().culture = this.formGroup.value.culture.name; + this.formGroup.disable(); + this.authService.me().subscribe(result => window.location.reload()); + }, + error => { + console.log(error); + }); + } } diff --git a/dmp-frontend/src/app/users/users.module.ts b/dmp-frontend/src/app/users/users.module.ts index e945776ac..e7a8e3f6f 100644 --- a/dmp-frontend/src/app/users/users.module.ts +++ b/dmp-frontend/src/app/users/users.module.ts @@ -20,47 +20,47 @@ import { UserProfileComponent } from './profile/user-profile.component'; import { TimezoneInfoDisplayPipe } from '../utilities/culture/pipes/TimezoneInfoDisplayPipe'; @NgModule({ - imports: [ - CommonModule, - SharedModule, - BaseHttpModule.forRoot(), + imports: [ + CommonModule, + SharedModule, + BaseHttpModule.forRoot(), - RouterModule.forChild(UsersRoutes), - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useFactory: HttpLoaderFactory, - deps: [HttpClient] - } - }), - ReactiveFormsModule, - MaterialModule - ], + RouterModule.forChild(UsersRoutes), + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + ReactiveFormsModule, + MaterialModule + ], - declarations: [ - UsersComponent, - UsersCriteriaComponent, - UserRoleEditorComponent, - UserProfileComponent, - TimezoneInfoDisplayPipe - ], - providers: [ - BaseHttpService, - UserReferenceService - ], - exports: [ - UsersComponent + declarations: [ + UsersComponent, + UsersCriteriaComponent, + UserRoleEditorComponent, + UserProfileComponent, + TimezoneInfoDisplayPipe + ], + providers: [ + BaseHttpService, + UserReferenceService + ], + exports: [ + UsersComponent - ] + ] }) export class UsersModule { - constructor(private translate: TranslateService) { - translate.setDefaultLang('en'); - translate.use('en'); - } + constructor(private translate: TranslateService) { + translate.setDefaultLang('en'); + translate.use('en'); + } } export function HttpLoaderFactory(httpClient: HttpClient) { - return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); + return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); } diff --git a/dmp-frontend/src/app/users/users.routes.ts b/dmp-frontend/src/app/users/users.routes.ts index 1babd1d4f..8cbaae4f3 100644 --- a/dmp-frontend/src/app/users/users.routes.ts +++ b/dmp-frontend/src/app/users/users.routes.ts @@ -3,6 +3,6 @@ import { UsersComponent } from './components/users.component'; import { UserProfileComponent } from './profile/user-profile.component'; export const UsersRoutes: Routes = [ - { path: '', component: UsersComponent }, - { path: ':id', component: UserProfileComponent } + { path: '', component: UsersComponent }, + { path: ':id', component: UserProfileComponent } ]; diff --git a/dmp-frontend/src/app/utilities/JsonSerializer.ts b/dmp-frontend/src/app/utilities/JsonSerializer.ts index 705a7eee1..b7c502484 100644 --- a/dmp-frontend/src/app/utilities/JsonSerializer.ts +++ b/dmp-frontend/src/app/utilities/JsonSerializer.ts @@ -1,22 +1,22 @@ import { Serializable } from '../models/interfaces/Serializable'; export class JsonSerializer { - public static fromJSONArray>(items: any[], type: { new(): T; }): T[] { - if (!items) return new Array(); - const objectList: T[] = new Array(); - for (let i = 0; i < items.length; i++) { - objectList.push(new type().fromJSONObject(items[i])) - } - return objectList; - } + public static fromJSONArray>(items: any[], type: { new(): T; }): T[] { + if (!items) { return new Array(); } + const objectList: T[] = new Array(); + for (let i = 0; i < items.length; i++) { + objectList.push(new type().fromJSONObject(items[i])); + } + return objectList; + } - public static fromJSONObject>(item: any, type: { new(): T; }): T { - if (!item) return null; - return new type().fromJSONObject(item); - } + public static fromJSONObject>(item: any, type: { new(): T; }): T { + if (!item) { return null; } + return new type().fromJSONObject(item); + } - public static copy>(item: any, itemToCopy: any): T { - if (!item) return null; - return item.fromJSONObject(itemToCopy); - } + public static copy>(item: any, itemToCopy: any): T { + if (!item) { return null; } + return item.fromJSONObject(itemToCopy); + } } diff --git a/dmp-frontend/src/app/utilities/UrlUtilities.ts b/dmp-frontend/src/app/utilities/UrlUtilities.ts index 3ae4a39c5..91ec68a07 100644 --- a/dmp-frontend/src/app/utilities/UrlUtilities.ts +++ b/dmp-frontend/src/app/utilities/UrlUtilities.ts @@ -1,17 +1,17 @@ -import { Injectable } from "@angular/core"; +import { Injectable } from '@angular/core'; @Injectable() export class UrlUtilities { - public applyUrlTemplate(url: string, params: any): string { - let paramsToString = ""; - if (params) paramsToString = "?" - let keys = Object.keys(params); - keys.forEach(x => { - if (keys.indexOf(x) > 0) paramsToString += "&" - paramsToString += x + "=" + params[x]; - }) - return url + paramsToString; - } + public applyUrlTemplate(url: string, params: any): string { + let paramsToString = ''; + if (params) { paramsToString = '?'; } + const keys = Object.keys(params); + keys.forEach(x => { + if (keys.indexOf(x) > 0) { paramsToString += '&'; } + paramsToString += x + '=' + params[x]; + }); + return url + paramsToString; + } } diff --git a/dmp-frontend/src/app/utilities/cite-http-service-module/base-http.service.ts b/dmp-frontend/src/app/utilities/cite-http-service-module/base-http.service.ts index 7f9182cab..59e22513c 100644 --- a/dmp-frontend/src/app/utilities/cite-http-service-module/base-http.service.ts +++ b/dmp-frontend/src/app/utilities/cite-http-service-module/base-http.service.ts @@ -14,124 +14,120 @@ import { ApiResponseCode } from '../../utilities/types/ApiResponseCode'; @Injectable() export class BaseHttpService { - constructor( - protected http: HttpClient, - private router: Router, - private authService: AuthService, - public language: TranslateService, - public snackBar: MatSnackBar, - public route: ActivatedRoute - ) { - } - get(url: string, options?: any, appendOptions: boolean = true): Observable { - return this.interceptRepsonse(this.http.get(url, this.buildRequestOptions(appendOptions, options))); - } - post(url: string, body: any, options?: any, appendOptions: boolean = true): Observable { - return this.interceptRepsonse(this.http.post(url, body, this.buildRequestOptions(appendOptions, options))); - } - put(url: string, body: any, options?: any, appendOptions: boolean = true): Observable { - return this.interceptRepsonse(this.http.put(url, body, this.buildRequestOptions(appendOptions, options))); - } - delete(url: string, options?: any, appendOptions: boolean = true): Observable { - return this.interceptRepsonse(this.http.delete(url, this.buildRequestOptions(appendOptions, options))); - } - patch(url: string, body: any, options?: any, appendOptions: boolean = true): Observable { - return this.interceptRepsonse(this.http.patch(url, body, this.buildRequestOptions(appendOptions, options))); - } - head(url: string, options?: any, appendOptions: boolean = true): Observable { - return this.interceptRepsonse(this.http.head(url, this.buildRequestOptions(appendOptions, options))); - } - options(url: string, options?: any, appendOptions: boolean = true): Observable { - return this.interceptRepsonse(this.http.options(url, this.buildRequestOptions(appendOptions, options))); - } + constructor( + protected http: HttpClient, + private router: Router, + private authService: AuthService, + public language: TranslateService, + public snackBar: MatSnackBar, + public route: ActivatedRoute + ) { + } + get(url: string, options?: any, appendOptions: boolean = true): Observable { + return this.interceptRepsonse(this.http.get(url, this.buildRequestOptions(appendOptions, options))); + } + post(url: string, body: any, options?: any, appendOptions: boolean = true): Observable { + return this.interceptRepsonse(this.http.post(url, body, this.buildRequestOptions(appendOptions, options))); + } + put(url: string, body: any, options?: any, appendOptions: boolean = true): Observable { + return this.interceptRepsonse(this.http.put(url, body, this.buildRequestOptions(appendOptions, options))); + } + delete(url: string, options?: any, appendOptions: boolean = true): Observable { + return this.interceptRepsonse(this.http.delete(url, this.buildRequestOptions(appendOptions, options))); + } + patch(url: string, body: any, options?: any, appendOptions: boolean = true): Observable { + return this.interceptRepsonse(this.http.patch(url, body, this.buildRequestOptions(appendOptions, options))); + } + head(url: string, options?: any, appendOptions: boolean = true): Observable { + return this.interceptRepsonse(this.http.head(url, this.buildRequestOptions(appendOptions, options))); + } + options(url: string, options?: any, appendOptions: boolean = true): Observable { + return this.interceptRepsonse(this.http.options(url, this.buildRequestOptions(appendOptions, options))); + } - protected buildRequestOptions(appendOptions: boolean, options?: any): Object { - if (options == null) { - options = new RequestOptions(); - } - if (options.headers == null) { - options.headers = new Headers(); - } - if (!options.headers.has('Content-Type') && appendOptions) { - options.headers = options.headers.set('Content-Type', 'application/json'); - } - if (!options.headers.has('Content-Type') && appendOptions) { - options.headers = options.headers.set('Content-Type', 'application/json'); - } - if (!options.headers.has('AuthToken')) { - const principal = this.authService.current(); - if (principal) { - options.headers = options.headers.set('AuthToken', principal.token); - } - } + protected buildRequestOptions(appendOptions: boolean, options?: any): Object { + if (options == null) { + options = new RequestOptions(); + } + if (options.headers == null) { + options.headers = new Headers(); + } + if (!options.headers.has('Content-Type') && appendOptions) { + options.headers = options.headers.set('Content-Type', 'application/json'); + } + if (!options.headers.has('Content-Type') && appendOptions) { + options.headers = options.headers.set('Content-Type', 'application/json'); + } + if (!options.headers.has('AuthToken')) { + const principal = this.authService.current(); + if (principal) { + options.headers = options.headers.set('AuthToken', principal.token); + } + } - return options; - } + return options; + } - private interceptRepsonse(observable: Observable): Observable { - return observable - .catch((errorResponse) => { - if (errorResponse.status === 401) { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT', language: this.language }, - duration: 3000, - }) - let currentPage = this.router.url; - this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: currentPage } }); - //this.notification.httpError(error); - return Observable.of(); - } else { - let error: any = errorResponse.error - if (error.statusCode == ApiMessageCode.ERROR_MESSAGE) { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: error.message, language: null }, - duration: 3000, - }) - return Observable.throw(errorResponse); - } - else if (error.statusCode == ApiMessageCode.VALIDATION_MESSAGE) { - return Observable.throw(errorResponse); - } - else { - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: 'GENERAL.ERRORS.HTTP-REQUEST-ERROR', language: this.language }, - duration: 3000, - }) - return Observable.throw(errorResponse); - } - } - }) - .map(response => { - if (response instanceof Blob) return response - if (response["statusCode"] == ApiMessageCode.SUCCESS_MESSAGE) { - //throw new Error('Request failed'); - this.snackBar.openFromComponent(SnackBarNotificationComponent, { - data: { message: response["message"], language: null }, - duration: 3000, - }) - return response["payload"]; + private interceptRepsonse(observable: Observable): Observable { + return observable + .catch((errorResponse) => { + if (errorResponse.status === 401) { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT', language: this.language }, + duration: 3000, + }); + const currentPage = this.router.url; + this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: currentPage } }); + //this.notification.httpError(error); + return Observable.of(); + } else { + const error: any = errorResponse.error; + if (error.statusCode === ApiMessageCode.ERROR_MESSAGE) { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: error.message, language: null }, + duration: 3000, + }); + return Observable.throw(errorResponse); + } else if (error.statusCode === ApiMessageCode.VALIDATION_MESSAGE) { + return Observable.throw(errorResponse); + } else { + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.ERRORS.HTTP-REQUEST-ERROR', language: this.language }, + duration: 3000, + }); + return Observable.throw(errorResponse); + } + } + }) + .map(response => { + if (response instanceof Blob) { return response; } + if (response['statusCode'] === ApiMessageCode.SUCCESS_MESSAGE) { + //throw new Error('Request failed'); + this.snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: response['message'], language: null }, + duration: 3000, + }); + return response['payload']; - } - else if (response["statusCode"] == ApiMessageCode.NO_MESSAGE) { - return response["payload"]; - } - else { - return response["payload"]; - } - }); - } + } else if (response['statusCode'] === ApiMessageCode.NO_MESSAGE) { + return response['payload']; + } else { + return response['payload']; + } + }); + } - // public handleResponse(response: BaseHttpResponseModel) { - // if (response.statusCode < 200 || response.statusCode >= 300) { - // //throw new Error('Request failed'); - // this.snackBar.openFromComponent(SnackBarNotificationComponent, { - // data: { message: 'GENERAL.ERRORS.HTTP-REQUEST-ERROR', language: this.language }, - // duration: 3000, - // extraClasses: ['snackbar-warning'] - // }) - // } - // else { - // return response.payload; - // } - // } + // public handleResponse(response: BaseHttpResponseModel) { + // if (response.statusCode < 200 || response.statusCode >= 300) { + // //throw new Error('Request failed'); + // this.snackBar.openFromComponent(SnackBarNotificationComponent, { + // data: { message: 'GENERAL.ERRORS.HTTP-REQUEST-ERROR', language: this.language }, + // duration: 3000, + // extraClasses: ['snackbar-warning'] + // }) + // } + // else { + // return response.payload; + // } + // } } diff --git a/dmp-frontend/src/app/utilities/cite-http-service-module/cite-http.module.ts b/dmp-frontend/src/app/utilities/cite-http-service-module/cite-http.module.ts index 073fc064b..d4e9c4a92 100644 --- a/dmp-frontend/src/app/utilities/cite-http-service-module/cite-http.module.ts +++ b/dmp-frontend/src/app/utilities/cite-http-service-module/cite-http.module.ts @@ -7,19 +7,19 @@ import { HttpLoaderFactory } from '../../projects/projects.module'; import { HttpClient, HttpClientModule } from '@angular/common/http'; @NgModule({ - imports: [ - CommonModule, - HttpClientModule - ] + imports: [ + CommonModule, + HttpClientModule + ] }) export class BaseHttpModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: BaseHttpModule, - providers: [ - AuthService, - BaseHttpService - ] - }; - } + static forRoot(): ModuleWithProviders { + return { + ngModule: BaseHttpModule, + providers: [ + AuthService, + BaseHttpService + ] + }; + } } diff --git a/dmp-frontend/src/app/utilities/culture/culture-service.ts b/dmp-frontend/src/app/utilities/culture/culture-service.ts index 7b1204fc4..46b49ec47 100644 --- a/dmp-frontend/src/app/utilities/culture/culture-service.ts +++ b/dmp-frontend/src/app/utilities/culture/culture-service.ts @@ -9,68 +9,68 @@ const availableCultures: CultureInfo[] = require('../../../assets/resources/avai @Injectable() export class CultureService { - private cultureValues = new Map(); // cultures by name - private cultureChangeSubject = new Subject(); - private currentCulture: CultureInfo; + private cultureValues = new Map(); // cultures by name + private cultureChangeSubject = new Subject(); + private currentCulture: CultureInfo; - constructor( - private authService: AuthService - ) { - if (availableCultures) { - this.cultureValues = new Map(); - availableCultures.forEach(culture => { - this.cultureValues.set(culture.name, culture); - }); - } - } + constructor( + private authService: AuthService + ) { + if (availableCultures) { + this.cultureValues = new Map(); + availableCultures.forEach(culture => { + this.cultureValues.set(culture.name, culture); + }); + } + } - getCultureValues(): CultureInfo[] { - const values: CultureInfo[] = []; - this.cultureValues.forEach((value) => values.push(value)); - return values; - } + getCultureValues(): CultureInfo[] { + const values: CultureInfo[] = []; + this.cultureValues.forEach((value) => values.push(value)); + return values; + } - getCultureValue(culture: string): CultureInfo | undefined { - return this.cultureValues.get(culture); - } + getCultureValue(culture: string): CultureInfo | undefined { + return this.cultureValues.get(culture); + } - cultureSelected(culture: string | CultureInfo) { - let newCultureName: string; - if (typeof culture == 'string') { - if (this.currentCulture && this.currentCulture.name === culture) { return; } - newCultureName = culture; - } else { - if (this.currentCulture && this.currentCulture.name === culture.name) { return; } - newCultureName = culture.name; - } + cultureSelected(culture: string | CultureInfo) { + let newCultureName: string; + if (typeof culture === 'string') { + if (this.currentCulture && this.currentCulture.name === culture) { return; } + newCultureName = culture; + } else { + if (this.currentCulture && this.currentCulture.name === culture.name) { return; } + newCultureName = culture.name; + } - const newCulture = this.cultureValues.get(newCultureName); - if (!newCulture) { - console.error(`unsupported culture given: ${newCultureName}`); //TODO: throw error? - return; - } - this.currentCulture = newCulture; - this.cultureChangeSubject.next(newCulture); + const newCulture = this.cultureValues.get(newCultureName); + if (!newCulture) { + console.error(`unsupported culture given: ${newCultureName}`); //TODO: throw error? + return; + } + this.currentCulture = newCulture; + this.cultureChangeSubject.next(newCulture); - // Set angular locale based on user selection. - let locale = newCulture.name - import(`@angular/common/locales/${locale}.js`).catch(reason => { - console.warn('Could not load locale: ' + locale); - locale = newCulture.name.split('-')[0]; - console.debug('Will try ' + locale); - return import(`@angular/common/locales/${locale}.js`).catch(reason => { - console.error('Could not load locale: ' + locale) - }); - }).then(selectedLocale => { - registerLocaleData(selectedLocale.default); - }); - } + // Set angular locale based on user selection. + let locale = newCulture.name; + import(`@angular/common/locales/${locale}.js`).catch(reason => { + console.warn('Could not load locale: ' + locale); + locale = newCulture.name.split('-')[0]; + console.warn('Will try ' + locale); + return import(`@angular/common/locales/${locale}.js`).catch(resutl => { + console.error('Could not load locale: ' + locale); + }); + }).then(selectedLocale => { + registerLocaleData(selectedLocale.default); + }); + } - getCultureChangeObservable(): Observable { - return this.cultureChangeSubject.asObservable(); - } + getCultureChangeObservable(): Observable { + return this.cultureChangeSubject.asObservable(); + } - getCurrentCulture(): String { - return this.authService.current() && this.authService.current().culture ? this.authService.current().culture : this.currentCulture.name; - } + getCurrentCulture(): String { + return this.authService.current() && this.authService.current().culture ? this.authService.current().culture : this.currentCulture.name; + } } diff --git a/dmp-frontend/src/app/utilities/culture/models/culture-info.ts b/dmp-frontend/src/app/utilities/culture/models/culture-info.ts index c3afee24a..d365c5974 100644 --- a/dmp-frontend/src/app/utilities/culture/models/culture-info.ts +++ b/dmp-frontend/src/app/utilities/culture/models/culture-info.ts @@ -1,5 +1,5 @@ export class CultureInfo { - public name: string; - public displayName: string; - public nativeName: string; + public name: string; + public displayName: string; + public nativeName: string; } diff --git a/dmp-frontend/src/app/utilities/culture/pipes/TimezoneInfoDisplayPipe.ts b/dmp-frontend/src/app/utilities/culture/pipes/TimezoneInfoDisplayPipe.ts index aa88e27e1..70eb69143 100644 --- a/dmp-frontend/src/app/utilities/culture/pipes/TimezoneInfoDisplayPipe.ts +++ b/dmp-frontend/src/app/utilities/culture/pipes/TimezoneInfoDisplayPipe.ts @@ -4,9 +4,9 @@ import 'moment-timezone'; @Pipe({ name: 'timezoneInfoDisplay' }) export class TimezoneInfoDisplayPipe implements PipeTransform { - constructor() { } + constructor() { } - public transform(value): any { - return value + ' (GMT' + moment["tz"](value).format('Z') + ')'; - } + public transform(value): any { + return value + ' (GMT' + moment['tz'](value).format('Z') + ')'; + } } diff --git a/dmp-frontend/src/app/utilities/forms/FormGenerator.ts b/dmp-frontend/src/app/utilities/forms/FormGenerator.ts index a30da24a8..c253af2e6 100644 --- a/dmp-frontend/src/app/utilities/forms/FormGenerator.ts +++ b/dmp-frontend/src/app/utilities/forms/FormGenerator.ts @@ -1,6 +1,6 @@ -import { ValidationContext } from "../validators/ValidationContext"; -import { FormGroup } from "@angular/forms"; +import { ValidationContext } from '../validators/ValidationContext'; +import { FormGroup } from '@angular/forms'; export interface FormGenerator { buildForm(validation: ValidationContext, disabled?: boolean): FormGroup; -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/utilities/types/ApiMessageCode.ts b/dmp-frontend/src/app/utilities/types/ApiMessageCode.ts index c9c9b931f..1d8c31779 100644 --- a/dmp-frontend/src/app/utilities/types/ApiMessageCode.ts +++ b/dmp-frontend/src/app/utilities/types/ApiMessageCode.ts @@ -1,9 +1,8 @@ export enum ApiMessageCode { - NO_MESSAGE = 0, - SUCCESS_MESSAGE = 200, - WARN_MESSAGE = 300, - ERROR_MESSAGE = 400, - DEFAULT_ERROR_MESSAGE = 444, - VALIDATION_MESSAGE = 445 - -} \ No newline at end of file + NO_MESSAGE = 0, + SUCCESS_MESSAGE = 200, + WARN_MESSAGE = 300, + ERROR_MESSAGE = 400, + DEFAULT_ERROR_MESSAGE = 444, + VALIDATION_MESSAGE = 445 +} diff --git a/dmp-frontend/src/app/utilities/types/ApiResponseCode.ts b/dmp-frontend/src/app/utilities/types/ApiResponseCode.ts index fa650dc3b..bb64a7ef5 100644 --- a/dmp-frontend/src/app/utilities/types/ApiResponseCode.ts +++ b/dmp-frontend/src/app/utilities/types/ApiResponseCode.ts @@ -1,4 +1,4 @@ export enum ApiResponseCode { - JSON_RESPONSE = 0, - FILE_RESPONSE = 1, -} \ No newline at end of file + JSON_RESPONSE = 0, + FILE_RESPONSE = 1, +} diff --git a/dmp-frontend/src/app/utilities/utilities.ts b/dmp-frontend/src/app/utilities/utilities.ts index c001d917c..bbdcbd008 100644 --- a/dmp-frontend/src/app/utilities/utilities.ts +++ b/dmp-frontend/src/app/utilities/utilities.ts @@ -8,37 +8,37 @@ import { TranslateService } from '@ngx-translate/core'; @Injectable() export class Utilities { - constructor(private language: TranslateService) { + constructor(private language: TranslateService) { - } + } - convertFromPrincipalAppRole(status: Principal.AppRole): string { - switch (status) { - case Principal.AppRole.Admin: return 'TYPES.APP-ROLE.ADMIN' - case Principal.AppRole.User: return 'TYPES.APP-ROLE.USER' - case Principal.AppRole.Manager: return 'TYPES.APP-ROLE.MANAGER' - } - } + convertFromPrincipalAppRole(status: Principal.AppRole): string { + switch (status) { + case Principal.AppRole.Admin: return 'TYPES.APP-ROLE.ADMIN'; + case Principal.AppRole.User: return 'TYPES.APP-ROLE.USER'; + case Principal.AppRole.Manager: return 'TYPES.APP-ROLE.MANAGER'; + } + } - convertFromDMPProfileDataType(type: DMPProfileFieldDataType): string { - switch (type) { - case DMPProfileFieldDataType.DATE: return 'TYPES.DMP-PROFILE-FIELD.DATA-TYPE.DATE' - case DMPProfileFieldDataType.NUMBER: return 'TYPES.DMP-PROFILE-FIELD.DATA-TYPE.NUMBER' - case DMPProfileFieldDataType.TEXT: return 'TYPES.DMP-PROFILE-FIELD.DATA-TYPE.TEXT' - } - } + convertFromDMPProfileDataType(type: DMPProfileFieldDataType): string { + switch (type) { + case DMPProfileFieldDataType.DATE: return 'TYPES.DMP-PROFILE-FIELD.DATA-TYPE.DATE'; + case DMPProfileFieldDataType.NUMBER: return 'TYPES.DMP-PROFILE-FIELD.DATA-TYPE.NUMBER'; + case DMPProfileFieldDataType.TEXT: return 'TYPES.DMP-PROFILE-FIELD.DATA-TYPE.TEXT'; + } + } - convertFromDMPProfileType(type: DMPProfileType): string { - switch (type) { - case DMPProfileType.INPUT: return 'TYPES.DMP-PROFILE-FIELD.TYPE.INPUT' - } - } + convertFromDMPProfileType(type: DMPProfileType): string { + switch (type) { + case DMPProfileType.INPUT: return 'TYPES.DMP-PROFILE-FIELD.TYPE.INPUT'; + } + } - convertFromDatasetStatus(status: DatasetStatus): string { - switch (status) { - case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT') - case DatasetStatus.Finalised: return this.language.instant('TYPES.DATASET-STATUS.FINALISED') - } + convertFromDatasetStatus(status: DatasetStatus): string { + switch (status) { + case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT'); + case DatasetStatus.Finalised: return this.language.instant('TYPES.DATASET-STATUS.FINALISED'); + } - } + } } diff --git a/dmp-frontend/src/app/utilities/validators/ValidationContext.ts b/dmp-frontend/src/app/utilities/validators/ValidationContext.ts index ef3528ff2..37b831bb5 100644 --- a/dmp-frontend/src/app/utilities/validators/ValidationContext.ts +++ b/dmp-frontend/src/app/utilities/validators/ValidationContext.ts @@ -1,20 +1,20 @@ import { ValidatorFn } from '@angular/forms'; export class ValidationContext { - validation: Validation[] = []; + validation: Validation[] = []; - getValidation(key: string): Validation { - for (let i = 0; i < this.validation.length; i++) { - if (this.validation[i].key === key) { - return this.validation[i]; - } - } - throw new Error('Key Was Not Found In The Validation Context'); - } + getValidation(key: string): Validation { + for (let i = 0; i < this.validation.length; i++) { + if (this.validation[i].key === key) { + return this.validation[i]; + } + } + throw new Error('Key Was Not Found In The Validation Context'); + } } export class Validation { - key: string; - validators?: ValidatorFn[] = new Array(); - descendantValidations?: ValidationContext; + key: string; + validators?: ValidatorFn[] = new Array(); + descendantValidations?: ValidationContext; } diff --git a/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRule.ts b/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRule.ts index 56051bd71..0a1958e25 100644 --- a/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRule.ts +++ b/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRule.ts @@ -1,5 +1,5 @@ import { VisibilityRuleSource } from './VisibilityRuleSource'; export class VisibilityRule { - public targetControlId: string; - public sourceVisibilityRules: Array -} \ No newline at end of file + public targetControlId: string; + public sourceVisibilityRules: Array; +} diff --git a/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRuleSource.ts b/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRuleSource.ts index 90ac1a6c1..2db9978a3 100644 --- a/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRuleSource.ts +++ b/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRuleSource.ts @@ -1,4 +1,4 @@ -export class VisibilityRuleSource{ - public sourceControlId:string; - public sourceControlValue:string; -} \ No newline at end of file +export class VisibilityRuleSource { + public sourceControlId: string; + public sourceControlValue: string; +} diff --git a/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRulesContext.ts b/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRulesContext.ts index eb8541f68..22d5f3f75 100644 --- a/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRulesContext.ts +++ b/dmp-frontend/src/app/utilities/visibility-rules/models/VisibilityRulesContext.ts @@ -6,27 +6,27 @@ export class VisibilityRulesContext { public getRulesFromKey(id: string): VisibilityRule { - for (let i = 0; i < this.rules.length; i++) { - if (id == this.rules[i].targetControlId) return this.rules[i] - } - return null; + for (let i = 0; i < this.rules.length; i++) { + if (id === this.rules[i].targetControlId) { return this.rules[i]; } + } + return null; } public buildVisibilityRuleContext(items: Array) { - items.forEach(item => { - this.addToVisibilityRulesContext(item) - }); + items.forEach(item => { + this.addToVisibilityRulesContext(item); + }); } private addToVisibilityRulesContext(item: Rule): void { - for (let i = 0; i < this.rules.length; i++) { - if (this.rules[i].targetControlId == item.targetField) { - this.rules[i].sourceVisibilityRules.push({ sourceControlId: item.sourceField, sourceControlValue: item.requiredValue }); - return; - } - } - let newVisibilityRuleArray = [({ sourceControlId: item.sourceField, sourceControlValue: item.requiredValue })]; - this.rules.push({ targetControlId: item.targetField, sourceVisibilityRules: newVisibilityRuleArray }) - return; + for (let i = 0; i < this.rules.length; i++) { + if (this.rules[i].targetControlId === item.targetField) { + this.rules[i].sourceVisibilityRules.push({ sourceControlId: item.sourceField, sourceControlValue: item.requiredValue }); + return; + } + } + const newVisibilityRuleArray = [({ sourceControlId: item.sourceField, sourceControlValue: item.requiredValue })]; + this.rules.push({ targetControlId: item.targetField, sourceVisibilityRules: newVisibilityRuleArray }); + return; } } diff --git a/dmp-frontend/src/app/utilities/visibility-rules/visibility-rules.service.ts b/dmp-frontend/src/app/utilities/visibility-rules/visibility-rules.service.ts index 3528fa7c1..08b80f59f 100644 --- a/dmp-frontend/src/app/utilities/visibility-rules/visibility-rules.service.ts +++ b/dmp-frontend/src/app/utilities/visibility-rules/visibility-rules.service.ts @@ -8,141 +8,142 @@ import { JsonSerializer } from '../JsonSerializer'; @Injectable() export class VisibilityRulesService { - public formGroup: FormGroup; - public visibilityRuleContext: VisibilityRulesContext; - public fieldsPathMemory: any = {}; - private elementVisibilityMap = new Map(); - private initialModel: DatasetProfileDefinitionModel; - private currentModel: DatasetProfileDefinitionModel; + public formGroup: FormGroup; + public visibilityRuleContext: VisibilityRulesContext; + public fieldsPathMemory: any = {}; + private elementVisibilityMap = new Map(); + private initialModel: DatasetProfileDefinitionModel; + private currentModel: DatasetProfileDefinitionModel; - constructor(public applicationReference: ApplicationRef, public ngZone: NgZone) { + constructor(public applicationReference: ApplicationRef, public ngZone: NgZone) { - } + } - public setModel(model: DatasetProfileDefinitionModel) { - this.initialModel = JsonSerializer.fromJSONObject(model, DatasetProfileDefinitionModel); - this.currentModel = model - //this.visibilityRuleContext.rules.forEach(item => this.evaluateVisibility(item)) - } + public setModel(model: DatasetProfileDefinitionModel) { + this.initialModel = JsonSerializer.fromJSONObject(model, DatasetProfileDefinitionModel); + this.currentModel = model; + //this.visibilityRuleContext.rules.forEach(item => this.evaluateVisibility(item)) + } - public triggerVisibilityEvaluation() { - this.visibilityRuleContext.rules.forEach(item => this.evaluateVisibility(item)) - } + public triggerVisibilityEvaluation() { + this.visibilityRuleContext.rules.forEach(item => this.evaluateVisibility(item)); + } - public getFormGroup(id: string): FormGroup { - let pathKeyArray = this.search("pages", this.initialModel.pages, id).split(".") + public getFormGroup(id: string): FormGroup { + const pathKeyArray = this.search('pages', this.initialModel.pages, id).split('.'); - pathKeyArray.pop(); - let pathKey = pathKeyArray.join("."); - if (!this.fieldsPathMemory[id] && pathKey) this.fieldsPathMemory[id] = pathKey; - return (this.formGroup.get(pathKey)); - } + pathKeyArray.pop(); + const pathKey = pathKeyArray.join('.'); + if (!this.fieldsPathMemory[id] && pathKey) { this.fieldsPathMemory[id] = pathKey; } + return (this.formGroup.get(pathKey)); + } - public checkElementVisibility(id: string): boolean { - if (!this.elementVisibilityMap.has(id) || this.elementVisibilityMap.get(id)) return true; - else return false; - } + public checkElementVisibility(id: string): boolean { + if (!this.elementVisibilityMap.has(id) || this.elementVisibilityMap.get(id)) { return true; } else { return false; } + } - public buildVisibilityRules(item: Array) { - this.visibilityRuleContext = new VisibilityRulesContext(); - this.visibilityRuleContext.buildVisibilityRuleContext(item); - } + public buildVisibilityRules(item: Array) { + this.visibilityRuleContext = new VisibilityRulesContext(); + this.visibilityRuleContext.buildVisibilityRuleContext(item); + } - public updateValueAndVisibility(id: string) { - let visibilityRules = this.visibilityRuleContext.rules.filter(item => item.sourceVisibilityRules.filter(source => source.sourceControlId === id).length > 0); - visibilityRules.forEach(item => this.evaluateVisibility(item)) - } + public updateValueAndVisibility(id: string) { + const visibilityRules = this.visibilityRuleContext.rules.filter(item => item.sourceVisibilityRules.filter(source => source.sourceControlId === id).length > 0); + visibilityRules.forEach(item => this.evaluateVisibility(item)); + } - private evaluateVisibility(visibilityRule: VisibilityRule) { - for (let i = 0; i < visibilityRule.sourceVisibilityRules.length; i++) { - let pathKey = this.fieldsPathMemory[visibilityRule.sourceVisibilityRules[i].sourceControlId]; - if (this.formGroup.get(pathKey + '.value') && ((this.formGroup.get(pathKey + '.value').value == null || this.formGroup.get(pathKey + '.value').value == null) || "" + this.formGroup.get(pathKey + '.value').value != "" + visibilityRule.sourceVisibilityRules[i].sourceControlValue)) { - if (this.formGroup.get(pathKey).parent.get("id")) { - if (!this.checkElementVisibility(this.formGroup.get(pathKey).parent.get("id").value)) { - let targetPathKey = this.fieldsPathMemory[visibilityRule.targetControlId] - this.getObject(this.currentModel, "id", visibilityRule.targetControlId, this.currentModel, true) - this.elementVisibilityMap.set(visibilityRule.targetControlId, false) - this.clearValues(targetPathKey) - return; - } - } - else { - let targetPathKey = this.fieldsPathMemory[visibilityRule.targetControlId] - this.getObject(this.currentModel, "id", visibilityRule.targetControlId, this.currentModel, true) - this.elementVisibilityMap.set(visibilityRule.targetControlId, false) - this.clearValues(targetPathKey) - return; - } - } - } - let obj = this.getObject(this.initialModel, "id", visibilityRule.targetControlId, this.initialModel) - let targetObjPathKey = this.fieldsPathMemory[visibilityRule.targetControlId] ? this.fieldsPathMemory[visibilityRule.targetControlId] : this.search("pages", this.initialModel.pages, obj); - this.updateValue(this.currentModel, obj, targetObjPathKey) - this.elementVisibilityMap.set(visibilityRule.targetControlId, true) - } + private evaluateVisibility(visibilityRule: VisibilityRule) { + for (let i = 0; i < visibilityRule.sourceVisibilityRules.length; i++) { + const pathKey = this.fieldsPathMemory[visibilityRule.sourceVisibilityRules[i].sourceControlId]; + if (this.formGroup.get(pathKey + '.value') && ((this.formGroup.get(pathKey + '.value').value == null || this.formGroup.get(pathKey + '.value').value == null) || '' + this.formGroup.get(pathKey + '.value').value !== '' + visibilityRule.sourceVisibilityRules[i].sourceControlValue)) { + if (this.formGroup.get(pathKey).parent.get('id')) { + if (!this.checkElementVisibility(this.formGroup.get(pathKey).parent.get('id').value)) { + const targetPathKey = this.fieldsPathMemory[visibilityRule.targetControlId]; + this.getObject(this.currentModel, 'id', visibilityRule.targetControlId, this.currentModel, true); + this.elementVisibilityMap.set(visibilityRule.targetControlId, false); + this.clearValues(targetPathKey); + return; + } + } else { + const targetPathKey = this.fieldsPathMemory[visibilityRule.targetControlId]; + this.getObject(this.currentModel, 'id', visibilityRule.targetControlId, this.currentModel, true); + this.elementVisibilityMap.set(visibilityRule.targetControlId, false); + this.clearValues(targetPathKey); + return; + } + } + } + const obj = this.getObject(this.initialModel, 'id', visibilityRule.targetControlId, this.initialModel); + const targetObjPathKey = this.fieldsPathMemory[visibilityRule.targetControlId] ? this.fieldsPathMemory[visibilityRule.targetControlId] : this.search('pages', this.initialModel.pages, obj); + this.updateValue(this.currentModel, obj, targetObjPathKey); + this.elementVisibilityMap.set(visibilityRule.targetControlId, true); + } - private clearValues(pathKey) { - if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null) - if (pathKey && this.formGroup.get(pathKey)["controls"].fields) { - for (var i = 0; i < this.formGroup.get(pathKey)["controls"].fields.length; i++) - this.clearValues(pathKey + '.fields.' + i); - } - } + private clearValues(pathKey) { + if (pathKey && this.formGroup.get(pathKey + '.value')) { this.formGroup.get(pathKey + '.value').patchValue(null); } + if (pathKey && this.formGroup.get(pathKey)['controls'].fields) { + for (let i = 0; i < this.formGroup.get(pathKey)['controls'].fields.length; i++) { + this.clearValues(pathKey + '.fields.' + i); + } + } + } - // deleteFromModel(path: string, obj: any) { - // if (!path) return - // const _obj = JSON.parse(JSON.stringify(obj)); - // const keys = path.split('.'); + // deleteFromModel(path: string, obj: any) { + // if (!path) return + // const _obj = JSON.parse(JSON.stringify(obj)); + // const keys = path.split('.'); - // keys.reduce((acc, key, index) => { - // if (index === keys.length - 1) { - // delete acc[key]; - // return true; - // } - // return acc[key]; - // }, _obj); - // return _obj; - // } + // keys.reduce((acc, key, index) => { + // if (index === keys.length - 1) { + // delete acc[key]; + // return true; + // } + // return acc[key]; + // }, _obj); + // return _obj; + // } - updateValue(obj, value, path) { - var i; - path = path.split('.'); + updateValue(obj, value, path) { + let i; + path = path.split('.'); - for (i = 0; i < path.length - 1; i++) { - obj = obj[path[i]]; - } + for (i = 0; i < path.length - 1; i++) { + obj = obj[path[i]]; + } - for (let propIndex = 0; propIndex < obj.length; propIndex++) { - if (obj[propIndex] && obj[propIndex]["id"] === value["id"]) return - } - obj[path[i]] = value; - } + for (let propIndex = 0; propIndex < obj.length; propIndex++) { + if (obj[propIndex] && obj[propIndex]['id'] === value['id']) { return; } + } + obj[path[i]] = value; + } - search(path, obj, target) { - for (var k in obj) { - if (obj.hasOwnProperty(k)) - if (obj[k] === target) - return path + "." + k - else if (typeof obj[k] === "object") { - var result = this.search(path + "." + k, obj[k], target); - if (result) - return result; - } - } - return false; - } + search(path, obj, target) { + for (const k in obj) { + if (obj.hasOwnProperty(k)) { + if (obj[k] === target) { + return path + '.' + k; + } else if (typeof obj[k] === 'object') { + const result = this.search(path + '.' + k, obj[k], target); + if (result) { + return result; + } + } + } + } + return false; + } - private getObject(obj, key, val, parent, deleteObj = false) { - for (var i in obj) { - if (!obj.hasOwnProperty(i)) continue; - if (typeof obj[i] == 'object') { - let returnObj = this.getObject(obj[i], key, val, obj, deleteObj); - if (returnObj) return returnObj - } else if (i == key && obj[key] == val) { - //console.log(obj[key]) - if (deleteObj) parent[parent.indexOf(obj)] = null - return obj - } - } - } + private getObject(obj, key, val, parent, deleteObj = false) { + for (const i in obj) { + if (!obj.hasOwnProperty(i)) { continue; } + if (typeof obj[i] === 'object') { + const returnObj = this.getObject(obj[i], key, val, obj, deleteObj); + if (returnObj) { return returnObj; } + } else if (i === key && obj[key] === val) { + //console.log(obj[key]) + if (deleteObj) { parent[parent.indexOf(obj)] = null; } + return obj; + } + } + } } diff --git a/dmp-frontend/src/app/welcomepage/welcomepage.component.html b/dmp-frontend/src/app/welcomepage/welcomepage.component.html index be5bbfb10..171e9b627 100644 --- a/dmp-frontend/src/app/welcomepage/welcomepage.component.html +++ b/dmp-frontend/src/app/welcomepage/welcomepage.component.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/welcomepage/welcomepage.component.ts b/dmp-frontend/src/app/welcomepage/welcomepage.component.ts index e77a9a5fd..e27a6baa4 100644 --- a/dmp-frontend/src/app/welcomepage/welcomepage.component.ts +++ b/dmp-frontend/src/app/welcomepage/welcomepage.component.ts @@ -3,28 +3,28 @@ import { Router, ActivatedRoute } from '@angular/router'; import { DashboardService } from '../../app/services/dashboard/dashboard.service'; import { DashboardStatisticsModel } from '../models/dashboard/DashboardStatisticsModel'; import { JsonSerializer } from '../utilities/JsonSerializer'; -import { HomepageComponent } from '../homepage/homepage.component' +import { HomepageComponent } from '../homepage/homepage.component'; import { IBreadCrumbComponent } from '../shared/components/breadcrumb/definition/IBreadCrumbComponent'; import { Observable } from 'rxjs/Observable'; import { BreadcrumbItem } from '../shared/components/breadcrumb/definition/breadcrumb-item'; @Component({ - selector: 'welcomepage', - templateUrl: './welcomepage.component.html', - // styleUrls: ['./homepage.component.css'], - providers: [DashboardService] + selector: 'app-welcomepage', + templateUrl: './welcomepage.component.html', + // styleUrls: ['./homepage.component.css'], + providers: [DashboardService] }) export class WelcomepageComponent implements OnInit, IBreadCrumbComponent { - breadCrumbs: Observable = Observable.of([]); - private userInfo: any; - private dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel(); + breadCrumbs: Observable = Observable.of([]); + private userInfo: any; + private dashboardStatisticsData: DashboardStatisticsModel = new DashboardStatisticsModel(); - constructor() { - } + constructor() { + } - ngOnInit() { - //this.breadCrumbs = Observable.of([{ parentComponentName: null, label: 'Home', url: "/welcome" }]) - } + ngOnInit() { + //this.breadCrumbs = Observable.of([{ parentComponentName: null, label: 'Home', url: "/welcome" }]) + } }