From 1c535a872f73ecf7c731ec8c97f6195652dae0f8 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 11 Jul 2026 23:21:30 +0200 Subject: [PATCH 1/4] Add multi-role account --- .../src/main/inse/account_management/model.py | 35 ++++++-- service/src/main/inse/auth/model.py | 87 +++++++++++++++++-- service/src/main/inse/database.py | 15 ++++ 3 files changed, 125 insertions(+), 12 deletions(-) diff --git a/service/src/main/inse/account_management/model.py b/service/src/main/inse/account_management/model.py index 8b21edf7..dd6a11c6 100644 --- a/service/src/main/inse/account_management/model.py +++ b/service/src/main/inse/account_management/model.py @@ -1,9 +1,9 @@ import uuid from typing import List, Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, Field, model_validator -from inse.auth.model import UserRole +from inse.auth.model import UserRole, normalize_roles class OrganizationProfile(BaseModel): @@ -16,7 +16,7 @@ class AccountProfile(BaseModel): id: uuid.UUID email: str name: str - role: UserRole + roles: List[UserRole] organization_id: uuid.UUID organization_name: str deleted: bool @@ -34,20 +34,45 @@ class AccountPage(BaseModel): class CreateAccountRequest(BaseModel): + @model_validator(mode="before") + @classmethod + def _role_to_roles(cls, values): + if isinstance(values, dict) and "roles" not in values and "role" in values: + values = {**values, "roles": [values["role"]]} + return values + email: str = Field(min_length=3) name: str = Field(min_length=1) - role: UserRole = UserRole.USER + roles: List[UserRole] = Field(default_factory=lambda: [UserRole.USER]) organization_id: uuid.UUID password: str = Field(min_length=8) openalex_person_id: Optional[str] = None + @model_validator(mode="after") + def _normalize_roles(self): + self.roles = normalize_roles(self.roles) + return self + class UpdateAccountRequest(BaseModel): + @model_validator(mode="before") + @classmethod + def _role_to_roles(cls, values): + if isinstance(values, dict) and "roles" not in values and "role" in values: + values = {**values, "roles": [values["role"]]} + return values + email: Optional[str] = Field(default=None, min_length=3) name: Optional[str] = Field(default=None, min_length=1) - role: Optional[UserRole] = None + roles: Optional[List[UserRole]] = None organization_id: Optional[uuid.UUID] = None password: Optional[str] = Field(default=None, min_length=8) openalex_person_id: Optional[str] = None deleted: Optional[bool] = None activated: Optional[bool] = None + + @model_validator(mode="after") + def _normalize_roles(self): + if self.roles is not None: + self.roles = normalize_roles(self.roles) + return self diff --git a/service/src/main/inse/auth/model.py b/service/src/main/inse/auth/model.py index 4848cb78..06596ff4 100644 --- a/service/src/main/inse/auth/model.py +++ b/service/src/main/inse/auth/model.py @@ -3,8 +3,8 @@ from datetime import datetime from enum import StrEnum from typing import List -from pydantic import BaseModel -from sqlalchemy import UniqueConstraint +from pydantic import BaseModel, model_validator +from sqlalchemy import JSON, Column, UniqueConstraint from sqlmodel import Field, Relationship, SQLModel @@ -15,6 +15,35 @@ class UserRole(StrEnum): USER = "USER" +ROLE_PRIORITY = { + UserRole.SUPER_ADMIN: 0, + UserRole.ADMIN: 1, + UserRole.MANAGER: 2, + UserRole.USER: 3, +} + + +def normalize_roles(roles: List[UserRole] | List[str] | UserRole | str | None) -> List[UserRole]: + if roles is None: + return [UserRole.USER] + if isinstance(roles, (str, UserRole)): + roles = [roles] + + normalized = [] + seen = set() + for role in roles: + user_role = role if isinstance(role, UserRole) else UserRole(role) + if user_role not in seen: + normalized.append(user_role) + seen.add(user_role) + + return sorted(normalized or [UserRole.USER], key=lambda role: ROLE_PRIORITY[role]) + + +def effective_role_for_roles(roles: List[UserRole] | List[str] | UserRole | str | None) -> UserRole: + return normalize_roles(roles)[0] + + class TokenType(StrEnum): ID_TOKEN = "ID_TOKEN" REFRESH_TOKEN = "REFRESH_TOKEN" @@ -57,6 +86,13 @@ class Organization(Durable, table=True): class Account(Durable, table=True): + @model_validator(mode="before") + @classmethod + def _role_to_roles(cls, values): + if isinstance(values, dict) and "roles" not in values and "role" in values: + values = {**values, "roles": [values["role"]]} + return values + id: uuid.UUID | None = Field( default_factory=uuid.uuid4, primary_key=True, @@ -101,15 +137,22 @@ class Account(Durable, table=True): nullable=False, description="The unique identifier of the organization strictly associated with this account.", ) - role: UserRole = Field( - default=UserRole.USER, - index=True, - nullable=False, - description="The specific role this account holds within its organization.", + roles: List[UserRole] = Field( + default_factory=lambda: [UserRole.USER], + sa_column=Column(JSON, nullable=False, default=lambda: [UserRole.USER.value]), + description="The roles this account holds within its organization.", ) organization: Organization = Relationship(back_populates="accounts") + @property + def role(self) -> UserRole: + return effective_role_for_roles(self.roles) + + @role.setter + def role(self, value: UserRole) -> None: + self.roles = normalize_roles(value) + class Secret(SQLModel, table=True): __table_args__ = ( @@ -176,6 +219,17 @@ class IdTokenMetadata(BaseTokenData): class AccessTokenMetadata(BaseTokenData): + @model_validator(mode="before") + @classmethod + def _effective_role_to_roles(cls, values): + if ( + isinstance(values, dict) + and "effective_roles" not in values + and "effective_role" in values + ): + values = {**values, "effective_roles": [values["effective_role"]]} + return values + token_type: TokenType = Field( default=TokenType.ACCESS_TOKEN, const=True, @@ -191,6 +245,10 @@ class AccessTokenMetadata(BaseTokenData): default=UserRole.USER, description="The specific role this access token grants within its organization.", ) + effective_roles: List[UserRole] = Field( + default_factory=lambda: [UserRole.USER], + description="The roles this access token grants within its organization.", + ) effective_organization_id: uuid.UUID = Field( description="The unique identifier of the organization associated with this access token.", ) @@ -211,6 +269,17 @@ class AccessToken(AccessTokenMetadata): class RefreshTokenMetadata(BaseTokenData): + @model_validator(mode="before") + @classmethod + def _effective_role_to_roles(cls, values): + if ( + isinstance(values, dict) + and "effective_roles" not in values + and "effective_role" in values + ): + values = {**values, "effective_roles": [values["effective_role"]]} + return values + token_type: TokenType = Field( default=TokenType.REFRESH_TOKEN, const=True, @@ -223,6 +292,10 @@ class RefreshTokenMetadata(BaseTokenData): default=UserRole.USER, description="The specific role this access token grants within its organization.", ) + effective_roles: List[UserRole] = Field( + default_factory=lambda: [UserRole.USER], + description="The roles this access token grants within its organization.", + ) effective_organization_id: uuid.UUID = Field( description="The unique identifier of the organization associated with this access token.", ) diff --git a/service/src/main/inse/database.py b/service/src/main/inse/database.py index 077f7faa..6ad5da6d 100644 --- a/service/src/main/inse/database.py +++ b/service/src/main/inse/database.py @@ -91,6 +91,21 @@ def create_db_and_tables(): "BOOLEAN NOT NULL DEFAULT TRUE" ) ) + if "roles" not in columns: + with engine.begin() as connection: + connection.execute( + text( + "ALTER TABLE account ADD COLUMN roles " + "JSON NOT NULL DEFAULT '[\"USER\"]'" + ) + ) + if "role" in columns: + connection.execute( + text( + "UPDATE account SET roles = '[\"' || role || '\"]' " + "WHERE role IS NOT NULL" + ) + ) def get_session(): From 13507c2ae8f64654802bd009590081d19ef595e2 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 11 Jul 2026 23:21:52 +0200 Subject: [PATCH 2/4] Support multiple roles in account services --- .../main/inse/account_management/service.py | 24 +++++++--- service/src/main/inse/auth/service.py | 44 +++++++++++++++---- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/service/src/main/inse/account_management/service.py b/service/src/main/inse/account_management/service.py index b9d9dfda..0b4a65f7 100644 --- a/service/src/main/inse/account_management/service.py +++ b/service/src/main/inse/account_management/service.py @@ -5,7 +5,13 @@ from fastapi import HTTPException, status from sqlmodel import Session, func, or_, select from inse.auth import service as auth_service -from inse.auth.model import AccessTokenMetadata, Account, Organization, UserRole +from inse.auth.model import ( + AccessTokenMetadata, + Account, + Organization, + UserRole, + normalize_roles, +) from .model import ( AccountPage, @@ -28,13 +34,17 @@ def _role_allowed_for_editor(editor_role: UserRole, role: UserRole) -> bool: return False +def _roles_allowed_for_editor(editor_role: UserRole, roles: list[UserRole]) -> bool: + return all(_role_allowed_for_editor(editor_role, role) for role in roles) + + def _account_to_profile(account: Account, token: AccessTokenMetadata) -> AccountProfile: organization_name = account.organization.name if account.organization else "" return AccountProfile( id=account.id, email=account.email, name=account.name, - role=account.role, + roles=normalize_roles(account.roles), organization_id=account.organization_id, organization_name=organization_name, deleted=account.deleted, @@ -175,7 +185,7 @@ def create_account( detail="Admins can only create accounts in their own organization.", ) - if not _role_allowed_for_editor(access_token.effective_role, payload.role): + if not _roles_allowed_for_editor(access_token.effective_role, payload.roles): raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail="You cannot assign this role.", @@ -194,7 +204,7 @@ def create_account( account = Account( email=email, name=payload.name.strip(), - role=payload.role, + roles=payload.roles, organization_id=payload.organization_id, password_hash=auth_service._hash_password(payload.password), openalex_person_id=payload.openalex_person_id, @@ -261,15 +271,15 @@ def update_account( if payload.openalex_person_id is not None: account.openalex_person_id = payload.openalex_person_id - if payload.role is not None: + if payload.roles is not None: if not can_admin_update: raise HTTPException(status_code=status.HTTP_403_FORBIDDEN) - if not _role_allowed_for_editor(access_token.effective_role, payload.role): + if not _roles_allowed_for_editor(access_token.effective_role, payload.roles): raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail="You cannot assign this role.", ) - account.role = payload.role + account.roles = payload.roles account.epoch += 1 if payload.organization_id is not None: diff --git a/service/src/main/inse/auth/service.py b/service/src/main/inse/auth/service.py index 7c1d74d4..7fcf10ac 100644 --- a/service/src/main/inse/auth/service.py +++ b/service/src/main/inse/auth/service.py @@ -28,6 +28,8 @@ from inse.auth.model import ( SecretPurpose, TokenType, UserRole, + effective_role_for_roles, + normalize_roles, ) from inse.config import get_settings from inse.database import get_session @@ -44,6 +46,7 @@ PASSWORD_RESET_MAX_REQUESTS_PER_WINDOW = 3 # 3 minutes REAL_ACCOUNT_ID_KEY = "real_account_id" EFFECTIVE_ACCOUNT_ID_KEY = "effective_account_id" EFFECTIVE_ROLE_KEY = "effective_role" +EFFECTIVE_ROLES_KEY = "effective_roles" EFFECTIVE_ORGANIZATION_ID_KEY = "effective_organization_id" EPOCH_KEY = "epoch" USER_FINGERPRINT_HASH_KEY = "user_fingerprint_hash" @@ -110,14 +113,14 @@ def create_predefined_accounts(session: Session, file_path: str): session.add(organization) for account_data in data.get("accounts", []): organization_id = uuid.UUID(account_data["organization_id"]) - role = UserRole(account_data["role"]) + roles = normalize_roles(account_data.get("roles", account_data.get("role"))) email = account_data["email"] password_hash = _hash_password(account_data["password"]) account = Account( email=email, name=account_data["name"], organization_id=organization_id, - role=role, + roles=roles, password_hash=password_hash, epoch=0, ) @@ -609,6 +612,11 @@ def _get_current_user_access_token_payload( ), epoch=access_token_payload[EPOCH_KEY], effective_role=UserRole(access_token_payload[EFFECTIVE_ROLE_KEY]), + effective_roles=normalize_roles( + access_token_payload.get( + EFFECTIVE_ROLES_KEY, access_token_payload[EFFECTIVE_ROLE_KEY] + ) + ), effective_organization_id=uuid.UUID( access_token_payload[EFFECTIVE_ORGANIZATION_ID_KEY] ), @@ -649,6 +657,11 @@ def _get_current_user_refresh_token_payload( ), epoch=refresh_token_payload[EPOCH_KEY], effective_role=UserRole(refresh_token_payload[EFFECTIVE_ROLE_KEY]), + effective_roles=normalize_roles( + refresh_token_payload.get( + EFFECTIVE_ROLES_KEY, refresh_token_payload[EFFECTIVE_ROLE_KEY] + ) + ), effective_organization_id=uuid.UUID( refresh_token_payload[EFFECTIVE_ORGANIZATION_ID_KEY] ), @@ -728,7 +741,7 @@ def _get_account_epoch( return account.epoch -def _get_account_role(session: Session, account_id: uuid.UUID) -> UserRole: +def _get_account_roles(session: Session, account_id: uuid.UUID) -> list[UserRole]: """Retrieves the role for the given account ID. Args: @@ -736,14 +749,14 @@ def _get_account_role(session: Session, account_id: uuid.UUID) -> UserRole: account_id (uuid.UUID): The unique identifier of the account for which to retrieve the role. Returns: - UserRole: The role associated with the given account ID. + list[UserRole]: The roles associated with the given account ID. """ account = session.get(Account, account_id) if not account or account.deleted or not account.activated or account.id is None: raise AccountNotFoundException - return account.role + return normalize_roles(account.roles) def _get_account_organization(session: Session, account_id: uuid.UUID) -> uuid.UUID: @@ -794,13 +807,16 @@ def _is_valid_impersonation( ): raise AccountNotFoundException - if real_account.role == UserRole.SUPER_ADMIN: + real_account_role = effective_role_for_roles(real_account.roles) + effective_account_role = effective_role_for_roles(effective_account.roles) + + if real_account_role == UserRole.SUPER_ADMIN: return True # Super admins can impersonate any account if real_account.organization_id != effective_account.organization_id: return False # Cannot impersonate accounts from different organizations - if real_account.role == UserRole.ADMIN and effective_account.role in [ + if real_account_role == UserRole.ADMIN and effective_account_role in [ UserRole.MANAGER, UserRole.USER, ]: @@ -847,7 +863,8 @@ def get_access_token( detail="Impersonation not allowed", ) - role = _get_account_role(session=session, account_id=effective_account_id) + roles = _get_account_roles(session=session, account_id=effective_account_id) + role = effective_role_for_roles(roles) epoch = _get_account_epoch(account_id=effective_account_id, session=session) organization_id = _get_account_organization( session=session, account_id=effective_account_id @@ -862,6 +879,7 @@ def get_access_token( effective_organization_id=organization_id, epoch=epoch, user_fingerprint_hash=user_fingerprint_hash, + effective_roles=roles, ) _set_refresh_token( response=response, @@ -870,6 +888,7 @@ def get_access_token( effective_role=role, effective_organization_id=organization_id, epoch=epoch, + effective_roles=roles, ) return AccessResponse( access_token=access_token, @@ -974,6 +993,7 @@ def refresh_access_token( effective_organization_id=refresh_token.effective_organization_id, epoch=refresh_token.epoch, user_fingerprint_hash=user_fingerprint_hash, + effective_roles=refresh_token.effective_roles, ) @@ -1020,6 +1040,7 @@ def _set_refresh_token( effective_role: UserRole, effective_organization_id: uuid.UUID, epoch: int, + effective_roles: list[UserRole] | None = None, ) -> RefreshTokenMetadata: """Builds a refresh token for the specified account IDs, role, organization ID, epoch, and fingerprint hash. @@ -1038,10 +1059,12 @@ def _set_refresh_token( expires_at = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( minutes=REFRESH_TOKEN_EXPIRATION_MINUTES ) + effective_roles = normalize_roles(effective_roles or effective_role) payload = { REAL_ACCOUNT_ID_KEY: str(real_account_id), EFFECTIVE_ACCOUNT_ID_KEY: str(effective_account_id), EFFECTIVE_ROLE_KEY: effective_role.value, + EFFECTIVE_ROLES_KEY: [role.value for role in effective_roles], EFFECTIVE_ORGANIZATION_ID_KEY: str(effective_organization_id), EPOCH_KEY: epoch, } @@ -1058,6 +1081,7 @@ def _set_refresh_token( expires_at=expires_at, epoch=epoch, effective_role=effective_role, + effective_roles=effective_roles, effective_organization_id=effective_organization_id, ) @@ -1069,6 +1093,7 @@ def _build_access_token( effective_organization_id: uuid.UUID, epoch: int, user_fingerprint_hash: str, + effective_roles: list[UserRole] | None = None, ) -> AccessToken: """Builds an access token for the specified account IDs, role, organization ID, epoch, and fingerprint hash. @@ -1087,10 +1112,12 @@ def _build_access_token( expires_at = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( minutes=ACCESS_TOKEN_EXPIRATION_MINUTES ) + effective_roles = normalize_roles(effective_roles or effective_role) payload = { REAL_ACCOUNT_ID_KEY: str(real_account_id), EFFECTIVE_ACCOUNT_ID_KEY: str(effective_account_id), EFFECTIVE_ROLE_KEY: effective_role.value, + EFFECTIVE_ROLES_KEY: [role.value for role in effective_roles], EFFECTIVE_ORGANIZATION_ID_KEY: str(effective_organization_id), EPOCH_KEY: epoch, USER_FINGERPRINT_HASH_KEY: user_fingerprint_hash, @@ -1108,6 +1135,7 @@ def _build_access_token( expires_at=expires_at, epoch=epoch, effective_role=effective_role, + effective_roles=effective_roles, effective_organization_id=effective_organization_id, user_fingerprint_hash=user_fingerprint_hash, raw_token=raw_token, From 1e8e82f1d9082666d65597833a26037e69ad5933 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Sat, 11 Jul 2026 23:22:12 +0200 Subject: [PATCH 3/4] Support multiple roles in account UI --- webapp/src/app/api/model/accessToken.ts | 1 + webapp/src/app/api/model/accountProfile.ts | 2 +- .../src/app/api/model/createAccountRequest.ts | 2 +- .../src/app/api/model/updateAccountRequest.ts | 2 +- .../app/modules/account/account.component.ts | 2 +- .../accounts/account-dialog.component.html | 2 +- .../accounts/account-dialog.component.ts | 20 +++++++++++------- .../modules/accounts/accounts.component.html | 4 +++- .../modules/accounts/accounts.component.ts | 21 ++++++++++++++++--- 9 files changed, 40 insertions(+), 16 deletions(-) diff --git a/webapp/src/app/api/model/accessToken.ts b/webapp/src/app/api/model/accessToken.ts index 2c470009..ee3cf2ae 100644 --- a/webapp/src/app/api/model/accessToken.ts +++ b/webapp/src/app/api/model/accessToken.ts @@ -40,6 +40,7 @@ export interface AccessToken { * The specific role this access token grants within its organization. */ effective_role?: UserRole; + effective_roles?: Array; /** * The unique identifier of the organization associated with this access token. */ diff --git a/webapp/src/app/api/model/accountProfile.ts b/webapp/src/app/api/model/accountProfile.ts index 58adefb8..109f865f 100644 --- a/webapp/src/app/api/model/accountProfile.ts +++ b/webapp/src/app/api/model/accountProfile.ts @@ -14,7 +14,7 @@ export interface AccountProfile { id: string; email: string; name: string; - role: UserRole; + roles: Array; organization_id: string; organization_name: string; deleted: boolean; diff --git a/webapp/src/app/api/model/createAccountRequest.ts b/webapp/src/app/api/model/createAccountRequest.ts index 3be9003b..62745b5a 100644 --- a/webapp/src/app/api/model/createAccountRequest.ts +++ b/webapp/src/app/api/model/createAccountRequest.ts @@ -13,7 +13,7 @@ import { UserRole } from './userRole'; export interface CreateAccountRequest { email: string; name: string; - role?: UserRole; + roles?: Array; organization_id: string; password: string; openalex_person_id?: string | null; diff --git a/webapp/src/app/api/model/updateAccountRequest.ts b/webapp/src/app/api/model/updateAccountRequest.ts index efc4cea6..39b7f1dc 100644 --- a/webapp/src/app/api/model/updateAccountRequest.ts +++ b/webapp/src/app/api/model/updateAccountRequest.ts @@ -13,7 +13,7 @@ import { UserRole } from './userRole'; export interface UpdateAccountRequest { email?: string | null; name?: string | null; - role?: UserRole | null; + roles?: Array | null; organization_id?: string | null; password?: string | null; openalex_person_id?: string | null; diff --git a/webapp/src/app/modules/account/account.component.ts b/webapp/src/app/modules/account/account.component.ts index 651335a0..4f194f76 100644 --- a/webapp/src/app/modules/account/account.component.ts +++ b/webapp/src/app/modules/account/account.component.ts @@ -186,7 +186,7 @@ export class AccountComponent { constructor() { effect(() => { - this.roles = [this.accountProfile().role]; + this.roles = this.accountProfile().roles; }); } } diff --git a/webapp/src/app/modules/accounts/account-dialog.component.html b/webapp/src/app/modules/accounts/account-dialog.component.html index bb6d674d..a494ff36 100644 --- a/webapp/src/app/modules/accounts/account-dialog.component.html +++ b/webapp/src/app/modules/accounts/account-dialog.component.html @@ -24,7 +24,7 @@ Rolle - + @for (role of data.roles; track role) { {{ role }} } diff --git a/webapp/src/app/modules/accounts/account-dialog.component.ts b/webapp/src/app/modules/accounts/account-dialog.component.ts index 87fb87f2..15e312ae 100644 --- a/webapp/src/app/modules/accounts/account-dialog.component.ts +++ b/webapp/src/app/modules/accounts/account-dialog.component.ts @@ -35,7 +35,7 @@ export interface AccountDialogData { export interface AccountPayload { email?: string; name?: string; - role?: UserRole; + roles?: UserRole[]; organization_id?: string; password?: string; deleted?: boolean; @@ -45,7 +45,7 @@ export interface AccountPayload { export interface CreateAccountPayload { email: string; name: string; - role: UserRole; + roles: UserRole[]; organization_id: string; password: string; } @@ -85,7 +85,7 @@ export class AccountDialogComponent { name: new FormControl(this.data.account?.name ?? '', [ Validators.required, ]), - role: new FormControl(this.data.account?.role ?? 'USER', [ + roles: new FormControl(this.data.account?.roles ?? ['USER'], [ Validators.required, ]), organizationId: new FormControl( @@ -115,7 +115,7 @@ export class AccountDialogComponent { payload: { email: value.email ?? '', name: value.name ?? '', - role: value.role ?? 'USER', + roles: value.roles ?? ['USER'], organization_id: value.organizationId ?? '', password: value.password ?? '', }, @@ -128,7 +128,7 @@ export class AccountDialogComponent { const email = (value.email ?? '').trim(); const name = (value.name ?? '').trim(); - const role = value.role ?? account.role; + const roles = value.roles ?? account.roles; const organizationId = value.organizationId ?? account.organization_id; const password = value.password?.trim() ?? ''; @@ -140,8 +140,8 @@ export class AccountDialogComponent { payload.name = name; } - if (role !== account.role) { - payload.role = role; + if (!this.sameRoles(roles, account.roles)) { + payload.roles = roles; } if (password) { @@ -166,4 +166,10 @@ export class AccountDialogComponent { protected close(): void { this.dialogRef.close(); } + + private sameRoles(left: UserRole[], right: UserRole[]): boolean { + return ( + left.length === right.length && left.every((role) => right.includes(role)) + ); + } } diff --git a/webapp/src/app/modules/accounts/accounts.component.html b/webapp/src/app/modules/accounts/accounts.component.html index 7e1f45e0..8c88c468 100644 --- a/webapp/src/app/modules/accounts/accounts.component.html +++ b/webapp/src/app/modules/accounts/accounts.component.html @@ -44,7 +44,9 @@ - {{ row.role | role }} + @for (role of row.roles; track role) { + {{ role | role }} + } diff --git a/webapp/src/app/modules/accounts/accounts.component.ts b/webapp/src/app/modules/accounts/accounts.component.ts index 127d259c..b8ec1d26 100644 --- a/webapp/src/app/modules/accounts/accounts.component.ts +++ b/webapp/src/app/modules/accounts/accounts.component.ts @@ -126,10 +126,10 @@ export class AccountsComponent implements OnInit { accessorKey: 'organization_name', }, { - id: 'role', + id: 'roles', header: 'Rolle', type: 'accessor', - accessorKey: 'role', + accessorKey: 'roles', cellTemplate: this.accountRoleTmp(), }, { @@ -325,7 +325,22 @@ export class AccountsComponent implements OnInit { return ( this.credentialService.isEffectiveAdmin() && - (account.role === 'MANAGER' || account.role === 'USER') + (this.effectiveRole(account) === 'MANAGER' || + this.effectiveRole(account) === 'USER') ); } + + protected effectiveRole(account: AccountProfile): UserRole { + const roles = account.roles; + if (roles.includes('SUPER_ADMIN')) { + return 'SUPER_ADMIN'; + } + if (roles.includes('ADMIN')) { + return 'ADMIN'; + } + if (roles.includes('MANAGER')) { + return 'MANAGER'; + } + return 'USER'; + } } From 8601024d264c4800e8a81e94b0ad8af685164e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20Paul=20Ton=C4=8Dik?= Date: Mon, 13 Jul 2026 13:12:52 +0200 Subject: [PATCH 4/4] feat(work-purposes): integrated real index for retrieval --- .../main/inse/integrations/elasticsearch.py | 1 + service/src/main/inse/model.py | 2 + service/src/main/inse/works/model.py | 8 +- .../src/main/inse/works/purpose_service.py | 111 +++- ude_person.http | 24 + webapp/src/app/api/.openapi-generator/FILES | 11 + webapp/src/app/api/api/api.ts | 6 +- webapp/src/app/api/api/bookmarks.service.ts | 229 ++++++++ webapp/src/app/api/api/dashboard.service.ts | 504 ++++++++++++++++++ .../src/app/api/model/createPersonBookmark.ts | 15 + .../app/api/model/dashboardStatisticValue.ts | 17 + .../src/app/api/model/dashboardStatistics.ts | 22 + webapp/src/app/api/model/keywordsRequest.ts | 32 +- webapp/src/app/api/model/models.ts | 10 + .../app/api/model/personBookmarkResponse.ts | 17 + webapp/src/app/api/model/topAuthor.ts | 17 + .../src/app/api/model/topAuthorStatistics.ts | 20 + webapp/src/app/api/model/topicHeatmap.ts | 19 + webapp/src/app/api/model/topicHeatmapField.ts | 19 + webapp/src/app/api/model/topicHeatmapValue.ts | 17 + webapp/src/app/api/model/workPurpose.ts | 8 +- .../institution-projects.component.html | 8 +- .../institution-projects.component.scss | 2 +- .../institution-projects.component.ts | 4 +- .../person-network.component.html | 2 +- .../person-network.component.scss | 2 +- .../person-network.component.ts | 4 +- .../person-publications.component.html | 38 +- .../person-publications.component.ts | 139 +++-- .../app-info-card.component.html} | 4 +- .../app-info-card.component.scss} | 0 .../app-info-card/app-info-card.component.ts} | 8 +- 32 files changed, 1197 insertions(+), 123 deletions(-) create mode 100644 webapp/src/app/api/api/bookmarks.service.ts create mode 100644 webapp/src/app/api/api/dashboard.service.ts create mode 100644 webapp/src/app/api/model/createPersonBookmark.ts create mode 100644 webapp/src/app/api/model/dashboardStatisticValue.ts create mode 100644 webapp/src/app/api/model/dashboardStatistics.ts create mode 100644 webapp/src/app/api/model/personBookmarkResponse.ts create mode 100644 webapp/src/app/api/model/topAuthor.ts create mode 100644 webapp/src/app/api/model/topAuthorStatistics.ts create mode 100644 webapp/src/app/api/model/topicHeatmap.ts create mode 100644 webapp/src/app/api/model/topicHeatmapField.ts create mode 100644 webapp/src/app/api/model/topicHeatmapValue.ts rename webapp/src/app/{modules/person-network-info-card/person-network-info-card.component.html => shared/ui/app-info-card/app-info-card.component.html} (78%) rename webapp/src/app/{modules/person-network-info-card/person-network-info-card.component.scss => shared/ui/app-info-card/app-info-card.component.scss} (100%) rename webapp/src/app/{modules/person-network-info-card/person-network-info-card.component.ts => shared/ui/app-info-card/app-info-card.component.ts} (61%) diff --git a/service/src/main/inse/integrations/elasticsearch.py b/service/src/main/inse/integrations/elasticsearch.py index be4bcb17..b58065cf 100644 --- a/service/src/main/inse/integrations/elasticsearch.py +++ b/service/src/main/inse/integrations/elasticsearch.py @@ -92,6 +92,7 @@ def _index_to_cluster(index: ESIndex) -> Optional[ESCluster]: ESIndex.OPENALEX_AUTHORS, ESIndex.OPENALEX_INSTITUTIONS, ESIndex.OPENALEX_PUBLICATIONS, + ESIndex.WORK_CLASSIFICATIONS, }: return ESCluster.NES elif index in { diff --git a/service/src/main/inse/model.py b/service/src/main/inse/model.py index 4b129cb9..a417cb81 100644 --- a/service/src/main/inse/model.py +++ b/service/src/main/inse/model.py @@ -98,3 +98,5 @@ class ESIndex(StrEnum): CORDIS_EU_HORIZON_EUROPE_WEB_LINKS = "cordis_eu_horizon_europe_web_links" CORDIS_EU_HORIZON_EUROPE_EUROSCIVOC = "cordis_eu_horizon_europe_euroscivoc" CORDIS_EU_HORIZON_EUROPE_LEGAL_BASIS = "cordis_eu_horizon_europe_legal_basis" + + WORK_CLASSIFICATIONS = "work-classifications" diff --git a/service/src/main/inse/works/model.py b/service/src/main/inse/works/model.py index c4e01fdb..3adaf777 100644 --- a/service/src/main/inse/works/model.py +++ b/service/src/main/inse/works/model.py @@ -45,10 +45,12 @@ class WorkList(BaseModel): class WorkPurpose(StrEnum): - """Represents the purpose of a work. Either a foundation work or an application work.""" + """Represents the purpose of a work.""" - FOUNDATION = "Foundation" - APPLICATION = "Application" + BASIC_RESEARCH = "Basic Research" + APPLIED_RESEARCH = "Applied Research" + NON_RESEARCH = "Non-Research" + EXPERIMENTAL_DEVELOPMENT = "Experimental Development" class SpecificWorkPurpose(BaseModel): diff --git a/service/src/main/inse/works/purpose_service.py b/service/src/main/inse/works/purpose_service.py index a5fe5031..6af0e233 100644 --- a/service/src/main/inse/works/purpose_service.py +++ b/service/src/main/inse/works/purpose_service.py @@ -1,6 +1,5 @@ import logging -import random -from typing import List +from typing import Dict, List from inse.exceptions import NotFoundException @@ -9,7 +8,8 @@ from inse.model import ESIndex from inse.works.model import AuthorWorkPurposes, SpecificWorkPurpose, WorkPurpose logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) +# logger.setLevel(logging.INFO) +logger.setLevel(logging.DEBUG) async def get_work_purpose(raw_oa_work_id: str) -> SpecificWorkPurpose: @@ -32,13 +32,64 @@ async def get_work_purpose(raw_oa_work_id: str) -> SpecificWorkPurpose: return SpecificWorkPurpose( raw_oa_work_id=raw_oa_work_id, publication_year=source.get("publication_year"), - purpose=WorkPurpose.FOUNDATION, # TODO: Replace with actual purpose determination logic + purpose=WorkPurpose.NON_RESEARCH, # TODO: Replace with actual purpose determination logic reasoning="This is a placeholder reasoning for the purpose determination.", ) async def get_author_work_purposes(raw_oa_author_id: str) -> AuthorWorkPurposes: raw_oa_author_id = raw_oa_author_id.strip().upper() + logger.debug(f"Retrieving work purposes for author {raw_oa_author_id}") + relevant_work_information = await get_relevant_work_information(raw_oa_author_id) + logger.debug( + f"Retrieved work ids for author {raw_oa_author_id}: {list(relevant_work_information.keys())}" + ) + raw_work_ids = list(map(_extract_raw_work_id, relevant_work_information.keys())) + logger.debug( + f"Extracted raw work ids for author {raw_oa_author_id}: {raw_work_ids}" + ) + + response = await elasticsearch.search( + index=ESIndex.WORK_CLASSIFICATIONS, + source=["work_id", "classification"], + query={"terms": {"work_id": raw_work_ids}}, + size=10000, + ) + logger.debug(f"Elasticsearch response for work classifications v2FOO: {response}") + + purposes: List[SpecificWorkPurpose] = [] + + hits_block = response.get("hits", {}) + hits = hits_block.get("hits", []) + total_hits = hits_block.get("total", {}).get("value", 0) + for hit in hits: + source = hit.get("_source", {}) + work_id = source.get("work_id") + classification = source.get("classification") + if work_id: + work_purpose = _primary_classification_category_to_work_purpose( + classification.get("primary_category", "") + ) + purposes.append( + SpecificWorkPurpose( + raw_oa_work_id=work_id, + publication_year=relevant_work_information.get( + f"https://openalex.org/{work_id}" + ), + purpose=work_purpose, + reasoning=classification.get("classification_reason"), + ) + ) + else: + logger.warning(f"Work hit without id for author {raw_oa_author_id}: {hit}") + + return AuthorWorkPurposes( + raw_oa_author_id=raw_oa_author_id, total=total_hits, purposes=purposes + ) + + +async def get_relevant_work_information(raw_oa_author_id: str) -> Dict[str, int]: + raw_oa_author_id = raw_oa_author_id.strip().upper() response = await elasticsearch.search( index=ESIndex.OPENALEX_WORKS_WILDCARD, @@ -64,38 +115,40 @@ async def get_author_work_purposes(raw_oa_author_id: str) -> AuthorWorkPurposes: logger.debug(f"Elasticsearch response for author id {raw_oa_author_id}: {response}") - purposes: List[SpecificWorkPurpose] = [] - - # TODO: implement actual retrieval of previously determined purposes for the author's works - hits_block = response.get("hits", {}) hits = hits_block.get("hits", []) - total_hits = hits_block.get("total", {}).get("value", 0) + d: Dict[str, int] = {} for hit in hits: source = hit.get("_source", {}) work_id = source.get("id") publication_year = source.get("publication_year") if work_id: - # TODO: Remove random based purpose assignment - if random.choice([True, False]): - purpose = SpecificWorkPurpose( - raw_oa_work_id=work_id, - publication_year=publication_year, - purpose=WorkPurpose.FOUNDATION, - reasoning=f"Placeholder reasoning for work {work_id}.", - ) - else: - purpose = SpecificWorkPurpose( - raw_oa_work_id=work_id, - publication_year=publication_year, - purpose=WorkPurpose.APPLICATION, - reasoning=f"Placeholder reasoning for work {work_id}.", - ) - - purposes.append(purpose) + d[work_id] = int(publication_year) if publication_year is not None else 0 else: logger.warning(f"Work hit without id for author {raw_oa_author_id}: {hit}") - return AuthorWorkPurposes( - raw_oa_author_id=raw_oa_author_id, total=total_hits, purposes=purposes - ) + return d + + +def _extract_raw_work_id(work_id: str) -> str: + """ + Extracts the raw work ID from a full OpenAlex work ID. + For example, given "https://openalex.org/W1234567890", it returns "W1234567890". + """ + if not work_id: + return "" + return work_id.split("/")[-1] + + +def _primary_classification_category_to_work_purpose( + primary_category: str, +) -> WorkPurpose: + mapping = { + "basic_research": WorkPurpose.BASIC_RESEARCH, + "applied_research": WorkPurpose.APPLIED_RESEARCH, + "non_research": WorkPurpose.NON_RESEARCH, + "experimental_development": WorkPurpose.EXPERIMENTAL_DEVELOPMENT, + } + return mapping.get( + primary_category, WorkPurpose.NON_RESEARCH + ) # Default to NON_RESEARCH if not found diff --git a/ude_person.http b/ude_person.http index b95414f9..d01c72a5 100644 --- a/ude_person.http +++ b/ude_person.http @@ -1141,6 +1141,30 @@ Content-Type: application/json ### +GET https://project.nes.uni-due.de/elastic/work-classifications/_search +Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ== +Content-Type: application/json + +### + +GET https://project.nes.uni-due.de/elastic/work-classifications/_search +Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ== +Content-Type: application/json + +{ + "size": 0, + "aggs": { + "primary_categories": { + "terms": { + "field": "classification.primary_category", + "size": 100 + } + } + } +} + +### + GET https://project.nes.uni-due.de/elastic/openalex-authors/_mapping Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ== Content-Type: application/json diff --git a/webapp/src/app/api/.openapi-generator/FILES b/webapp/src/app/api/.openapi-generator/FILES index 39425d4e..d0adc0e5 100644 --- a/webapp/src/app/api/.openapi-generator/FILES +++ b/webapp/src/app/api/.openapi-generator/FILES @@ -5,7 +5,9 @@ api.base.service.ts api.module.ts api/api.ts api/auth.service.ts +api/bookmarks.service.ts api/companyConnections.service.ts +api/dashboard.service.ts api/funding.service.ts api/iNSEService.service.ts api/institutions.service.ts @@ -69,8 +71,11 @@ model/cordisEuProjectPage.ts model/costUsd.ts model/createAccountRequest.ts model/createOrganizationRequest.ts +model/createPersonBookmark.ts model/customAuthor.ts model/customAuthorsListResponse.ts +model/dashboardStatisticValue.ts +model/dashboardStatistics.ts model/dehydratedAuthor.ts model/dehydratedFunder.ts model/dehydratedInstitution.ts @@ -170,6 +175,7 @@ model/patentsByInstitutionResponse.ts model/patentsByKeywordsRequest.ts model/patentsByKeywordsResponse.ts model/personBio.ts +model/personBookmarkResponse.ts model/projectType.ts model/projectsFilteringProperties.ts model/projectsSortBy.ts @@ -182,11 +188,16 @@ model/score.ts model/sortDirection.ts model/specificWorkPurpose.ts model/tokenType.ts +model/topAuthor.ts +model/topAuthorStatistics.ts model/topInstitutionItem.ts model/topic.ts model/topicCount.ts model/topicDomain.ts model/topicField.ts +model/topicHeatmap.ts +model/topicHeatmapField.ts +model/topicHeatmapValue.ts model/topicIds.ts model/topicSubfield.ts model/topicYearlyData.ts diff --git a/webapp/src/app/api/api/api.ts b/webapp/src/app/api/api/api.ts index 43555caf..3a480162 100644 --- a/webapp/src/app/api/api/api.ts +++ b/webapp/src/app/api/api/api.ts @@ -1,7 +1,11 @@ export * from './auth.service'; import { AuthService } from './auth.service'; +export * from './bookmarks.service'; +import { BookmarksService } from './bookmarks.service'; export * from './companyConnections.service'; import { CompanyConnectionsService } from './companyConnections.service'; +export * from './dashboard.service'; +import { DashboardService } from './dashboard.service'; export * from './funding.service'; import { FundingService } from './funding.service'; export * from './iNSEService.service'; @@ -30,4 +34,4 @@ export * from './works.service'; import { WorksService } from './works.service'; export * from './worksV2.service'; import { WorksV2Service } from './worksV2.service'; -export const APIS = [AuthService, CompanyConnectionsService, FundingService, INSEServiceService, InstitutionsService, KeywordsService, NewsService, OrganizationService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, UniversityRankingsService, WorksService, WorksV2Service]; +export const APIS = [AuthService, BookmarksService, CompanyConnectionsService, DashboardService, FundingService, INSEServiceService, InstitutionsService, KeywordsService, NewsService, OrganizationService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, UniversityRankingsService, WorksService, WorksV2Service]; diff --git a/webapp/src/app/api/api/bookmarks.service.ts b/webapp/src/app/api/api/bookmarks.service.ts new file mode 100644 index 00000000..3e0ec2e8 --- /dev/null +++ b/webapp/src/app/api/api/bookmarks.service.ts @@ -0,0 +1,229 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +// @ts-ignore +import { CreatePersonBookmark } from '../model/createPersonBookmark'; +// @ts-ignore +import { HTTPValidationError } from '../model/hTTPValidationError'; +// @ts-ignore +import { PersonBookmarkResponse } from '../model/personBookmarkResponse'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { BaseService } from '../api.base.service'; + + + +@Injectable({ + providedIn: 'root' +}) +export class BookmarksService extends BaseService { + + constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) { + super(basePath, configuration); + } + + /** + * Bookmark Person + * @endpoint put /api/bookmarks/persons/{person_id} + * @param personId + * @param createPersonBookmark + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public bookmarkPerson(personId: string, createPersonBookmark: CreatePersonBookmark, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public bookmarkPerson(personId: string, createPersonBookmark: CreatePersonBookmark, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public bookmarkPerson(personId: string, createPersonBookmark: CreatePersonBookmark, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public bookmarkPerson(personId: string, createPersonBookmark: CreatePersonBookmark, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (personId === null || personId === undefined) { + throw new Error('Required parameter personId was null or undefined when calling bookmarkPerson.'); + } + if (createPersonBookmark === null || createPersonBookmark === undefined) { + throw new Error('Required parameter createPersonBookmark was null or undefined when calling bookmarkPerson.'); + } + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/bookmarks/persons/${this.configuration.encodeParam({name: "personId", value: personId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('put', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: createPersonBookmark, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * List Person Bookmarks + * @endpoint get /api/bookmarks/persons + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public listPersonBookmarks(secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public listPersonBookmarks(secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public listPersonBookmarks(secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public listPersonBookmarks(secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/bookmarks/persons`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request>('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * Remove Person Bookmark + * @endpoint delete /api/bookmarks/persons/{person_id} + * @param personId + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public removePersonBookmark(personId: string, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public removePersonBookmark(personId: string, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public removePersonBookmark(personId: string, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public removePersonBookmark(personId: string, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (personId === null || personId === undefined) { + throw new Error('Required parameter personId was null or undefined when calling removePersonBookmark.'); + } + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/bookmarks/persons/${this.configuration.encodeParam({name: "personId", value: personId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('delete', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + +} diff --git a/webapp/src/app/api/api/dashboard.service.ts b/webapp/src/app/api/api/dashboard.service.ts new file mode 100644 index 00000000..5bf6b615 --- /dev/null +++ b/webapp/src/app/api/api/dashboard.service.ts @@ -0,0 +1,504 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +// @ts-ignore +import { DashboardStatisticValue } from '../model/dashboardStatisticValue'; +// @ts-ignore +import { DashboardStatistics } from '../model/dashboardStatistics'; +// @ts-ignore +import { HTTPValidationError } from '../model/hTTPValidationError'; +// @ts-ignore +import { TopAuthorStatistics } from '../model/topAuthorStatistics'; +// @ts-ignore +import { TopicHeatmap } from '../model/topicHeatmap'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; +import { BaseService } from '../api.base.service'; + + + +@Injectable({ + providedIn: 'root' +}) +export class DashboardService extends BaseService { + + constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string|string[], @Optional() configuration?: Configuration) { + super(basePath, configuration); + } + + /** + * Dashboard Bmbf Projects + * @endpoint get /api/dashboard/statistics/projects/bmbf + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDashboardBmbfProjects(secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDashboardBmbfProjects(secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardBmbfProjects(secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardBmbfProjects(secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/dashboard/statistics/projects/bmbf`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * Dashboard Dfg Projects + * @endpoint get /api/dashboard/statistics/projects/dfg + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDashboardDfgProjects(secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDashboardDfgProjects(secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardDfgProjects(secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardDfgProjects(secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/dashboard/statistics/projects/dfg`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * Dashboard Eu Projects + * @endpoint get /api/dashboard/statistics/projects/eu + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDashboardEuProjects(secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDashboardEuProjects(secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardEuProjects(secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardEuProjects(secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/dashboard/statistics/projects/eu`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * Dashboard Persons + * @endpoint get /api/dashboard/statistics/persons + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDashboardPersons(secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDashboardPersons(secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardPersons(secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardPersons(secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/dashboard/statistics/persons`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * Dashboard Publications + * @endpoint get /api/dashboard/statistics/publications + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDashboardPublications(secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDashboardPublications(secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardPublications(secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardPublications(secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/dashboard/statistics/publications`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * Dashboard Statistics + * @endpoint get /api/dashboard/statistics + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDashboardStatistics(secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDashboardStatistics(secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardStatistics(secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardStatistics(secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/dashboard/statistics`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * Dashboard Top Authors + * @endpoint get /api/dashboard/top-authors + * @param worksPeriod + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDashboardTopAuthors(worksPeriod?: 'all_time' | 'last_5_years', secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDashboardTopAuthors(worksPeriod?: 'all_time' | 'last_5_years', secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardTopAuthors(worksPeriod?: 'all_time' | 'last_5_years', secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardTopAuthors(worksPeriod?: 'all_time' | 'last_5_years', secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + worksPeriod, 'works_period'); + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/dashboard/top-authors`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + + /** + * Dashboard Topic Heatmap + * @endpoint get /api/dashboard/topic-heatmap + * @param fromYear + * @param toYear + * @param limit + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public getDashboardTopicHeatmap(fromYear?: number, toYear?: number, limit?: number, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDashboardTopicHeatmap(fromYear?: number, toYear?: number, limit?: number, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardTopicHeatmap(fromYear?: number, toYear?: number, limit?: number, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDashboardTopicHeatmap(fromYear?: number, toYear?: number, limit?: number, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + fromYear, 'from_year'); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + toYear, 'to_year'); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + limit, 'limit'); + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders('HTTPBearer', 'Authorization', localVarHeaders, 'Bearer '); + + const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([ + 'application/json' + ]); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + const localVarHttpContext: HttpContext = options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/dashboard/topic-heatmap`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), + reportProgress: reportProgress + } + ); + } + +} diff --git a/webapp/src/app/api/model/createPersonBookmark.ts b/webapp/src/app/api/model/createPersonBookmark.ts new file mode 100644 index 00000000..e2e196dd --- /dev/null +++ b/webapp/src/app/api/model/createPersonBookmark.ts @@ -0,0 +1,15 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface CreatePersonBookmark { + person_name?: string | null; +} + diff --git a/webapp/src/app/api/model/dashboardStatisticValue.ts b/webapp/src/app/api/model/dashboardStatisticValue.ts new file mode 100644 index 00000000..928bdd76 --- /dev/null +++ b/webapp/src/app/api/model/dashboardStatisticValue.ts @@ -0,0 +1,17 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface DashboardStatisticValue { + institution_id: string; + organization_name: string; + value: number; +} + diff --git a/webapp/src/app/api/model/dashboardStatistics.ts b/webapp/src/app/api/model/dashboardStatistics.ts new file mode 100644 index 00000000..ba33382d --- /dev/null +++ b/webapp/src/app/api/model/dashboardStatistics.ts @@ -0,0 +1,22 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface DashboardStatistics { + institution_id: string; + organization_name: string; + publications: number; + persons: number; + projects: number; + dfg_projects: number; + eu_projects: number; + bmbf_projects: number; +} + diff --git a/webapp/src/app/api/model/keywordsRequest.ts b/webapp/src/app/api/model/keywordsRequest.ts index 094ed97b..8acb7082 100644 --- a/webapp/src/app/api/model/keywordsRequest.ts +++ b/webapp/src/app/api/model/keywordsRequest.ts @@ -1,7 +1,7 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -9,18 +9,20 @@ */ import { FileUpload } from './fileUpload'; -export interface KeywordsRequest { - /** - * The input text from which to extract keywords. - */ - query: string; - files?: Array | null; - /** - * The mode of keyword extraction, e.g., \'url\', \'text\', or \'keywords\'. - */ - mode: string; - /** - * The maximum number of keywords to extract. - */ - limit?: number; + +export interface KeywordsRequest { + /** + * The input text from which to extract keywords. + */ + query: string; + files?: Array | null; + /** + * The mode of keyword extraction, e.g., \'url\', \'text\', or \'keywords\'. + */ + mode: string; + /** + * The maximum number of keywords to extract. + */ + limit?: number; } + diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index 3077033f..7559ebd9 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -43,8 +43,11 @@ export * from './cordisEuProjectPage'; export * from './costUsd'; export * from './createAccountRequest'; export * from './createOrganizationRequest'; +export * from './createPersonBookmark'; export * from './customAuthor'; export * from './customAuthorsListResponse'; +export * from './dashboardStatisticValue'; +export * from './dashboardStatistics'; export * from './dehydratedAuthor'; export * from './dehydratedFunder'; export * from './dehydratedInstitution'; @@ -59,6 +62,7 @@ export * from './euProjectData'; export * from './extractedKeywords'; export * from './extractedKeywordsLLM'; export * from './extractedKeywordsResponse'; +export * from './fileUpload'; export * from './filterInformation'; export * from './filterProperties'; export * from './fp7EurosciVoc'; @@ -142,6 +146,7 @@ export * from './patentsByInstitutionResponse'; export * from './patentsByKeywordsRequest'; export * from './patentsByKeywordsResponse'; export * from './personBio'; +export * from './personBookmarkResponse'; export * from './projectType'; export * from './projectsFilteringProperties'; export * from './projectsSortBy'; @@ -154,11 +159,16 @@ export * from './score'; export * from './sortDirection'; export * from './specificWorkPurpose'; export * from './tokenType'; +export * from './topAuthor'; +export * from './topAuthorStatistics'; export * from './topInstitutionItem'; export * from './topic'; export * from './topicCount'; export * from './topicDomain'; export * from './topicField'; +export * from './topicHeatmap'; +export * from './topicHeatmapField'; +export * from './topicHeatmapValue'; export * from './topicIds'; export * from './topicSubfield'; export * from './topicYearlyData'; diff --git a/webapp/src/app/api/model/personBookmarkResponse.ts b/webapp/src/app/api/model/personBookmarkResponse.ts new file mode 100644 index 00000000..5227060a --- /dev/null +++ b/webapp/src/app/api/model/personBookmarkResponse.ts @@ -0,0 +1,17 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface PersonBookmarkResponse { + person_id: string; + person_name: string | null; + created_at: string; +} + diff --git a/webapp/src/app/api/model/topAuthor.ts b/webapp/src/app/api/model/topAuthor.ts new file mode 100644 index 00000000..6a74fa91 --- /dev/null +++ b/webapp/src/app/api/model/topAuthor.ts @@ -0,0 +1,17 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface TopAuthor { + id?: string | null; + name: string; + count: number; +} + diff --git a/webapp/src/app/api/model/topAuthorStatistics.ts b/webapp/src/app/api/model/topAuthorStatistics.ts new file mode 100644 index 00000000..6ea5990a --- /dev/null +++ b/webapp/src/app/api/model/topAuthorStatistics.ts @@ -0,0 +1,20 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { TopAuthor } from './topAuthor'; + + +export interface TopAuthorStatistics { + institution_id: string; + works: Array; + projects: Array; + patents: Array; + news: Array; +} + diff --git a/webapp/src/app/api/model/topicHeatmap.ts b/webapp/src/app/api/model/topicHeatmap.ts new file mode 100644 index 00000000..be36dc40 --- /dev/null +++ b/webapp/src/app/api/model/topicHeatmap.ts @@ -0,0 +1,19 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { TopicHeatmapField } from './topicHeatmapField'; + + +export interface TopicHeatmap { + institution_id: string; + organization_name: string; + years: Array; + fields: Array; +} + diff --git a/webapp/src/app/api/model/topicHeatmapField.ts b/webapp/src/app/api/model/topicHeatmapField.ts new file mode 100644 index 00000000..1687c6d9 --- /dev/null +++ b/webapp/src/app/api/model/topicHeatmapField.ts @@ -0,0 +1,19 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { TopicHeatmapValue } from './topicHeatmapValue'; + + +export interface TopicHeatmapField { + id: string; + name: string; + total: number; + values: Array; +} + diff --git a/webapp/src/app/api/model/topicHeatmapValue.ts b/webapp/src/app/api/model/topicHeatmapValue.ts new file mode 100644 index 00000000..f840b938 --- /dev/null +++ b/webapp/src/app/api/model/topicHeatmapValue.ts @@ -0,0 +1,17 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface TopicHeatmapValue { + year: number; + count: number; + share: number; +} + diff --git a/webapp/src/app/api/model/workPurpose.ts b/webapp/src/app/api/model/workPurpose.ts index 617ce5e1..8001a192 100644 --- a/webapp/src/app/api/model/workPurpose.ts +++ b/webapp/src/app/api/model/workPurpose.ts @@ -10,11 +10,13 @@ /** - * Represents the purpose of a work. Either a foundation work or an application work. + * Represents the purpose of a work. */ export const WorkPurpose = { - Foundation: 'Foundation', - Application: 'Application' + BasicResearch: 'Basic Research', + AppliedResearch: 'Applied Research', + NonResearch: 'Non-Research', + ExperimentalDevelopment: 'Experimental Development' } as const; export type WorkPurpose = typeof WorkPurpose[keyof typeof WorkPurpose]; diff --git a/webapp/src/app/modules/institution-projects/institution-projects.component.html b/webapp/src/app/modules/institution-projects/institution-projects.component.html index 6da70b65..68aa24e5 100644 --- a/webapp/src/app/modules/institution-projects/institution-projects.component.html +++ b/webapp/src/app/modules/institution-projects/institution-projects.component.html @@ -43,25 +43,25 @@
- - - - @for (summary of this.summaryCards(); track $index) { - diff --git a/webapp/src/app/modules/person-network/person-network.component.scss b/webapp/src/app/modules/person-network/person-network.component.scss index 74a4778c..716b4881 100644 --- a/webapp/src/app/modules/person-network/person-network.component.scss +++ b/webapp/src/app/modules/person-network/person-network.component.scss @@ -47,7 +47,7 @@ form > div > mat-button-toggle-group { gap: 20px; } -.summary-container app-person-network-info-card { +.summary-container app-info-card { flex: 1 1 0; } diff --git a/webapp/src/app/modules/person-network/person-network.component.ts b/webapp/src/app/modules/person-network/person-network.component.ts index ebceeec9..e9172c5a 100644 --- a/webapp/src/app/modules/person-network/person-network.component.ts +++ b/webapp/src/app/modules/person-network/person-network.component.ts @@ -37,7 +37,7 @@ import { MatSelectModule } from '@angular/material/select'; import { MatExpansionModule } from '@angular/material/expansion'; import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { PersonNetworkFilterDialogComponent } from '../person-network-filter-dialog/person-network-filter-dialog.component'; -import { PersonNetworkInfoCardComponent } from '../person-network-info-card/person-network-info-card.component'; +import { AppInfoCardComponent } from '../../shared/ui/app-info-card/app-info-card.component'; import { GenericColumn, DataTableComponent, @@ -95,7 +95,7 @@ type IInstitution = { MatSelectModule, MatExpansionModule, MatDialogModule, - PersonNetworkInfoCardComponent, + AppInfoCardComponent, DataTableComponent, ], templateUrl: './person-network.component.html', diff --git a/webapp/src/app/modules/person-publications/person-publications.component.html b/webapp/src/app/modules/person-publications/person-publications.component.html index 56dca982..5e0b41ff 100644 --- a/webapp/src/app/modules/person-publications/person-publications.component.html +++ b/webapp/src/app/modules/person-publications/person-publications.component.html @@ -7,16 +7,38 @@ Forschungszwecke - {{ foundationAmount() }} Grundlagenforschung, - {{ applicationAmount() }} anwendungsbasierte - Forschung + @if (this.authorWorkPurposes().purposes?.length === 0) { +
+ Keine klassifizierten Publikationen gefunden. +
+ } @else { +
+ }
+ style=" + width: 100%; + display: flex; + gap: 1rem; + flex-wrap: wrap; + margin-top: 1rem; + "> + + + + +
diff --git a/webapp/src/app/modules/person-publications/person-publications.component.ts b/webapp/src/app/modules/person-publications/person-publications.component.ts index 19c83518..ebe1fa07 100644 --- a/webapp/src/app/modules/person-publications/person-publications.component.ts +++ b/webapp/src/app/modules/person-publications/person-publications.component.ts @@ -11,18 +11,14 @@ import { viewChild, } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; -import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; -import { ActivatedRoute, ParamMap, Router, RouterLink } from '@angular/router'; +import { FormControl, ReactiveFormsModule } from '@angular/forms'; +import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { MatAutocompleteModule, MatAutocompleteSelectedEvent, } from '@angular/material/autocomplete'; import { MatIconModule } from '@angular/material/icon'; -import { - MatPaginator, - MatPaginatorModule, - PageEvent, -} from '@angular/material/paginator'; +import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar'; import { MatTableModule } from '@angular/material/table'; @@ -34,7 +30,6 @@ import { MatTooltipModule } from '@angular/material/tooltip'; import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop'; import { catchError, - combineLatest, debounceTime, distinctUntilChanged, finalize, @@ -78,6 +73,7 @@ import { import { WorkTypePipe } from '../../shared/pipes/work-type.pipe'; import { LanguageCodePipe } from '../../shared/pipes/language-code.pipe'; import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component'; +import { AppInfoCardComponent } from '../../shared/ui/app-info-card/app-info-card.component'; echarts.use([ GridComponent, CanvasRenderer, @@ -114,17 +110,25 @@ interface TopicAutocompleteResponse { results?: TopicAutocompleteOption[] | null; } -type PublicationSort = 'year' | 'citations'; - interface YearlyPurposeCounts { year: number; - FOUNDATION: number; - APPLICATION: number; + basicResearch: number; + appliedResearch: number; + nonResearch: number; + experimentalDevelopment: number; } -const PURPOSE_LABELS: Record<'FOUNDATION' | 'APPLICATION', string> = { - FOUNDATION: 'Grundlagenforschung', - APPLICATION: 'anwendungsbasierte Forschung', +const PURPOSE_LABELS: Record< + | 'BASIC_RESEARCH' + | 'APPLIED_RESEARCH' + | 'NON_RESEARCH' + | 'EXPERIMENTAL_DEVELOPMENT', + string +> = { + BASIC_RESEARCH: 'Grundlagenforschung', + APPLIED_RESEARCH: 'anwendungsbasierte Forschung', + NON_RESEARCH: 'nicht-forschende Tätigkeit', + EXPERIMENTAL_DEVELOPMENT: 'experimentelle Entwicklung', }; @Component({ selector: 'app-person-publications', @@ -151,12 +155,12 @@ const PURPOSE_LABELS: Record<'FOUNDATION' | 'APPLICATION', string> = { WorkTypePipe, LanguageCodePipe, QueryParamPaginatorComponent, + AppInfoCardComponent, ], templateUrl: './person-publications.component.html', styleUrl: './person-publications.component.scss', }) export class PersonPublicationsComponent implements OnInit { - @ViewChild(MatPaginator) paginator?: MatPaginator; private readonly destroyRef = inject(DestroyRef); private readonly worksService = inject(WorksService); @@ -173,26 +177,43 @@ export class PersonPublicationsComponent implements OnInit { const authorWorkPurposes = this.authorWorkPurposes(); return this.getAuthorSpecificWorkPurposesByYear(authorWorkPurposes); }); - foundationAmount = computed(() => { - const authorWorkPurposes = this.authorWorkPurposes(); + basicResearchAmount = computed(() => { + return this.countPurpose( + this.authorWorkPurposes().purposes || [], + WorkPurpose.BasicResearch, + ); + }); + appliedResearchAmount = computed(() => { + return this.countPurpose( + this.authorWorkPurposes().purposes || [], + WorkPurpose.AppliedResearch, + ); + }); + nonResearchAmount = computed(() => { + return this.countPurpose( + this.authorWorkPurposes().purposes || [], + WorkPurpose.NonResearch, + ); + }); + experimentalDevelopmentAmount = computed(() => { + return this.countPurpose( + this.authorWorkPurposes().purposes || [], + WorkPurpose.ExperimentalDevelopment, + ); + }); + + countPurpose = ( + specificWorkPurposes: SpecificWorkPurpose[], + purpose: WorkPurpose, + ) => { let count = 0; - for (const purpose of authorWorkPurposes.purposes ?? []) { - if (purpose.purpose === WorkPurpose.Foundation) { + for (const specificWorkPurpose of specificWorkPurposes) { + if (specificWorkPurpose.purpose == purpose) { count++; } } return count; - }); - applicationAmount = computed(() => { - const authorWorkPurposes = this.authorWorkPurposes(); - let count = 0; - for (const purpose of authorWorkPurposes.purposes ?? []) { - if (purpose.purpose === WorkPurpose.Application) { - count++; - } - } - return count; - }); + }; chartOption!: echarts.EChartsCoreOption; @@ -223,9 +244,6 @@ export class PersonPublicationsComponent implements OnInit { readonly yearSearchControl = new FormControl('', { nonNullable: true }); readonly typeSearchControl = new FormControl('', { nonNullable: true }); readonly languageSearchControl = new FormControl('', { nonNullable: true }); - readonly sortControl = new FormControl('year', { - nonNullable: true, - }); readonly publicationYearOptions = this.createPublicationYearOptions(); @@ -379,14 +397,20 @@ export class PersonPublicationsComponent implements OnInit { .map(([year, purposes]) => { const counts: YearlyPurposeCounts = { year: Number(year), - FOUNDATION: 0, - APPLICATION: 0, + basicResearch: 0, + appliedResearch: 0, + nonResearch: 0, + experimentalDevelopment: 0, }; for (const purpose of purposes) { - if (purpose.purpose === WorkPurpose.Foundation) { - counts.FOUNDATION++; - } else if (purpose.purpose === WorkPurpose.Application) { - counts.APPLICATION++; + if (purpose.purpose == WorkPurpose.BasicResearch) { + counts.basicResearch++; + } else if (purpose.purpose == WorkPurpose.AppliedResearch) { + counts.appliedResearch++; + } else if (purpose.purpose == WorkPurpose.NonResearch) { + counts.nonResearch++; + } else if (purpose.purpose == WorkPurpose.ExperimentalDevelopment) { + counts.experimentalDevelopment++; } } return counts; @@ -398,15 +422,20 @@ export class PersonPublicationsComponent implements OnInit { return { tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, legend: { - data: [PURPOSE_LABELS.FOUNDATION, PURPOSE_LABELS.APPLICATION], - top: 0, + data: [ + PURPOSE_LABELS.BASIC_RESEARCH, + PURPOSE_LABELS.APPLIED_RESEARCH, + PURPOSE_LABELS.NON_RESEARCH, + PURPOSE_LABELS.EXPERIMENTAL_DEVELOPMENT, + ], + bottom: 0, itemGap: 40, }, grid: { left: '3%', right: '4%', - bottom: '3%', - top: '10%', + bottom: '10%', + top: '3%', containLabel: true, }, xAxis: { @@ -416,18 +445,32 @@ export class PersonPublicationsComponent implements OnInit { yAxis: { type: 'value' }, series: [ { - name: PURPOSE_LABELS.FOUNDATION, + name: PURPOSE_LABELS.BASIC_RESEARCH, type: 'bar', stack: 'total', emphasis: { focus: 'series' }, - data: data.map((d) => d.FOUNDATION), + data: data.map((d) => d.basicResearch), }, { - name: PURPOSE_LABELS.APPLICATION, + name: PURPOSE_LABELS.APPLIED_RESEARCH, type: 'bar', stack: 'total', emphasis: { focus: 'series' }, - data: data.map((d) => d.APPLICATION), + data: data.map((d) => d.appliedResearch), + }, + { + name: PURPOSE_LABELS.NON_RESEARCH, + type: 'bar', + stack: 'total', + emphasis: { focus: 'series' }, + data: data.map((d) => d.nonResearch), + }, + { + name: PURPOSE_LABELS.EXPERIMENTAL_DEVELOPMENT, + type: 'bar', + stack: 'total', + emphasis: { focus: 'series' }, + data: data.map((d) => d.experimentalDevelopment), }, ], }; diff --git a/webapp/src/app/modules/person-network-info-card/person-network-info-card.component.html b/webapp/src/app/shared/ui/app-info-card/app-info-card.component.html similarity index 78% rename from webapp/src/app/modules/person-network-info-card/person-network-info-card.component.html rename to webapp/src/app/shared/ui/app-info-card/app-info-card.component.html index 29c0ea8b..3c3f4220 100644 --- a/webapp/src/app/modules/person-network-info-card/person-network-info-card.component.html +++ b/webapp/src/app/shared/ui/app-info-card/app-info-card.component.html @@ -1,6 +1,8 @@ - {{ icon() }} + @if (icon()) { + {{ icon() }} + }
{{ value() }} {{ description() }} diff --git a/webapp/src/app/modules/person-network-info-card/person-network-info-card.component.scss b/webapp/src/app/shared/ui/app-info-card/app-info-card.component.scss similarity index 100% rename from webapp/src/app/modules/person-network-info-card/person-network-info-card.component.scss rename to webapp/src/app/shared/ui/app-info-card/app-info-card.component.scss diff --git a/webapp/src/app/modules/person-network-info-card/person-network-info-card.component.ts b/webapp/src/app/shared/ui/app-info-card/app-info-card.component.ts similarity index 61% rename from webapp/src/app/modules/person-network-info-card/person-network-info-card.component.ts rename to webapp/src/app/shared/ui/app-info-card/app-info-card.component.ts index fe5c3913..3e4114bc 100644 --- a/webapp/src/app/modules/person-network-info-card/person-network-info-card.component.ts +++ b/webapp/src/app/shared/ui/app-info-card/app-info-card.component.ts @@ -3,12 +3,12 @@ import { MatCardModule } from '@angular/material/card'; import { MatIconModule } from '@angular/material/icon'; @Component({ - selector: 'app-person-network-info-card', + selector: 'app-info-card', imports: [MatIconModule, MatCardModule], - templateUrl: './person-network-info-card.component.html', - styleUrl: './person-network-info-card.component.scss', + templateUrl: './app-info-card.component.html', + styleUrl: './app-info-card.component.scss', }) -export class PersonNetworkInfoCardComponent { +export class AppInfoCardComponent { readonly icon = input(); readonly value = input(); readonly description = input();