mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
F OpenNebula/one#5422: Add missed features
This commit is contained in:
parent
dbb677f818
commit
185b761303
@ -10,7 +10,9 @@ export * from 'client/features/One/cluster/hooks'
|
||||
export * from 'client/features/One/datastore/hooks'
|
||||
export * from 'client/features/One/group/hooks'
|
||||
export * from 'client/features/One/host/hooks'
|
||||
export * from 'client/features/One/marketApp/hooks'
|
||||
export * from 'client/features/One/image/hooks'
|
||||
export * from 'client/features/One/marketplace/hooks'
|
||||
export * from 'client/features/One/marketplaceApp/hooks'
|
||||
export * from 'client/features/One/provider/hooks'
|
||||
export * from 'client/features/One/provision/hooks'
|
||||
export * from 'client/features/One/user/hooks'
|
||||
|
10
src/fireedge/src/client/features/One/image/actions.js
Normal file
10
src/fireedge/src/client/features/One/image/actions.js
Normal file
@ -0,0 +1,10 @@
|
||||
import { createAction } from 'client/features/One/utils'
|
||||
import { imageService } from 'client/features/One/image/services'
|
||||
|
||||
export const getImage = createAction('image', imageService.getImage)
|
||||
|
||||
export const getImages = createAction(
|
||||
'image/pool',
|
||||
imageService.getImages,
|
||||
response => ({ images: response })
|
||||
)
|
23
src/fireedge/src/client/features/One/image/hooks.js
Normal file
23
src/fireedge/src/client/features/One/image/hooks.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { useCallback } from 'react'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import { unwrapResult } from '@reduxjs/toolkit'
|
||||
|
||||
import * as actions from 'client/features/One/image/actions'
|
||||
|
||||
export const useImage = () => (
|
||||
useSelector(state => state.one.images)
|
||||
)
|
||||
|
||||
export const useImageApi = () => {
|
||||
const dispatch = useDispatch()
|
||||
|
||||
const unwrapDispatch = useCallback(
|
||||
action => dispatch(action).then(unwrapResult)
|
||||
, [dispatch]
|
||||
)
|
||||
|
||||
return {
|
||||
getImage: id => unwrapDispatch(actions.getImage({ id })),
|
||||
getImages: () => unwrapDispatch(actions.getImages())
|
||||
}
|
||||
}
|
25
src/fireedge/src/client/features/One/image/services.js
Normal file
25
src/fireedge/src/client/features/One/image/services.js
Normal file
@ -0,0 +1,25 @@
|
||||
import { Actions, Commands } from 'server/utils/constants/commands/image'
|
||||
import { httpCodes } from 'server/utils/constants'
|
||||
import { requestParams, RestClient } from 'client/utils'
|
||||
import { poolRequest } from 'client/features/One/utils'
|
||||
|
||||
export const imageService = ({
|
||||
getImage: ({ filter, id }) => {
|
||||
const name = Actions.IMAGE_INFO
|
||||
const { url, options } = requestParams(
|
||||
{ filter, id },
|
||||
{ name, ...Commands[name] }
|
||||
)
|
||||
|
||||
return RestClient.get(url, options).then(res => {
|
||||
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
|
||||
|
||||
return res?.data?.IMAGE ?? {}
|
||||
})
|
||||
},
|
||||
getImages: data => {
|
||||
const name = Actions.IMAGE_POOL_INFO
|
||||
const command = { name, ...Commands[name] }
|
||||
return poolRequest(data, command, 'IMAGE')
|
||||
}
|
||||
})
|
@ -1,10 +0,0 @@
|
||||
import { createAction } from 'client/features/One/utils'
|
||||
import { marketAppService } from 'client/features/One/marketApp/services'
|
||||
|
||||
export const getMarketApp = createAction('app', marketAppService.getMarketApp)
|
||||
|
||||
export const getMarketApps = createAction(
|
||||
'app/pool',
|
||||
marketAppService.getMarketApps,
|
||||
response => ({ apps: response })
|
||||
)
|
10
src/fireedge/src/client/features/One/marketplace/actions.js
Normal file
10
src/fireedge/src/client/features/One/marketplace/actions.js
Normal file
@ -0,0 +1,10 @@
|
||||
import { createAction } from 'client/features/One/utils'
|
||||
import { marketplaceService } from 'client/features/One/marketplace/services'
|
||||
|
||||
export const getMarketplace = createAction('marketplace', marketplaceService.getMarketplace)
|
||||
|
||||
export const getMarketplaces = createAction(
|
||||
'marketplace/pool',
|
||||
marketplaceService.getMarketplaces,
|
||||
response => ({ marketplaces: response })
|
||||
)
|
23
src/fireedge/src/client/features/One/marketplace/hooks.js
Normal file
23
src/fireedge/src/client/features/One/marketplace/hooks.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { useCallback } from 'react'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import { unwrapResult } from '@reduxjs/toolkit'
|
||||
|
||||
import * as actions from 'client/features/One/marketplace/actions'
|
||||
|
||||
export const useMarketplace = () => (
|
||||
useSelector(state => state.one.marketplaces)
|
||||
)
|
||||
|
||||
export const useMarketplaceApi = () => {
|
||||
const dispatch = useDispatch()
|
||||
|
||||
const unwrapDispatch = useCallback(
|
||||
action => dispatch(action).then(unwrapResult)
|
||||
, [dispatch]
|
||||
)
|
||||
|
||||
return {
|
||||
getMarketplace: id => unwrapDispatch(actions.getMarketplace({ id })),
|
||||
getMarketplaces: () => unwrapDispatch(actions.getMarketplaces())
|
||||
}
|
||||
}
|
25
src/fireedge/src/client/features/One/marketplace/services.js
Normal file
25
src/fireedge/src/client/features/One/marketplace/services.js
Normal file
@ -0,0 +1,25 @@
|
||||
import { Actions, Commands } from 'server/utils/constants/commands/market'
|
||||
import { httpCodes } from 'server/utils/constants'
|
||||
import { requestParams, RestClient } from 'client/utils'
|
||||
import { poolRequest } from 'client/features/One/utils'
|
||||
|
||||
export const marketplaceService = ({
|
||||
getMarketplace: ({ filter, id }) => {
|
||||
const name = Actions.MARKET_INFO
|
||||
const { url, options } = requestParams(
|
||||
{ filter, id },
|
||||
{ name, ...Commands[name] }
|
||||
)
|
||||
|
||||
return RestClient.get(url, options).then(res => {
|
||||
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
|
||||
|
||||
return res?.data?.MARKETPLACE ?? {}
|
||||
})
|
||||
},
|
||||
getMarketplaces: data => {
|
||||
const name = Actions.MARKET_POOL_INFO
|
||||
const command = { name, ...Commands[name] }
|
||||
return poolRequest(data, command, 'MARKETPLACE')
|
||||
}
|
||||
})
|
@ -0,0 +1,13 @@
|
||||
import { createAction } from 'client/features/One/utils'
|
||||
import { marketplaceAppService } from 'client/features/One/marketplaceApp/services'
|
||||
|
||||
export const getMarketplaceApp = createAction(
|
||||
'app',
|
||||
marketplaceAppService.getMarketplaceApp
|
||||
)
|
||||
|
||||
export const getMarketplaceApps = createAction(
|
||||
'app/pool',
|
||||
marketplaceAppService.getMarketplaceApps,
|
||||
response => ({ apps: response })
|
||||
)
|
@ -2,13 +2,13 @@ import { useCallback } from 'react'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import { unwrapResult } from '@reduxjs/toolkit'
|
||||
|
||||
import * as actions from 'client/features/One/marketApp/actions'
|
||||
import * as actions from 'client/features/One/marketplaceApp/actions'
|
||||
|
||||
export const useMarketApp = () => (
|
||||
export const useMarketplaceApp = () => (
|
||||
useSelector(state => state.one.apps)
|
||||
)
|
||||
|
||||
export const useMarketAppApi = () => {
|
||||
export const useMarketplaceAppApi = () => {
|
||||
const dispatch = useDispatch()
|
||||
|
||||
const unwrapDispatch = useCallback(
|
||||
@ -17,7 +17,7 @@ export const useMarketAppApi = () => {
|
||||
)
|
||||
|
||||
return {
|
||||
getMarketApp: id => unwrapDispatch(actions.getMarketApp({ id })),
|
||||
getMarketApps: () => unwrapDispatch(actions.getMarketApps())
|
||||
getMarketplaceApp: id => unwrapDispatch(actions.getMarketplaceApp({ id })),
|
||||
getMarketplaceApps: () => unwrapDispatch(actions.getMarketplaceApps())
|
||||
}
|
||||
}
|
@ -3,8 +3,8 @@ import { httpCodes } from 'server/utils/constants'
|
||||
import { requestParams, RestClient } from 'client/utils'
|
||||
import { poolRequest } from 'client/features/One/utils'
|
||||
|
||||
export const marketAppService = ({
|
||||
getMarketApp: ({ filter, id }) => {
|
||||
export const marketplaceAppService = ({
|
||||
getMarketplaceApp: ({ filter, id }) => {
|
||||
const name = Actions.MARKETAPP_INFO
|
||||
const { url, options } = requestParams(
|
||||
{ filter, id },
|
||||
@ -17,7 +17,7 @@ export const marketAppService = ({
|
||||
return res?.data?.MARKETAPP ?? {}
|
||||
})
|
||||
},
|
||||
getMarketApps: data => {
|
||||
getMarketplaceApps: data => {
|
||||
const name = Actions.MARKETAPP_POOL_INFO
|
||||
const command = { name, ...Commands[name] }
|
||||
return poolRequest(data, command, 'MARKETPLACEAPP')
|
@ -5,30 +5,30 @@ import { socketEventState } from 'client/features/One/socket/actions'
|
||||
const initial = {
|
||||
requests: {},
|
||||
|
||||
vms: [],
|
||||
templates: [],
|
||||
acl: [],
|
||||
applications: [],
|
||||
applicationsTemplates: [],
|
||||
apps: [],
|
||||
clusters: [],
|
||||
datastores: [],
|
||||
files: [],
|
||||
groups: [],
|
||||
hosts: [],
|
||||
images: [],
|
||||
marketplaces: [],
|
||||
providers: [],
|
||||
provisions: [],
|
||||
provisionsTemplates: [],
|
||||
securityGroups: [],
|
||||
templates: [],
|
||||
users: [],
|
||||
vdc: [],
|
||||
virtualRouters: [],
|
||||
vmGroups: [],
|
||||
images: [],
|
||||
files: [],
|
||||
marketplaces: [],
|
||||
apps: [],
|
||||
vms: [],
|
||||
vNetworks: [],
|
||||
vNetworksTemplates: [],
|
||||
securityGroups: [],
|
||||
clusters: [],
|
||||
hosts: [],
|
||||
zones: [],
|
||||
users: [],
|
||||
groups: [],
|
||||
vdc: [],
|
||||
acl: [],
|
||||
provisionsTemplates: [],
|
||||
providers: [],
|
||||
provisions: []
|
||||
zones: []
|
||||
}
|
||||
|
||||
const { actions, reducer } = createSlice({
|
||||
|
Loading…
x
Reference in New Issue
Block a user