diff --git a/.run/OkrApplication-local-prod-debug.run.xml b/.run/OkrApplication-local-prod-debug.run.xml new file mode 100755 index 0000000000..15ae63f4ef --- /dev/null +++ b/.run/OkrApplication-local-prod-debug.run.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/backend/pom.xml b/backend/pom.xml index bff729e9d2..a71e3b5c54 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -83,6 +83,15 @@ 3.26.3 test + + org.springframework.boot + spring-boot-devtools + + + org.springframework + springloaded + 1.2.8.RELEASE + diff --git a/frontend/package.json b/frontend/package.json index 504cbc63af..7fcf6cc0a0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,7 +3,7 @@ "version": "2.0.0", "scripts": { "ng": "ng", - "start": "ng serve ", + "start": "ng serve", "build": "ng build", "build:staging": "ng build --configuration staging", "watch": "ng build --watch --configuration development", diff --git a/frontend/src/app/components/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/components/check-in-history-dialog/check-in-history-dialog.component.ts index 4241ad6426..7b8a93d8fe 100644 --- a/frontend/src/app/components/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/components/check-in-history-dialog/check-in-history-dialog.component.ts @@ -48,6 +48,7 @@ export class CheckInHistoryDialogComponent implements OnInit { }); dialogRef.afterClosed().subscribe(() => { this.loadCheckInHistory(); + this.refreshDataService.reloadKeyResultSubject.next(); this.refreshDataService.markDataRefresh(); }); } diff --git a/frontend/src/app/components/keyresult-detail/keyresult-detail.component.spec.ts b/frontend/src/app/components/keyresult-detail/keyresult-detail.component.spec.ts index c0e0055357..ebaec251bc 100644 --- a/frontend/src/app/components/keyresult-detail/keyresult-detail.component.spec.ts +++ b/frontend/src/app/components/keyresult-detail/keyresult-detail.component.spec.ts @@ -12,6 +12,7 @@ import { MatIconModule } from '@angular/material/icon'; import { ActivatedRoute } from '@angular/router'; import { ScoringComponent } from '../../shared/custom/scoring/scoring.component'; import { ConfidenceComponent } from '../confidence/confidence.component'; +import { RefreshDataService } from '../../services/refresh-data.service'; const keyResultServiceMock = { getFullKeyResult: jest.fn(), @@ -87,4 +88,21 @@ describe('KeyresultDetailComponent', () => { const button = fixture.debugElement.query(By.css('[data-testId="add-check-in"]')); expect(button).toBeFalsy(); }); + + it('should trigger observable when subject gets next value', () => { + const spy = jest.spyOn(component, 'loadKeyResult'); + const refreshDataService = TestBed.inject(RefreshDataService); + refreshDataService.reloadKeyResultSubject.next(); + expect(spy).toHaveBeenCalled(); + }); + + it('should close subscription on destroy', () => { + const spyNext = jest.spyOn(component.ngDestroy$, 'next'); + const spyComplete = jest.spyOn(component.ngDestroy$, 'complete'); + + component.ngOnDestroy(); + + expect(spyNext).toHaveBeenCalled(); + expect(spyComplete).toHaveBeenCalled(); + }); }); diff --git a/frontend/src/app/components/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/components/keyresult-detail/keyresult-detail.component.ts index d31fae0dfb..62e728dcf2 100644 --- a/frontend/src/app/components/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/components/keyresult-detail/keyresult-detail.component.ts @@ -1,11 +1,11 @@ -import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit } from '@angular/core'; import { KeyResult } from '../../shared/types/model/KeyResult'; import { KeyresultService } from '../../services/keyresult.service'; import { KeyResultMetric } from '../../shared/types/model/KeyResultMetric'; import { KeyResultOrdinal } from '../../shared/types/model/KeyResultOrdinal'; import { CheckInHistoryDialogComponent } from '../check-in-history-dialog/check-in-history-dialog.component'; import { MatDialog } from '@angular/material/dialog'; -import { BehaviorSubject, catchError, EMPTY } from 'rxjs'; +import { BehaviorSubject, catchError, EMPTY, Subject, takeUntil } from 'rxjs'; import { ActivatedRoute, Router } from '@angular/router'; import { RefreshDataService } from '../../services/refresh-data.service'; import { CloseState } from '../../shared/types/enums/CloseState'; @@ -22,10 +22,11 @@ import { ConfirmDialogComponent } from '../../shared/dialog/confirm-dialog/confi styleUrls: ['./keyresult-detail.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class KeyresultDetailComponent implements OnInit { +export class KeyresultDetailComponent implements OnInit, OnDestroy { @Input() keyResultId!: number; keyResult$: BehaviorSubject = new BehaviorSubject({} as KeyResult); + ngDestroy$: Subject = new Subject(); isComplete: boolean = false; protected readonly DATE_FORMAT = DATE_FORMAT; protected readonly isLastCheckInNegative = isLastCheckInNegative; @@ -41,6 +42,14 @@ export class KeyresultDetailComponent implements OnInit { ngOnInit(): void { this.keyResultId = this.getIdFromParams(); this.loadKeyResult(this.keyResultId); + this.refreshDataService.reloadKeyResultSubject.pipe(takeUntil(this.ngDestroy$)).subscribe(() => { + this.loadKeyResult(this.keyResultId); + }); + } + + ngOnDestroy() { + this.ngDestroy$.next(); + this.ngDestroy$.complete(); } private getIdFromParams(): number { @@ -181,7 +190,7 @@ export class KeyresultDetailComponent implements OnInit { }, }); dialogRef.afterClosed().subscribe(() => { - this.loadKeyResult(this.keyResult$.getValue().id); + this.refreshDataService.reloadKeyResultSubject.next(); this.refreshDataService.markDataRefresh(); }); } diff --git a/frontend/src/app/services/refresh-data.service.ts b/frontend/src/app/services/refresh-data.service.ts index fe5a7f5f7a..3c1a1fb321 100644 --- a/frontend/src/app/services/refresh-data.service.ts +++ b/frontend/src/app/services/refresh-data.service.ts @@ -7,6 +7,7 @@ import { DEFAULT_HEADER_HEIGHT_PX } from '../shared/constantLibary'; }) export class RefreshDataService { public reloadOverviewSubject: Subject = new Subject(); + public reloadKeyResultSubject: Subject = new Subject(); public quarterFilterReady: Subject = new Subject(); public teamFilterReady: Subject = new Subject();