Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync code from refs/heads/dev/1.10.5 to enterprise #3175

Open
wants to merge 10 commits into
base: enterprise
Choose a base branch
from
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
13 changes: 12 additions & 1 deletion src/hooks/Rule/rule/useRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,24 @@ export const useRuleUtils = (): {
}
}

export const SourceServerType = {
MQTTBroker: BridgeType.MQTT,
}

/**
* Unlike RuleInputType, the action here is specific to what type of action it is.
*/
export const RuleSourceType = {
Message: 'message',
Event: 'event',
MQTTBroker: BridgeType.MQTT,
...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 }>
getRuleSourceIcon: (type: string) => string
} => {
Expand Down Expand Up @@ -272,6 +277,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 @@ -335,6 +345,7 @@ export const useRuleInputs = (): {
detectInputType,
isBridgeType,
isNotBridgeSourceTypes,
sourceServerOptList,
sourceOptList,
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
16 changes: 12 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,22 @@ export default (): {
chunkList()
}

const checkValue = (filterValue: string | boolean, value: any) => {
if (typeof filterValue === 'string') {
const reg = new RegExp(filterValue, 'i')
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 @@ -643,4 +643,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 @@ -1089,6 +1089,10 @@ export default {
zh: '关联规则',
en: 'Associated Rules',
},
viewRules: {
zh: '查看规则',
en: 'View Rules',
},
directDispatch: {
zh: '直接派发',
en: 'Direct Dispatch',
Expand Down
5 changes: 5 additions & 0 deletions src/style/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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 @@ -5,12 +5,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
89 changes: 53 additions & 36 deletions src/types/schemas/actions.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,6 @@ export interface BridgeNodeMetrics {
metrics?: BridgeMetrics
}

export interface BridgeMqttPublisherPutBridgeV2 {
local_topic?: string
parameters: BridgeMqttPublisherActionParameters
enable?: boolean
connector: string
tags?: string[]
description?: string
resource_opts?: BridgeMqttPublisherActionResourceOpts
}

export type BridgeMqttPublisherPostBridgeV2Type =
typeof BridgeMqttPublisherPostBridgeV2Type[keyof typeof BridgeMqttPublisherPostBridgeV2Type]

Expand All @@ -356,18 +346,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 @@ -433,13 +411,26 @@ export interface BridgeMqttPublisherActionParameters {
payload?: string
}

export interface BridgeHttpPutBridgeV2 {
export interface BridgeMqttPublisherPutBridgeV2 {
local_topic?: string
parameters: BridgeMqttPublisherActionParameters
enable?: boolean
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 @@ -450,17 +441,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 @@ -484,6 +464,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 Expand Up @@ -536,3 +536,20 @@ export interface BridgeHttpActionResourceOpts {
inflight_window?: number
max_buffer_bytes?: string
}

export interface ActionsAndSourcesResponseNodeStatus {
node?: string
status?: string
status_reason?: string
}

export interface ActionsAndSourcesResponseSummary {
enabled?: boolean
name?: string
type?: string
last_modified_at?: number
node_status?: ActionsAndSourcesResponseNodeStatus[]
rules?: string[]
status?: string
status_reason?: string
}
6 changes: 6 additions & 0 deletions src/types/schemas/authorization.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,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 @@ -974,6 +976,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 @@ -1035,6 +1039,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 @@ -686,7 +686,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
Loading