From ce3b2789f86b6918456b28395743d022cf4277f7 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Fri, 14 Jul 2023 18:28:02 +0300 Subject: [PATCH] Add warning if manadatory information is not filled in the existed services. --- src/app/apis/apis.component.ts | 49 ++++++++++++++++--- src/app/app.component.ts | 2 +- src/app/openaireLibrary | 2 +- .../personal-info/personal-info.component.ts | 7 ++- src/app/services/apis.service.ts | 26 ++++++++-- src/app/services/personal.service.ts | 3 ++ src/environments/environment.beta.ts | 8 +-- src/environments/environment.prod.ts | 8 +-- src/environments/environment.ts | 8 +-- 9 files changed, 86 insertions(+), 27 deletions(-) diff --git a/src/app/apis/apis.component.ts b/src/app/apis/apis.component.ts index fa66f1b..83deeb0 100644 --- a/src/app/apis/apis.component.ts +++ b/src/app/apis/apis.component.ts @@ -1,16 +1,12 @@ import {ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild} from "@angular/core"; -import {FormBuilder, FormGroup, Validators} from "@angular/forms"; +import {FormArray, FormBuilder, FormGroup, Validators} from "@angular/forms"; import {Subscription} from "rxjs"; import {UserManagementService} from "../openaireLibrary/services/user-management.service"; import {User} from "../openaireLibrary/login/utils/helper.class"; -import {PersonalInfo, PersonalService} from "../services/personal.service"; import {NotificationHandler} from "../openaireLibrary/utils/notification-handler"; import {API, ApisService} from "../services/apis.service"; import {AlertModal} from "../openaireLibrary/utils/modal/alert"; import {StringUtils} from "../openaireLibrary/utils/string-utils.class"; -import {properties} from "../../environments/environment"; -import {Stakeholder} from "../openaireLibrary/monitor/entities/stakeholder"; -import {CommunityInfo} from "../openaireLibrary/connect/community/communityInfo"; import {UtilitiesService} from "../openaireLibrary/services/utilities.service"; declare var copy; @@ -60,8 +56,12 @@ declare var copy; (click)="openEditModal(i)"> - + @@ -77,9 +77,20 @@ declare var copy; [formInput]="form.get('name')">
-
+
+
+
+
+
+
Separate groups with commas
+
Register your service to get a client id and a client @@ -226,6 +237,8 @@ export class ApisComponent implements OnInit, OnDestroy { advanced: boolean = false; byValue: boolean = true; hint = '{"kty": ..., "e": ... , "use": ... , "kid": ..., "alg": ... , "n": ...}'; + frequency: string[] = ['Daily', 'Weekly', 'Monthly']; + groups: string[] = ['Commerce', 'Education', 'Health', 'Non profit', 'Public Sector']; @ViewChild("editModal") editModal: AlertModal; @ViewChild("deleteModal") deleteModal: AlertModal; @ViewChild("infoModal") infoModal: AlertModal; @@ -260,6 +273,14 @@ export class ApisComponent implements OnInit, OnDestroy { }) } + get target():FormArray { + if(this.form) { + return this.form.get('target'); + } else { + return this.fb.array([]); + } + } + openEditModal(index: number = -1) { let api = new API(); this.index = index; @@ -275,14 +296,26 @@ export class ApisComponent implements OnInit, OnDestroy { this.form = this.fb.group({ name: this.fb.control(api.service.name, Validators.required), keyType: this.fb.control(api.service.keyType), + description: this.fb.control(api.service.description), + frequency: this.fb.control(api.service.frequency, Validators.required), + target: this.fb.array([], Validators.required), logoURL: this.fb.control(api.details.logoUri, [StringUtils.urlValidator()]), url: this.fb.control(api.service.url, [Validators.required, StringUtils.urlValidator()]), uri: this.fb.control(api.details.jwksUri, [StringUtils.urlValidator()]), value: this.fb.control(null, [StringUtils.jsonValidator('The format should be {"kty": ..., "e": ... , "use": ... , "kid": ..., "alg": ... , "n": ...}')]) }); + if(api.service.target) { + api.service.target.forEach(target => { + this.target.push(this.fb.control(target)); + }); + } if(api.details?.jwks?.keys) { this.form.get('value').setValue(JSON.stringify(api.details.jwks.keys[0])); } + if(api.invalid) { + this.form.markAllAsTouched(); + this.cdr.detectChanges(); + } this.advanced = !!this.form.get('keyType').getRawValue(); this.byValue = this.advanced && this.form.get('keyType').getRawValue() === 'value'; this.formChanges(); @@ -323,7 +356,7 @@ export class ApisComponent implements OnInit, OnDestroy { } else { this.subscriptions.push(this.apisService.save(this.apis[this.index].service.id, this.form.getRawValue()).subscribe(api => { this.apis[this.index] = api; - NotificationHandler.rise('Your service has been created successfully.'); + NotificationHandler.rise('Your service has been saved successfully.'); this.loading = false; }, error => { console.error(error); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a74057c..a6c8f8d 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -20,7 +20,7 @@ import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component [class.sidebar_mini]="!open && hasSidebar" [class.sidebar_hover]="hover"> -
diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 5645dee..55a0454 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 5645deec97d1bd3cb35cec792ac8dc963c0f4d8a +Subproject commit 55a045433077a4fb866345456694e6490654c89f diff --git a/src/app/personal-info/personal-info.component.ts b/src/app/personal-info/personal-info.component.ts index b9d3846..823531b 100644 --- a/src/app/personal-info/personal-info.component.ts +++ b/src/app/personal-info/personal-info.component.ts @@ -27,7 +27,9 @@ import {NavigationEnd, Router} from "@angular/router"; [placeholder]="'Name'">
-
+
+
{ - return this.http.get(properties.developersApiUrl + "/apis/all", CustomOptions.registryOptions()); + return this.http.get(properties.developersApiUrl + "/apis/all", CustomOptions.registryOptions()) + .pipe(map(apis => apis.map(api => this.setInvalid(api)))); } public getMyServices(): Observable { - return this.http.get(properties.developersApiUrl + "/apis/my-services", CustomOptions.registryOptions()); + return this.http.get(properties.developersApiUrl + "/apis/my-services", CustomOptions.registryOptions()) + .pipe(map(apis => apis.map(api => this.setInvalid(api)))); } public create(form: any): Observable { - return this.http.post(properties.developersApiUrl + "/apis/save/new", form, CustomOptions.registryOptions()); + return this.http.post(properties.developersApiUrl + "/apis/save/new", form, CustomOptions.registryOptions()) + .pipe(map(api => this.setInvalid(api))); } public save(id: number, form: any): Observable { - return this.http.post(properties.developersApiUrl + "/apis/save/" + id, form, CustomOptions.registryOptions()); + return this.http.post(properties.developersApiUrl + "/apis/save/" + id, form, CustomOptions.registryOptions()) + .pipe(map(api => this.setInvalid(api))); } public delete(id: number): Observable { return this.http.delete(properties.developersApiUrl + "/apis/delete/" + id, CustomOptions.registryOptions()); } + + private setInvalid(api: API) { + api.invalid = !api.service.url || !api.service.frequency || !api.service.target || api.service.target.length == 0; + return api; + } } diff --git a/src/app/services/personal.service.ts b/src/app/services/personal.service.ts index 5e66b7c..11919d8 100644 --- a/src/app/services/personal.service.ts +++ b/src/app/services/personal.service.ts @@ -3,12 +3,15 @@ import {HttpClient} from "@angular/common/http"; import {properties} from "../../environments/environment"; import {CustomOptions} from "../openaireLibrary/services/servicesUtils/customOptions.class"; +export type AffiliationType = 'Organization' | 'University' | 'SME' | 'Public Sector'; + export interface PersonalInfo { id: string; email: string; name: string; surname: string; affiliation: string; + affiliationType: string; position: string; } diff --git a/src/environments/environment.beta.ts b/src/environments/environment.beta.ts index ff884ec..edfab3d 100644 --- a/src/environments/environment.beta.ts +++ b/src/environments/environment.beta.ts @@ -4,10 +4,10 @@ export let properties: EnvProperties = { environment: 'production', dashboard: 'developers', useCache: false, - loginUrl: "https://beta.services.openaire.eu/client-management/openid_connect_login", - userInfoUrl: "https://beta.services.openaire.eu/client-management/userInfo", - developersApiUrl: "https://beta.services.openaire.eu/client-management", - logoutUrl: "https://beta.services.openaire.eu/client-management/openid_logout", + loginUrl: "https://beta.services.openaire.eu/developers-api/openid_connect_login", + userInfoUrl: "https://beta.services.openaire.eu/developers-api/userInfo", + developersApiUrl: "https://beta.services.openaire.eu/developers-api", + logoutUrl: "https://beta.services.openaire.eu/developers-api/openid_logout", cookieDomain: '.openaire.eu', errorLink: '/error', }; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 6f9e205..430874b 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -4,10 +4,10 @@ export let properties: EnvProperties = { environment: 'production', dashboard: 'developers', useCache: false, - loginUrl: "https://services.openaire.eu/client-management/openid_connect_login", - userInfoUrl: "https://services.openaire.eu/client-management/userInfo", - developersApiUrl: "https://services.openaire.eu/client-management", - logoutUrl: "https://services.openaire.eu/client-management/openid_logout", + loginUrl: "https://services.openaire.eu/developers-api/openid_connect_login", + userInfoUrl: "https://services.openaire.eu/developers-api/userInfo", + developersApiUrl: "https://services.openaire.eu/developers-api", + logoutUrl: "https://services.openaire.eu/developers-api/openid_logout", cookieDomain: '.openaire.eu', errorLink: '/error', }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 470d36a..994a2c5 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -9,10 +9,10 @@ export let properties: EnvProperties = { environment: 'development', dashboard: 'developers', useCache: false, - loginUrl: "http://mpagasas.di.uoa.gr:19580/client-management/openid_connect_login", - userInfoUrl: "http://mpagasas.di.uoa.gr:19580/client-management/userInfo", - developersApiUrl: "http://mpagasas.di.uoa.gr:19580/client-management", - logoutUrl: "http://mpagasas.di.uoa.gr:19580/client-management/openid_logout", + loginUrl: "http://mpagasas.di.uoa.gr:19580/developers-api/openid_connect_login", + userInfoUrl: "http://mpagasas.di.uoa.gr:19580/developers-api/userInfo", + developersApiUrl: "http://mpagasas.di.uoa.gr:19580/developers-api", + logoutUrl: "http://mpagasas.di.uoa.gr:19580/developers-api/openid_logout", cookieDomain: '.di.uoa.gr', errorLink: '/error', domain: 'http://mpagasas.di.uoa.gr:5001',