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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export class MaintenanceService {
/** Injected Angular `HttpClient` for making API requests. */
private readonly http = inject(HttpClient);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

/**
* Fetches the maintenance status from the API and transforms the response.
Expand Down
15 changes: 12 additions & 3 deletions src/app/core/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@ export class AuthService {
private readonly cookieService = inject(CookieService);
private readonly loaderService = inject(LoaderService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2/users/`;
private readonly webUrl = this.environment.webUrl;
private readonly casUrl = this.environment.casUrl;
private readonly actions = createDispatchMap({ clearCurrentUser: ClearCurrentUser });

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2/users/`;
}

get webUrl() {
return this.environment.webUrl;
}

get casUrl() {
return this.environment.casUrl;
}

navigateToSignIn(): void {
this.loaderService.show();
const loginUrl = `${this.casUrl}/login?${urlParam({ service: `${this.webUrl}/login` })}`;
Expand Down
5 changes: 4 additions & 1 deletion src/app/core/services/request-access.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { JsonApiService } from '@osf/shared/services';
export class RequestAccessService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

requestAccessToProject(projectId: string, comment = ''): Observable<void> {
const payload = {
Expand Down
17 changes: 10 additions & 7 deletions src/app/core/services/user-emails.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { JsonApiService } from '@osf/shared/services';
export class UserEmailsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly baseUrl = `${this.environment.apiDomainUrl}/v2/users`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2/users`;
}

getEmails(): Observable<AccountEmailModel[]> {
const params: Record<string, string> = {
Expand All @@ -22,7 +25,7 @@ export class UserEmailsService {
};

return this.jsonApiService
.get<EmailsResponseJsonApi>(`${this.baseUrl}/me/settings/emails/`, params)
.get<EmailsResponseJsonApi>(`${this.apiUrl}/me/settings/emails/`, params)
.pipe(map((response) => MapEmails(response.data)));
}

Expand All @@ -32,7 +35,7 @@ export class UserEmailsService {
};

return this.jsonApiService
.get<EmailResponseJsonApi>(`${this.baseUrl}/me/settings/emails/${emailId}/`, params)
.get<EmailResponseJsonApi>(`${this.apiUrl}/me/settings/emails/${emailId}/`, params)
.pipe(map((response) => MapEmail(response.data)));
}

Expand All @@ -55,7 +58,7 @@ export class UserEmailsService {
};

return this.jsonApiService
.post<EmailResponseJsonApi>(`${this.baseUrl}/${userId}/settings/emails/`, body)
.post<EmailResponseJsonApi>(`${this.apiUrl}/${userId}/settings/emails/`, body)
.pipe(map((response) => MapEmail(response.data)));
}

Expand All @@ -71,7 +74,7 @@ export class UserEmailsService {
};

return this.jsonApiService
.patch<EmailsDataJsonApi>(`${this.baseUrl}/me/settings/emails/${emailId}/`, body)
.patch<EmailsDataJsonApi>(`${this.apiUrl}/me/settings/emails/${emailId}/`, body)
.pipe(map((response) => MapEmail(response)));
}

Expand All @@ -87,11 +90,11 @@ export class UserEmailsService {
};

return this.jsonApiService
.patch<EmailsDataJsonApi>(`${this.baseUrl}/me/settings/emails/${emailId}/`, body)
.patch<EmailsDataJsonApi>(`${this.apiUrl}/me/settings/emails/${emailId}/`, body)
.pipe(map((response) => MapEmail(response)));
}

deleteEmail(emailId: string): Observable<void> {
return this.jsonApiService.delete(`${this.baseUrl}/me/settings/emails/${emailId}/`);
return this.jsonApiService.delete(`${this.apiUrl}/me/settings/emails/${emailId}/`);
}
}
5 changes: 4 additions & 1 deletion src/app/core/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import { JsonApiService } from '@shared/services';
export class UserService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

getUserById(userId: string): Observable<User> {
return this.jsonApiService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ import {
export class InstitutionsAdminService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;
private readonly shareTroveUrl = this.environment.shareTroveUrl;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

get shareTroveUrl() {
return this.environment.shareTroveUrl;
}

fetchDepartments(institutionId: string): Observable<InstitutionDepartment[]> {
return this.jsonApiService
Expand Down
5 changes: 4 additions & 1 deletion src/app/features/analytics/services/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { AnalyticsMetricsGetResponse, AnalyticsMetricsModel, RelatedCountsGetRes
export class AnalyticsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiDomainUrl = this.environment.apiDomainUrl;

get apiDomainUrl() {
return this.environment.apiDomainUrl;
}

private readonly urlMap = new Map<ResourceType, string>([
[ResourceType.Project, 'nodes'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { JsonApiService } from '@shared/services';
export class AddToCollectionService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

fetchCollectionLicenses(providerId: string): Observable<LicenseModel[]> {
return this.jsonApiService
Expand Down
11 changes: 7 additions & 4 deletions src/app/features/meetings/services/meetings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import {
export class MeetingsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly baseUrl = `${this.environment.apiDomainUrl}/_/meetings/`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/_/meetings/`;
}

getAllMeetings(pageNumber: number, pageSize: number, filters: SearchFilters): Observable<MeetingsWithPaging> {
const params: Record<string, unknown> = searchPreferencesToJsonApiQueryParams(
Expand All @@ -34,7 +37,7 @@ export class MeetingsService {
);

return this.jsonApiService
.get<ResponseJsonApi<MeetingGetResponseJsonApi[]>>(this.baseUrl, params)
.get<ResponseJsonApi<MeetingGetResponseJsonApi[]>>(this.apiUrl, params)
.pipe(map((response) => MeetingsMapper.fromMeetingsGetResponse(response)));
}

Expand All @@ -53,13 +56,13 @@ export class MeetingsService {
);

return this.jsonApiService
.get<ResponseJsonApi<MeetingSubmissionGetResponseJsonApi[]>>(`${this.baseUrl}${meetingId}/submissions/`, params)
.get<ResponseJsonApi<MeetingSubmissionGetResponseJsonApi[]>>(`${this.apiUrl}${meetingId}/submissions/`, params)
.pipe(map((response) => MeetingsMapper.fromMeetingSubmissionGetResponse(response)));
}

getMeetingById(meetingId: string) {
return this.jsonApiService
.get<JsonApiResponse<MeetingGetResponseJsonApi, null>>(this.baseUrl + meetingId)
.get<JsonApiResponse<MeetingGetResponseJsonApi, null>>(this.apiUrl + meetingId)
.pipe(map((response) => MeetingsMapper.fromMeetingGetResponse(response.data)));
}
}
16 changes: 13 additions & 3 deletions src/app/features/metadata/services/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@ import { CrossRefFundersResponse, CustomItemMetadataRecord, Metadata } from '../
export class MetadataService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiDomainUrl = this.environment.apiDomainUrl;
private readonly funderApiUrl = this.environment.funderApiUrl;
private readonly apiUrl = `${this.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

get apiDomainUrl() {
return this.environment.apiDomainUrl;
}

get funderApiUrl() {
return this.environment.funderApiUrl;
}

private readonly urlMap = new Map<ResourceType, string>([
[ResourceType.Project, 'nodes'],
[ResourceType.Registration, 'registrations'],
Expand Down
5 changes: 4 additions & 1 deletion src/app/features/moderation/services/moderators.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import { ModeratorAddModel, ModeratorDataJsonApi, ModeratorModel, ModeratorRespo
export class ModeratorsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

private readonly urlMap = new Map<ResourceType, string>([
[ResourceType.Collection, 'providers/collections'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import { PreprintSubmissionPaginatedData } from '../models/preprint-submission.m
export class PreprintModerationService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

getPreprintProviders(): Observable<PreprintProviderModerationInfo[]> {
const baseUrl = `${this.apiUrl}/providers/preprints/?filter[permissions]=view_actions,set_up_moderation`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { RegistryModeration, RegistryResponseJsonApi, ReviewAction, ReviewAction
export class RegistryModerationService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

getRegistrySubmissions(
provider: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export class PreprintFilesService {
private filesService = inject(FilesService);
private jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

updateFileRelationship(preprintId: string, fileId: string): Observable<Preprint> {
return this.jsonApiService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import { JsonApiService } from '@shared/services';
export class PreprintLicensesService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

getLicenses(providerId: string): Observable<LicenseModel[]> {
return this.jsonApiService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ import { JsonApiService } from '@shared/services';
export class PreprintProvidersService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly baseUrl = `${this.environment.apiDomainUrl}/v2/providers/preprints/`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2/providers/preprints/`;
}

getPreprintProviderById(id: string): Observable<PreprintProviderDetails> {
return this.jsonApiService
.get<JsonApiResponse<PreprintProviderDetailsJsonApi, null>>(`${this.baseUrl}${id}/?embed=brand`)
.get<JsonApiResponse<PreprintProviderDetailsJsonApi, null>>(`${this.apiUrl}${id}/?embed=brand`)
.pipe(map((response) => PreprintProvidersMapper.fromPreprintProviderDetailsGetResponse(response.data)));
}

getPreprintProvidersToAdvertise(): Observable<PreprintProviderShortInfo[]> {
return this.jsonApiService
.get<
JsonApiResponse<PreprintProviderDetailsJsonApi[], null>
>(`${this.baseUrl}?filter[advertise_on_discover_page]=true&reload=true`)
>(`${this.apiUrl}?filter[advertise_on_discover_page]=true&reload=true`)
.pipe(
map((response) =>
PreprintProvidersMapper.toPreprintProviderShortInfoFromGetResponse(
Expand All @@ -42,13 +45,13 @@ export class PreprintProvidersService {

getPreprintProvidersAllowingSubmissions(): Observable<PreprintProviderShortInfo[]> {
return this.jsonApiService
.get<JsonApiResponse<PreprintProviderDetailsJsonApi[], null>>(`${this.baseUrl}?filter[allow_submissions]=true`)
.get<JsonApiResponse<PreprintProviderDetailsJsonApi[], null>>(`${this.apiUrl}?filter[allow_submissions]=true`)
.pipe(map((response) => PreprintProvidersMapper.toPreprintProviderShortInfoFromGetResponse(response.data)));
}

getHighlightedSubjectsByProviderId(providerId: string): Observable<SubjectModel[]> {
return this.jsonApiService
.get<SubjectsResponseJsonApi>(`${this.baseUrl}${providerId}/subjects/highlighted/?page[size]=20`)
.get<SubjectsResponseJsonApi>(`${this.apiUrl}${providerId}/subjects/highlighted/?page[size]=20`)
.pipe(map((response) => PreprintProvidersMapper.fromSubjectsGetResponse(response.data)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ import { Preprint, PreprintAttributesJsonApi, PreprintLinksJsonApi, PreprintRela
export class PreprintsProjectsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

getAvailableProjects(searchTerm: StringOrNull): Observable<IdName[]> {
const params: Record<string, Primitive> = {};
params['page'] = 1;

if (searchTerm) {
params['filter[title]'] = searchTerm;
}
Expand Down
5 changes: 4 additions & 1 deletion src/app/features/preprints/services/preprints.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ import {
export class PreprintsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

private domainToApiFieldMap: Record<string, string> = {
title: 'title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { ProjectOverviewResponseJsonApi, ProjectOverviewWithMeta } from '../mode
export class ProjectOverviewService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

getProjectById(projectId: string): Observable<ProjectOverviewWithMeta> {
const params: Record<string, unknown> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { JsonApiService } from '@osf/shared/services';
export class RegistrationsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

getRegistrations(projectId: string, page: number, pageSize: number): Observable<PaginatedData<RegistrationCard[]>> {
const params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import {
export class SettingsService {
private readonly jsonApiService = inject(JsonApiService);
private readonly environment = inject(ENVIRONMENT);
private readonly apiUrl = `${this.environment.apiDomainUrl}/v2`;

get apiUrl() {
return `${this.environment.apiDomainUrl}/v2`;
}

getProjectSettings(nodeId: string): Observable<ProjectSettingsModel> {
return this.jsonApiService
Expand Down
Loading
Loading