diff --git a/dmp-admin/src/app/app.component.html b/dmp-admin/src/app/app.component.html index 8033861af..fb3975929 100644 --- a/dmp-admin/src/app/app.component.html +++ b/dmp-admin/src/app/app.component.html @@ -42,7 +42,7 @@ - + \ No newline at end of file diff --git a/dmp-admin/src/app/app.module.ts b/dmp-admin/src/app/app.module.ts index a1ff61f0b..e262b5ab5 100644 --- a/dmp-admin/src/app/app.module.ts +++ b/dmp-admin/src/app/app.module.ts @@ -67,6 +67,7 @@ import { DatasetprofileEditorComponent } from './managers/datasetprofile-editor/ import { DatasetProfileGUIEditorComponent } from './dataset-profile-gui-editor/dataset-profile-gui-editor.component'; import { DatasetProfileModule } from './dataset-profile-form/dataset-profile.module'; +import { UnauthorizedModule } from './unauthorized/unauthorized.module'; // import { FieldFormComponent } from './dataset-profile-form/field-form/field-form.component'; // import { FormComponent } from './dataset-profile-form/form/form.component'; diff --git a/dmp-admin/src/app/routes.ts b/dmp-admin/src/app/routes.ts index 0a08a6da1..b6e651cfe 100644 --- a/dmp-admin/src/app/routes.ts +++ b/dmp-admin/src/app/routes.ts @@ -11,7 +11,9 @@ import { DatasetprofileEditorComponent } from './managers/datasetprofile-editor/ import { MainWindowComponent } from './main-window/main-window.component'; import { NgModule } from '@angular/core'; import { AuthGuard } from './guards/auth.guard'; - +import { AppComponent } from 'app/app.component'; +import { MainSignInComponent } from 'app/login/main-sign-in/main-sign-in.component'; +import { UnauthorizedComponent } from './unauthorized/unauthorized.component'; // Route Configuration @@ -19,9 +21,14 @@ const routes: Routes = [ { path: '', - redirectTo: 'app-root', + redirectTo: '/main', pathMatch: 'full' }, + { + path: 'app-root', + component: AppComponent, + canActivate: [AuthGuard] + }, { path: 'datasets', component: DatasetsViewerComponent, @@ -43,7 +50,9 @@ const routes: Routes = [ component: MainWindowComponent, canActivate: [AuthGuard] }, - { path: 'form', loadChildren: './dataset-profile-form/dataset-profile.module#DatasetProfileModule', canActivate: [AuthGuard]} + { path: 'form', loadChildren: './dataset-profile-form/dataset-profile.module#DatasetProfileModule', canActivate: [AuthGuard]}, + { path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' } , + { path: "login", component: MainSignInComponent } ]; @NgModule({ @@ -56,7 +65,7 @@ const routes: Routes = [ RouterModule ], providers: [ - + AuthGuard ] }) diff --git a/dmp-admin/src/app/services/auth/auth.service.ts b/dmp-admin/src/app/services/auth/auth.service.ts index 2ee468aab..c0da3a854 100644 --- a/dmp-admin/src/app/services/auth/auth.service.ts +++ b/dmp-admin/src/app/services/auth/auth.service.ts @@ -30,7 +30,10 @@ export class AuthService { this.headers = this.headers.set('Accept', 'application/json'); } - + private clear(): void { + localStorage.removeItem('principal'); + } + public current(principal?: Principal): Principal { if (principal) { localStorage.setItem('principal', JSON.stringify(principal)); @@ -40,7 +43,30 @@ export class AuthService { if (!principalJson) { return null; } const principalObj = JSON.parse(principalJson) as Principal; return principalObj; - } + } + + 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 nativeLogin(credentials: Credential): Observable { debugger; const url = this.actionUrl + 'nativelogin'; diff --git a/dmp-admin/src/app/unauthorized/unauthorized.component.html b/dmp-admin/src/app/unauthorized/unauthorized.component.html new file mode 100644 index 000000000..1a1112d35 --- /dev/null +++ b/dmp-admin/src/app/unauthorized/unauthorized.component.html @@ -0,0 +1 @@ +{{message}} \ No newline at end of file diff --git a/dmp-admin/src/app/unauthorized/unauthorized.component.js.map b/dmp-admin/src/app/unauthorized/unauthorized.component.js.map new file mode 100644 index 000000000..c61b89104 --- /dev/null +++ b/dmp-admin/src/app/unauthorized/unauthorized.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"unauthorized.component.js","sourceRoot":"","sources":["unauthorized.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAMzD,IAAa,qBAAqB;IAG9B,+BACY,WAAwB,EACxB,KAAqB,EACrB,MAAc;QAFd,gBAAW,GAAX,WAAW,CAAa;QACxB,UAAK,GAAL,KAAK,CAAgB;QACrB,WAAM,GAAN,MAAM,CAAQ;IACtB,CAAC;IAEL,+CAAe,GAAf;QAAA,iBAaC;QAZG,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC;QACpE,IAAI,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3C,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,CAAC,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,SAAS,CAC3B,UAAA,SAAS;gBACL,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBAAC,KAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;YAChG,CAAC,EACD,UAAA,GAAG,IAAI,OAAA,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,EAAvC,CAAuC,CAAC,CAAC;QACxD,CAAC;IACL,CAAC;IACL,4BAAC;AAAD,CAAC,AAvBD,IAuBC;AArBG;IADC,KAAK,EAAE;;sDACe;AAFd,qBAAqB;IAJjC,SAAS,CAAC;QACP,QAAQ,EAAE,wBAAwB;QAClC,WAAW,EAAE,+BAA+B;KAC/C,CAAC;qCAK2B,WAAW;QACjB,cAAc;QACb,MAAM;GANjB,qBAAqB,CAuBjC;SAvBY,qBAAqB"} \ No newline at end of file diff --git a/dmp-admin/src/app/unauthorized/unauthorized.component.ts b/dmp-admin/src/app/unauthorized/unauthorized.component.ts new file mode 100644 index 000000000..f8c067519 --- /dev/null +++ b/dmp-admin/src/app/unauthorized/unauthorized.component.ts @@ -0,0 +1,33 @@ +import { AuthService } from '../services/auth/auth.service'; +import { Component, Input } from "@angular/core"; +import { ActivatedRoute, Router } from "@angular/router"; + +@Component({ + selector: 'unauthorized-component', + templateUrl: './unauthorized.component.html' +}) +export class UnauthorizedComponent { + @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 diff --git a/dmp-admin/src/app/unauthorized/unauthorized.module.js.map b/dmp-admin/src/app/unauthorized/unauthorized.module.js.map new file mode 100644 index 000000000..126948b9d --- /dev/null +++ b/dmp-admin/src/app/unauthorized/unauthorized.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"unauthorized.module.js","sourceRoot":"","sources":["unauthorized.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAmBtD,IAAa,kBAAkB;IAA/B;IAAkC,CAAC;IAAD,yBAAC;AAAD,CAAC,AAAnC,IAAmC;AAAtB,kBAAkB;IAlB9B,QAAQ,CAAC;QACN,OAAO,EAAE;YACL,YAAY;YACZ,WAAW;YACX,gBAAgB;YAChB,kBAAkB;YAClB,YAAY;SACf;QAED,YAAY,EAAE;YACV,qBAAqB;SACxB;QAED,OAAO,EAAE;YACL,qBAAqB;SACxB;KACJ,CAAC;GAEW,kBAAkB,CAAI;SAAtB,kBAAkB"} \ No newline at end of file diff --git a/dmp-admin/src/app/unauthorized/unauthorized.module.ts b/dmp-admin/src/app/unauthorized/unauthorized.module.ts new file mode 100644 index 000000000..5929b9ed7 --- /dev/null +++ b/dmp-admin/src/app/unauthorized/unauthorized.module.ts @@ -0,0 +1,29 @@ +import { CommonModule } from '@angular/common'; +import { HttpClientModule } from '@angular/common/http'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; + +import { RouterModule } from '@angular/router'; + +import { UnauthorizedComponent } from './unauthorized.component'; +import { UnauthorizedRoutes } from './unauthorized.routes'; +//import { SharedModule } from '../shared/shared.module' +@NgModule({ + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + UnauthorizedRoutes + // SharedModule + ], + + declarations: [ + UnauthorizedComponent + ], + + exports: [ + UnauthorizedComponent + ] +}) + +export class UnauthorizedModule { } diff --git a/dmp-admin/src/app/unauthorized/unauthorized.routes.js.map b/dmp-admin/src/app/unauthorized/unauthorized.routes.js.map new file mode 100644 index 000000000..8a1dbc929 --- /dev/null +++ b/dmp-admin/src/app/unauthorized/unauthorized.routes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"unauthorized.routes.js","sourceRoot":"","sources":["unauthorized.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAU,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,IAAM,MAAM,GAAW;IACnB,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE;CACjD,CAAC;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC"} \ No newline at end of file diff --git a/dmp-admin/src/app/unauthorized/unauthorized.routes.ts b/dmp-admin/src/app/unauthorized/unauthorized.routes.ts new file mode 100644 index 000000000..f8e4ebee4 --- /dev/null +++ b/dmp-admin/src/app/unauthorized/unauthorized.routes.ts @@ -0,0 +1,9 @@ +import { RouterModule, Routes } from '@angular/router'; + +import { UnauthorizedComponent } from './unauthorized.component'; + +const routes: Routes = [ + { path: '', component: UnauthorizedComponent } +]; + +export const UnauthorizedRoutes = RouterModule.forChild(routes); diff --git a/dmp-frontend/package-lock.json b/dmp-frontend/package-lock.json index 7c25c48da..f97b8e9ad 100644 --- a/dmp-frontend/package-lock.json +++ b/dmp-frontend/package-lock.json @@ -1234,6 +1234,7 @@ "requires": { "anymatch": "1.3.2", "async-each": "1.0.1", + "fsevents": "1.1.3", "glob-parent": "2.0.0", "inherits": "2.0.3", "is-binary-path": "1.0.1", @@ -2829,6 +2830,910 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", + "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", + "dev": true, + "optional": true, + "requires": { + "nan": "2.8.0", + "node-pre-gyp": "0.6.39" + }, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.2.9" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "balanced-match": { + "version": "0.4.2", + "bundled": true, + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "dev": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.7", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "0.4.2", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "caseless": { + "version": "0.12.0", + "bundled": true, + "dev": true, + "optional": true + }, + "co": { + "version": "4.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "dev": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "debug": { + "version": "2.6.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true, + "dev": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true, + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.1" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "1.1.1", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true, + "dev": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "dev": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true, + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.0" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.4", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "jodid25519": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "mime-db": { + "version": "1.27.0", + "bundled": true, + "dev": true + }, + "mime-types": { + "version": "2.1.15", + "bundled": true, + "dev": true, + "requires": { + "mime-db": "1.27.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.39", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "1.0.2", + "hawk": "3.1.3", + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.0", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.1", + "semver": "5.3.0", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1.1.0", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true, + "dev": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "optional": true + }, + "qs": { + "version": "6.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.2.9", + "bundled": true, + "dev": true, + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.1", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.0.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.0.1" + } + }, + "rimraf": { + "version": "2.6.1", + "bundled": true, + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.0.1", + "bundled": true, + "dev": true + }, + "semver": { + "version": "5.3.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jodid25519": "1.0.2", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "dev": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "2.6.8", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.2.9", + "rimraf": "2.6.1", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "dev": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true, + "dev": true, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "uuid": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "verror": { + "version": "1.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2" + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + } + } + }, "fstream": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", @@ -6456,11 +7361,11 @@ } }, "rxjs": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.4.3.tgz", - "integrity": "sha512-fSNi+y+P9ss+EZuV0GcIIqPUK07DEaMRUtLJvdcvMyFjc9dizuDjere+A4V7JrLGnm9iCc+nagV/4QdMTkqC4A==", + "version": "5.5.6", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.6.tgz", + "integrity": "sha512-v4Q5HDC0FHAQ7zcBX7T2IL6O5ltl1a2GX4ENjPXg6SjDY69Cmx9v4113C99a4wGF16ClPv5Z8mghuYorVkg/kg==", "requires": { - "symbol-observable": "1.0.4" + "symbol-observable": "1.0.1" } }, "safe-buffer": { @@ -7136,9 +8041,9 @@ } }, "symbol-observable": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.4.tgz", - "integrity": "sha1-Kb9hXUqnEhvdiYsi1LP5vE4qoD0=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", + "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=" }, "tapable": { "version": "0.2.8", diff --git a/dmp-frontend/package.json b/dmp-frontend/package.json index 3ed9b91f0..65c55e415 100644 --- a/dmp-frontend/package.json +++ b/dmp-frontend/package.json @@ -27,7 +27,7 @@ "@ngx-translate/core": "^9.0.1", "@ngx-translate/http-loader": "^2.0.0", "core-js": "^2.4.1", - "rxjs": "^5.4.2", + "rxjs": "5.5.6", "zone.js": "^0.8.17" }, "devDependencies": { diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index a9662d742..b561caae5 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -10,6 +10,7 @@ const appRoutes: Routes = [ { path: 'datasets', loadChildren: './datasets/dataset.module#DatasetModule' ,canActivate: [AuthGuard]}, { path: 'projects', loadChildren: './projects/projects.module#ProjectsModule',canActivate: [AuthGuard] }, { path: "dmps", loadChildren: './dmps/dmps.module#DataManagementPlanModule',canActivate: [AuthGuard] }, + { path: 'form', loadChildren: './dataset-profile-form/dataset-profile.module#DatasetProfileModule', canActivate: [AuthGuard]}, { path: 'welcome', component: HomepageComponent, canActivate: [AuthGuard] }, { path: '', redirectTo: '/welcome', pathMatch: 'full' }, { path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' } diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index cda55cf95..beb768b5a 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -30,6 +30,7 @@ import { HomepageComponent } from './homepage/homepage.component'; import { PageNotFoundComponent } from './not-found.component'; import { AppComponent } from './app.component'; import { NgModule } from "@angular/core"; +import { DatasetProfileModule } from './dataset-profile-form/dataset-profile.module'; @NgModule({ 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 new file mode 100644 index 000000000..7424f1e1c --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.html @@ -0,0 +1,83 @@ + + + Composite Field + + Multiplicity + + + Comment + + + + + FieldSet Label + + + + Description + + + + ExtendedDescription + + + + + + Multiplicity + + Min + + + + + Max + + + + + + Ordinal + + + + Id + + + + + + + + + + + + + {{i + 1}}. {{form.get('fields').get(''+i).get('title').value}} + {{i + 1}}. Child Field {{i + 1}} + + + + + + + + + + + + + + + + + Add Child Field + + + + + \ No newline at end of file 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 new file mode 100644 index 000000000..b37428bff --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/compositefield-form/compositefield-form.component.ts @@ -0,0 +1,57 @@ +import { Component, Input } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { FieldSet } from 'app/models/datasetProfileAdmin/FieldSet'; +import { Field } from 'app/models/datasetProfileAdmin/Field'; +import { FormArray, FormControl } from '@angular/forms'; + +@Component({ + selector: 'compositefield-form', + templateUrl: './compositefield-form.component.html', + styleUrls: [] +}) + +export class CompositeFieldFormComponent { + @Input() form: FormGroup; + @Input() dataModel: FieldSet; + @Input() indexPath: string; + + isComposite: boolean = false; + isMultiplicityEnabled: boolean = false; + + 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; + } + + 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); + } + } + + addNewField() { + let 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); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/dataset-profile-form/dataset-profile.module.ts b/dmp-frontend/src/app/dataset-profile-form/dataset-profile.module.ts new file mode 100644 index 000000000..9f71696a9 --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/dataset-profile.module.ts @@ -0,0 +1,77 @@ +import { NgModule } from "@angular/core"; +import { CommonModule } from '@angular/common'; +import { FormsModule,ReactiveFormsModule } from '@angular/forms'; + +import { DatasetProfileRoutes } from "./dataset-profile.router"; +import { RouterModule } from "@angular/router"; + +import { FormComponent } from './form/form.component'; +//import { GroupFieldFormComponent } from './groupfield-form/groupfield-form.component'; +import { RuleFormComponent } from './rule-component/rule.component'; +import { SectionFormComponent } from './section-form/section-form.component'; +import { PageFormComponent } from './page-form/page-component'; +import { CompositeFieldFormComponent } from './compositefield-form/compositefield-form.component'; +import { FieldFormComponent } from './field-form/field-form.component'; +import { HttpClientModule, HttpClient } from "@angular/common/http"; + +import { CheckBoxComponent } from '../shared/componentsAdmin/checkbox/checkbox-component'; +import { FreeTextData } from '../models/DataField/FreeTextData'; +import { BooleanDecisionComponent } from '../shared/componentsAdmin/booleanDecision/booleanDecision-component'; +import { FreeTextComponent } from '../shared/componentsAdmin/freetext/freetext-component'; +import { TextAreaComponent } from '../shared/componentsAdmin/textarea/textarea-component'; +import { RadioBoxComponent } from '../shared/componentsAdmin/radiobox/radiobox-component'; +import { WordlistComponent } from '../shared/componentsAdmin/wordlist/wordlist-component'; +import { AutocompleteComponent } from '../shared/componentsAdmin/autocomplete/autocomplete-component'; +import { ComboboxComponent } from '../shared/componentsAdmin/combobox/combobox-component'; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + ReactiveFormsModule, + RouterModule, + RouterModule.forChild(DatasetProfileRoutes) + ], + + declarations: [ + FormComponent, + //GroupFieldFormComponent, + RuleFormComponent, + SectionFormComponent, + PageFormComponent, + CompositeFieldFormComponent, + FieldFormComponent, + TextAreaComponent, + CheckBoxComponent, + BooleanDecisionComponent, + FreeTextComponent, + ComboboxComponent, + AutocompleteComponent, + WordlistComponent, + RadioBoxComponent + ], + + exports: [ + FormComponent, + //GroupFieldFormComponent, + RuleFormComponent, + SectionFormComponent, + PageFormComponent, + CompositeFieldFormComponent, + FieldFormComponent, + TextAreaComponent, + CheckBoxComponent, + BooleanDecisionComponent, + FreeTextComponent, + ComboboxComponent, + AutocompleteComponent, + WordlistComponent, + RadioBoxComponent + ], + providers:[ + ] +}) + + +export class DatasetProfileModule { } \ No newline at end of file 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 new file mode 100644 index 000000000..44e2337e6 --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts @@ -0,0 +1,15 @@ +import { RouterModule, Routes } from '@angular/router'; +import { FormComponent } from 'app/dataset-profile-form/form/form.component'; + +export const DatasetProfileRoutes: Routes = [ + //{ path: "new/:dmpId", component: DatasetWizardComponent, canActivate: [AuthGuard] } + { + 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 new file mode 100644 index 000000000..652a20e87 --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.html @@ -0,0 +1,120 @@ + + + + + Id + + + + + + View style + + textarea + booleanDecision + combobox + checkBox + freetext + radiobox + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Multiplicity + + Min + + + + + Max + + + + + + Ordinal + + + + + Default Value + + + + + Validation + + + + {{option.value}} + + + + + + + + + Multiplicity + + + + + {{i + 1}}. Rule {{i + 1}} + + + + + + + + + + + + + + + + + Add Rule + + + + + \ No newline at end of file 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 new file mode 100644 index 000000000..46b97ae94 --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/field-form/field-form.component.ts @@ -0,0 +1,54 @@ + +import { Component, Input } from '@angular/core'; +import { FormGroup, FormControl, FormArray } from '@angular/forms'; +import { ValidationTypes } from '@app/models/common/ValidationTypes'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; +import { Rule } from '@app/models/datasetProfileAdmin/Rule'; + +@Component({ + selector: 'field-form', + templateUrl: './field-form.component.html', + styleUrls: [] +}) + +export class FieldFormComponent { + @Input() form: FormGroup; + @Input() dataModel: Field; + @Input() showMultiplicity: boolean = true; + @Input() indexPath: string; + validationsOptions: Array; + isFieldMultiplicityEnabled: boolean = false; + + 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(); + } + + 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()); + } + + 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 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 new file mode 100644 index 000000000..2741ea42b --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/form/form.component.html @@ -0,0 +1,73 @@ + + + + + + Label + + + + Label is required. + + + + + + + + + {{i + 1}}. {{form.get('sections').get(''+i).get('title').value}} + {{i + 1}}. Section {{i + 1}} + + + + + + + + + + + + + + + + + + {{i + 1}}.{{form.get('pages').at(i).get('title').value}} + {{i + 1}}. Page{{i + 1}} + + + + + + + + + + + + + + + + + Add Section + + + + + + + Add Page + + + + + Save + + + \ No newline at end of file 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 new file mode 100644 index 000000000..b46186c0c --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/form/form.component.ts @@ -0,0 +1,89 @@ +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { DatasetProfileService } from '../../services/dataset-profile.service'; +import { DatasetProfileModelAdmin } from '../../models/datasetProfileAdmin/DatasetProfileModelAdmin'; +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 { DatasetProfileAdmin } from '@app/services/datasetProfileAdmin/datasetProfileAfmin.service'; +import { Section } from '@app/models/datasetProfileAdmin/Section'; + +@Component({ + selector: 'form-comp', + templateUrl: './form.component.html', + providers:[DatasetProfileAdmin, DatasetProfileService], + styleUrls: [] +}) + +export class FormComponent { + + dataModel: DatasetProfileModelAdmin; + form: FormGroup; + private profileID: string; + + constructor(public datasetprofileAdmin: DatasetProfileAdmin, private datasetProfileService: DatasetProfileService, private route: ActivatedRoute) { + this.profileID = route.snapshot.params['id']; + } + + 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(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()); + } + + addPage(number) { + let 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) + } + + 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; + + if (this.profileID) this.updateForm(this.profileID, data).subscribe(); + else this.createForm(data).subscribe(); + } + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/dataset-profile-form/page-form/page-component.html b/dmp-frontend/src/app/dataset-profile-form/page-form/page-component.html new file mode 100644 index 000000000..3ad68805d --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/page-form/page-component.html @@ -0,0 +1,8 @@ + + + + Title + + + + \ No newline at end of file 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 new file mode 100644 index 000000000..573ca355b --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/page-form/page-component.ts @@ -0,0 +1,19 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { FormGroup } from '@angular/forms' +import { Page } from '@app/models/datasetProfileAdmin/Page'; + + +@Component({ + selector: 'page-form', + templateUrl: './page-component.html', + styleUrls: [] +}) + +export class PageFormComponent { + @Input() form: FormGroup; + @Input() dataModel: Page; + + TargetValidation() { + } + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/dataset-profile-form/rule-component/rule.component.html b/dmp-frontend/src/app/dataset-profile-form/rule-component/rule.component.html new file mode 100644 index 000000000..7ddb10c84 --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/rule-component/rule.component.html @@ -0,0 +1,33 @@ + + + + + Rule Type + + field value + + + + Target + + + + + + Value + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/dataset-profile-form/rule-component/rule.component.ts b/dmp-frontend/src/app/dataset-profile-form/rule-component/rule.component.ts new file mode 100644 index 000000000..fa91de7e3 --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/rule-component/rule.component.ts @@ -0,0 +1,18 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { FormGroup } from '@angular/forms' +import { Rule } from 'app/models/datasetProfileAdmin/Rule' + +@Component({ + selector: 'rule-form', + templateUrl: './rule.component.html', + styleUrls: [] +}) + +export class RuleFormComponent { +@Input() form: FormGroup; +@Input() dataModel: FormGroup; + +TargetValidation(){ +} + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.css b/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.css new file mode 100644 index 000000000..1ded10469 --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.css @@ -0,0 +1,5 @@ +.section-container { + background-color: #f5f5f5; + border: 1px solid #e3e3e3; + padding: 24px; +} \ No newline at end of file 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 new file mode 100644 index 000000000..1d3730e4f --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.html @@ -0,0 +1,124 @@ + + + + + Title + + + + Id + + + + Ordinal + + + + Page + + {{pageGroup.get('title').value}} + + Page is required + + + Default Visibility + + true + + + false + + + + + + 0" class="panel-group" style="margin-top:10px;"> + + + {{i + 1}}. {{form.get('sections').get(''+i).get('title').value}} + {{i + 1}}. Section {{i + 1}} + + + + + + + + + + + + + + + + + + + + + + + + + {{i + 1}}. Field {{i + 1}} + + + + + + + + + + + + + + + + + + + + Add Field + + + + + + Add Section + + + + \ No newline at end of file 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 new file mode 100644 index 000000000..a7e2a4cef --- /dev/null +++ b/dmp-frontend/src/app/dataset-profile-form/section-form/section-form.component.ts @@ -0,0 +1,63 @@ +import { Component, OnInit, Input, ViewEncapsulation } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import { Section } from 'app/models/datasetProfileAdmin/Section'; +import { FormArray } from '@angular/forms'; +import { DatasetProfileModel } from 'app/models/DataSetProfile/DatasetProfileModel'; +import { FieldSet } from 'app/models/datasetProfileAdmin/FieldSet'; +import { Field } from 'app/models/datasetProfileAdmin/Field'; +import { Page } from 'app/models/datasetProfileAdmin/Page'; +import { JsonSerializer } from 'app/utilities/JsonSerializer'; + +@Component({ + selector: 'section-form', + templateUrl: './section-form.component.html', + styleUrls: ['./section-form.component.css'], + encapsulation: ViewEncapsulation.None +}) + +export class SectionFormComponent { + @Input() form: FormGroup; + @Input() dataModel: Section; + @Input() indexPath: string; + + constructor() { } + + ngOnInit() { + var self = this; + this.form.root.get("pages").valueChanges.subscribe(function (value) { + self.keepPageSelectionValid(value); + }); + } + + 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()); + } + + addSectioninSection() { + let 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); + } + + 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(); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/DataField/AutocompleteData.ts b/dmp-frontend/src/app/models/DataField/AutocompleteData.ts new file mode 100644 index 000000000..11873a833 --- /dev/null +++ b/dmp-frontend/src/app/models/DataField/AutocompleteData.ts @@ -0,0 +1,23 @@ +import { DataField } from './DataField'; +import { FormGroup } from '@angular/forms' + +export class AutocompleteData extends DataField{ + + public type:string; + public url:string; + + buildForm():FormGroup{ + return this.formBuilder.group({ + label:[this.label], + type:[this.type], + url:[this.url] + }) + } + + fromJSONObject(item:any):AutocompleteData{ + this.type = item.type; + this.url = item.url; + this.label = item.label; + return this; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/DataField/BooleanDecisionData.ts b/dmp-frontend/src/app/models/DataField/BooleanDecisionData.ts new file mode 100644 index 000000000..f8d8c9dd6 --- /dev/null +++ b/dmp-frontend/src/app/models/DataField/BooleanDecisionData.ts @@ -0,0 +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; + } + + fromJSONObject(item:any):BooleanDecisionData{ + this.label = item.label + return this; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/DataField/CheckBoxData.ts b/dmp-frontend/src/app/models/DataField/CheckBoxData.ts new file mode 100644 index 000000000..ab3713697 --- /dev/null +++ b/dmp-frontend/src/app/models/DataField/CheckBoxData.ts @@ -0,0 +1,16 @@ +import { DataField } from './DataField'; +import { FormGroup } from '@angular/forms'; +export class CheckBoxData extends DataField{ + + buildForm():FormGroup{ + let 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 diff --git a/dmp-frontend/src/app/models/DataField/DataField.ts b/dmp-frontend/src/app/models/DataField/DataField.ts new file mode 100644 index 000000000..e520408df --- /dev/null +++ b/dmp-frontend/src/app/models/DataField/DataField.ts @@ -0,0 +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"); + } + + fromJSONObject(item:any):T{ + throw new Error("From Json Object is not correctly overriden") + } + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/DataField/FreeTextData.ts b/dmp-frontend/src/app/models/DataField/FreeTextData.ts new file mode 100644 index 000000000..f32703ec0 --- /dev/null +++ b/dmp-frontend/src/app/models/DataField/FreeTextData.ts @@ -0,0 +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; + } + + fromJSONObject(item:any):FreeTextData{ + this.label = item.label + return this; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/DataField/RadioBoxData.ts b/dmp-frontend/src/app/models/DataField/RadioBoxData.ts new file mode 100644 index 000000000..443f61437 --- /dev/null +++ b/dmp-frontend/src/app/models/DataField/RadioBoxData.ts @@ -0,0 +1,29 @@ +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { DataField } from './DataField'; +import { ListingItem } from '../Common/ListingItem'; +import { FormGroup } from '@angular/forms' + +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; + } + + fromJSONObject(item:any):RadioBoxData{ + this.options = JsonSerializer.fromJSONArray(item.options,ListingItem); + this.label = item.label + return this; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/DataField/TextArea.ts b/dmp-frontend/src/app/models/DataField/TextArea.ts new file mode 100644 index 000000000..f5e24dbcc --- /dev/null +++ b/dmp-frontend/src/app/models/DataField/TextArea.ts @@ -0,0 +1,16 @@ +import { DataField } from './DataField'; +import { FormGroup } from '@angular/forms'; +export class TextArea extends DataField{ + + buildForm(): FormGroup { + let formGroup = this.formBuilder.group({ + label: this.label + }); + return formGroup; + } + + fromJSONObject(item: any): TextArea { + this.label = item.label + return this; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/DataField/WordListData.ts b/dmp-frontend/src/app/models/DataField/WordListData.ts new file mode 100644 index 000000000..e33d92970 --- /dev/null +++ b/dmp-frontend/src/app/models/DataField/WordListData.ts @@ -0,0 +1,32 @@ +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { ListingItem } from '../Common/ListingItem'; +import { DataField } from './DataField'; +import { FormGroup } from '@angular/forms' + +export class WordListData extends DataField{ + public type:string; + public options:Array; + buildForm():FormGroup{ + let formGroup = this.formBuilder.group({ + type:[this.type], + 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; + } + + fromJSONObject(item:any):WordListData{ + this.type = item.type; + this.options = JsonSerializer.fromJSONArray(item.options,ListingItem); + this.label = item.label; + return this; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/common/ListingItem.ts b/dmp-frontend/src/app/models/common/ListingItem.ts new file mode 100644 index 000000000..0d1383b07 --- /dev/null +++ b/dmp-frontend/src/app/models/common/ListingItem.ts @@ -0,0 +1,20 @@ +import { FormGenerator } from '../interfaces/FormGenerator'; +import { Serializable } from '../interfaces/Serializable'; +import { FormGroup, FormBuilder } from '@angular/forms' +export class ListingItem implements Serializable, FormGenerator{ + public label: string; + public value: string; + + fromJSONObject(item: any): ListingItem { + this.label = item.label; + this.value = item.value; + return this; + } + + buildForm(): FormGroup { + return new FormBuilder().group({ + label: [this.label], + value: [this.value] + }) + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/DatasetProfileModelAdmin.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/DatasetProfileModelAdmin.ts new file mode 100644 index 000000000..10b36259a --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/DatasetProfileModelAdmin.ts @@ -0,0 +1,43 @@ +import { BaseModel } from '../BaseModel'; +import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'; +import { FormGenerator } from '../interfaces/FormGenerator'; +import { JsonSerializer } from 'app/utilities/JsonSerializer'; +import { Section } from './Section'; +import { Serializable } from '../interfaces/Serializable'; +import { Page } from "./Page"; + +export class DatasetProfileModelAdmin extends BaseModel implements Serializable,FormGenerator{ + + public sections: Array = new Array(); + public pages: Array = new Array(); + public label: string; + + fromJSONObject(item:any):DatasetProfileModelAdmin{ + this.sections = JsonSerializer.fromJSONArray(item.sections, Section); + this.pages = JsonSerializer.fromJSONArray(item.pages, Page); + this.label = item.label; + return this; + } + + buildForm():FormGroup{ + let formGroup: FormGroup = new FormBuilder().group({}); + + let sectionsFormArray = new Array(); + this.sections.forEach(item => { + let form: FormGroup = item.buildForm(); + sectionsFormArray.push(form) + }) + formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); + + let pagesFormArray = new Array(); + this.pages.forEach(item => { + let form: FormGroup = item.buildForm(); + pagesFormArray.push(form) + }) + formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); + + formGroup.addControl('label', new FormControl(this.label, Validators.required)); + return formGroup; + } + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/DefaultValue.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/DefaultValue.ts new file mode 100644 index 000000000..c2bec0ea5 --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/DefaultValue.ts @@ -0,0 +1,24 @@ +import { BaseModel } from '../BaseModel'; +import { FormGroup } from '@angular/forms'; +import { FormGenerator } from '../interfaces/FormGenerator'; +import { Serializable } from '../interfaces/Serializable'; + +export class DefaultValue extends BaseModel implements Serializable,FormGenerator{ + public type:string; + public value:string; + + fromJSONObject(item:any):DefaultValue{ + this.type = item.type; + this.value = item.value; + return this; + } + + buildForm():FormGroup{ + let formGroup = this.formBuilder.group({ + type: [this.type], + value: [this.value] + + }); + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/Field.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/Field.ts new file mode 100644 index 000000000..4e4679a91 --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/Field.ts @@ -0,0 +1,82 @@ +import { BooleanDecisionData } from '../DataField/BooleanDecisionData'; +import { FreeTextData } from '../DataField/FreeTextData'; +import { TextArea } from '../DataField/TextArea'; +import { CheckBoxData } from '../DataField/CheckBoxData'; +import { RadioBoxData } from '../DataField/RadioBoxData'; +import { WordListData } from '../DataField/WordListData'; +import { AutocompleteData } from '../DataField/AutocompleteData'; +import { DataField } from '../DataField/DataField'; +import { BaseModel } from '../BaseModel'; +import { FormGroup, FormArray, FormControl } from '@angular/forms'; +import { FormGenerator } from '../interfaces/FormGenerator'; +import { JsonSerializer } from 'app/utilities/JsonSerializer'; +import { Serializable } from '../interfaces/Serializable'; +import { Rule } from './Rule'; +import { Multiplicity } from './Multiplicity'; +import { DefaultValue } from './DefaultValue'; +import { ViewStyle } from './ViewStyle'; +import { Visibility } from './Visibility'; +import { ValidationTypes } from '@app/models/common/ValidationTypes'; + +export class Field extends BaseModel implements Serializable, FormGenerator{ + + public id: string; + public title: string; + public defaultValue: DefaultValue = new DefaultValue; + public viewStyle: ViewStyle = new ViewStyle(); + public page: number; + //public multiplicity: Multiplicity = new Multiplicity(); + public ordinal: number; + public visible: Visibility = new Visibility(); + public data: DataField; + public validations: Array; + + fromJSONObject(item: any): Field { + this.id = item.id; + this.title = item.title; + this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue); + this.page = item.page; + // this.multiplicity = new JsonSerializer().fromJSONObject(item.multiplicity, Multiplicity); + this.ordinal = item.ordinal; + this.validations = item.validations; + this.viewStyle = JsonSerializer.fromJSONObject(item.viewStyle, ViewStyle); + this.visible = JsonSerializer.fromJSONObject(item.visible, Visibility); + if (item.data) { + if (this.viewStyle.renderStyle === "combobox") { + if (item.data.type === "autocomplete") this.data = JsonSerializer.fromJSONObject(item.data, AutocompleteData); + if (item.data.type === "wordlist") this.data = JsonSerializer.fromJSONObject(item.data, WordListData); + } else { + if (this.viewStyle.renderStyle === "radiobox") this.data = JsonSerializer.fromJSONObject(item.data, RadioBoxData); + if (this.viewStyle.renderStyle === "checkBox") this.data = JsonSerializer.fromJSONObject(item.data, CheckBoxData); + if (this.viewStyle.renderStyle === "textarea") this.data = JsonSerializer.fromJSONObject(item.data, TextArea); + if (this.viewStyle.renderStyle === "freetext") this.data = JsonSerializer.fromJSONObject(item.data, FreeTextData); + if (this.viewStyle.renderStyle === "booleanDecision") this.data = JsonSerializer.fromJSONObject(item.data, BooleanDecisionData); + } + } + return this; + } + + buildForm(): FormGroup { + let formGroup = this.formBuilder.group({ + id: [this.id], + title: [this.title], + page: [this.page], + ordinal: [this.ordinal] + }); + let valid = ValidationTypes.None + if (this.validations && this.validations[0]==1) valid = ValidationTypes.Required + const arr = new FormArray([ + new FormControl(valid) + ]); + + //formGroup.addControl("multiplicity", this.multiplicity.buildForm()); + formGroup.addControl("validations", arr); + formGroup.addControl("defaultValue", this.defaultValue.buildForm()); + formGroup.addControl("viewStyle", this.viewStyle.buildForm()); + formGroup.addControl("visible", this.visible.buildForm()); + //formGroup.addControl("data",this.data? this.data.buildForm():this.formBuilder.group({})); + if (this.data) formGroup.addControl("data", this.data.buildForm()); + + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/FieldSet.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/FieldSet.ts new file mode 100644 index 000000000..7427f7bcd --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/FieldSet.ts @@ -0,0 +1,51 @@ +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { FormGroup } from '@angular/forms'; +import { Serializable } from '../interfaces/Serializable'; +import { BaseModel } from '../BaseModel'; +import {Field} from './Field' +import {Multiplicity} from './Multiplicity' + +export class FieldSet extends BaseModel implements Serializable { + public fields:Array = new Array(); + public id:string; + public ordinal:number; + public multiplicity: Multiplicity = new Multiplicity(); + public title:string; + public description:string; + public extendedDescription:string; + public hasCommentField:boolean; + + fromJSONObject(item:any):FieldSet{ + + this.fields = JsonSerializer.fromJSONArray(item.fields,Field); + this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity); + this.id = item.id; + this.ordinal = item.ordinal; + this.title = item.title; + this.description = item.description; + this.extendedDescription = item.extendedDescription; + this.hasCommentField = item.hasCommentField; + 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] + }); + + let fieldsFormArray = new Array(); + this.fields.forEach(item => { + let form: FormGroup = item.buildForm(); + fieldsFormArray.push(form) + }) + formGroup.addControl('fields', this.formBuilder.array(fieldsFormArray)); + formGroup.addControl("multiplicity", this.multiplicity.buildForm()); + + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/Multiplicity.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/Multiplicity.ts new file mode 100644 index 000000000..a0d2069be --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/Multiplicity.ts @@ -0,0 +1,23 @@ +import { BaseModel } from '../BaseModel'; +import { FormGroup } from '@angular/forms'; +import { FormGenerator } from '../interfaces/FormGenerator'; +import { Serializable } from '../interfaces/Serializable'; +export class Multiplicity extends BaseModel implements Serializable,FormGenerator{ + public min:number; + public max:string; + + fromJSONObject(item:any):Multiplicity{ + this.min = item.min; + this.max = item.max; + return this; + } + + buildForm():FormGroup{ + let formGroup = this.formBuilder.group({ + min: [this.min], + max: [this.max] + + }); + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/Page.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/Page.ts new file mode 100644 index 000000000..d54861281 --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/Page.ts @@ -0,0 +1,33 @@ +import { BaseModel } from '../BaseModel'; +import { FormGroup } from '@angular/forms'; +import { FormGenerator } from '../interfaces/FormGenerator'; +import { Serializable } from '../interfaces/Serializable'; + +export class Page extends BaseModel implements Serializable, FormGenerator{ + public title: string; + public id: string; + public ordinal: number; + + constructor(ordinal?: number) { + super(); + if (isNaN(ordinal)) this.ordinal = 0; + else this.ordinal = ordinal; + this.id = "page_" + this.ordinal; + } + + fromJSONObject(item: any): Page { + this.title = item.title; + this.id = item.id; + this.ordinal = item.ordinal; + return this; + } + + buildForm(): FormGroup { + let formGroup = this.formBuilder.group({ + title: [this.title], + id: [this.id], + ordinal: [this.ordinal] + }); + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/Rule.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/Rule.ts new file mode 100644 index 000000000..22f697967 --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/Rule.ts @@ -0,0 +1,34 @@ +import { BaseModel } from '../BaseModel'; +import { FormGroup } from '@angular/forms'; +import { FormGenerator } from '../interfaces/FormGenerator'; +import { Serializable } from '../interfaces/Serializable'; +export class Rule extends BaseModel implements Serializable,FormGenerator{ + public sourceField:string; + public target:string; + public value: string; + public ruleType: string; + public ruleStyle: string; + public valueType: string; + + fromJSONObject(item:any):Rule{ + this.sourceField = item.sourceField; + this.target = item.target; + this.value = item.value; + this.ruleType = item.ruleType; + this.ruleStyle = item.ruleStyle; + this.valueType = item.valueType; + return this; + } + + buildForm():FormGroup{ + let formGroup = this.formBuilder.group({ + sourceField: [this.sourceField], + target: [this.target], + ruleStyle: [this.ruleStyle], + value: [this.value], + ruleType: [this.ruleType], + valueType: [this.valueType] + }); + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/Section.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/Section.ts new file mode 100644 index 000000000..7efdb5ef2 --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/Section.ts @@ -0,0 +1,70 @@ +import { JsonSerializer } from '../../utilities/JsonSerializer'; +import { FieldSet } from './FieldSet'; +import { BaseModel } from '../BaseModel'; +import { FormGenerator } from '../interfaces/FormGenerator'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { Serializable } from '../interfaces/Serializable'; + +export class Section extends BaseModel implements Serializable, FormGenerator{ + public sections: Array = new Array(); + //public fieldGroups: Array = new Array(); + public defaultVisibility: boolean; + public page: number; + public id: string + public title: string + public description: string; + public ordinal: number; + public fieldSets: Array = new Array(); + + fromJSONObject(item: any): Section { + this.sections = JsonSerializer.fromJSONArray(item.sections, Section); + //this.fieldGroups = new JsonSerializer().fromJSONArray(item.fieldGroups, FieldGroup); + this.page = item.page; + this.defaultVisibility = item.defaultVisibility; + this.id = item.id; + this.title = item.title; + this.description = item.description; + this.ordinal = item.ordinal; + this.fieldSets = JsonSerializer.fromJSONArray(item.fieldSets, FieldSet); + return this; + } + + buildForm(): FormGroup { + let formGroup: FormGroup = new FormBuilder().group({}); + let sectionsFormArray = new Array(); + if (this.sections) { + this.sections.forEach(item => { + let form: FormGroup = item.buildForm(); + sectionsFormArray.push(form) + }) + } + // let fieldGroupsFormArray = new Array(); + // if (this.fieldGroups) { + // this.fieldGroups.forEach(item => { + // let form: FormGroup = item.buildForm(); + // fieldGroupsFormArray.push(form) + // }) + // } + let compositeFieldsFormArray = new Array(); + if (this.fieldSets) { + this.fieldSets.forEach(item => { + let form: FormGroup = item.buildForm(); + compositeFieldsFormArray.push(form) + }) + } + + formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); + // formGroup.addControl('fieldGroups', this.formBuilder.array(fieldGroupsFormArray)); + formGroup.addControl('fieldSets', this.formBuilder.array(compositeFieldsFormArray)); + formGroup.addControl('defaultVisibility', new FormControl(this.defaultVisibility)); + formGroup.addControl('page', new FormControl(this.page, [Validators.required])); + formGroup.addControl('id', new FormControl(this.id)); + formGroup.addControl('title', new FormControl(this.title)); + formGroup.addControl('description', new FormControl(this.description)); + formGroup.addControl('ordinal', new FormControl(this.ordinal)); + + if( !formGroup.controls["defaultVisibility"].value) formGroup.controls["defaultVisibility"].setValue(true); + + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/ViewStyle.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/ViewStyle.ts new file mode 100644 index 000000000..c5ef91a9d --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/ViewStyle.ts @@ -0,0 +1,24 @@ +import { BaseModel } from '../BaseModel'; +import { FormGroup } from '@angular/forms'; +import { FormGenerator } from '../interfaces/FormGenerator'; +import { Serializable } from '../interfaces/Serializable'; + +export class ViewStyle extends BaseModel implements Serializable,FormGenerator{ + public cssClass:string; + public renderStyle:string; + + fromJSONObject(item:any):ViewStyle{ + this.cssClass = item.cssClass; + this.renderStyle = item.renderStyle; + return this; + } + + buildForm():FormGroup{ + let formGroup = this.formBuilder.group({ + cssClass: [this.cssClass], + renderStyle: [this.renderStyle] + + }); + return formGroup; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasetProfileAdmin/Visibility.ts b/dmp-frontend/src/app/models/datasetProfileAdmin/Visibility.ts new file mode 100644 index 000000000..6c240a505 --- /dev/null +++ b/dmp-frontend/src/app/models/datasetProfileAdmin/Visibility.ts @@ -0,0 +1,37 @@ +import { BaseModel } from '../BaseModel'; +import { Rule } from "./Rule"; +import { FormGenerator } from "../interfaces/FormGenerator"; +import { FormGroup } from '@angular/forms'; +import { Serializable } from '../interfaces/Serializable'; +import { JsonSerializer } from 'app/utilities/JsonSerializer'; + +export class Visibility extends BaseModel implements Serializable, FormGenerator{ + public rules: Array = new Array(); + public style:string; + + fromJSONObject(item:any):Visibility{ + this.rules = JsonSerializer.fromJSONArray(item.rules, Rule); + this.style = item.style; + + return this; + } + + buildForm():FormGroup{ + let formGroup = this.formBuilder.group({ + style:[this.style] + }) + + let rulesFormArray = new Array(); + if (this.rules){ + this.rules.forEach(rule =>{ + let form:FormGroup = rule.buildForm(); + rulesFormArray.push(form); + }); + } + + formGroup.addControl("rules", this.formBuilder.array(rulesFormArray)); + + return formGroup; + } + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/services/dataset-profile.service.ts b/dmp-frontend/src/app/services/dataset-profile.service.ts new file mode 100644 index 000000000..da174b7a0 --- /dev/null +++ b/dmp-frontend/src/app/services/dataset-profile.service.ts @@ -0,0 +1,38 @@ +import { Component, Input, OnInit, AfterViewChecked, ViewChild } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { DatasetProfileAdmin } from '@app/services/datasetProfileAdmin/datasetProfileAfmin.service'; + +@Injectable() +export class DatasetProfileService implements OnInit { + + constructor(public datasetProfileAdmin: DatasetProfileAdmin) { + } + + + ngOnInit(){ + + } + + fetchAllDatasetProfiles(){ + // return this.restBase.get("datasetprofiles/getAll"); + } + + getDatasetProfileById(datasetProfileID){ + return this.datasetProfileAdmin.getDatasetProfileById(datasetProfileID); + } + + createDatasetProfile(datasetProfile){ + // return this.restBase.post("datasetprofile/create", datasetProfile); + } + + updateDatasetProfile(datasetProfile){ + // return this.restBase.post("datasetprofile/update", datasetProfile); + } + + delete(datasetProfile){ + // return this.restBase.post("datasetprofile/delete", datasetProfile); + } + + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts b/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts new file mode 100644 index 000000000..6ceba92ca --- /dev/null +++ b/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts @@ -0,0 +1,47 @@ +import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { HostConfiguration } from './../../app.constants'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { Observable } from 'rxjs/Observable'; +import { DataTableRequest } from '../../models/data-table/DataTableRequest'; +import { DataTableData } from '../../models/data-table/DataTableData'; +import { DatasetModel } from '../../models/datasets/DatasetModel'; +import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria'; + +import { DatasetProfileModelAdmin } from '../../models/datasetProfileAdmin/DatasetProfileModelAdmin'; + + +@Injectable() +export class DatasetProfileAdmin { + + private actionUrl: string; + private headers: HttpHeaders; + + constructor(private http: BaseHttpService) { + + 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 }); + } + + 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 }) + } + // getPaged(dataTableRequest: DataTableRequest): Observable> { + // return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); + // } + + // makeDatasetPublic(id: String){ + // return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }) + // } + +} diff --git a/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.html b/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.html new file mode 100644 index 000000000..aa75c0aff --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.html @@ -0,0 +1,13 @@ + + + + Label + + + + Url + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.ts new file mode 100644 index 000000000..c84c28eb0 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/autocomplete/autocomplete-component.ts @@ -0,0 +1,23 @@ +import { AutocompleteData } from '../../../models/DataField/AutocompleteData'; +import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { FormArray } from '@angular/forms'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; + +@Component({ + selector: 'autocomplete-component', + templateUrl: './autocomplete-component.html' +}) +export class AutocompleteComponent implements OnInit{ + @Input() dataModel: Field; + @Input() form: FormGroup; + private data:AutocompleteData = new AutocompleteData(); + + ngOnInit(){ + this.data.type= "autocomplete"; + let autocomplete: AutocompleteData = new AutocompleteData(); + //this.dataModel.data = new JsonSerializer().fromJSONObject(this.data,AutocompleteData); + //(this.form.get("data")).push(autocomplete.buildForm()); + this.form.addControl("data", this.data.buildForm()); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.html b/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.html new file mode 100644 index 000000000..2411edac1 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.html @@ -0,0 +1,9 @@ + + + + Label + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.ts new file mode 100644 index 000000000..b32cc8b81 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/booleanDecision/booleanDecision-component.ts @@ -0,0 +1,20 @@ + +import { BooleanDecisionData } from '../../../models/DataField/BooleanDecisionData'; +import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { FormArray } from '@angular/forms'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; + +@Component({ + selector: 'booleanDecision-component', + templateUrl: './booleanDecision-component.html' +}) +export class BooleanDecisionComponent implements OnInit{ + @Input() dataModel: Field; + @Input() form: FormGroup; + private data:BooleanDecisionData = new BooleanDecisionData(); + + ngOnInit(){ + this.form.addControl("data", this.data.buildForm()); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.html b/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.html new file mode 100644 index 000000000..2411edac1 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.html @@ -0,0 +1,9 @@ + + + + Label + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.ts new file mode 100644 index 000000000..181dbb90d --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/checkbox/checkbox-component.ts @@ -0,0 +1,20 @@ +import { CheckBoxData } from '../../../models/DataField/CheckBoxData'; +import { BooleanDecisionData } from '../../../models/DataField/BooleanDecisionData'; +import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { FormArray } from '@angular/forms'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; + +@Component({ + selector: 'checkbox-component', + templateUrl: './checkbox-component.html' +}) +export class CheckBoxComponent implements OnInit{ + @Input() dataModel: Field; + @Input() form: FormGroup; + private data:CheckBoxData = new CheckBoxData(); + + ngOnInit(){ + this.form.addControl("data", this.data.buildForm()); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.html b/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.html new file mode 100644 index 000000000..a3eb851a1 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.html @@ -0,0 +1,16 @@ + + Type of Combobox + + {{option.value}} + + + + + + + + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.ts new file mode 100644 index 000000000..5667176d8 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/combobox/combobox-component.ts @@ -0,0 +1,25 @@ +import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; + +@Component({ + selector: 'combobox-component', + 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"}]; + + ngOnInit(){ + if (this.dataModel.data && this.form.get("data")){ + this.type = this.form.get("data").get("type").value; + } + + } + + onchangeCombo(){ + if (this.form.get("data")) this.form.removeControl("data"); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.html b/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.html new file mode 100644 index 000000000..2411edac1 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.html @@ -0,0 +1,9 @@ + + + + Label + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.ts new file mode 100644 index 000000000..4cf826f00 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/freetext/freetext-component.ts @@ -0,0 +1,21 @@ +import { FreeTextData } from '../../../models/DataField/FreeTextData'; +import { CheckBoxData } from '../../../models/DataField/CheckBoxData'; +import { BooleanDecisionData } from '../../../models/DataField/BooleanDecisionData'; +import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { FormArray } from '@angular/forms'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; + +@Component({ + selector: 'freetext-component', + templateUrl: './freetext-component.html' +}) +export class FreeTextComponent implements OnInit{ + @Input() dataModel: Field; + @Input() form: FormGroup; + private data:FreeTextData = new FreeTextData(); + + ngOnInit(){ + this.form.addControl("data", this.data.buildForm()); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.html b/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.html new file mode 100644 index 000000000..f33a91a9d --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.html @@ -0,0 +1,29 @@ + + + + Label + + + + + + + + Label + + + + Value + + + + + + + + + Add + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.ts new file mode 100644 index 000000000..e829f3863 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/radiobox/radiobox-component.ts @@ -0,0 +1,33 @@ +import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { RadioBoxData } from '../../../models/DataField/RadioBoxData'; +import { FormArray } from '@angular/forms'; +import { ListingItem } from '../../../models/Common/ListingItem'; +import { JsonSerializer } from '../../../utilities/JsonSerializer'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; + +@Component({ + selector: 'radiobox-component', + templateUrl: './radiobox-component.html' +}) +export class RadioBoxComponent implements OnInit{ + @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.addNewRow(); + } + + addNewRow(){ + let radioListOptions:ListingItem = new ListingItem(); + (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); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.html b/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.html new file mode 100644 index 000000000..2411edac1 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.html @@ -0,0 +1,9 @@ + + + + Label + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.ts new file mode 100644 index 000000000..fdb457f3e --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/textarea/textarea-component.ts @@ -0,0 +1,22 @@ +import { TextArea } from '../../../models/DataField/TextArea'; +import { FreeTextData } from '../../../models/DataField/FreeTextData'; +import { CheckBoxData } from '../../../models/DataField/CheckBoxData'; +import { BooleanDecisionData } from '../../../models/DataField/BooleanDecisionData'; +import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { FormArray } from '@angular/forms'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; + +@Component({ + selector: 'textarea-component', + templateUrl: './textarea-component.html' +}) +export class TextAreaComponent implements OnInit{ + @Input() dataModel: Field; + @Input() form: FormGroup; + private data:TextArea = new TextArea(); + + ngOnInit(){ + this.form.addControl("data", this.data.buildForm()); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.html b/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.html new file mode 100644 index 000000000..73da25ad7 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.html @@ -0,0 +1,28 @@ + + + + Label + + + + + + + Label + + + + Value + + + + + + + + + Add + + + + + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.ts b/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.ts new file mode 100644 index 000000000..0c105e4f0 --- /dev/null +++ b/dmp-frontend/src/app/shared/componentsAdmin/wordlist/wordlist-component.ts @@ -0,0 +1,34 @@ +import { FormGroup } from '@angular/forms'; +import { Component, Input, OnInit } from '@angular/core'; +import { WordListData } from '../../../models/DataField/WordListData'; +import { FormArray } from '@angular/forms'; +import { ListingItem } from '../../../models/Common/ListingItem'; +import { JsonSerializer } from '../../../utilities/JsonSerializer'; +import { Field } from '@app/models/datasetProfileAdmin/Field'; + +@Component({ + selector: 'wordlist-component', + templateUrl: './wordlist-component.html' +}) +export class WordlistComponent implements OnInit{ + @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(); + } + + 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); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/unauthorized/unauthorized.component.js b/dmp-frontend/src/app/unauthorized/unauthorized.component.js deleted file mode 100644 index b82d4c451..000000000 --- a/dmp-frontend/src/app/unauthorized/unauthorized.component.js +++ /dev/null @@ -1,49 +0,0 @@ -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -import { Component, Input } from "@angular/core"; -import { AuthService } from "../core/services/auth.service"; -import { ActivatedRoute, Router } from "@angular/router"; -var UnauthorizedComponent = (function () { - function UnauthorizedComponent(authService, route, router) { - this.authService = authService; - this.route = route; - this.router = router; - } - UnauthorizedComponent.prototype.ngAfterViewInit = function () { - var _this = this; - var returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/'; - var principal = this.authService.current(); - if (!principal) { - this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } }); - } - else { - this.authService.me().subscribe(function (principal) { - if (!principal) - _this.router.navigate(['/login'], { queryParams: { returnUrl: returnUrl } }); - }, function (err) { return console.error('An error occurred', err); }); - } - }; - return UnauthorizedComponent; -}()); -__decorate([ - Input(), - __metadata("design:type", String) -], UnauthorizedComponent.prototype, "message", void 0); -UnauthorizedComponent = __decorate([ - Component({ - selector: 'unauthorized-component', - templateUrl: './unauthorized.component.html' - }), - __metadata("design:paramtypes", [AuthService, - ActivatedRoute, - Router]) -], UnauthorizedComponent); -export { UnauthorizedComponent }; -//# sourceMappingURL=unauthorized.component.js.map \ No newline at end of file diff --git a/dmp-frontend/src/app/unauthorized/unauthorized.module.js b/dmp-frontend/src/app/unauthorized/unauthorized.module.js deleted file mode 100644 index 423333fa7..000000000 --- a/dmp-frontend/src/app/unauthorized/unauthorized.module.js +++ /dev/null @@ -1,37 +0,0 @@ -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -import { CommonModule } from '@angular/common'; -import { HttpClientModule } from '@angular/common/http'; -import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { UnauthorizedComponent } from './unauthorized.component'; -import { UnauthorizedRoutes } from './unauthorized.routes'; -import { SharedModule } from '../shared/shared.module'; -var UnauthorizedModule = (function () { - function UnauthorizedModule() { - } - return UnauthorizedModule; -}()); -UnauthorizedModule = __decorate([ - NgModule({ - imports: [ - CommonModule, - FormsModule, - HttpClientModule, - UnauthorizedRoutes, - SharedModule - ], - declarations: [ - UnauthorizedComponent - ], - exports: [ - UnauthorizedComponent - ] - }) -], UnauthorizedModule); -export { UnauthorizedModule }; -//# sourceMappingURL=unauthorized.module.js.map \ No newline at end of file diff --git a/dmp-frontend/src/app/unauthorized/unauthorized.routes.js b/dmp-frontend/src/app/unauthorized/unauthorized.routes.js deleted file mode 100644 index f9666de09..000000000 --- a/dmp-frontend/src/app/unauthorized/unauthorized.routes.js +++ /dev/null @@ -1,7 +0,0 @@ -import { RouterModule } from '@angular/router'; -import { UnauthorizedComponent } from './unauthorized.component'; -var routes = [ - { path: '', component: UnauthorizedComponent } -]; -export var UnauthorizedRoutes = RouterModule.forChild(routes); -//# sourceMappingURL=unauthorized.routes.js.map \ No newline at end of file