diff --git a/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/GraphQLQuery.cs b/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/GraphQLQuery.cs index 1775311b98..86b2af3400 100644 --- a/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/GraphQLQuery.cs +++ b/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/GraphQLQuery.cs @@ -226,6 +226,8 @@ public GraphQLQuery() var gridAreas = await client.GetGridAreasAsync(); var gridAreaLookup = gridAreas.ToDictionary(x => x.Id); var actorDto = await client.GetActorAsync(context.GetArgument("id")); + var organization = await client.GetOrganizationAsync(actorDto.OrganizationId); + var actor = new Actor(actorDto.ActorId, actorDto.Name.Value, actorDto.ActorNumber.Value) { GridAreas = actorDto.MarketRoles @@ -236,6 +238,7 @@ public GraphQLQuery() MarketRole = actorDto.MarketRoles.FirstOrDefault()?.EicFunction, Status = actorDto.Status, + Organization = organization, }; return actor; }); @@ -249,6 +252,8 @@ public GraphQLQuery() { var eicFunctions = context.GetArgument("eicFunctions", Array.Empty()); var gridAreas = await client.GetGridAreasAsync(); + var organizations = await client.GetOrganizationsAsync(); + var organizationLookup = organizations.ToDictionary(x => x.OrganizationId); var gridAreaLookup = gridAreas.ToDictionary(x => x.Id); var actors = await client.GetActorsAsync(); @@ -270,6 +275,7 @@ public GraphQLQuery() MarketRole = x.MarketRoles.FirstOrDefault()?.EicFunction, Status = x.Status, + Organization = organizationLookup[x.OrganizationId], }); // TODO: Is this the right place to filter this list? diff --git a/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/Actor.cs b/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/Actor.cs index 183142b4a7..11020f9246 100644 --- a/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/Actor.cs +++ b/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/Actor.cs @@ -31,6 +31,8 @@ public class Actor public ActorStatus Status { get; set; } + public OrganizationDto? Organization { get; set; } + public Actor(Guid id, string name, string glnOrEicNumber) { Id = id; diff --git a/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/ActorDtoType.cs b/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/ActorDtoType.cs index d915195ddc..a2ac9f0335 100644 --- a/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/ActorDtoType.cs +++ b/apps/dh/api-dh/source/DataHub.WebApi/GraphQL/Types/ActorDtoType.cs @@ -38,6 +38,10 @@ public ActorDtoType() .Resolve(x => x.Source.Status) .Description("The status of the actor."); + Field("organization") + .Resolve(x => x.Source.Organization) + .Description("The organization of the actor."); + // Below are commented out since the actor number is currently // the only field that market participant and wholesale have in common // AND it is also not currently possible to get actor information from diff --git a/libs/dh/shared/domain/src/lib/generated/graphql.ts b/libs/dh/shared/domain/src/lib/generated/graphql.ts index 9c859b2db3..8a27b7d624 100644 --- a/libs/dh/shared/domain/src/lib/generated/graphql.ts +++ b/libs/dh/shared/domain/src/lib/generated/graphql.ts @@ -13,7 +13,6 @@ export type Scalars = { Boolean: boolean; Int: number; Float: number; - /** The `DateTimeOffset` scalar type represents a date, time and offset from UTC. `DateTimeOffset` expects timestamps to be formatted in accordance with the [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) standard. */ DateTimeOffset: string; DateRange: { start: string, end: string}; }; @@ -308,6 +307,8 @@ export type Actor = { marketRole?: Maybe; /** The status of the actor. */ status?: Maybe; + /** The organization of the actor. */ + organization?: Maybe; }; export enum ActorStatus { @@ -349,11 +350,6 @@ export type CreateCalculationInput = { gridAreaCodes: Array; }; -export type GetActorFilterQueryVariables = Exact<{ [key: string]: never; }>; - - -export type GetActorFilterQuery = { __typename?: 'GraphQLQuery', actors: Array<{ __typename?: 'Actor', value: string, displayValue: string, gridAreas: Array<{ __typename?: 'GridArea', code: string }> }> }; - export type GetPermissionDetailsQueryVariables = Exact<{ id: Scalars['ID']; }>; @@ -361,17 +357,12 @@ export type GetPermissionDetailsQueryVariables = Exact<{ export type GetPermissionDetailsQuery = { __typename?: 'GraphQLQuery', permission: { __typename?: 'Permission', id: number, name: string, description: string, created: string, assignableTo: Array, userRoles: Array<{ __typename?: 'UserRole', id: string, name: string, description: string, eicFunction: EicFunction, status: UserRoleStatus }> } }; -export type GetGridAreasQueryVariables = Exact<{ [key: string]: never; }>; - - -export type GetGridAreasQuery = { __typename?: 'GraphQLQuery', gridAreas: Array<{ __typename?: 'GridArea', code: string, name: string, validTo?: string | null, validFrom: string }> }; - -export type GetActorsForSettlementReportQueryVariables = Exact<{ - eicFunctions?: InputMaybe | EicFunction>; +export type GetPermissionsQueryVariables = Exact<{ + searchTerm?: InputMaybe; }>; -export type GetActorsForSettlementReportQuery = { __typename?: 'GraphQLQuery', actors: Array<{ __typename?: 'Actor', value: string, displayValue: string, gridAreas: Array<{ __typename?: 'GridArea', code: string }> }> }; +export type GetPermissionsQuery = { __typename?: 'GraphQLQuery', permissions: Array<{ __typename?: 'Permission', id: number, name: string, description: string, created: string }> }; export type CreateCalculationMutationVariables = Exact<{ input: CreateCalculationInput; @@ -387,6 +378,25 @@ export type GetPermissionLogsQueryVariables = Exact<{ export type GetPermissionLogsQuery = { __typename?: 'GraphQLQuery', permissionLogs: Array<{ __typename?: 'PermissionAuditLog', permissionId: number, changedByUserId: string, changedByUserName: string, permissionAuditLogType: PermissionAuditLogType, timestamp: string, value: string }> }; +export type GetActorFilterQueryVariables = Exact<{ [key: string]: never; }>; + + +export type GetActorFilterQuery = { __typename?: 'GraphQLQuery', actors: Array<{ __typename?: 'Actor', value: string, displayValue: string, gridAreas: Array<{ __typename?: 'GridArea', code: string }> }> }; + +export type GetCalculationQueryVariables = Exact<{ + id: Scalars['ID']; +}>; + + +export type GetCalculationQuery = { __typename?: 'GraphQLQuery', calculation?: { __typename?: 'Calculation', id: string, executionState: BatchState, executionTimeEnd?: string | null, executionTimeStart?: string | null, period?: { start: string, end: string} | null, statusType: StatusType, processType: ProcessType, createdByUserName: string, gridAreas: Array<{ __typename?: 'GridArea', code: string, name: string, id: string, priceAreaCode: PriceAreaCode, validFrom: string }> } | null }; + +export type GetActorsForSettlementReportQueryVariables = Exact<{ + eicFunctions?: InputMaybe | EicFunction>; +}>; + + +export type GetActorsForSettlementReportQuery = { __typename?: 'GraphQLQuery', actors: Array<{ __typename?: 'Actor', value: string, displayValue: string, gridAreas: Array<{ __typename?: 'GridArea', code: string }> }> }; + export type GetCalculationsQueryVariables = Exact<{ executionTime?: InputMaybe; period?: InputMaybe; @@ -398,17 +408,17 @@ export type GetCalculationsQueryVariables = Exact<{ export type GetCalculationsQuery = { __typename?: 'GraphQLQuery', calculations: Array<{ __typename?: 'Calculation', id: string, executionState: BatchState, executionTimeEnd?: string | null, executionTimeStart?: string | null, period?: { start: string, end: string} | null, statusType: StatusType, processType: ProcessType, createdByUserName: string, gridAreas: Array<{ __typename?: 'GridArea', code: string, name: string }> }> }; -export type GetPermissionsQueryVariables = Exact<{ - searchTerm?: InputMaybe; -}>; +export type GetGridAreasQueryVariables = Exact<{ [key: string]: never; }>; -export type GetPermissionsQuery = { __typename?: 'GraphQLQuery', permissions: Array<{ __typename?: 'Permission', id: number, name: string, description: string, created: string }> }; +export type GetGridAreasQuery = { __typename?: 'GraphQLQuery', gridAreas: Array<{ __typename?: 'GridArea', code: string, name: string, validTo?: string | null, validFrom: string }> }; -export type GetActorsQueryVariables = Exact<{ [key: string]: never; }>; +export type GetLatestBalanceFixingQueryVariables = Exact<{ + period?: InputMaybe; +}>; -export type GetActorsQuery = { __typename?: 'GraphQLQuery', actors: Array<{ __typename?: 'Actor', id: string, glnOrEicNumber: string, name: string, marketRole?: EicFunction | null, status?: ActorStatus | null }> }; +export type GetLatestBalanceFixingQuery = { __typename?: 'GraphQLQuery', calculations: Array<{ __typename?: 'Calculation', period?: { start: string, end: string} | null }> }; export type GetSettlementReportsQueryVariables = Exact<{ period?: InputMaybe; @@ -418,49 +428,24 @@ export type GetSettlementReportsQueryVariables = Exact<{ export type GetSettlementReportsQuery = { __typename?: 'GraphQLQuery', settlementReports: Array<{ __typename?: 'SettlementReport', batchNumber: string, processType: ProcessType, period?: { start: string, end: string} | null, executionTime?: string | null, gridArea: { __typename?: 'GridArea', code: string, name: string } }> }; -export type GetCalculationQueryVariables = Exact<{ - id: Scalars['ID']; -}>; - - -export type GetCalculationQuery = { __typename?: 'GraphQLQuery', calculation?: { __typename?: 'Calculation', id: string, executionState: BatchState, executionTimeEnd?: string | null, executionTimeStart?: string | null, period?: { start: string, end: string} | null, statusType: StatusType, processType: ProcessType, createdByUserName: string, gridAreas: Array<{ __typename?: 'GridArea', code: string, name: string, id: string, priceAreaCode: PriceAreaCode, validFrom: string }> } | null }; - -export type GetLatestBalanceFixingQueryVariables = Exact<{ - period?: InputMaybe; -}>; +export type GetActorsQueryVariables = Exact<{ [key: string]: never; }>; -export type GetLatestBalanceFixingQuery = { __typename?: 'GraphQLQuery', calculations: Array<{ __typename?: 'Calculation', period?: { start: string, end: string} | null }> }; +export type GetActorsQuery = { __typename?: 'GraphQLQuery', actors: Array<{ __typename?: 'Actor', id: string, glnOrEicNumber: string, name: string, marketRole?: EicFunction | null, status?: ActorStatus | null }> }; -export const GetActorFilterDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetActorFilter"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"actors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"id"}},{"kind":"Field","alias":{"kind":"Name","value":"displayValue"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetPermissionDetailsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPermissionDetails"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"permission"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"created"}},{"kind":"Field","name":{"kind":"Name","value":"assignableTo"}},{"kind":"Field","name":{"kind":"Name","value":"userRoles"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"eicFunction"}},{"kind":"Field","name":{"kind":"Name","value":"status"}}]}}]}}]}}]} as unknown as DocumentNode; -export const GetGridAreasDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"validTo"}},{"kind":"Field","name":{"kind":"Name","value":"validFrom"}}]}}]}}]} as unknown as DocumentNode; -export const GetActorsForSettlementReportDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetActorsForSettlementReport"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"eicFunctions"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"EicFunction"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"actors"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"eicFunctions"},"value":{"kind":"Variable","name":{"kind":"Name","value":"eicFunctions"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"glnOrEicNumber"}},{"kind":"Field","alias":{"kind":"Name","value":"displayValue"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetPermissionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPermissions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"searchTerm"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"permissions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"searchTerm"},"value":{"kind":"Variable","name":{"kind":"Name","value":"searchTerm"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"created"}}]}}]}}]} as unknown as DocumentNode; export const CreateCalculationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateCalculation"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateCalculationInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createCalculation"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode; export const GetPermissionLogsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPermissionLogs"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"permissionLogs"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"permissionId"}},{"kind":"Field","name":{"kind":"Name","value":"changedByUserId"}},{"kind":"Field","name":{"kind":"Name","value":"changedByUserName"}},{"kind":"Field","name":{"kind":"Name","value":"permissionAuditLogType"}},{"kind":"Field","name":{"kind":"Name","value":"timestamp"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]} as unknown as DocumentNode; -export const GetCalculationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCalculations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"executionTime"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"period"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"processTypes"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ProcessType"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"gridAreaCodes"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"executionStates"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"BatchState"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"calculations"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"executionTime"},"value":{"kind":"Variable","name":{"kind":"Name","value":"executionTime"}}},{"kind":"Argument","name":{"kind":"Name","value":"period"},"value":{"kind":"Variable","name":{"kind":"Name","value":"period"}}},{"kind":"Argument","name":{"kind":"Name","value":"processTypes"},"value":{"kind":"Variable","name":{"kind":"Name","value":"processTypes"}}},{"kind":"Argument","name":{"kind":"Name","value":"gridAreaCodes"},"value":{"kind":"Variable","name":{"kind":"Name","value":"gridAreaCodes"}}},{"kind":"Argument","name":{"kind":"Name","value":"executionStates"},"value":{"kind":"Variable","name":{"kind":"Name","value":"executionStates"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"executionState"}},{"kind":"Field","name":{"kind":"Name","value":"executionTimeEnd"}},{"kind":"Field","name":{"kind":"Name","value":"executionTimeStart"}},{"kind":"Field","name":{"kind":"Name","value":"period"}},{"kind":"Field","name":{"kind":"Name","value":"statusType"}},{"kind":"Field","name":{"kind":"Name","value":"processType"}},{"kind":"Field","name":{"kind":"Name","value":"createdByUserName"}},{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; -export const GetPermissionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPermissions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"searchTerm"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"permissions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"searchTerm"},"value":{"kind":"Variable","name":{"kind":"Name","value":"searchTerm"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"created"}}]}}]}}]} as unknown as DocumentNode; -export const GetActorsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetActors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"actors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"glnOrEicNumber"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"marketRole"}},{"kind":"Field","name":{"kind":"Name","value":"status"}}]}}]}}]} as unknown as DocumentNode; -export const GetSettlementReportsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSettlementReports"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"period"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"executionTime"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"settlementReports"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"period"},"value":{"kind":"Variable","name":{"kind":"Name","value":"period"}}},{"kind":"Argument","name":{"kind":"Name","value":"executionTime"},"value":{"kind":"Variable","name":{"kind":"Name","value":"executionTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"batchNumber"}},{"kind":"Field","name":{"kind":"Name","value":"processType"}},{"kind":"Field","name":{"kind":"Name","value":"period"}},{"kind":"Field","name":{"kind":"Name","value":"executionTime"}},{"kind":"Field","name":{"kind":"Name","value":"gridArea"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetActorFilterDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetActorFilter"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"actors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"id"}},{"kind":"Field","alias":{"kind":"Name","value":"displayValue"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetCalculationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCalculation"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"calculation"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"executionState"}},{"kind":"Field","name":{"kind":"Name","value":"executionTimeEnd"}},{"kind":"Field","name":{"kind":"Name","value":"executionTimeStart"}},{"kind":"Field","name":{"kind":"Name","value":"period"}},{"kind":"Field","name":{"kind":"Name","value":"statusType"}},{"kind":"Field","name":{"kind":"Name","value":"processType"}},{"kind":"Field","name":{"kind":"Name","value":"createdByUserName"}},{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"priceAreaCode"}},{"kind":"Field","name":{"kind":"Name","value":"validFrom"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetActorsForSettlementReportDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetActorsForSettlementReport"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"eicFunctions"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"EicFunction"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"actors"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"eicFunctions"},"value":{"kind":"Variable","name":{"kind":"Name","value":"eicFunctions"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"glnOrEicNumber"}},{"kind":"Field","alias":{"kind":"Name","value":"displayValue"},"name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetCalculationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCalculations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"executionTime"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"period"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"processTypes"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ProcessType"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"gridAreaCodes"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"executionStates"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"BatchState"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"calculations"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"executionTime"},"value":{"kind":"Variable","name":{"kind":"Name","value":"executionTime"}}},{"kind":"Argument","name":{"kind":"Name","value":"period"},"value":{"kind":"Variable","name":{"kind":"Name","value":"period"}}},{"kind":"Argument","name":{"kind":"Name","value":"processTypes"},"value":{"kind":"Variable","name":{"kind":"Name","value":"processTypes"}}},{"kind":"Argument","name":{"kind":"Name","value":"gridAreaCodes"},"value":{"kind":"Variable","name":{"kind":"Name","value":"gridAreaCodes"}}},{"kind":"Argument","name":{"kind":"Name","value":"executionStates"},"value":{"kind":"Variable","name":{"kind":"Name","value":"executionStates"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"executionState"}},{"kind":"Field","name":{"kind":"Name","value":"executionTimeEnd"}},{"kind":"Field","name":{"kind":"Name","value":"executionTimeStart"}},{"kind":"Field","name":{"kind":"Name","value":"period"}},{"kind":"Field","name":{"kind":"Name","value":"statusType"}},{"kind":"Field","name":{"kind":"Name","value":"processType"}},{"kind":"Field","name":{"kind":"Name","value":"createdByUserName"}},{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetGridAreasDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"gridAreas"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"validTo"}},{"kind":"Field","name":{"kind":"Name","value":"validFrom"}}]}}]}}]} as unknown as DocumentNode; export const GetLatestBalanceFixingDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLatestBalanceFixing"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"period"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"calculations"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1"}},{"kind":"Argument","name":{"kind":"Name","value":"period"},"value":{"kind":"Variable","name":{"kind":"Name","value":"period"}}},{"kind":"Argument","name":{"kind":"Name","value":"processTypes"},"value":{"kind":"EnumValue","value":"BALANCE_FIXING"}},{"kind":"Argument","name":{"kind":"Name","value":"executionStates"},"value":{"kind":"EnumValue","value":"COMPLETED"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"period"}}]}}]}}]} as unknown as DocumentNode; - -/** - * @param resolver a function that accepts a captured request and may return a mocked response. - * @see https://mswjs.io/docs/basics/response-resolver - * @example - * mockGetActorFilterQuery((req, res, ctx) => { - * return res( - * ctx.data({ actors }) - * ) - * }) - */ -export const mockGetActorFilterQuery = (resolver: ResponseResolver, GraphQLContext, any>) => - graphql.query( - 'GetActorFilter', - resolver - ) +export const GetSettlementReportsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSettlementReports"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"period"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"executionTime"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateRange"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"settlementReports"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"period"},"value":{"kind":"Variable","name":{"kind":"Name","value":"period"}}},{"kind":"Argument","name":{"kind":"Name","value":"executionTime"},"value":{"kind":"Variable","name":{"kind":"Name","value":"executionTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"batchNumber"}},{"kind":"Field","name":{"kind":"Name","value":"processType"}},{"kind":"Field","name":{"kind":"Name","value":"period"}},{"kind":"Field","name":{"kind":"Name","value":"executionTime"}},{"kind":"Field","name":{"kind":"Name","value":"gridArea"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"code"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetActorsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetActors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"actors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"glnOrEicNumber"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"marketRole"}},{"kind":"Field","name":{"kind":"Name","value":"status"}}]}}]}}]} as unknown as DocumentNode; /** * @param resolver a function that accepts a captured request and may return a mocked response. @@ -483,32 +468,16 @@ export const mockGetPermissionDetailsQuery = (resolver: ResponseResolver { - * return res( - * ctx.data({ gridAreas }) - * ) - * }) - */ -export const mockGetGridAreasQuery = (resolver: ResponseResolver, GraphQLContext, any>) => - graphql.query( - 'GetGridAreas', - resolver - ) - -/** - * @param resolver a function that accepts a captured request and may return a mocked response. - * @see https://mswjs.io/docs/basics/response-resolver - * @example - * mockGetActorsForSettlementReportQuery((req, res, ctx) => { - * const { eicFunctions } = req.variables; + * mockGetPermissionsQuery((req, res, ctx) => { + * const { searchTerm } = req.variables; * return res( - * ctx.data({ actors }) + * ctx.data({ permissions }) * ) * }) */ -export const mockGetActorsForSettlementReportQuery = (resolver: ResponseResolver, GraphQLContext, any>) => - graphql.query( - 'GetActorsForSettlementReport', +export const mockGetPermissionsQuery = (resolver: ResponseResolver, GraphQLContext, any>) => + graphql.query( + 'GetPermissions', resolver ) @@ -550,16 +519,15 @@ export const mockGetPermissionLogsQuery = (resolver: ResponseResolver { - * const { executionTime, period, processTypes, gridAreaCodes, executionStates } = req.variables; + * mockGetActorFilterQuery((req, res, ctx) => { * return res( - * ctx.data({ calculations }) + * ctx.data({ actors }) * ) * }) */ -export const mockGetCalculationsQuery = (resolver: ResponseResolver, GraphQLContext, any>) => - graphql.query( - 'GetCalculations', +export const mockGetActorFilterQuery = (resolver: ResponseResolver, GraphQLContext, any>) => + graphql.query( + 'GetActorFilter', resolver ) @@ -567,16 +535,16 @@ export const mockGetCalculationsQuery = (resolver: ResponseResolver { - * const { searchTerm } = req.variables; + * mockGetCalculationQuery((req, res, ctx) => { + * const { id } = req.variables; * return res( - * ctx.data({ permissions }) + * ctx.data({ calculation }) * ) * }) */ -export const mockGetPermissionsQuery = (resolver: ResponseResolver, GraphQLContext, any>) => - graphql.query( - 'GetPermissions', +export const mockGetCalculationQuery = (resolver: ResponseResolver, GraphQLContext, any>) => + graphql.query( + 'GetCalculation', resolver ) @@ -584,15 +552,16 @@ export const mockGetPermissionsQuery = (resolver: ResponseResolver { + * mockGetActorsForSettlementReportQuery((req, res, ctx) => { + * const { eicFunctions } = req.variables; * return res( * ctx.data({ actors }) * ) * }) */ -export const mockGetActorsQuery = (resolver: ResponseResolver, GraphQLContext, any>) => - graphql.query( - 'GetActors', +export const mockGetActorsForSettlementReportQuery = (resolver: ResponseResolver, GraphQLContext, any>) => + graphql.query( + 'GetActorsForSettlementReport', resolver ) @@ -600,16 +569,16 @@ export const mockGetActorsQuery = (resolver: ResponseResolver { - * const { period, executionTime } = req.variables; + * mockGetCalculationsQuery((req, res, ctx) => { + * const { executionTime, period, processTypes, gridAreaCodes, executionStates } = req.variables; * return res( - * ctx.data({ settlementReports }) + * ctx.data({ calculations }) * ) * }) */ -export const mockGetSettlementReportsQuery = (resolver: ResponseResolver, GraphQLContext, any>) => - graphql.query( - 'GetSettlementReports', +export const mockGetCalculationsQuery = (resolver: ResponseResolver, GraphQLContext, any>) => + graphql.query( + 'GetCalculations', resolver ) @@ -617,16 +586,15 @@ export const mockGetSettlementReportsQuery = (resolver: ResponseResolver { - * const { id } = req.variables; + * mockGetGridAreasQuery((req, res, ctx) => { * return res( - * ctx.data({ calculation }) + * ctx.data({ gridAreas }) * ) * }) */ -export const mockGetCalculationQuery = (resolver: ResponseResolver, GraphQLContext, any>) => - graphql.query( - 'GetCalculation', +export const mockGetGridAreasQuery = (resolver: ResponseResolver, GraphQLContext, any>) => + graphql.query( + 'GetGridAreas', resolver ) @@ -646,3 +614,36 @@ export const mockGetLatestBalanceFixingQuery = (resolver: ResponseResolver { + * const { period, executionTime } = req.variables; + * return res( + * ctx.data({ settlementReports }) + * ) + * }) + */ +export const mockGetSettlementReportsQuery = (resolver: ResponseResolver, GraphQLContext, any>) => + graphql.query( + 'GetSettlementReports', + resolver + ) + +/** + * @param resolver a function that accepts a captured request and may return a mocked response. + * @see https://mswjs.io/docs/basics/response-resolver + * @example + * mockGetActorsQuery((req, res, ctx) => { + * return res( + * ctx.data({ actors }) + * ) + * }) + */ +export const mockGetActorsQuery = (resolver: ResponseResolver, GraphQLContext, any>) => + graphql.query( + 'GetActors', + resolver + ) diff --git a/libs/eo/auth/routing-security/src/lib/eo-authentication.guard.ts b/libs/eo/auth/routing-security/src/lib/eo-authentication.guard.ts index a20bd9bff2..aa9ac886c3 100644 --- a/libs/eo/auth/routing-security/src/lib/eo-authentication.guard.ts +++ b/libs/eo/auth/routing-security/src/lib/eo-authentication.guard.ts @@ -33,10 +33,10 @@ export class EoScopeGuard implements CanActivate { return this.authStore.getScope$.pipe( map((scope) => { - if (scope.includes('not-accepted-terms')) this.router.navigate(['/terms']); + if (scope.includes('not-accepted-privacypolicy-terms')) this.router.navigate(['/terms']); if (!this.authStore.token.getValue()) this.router.navigate(['']); - return !!scope.includes('accepted-terms'); + return !scope.includes('not-accepted-privacypolicy-terms'); }) ); } diff --git a/libs/eo/core/shell/src/lib/eo-login.component.ts b/libs/eo/core/shell/src/lib/eo-login.component.ts index 464362dec6..19ee5f30c9 100644 --- a/libs/eo/core/shell/src/lib/eo-login.component.ts +++ b/libs/eo/core/shell/src/lib/eo-login.component.ts @@ -46,9 +46,9 @@ export class EoLoginComponent { this.router.navigate(['/'], { queryParamsHandling: 'preserve' }); } else if (isTokenExpired) { this.service.logout(); - } else if (scope.includes('not-accepted-terms')) { + } else if (scope.includes('not-accepted-privacypolicy-terms')) { this.router.navigate(['/terms']); - } else if (scope.includes('accepted-terms') && scope.includes('dashboard')) { + } else if (scope.includes('dashboard')) { this.router.navigate(['/dashboard']); } else this.router.navigate(['/'], { queryParamsHandling: 'preserve' }); }); diff --git a/libs/eo/shared/assets/src/assets/configuration/privacy-policy.json b/libs/eo/shared/assets/src/assets/configuration/privacy-policy.json new file mode 100644 index 0000000000..3f562dd675 --- /dev/null +++ b/libs/eo/shared/assets/src/assets/configuration/privacy-policy.json @@ -0,0 +1 @@ +{ "version": 1 } diff --git a/libs/eo/shared/atomic-design/feature-molecules/src/lib/eo-privacy-policy/eo-privacy-policy.component.ts b/libs/eo/shared/atomic-design/feature-molecules/src/lib/eo-privacy-policy/eo-privacy-policy.component.ts index 8f22aa671b..cf054090ec 100644 --- a/libs/eo/shared/atomic-design/feature-molecules/src/lib/eo-privacy-policy/eo-privacy-policy.component.ts +++ b/libs/eo/shared/atomic-design/feature-molecules/src/lib/eo-privacy-policy/eo-privacy-policy.component.ts @@ -14,15 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AsyncPipe } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { AsyncPipe, NgIf } from '@angular/common'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; + +import { WattEmptyStateComponent } from '@energinet-datahub/watt/empty-state'; + import { EoScrollViewComponent } from '@energinet-datahub/eo/shared/atomic-design/ui-atoms'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, - imports: [EoScrollViewComponent, AsyncPipe], + imports: [EoScrollViewComponent, AsyncPipe, NgIf, WattEmptyStateComponent], selector: 'eo-privacy-policy', styles: [ ` @@ -30,11 +32,7 @@ import { EoScrollViewComponent } from '@energinet-datahub/eo/shared/atomic-desig display: block; } - small { - color: var(--watt-color-neutral-grey-700); - } - - .policy ::ng-deep { + :host ::ng-deep { h2 { margin-bottom: 16px; } @@ -85,10 +83,21 @@ import { EoScrollViewComponent } from '@energinet-datahub/eo/shared/atomic-desig } `, ], - template: `
`, + template: ` + +
+
+ + + + + `, }) export class EoPrivacyPolicyComponent { - privacyPolicy$ = this.http.get('/assets/html/privacy-policy.html', { responseType: 'text' }); - - constructor(private http: HttpClient) {} + @Input() policy!: string | null; + @Input() hasError = false; } diff --git a/libs/eo/shared/services/src/auth/auth.store.ts b/libs/eo/shared/services/src/auth/auth.store.ts index b938c51ce4..5e48f22587 100644 --- a/libs/eo/shared/services/src/auth/auth.store.ts +++ b/libs/eo/shared/services/src/auth/auth.store.ts @@ -23,11 +23,9 @@ export interface EoLoginToken { exp?: number; name?: string; nbf?: number; - /** @example "accepted-terms dashboard production meters certificates" */ + /** @example "dashboard production meters certificates" */ scope?: string; sub?: string; - /** @example 3 - To indicate that the latest terms version is 3 */ - trm?: number; tin?: string; } @@ -46,7 +44,6 @@ export class EoAuthStore extends ComponentStore { getScope$ = this.select((state) => state.scope?.split(' ') ?? []); getTokenNotBefore$ = this.select((state) => state.nbf ?? 0); getTokenExpiry$ = this.select((state) => state.exp ?? 0); - getTermsVersion$ = this.select((state) => state.trm); getTin$ = this.select((state) => state.tin); isTokenExpired$ = this.select((state) => Date.now() / 1000 > (state.exp ?? 0)); diff --git a/libs/eo/shared/services/src/feature-flag/feature-flag.directive.ts b/libs/eo/shared/services/src/feature-flag/feature-flag.directive.ts index 5e2a0db524..f2c17c3865 100644 --- a/libs/eo/shared/services/src/feature-flag/feature-flag.directive.ts +++ b/libs/eo/shared/services/src/feature-flag/feature-flag.directive.ts @@ -18,8 +18,7 @@ import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core'; import { EoAuthStore } from '../auth/auth.store'; const knownFeatures = [ - 'not-accepted-terms', - 'accepted-terms', + 'not-accepted-privacypolicy-terms', 'dashboard', 'production', 'meters', diff --git a/libs/eo/shared/services/src/terms/eo-terms.service.ts b/libs/eo/shared/services/src/terms/eo-terms.service.ts index 3ef3240327..3b26478a50 100644 --- a/libs/eo/shared/services/src/terms/eo-terms.service.ts +++ b/libs/eo/shared/services/src/terms/eo-terms.service.ts @@ -17,40 +17,25 @@ import { HttpClient } from '@angular/common/http'; import { Inject, Injectable } from '@angular/core'; import { EoApiEnvironment, eoApiEnvironmentToken } from '@energinet-datahub/eo/shared/environments'; -import { switchMap } from 'rxjs'; -import { EoAuthStore } from '../auth/auth.store'; - -export interface AuthTermsResponse { - /** - * A single line of raw text - */ - readonly headline: string; - /** - * A string containing safe HTML - */ - readonly terms: string; - /** - * A string: I.eg: "0.1" - */ - readonly version: string; -} @Injectable({ providedIn: 'root', }) export class EoTermsService { #apiBase: string; + private currentVersion = -1; constructor( private http: HttpClient, - private authStore: EoAuthStore, @Inject(eoApiEnvironmentToken) apiEnvironment: EoApiEnvironment ) { this.#apiBase = `${apiEnvironment.apiBase}`; } + setVersion(version: number) { + this.currentVersion = version; + } + acceptTerms() { - return this.authStore.getTermsVersion$.pipe( - switchMap((version) => this.http.put(`${this.#apiBase}/terms/accept`, { version })) - ); + return this.http.put(`${this.#apiBase}/terms/user/accept/${this.currentVersion}`, null); } } diff --git a/libs/eo/terms/src/lib/eo-terms.component.ts b/libs/eo/terms/src/lib/eo-terms.component.ts index 9e6498d6e9..f3f0f8f8d1 100644 --- a/libs/eo/terms/src/lib/eo-terms.component.ts +++ b/libs/eo/terms/src/lib/eo-terms.component.ts @@ -14,21 +14,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { NgIf } from '@angular/common'; -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { AsyncPipe, NgIf } from '@angular/common'; +import { HttpClient } from '@angular/common/http'; +import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { Router } from '@angular/router'; +import { catchError, of, switchMap } from 'rxjs'; + +import { WattButtonComponent } from '@energinet-datahub/watt/button'; +import { WattCheckboxComponent } from '@energinet-datahub/watt/checkbox'; +import { WattSpinnerComponent } from '@energinet-datahub/watt/spinner'; + import { EoPrivacyPolicyComponent } from '@energinet-datahub/eo/shared/atomic-design/feature-molecules'; import { EoScrollViewComponent } from '@energinet-datahub/eo/shared/atomic-design/ui-atoms'; import { EoFooterComponent, EoHeaderComponent, } from '@energinet-datahub/eo/shared/atomic-design/ui-organisms'; -import { EoAuthService, EoAuthStore, EoTermsService } from '@energinet-datahub/eo/shared/services'; -import { WattButtonComponent } from '@energinet-datahub/watt/button'; -import { WattCheckboxComponent } from '@energinet-datahub/watt/checkbox'; -import { WattSpinnerComponent } from '@energinet-datahub/watt/spinner'; +import { EoAuthService, EoTermsService } from '@energinet-datahub/eo/shared/services'; +interface VersionResponse { + version: number; +} @Component({ changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, @@ -42,6 +49,7 @@ import { WattSpinnerComponent } from '@energinet-datahub/watt/spinner'; EoScrollViewComponent, WattSpinnerComponent, NgIf, + AsyncPipe, ], selector: 'eo-auth-terms', styles: [ @@ -71,10 +79,17 @@ import { WattSpinnerComponent } from '@energinet-datahub/watt/spinner';
- +
- + I have seen the Privacy Policy
@@ -99,16 +114,31 @@ import { WattSpinnerComponent } from '@energinet-datahub/watt/spinner'; `, }) export class EoTermsComponent { + private http = inject(HttpClient); + private termsService = inject(EoTermsService); + private authService = inject(EoAuthService); + private router = inject(Router); + private policyVersion$ = this.http.get( + '/assets/configuration/privacy-policy.json' + ); + + loadingPrivacyPolicyFailed = false; + privacyPolicy$ = this.policyVersion$.pipe( + switchMap((response) => { + this.termsService.setVersion(response.version); + return this.http.get('/assets/html/privacy-policy.html', { responseType: 'text' }); + }), + catchError(() => { + this.termsService.setVersion(-1); + this.loadingPrivacyPolicyFailed = true; + + return of(null); + }) + ); + hasAcceptedPrivacyPolicy = false; startedAcceptFlow = false; - constructor( - private authService: EoAuthService, - private termsService: EoTermsService, - private authStore: EoAuthStore, - private router: Router - ) {} - onCancel() { this.authService.logout(); } diff --git a/schema.graphql b/schema.graphql index 0a9e9dd2e9..f2bf8c0904 100644 --- a/schema.graphql +++ b/schema.graphql @@ -296,6 +296,9 @@ type Actor { """The status of the actor.""" status: ActorStatus + + """The organization of the actor.""" + organization: Organization } enum ActorStatus {