From 9a3b5a9f94bf0cc89f29a5a4cf69d7f0470c02ae Mon Sep 17 00:00:00 2001 From: George Nash Date: Thu, 7 Mar 2024 19:44:33 +0000 Subject: [PATCH 1/2] affiliation detail component --- .../affiliation-detail.component.html | 116 ++++++++++++++++++ .../affiliation-detail.component.scss | 0 .../affiliation-detail.component.spec.ts | 31 +++++ .../affiliation-detail.component.ts | 41 +++++++ ui/src/app/affiliation/affiliation.module.ts | 5 +- ui/src/app/affiliation/affiliation.route.ts | 25 +++- .../affiliation/affiliations.component.html | 2 +- 7 files changed, 212 insertions(+), 8 deletions(-) create mode 100644 ui/src/app/affiliation/affiliation-detail.component.html create mode 100644 ui/src/app/affiliation/affiliation-detail.component.scss create mode 100644 ui/src/app/affiliation/affiliation-detail.component.spec.ts create mode 100644 ui/src/app/affiliation/affiliation-detail.component.ts diff --git a/ui/src/app/affiliation/affiliation-detail.component.html b/ui/src/app/affiliation/affiliation-detail.component.html new file mode 100644 index 000000000..db6bf7c71 --- /dev/null +++ b/ui/src/app/affiliation/affiliation-detail.component.html @@ -0,0 +1,116 @@ +
+
+
+

Affiliation details

+
+ +
+
+
ID
+
+ {{affiliation.id}} +
+
Email
+
+ {{affiliation.email}} +
+
Status
+
+ {{affiliation.prettyStatus}} +
+
Permission link
+
+ +
+
ORCID iD
+
+ {{orcidBaseUrl}}/{{affiliation.orcidId}} +
+
Affiliation Section
+
+ {{affiliation.affiliationSection}} +
+
Organization
+
+ {{affiliation.orgName}}: {{affiliation.orgCity}}, {{affiliation.orgRegion}}, {{affiliation.orgCountry}}
+ {{affiliation.disambiguationSource}} {{affiliation.disambiguatedOrgId}} +
+
Department Name
+
+ {{affiliation.departmentName}} +
+
Role Title
+
+ {{affiliation.roleTitle}} +
+
Url
+
+ {{affiliation.url}} +
+
Start Date
+
+ {{affiliation.startYear!}}-{{affiliation.startMonth}}-{{affiliation.startDay!}} +
+
End Date
+
+ {{affiliation.endYear!}}-{{affiliation.endMonth}}-{{affiliation.endDay!}} +
+
External Id
+
+ {{affiliation.externalIdType!}} {{affiliation.externalId}} {{affiliation.externalId}} +
+
Created
+
+ {{affiliation.created!.toString() | date:'medium'}} +
+
Added To ORCID
+
+ {{affiliation.addedToORCID!.toString() | date:'medium'}} +
+
Updated In ORCID
+
+ {{affiliation.updatedInORCID!.toString() | date:'medium'}} +
+
Modified
+
+ {{affiliation.modified!.toString() | date:'medium'}} by {{affiliation.lastModifiedBy}} +
+
Admin Id
+
+ {{ownerId}} +
+
Notification First Sent
+
+ {{affiliation.notificationSent.toString() | date:'medium'}} +
+
Notification First Sent
+
+ {{affiliation.invitationSent.toString() | date:'medium'}} +
+
Notification Last Sent
+
+ {{affiliation.notificationLastSent.toString() | date:'medium'}} +
+
Notification Last Sent
+
+ {{affiliation.invitationLastSent.toString() | date:'medium'}} +
+
+
+
+
+ + + +
+
+
+
diff --git a/ui/src/app/affiliation/affiliation-detail.component.scss b/ui/src/app/affiliation/affiliation-detail.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ui/src/app/affiliation/affiliation-detail.component.spec.ts b/ui/src/app/affiliation/affiliation-detail.component.spec.ts new file mode 100644 index 000000000..823b9fea0 --- /dev/null +++ b/ui/src/app/affiliation/affiliation-detail.component.spec.ts @@ -0,0 +1,31 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing' + +import { AffiliationDetailComponent } from './affiliation-detail.component' +import { UserService } from '../user/service/user.service' +import { RouterTestingModule } from '@angular/router/testing' + +describe('AffiliationDetailComponent', () => { + let component: AffiliationDetailComponent + let fixture: ComponentFixture + let userServiceSpy: jasmine.SpyObj + + beforeEach(() => { + userServiceSpy = jasmine.createSpyObj('UserService', ['find']) + + TestBed.configureTestingModule({ + declarations: [AffiliationDetailComponent], + imports: [RouterTestingModule], + providers: [{ provide: UserService, useValue: userServiceSpy }], + }).compileComponents() + + fixture = TestBed.createComponent(AffiliationDetailComponent) + component = fixture.componentInstance + fixture.detectChanges() + + userServiceSpy = TestBed.inject(UserService) as jasmine.SpyObj + }) + + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/ui/src/app/affiliation/affiliation-detail.component.ts b/ui/src/app/affiliation/affiliation-detail.component.ts new file mode 100644 index 000000000..45f380944 --- /dev/null +++ b/ui/src/app/affiliation/affiliation-detail.component.ts @@ -0,0 +1,41 @@ +import { Component, OnInit } from '@angular/core' +import { Affiliation, IAffiliation } from './model/affiliation.model' +import { ORCID_BASE_URL } from '../app.constants' +import { ActivatedRoute } from '@angular/router' +import { UserService } from '../user/service/user.service' +import { faPencilAlt, faArrowLeft } from '@fortawesome/free-solid-svg-icons' + +@Component({ + selector: 'app-affiliation-detail', + templateUrl: './affiliation-detail.component.html', + styleUrls: ['./affiliation-detail.component.scss'], +}) +export class AffiliationDetailComponent implements OnInit { + affiliation: IAffiliation = new Affiliation() + orcidBaseUrl: string = ORCID_BASE_URL + ownerId: string | undefined + faPencilAlt = faPencilAlt + faArrowLeft = faArrowLeft + + constructor( + protected activatedRoute: ActivatedRoute, + protected userService: UserService + ) {} + + ngOnInit() { + this.activatedRoute.data.subscribe(({ affiliation }) => { + this.affiliation = affiliation + this.userService.find(this.affiliation!.ownerId!).subscribe((user) => { + this.ownerId = user.email + }) + }) + } + + previousState() { + window.history.back() + } + + successMessage() { + alert($localize`:@@gatewayApp.assertionServiceAssertion.copySuccess.string:`) + } +} diff --git a/ui/src/app/affiliation/affiliation.module.ts b/ui/src/app/affiliation/affiliation.module.ts index 0e4de35eb..d043c564b 100644 --- a/ui/src/app/affiliation/affiliation.module.ts +++ b/ui/src/app/affiliation/affiliation.module.ts @@ -5,11 +5,12 @@ import { AffiliationsComponent } from './affiliations.component' import { affiliationRoutes } from './affiliation.route' import { SharedModule } from '../shared/shared.module' import { CommonModule } from '@angular/common' -import { FormsModule } from '@angular/forms' +import { FormsModule } from '@angular/forms'; +import { AffiliationDetailComponent } from './affiliation-detail.component' @NgModule({ imports: [CommonModule, FormsModule, SharedModule, RouterModule.forChild(affiliationRoutes), ClipboardModule], - declarations: [AffiliationsComponent], + declarations: [AffiliationsComponent, AffiliationDetailComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], }) export class AffiliationModule {} diff --git a/ui/src/app/affiliation/affiliation.route.ts b/ui/src/app/affiliation/affiliation.route.ts index debd50067..b456ec448 100644 --- a/ui/src/app/affiliation/affiliation.route.ts +++ b/ui/src/app/affiliation/affiliation.route.ts @@ -1,11 +1,11 @@ import { ActivatedRouteSnapshot, ResolveFn, RouterStateSnapshot, Routes } from '@angular/router' import { AuthGuard } from '../account/auth.guard' -import { EMPTY, Observable, filter, of, take } from 'rxjs' -import { Injectable, inject } from '@angular/core' +import { Observable, filter, of, take } from 'rxjs' +import { inject } from '@angular/core' import { AffiliationService } from './service/affiliations.service' import { Affiliation } from './model/affiliation.model' import { AffiliationsComponent } from './affiliations.component' -import { HttpResponse } from '@angular/common/http' +import { AffiliationDetailComponent } from './affiliation-detail.component' export const AffiliationResolver: ResolveFn = ( route: ActivatedRouteSnapshot, @@ -13,7 +13,10 @@ export const AffiliationResolver: ResolveFn = ( affiliationService: AffiliationService = inject(AffiliationService) ): Observable => { if (route.paramMap.get('id')) { - return affiliationService.find(route.paramMap.get('id')!) + return affiliationService.find(route.paramMap.get('id')!).pipe( + filter((affiliation: Affiliation) => !!affiliation), + take(1) + ) } else { return of(null) } @@ -21,7 +24,7 @@ export const AffiliationResolver: ResolveFn = ( export const affiliationRoutes: Routes = [ { - path: '', + path: 'affiliations', component: AffiliationsComponent, data: { authorities: ['ASSERTION_SERVICE_ENABLED'], @@ -30,4 +33,16 @@ export const affiliationRoutes: Routes = [ }, canActivate: [AuthGuard], }, + { + path: 'affiliations/:id/view', + component: AffiliationDetailComponent, + resolve: { + affiliation: AffiliationResolver, + }, + data: { + authorities: ['ASSERTION_SERVICE_ENABLED'], + pageTitle: 'gatewayApp.assertionServiceAssertion.home.title.string', + }, + canActivate: [AuthGuard], + }, ] diff --git a/ui/src/app/affiliation/affiliations.component.html b/ui/src/app/affiliation/affiliations.component.html index dd06940a2..f86027a9b 100644 --- a/ui/src/app/affiliation/affiliations.component.html +++ b/ui/src/app/affiliation/affiliations.component.html @@ -186,7 +186,7 @@

-{{ affiliation.endMonth }}-{{ affiliation.endDay }}
View details From f9f0b592c3a540466866ad4cac44879fc9ba0b64 Mon Sep 17 00:00:00 2001 From: George Nash Date: Thu, 7 Mar 2024 19:46:47 +0000 Subject: [PATCH 2/2] cleanup imports --- ui/src/app/user/user.route.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/app/user/user.route.ts b/ui/src/app/user/user.route.ts index fbbc96b17..ddb774385 100644 --- a/ui/src/app/user/user.route.ts +++ b/ui/src/app/user/user.route.ts @@ -2,10 +2,10 @@ import { ActivatedRouteSnapshot, ResolveFn, RouterStateSnapshot, Routes } from ' import { UsersComponent } from './users.component' import { AuthGuard } from '../account/auth.guard' import { UserDetailComponent } from './user-detail.component' -import { EMPTY, Observable, filter, of, take } from 'rxjs' +import { Observable, filter, of, take } from 'rxjs' import { User } from './model/user.model' import { UserService } from './service/user.service' -import { Injectable, inject } from '@angular/core' +import { inject } from '@angular/core' import { UserUpdateComponent } from './user-update.component' import { UserImportPopupComponent } from './user-import-dialog.component' import { UserDeletePopupComponent } from './user-delete.component'