diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts index b542848..4422e58 100644 --- a/src/app/app.routing.ts +++ b/src/app/app.routing.ts @@ -149,6 +149,11 @@ const appRoutes: Routes = [ loadChildren: './pages/community/content-providers/communityContentProviders.module#CommunityContentProvidersModule', resolve: { envSpecific: EnvironmentSpecificResolver } }, + { + path: 'manage-content-providers/criteria', + loadChildren: './pages/community/content-providers/criteria/criteria.module#CriteriaModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, { path: 'mining', loadChildren: './pages/mining/mining.module#MiningModule', diff --git a/src/app/pages/community/content-providers/criteria/criteria-routing.module.ts b/src/app/pages/community/content-providers/criteria/criteria-routing.module.ts new file mode 100644 index 0000000..90a3a97 --- /dev/null +++ b/src/app/pages/community/content-providers/criteria/criteria-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import {RouterModule} from '@angular/router'; +import {IsCommunity} from '../../../../openaireLibrary/connect/communityGuard/isCommunity.guard'; +import {ConnectAdminLoginGuard} from '../../../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; +import {CriteriaComponent} from './criteria.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: CriteriaComponent} + ]) + ] +}) +export class CriteriaRoutingModule { } diff --git a/src/app/pages/community/content-providers/criteria/criteria.component.html b/src/app/pages/community/content-providers/criteria/criteria.component.html new file mode 100644 index 0000000..10eb9db --- /dev/null +++ b/src/app/pages/community/content-providers/criteria/criteria.component.html @@ -0,0 +1,108 @@ + +
+
+
+ +
+ Criteria for
+ {{dataProvider.officialname}} +
+
+
+ +
+
+
+ +
+ If no criteria are specified, all research results of this content provider will be included in your community. +
+
+
+ Add criteria to limit research results.
+ Results which satisfy any of the above criteria will be included in your community. +
+ +
+
+ No criteria are specified +
+
+
+
+
+ Criterion {{i + 1}}
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ AND +
+
+ +
+
+ +
+
+
+
+ + Add Constraint +
+
+
+
+
+
+ + Add Criterion +
+
diff --git a/src/app/pages/community/content-providers/criteria/criteria.component.ts b/src/app/pages/community/content-providers/criteria/criteria.component.ts new file mode 100644 index 0000000..4160673 --- /dev/null +++ b/src/app/pages/community/content-providers/criteria/criteria.component.ts @@ -0,0 +1,135 @@ +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {HelperFunctions} from '../../../../openaireLibrary/utils/HelperFunctions.class'; +import {SearchCommunityDataprovidersService} from '../../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; +import {EnvProperties} from '../../../../openaireLibrary/utils/properties/env-properties'; +import {ContentProvider} from '../../../../openaireLibrary/utils/entities/contentProvider'; +import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {ManageCommunityContentProvidersService} from '../../../../services/manageContentProviders.service'; + +@Component({ + selector: 'criteria', + templateUrl: './criteria.component.html' +}) + +export class CriteriaComponent implements OnInit { + public community: string = ''; + public openaireId: string = ''; + public dataProvider: ContentProvider = null; + public selcrit: FormGroup; + private properties: EnvProperties; + showLoading = true; + public errorMessage: string; + + constructor(private route: ActivatedRoute, private _router: Router, + private searchCommunityDataprovidersService: SearchCommunityDataprovidersService, + private manageCommunityContentProvidersService: ManageCommunityContentProvidersService, + private fb: FormBuilder) { + } + + ngOnInit() { + this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { + this.properties = data.envSpecific; + this.route.queryParams.subscribe(params => { + if (params['communityId']) { + this.community = params['communityId']; + } + if (params['openaireId']) { + this.openaireId = params['openaireId']; + } + this.searchCommunityDataprovidersService.searchDataproviders(this.properties, this.community).subscribe(dataProviders => { + dataProviders.forEach(dataProvider => { + if (dataProvider.openaireId == this.openaireId) { + this.dataProvider = dataProvider; + } + }); + if (!this.dataProvider) { + this._router.navigate(['manage-content-providers'], + {queryParams: {'communityId': this.community}}); + } + this.buildForm(); + this.showLoading = false; + }); + HelperFunctions.scroll(); + }); + }); + } + + public ngOnDestroy() { + } + + buildForm() { + this.selcrit = this.fb.group({ + criteria: this.fb.array([]) + }); + if (this.dataProvider.selcrit) { + this.dataProvider.selcrit.criteria.forEach(criteria => { + let constraintArray: FormArray = this.fb.array([]); + criteria.constraint.forEach(constraint => { + constraintArray.push(this.fb.group({ + field: this.fb.control(constraint.field, Validators.required), + verb: this.fb.control(constraint.verb, Validators.required), + value: this.fb.control(constraint.value, Validators.required) + })); + }); + this.criteria.push(this.fb.group({ + constraint: constraintArray + })); + }); + } + } + + public get criteria(): FormArray { + return this.selcrit.get('criteria') as FormArray; + } + + public getConstraint(i: number): FormArray { + return this.criteria.at(i).get('constraint') as FormArray; + } + + public addCriteria() { + let constraintArray: FormArray = this.fb.array([ + this.fb.group({ + field: this.fb.control('', Validators.required), + verb: this.fb.control('contains', Validators.required), + value: this.fb.control('', Validators.required) + }) + ]); + this.criteria.push(this.fb.group({ + constraint: constraintArray + })); + } + + public addConstraint(i: number) { + let constraintArray: FormArray = this.criteria.at(i).get('constraint') as FormArray; + constraintArray.push(this.fb.group({ + field: this.fb.control('', Validators.required), + verb: this.fb.control('contains', Validators.required), + value: this.fb.control('', Validators.required) + })); + } + + public removeConstraint(i: number, j: number) { + let constraintArray: FormArray = this.criteria.at(i).get('constraint') as FormArray; + constraintArray.removeAt(j); + if (constraintArray.length === 0) { + this.criteria.removeAt(i); + } + } + + save() { + this.errorMessage = null; + if (this.selcrit.status === 'VALID') { + this.dataProvider.selcrit = this.selcrit.value; + console.log(this.dataProvider); + this.manageCommunityContentProvidersService. + saveContentProvider(this.properties, this.dataProvider).subscribe( () => { + this._router.navigate(['manage-content-providers'], { + queryParams: {communityId: this.dataProvider.communityId} + }); + }); + } else { + this.errorMessage = 'Please fill all fields of each constraint or remove all constraints with empty fields.'; + } + } +} diff --git a/src/app/pages/community/content-providers/criteria/criteria.module.ts b/src/app/pages/community/content-providers/criteria/criteria.module.ts new file mode 100644 index 0000000..13c7d63 --- /dev/null +++ b/src/app/pages/community/content-providers/criteria/criteria.module.ts @@ -0,0 +1,32 @@ +import {NgModule} from '@angular/core'; + +import {EnvironmentSpecificResolver} from '../../../../openaireLibrary/utils/properties/environmentSpecificResolver'; +import {EnvironmentSpecificService} from '../../../../openaireLibrary/utils/properties/environment-specific.service'; +import {CommonModule} from '@angular/common'; +import {CriteriaComponent} from './criteria.component'; +import {CriteriaRoutingModule} from './criteria-routing.module'; +import {SearchCommunityDataprovidersService} from '../../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; +import {RouterModule} from '@angular/router'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {ManageCommunityContentProvidersService} from '../../../../services/manageContentProviders.service'; + +@NgModule({ + imports: [ + CommonModule, + CriteriaRoutingModule, + RouterModule, + FormsModule, + ReactiveFormsModule, + ], + declarations: [ + CriteriaComponent + ], + providers: [ + SearchCommunityDataprovidersService, + ManageCommunityContentProvidersService, + EnvironmentSpecificResolver, EnvironmentSpecificService + ], + exports: [CriteriaComponent] +}) + +export class CriteriaModule { } diff --git a/src/app/pages/community/content-providers/remove-content-providers.component.html b/src/app/pages/community/content-providers/remove-content-providers.component.html index 6f740a4..7d2e9b5 100644 --- a/src/app/pages/community/content-providers/remove-content-providers.component.html +++ b/src/app/pages/community/content-providers/remove-content-providers.component.html @@ -1,80 +1,102 @@ -
-
-
-
- - -
-
-
-
-
-
- All the research results collected from the content providers specified here will be automatically linked to your community dashboard. +
- + +
+ +
+
+ All the research results collected from the content providers specified here will be automatically linked to your + community dashboard.
- -
-
+
+ + +
+
- {{communitySearchUtils.totalResults | number}} content providers, page {{communitySearchUtils.page | number}} of {{(totalPages()) | number}} + {{communitySearchUtils.totalResults | number}} content providers, page {{communitySearchUtils.page | number}} + of {{(totalPages()) | number}} - - + + -
+
-
-
- - - - - - - - - - - - - - - - -
NameOfficial NameAction
- - {{result.name}} - [no name available] - - - {{result.officialname}} - - - - - -
-
+
+
+ + + + + + + + + + + + + + + + + +
NameOfficial NameCriteriaAction
+ + {{result.name}} + [no name available] + + + {{result.officialname}} + - + + + {{result.selcrit.criteria.length}} criteria + no criteria + + + +
+
-
-
+
+
- {{communitySearchUtils.totalResults | number}} content providers, page {{communitySearchUtils.page | number}} of {{(totalPages()) | number}} + {{communitySearchUtils.totalResults | number}} content providers, page {{communitySearchUtils.page | number}} + of {{(totalPages()) | number}} - - + + -
+
- + diff --git a/src/app/pages/community/content-providers/remove-content-providers.component.ts b/src/app/pages/community/content-providers/remove-content-providers.component.ts index 6a1dff2..957f670 100644 --- a/src/app/pages/community/content-providers/remove-content-providers.component.ts +++ b/src/app/pages/community/content-providers/remove-content-providers.component.ts @@ -306,4 +306,14 @@ export class RemoveContentProvidersComponent implements OnInit { ); } } + + goToCriteria(openaireId: string) { + this._router.navigate(['criteria'], { + queryParams: { + communityId: this.community, + openaireId: openaireId + }, + relativeTo: this.route + }) + } } diff --git a/src/app/pages/curator/curator.component.ts b/src/app/pages/curator/curator.component.ts index c0fd342..0b82154 100644 --- a/src/app/pages/curator/curator.component.ts +++ b/src/app/pages/curator/curator.component.ts @@ -158,7 +158,6 @@ export class CuratorComponent implements OnInit { for (let page of community.pages) { if (page['route'] === '/curators') { this.curatorsEnabled = page['isEnabled']; - console.log(this.curatorsEnabled); return; } } diff --git a/src/app/services/manageContentProviders.service.ts b/src/app/services/manageContentProviders.service.ts index adc95ed..8fe69b0 100644 --- a/src/app/services/manageContentProviders.service.ts +++ b/src/app/services/manageContentProviders.service.ts @@ -1,45 +1,34 @@ import {Injectable} from '@angular/core'; import {HttpClient, HttpHeaders} from '@angular/common/http'; -import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; +import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; +import {ContentProvider} from '../openaireLibrary/utils/entities/contentProvider'; +import {Observable} from 'rxjs/Observable'; @Injectable() export class ManageCommunityContentProvidersService { - constructor(private http: HttpClient ) {} - - removeContentProvider (properties:EnvProperties, communityId: string, id: string):any { - //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); - //let options = new RequestOptions({headers: headers, body: id}); - - let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'}); - - let url = properties.communityAPI+communityId+"/contentproviders"; - //return this.http.delete(url, options) - return this.http.request('delete', url, { body: id, headers: headers}) + constructor(private http: HttpClient) { } - addContentProvider(properties:EnvProperties, communityId: string, contentProvider: any) { - //let headers = new Headers({'Content-Type': 'application/json'}); - //let options = new RequestOptions({headers: headers}); + removeContentProvider(properties: EnvProperties, communityId: string, id: string): any { + let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'}); + let url = properties.communityAPI + communityId + '/contentproviders'; + return this.http.request('delete', url, {body: id, headers: headers}); + } - let headers = new HttpHeaders({'Content-Type': 'application/json'}); + addContentProvider(properties: EnvProperties, communityId: string, contentProvider: any): Observable { + let url = properties.communityAPI + communityId + '/contentproviders'; + let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, communityId); + return this.http.post(url, communityContentProvider); + } - let url = properties.communityAPI+communityId+"/contentproviders"; - - let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, communityId); - - return this.http.post(url, JSON.stringify(communityContentProvider), {headers: headers}); - //return this.http.post(url, JSON.stringify(communityContentProvider), options) - //.map(res => res.json()) - } - - convertSearchContentProviderToCommunityContentProvider(contentProvider: any, community: string) : any { - let communityContentProvider = { - "communityId": community, - "officialname": "", - "name": "", - "openaireId": "" - } + saveContentProvider(properties: EnvProperties, contentProvider: ContentProvider): Observable { + let url = properties.communityAPI + contentProvider.communityId + '/contentproviders'; + return this.http.post(url, contentProvider); + } + convertSearchContentProviderToCommunityContentProvider(contentProvider: any, community: string): ContentProvider { + let communityContentProvider: ContentProvider = new ContentProvider(); + communityContentProvider.communityId = community; communityContentProvider.officialname = contentProvider.title.name; communityContentProvider.name = contentProvider.englishname; communityContentProvider.openaireId = contentProvider.id; diff --git a/src/assets/env-properties.json b/src/assets/env-properties.json index 5229564..af4d224 100644 --- a/src/assets/env-properties.json +++ b/src/assets/env-properties.json @@ -1,5 +1,5 @@ { - "environment":"production", + "environment":"development", "enablePiwikTrack" : false, "useCache" : false, "metricsAPIURL" : "https://beta.services.openaire.eu/usagestats/", @@ -32,9 +32,9 @@ "vocabulariesAPI" :"https://beta.services.openaire.eu/provision/mvc/vocabularies/", "piwikBaseUrl" :" https://analytics.openaire.eu/piwik.php?idsite=6", - "loginUrl" :"http://rudie.di.uoa.gr:8280/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login", + "loginUrl" :"http://rudie.di.uoa.gr:8080/dnet-login/openid_connect_login", - "userInfoUrl" : "http://rudie.di.uoa.gr:8280/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=", + "userInfoUrl" : "http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=", "logoutUrl" :"https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=",