From 59b31ec40e7ba71c556616ad6b1012ff82fa321d Mon Sep 17 00:00:00 2001 From: Nazar Semets Date: Mon, 26 May 2025 15:01:47 +0300 Subject: [PATCH] feat(176): updated environment file --- src/app/core/services/user.service.ts | 9 +++++---- .../institutions/services/institutions.service.ts | 5 ++--- src/app/features/meetings/models/meetings.models.ts | 2 +- src/app/features/meetings/pages/index.ts | 4 ++-- .../pages/meeting-details/meeting-details.component.html | 2 +- .../pages/meeting-details/meeting-details.component.ts | 2 +- .../meetings-landing/meetings-landing.component.html | 2 +- .../pages/meetings-landing/meetings-landing.component.ts | 2 +- src/app/features/meetings/services/meetings.service.ts | 9 ++++++--- .../project/analytics/services/analytics.service.ts | 6 +++--- .../developer-apps/services/developer-apps.service.ts | 4 +++- .../services/notification-subscription.service.ts | 4 +++- .../services/profile-settings.api.service.ts | 5 +++-- src/app/shared/utils/index.ts | 1 + .../search-pref-to-json-api-query-params.helper.ts | 0 src/environments/environment.development.ts | 1 + src/environments/environment.ts | 1 + 17 files changed, 35 insertions(+), 24 deletions(-) rename src/app/shared/{helpers => utils}/search-pref-to-json-api-query-params.helper.ts (100%) diff --git a/src/app/core/services/user.service.ts b/src/app/core/services/user.service.ts index eab2f0e25..4daf67cf8 100644 --- a/src/app/core/services/user.service.ts +++ b/src/app/core/services/user.service.ts @@ -6,22 +6,23 @@ import { JsonApiResponse, User, UserGetResponse, UserMapper, UserSettings, UserS import { JsonApiService } from './json-api.service'; +import { environment } from 'src/environments/environment'; + @Injectable({ providedIn: 'root', }) export class UserService { - baseUrl = 'https://api.staging4.osf.io/v2/'; jsonApiService = inject(JsonApiService); getCurrentUser(): Observable { return this.jsonApiService - .get>(this.baseUrl + 'users/me/') + .get>(`${environment.apiUrl}/users/me/`) .pipe(map((user) => UserMapper.fromUserGetResponse(user.data))); } getCurrentUserSettings(): Observable { return this.jsonApiService - .get>(this.baseUrl + 'users/me/settings/') + .get>(`${environment.apiUrl}/users/me/settings/`) .pipe(map((response) => UserMapper.fromUserSettingsGetResponse(response.data))); } @@ -29,7 +30,7 @@ export class UserService { const request = UserMapper.toUpdateUserSettingsRequest(userId, userSettings); return this.jsonApiService - .patch(this.baseUrl + `users/${userId}/settings/`, request) + .patch(`${environment.apiUrl}/users/${userId}/settings/`, request) .pipe(map((response) => UserMapper.fromUserSettingsGetResponse(response))); } } diff --git a/src/app/features/institutions/services/institutions.service.ts b/src/app/features/institutions/services/institutions.service.ts index d9387deac..ad09830e8 100644 --- a/src/app/features/institutions/services/institutions.service.ts +++ b/src/app/features/institutions/services/institutions.service.ts @@ -15,12 +15,11 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class InstitutionsService { - #baseUrl = 'https://api.staging4.osf.io/v2/'; #jsonApiService = inject(JsonApiService); getUserInstitutions(): Observable { - const url = this.#baseUrl + 'users/me/institutions/'; - // const url = this.#baseUrl + 'users/26c59/institutions/'; + const url = `${environment.apiUrl}/users/me/institutions/`; + return this.#jsonApiService .get>(url) .pipe(map((response) => response.data.map((item) => InstitutionsMapper.fromResponse(item)))); diff --git a/src/app/features/meetings/models/meetings.models.ts b/src/app/features/meetings/models/meetings.models.ts index 585d824f2..dd405cb6e 100644 --- a/src/app/features/meetings/models/meetings.models.ts +++ b/src/app/features/meetings/models/meetings.models.ts @@ -1,5 +1,5 @@ // domain models -import { NumberOrNull, StringOrNull } from '@core/helpers/types.helper'; +import { NumberOrNull, StringOrNull } from '@core/helpers'; export interface Meeting { id: string; diff --git a/src/app/features/meetings/pages/index.ts b/src/app/features/meetings/pages/index.ts index 2af54e93d..35184f64e 100644 --- a/src/app/features/meetings/pages/index.ts +++ b/src/app/features/meetings/pages/index.ts @@ -1,2 +1,2 @@ -export * from './meetings-details'; -export * from './meetings-landing'; +export { MeetingDetailsComponent } from './meeting-details/meeting-details.component'; +export { MeetingsLandingComponent } from './meetings-landing/meetings-landing.component'; diff --git a/src/app/features/meetings/pages/meeting-details/meeting-details.component.html b/src/app/features/meetings/pages/meeting-details/meeting-details.component.html index bc312479d..8a835db11 100644 --- a/src/app/features/meetings/pages/meeting-details/meeting-details.component.html +++ b/src/app/features/meetings/pages/meeting-details/meeting-details.component.html @@ -57,7 +57,7 @@ - @if (item !== 1) { + @if (item?.id) { {{ item.title }} {{ item.authorName }} diff --git a/src/app/features/meetings/pages/meeting-details/meeting-details.component.ts b/src/app/features/meetings/pages/meeting-details/meeting-details.component.ts index 1e80cbc45..1f712473f 100644 --- a/src/app/features/meetings/pages/meeting-details/meeting-details.component.ts +++ b/src/app/features/meetings/pages/meeting-details/meeting-details.component.ts @@ -96,7 +96,7 @@ export class MeetingDetailsComponent { meetingSubmissions = select(MeetingsSelectors.getAllMeetingSubmissions); totalMeetingSubmissionsCount = select(MeetingsSelectors.getMeetingSubmissionsTotalCount); isMeetingSubmissionsLoading = select(MeetingsSelectors.isMeetingSubmissionsLoading); - skeletonData: number[] = Array.from({ length: 10 }, () => 1); + skeletonData: MeetingSubmission[] = Array.from({ length: 10 }, () => ({}) as MeetingSubmission); pageDescription = computed(() => { const meeting = this.meeting(); diff --git a/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.html b/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.html index 96091c20c..f9de138dd 100644 --- a/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.html +++ b/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.html @@ -58,7 +58,7 @@ - @if (item !== 1) { + @if (item?.id) { {{ item.name }} {{ item.submissionsCount }} diff --git a/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.ts b/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.ts index 0034d9c21..d8c3468bb 100644 --- a/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.ts +++ b/src/app/features/meetings/pages/meetings-landing/meetings-landing.component.ts @@ -64,7 +64,7 @@ export class MeetingsLandingComponent { meetings = select(MeetingsSelectors.getAllMeetings); totalMeetingsCount = select(MeetingsSelectors.getMeetingsTotalCount); isMeetingsLoading = select(MeetingsSelectors.isMeetingsLoading); - skeletonData: number[] = Array.from({ length: 10 }, () => 1); + skeletonData: Meeting[] = Array.from({ length: 10 }, () => ({}) as Meeting); constructor() { this.setupTotalRecordsEffect(); diff --git a/src/app/features/meetings/services/meetings.service.ts b/src/app/features/meetings/services/meetings.service.ts index 0a1c33873..5b1068f0f 100644 --- a/src/app/features/meetings/services/meetings.service.ts +++ b/src/app/features/meetings/services/meetings.service.ts @@ -11,15 +11,18 @@ import { MeetingSubmissionsWithPaging, MeetingsWithPaging, } from '@osf/features/meetings/models'; -import { searchPreferencesToJsonApiQueryParams } from '@shared/helpers/search-pref-to-json-api-query-params.helper'; -import { SearchFilters } from '@shared/models/filters/search-filters.model'; +import { searchPreferencesToJsonApiQueryParams } from '@osf/shared/utils'; +import { SearchFilters } from '@shared/models/filters'; + +import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root', }) export class MeetingsService { jsonApiService = inject(JsonApiService); - baseUrl = 'https://api.staging4.osf.io/_/meetings/'; + baseUrl = `${environment.apiDomainUrl}/_/meetings/`; + #meetingSubmissionSortFieldMap: Record = { title: 'title', authorName: 'author_name', diff --git a/src/app/features/project/analytics/services/analytics.service.ts b/src/app/features/project/analytics/services/analytics.service.ts index 2e1b4aa90..ed9bcd76e 100644 --- a/src/app/features/project/analytics/services/analytics.service.ts +++ b/src/app/features/project/analytics/services/analytics.service.ts @@ -14,13 +14,13 @@ import { environment } from 'src/environments/environment'; providedIn: 'root', }) export class AnalyticsService { - #baseUrl = 'https://api.staging4.osf.io/_/metrics/query/node_analytics'; - #jsonApiService = inject(JsonApiService); getMetrics(projectId: string, dateRange: string): Observable { + const baseUrl = `${environment.apiDomainUrl}/_/metrics/query/node_analytics`; + return this.#jsonApiService - .get>(`${this.#baseUrl}/${projectId}/${dateRange}`) + .get>(`${baseUrl}/${projectId}/${dateRange}`) .pipe(map((response) => AnalyticsMetricsMapper.fromResponse(response.data))); } diff --git a/src/app/features/settings/developer-apps/services/developer-apps.service.ts b/src/app/features/settings/developer-apps/services/developer-apps.service.ts index 7e3bd3441..dad6a5f13 100644 --- a/src/app/features/settings/developer-apps/services/developer-apps.service.ts +++ b/src/app/features/settings/developer-apps/services/developer-apps.service.ts @@ -8,12 +8,14 @@ import { JsonApiService } from '@osf/core/services'; import { DeveloperAppMapper } from '../mappers'; import { DeveloperApp, DeveloperAppCreateUpdate, DeveloperAppGetResponse } from '../models'; +import { environment } from 'src/environments/environment'; + @Injectable({ providedIn: 'root', }) export class DeveloperApplicationsService { jsonApiService = inject(JsonApiService); - baseUrl = 'https://api.staging4.osf.io/v2/applications/'; + baseUrl = `${environment.apiUrl}/applications/`; getApplications(): Observable { return this.jsonApiService.get>(this.baseUrl).pipe( diff --git a/src/app/features/settings/notifications/services/notification-subscription.service.ts b/src/app/features/settings/notifications/services/notification-subscription.service.ts index f41f61b18..d68699cf1 100644 --- a/src/app/features/settings/notifications/services/notification-subscription.service.ts +++ b/src/app/features/settings/notifications/services/notification-subscription.service.ts @@ -9,12 +9,14 @@ import { SubscriptionFrequency } from '../enums'; import { NotificationSubscriptionMapper } from '../mappers'; import { NotificationSubscription, NotificationSubscriptionGetResponse } from '../models'; +import { environment } from 'src/environments/environment'; + @Injectable({ providedIn: 'root', }) export class NotificationSubscriptionService { jsonApiService = inject(JsonApiService); - baseUrl = 'https://api.staging4.osf.io/v2/subscriptions/'; + baseUrl = `${environment.apiUrl}/subscriptions/`; getAllGlobalNotificationSubscriptions(): Observable { const params: Record = { diff --git a/src/app/features/settings/profile-settings/services/profile-settings.api.service.ts b/src/app/features/settings/profile-settings/services/profile-settings.api.service.ts index dc4114b04..4838927cf 100644 --- a/src/app/features/settings/profile-settings/services/profile-settings.api.service.ts +++ b/src/app/features/settings/profile-settings/services/profile-settings.api.service.ts @@ -5,16 +5,17 @@ import { JsonApiService } from '@osf/core/services'; import { ProfileSettingsStateModel, ProfileSettingsUpdate } from '../store'; +import { environment } from 'src/environments/environment'; + @Injectable({ providedIn: 'root', }) export class ProfileSettingsApiService { - readonly #baseUrl = 'https://api.staging4.osf.io/v2/'; readonly #jsonApiService = inject(JsonApiService); patchUserSettings(userId: string, key: keyof ProfileSettingsStateModel, data: ProfileSettingsUpdate) { const patchedData = { [key]: data }; - return this.#jsonApiService.patch>(`${this.#baseUrl}users/${userId}/`, { + return this.#jsonApiService.patch>(`${environment.apiUrl}users/${userId}/`, { data: { type: 'users', id: userId, attributes: patchedData }, }); } diff --git a/src/app/shared/utils/index.ts b/src/app/shared/utils/index.ts index 8e1319c43..60b69869d 100644 --- a/src/app/shared/utils/index.ts +++ b/src/app/shared/utils/index.ts @@ -2,3 +2,4 @@ export * from './add-filters-params.helper'; export * from './breakpoints.tokens'; export * from './custom-form-validators.helper'; export * from './get-resource-types.helper'; +export * from './search-pref-to-json-api-query-params.helper'; diff --git a/src/app/shared/helpers/search-pref-to-json-api-query-params.helper.ts b/src/app/shared/utils/search-pref-to-json-api-query-params.helper.ts similarity index 100% rename from src/app/shared/helpers/search-pref-to-json-api-query-params.helper.ts rename to src/app/shared/utils/search-pref-to-json-api-query-params.helper.ts diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts index e3b3e9699..861bd440f 100644 --- a/src/environments/environment.development.ts +++ b/src/environments/environment.development.ts @@ -1,6 +1,7 @@ export const environment = { production: false, apiUrl: 'https://api.staging4.osf.io/v2', + apiDomainUrl: 'https://api.staging4.osf.io', shareDomainUrl: 'https://staging-share.osf.io/trove', addonsApiUrl: 'https://addons.staging4.osf.io/v1', }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index e3b3e9699..861bd440f 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,6 +1,7 @@ export const environment = { production: false, apiUrl: 'https://api.staging4.osf.io/v2', + apiDomainUrl: 'https://api.staging4.osf.io', shareDomainUrl: 'https://staging-share.osf.io/trove', addonsApiUrl: 'https://addons.staging4.osf.io/v1', };