From 011c14ee6a5c92c2ec811cdeecdbff90ce58be2e Mon Sep 17 00:00:00 2001 From: Kazgatari <56477241+Kazgatari@users.noreply.github.com> Date: Thu, 28 May 2026 22:11:06 +0200 Subject: [PATCH 1/2] Experimental Signal based service injection --- service/src/main/inse/logic.py | 3 +- service/src/main/inse/model.py | 6 +- .../person-interesting.component.html | 12 +++ .../person-interesting.component.scss | 38 +++++++++ .../person-interesting.component.spec.ts | 23 +++++ .../person-interesting.component.ts | 46 ++++++++++ .../app/modules/person/person.component.html | 57 ++++++++----- .../app/modules/person/person.component.scss | 29 ------- .../app/modules/person/person.component.ts | 84 ++++++++++++++++++- .../shared/services/person-store.service.ts | 38 +++++++++ 10 files changed, 280 insertions(+), 56 deletions(-) create mode 100644 webapp/src/app/modules/person-interesting/person-interesting.component.html create mode 100644 webapp/src/app/modules/person-interesting/person-interesting.component.scss create mode 100644 webapp/src/app/modules/person-interesting/person-interesting.component.spec.ts create mode 100644 webapp/src/app/modules/person-interesting/person-interesting.component.ts create mode 100644 webapp/src/app/shared/services/person-store.service.ts diff --git a/service/src/main/inse/logic.py b/service/src/main/inse/logic.py index 03706004..d98c878f 100644 --- a/service/src/main/inse/logic.py +++ b/service/src/main/inse/logic.py @@ -152,7 +152,8 @@ def get_topics_from_cache(topic_names: List[str]) -> List[model.Topic]: continue topics.append(model.Topic( id=data.get("topic_id", ""), - name=name, + display_name=name, + count=data.get("count", 1), subfield=data.get("subfield", ""), field=data.get("field", ""), domain=data.get("domain", "") diff --git a/service/src/main/inse/model.py b/service/src/main/inse/model.py index b9ddf38b..6c798a1c 100644 --- a/service/src/main/inse/model.py +++ b/service/src/main/inse/model.py @@ -38,11 +38,15 @@ class ItemPage(Page[Item]): class Topic(BaseModel): id: str = Field(description="The openalex topic id.") - name: str = Field(description="The topic name.") + display_name: str = Field(description="The topic name.") + count: int = Field(description="The number of works associated with the topic.") subfield: str = Field(description="The subfield of the topic.") field: str = Field(description="The field of the topic.") domain: str = Field(description="The domain of the topic.") +class TopicShare(Topic): + count: float = Field(description="Share value (0..1) for this topic.") + class PersonBio(BaseModel): bio: str = Field(description="The generated biography.") diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.html b/webapp/src/app/modules/person-interesting/person-interesting.component.html new file mode 100644 index 00000000..509d3ebb --- /dev/null +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.html @@ -0,0 +1,12 @@ + diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.scss b/webapp/src/app/modules/person-interesting/person-interesting.component.scss new file mode 100644 index 00000000..314e13de --- /dev/null +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.scss @@ -0,0 +1,38 @@ +:host { + display: block; +} + +.interest-card { + align-self: center; + padding: 24px 28px; + border-radius: var(--sg-radius-sm); + background: var(--sg-surface-muted); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8); +} + +.interest-card h3 { + margin: 0 0 18px; + font-size: 14px; + font-weight: 700; +} + +.interest-tags { + display: flex; + flex-wrap: wrap; + gap: 12px; +} + +.interest-tags span { + padding: 9px 16px; + border: 1px solid #a8c0ff; + border-radius: 7px; + background: #ffffff; + color: var(--sg-primary); + font-size: 13px; + font-weight: 600; +} + +.interest-tags .interest-empty { + border-style: dashed; + color: var(--sg-text-muted); +} diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.spec.ts b/webapp/src/app/modules/person-interesting/person-interesting.component.spec.ts new file mode 100644 index 00000000..bb382718 --- /dev/null +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PersonInterestingComponent } from './person-interesting.component'; + +describe('PersonInterestingComponent', () => { + let component: PersonInterestingComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [PersonInterestingComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(PersonInterestingComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.ts b/webapp/src/app/modules/person-interesting/person-interesting.component.ts new file mode 100644 index 00000000..9a20f6ab --- /dev/null +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.ts @@ -0,0 +1,46 @@ +import { Component, Input } from '@angular/core'; + +import { Topic } from '../../api'; + +interface InterestTag { + label: string; + score: number; +} + +@Component({ + selector: 'app-person-interesting', + imports: [], + templateUrl: './person-interesting.component.html', + styleUrl: './person-interesting.component.scss', +}) +export class PersonInterestingComponent { + private _topics: Topic[] = []; + tags: InterestTag[] = []; + + @Input() + set topics(value: Topic[] | null) { + this._topics = value ?? []; + this.tags = this.buildTags(this._topics); + } + + get topics(): Topic[] { + return this._topics; + } + + private buildTags(topics: Topic[]): InterestTag[] { + const grouped = new Map(); + + for (const topic of topics) { + const label = (topic.subfield?.display_name ?? '').trim(); + if (!label) continue; + + const score = typeof topic.score === 'number' ? topic.score : 0; + grouped.set(label, (grouped.get(label) ?? 0) + score); + } + + return Array.from(grouped.entries()) + .map(([label, score]) => ({ label, score })) + .sort((a, b) => b.score - a.score) + .slice(0, 8); + } +} diff --git a/webapp/src/app/modules/person/person.component.html b/webapp/src/app/modules/person/person.component.html index a937e2a5..0378513a 100644 --- a/webapp/src/app/modules/person/person.component.html +++ b/webapp/src/app/modules/person/person.component.html @@ -1,41 +1,56 @@
-
AB
+
{{ initials() }}
- Prof. Dr. -

Anna Becker

+ Person +

{{ displayName() }}

-

Universität Duisburg-Essen

- Fakultät für Ingenieurwissenschaften - Lehrstuhl für Datenanalyse +

{{ institution() }}

+ @if (countryCode()) { + {{ countryCode() }} + } + @if (worksCount() !== null || citedByCount() !== null) { + + @if (worksCount() !== null) { + {{ worksCount() }} Publikationen + } + @if (worksCount() !== null && citedByCount() !== null) { + · + } + @if (citedByCount() !== null) { + {{ citedByCount() }} Zitationen + } + + }
mail anna.becker@uni-due.de
-
- verified - 0000-0002-1234-5678 -
+ @if (openAlexId()) { +
+ person + {{ openAlexId() }} +
+ } + @if (orcid()) { +
+ verified + {{ orcid() }} +
+ }
- +