Skip to content

Commit

Permalink
Merge branch 'dev/1.10.5' into enterprise
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinplemelon committed Jan 23, 2025
2 parents 2e945b9 + 877b12c commit 4d8bdf6
Show file tree
Hide file tree
Showing 31 changed files with 813 additions and 525 deletions.
11 changes: 11 additions & 0 deletions src/api/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ export const getActions = async (): Promise<Array<Action>> => {
}
}

export const getSimplifiedActions = async (): Promise<Array<Action>> => {
try {
const data = await http.get(`/actions_summary`)
return Promise.resolve(
data.map((item: Omit<Action, 'id'>) => ({ id: getBridgeKey(item as any), ...item })),
)
} catch (error) {
return Promise.reject(error)
}
}

export const postAction = async (data: Action): Promise<Action> => {
try {
const ret = await http.post(`/actions`, data)
Expand Down
18 changes: 18 additions & 0 deletions src/api/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ export const getSources = async (): Promise<Array<Source>> => {
}
}

export const getSimplifiedSources = async (): Promise<Array<Source>> => {
try {
const data = await http.get(`/sources_summary`)
return Promise.resolve(
data.map((item: Omit<Source, 'id'>) => {
const id = getBridgeKey(item as any)
return {
id,
idForRuleFrom: `${RULE_INPUT_BRIDGE_TYPE_PREFIX}${id}`,
...item,
}
}),
)
} catch (error) {
return Promise.reject(error)
}
}

export const postSource = async (source: Source): Promise<Source> => {
try {
const ret = await http.post(`/sources`, source)
Expand Down
Binary file modified src/assets/img/connections.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/live_connections.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/retained.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/shared_subscriptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/img/subs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/img/topics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/hooks/Rule/action/useActionList.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getActions } from '@/api/action'
import { getSimplifiedActions } from '@/api/action'
import { BridgeItem } from '@/types/rule'

export default (): {
getActionList: () => Promise<Array<BridgeItem>>
} => {
const getActionList = async (): Promise<Array<BridgeItem>> => {
try {
const data = await getActions()
const data = await getSimplifiedActions()
return Promise.resolve(data)
} catch (error) {
return Promise.reject(error)
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/Rule/action/useSourceList.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getSources } from '@/api/sources'
import { getSimplifiedSources } from '@/api/sources'
import { BridgeItem } from '@/types/rule'

export default (): {
getSourceList: () => Promise<Array<BridgeItem>>
} => {
const getSourceList = async () => {
try {
const sourceList: Array<BridgeItem> = await getSources()
const sourceList = await getSimplifiedSources()
return Promise.resolve(sourceList)
} catch (error) {
return Promise.reject(error)
Expand Down
19 changes: 15 additions & 4 deletions src/hooks/Rule/rule/useRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,27 @@ export const useRuleUtils = (): {
}
}

export const SourceServerType = {
MQTTBroker: BridgeType.MQTT,
Kafka: BridgeType.KafkaConsumer,
GCP: BridgeType.GCPConsumer,
RabbitMQ: BridgeType.RabbitMQ,
}

/**
* Unlike RuleInputType, the action here is specific to what type of action it is.
*/
export const RuleSourceType = {
Message: 'message',
Event: 'event',
MQTTBroker: BridgeType.MQTT,
Kafka: BridgeType.KafkaConsumer,
GCP: BridgeType.GCPConsumer,
RabbitMQ: BridgeType.RabbitMQ,
...SourceServerType,
}
export const useRuleInputs = (): {
getBridgeIdFromInput: (input: string) => string
detectInputType: (from: string) => string
isBridgeType: (type: string) => boolean
isNotBridgeSourceTypes: Array<string>
sourceServerOptList: Array<{ value: string; label: string }>
sourceOptList: Array<{ value: string; label: string }>
inputTypesIconNew: string[]
getRuleSourceIcon: (type: string) => string
Expand Down Expand Up @@ -277,6 +282,11 @@ export const useRuleInputs = (): {
return ret || specificType
}

const sourceServerOptList = Object.entries(SourceServerType).map(([, value]) => ({
value,
label: getTypeLabel(value),
}))

const sourceOptList = Object.entries(RuleSourceType).map(([, value]) => ({
value,
label: getTypeLabel(value),
Expand Down Expand Up @@ -340,6 +350,7 @@ export const useRuleInputs = (): {
detectInputType,
isBridgeType,
isNotBridgeSourceTypes,
sourceServerOptList,
sourceOptList,
inputTypesIconNew: typesIconNew,
getRuleSourceIcon,
Expand Down
28 changes: 28 additions & 0 deletions src/hooks/Rule/useActionAndSourceStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ConnectionStatus } from '@/types/enum'
import useI18nTl from '../useI18nTl'

const useActionAndSourceStatus = (): {
statusOptList: Array<{ value: ConnectionStatus; label: string }>
statusLabelMap: Record<ConnectionStatus, string>
} => {
const { t, tl } = useI18nTl('RuleEngine')
const statusLabelMap = {
[ConnectionStatus.Connected]: tl('actionAvailable'),
[ConnectionStatus.Disconnected]: tl('actionUnavailable'),
[ConnectionStatus.Connecting]: t('Base.connecting'),
[ConnectionStatus.Inconsistent]: t('Base.inconsistent'),
[ConnectionStatus.Stopped]: t('Base.stopped'),
}
const statusOptList = (Object.entries(statusLabelMap) as [ConnectionStatus, string][]).map(
([key, value]) => ({
value: key,
label: value,
}),
)
return {
statusLabelMap,
statusOptList,
}
}

export default useActionAndSourceStatus
1 change: 1 addition & 0 deletions src/hooks/Rule/useDataHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const keysDoNotNeedForAPI = [
'actions',
'id',
'rules',
'last_modified_at',
]

const keysNeedDel = {
Expand Down
19 changes: 15 additions & 4 deletions src/hooks/usePaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface PageMeta {

export interface FilterItem {
key: string
value: string
value: string | boolean
}

interface SortFrom {
Expand Down Expand Up @@ -46,14 +46,25 @@ export default (): {
chunkList()
}

const checkValue = (filterValue: string | boolean, value: any) => {
if (typeof filterValue === 'string') {
const reg = new RegExp(filterValue, 'i')
if (Array.isArray(value)) {
return value.some((item) => reg.test(item))
}
return reg.test(value)
}
return filterValue === value
}

const filterList = (filters: Array<FilterItem> = []) => {
latestFiltersString = JSON.stringify(filters)
if (filters.length === 0) {
listAfterFilter.value = totalData.value
} else {
listAfterFilter.value = totalData.value.filter((item) =>
filters.every(({ key, value }) => item[key]?.indexOf && item[key].indexOf(value) > -1),
)
listAfterFilter.value = totalData.value.filter((item) => {
return filters.every(({ key, value: filterValue }) => checkValue(filterValue, item[key]))
})
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/i18n/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,4 +699,8 @@ export default {
zh: '',
en: ' ',
},
lastModified: {
zh: '最后修改',
en: 'Last Modified',
},
}
4 changes: 4 additions & 0 deletions src/i18n/RuleEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,10 @@ It's recommended to use a template syntax, e.g., \`\${'{'}timestamp{'}'}\` or \`
zh: '关联规则',
en: 'Associated Rules',
},
viewRules: {
zh: '查看规则',
en: 'View Rules',
},
invalidGroupId: {
zh: '无效的 Group ID',
en: 'Invalid Group ID',
Expand Down
5 changes: 5 additions & 0 deletions src/style/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ p.description {
.el-date-editor {
width: 100%;
}
.col-oper {
display: flex !important;
align-items: center;
justify-content: flex-end;
}
}

.emq-table-footer {
Expand Down
6 changes: 0 additions & 6 deletions src/style/management.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
.section-header {
margin-top: 0;
}

.col-oper {
display: flex !important;
align-items: center;
justify-content: flex-end;
}
.show-more {
font-size: 18px;
cursor: pointer;
Expand Down
58 changes: 33 additions & 25 deletions src/types/schemas/actions.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2102,18 +2102,6 @@ export const BridgeMqttPublisherPostBridgeV2Type = {
mqtt: 'mqtt',
} as const

export interface BridgeMqttPublisherPostBridgeV2 {
type: BridgeMqttPublisherPostBridgeV2Type
name: string
local_topic?: string
parameters: BridgeMqttPublisherActionParameters
enable?: boolean
connector: string
tags?: string[]
description?: string
resource_opts?: BridgeMqttPublisherActionResourceOpts
}

export type BridgeMqttPublisherGetBridgeV2Status =
typeof BridgeMqttPublisherGetBridgeV2Status[keyof typeof BridgeMqttPublisherGetBridgeV2Status]

Expand Down Expand Up @@ -2770,8 +2758,19 @@ export interface BridgeHttpPutBridgeV2 {
connector: string
tags?: string[]
description?: string
parameters: BridgeHttpParametersOpts
resource_opts?: BridgeHttpActionResourceOpts
resource_opts?: BridgeMqttPublisherActionResourceOpts
}

export interface BridgeMqttPublisherPostBridgeV2 {
type: BridgeMqttPublisherPostBridgeV2Type
name: string
local_topic?: string
parameters: BridgeMqttPublisherActionParameters
enable?: boolean
connector: string
tags?: string[]
description?: string
resource_opts?: BridgeMqttPublisherActionResourceOpts
}

export type BridgeHttpPostBridgeV2Type =
Expand All @@ -2782,17 +2781,6 @@ export const BridgeHttpPostBridgeV2Type = {
http: 'http',
} as const

export interface BridgeHttpPostBridgeV2 {
type: BridgeHttpPostBridgeV2Type
name: string
enable?: boolean
connector: string
tags?: string[]
description?: string
parameters: BridgeHttpParametersOpts
resource_opts?: BridgeHttpActionResourceOpts
}

export type BridgeHttpParametersOptsHeaders = { [key: string]: any }

export type BridgeHttpParametersOptsMethod =
Expand All @@ -2816,6 +2804,26 @@ export interface BridgeHttpParametersOpts {
request_timeout?: string
}

export interface BridgeHttpPutBridgeV2 {
enable?: boolean
connector: string
tags?: string[]
description?: string
parameters: BridgeHttpParametersOpts
resource_opts?: BridgeHttpActionResourceOpts
}

export interface BridgeHttpPostBridgeV2 {
type: BridgeHttpPostBridgeV2Type
name: string
enable?: boolean
connector: string
tags?: string[]
description?: string
parameters: BridgeHttpParametersOpts
resource_opts?: BridgeHttpActionResourceOpts
}

export type BridgeHttpGetBridgeV2Type =
typeof BridgeHttpGetBridgeV2Type[keyof typeof BridgeHttpGetBridgeV2Type]

Expand Down
6 changes: 6 additions & 0 deletions src/types/schemas/authorization.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ export interface AuthzMongoSingle {
enable?: boolean
collection: string
filter?: AuthzMongoSingleFilter
limit?: number
skip?: number
mongo_type: AuthzMongoSingleMongoType
server: string
w_mode?: AuthzMongoSingleWMode
Expand Down Expand Up @@ -999,6 +1001,8 @@ export interface AuthzMongoSharded {
enable?: boolean
collection: string
filter?: AuthzMongoShardedFilter
limit?: number
skip?: number
mongo_type: AuthzMongoShardedMongoType
servers: string
w_mode?: AuthzMongoShardedWMode
Expand Down Expand Up @@ -1060,6 +1064,8 @@ export interface AuthzMongoRs {
enable?: boolean
collection: string
filter?: AuthzMongoRsFilter
limit?: number
skip?: number
mongo_type: AuthzMongoRsMongoType
servers: string
w_mode?: AuthzMongoRsWMode
Expand Down
2 changes: 1 addition & 1 deletion src/types/schemas/gateways.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ export type EmqxGatewayApiGatewayNodeStatusNode =

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const EmqxGatewayApiGatewayNodeStatusNode = {
'emqx@127001': 'emqx@127.0.0.1',
'emqx@1721702': 'emqx@172.17.0.2',
} as const

export interface EmqxGatewayApiGatewayNodeStatus {
Expand Down
1 change: 1 addition & 0 deletions src/types/schemas/retainer.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export interface RetainerRetainer {
max_payload_size?: string
stop_publish_clear_msg?: boolean
delivery_rate?: string
max_publish_rate?: string
backend?: RetainerMnesiaConfig
}

Expand Down
Loading

0 comments on commit 4d8bdf6

Please sign in to comment.