Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/features/analytics/services/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { AnalyticsService } from './analytics.service';
export { ResourceAnalyticsService } from './resource-analytics.service';
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import { map, Observable } from 'rxjs';
import { inject, Injectable } from '@angular/core';

import { ENVIRONMENT } from '@core/provider/environment.provider';
import { AnalyticsMetricsMapper, RelatedCountsMapper } from '@osf/features/analytics/mappers';
import {
NodeAnalyticsModel,
NodeAnalyticsResponseJsonApi,
RelatedCountsGetResponse,
} from '@osf/features/analytics/models';
import { ResourceType } from '@osf/shared/enums/resource-type.enum';
import { JsonApiService } from '@osf/shared/services/json-api.service';

import { AnalyticsMetricsMapper, RelatedCountsMapper } from '../mappers';
import { NodeAnalyticsModel, NodeAnalyticsResponseJsonApi, RelatedCountsGetResponse } from '../models';

@Injectable({
providedIn: 'root',
})
export class AnalyticsService {
export class ResourceAnalyticsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);

Expand Down
4 changes: 2 additions & 2 deletions src/app/features/analytics/store/analytics.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { inject, Injectable } from '@angular/core';
import { handleSectionError } from '@osf/shared/helpers/state-error.handler';

import { NodeAnalyticsModel, RelatedCountsModel } from '../models';
import { AnalyticsService } from '../services';
import { ResourceAnalyticsService } from '../services';

import { ClearAnalytics, GetMetrics, GetRelatedCounts } from './analytics.actions';
import { ANALYTICS_DEFAULT_STATE, AnalyticsStateModel } from './analytics.model';
Expand All @@ -19,7 +19,7 @@ import { ANALYTICS_DEFAULT_STATE, AnalyticsStateModel } from './analytics.model'
})
@Injectable()
export class AnalyticsState {
private readonly analyticsService = inject(AnalyticsService);
private readonly analyticsService = inject(ResourceAnalyticsService);
private readonly REFRESH_INTERVAL = 5 * 60 * 1000;

@Action(GetMetrics)
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/project/wiki/wiki.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class WikiComponent {
this.actions
.getWikiList(ResourceType.Project, this.projectId())
.pipe(
takeUntilDestroyed(),
takeUntilDestroyed(this.destroyRef),
tap(() => {
if (!this.wikiIdFromQueryParams) {
this.navigateToWiki(this.wikiList()?.[0]?.id || '');
Expand All @@ -124,7 +124,7 @@ export class WikiComponent {

this.route.queryParams
.pipe(
takeUntilDestroyed(),
takeUntilDestroyed(this.destroyRef),
map((params) => params['wiki']),
filter((wikiId) => wikiId),
tap((wikiId) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ChangeDetectionStrategy,
Component,
computed,
DestroyRef,
effect,
inject,
input,
Expand Down Expand Up @@ -82,6 +83,7 @@ export class CustomStepComponent implements OnDestroy {
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);
private readonly fb = inject(FormBuilder);
private readonly destroyRef = inject(DestroyRef);
private toastService = inject(ToastService);

readonly pages = select(RegistriesSelectors.getPagesSchema);
Expand All @@ -105,7 +107,7 @@ export class CustomStepComponent implements OnDestroy {
attachedFiles: Record<string, Partial<FileModel & { file_id: string }>[]> = {};

constructor() {
this.route.params.pipe(takeUntilDestroyed()).subscribe((params) => {
this.route.params.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((params) => {
this.updateStepState();
this.step.set(+params['step']);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ChangeDetectionStrategy,
Component,
computed,
DestroyRef,
effect,
inject,
OnDestroy,
Expand Down Expand Up @@ -43,6 +44,7 @@ export class DraftsComponent implements OnDestroy {
private readonly route = inject(ActivatedRoute);
private readonly loaderService = inject(LoaderService);
private readonly translateService = inject(TranslateService);
private readonly destroyRef = inject(DestroyRef);

readonly pages = select(RegistriesSelectors.getPagesSchema);
readonly draftRegistration = select(RegistriesSelectors.getDraftRegistration);
Expand Down Expand Up @@ -127,7 +129,7 @@ export class DraftsComponent implements OnDestroy {
constructor() {
this.router.events
.pipe(
takeUntilDestroyed(),
takeUntilDestroyed(this.destroyRef),
filter((event): event is NavigationEnd => event instanceof NavigationEnd)
)
.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ChangeDetectionStrategy,
Component,
computed,
DestroyRef,
effect,
inject,
OnDestroy,
Expand Down Expand Up @@ -37,9 +38,11 @@ import { ClearState, FetchSchemaBlocks, FetchSchemaResponse, RegistriesSelectors
export class JustificationComponent implements OnDestroy {
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);
private readonly destroyRef = inject(DestroyRef);

private readonly loaderService = inject(LoaderService);
private readonly translateService = inject(TranslateService);

readonly pages = select(RegistriesSelectors.getPagesSchema);
readonly stepsState = select(RegistriesSelectors.getStepsState);
readonly schemaResponse = select(RegistriesSelectors.getSchemaResponse);
Expand Down Expand Up @@ -109,7 +112,7 @@ export class JustificationComponent implements OnDestroy {
constructor() {
this.router.events
.pipe(
takeUntilDestroyed(),
takeUntilDestroyed(this.destroyRef),
filter((event): event is NavigationEnd => event instanceof NavigationEnd)
)
.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Textarea } from 'primeng/textarea';
import { tap } from 'rxjs';

import { DatePipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { ChangeDetectionStrategy, Component, DestroyRef, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormBuilder, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';

Expand Down Expand Up @@ -46,6 +46,8 @@ import { RegistryOverviewSelectors, SubmitDecision } from '../../store/registry-
})
export class RegistryMakeDecisionComponent {
private readonly fb = inject(FormBuilder);
private readonly destroyRef = inject(DestroyRef);

readonly config = inject(DynamicDialogConfig);
readonly dialogRef = inject(DynamicDialogRef);

Expand Down Expand Up @@ -118,7 +120,7 @@ export class RegistryMakeDecisionComponent {

this.requestForm
.get(ModerationDecisionFormControls.Action)
?.valueChanges.pipe(takeUntilDestroyed())
?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((action) => {
this.updateCommentValidators(action);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class RegistryOverviewComponent {
this.actions.getBookmarksId();
this.route.queryParams
.pipe(
takeUntilDestroyed(),
takeUntilDestroyed(this.destroyRef),
map((params) => ({ revisionId: params['revisionId'], mode: params['mode'] })),
tap(({ revisionId, mode }) => {
this.revisionId = revisionId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class RegistryWikiComponent {
this.actions
.getWikiList(ResourceType.Registration, this.resourceId)
.pipe(
takeUntilDestroyed(),
takeUntilDestroyed(this.destroyRef),
tap(() => {
if (!this.wikiIdFromQueryParams) {
this.navigateToWiki(this.wikiList()?.[0]?.id || '');
Expand All @@ -100,7 +100,7 @@ export class RegistryWikiComponent {

this.route.queryParams
.pipe(
takeUntilDestroyed(),
takeUntilDestroyed(this.destroyRef),
map((params) => params['wiki']),
filter((wikiId) => wikiId),
tap((wikiId) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';

import { timer } from 'rxjs';

import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, DestroyRef, inject, signal } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';

import { Education } from '@osf/shared/models/user/education.model';
Expand All @@ -20,16 +20,18 @@ import { EducationHistoryComponent } from '../education-history/education-histor
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class EducationHistoryDialogComponent {
private readonly config = inject(DynamicDialogConfig);
dialogRef = inject(DynamicDialogRef);
private readonly config = inject(DynamicDialogConfig);
private readonly destroyRef = inject(DestroyRef);

readonly educationHistory = signal<Education[]>([]);
readonly isContentVisible = signal(false);

constructor() {
this.educationHistory.set(this.config.data);

timer(0)
.pipe(takeUntilDestroyed())
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.isContentVisible.set(true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';

import { timer } from 'rxjs';

import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, DestroyRef, inject, signal } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';

import { Employment } from '@osf/shared/models/user/employment.model';
Expand All @@ -20,16 +20,18 @@ import { EmploymentHistoryComponent } from '../employment-history/employment-his
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class EmploymentHistoryDialogComponent {
private readonly config = inject(DynamicDialogConfig);
dialogRef = inject(DynamicDialogRef);
private readonly destroyRef = inject(DestroyRef);
private readonly config = inject(DynamicDialogConfig);

readonly employmentHistory = signal<Employment[]>([]);
readonly isContentVisible = signal(false);

constructor() {
this.employmentHistory.set(this.config.data);

timer(0)
.pipe(takeUntilDestroyed())
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.isContentVisible.set(true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ import { Button } from 'primeng/button';

import { timer } from 'rxjs';

import { AfterViewInit, Component, effect, ElementRef, inject, input, signal, viewChild } from '@angular/core';
import {
AfterViewInit,
Component,
DestroyRef,
effect,
ElementRef,
inject,
input,
signal,
viewChild,
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Router } from '@angular/router';

@Component({
Expand All @@ -24,6 +35,7 @@ export class TruncatedTextComponent implements AfterViewInit {
readonly contentElement = viewChild<ElementRef>('textContent');

private readonly router = inject(Router);
private readonly destroyRef = inject(DestroyRef);

isTextExpanded = signal(false);
hasOverflowingText = signal(false);
Expand All @@ -41,7 +53,9 @@ export class TruncatedTextComponent implements AfterViewInit {
const currentText = this.text();
if (currentText) {
this.isTextExpanded.set(false);
timer(0).subscribe(() => this.checkTextOverflow());
timer(0)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.checkTextOverflow());
}
});
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/shared/directives/scroll-top.directive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filter } from 'rxjs';

import { Directive, ElementRef, inject } from '@angular/core';
import { DestroyRef, Directive, ElementRef, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { NavigationEnd, Router } from '@angular/router';

Expand All @@ -10,12 +10,13 @@ import { NavigationEnd, Router } from '@angular/router';
export class ScrollTopOnRouteChangeDirective {
private el = inject(ElementRef);
private router = inject(Router);
private destroyRef = inject(DestroyRef);

constructor() {
this.router.events
.pipe(
filter((e) => e instanceof NavigationEnd),
takeUntilDestroyed()
takeUntilDestroyed(this.destroyRef)
)
.subscribe(() => {
let route = this.router.routerState.root;
Expand Down