Skip to content

Commit

Permalink
Changing enums import, adding OCPP2_0_1 values.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddygrebt committed Jan 9, 2025
1 parent 8400739 commit 4323175
Show file tree
Hide file tree
Showing 34 changed files with 172 additions and 216 deletions.
16 changes: 7 additions & 9 deletions src/message/certificate-signed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import {
IsOptional,
ValidateNested,
} from 'class-validator';
import {
CertificateSignedStatusEnumType,
CertificateSigningUseEnumType,
} from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { readFileContent, triggerMessageAndHandleResponse } from '../util';
import { StatusInfoType } from '../model/StatusInfoType';
import { GenericForm } from '../../components/form';
Expand All @@ -29,9 +26,9 @@ class CertificateSignedRequest {
// @IsOptional()
// customData?: CustomDataType;

@IsEnum(CertificateSigningUseEnumType)
@IsEnum(OCPP2_0_1.CertificateSigningUseEnumType)
@IsOptional()
certificateType?: CertificateSigningUseEnumType;
certificateType?: OCPP2_0_1.CertificateSigningUseEnumType;

@SupportedFileFormats(['.pem', '.id'])
@Type(() => File)
Expand All @@ -46,8 +43,8 @@ export class CertificateSignedResponse {
// @IsOptional()
// customData?: CustomDataType;

@IsEnum(CertificateSignedStatusEnumType)
status!: CertificateSignedStatusEnumType;
@IsEnum(OCPP2_0_1.CertificateSignedStatusEnumType)
status!: OCPP2_0_1.CertificateSignedStatusEnumType;

@Type(() => StatusInfoType)
@ValidateNested()
Expand Down Expand Up @@ -84,7 +81,8 @@ export const CertificateSigned: React.FC<CertificateSignedProps> = ({
responseSuccessCheck: (response: CertificateSignedResponse) =>
response &&
response.status &&
response.status === CertificateSignedStatusEnumType.Accepted,
response.status ===
OCPP2_0_1.CertificateSignedStatusEnumType.Accepted,
});
} catch (error) {
console.error('Error during submission:', error);
Expand Down
6 changes: 3 additions & 3 deletions src/message/change-availability/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
IsOptional,
ValidateNested,
} from 'class-validator';
import { OperationalStatusEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { NEW_IDENTIFIER } from '@util/consts';
import { ChargingStation } from '../../pages/charging-stations/ChargingStation';
import { GqlAssociation } from '@util/decorators/GqlAssociation';
Expand Down Expand Up @@ -42,9 +42,9 @@ export class ChangeAvailabilityRequest {
@IsOptional()
evse?: Evse | null;

@IsEnum(OperationalStatusEnumType)
@IsEnum(OCPP2_0_1.OperationalStatusEnumType)
@IsNotEmpty()
operationalStatus!: OperationalStatusEnumType;
operationalStatus!: OCPP2_0_1.OperationalStatusEnumType;

// todo
// @Type(() => CustomDataType)
Expand Down
6 changes: 3 additions & 3 deletions src/message/delete-certificate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IsOptional,
ValidateNested,
} from 'class-validator';
import { DeleteCertificateStatusEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { showError, showSucces } from '../util';
import { StatusInfoType } from '../model/StatusInfoType';
import { GenericForm } from '../../components/form';
Expand Down Expand Up @@ -47,8 +47,8 @@ class DeleteCertificateData {
}

export class DeleteCertificateResponse {
@IsEnum(DeleteCertificateStatusEnumType)
status!: DeleteCertificateStatusEnumType;
@IsEnum(OCPP2_0_1.DeleteCertificateStatusEnumType)
status!: OCPP2_0_1.DeleteCertificateStatusEnumType;

@Type(() => StatusInfoType)
@ValidateNested()
Expand Down
4 changes: 2 additions & 2 deletions src/message/get-base-report/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { GetBaseReportRequest, GetBaseReportRequestProps } from './model';
import { validateSync } from 'class-validator';
import { MessageConfirmation } from '../MessageConfirmation';
import { BaseRestClient } from '@util/BaseRestClient';
import { ReportBaseEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';

export interface GetBaseReportProps {
station: ChargingStation;
Expand Down Expand Up @@ -110,7 +110,7 @@ export const GetBaseReport: React.FC<GetBaseReportProps> = ({ station }) => {
getBaseReportRequest[GetBaseReportRequestProps.requestId] =
requestIdResponse?.data?.ChargingStationSequences[0]?.value ?? 0;
getBaseReportRequest[GetBaseReportRequestProps.reportBase] =
ReportBaseEnumType.FullInventory;
OCPP2_0_1.ReportBaseEnumType.FullInventory;

return (
<GenericForm
Expand Down
6 changes: 3 additions & 3 deletions src/message/get-base-report/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReportBaseEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { Type } from 'class-transformer';
import { IsInt, IsNotEmpty, IsEnum, IsOptional } from 'class-validator';
import { CustomDataType } from '../../model/CustomData';
Expand All @@ -14,9 +14,9 @@ export class GetBaseReportRequest {
@IsNotEmpty()
requestId!: number;

@IsEnum(ReportBaseEnumType)
@IsEnum(OCPP2_0_1.ReportBaseEnumType)
@IsNotEmpty()
reportBase!: ReportBaseEnumType;
reportBase!: OCPP2_0_1.ReportBaseEnumType;

@Type(() => CustomDataType)
@IsOptional()
Expand Down
18 changes: 10 additions & 8 deletions src/message/get-installed-certificate-ids/model.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsEnum, IsOptional, ValidateNested } from 'class-validator';
import { GetCertificateIdUseEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { Type } from 'class-transformer';
import { CustomDataType } from '../../model/CustomData';
import { CustomFormRender } from '@util/decorators/CustomFormRender';
Expand All @@ -8,7 +8,7 @@ import React from 'react';

export class GetInstalledCertificateIdsRequest {
@IsOptional()
@IsEnum(GetCertificateIdUseEnumType, { each: true })
@IsEnum(OCPP2_0_1.GetCertificateIdUseEnumType, { each: true })
@CustomFormRender(() => {
return (
<Form.Item
Expand All @@ -17,16 +17,18 @@ export class GetInstalledCertificateIdsRequest {
name="certificateType"
>
<Select mode="multiple">
{Object.entries(GetCertificateIdUseEnumType)?.map(([key, value]) => (
<Select.Option key={key} value={value}>
{value}
</Select.Option>
))}
{Object.entries(OCPP2_0_1.GetCertificateIdUseEnumType)?.map(
([key, value]) => (
<Select.Option key={key} value={value}>
{value}
</Select.Option>
),
)}
</Select>
</Form.Item>
);
})
certificateType?: GetCertificateIdUseEnumType[] | null;
certificateType?: OCPP2_0_1.GetCertificateIdUseEnumType[] | null;

@IsOptional()
@ValidateNested()
Expand Down
5 changes: 3 additions & 2 deletions src/message/get-log/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { GetLogRequest, GetLogRequestProps } from './model';
import { validateSync } from 'class-validator';
import { MessageConfirmation } from '../MessageConfirmation';
import { BaseRestClient } from '@util/BaseRestClient';
import { LogEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { CHARGING_STATION_SEQUENCES_GET_QUERY } from '../../pages/charging-station-sequences/queries';

const DIRECTUS_URL = import.meta.env.VITE_DIRECTUS_URL;
Expand Down Expand Up @@ -112,7 +112,8 @@ export const GetLog: React.FC<GetLogProps> = ({ station }) => {
getLogRequest[GetLogRequestProps.log] = {
remoteLocation: `${DIRECTUS_URL}/files`,
} as any; // Type assertion if necessary
getLogRequest[GetLogRequestProps.logType] = LogEnumType.DiagnosticsLog;
getLogRequest[GetLogRequestProps.logType] =
OCPP2_0_1.LogEnumType.DiagnosticsLog;

return (
<GenericForm
Expand Down
6 changes: 3 additions & 3 deletions src/message/get-log/model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
import { LogEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { TransformDate } from '@util/TransformDate';
import { CustomFormRender } from '@util/decorators/CustomFormRender';
import { Form, Input } from 'antd';
Expand Down Expand Up @@ -73,8 +73,8 @@ export class GetLogRequest {
@IsNotEmpty()
log!: LogParametersType;

@IsEnum(LogEnumType)
logType!: LogEnumType;
@IsEnum(OCPP2_0_1.LogEnumType)
logType!: OCPP2_0_1.LogEnumType;

@IsInt()
@IsNotEmpty()
Expand Down
14 changes: 7 additions & 7 deletions src/message/get-variables/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AttributeEnumType, GetVariableStatusEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import React, { useRef } from 'react';
import { Form } from 'antd';
import {
Expand Down Expand Up @@ -144,9 +144,9 @@ export class GetVariablesData {
@IsOptional()
evse?: Evse | null;

@IsEnum(AttributeEnumType)
@IsEnum(OCPP2_0_1.AttributeEnumType)
@IsOptional()
attributeType?: AttributeEnumType | null;
attributeType?: OCPP2_0_1.AttributeEnumType | null;
}

enum GetVariablesRequestProps {
Expand Down Expand Up @@ -177,13 +177,13 @@ export class GetVariableResultType {
@IsOptional()
attributeStatusInfo?: StatusInfoType;

@IsEnum(GetVariableStatusEnumType)
@IsEnum(OCPP2_0_1.GetVariableStatusEnumType)
@IsOptional()
attributeStatus!: GetVariableStatusEnumType;
attributeStatus!: OCPP2_0_1.GetVariableStatusEnumType;

@IsEnum(AttributeEnumType)
@IsEnum(OCPP2_0_1.AttributeEnumType)
@IsOptional()
attributeType?: AttributeEnumType;
attributeType?: OCPP2_0_1.AttributeEnumType;

@MaxLength(2500)
@IsString()
Expand Down
17 changes: 7 additions & 10 deletions src/message/install-certificate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
Length,
ValidateNested,
} from 'class-validator';
import {
InstallCertificateStatusEnumType,
InstallCertificateUseEnumType,
} from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { formatPem, showError, showSucces } from '../util';
import { StatusInfoType } from '../model/StatusInfoType';
import { GenericForm } from '../../components/form';
Expand Down Expand Up @@ -41,13 +38,13 @@ class InstallCertificateData {
@IsNotEmpty()
certificate!: string;

@IsEnum(InstallCertificateUseEnumType)
certificateType!: InstallCertificateUseEnumType;
@IsEnum(OCPP2_0_1.InstallCertificateUseEnumType)
certificateType!: OCPP2_0_1.InstallCertificateUseEnumType;
}

export class InstallCertificateResponse {
@IsEnum(InstallCertificateStatusEnumType)
status!: InstallCertificateStatusEnumType;
@IsEnum(OCPP2_0_1.InstallCertificateStatusEnumType)
status!: OCPP2_0_1.InstallCertificateStatusEnumType;

@Type(() => StatusInfoType)
@ValidateNested()
Expand All @@ -60,9 +57,9 @@ export class RootCertificateRequest {
@IsNotEmpty()
stationId!: string;

@IsEnum(InstallCertificateUseEnumType)
@IsEnum(OCPP2_0_1.InstallCertificateUseEnumType)
@IsNotEmpty()
certificateType!: InstallCertificateUseEnumType;
certificateType!: OCPP2_0_1.InstallCertificateUseEnumType;

@IsString()
@IsNotEmpty()
Expand Down
6 changes: 3 additions & 3 deletions src/message/model/ApnType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IsString,
MaxLength,
} from 'class-validator';
import { APNAuthenticationEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';

export class ApnType {
// todo
Expand Down Expand Up @@ -44,7 +44,7 @@ export class ApnType {
@IsOptional()
useOnlyPreferredNetwork?: boolean;

@IsEnum(APNAuthenticationEnumType)
@IsEnum(OCPP2_0_1.APNAuthenticationEnumType)
@IsNotEmpty()
apnAuthentication!: APNAuthenticationEnumType;
apnAuthentication!: OCPP2_0_1.APNAuthenticationEnumType;
}
18 changes: 7 additions & 11 deletions src/message/model/NetworkConnectionProfileType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import {
ValidateNested,
} from 'class-validator';
import { ApnType } from './ApnType';
import {
OCPPInterfaceEnumType,
OCPPTransportEnumType,
OCPPVersionEnumType,
} from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';
import { VpnType } from './VpnType';
import { Type } from 'class-transformer';

Expand All @@ -28,13 +24,13 @@ export class NetworkConnectionProfileType {
@IsOptional()
apn?: ApnType;

@IsEnum(OCPPVersionEnumType)
@IsEnum(OCPP2_0_1.OCPPVersionEnumType)
@IsNotEmpty()
ocppVersion!: OCPPVersionEnumType;
ocppVersion!: OCPP2_0_1.OCPPVersionEnumType;

@IsEnum(OCPPTransportEnumType)
@IsEnum(OCPP2_0_1.OCPPTransportEnumType)
@IsNotEmpty()
ocppTransport!: OCPPTransportEnumType;
ocppTransport!: OCPP2_0_1.OCPPTransportEnumType;

@MaxLength(512)
@IsUrl({ require_tld: false })
Expand All @@ -49,9 +45,9 @@ export class NetworkConnectionProfileType {
@IsNotEmpty()
securityProfile!: number;

@IsEnum(OCPPInterfaceEnumType)
@IsEnum(OCPP2_0_1.OCPPInterfaceEnumType)
@IsNotEmpty()
ocppInterface!: OCPPInterfaceEnumType;
ocppInterface!: OCPP2_0_1.OCPPInterfaceEnumType;

@Type(() => VpnType)
@ValidateNested()
Expand Down
6 changes: 3 additions & 3 deletions src/message/model/VpnType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
IsString,
MaxLength,
} from 'class-validator';
import { VPNEnumType } from '@citrineos/base';
import { OCPP2_0_1 } from '@citrineos/base';

export class VpnType {
// todo
Expand Down Expand Up @@ -39,7 +39,7 @@ export class VpnType {
@IsNotEmpty()
key!: string;

@IsEnum(VPNEnumType)
@IsEnum(OCPP2_0_1.VPNEnumType)
@IsNotEmpty()
type!: VPNEnumType;
type!: OCPP2_0_1.VPNEnumType;
}
Loading

0 comments on commit 4323175

Please sign in to comment.