Skip to content

Commit

Permalink
Added simple view for electricity market (#3880)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
mimse and github-actions[bot] authored Jan 15, 2025
1 parent 9f5b9e4 commit 2b2b345
Show file tree
Hide file tree
Showing 28 changed files with 744 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,46 @@ type MeteringGridAreaImbalanceSearchResult {
outgoingImbalancePerDay: [MeteringGridAreaImbalancePerDayDto!]!
}

type MeteringPointDto {
id: Long!
identification: String!
meteringPointPeriod: MeteringPointPeriodDto!
}

type MeteringPointPeriodDto {
id: Long!
validFrom: DateTime!
validTo: DateTime!
createdAt: DateTime!
gridAreaCode: String!
ownenBy: String!
connectionState: String!
type: String!
subType: String!
resolution: String!
unit: String!
productId: String!
scheduledMeterReadingMonth: Int!
}

"A connection to a list of items."
type MeteringPointsConnection {
"Information to aid in pagination."
pageInfo: PageInfo!
"A list of edges."
edges: [MeteringPointsEdge!]
"A flattened list of the nodes."
nodes: [MeteringPointDto!]
}

"An edge in a connection."
type MeteringPointsEdge {
"A cursor for use in pagination."
cursor: String!
"The item at the end of the edge."
node: MeteringPointDto!
}

type Mutation {
updateActor(input: UpdateActorInput!): UpdateActorPayload!
createMarketParticipant(input: CreateMarketParticipantInput!): CreateMarketParticipantPayload!
Expand Down Expand Up @@ -687,6 +727,7 @@ type Query {
calculationById(id: UUID!): Calculation! @authorize(roles: [ "calculations:manage", "calculations:view" ])
calculations(input: CalculationQueryInput! filter: String "Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String order: [CalculationSortInput!]): CalculationsConnection @authorize(roles: [ "calculations:manage", "calculations:view" ])
latestCalculation(period: DateRange! calculationType: CalculationType!): Calculation @authorize(roles: [ "calculations:manage", "calculations:view" ])
meteringPoints(filter: String "Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): MeteringPointsConnection
esettServiceStatus: [ReadinessStatusDto!]!
esettExchangeStatusReport: ExchangeEventStatusReportResponse!
esettOutgoingMessageById(documentId: String!): EsettOutgoingMessage!
Expand Down
2 changes: 2 additions & 0 deletions apps/dh/api-dh/source/DataHub.WebApi/ApiClientSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ public class ApiClientSettings
public string NotificationsBaseUrl { get; set; } = string.Empty;

public string Dh2BridgeBaseUrl { get; set; } = string.Empty;

public string ElectricityMarketBaseUrl { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,6 @@ private string ConvertToString(object? value, System.Globalization.CultureInfo c
}
}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class Instant
{

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class MeteringPointDto
{
Expand All @@ -315,13 +309,13 @@ public partial class MeteringPointPeriodDto
public long Id { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("validFrom", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public Instant ValidFrom { get; set; } = default!;
public System.DateTimeOffset ValidFrom { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("validTo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public Instant ValidTo { get; set; } = default!;
public System.DateTimeOffset ValidTo { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("createdAt", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public Instant CreatedAt { get; set; } = default!;
public System.DateTimeOffset CreatedAt { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("gridAreaCode", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string GridAreaCode { get; set; } = default!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"url": "https://localhost:7085/swagger/v1/swagger.json",
"url": "https://localhost:6005/swagger/v1/swagger.json",
"output": "swagger.json",
"newLineBehavior": "Auto"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@
},
"components": {
"schemas": {
"Instant": {
"type": "object",
"additionalProperties": false
},
"MeteringPointDto": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -97,25 +93,16 @@
"format": "int64"
},
"validFrom": {
"allOf": [
{
"$ref": "#/components/schemas/Instant"
}
]
"type": "string",
"format": "date-time"
},
"validTo": {
"allOf": [
{
"$ref": "#/components/schemas/Instant"
}
]
"type": "string",
"format": "date-time"
},
"createdAt": {
"allOf": [
{
"$ref": "#/components/schemas/Instant"
}
]
"type": "string",
"format": "date-time"
},
"gridAreaCode": {
"type": "string"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2020 Energinet DataHub A/S
//
// Licensed under the Apache License, Version 2.0 (the "License2");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Energinet.DataHub.WebApi.Clients.ElectricityMarket.v1;

namespace Energinet.DataHub.WebApi.GraphQL.Query;

public partial class Query
{
[UsePaging]
public async Task<IEnumerable<MeteringPointDto>> GetMeteringPointsAsync(
string? filter,
[Service] IElectricityMarketClient_V1 electricityMarketClient)
{
if (string.IsNullOrWhiteSpace(filter))
{
return Enumerable.Empty<MeteringPointDto>();
}

return await electricityMarketClient.ElectricityMarketAsync(filter).ConfigureAwait(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Energinet.DataHub.ProcessManager.Client.Extensions.DependencyInjection;
using Energinet.DataHub.ProcessManager.Client.Extensions.Options;
using Energinet.DataHub.WebApi.Clients.Dh2Bridge;
using Energinet.DataHub.WebApi.Clients.ElectricityMarket.v1;
using Energinet.DataHub.WebApi.Clients.ESettExchange.v1;
using Energinet.DataHub.WebApi.Clients.ImbalancePrices.v1;
using Energinet.DataHub.WebApi.Clients.MarketParticipant.v1;
Expand Down Expand Up @@ -96,6 +97,8 @@ public static IServiceCollection AddDomainClients(this IServiceCollection servic
GetBaseUri(apiClientSettings.NotificationsBaseUrl))
.AddDh2BridgeClient(
GetBaseUri(apiClientSettings.Dh2BridgeBaseUrl))
.AddElectricityMarket(
GetBaseUri(apiClientSettings.ElectricityMarketBaseUrl))
.AddSingleton(apiClientSettings);
}

Expand Down Expand Up @@ -195,4 +198,12 @@ private static IServiceCollection AddDh2BridgeClient(this IServiceCollection ser
baseUri.ToString(),
provider.GetRequiredService<AuthorizedHttpClientFactory>().CreateClient(baseUri)));
}

private static IServiceCollection AddElectricityMarket(this IServiceCollection serviceCollection, Uri baseUri)
{
return serviceCollection.AddScoped<IElectricityMarketClient_V1, ElectricityMarketClient_V1>(
provider => new ElectricityMarketClient_V1(
baseUri.ToString(),
provider.GetRequiredService<AuthorizedHttpClientFactory>().CreateClient(baseUri)));
}
}
3 changes: 2 additions & 1 deletion apps/dh/api-dh/source/DataHub.WebApi/appsettings.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"WholesaleOrchestrationSettlementReportsLightBaseUrl": "https://localhost:5091",
"SettlementReportsAPIBaseUrl": "https://localhost:5091",
"NotificationsBaseUrl": "https://localhost:5091",
"Dh2BridgeBaseUrl": "https://localhost:5091"
"Dh2BridgeBaseUrl": "https://localhost:5091",
"ElectricityMarketBaseUrl": "https://localhost:5091",
},
"APPLICATIONINSIGHTS_CONNECTION_STRING": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"UserAuthentication:MitIdExternalMetadataAddress": "https://<url>",
Expand Down
2 changes: 2 additions & 0 deletions libs/dh/core/routing/src/dhPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//#endregion
const marketParticipantSubPaths = {
actorsPath: 'actors',
Expand Down Expand Up @@ -49,6 +50,7 @@ const basePaths = {
gridAreas: 'grid-areas',
wholesale: 'wholesale',
login: 'login',
electricityMarketSimpleView: 'electricity-market-simple-view',
} as const;

export type MarketParticipantSubPaths =
Expand Down
8 changes: 8 additions & 0 deletions libs/dh/core/shell/src/lib/dh-core-shell.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ export const dhCoreShellRoutes: Routes = [
loadChildren: () => import('@energinet-datahub/dh/imbalance-prices/shell'),
canActivate: [MsalGuard],
},
{
path: getPath<BasePaths>('electricity-market-simple-view'),
loadComponent: () => import('@energinet-datahub/dh/electricity-market'),
data: {
titleTranslationKey: 'electricityMarket.topBarTitle',
},
canActivate: [MsalGuard],
},
{
path: getPath<BasePaths>('market-participant'),
loadChildren: () => import('@energinet-datahub/dh/market-participant/shell'),
Expand Down
68 changes: 39 additions & 29 deletions libs/dh/core/shell/src/lib/dh-primary-navigation.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,44 +39,54 @@
[link]="getLink('imbalance-prices')"
>{{ transloco("imbalancePrices") }}</watt-nav-list-item
>

<ng-container *dhFeatureFlag="'electricity-market'">
<watt-nav-list-item
*dhPermissionRequired="['fas']"
[link]="getLink('electricity-market-simple-view')"
>{{ transloco("electricityMarket") }}</watt-nav-list-item
>
</ng-container>
</watt-nav-list>

<ng-container
<watt-nav-list
*dhPermissionRequired="[
'calculations:view',
'settlement-reports:manage',
'request-aggregated-measured-data:view',
'request-wholesale-settlement:view',
]"
[expandable]="true"
[title]="transloco('wholesale.menuGroupLabel')"
>
<watt-nav-list [expandable]="true" [title]="transloco('wholesale.menuGroupLabel')">
<watt-nav-list-item
*dhPermissionRequired="[
'request-aggregated-measured-data:view',
'request-wholesale-settlement:view',
]"
[link]="getWholesaleLink('request-calculation')"
>{{ transloco("wholesale.requestCalculation") }}</watt-nav-list-item
>
<watt-nav-list-item
*dhPermissionRequired="['calculations:view']"
[link]="getWholesaleLink('calculations')"
>{{ transloco("wholesale.calculations") }}</watt-nav-list-item
>
<watt-nav-list-item
*dhPermissionRequired="[
'request-aggregated-measured-data:view',
'request-wholesale-settlement:view',
]"
[link]="getWholesaleLink('request-calculation')"
>{{ transloco("wholesale.requestCalculation") }}</watt-nav-list-item
>
<watt-nav-list-item
*dhPermissionRequired="['calculations:view']"
[link]="getWholesaleLink('calculations')"
>{{ transloco("wholesale.calculations") }}</watt-nav-list-item
>

<watt-nav-list-item
*dhPermissionRequired="['settlement-reports:manage']"
[link]="getWholesaleLink('settlement-reports')"
>{{ transloco("wholesale.settlementReports") }}</watt-nav-list-item
>
</watt-nav-list>
</ng-container>
<watt-nav-list-item
*dhPermissionRequired="['settlement-reports:manage']"
[link]="getWholesaleLink('settlement-reports')"
>{{ transloco("wholesale.settlementReports") }}</watt-nav-list-item
>
</watt-nav-list>

<ng-container *dhPermissionRequired="['users:manage']">
<watt-nav-list [expandable]="true" [title]="transloco('admin.menuGroupLabel')">
<watt-nav-list-item [link]="getLink('admin')">{{
transloco("admin.userManagement")
}}</watt-nav-list-item>
</watt-nav-list>
</ng-container>
<watt-nav-list
*dhPermissionRequired="['users:manage']"
[expandable]="true"
[title]="transloco('admin.menuGroupLabel')"
>
<watt-nav-list-item [link]="getLink('admin')">{{
transloco("admin.userManagement")
}}</watt-nav-list-item>
</watt-nav-list>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { TranslocoDirective } from '@ngneat/transloco';

import { WattNavListComponent, WattNavListItemComponent } from '@energinet-datahub/watt/shell';
import { DhFeatureFlagDirective } from '@energinet-datahub/dh/shared/feature-flags';
import { DhPermissionRequiredDirective } from '@energinet-datahub/dh/shared/feature-authorization';

import { WattNavListComponent, WattNavListItemComponent } from '@energinet-datahub/watt/shell';
import { WholesaleSubPaths, combinePaths, BasePaths } from '@energinet-datahub/dh/core/routing';

@Component({
Expand All @@ -38,6 +40,8 @@ import { WholesaleSubPaths, combinePaths, BasePaths } from '@energinet-datahub/d
TranslocoDirective,
WattNavListComponent,
WattNavListItemComponent,

DhFeatureFlagDirective,
DhPermissionRequiredDirective,
],
})
Expand Down
33 changes: 33 additions & 0 deletions libs/dh/electricity-market/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "dh",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "dh",
"style": "kebab-case"
}
]
},
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"]
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
Loading

0 comments on commit 2b2b345

Please sign in to comment.