Skip to content

Commit

Permalink
feat(south): south items repository
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerni10 authored and burgerni10 committed Jun 21, 2023
1 parent c95f95f commit de6819c
Show file tree
Hide file tree
Showing 28 changed files with 1,654 additions and 164 deletions.
18 changes: 9 additions & 9 deletions backend/engine/base-engine.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,39 +98,39 @@ describe('BaseEngine', () => {
const southList = engine.getSouthList()
const expectedResult = [
{
category: 'DatabaseOut',
category: 'database',
connectorName: 'SQL',
},
{
category: 'FileOut',
category: 'file',
connectorName: 'FolderScanner',
},
{
category: 'IoT',
category: 'iot',
connectorName: 'OPCUA_HA',
},
{
category: 'IoT',
category: 'iot',
connectorName: 'OPCUA_DA',
},
{
category: 'IoT',
category: 'iot',
connectorName: 'MQTT',
},
{
category: 'IoT',
category: 'iot',
connectorName: 'ADS',
},
{
category: 'IoT',
category: 'iot',
connectorName: 'Modbus',
},
{
category: 'IoT',
category: 'iot',
connectorName: 'OPCHDA',
},
{
category: 'API',
category: 'api',
connectorName: 'RestApi',
},
]
Expand Down
4 changes: 2 additions & 2 deletions backend/frontend/context/config-context.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { ConfigProvider, reducer } from './config-context.jsx'
global.fetch = jest.fn().mockImplementation((uri) => {
let jsonString
switch (uri) {
case '/api/installed-north':
case '/legacy/installed-north':
jsonString = JSON.stringify(['a', 'b', 'c'])
break
case '/api/installed-south':
case '/legacy/installed-south':
jsonString = JSON.stringify(['d', 'e', 'f'])
break
case '/config':
Expand Down
8 changes: 4 additions & 4 deletions backend/frontend/service/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ const getLogs = (fromDate, toDate, pageNumber, verbosity, filter, scope) => getR
`/logs?fromDate=${fromDate || ''}&toDate=${toDate || ''}&pageNumber=${pageNumber}&verbosity=[${verbosity}]&textMessage=${filter}&scope=${scope}`,
)
const getOIBusInfo = () => getRequest('/info')
const getSouthTypes = () => getRequest('/api/installed-south')
const getNorthTypes = () => getRequest('/api/installed-north')
const getSouth = async (id) => getRequest(`/api/south/${id}`)
const getNorth = async (id) => getRequest(`/api/north/${id}`)
const getSouthTypes = () => getRequest('/legacy/installed-south')
const getNorthTypes = () => getRequest('/legacy/installed-north')
const getSouth = async (id) => getRequest(`/legacy/south/${id}`)
const getNorth = async (id) => getRequest(`/legacy/north/${id}`)
const getSouthStatus = (id) => getRequest(`/south/${id}/status`)
const getNorthStatus = (id) => getRequest(`/north/${id}/status`)
const reload = () => getRequest('/reload')
Expand Down
4 changes: 2 additions & 2 deletions backend/frontend/service/apis.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const logSample = {
global.fetch = jest.fn().mockImplementation((uri) => {
let jsonString
switch (uri) {
case '/api/installed-north':
case '/legacy/installed-north':
jsonString = JSON.stringify(['a', 'b', 'c'])
break
case '/api/installed-south':
case '/legacy/installed-south':
jsonString = JSON.stringify(['d', 'e', 'f'])
break
case '/config':
Expand Down
21 changes: 17 additions & 4 deletions backend/model/engine.model.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
export const AUTHENTICATION_TYPES = ["none", "basic", "bearer", "api-key"];
export type AuthenticationType = typeof AUTHENTICATION_TYPES[number];

interface Authentication {
type: "basic" | "bearer" | "api-key";
type: AuthenticationType;
key: string;
secret: string;
}

export const LOG_LEVELS = [
"silent",
"error",
"warning",
"info",
"debug",
"trace",
];
export type LogLevel = typeof LOG_LEVELS[number];

/**
* Base settings for log parameters
*/
interface BaseLogSettings {
level: "silent" | "error" | "warning" | "info" | "debug" | "trace";
level: LogLevel;
}

/**
Expand Down Expand Up @@ -40,7 +53,7 @@ interface LokiLogSettings extends BaseLogSettings {
tokenAddress: string;
username: string;
password: string;
proxyId: string;
proxyId: string | null;
}

/**
Expand Down Expand Up @@ -69,7 +82,7 @@ interface HealthSignalHTTPDTO {
interval: number;
verbose: boolean;
address: string;
proxyId: string;
proxyId: string | null;
authentication: Authentication;
}

Expand Down
20 changes: 15 additions & 5 deletions backend/model/south-connector.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export interface SouthType {
category: string;
type: string;
description: string;
}

/**
* DTO for South connectors
*/
Expand All @@ -22,9 +28,9 @@ export interface SouthConnectorCommandDTO {
}

/**
* DTO used for South scan (a point/query/regexp and its settings linked to a scan mode)
* DTO used for South item (a point/query/regexp and its settings linked to a scan mode)
*/
export interface SouthScanDTO {
export interface SouthItemDTO {
id: string;
name: string;
southId: string;
Expand All @@ -33,11 +39,15 @@ export interface SouthScanDTO {
}

/**
* Command DTO used for South scan (a point/query/folder and its settings linked to a scan mode)
* Command DTO used for South item (a point/query/folder and its settings linked to a scan mode)
*/
export interface SouthScanCommandDTO {
southId: string;
export interface SouthItemCommandDTO {
name: string;
settings: object;
scanModeId: string;
}

export interface SouthItemSearchParam {
page: number | null;
name: string | null;
}
145 changes: 145 additions & 0 deletions backend/model/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
export type Instant = string;

export const Timezones = [
"Etc/UTC",
"Etc/GMT+12",
"Pacific/Midway",
"Pacific/Honolulu",
"Pacific/Marquesas",
"America/Anchorage",
"Pacific/Pitcairn",
"America/Los_Angeles",
"America/Tijuana",
"America/Chihuahua",
"America/Denver",
"America/Phoenix",
"America/Chicago",
"America/Guatemala",
"America/Mexico_City",
"America/Regina",
"America/Bogota",
"America/Indiana/Indianapolis",
"America/New_York",
"America/Caracas",
"America/Guyana",
"America/Halifax",
"America/La_Paz",
"America/Manaus",
"America/Santiago",
"America/St_Johns",
"America/Argentina/Buenos_Aires",
"America/Godthab",
"America/Montevideo",
"America/Sao_Paulo",
"Atlantic/South_Georgia",
"Atlantic/Azores",
"Atlantic/Cape_Verde",
"Africa/Casablanca",
"Africa/Monrovia",
"Europe/London",
"Africa/Algiers",
"Africa/Windhoek",
"Europe/Belgrade",
"Europe/Berlin",
"Europe/Brussels",
"Europe/Warsaw",
"Africa/Cairo",
"Africa/Harare",
"Asia/Amman",
"Asia/Beirut",
"Asia/Jerusalem",
"Europe/Athens",
"Europe/Helsinki",
"Europe/Minsk",
"Europe/Paris",
"Africa/Nairobi",
"Asia/Baghdad",
"Asia/Kuwait",
"Europe/Moscow",
"Asia/Tehran",
"Asia/Baku",
"Asia/Muscat",
"Asia/Tbilisi",
"Asia/Yerevan",
"Asia/Kabul",
"Asia/Karachi",
"Asia/Tashkent",
"Asia/Yekaterinburg",
"Asia/Colombo",
"Asia/Kolkata",
"Asia/Kathmandu",
"Asia/Dhaka",
"Asia/Novosibirsk",
"Asia/Rangoon",
"Asia/Bangkok",
"Asia/Krasnoyarsk",
"Asia/Hong_Kong",
"Asia/Irkutsk",
"Asia/Kuala_Lumpur",
"Asia/Taipei",
"Australia/Perth",
"Asia/Seoul",
"Asia/Tokyo",
"Asia/Yakutsk",
"Australia/Adelaide",
"Australia/Darwin",
"Asia/Vladivostok",
"Australia/Brisbane",
"Australia/Hobart",
"Australia/Sydney",
"Pacific/Guam",
"Australia/Lord_Howe",
"Asia/Magadan",
"Pacific/Norfolk",
"Pacific/Auckland",
"Pacific/Fiji",
"Pacific/Tongatapu",
];

export interface Page<T> {
/**
* The content of the page
*/
content: Array<T>;
/**
* The total number of elements
*/
totalElements: number;

/**
* The size of the page, i.e. the max size of the array of elements
*/
size: number;

/**
* The number of the page, starting at 0
*/
number: number;

/**
* The total number of pages (which can be 0)
*/
totalPages: number;
}

export function createPageFromArray<T>(
allElements: Array<T>,
pageSize: number,
pageNumber: number
): Page<T> {
return {
content: allElements.slice(
pageNumber * pageSize,
(pageNumber + 1) * pageSize
),
number: pageNumber,
size: pageSize,
totalElements: allElements.length,
totalPages: Math.ceil(allElements.length / pageSize),
};
}

export interface Interval {
start: Instant;
end: Instant;
}
Loading

0 comments on commit de6819c

Please sign in to comment.