-
- {NAME}
-
+ {NAME}
-
- {`#${ID}`}
-
+ {`#${ID}`}
{` ${TOTAL_USERS}`}
@@ -51,7 +47,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/Hosts/columns.js b/src/fireedge/src/client/components/Tables/Hosts/columns.js
index 62b2c88a4a..e9c70b6040 100644
--- a/src/fireedge/src/client/components/Tables/Hosts/columns.js
+++ b/src/fireedge/src/client/components/Tables/Hosts/columns.js
@@ -17,65 +17,69 @@
import { CategoryFilter } from 'client/components/Tables/Enhanced/Utils'
import * as HostModel from 'client/models/Host'
-const getTotalOfResources = resources => [resources?.ID ?? []].flat().length || 0
+const getTotalOfResources = (resources) =>
+ [resources?.ID ?? []].flat().length || 0
export default [
{ Header: 'ID', accessor: 'ID', sortType: 'number' },
{
Header: 'Name',
id: 'NAME',
- accessor: row => row?.TEMPLATE?.NAME ?? row.NAME
+ accessor: (row) => row?.TEMPLATE?.NAME ?? row.NAME,
},
{
Header: 'State',
id: 'STATE',
- accessor: row => HostModel.getState(row)?.name,
+ accessor: (row) => HostModel.getState(row)?.name,
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'State'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'State',
+ }),
+ filter: 'includesValue',
},
{ Header: 'Cluster', accessor: 'CLUSTER' },
{
Header: 'IM MAD',
accessor: 'IM_MAD',
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'IM Mad'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'IM Mad',
+ }),
+ filter: 'includesValue',
},
{
Header: 'VM MAD',
accessor: 'VM_MAD',
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'VM Mad'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'VM Mad',
+ }),
+ filter: 'includesValue',
},
{
Header: 'Running VMs',
id: 'RUNNING_VMS',
accessor: 'HOST_SHARE.RUNNING_VMS',
- sortType: 'number'
+ sortType: 'number',
},
{
Header: 'Total VMs',
id: 'TOTAL_VMS',
- accessor: row => getTotalOfResources(row?.VMS),
- sortType: 'number'
+ accessor: (row) => getTotalOfResources(row?.VMS),
+ sortType: 'number',
},
{
Header: 'Host Share',
accessor: 'HOST_SHARE',
- disableSortBy: true
- }
+ disableSortBy: true,
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/Hosts/index.js b/src/fireedge/src/client/components/Tables/Hosts/index.js
index 19857f7c9d..048fdd45fc 100644
--- a/src/fireedge/src/client/components/Tables/Hosts/index.js
+++ b/src/fireedge/src/client/components/Tables/Hosts/index.js
@@ -20,26 +20,37 @@ import { useAuth } from 'client/features/Auth'
import { useFetch } from 'client/hooks'
import { useHost, useHostApi } from 'client/features/One'
-import { SkeletonTable, EnhancedTable, EnhancedTableProps } from 'client/components/Tables'
+import {
+ SkeletonTable,
+ EnhancedTable,
+ EnhancedTableProps,
+} from 'client/components/Tables'
import { createColumns } from 'client/components/Tables/Enhanced/Utils'
import HostColumns from 'client/components/Tables/Hosts/columns'
import HostRow from 'client/components/Tables/Hosts/row'
-const HostsTable = props => {
+const HostsTable = (props) => {
const { view, getResourceView, filterPool } = useAuth()
- const columns = useMemo(() => createColumns({
- filters: getResourceView('HOST')?.filters,
- columns: HostColumns
- }), [view])
+ const columns = useMemo(
+ () =>
+ createColumns({
+ filters: getResourceView('HOST')?.filters,
+ columns: HostColumns,
+ }),
+ [view]
+ )
const hosts = useHost()
const { getHosts } = useHostApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getHosts)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getHosts)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [filterPool])
+ useEffect(() => {
+ fetchRequest()
+ }, [filterPool])
if (hosts?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -50,7 +61,7 @@ const HostsTable = props => {
columns={columns}
data={hosts}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={HostRow}
{...props}
/>
diff --git a/src/fireedge/src/client/components/Tables/Hosts/row.js b/src/fireedge/src/client/components/Tables/Hosts/row.js
index e76ea7d840..f9a9384ddb 100644
--- a/src/fireedge/src/client/components/Tables/Hosts/row.js
+++ b/src/fireedge/src/client/components/Tables/Hosts/row.js
@@ -19,7 +19,11 @@ import PropTypes from 'prop-types'
import { Server, ModernTv } from 'iconoir-react'
import { Typography } from '@mui/material'
-import { StatusCircle, LinearProgressWithLabel, StatusChip } from 'client/components/Status'
+import {
+ StatusCircle,
+ LinearProgressWithLabel,
+ StatusChip,
+} from 'client/components/Status'
import { rowStyles } from 'client/components/Tables/styles'
import { Tr } from 'client/components/HOC'
@@ -29,16 +33,18 @@ import { T } from 'client/constants'
const Row = ({ original, value, ...props }) => {
const classes = rowStyles()
const {
- ID, NAME, IM_MAD, VM_MAD, RUNNING_VMS,
- TOTAL_VMS, CLUSTER, TEMPLATE
+ ID,
+ NAME,
+ IM_MAD,
+ VM_MAD,
+ RUNNING_VMS,
+ TOTAL_VMS,
+ CLUSTER,
+ TEMPLATE,
} = value
- const {
- percentCpuUsed,
- percentCpuLabel,
- percentMemUsed,
- percentMemLabel
- } = HostModel.getAllocatedInfo(value)
+ const { percentCpuUsed, percentCpuLabel, percentMemUsed, percentMemLabel } =
+ HostModel.getAllocatedInfo(value)
const { color: stateColor, name: stateName } = HostModel.getState(original)
@@ -51,11 +57,11 @@ const Row = ({ original, value, ...props }) => {
-
+
{TEMPLATE?.NAME ?? NAME}
- {labels.map(label => (
+ {labels.map((label) => (
))}
@@ -92,7 +98,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/Images/columns.js b/src/fireedge/src/client/components/Tables/Images/columns.js
index 349dee6039..7a6afa4d6a 100644
--- a/src/fireedge/src/client/components/Tables/Images/columns.js
+++ b/src/fireedge/src/client/components/Tables/Images/columns.js
@@ -17,7 +17,8 @@
import { CategoryFilter } from 'client/components/Tables/Enhanced/Utils'
import * as ImageModel from 'client/models/Image'
-const getTotalOfResources = resources => [resources?.ID ?? []].flat().length || 0
+const getTotalOfResources = (resources) =>
+ [resources?.ID ?? []].flat().length || 0
export default [
{ Header: 'ID', accessor: 'ID', sortType: 'number' },
@@ -27,24 +28,25 @@ export default [
{
Header: 'State',
id: 'STATE',
- accessor: row => ImageModel.getState(row)?.name,
+ accessor: (row) => ImageModel.getState(row)?.name,
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'State'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'State',
+ }),
+ filter: 'includesValue',
},
{
Header: 'Type',
id: 'TYPE',
- accessor: row => ImageModel.getType(row)
+ accessor: (row) => ImageModel.getType(row),
},
{
Header: 'Disk Type',
id: 'DISK_TYPE',
- accessor: row => ImageModel.getDiskType(row)
+ accessor: (row) => ImageModel.getDiskType(row),
},
{ Header: 'Registration Time', accessor: 'REGTIME' },
{ Header: 'Datastore', accessor: 'DATASTORE' },
@@ -52,12 +54,12 @@ export default [
{
Header: 'Running VMs',
accessor: 'RUNNING_VMS',
- sortType: 'number'
+ sortType: 'number',
},
{
Header: 'Total VMs',
id: 'TOTAL_VMS',
- accessor: row => getTotalOfResources(row?.VMS),
- sortType: 'number'
- }
+ accessor: (row) => getTotalOfResources(row?.VMS),
+ sortType: 'number',
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/Images/detail.js b/src/fireedge/src/client/components/Tables/Images/detail.js
index 16d9a0c4ba..1a060e0bc6 100644
--- a/src/fireedge/src/client/components/Tables/Images/detail.js
+++ b/src/fireedge/src/client/components/Tables/Images/detail.js
@@ -42,14 +42,26 @@ const ImageDetail = ({ id }) => {
}, [id])
if (isLoading) {
- return
+ return
}
if (error) {
return {error}
}
- const { ID, NAME, UNAME, GNAME, REGTIME, SIZE, PERSISTENT, LOCK, DATASTORE, VMS, RUNNING_VMS } = data
+ const {
+ ID,
+ NAME,
+ UNAME,
+ GNAME,
+ REGTIME,
+ SIZE,
+ PERSISTENT,
+ LOCK,
+ DATASTORE,
+ VMS,
+ RUNNING_VMS,
+ } = data
const { name: stateName, color: stateColor } = ImageModel.getState(data)
const type = ImageModel.getType(data)
@@ -66,11 +78,9 @@ const ImageDetail = ({ id }) => {
-
- {`#${ID} - ${NAME}`}
-
+ {`#${ID} - ${NAME}`}
Owner: {UNAME}
@@ -84,17 +94,15 @@ const ImageDetail = ({ id }) => {
Running VMS: {` ${RUNNING_VMS} / ${usedByVms}`}
- )
- }
+ ),
+ },
]
- return (
-
- )
+ return
}
ImageDetail.propTypes = {
- id: PropTypes.string.isRequired
+ id: PropTypes.string.isRequired,
}
export default ImageDetail
diff --git a/src/fireedge/src/client/components/Tables/Images/index.js b/src/fireedge/src/client/components/Tables/Images/index.js
index c785fececb..acd5651663 100644
--- a/src/fireedge/src/client/components/Tables/Images/index.js
+++ b/src/fireedge/src/client/components/Tables/Images/index.js
@@ -20,21 +20,28 @@ import { useAuth } from 'client/features/Auth'
import { useFetch } from 'client/hooks'
import { useImage, useImageApi } from 'client/features/One'
-import { SkeletonTable, EnhancedTable, EnhancedTableProps } from 'client/components/Tables'
+import {
+ SkeletonTable,
+ EnhancedTable,
+ EnhancedTableProps,
+} from 'client/components/Tables'
import ImageColumns from 'client/components/Tables/Images/columns'
import ImageRow from 'client/components/Tables/Images/row'
-const ImagesTable = props => {
+const ImagesTable = (props) => {
const columns = useMemo(() => ImageColumns, [])
const images = useImage()
const { getImages } = useImageApi()
const { filterPool } = useAuth()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getImages)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getImages)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [filterPool])
+ useEffect(() => {
+ fetchRequest()
+ }, [filterPool])
if (images?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -45,7 +52,7 @@ const ImagesTable = props => {
columns={columns}
data={images}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={ImageRow}
{...props}
/>
diff --git a/src/fireedge/src/client/components/Tables/Images/row.js b/src/fireedge/src/client/components/Tables/Images/row.js
index 4257b50f94..cca86eea1e 100644
--- a/src/fireedge/src/client/components/Tables/Images/row.js
+++ b/src/fireedge/src/client/components/Tables/Images/row.js
@@ -28,13 +28,23 @@ import * as Helper from 'client/models/Helper'
const Row = ({ original, value, ...props }) => {
const classes = rowStyles()
const {
- ID, NAME, UNAME, GNAME, REGTIME, TYPE,
- DISK_TYPE, PERSISTENT, LOCK, DATASTORE,
- TOTAL_VMS, RUNNING_VMS
+ ID,
+ NAME,
+ UNAME,
+ GNAME,
+ REGTIME,
+ TYPE,
+ DISK_TYPE,
+ PERSISTENT,
+ LOCK,
+ DATASTORE,
+ TOTAL_VMS,
+ RUNNING_VMS,
} = value
- const labels = [...new Set([
- PERSISTENT && 'PERSISTENT', TYPE, DISK_TYPE])].filter(Boolean)
+ const labels = [
+ ...new Set([PERSISTENT && 'PERSISTENT', TYPE, DISK_TYPE]),
+ ].filter(Boolean)
const { color: stateColor, name: stateName } = ImageModel.getState(original)
@@ -48,20 +58,16 @@ const Row = ({ original, value, ...props }) => {
-
- {NAME}
-
+ {NAME}
{LOCK && }
- {labels.map(label => (
+ {labels.map((label) => (
))}
-
- {`#${ID} ${timeAgo}`}
-
+ {`#${ID} ${timeAgo}`}
{` ${UNAME}`}
@@ -89,7 +95,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/MarketplaceApps/actions.js b/src/fireedge/src/client/components/Tables/MarketplaceApps/actions.js
index ef08e28f50..1660913499 100644
--- a/src/fireedge/src/client/components/Tables/MarketplaceApps/actions.js
+++ b/src/fireedge/src/client/components/Tables/MarketplaceApps/actions.js
@@ -16,11 +16,7 @@
/* eslint-disable jsdoc/require-jsdoc */
import { useMemo } from 'react'
import { useHistory } from 'react-router-dom'
-import {
- RefreshDouble,
- AddSquare,
- CloudDownload
-} from 'iconoir-react'
+import { RefreshDouble, AddSquare, CloudDownload } from 'iconoir-react'
import { useAuth } from 'client/features/Auth'
import { useGeneralApi } from 'client/features/General'
@@ -33,7 +29,7 @@ import { createActions } from 'client/components/Tables/Enhanced/Utils'
import { PATH } from 'client/apps/sunstone/routesOne'
import { T, MARKETPLACE_APP_ACTIONS } from 'client/constants'
-const MessageToConfirmAction = rows => {
+const MessageToConfirmAction = (rows) => {
const names = rows?.map?.(({ original }) => original?.NAME)
return (
@@ -57,45 +53,52 @@ const Actions = () => {
const { enqueueSuccess } = useGeneralApi()
const { getMarketplaceApps, exportApp } = useMarketplaceAppApi()
- const marketplaceAppActions = useMemo(() => createActions({
- filters: getResourceView('MARKETPLACE-APP')?.actions,
- actions: [
- {
- accessor: MARKETPLACE_APP_ACTIONS.REFRESH,
- tooltip: T.Refresh,
- icon: RefreshDouble,
- action: async () => {
- await getMarketplaceApps()
- }
- },
- {
- accessor: MARKETPLACE_APP_ACTIONS.CREATE_DIALOG,
- tooltip: T.CreateMarketApp,
- icon: AddSquare,
- action: () => {
- history.push(PATH.STORAGE.MARKETPLACE_APPS.CREATE)
- }
- },
- {
- accessor: MARKETPLACE_APP_ACTIONS.EXPORT,
- tooltip: T.ImportIntoDatastore,
- selected: { max: 1 },
- icon: CloudDownload,
- options: [{
- dialogProps: { title: T.DownloadAppToOpenNebula },
- form: rows => {
- const app = rows?.map(({ original }) => original)[0]
- return ExportForm(app, app)
+ const marketplaceAppActions = useMemo(
+ () =>
+ createActions({
+ filters: getResourceView('MARKETPLACE-APP')?.actions,
+ actions: [
+ {
+ accessor: MARKETPLACE_APP_ACTIONS.REFRESH,
+ tooltip: T.Refresh,
+ icon: RefreshDouble,
+ action: async () => {
+ await getMarketplaceApps()
+ },
},
- onSubmit: async (formData, rows) => {
- const appId = rows?.[0]?.original?.ID
- const response = await exportApp(appId, formData)
- enqueueSuccess(response)
- }
- }]
- }
- ]
- }), [view])
+ {
+ accessor: MARKETPLACE_APP_ACTIONS.CREATE_DIALOG,
+ tooltip: T.CreateMarketApp,
+ icon: AddSquare,
+ action: () => {
+ history.push(PATH.STORAGE.MARKETPLACE_APPS.CREATE)
+ },
+ },
+ {
+ accessor: MARKETPLACE_APP_ACTIONS.EXPORT,
+ tooltip: T.ImportIntoDatastore,
+ selected: { max: 1 },
+ icon: CloudDownload,
+ options: [
+ {
+ dialogProps: { title: T.DownloadAppToOpenNebula },
+ form: (rows) => {
+ const app = rows?.map(({ original }) => original)[0]
+
+ return ExportForm(app, app)
+ },
+ onSubmit: async (formData, rows) => {
+ const appId = rows?.[0]?.original?.ID
+ const response = await exportApp(appId, formData)
+ enqueueSuccess(response)
+ },
+ },
+ ],
+ },
+ ],
+ }),
+ [view]
+ )
return marketplaceAppActions
}
diff --git a/src/fireedge/src/client/components/Tables/MarketplaceApps/columns.js b/src/fireedge/src/client/components/Tables/MarketplaceApps/columns.js
index b904230519..e7b85aae42 100644
--- a/src/fireedge/src/client/components/Tables/MarketplaceApps/columns.js
+++ b/src/fireedge/src/client/components/Tables/MarketplaceApps/columns.js
@@ -25,26 +25,28 @@ export default [
{
Header: 'State',
id: 'STATE',
- accessor: row => MarketplaceAppModel.getState(row)?.name,
+ accessor: (row) => MarketplaceAppModel.getState(row)?.name,
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'State'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'State',
+ }),
+ filter: 'includesValue',
},
{
Header: 'Type',
id: 'TYPE',
- accessor: row => MarketplaceAppModel.getType(row),
+ accessor: (row) => MarketplaceAppModel.getType(row),
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'Type'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'Type',
+ }),
+ filter: 'includesValue',
},
{ Header: 'Size', accessor: 'SIZE' },
{ Header: 'Registration Time', accessor: 'REGTIME' },
@@ -52,12 +54,13 @@ export default [
Header: 'Marketplace',
accessor: 'MARKETPLACE',
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'Marketplace'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'Marketplace',
+ }),
+ filter: 'includesValue',
},
- { Header: 'Zone ID', accessor: 'ZONE_ID' }
+ { Header: 'Zone ID', accessor: 'ZONE_ID' },
]
diff --git a/src/fireedge/src/client/components/Tables/MarketplaceApps/index.js b/src/fireedge/src/client/components/Tables/MarketplaceApps/index.js
index 74331ba757..b34f1fe5e0 100644
--- a/src/fireedge/src/client/components/Tables/MarketplaceApps/index.js
+++ b/src/fireedge/src/client/components/Tables/MarketplaceApps/index.js
@@ -25,21 +25,28 @@ import { createColumns } from 'client/components/Tables/Enhanced/Utils'
import MarketplaceAppColumns from 'client/components/Tables/MarketplaceApps/columns'
import MarketplaceAppRow from 'client/components/Tables/MarketplaceApps/row'
-const MarketplaceAppsTable = props => {
+const MarketplaceAppsTable = (props) => {
const { view, getResourceView, filterPool } = useAuth()
- const columns = useMemo(() => createColumns({
- filters: getResourceView('MARKETPLACE-APP')?.filters,
- columns: MarketplaceAppColumns
- }), [view])
+ const columns = useMemo(
+ () =>
+ createColumns({
+ filters: getResourceView('MARKETPLACE-APP')?.filters,
+ columns: MarketplaceAppColumns,
+ }),
+ [view]
+ )
const marketplaceApps = useMarketplaceApp()
const { getMarketplaceApps } = useMarketplaceAppApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getMarketplaceApps)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getMarketplaceApps)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [filterPool])
+ useEffect(() => {
+ fetchRequest()
+ }, [filterPool])
if (marketplaceApps?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -50,7 +57,7 @@ const MarketplaceAppsTable = props => {
columns={columns}
data={marketplaceApps}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={MarketplaceAppRow}
{...props}
/>
diff --git a/src/fireedge/src/client/components/Tables/MarketplaceApps/row.js b/src/fireedge/src/client/components/Tables/MarketplaceApps/row.js
index 87df371d2a..1c7e4d4dff 100644
--- a/src/fireedge/src/client/components/Tables/MarketplaceApps/row.js
+++ b/src/fireedge/src/client/components/Tables/MarketplaceApps/row.js
@@ -29,11 +29,20 @@ import { prettyBytes } from 'client/utils'
const Row = ({ original, value, ...props }) => {
const classes = rowStyles()
const {
- ID, NAME, UNAME, GNAME, LOCK, TYPE,
- REGTIME, MARKETPLACE, ZONE_ID, SIZE
+ ID,
+ NAME,
+ UNAME,
+ GNAME,
+ LOCK,
+ TYPE,
+ REGTIME,
+ MARKETPLACE,
+ ZONE_ID,
+ SIZE,
} = value
- const { color: stateColor, name: stateName } = MarketplaceAppModel.getState(original)
+ const { color: stateColor, name: stateName } =
+ MarketplaceAppModel.getState(original)
const time = Helper.timeFromMilliseconds(+REGTIME)
const timeAgo = `registered ${time.toRelative()}`
@@ -45,18 +54,14 @@ const Row = ({ original, value, ...props }) => {
-
- {NAME}
-
+ {NAME}
{LOCK && }
-
- {`#${ID} ${timeAgo}`}
-
+
{`#${ID} ${timeAgo}`}
{` ${UNAME}`}
@@ -85,7 +90,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/Marketplaces/columns.js b/src/fireedge/src/client/components/Tables/Marketplaces/columns.js
index 7c4ba29c1b..37021b63ef 100644
--- a/src/fireedge/src/client/components/Tables/Marketplaces/columns.js
+++ b/src/fireedge/src/client/components/Tables/Marketplaces/columns.js
@@ -17,7 +17,8 @@
import { CategoryFilter } from 'client/components/Tables/Enhanced/Utils'
import * as MarketplaceModel from 'client/models/Datastore'
-const getTotalOfResources = resources => [resources?.ID ?? []].flat().length || 0
+const getTotalOfResources = (resources) =>
+ [resources?.ID ?? []].flat().length || 0
export default [
{ Header: 'ID', accessor: 'ID', sortType: 'number' },
@@ -27,25 +28,27 @@ export default [
{
Header: 'State',
id: 'STATE',
- accessor: row => MarketplaceModel.getState(row)?.name,
+ accessor: (row) => MarketplaceModel.getState(row)?.name,
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'State'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'State',
+ }),
+ filter: 'includesValue',
},
{
Header: 'Market',
accessor: 'MARKET_MAD',
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'Market mad'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'Market mad',
+ }),
+ filter: 'includesValue',
},
{ Header: 'Total Capacity', accessor: 'TOTAL_MB' },
{ Header: 'Free Capacity', accessor: 'USED_MB' },
@@ -53,6 +56,6 @@ export default [
{
Header: 'Total Apps',
id: 'TOTAL_APPS',
- accessor: row => getTotalOfResources(row?.MARKETPLACEAPPS)
- }
+ accessor: (row) => getTotalOfResources(row?.MARKETPLACEAPPS),
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/Marketplaces/index.js b/src/fireedge/src/client/components/Tables/Marketplaces/index.js
index 9660e446ab..6a9cd5579c 100644
--- a/src/fireedge/src/client/components/Tables/Marketplaces/index.js
+++ b/src/fireedge/src/client/components/Tables/Marketplaces/index.js
@@ -29,18 +29,25 @@ import MarketplaceRow from 'client/components/Tables/Marketplaces/row'
const MarketplacesTable = ({ filter, ...props }) => {
const { view, getResourceView, filterPool } = useAuth()
- const columns = useMemo(() => createColumns({
- filters: getResourceView('MARKETPLACE')?.filters,
- columns: MarketplaceColumns
- }), [view])
+ const columns = useMemo(
+ () =>
+ createColumns({
+ filters: getResourceView('MARKETPLACE')?.filters,
+ columns: MarketplaceColumns,
+ }),
+ [view]
+ )
const marketplaces = useMarketplace()
const { getMarketplaces } = useMarketplaceApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getMarketplaces)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getMarketplaces)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [filterPool])
+ useEffect(() => {
+ fetchRequest()
+ }, [filterPool])
if (marketplaces?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -49,12 +56,13 @@ const MarketplacesTable = ({ filter, ...props }) => {
return (
String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={MarketplaceRow}
{...props}
/>
@@ -63,7 +71,7 @@ const MarketplacesTable = ({ filter, ...props }) => {
MarketplacesTable.propTypes = {
filter: PropTypes.func,
- ...EnhancedTable.propTypes
+ ...EnhancedTable.propTypes,
}
MarketplacesTable.displayName = 'MarketplacesTable'
diff --git a/src/fireedge/src/client/components/Tables/Marketplaces/row.js b/src/fireedge/src/client/components/Tables/Marketplaces/row.js
index 09f2efd5fb..c8fb6e9d96 100644
--- a/src/fireedge/src/client/components/Tables/Marketplaces/row.js
+++ b/src/fireedge/src/client/components/Tables/Marketplaces/row.js
@@ -19,7 +19,11 @@ import PropTypes from 'prop-types'
import { User, Group, CloudDownload } from 'iconoir-react'
import { Typography } from '@mui/material'
-import { StatusCircle, LinearProgressWithLabel, StatusChip } from 'client/components/Status'
+import {
+ StatusCircle,
+ LinearProgressWithLabel,
+ StatusChip,
+} from 'client/components/Status'
import { rowStyles } from 'client/components/Tables/styles'
import * as MarketplaceModel from 'client/models/Datastore'
@@ -28,9 +32,11 @@ const Row = ({ original, value, ...props }) => {
const classes = rowStyles()
const { ID, NAME, UNAME, GNAME, MARKET_MAD, TOTAL_APPS } = value
- const { name: stateName, color: stateColor } = MarketplaceModel.getState(original)
+ const { name: stateName, color: stateColor } =
+ MarketplaceModel.getState(original)
- const { percentOfUsed, percentLabel } = MarketplaceModel.getCapacityInfo(value)
+ const { percentOfUsed, percentLabel } =
+ MarketplaceModel.getCapacityInfo(value)
return (
@@ -39,9 +45,7 @@ const Row = ({ original, value, ...props }) => {
-
- {NAME}
-
+
{NAME}
@@ -73,7 +77,7 @@ Row.propTypes = {
value: PropTypes.object,
original: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/Skeleton/index.js b/src/fireedge/src/client/components/Tables/Skeleton/index.js
index 4495aa82bc..39f8e93d81 100644
--- a/src/fireedge/src/client/components/Tables/Skeleton/index.js
+++ b/src/fireedge/src/client/components/Tables/Skeleton/index.js
@@ -20,7 +20,7 @@ import EnhancedTableStyles from 'client/components/Tables/Enhanced/styles'
import { rowStyles } from 'client/components/Tables/styles'
const SkeletonTable = memo(() => {
- const isMobile = useMediaQuery(theme => theme.breakpoints.down('md'))
+ const isMobile = useMediaQuery((theme) => theme.breakpoints.down('md'))
const classes = EnhancedTableStyles()
const rowClasses = rowStyles()
@@ -51,7 +51,9 @@ const SkeletonTable = memo(() => {
return (
- {!isMobile &&
}
+ {!isMobile && (
+
+ )}
@@ -60,10 +62,18 @@ const SkeletonTable = memo(() => {
{isMobile ? (
-
+
) : (
-
-
+
+
diff --git a/src/fireedge/src/client/components/Tables/Users/columns.js b/src/fireedge/src/client/components/Tables/Users/columns.js
index 153a2e0f85..0eb89bbc03 100644
--- a/src/fireedge/src/client/components/Tables/Users/columns.js
+++ b/src/fireedge/src/client/components/Tables/Users/columns.js
@@ -18,5 +18,5 @@ export default [
{ Header: 'Name', accessor: 'NAME' },
{ Header: 'Group', accessor: 'GNAME' },
{ Header: 'Enabled', accessor: 'ENABLED' },
- { Header: 'Auth driver', accessor: 'AUTH_DRIVER' }
+ { Header: 'Auth driver', accessor: 'AUTH_DRIVER' },
]
diff --git a/src/fireedge/src/client/components/Tables/Users/index.js b/src/fireedge/src/client/components/Tables/Users/index.js
index edd37f8b04..30956590be 100644
--- a/src/fireedge/src/client/components/Tables/Users/index.js
+++ b/src/fireedge/src/client/components/Tables/Users/index.js
@@ -25,21 +25,28 @@ import { createColumns } from 'client/components/Tables/Enhanced/Utils'
import UserColumns from 'client/components/Tables/Users/columns'
import UserRow from 'client/components/Tables/Users/row'
-const UsersTable = props => {
+const UsersTable = (props) => {
const { view, getResourceView, filterPool } = useAuth()
- const columns = useMemo(() => createColumns({
- filters: getResourceView('USER')?.filters,
- columns: UserColumns
- }), [view])
+ const columns = useMemo(
+ () =>
+ createColumns({
+ filters: getResourceView('USER')?.filters,
+ columns: UserColumns,
+ }),
+ [view]
+ )
const users = useUser()
const { getUsers } = useUserApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getUsers)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getUsers)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [filterPool])
+ useEffect(() => {
+ fetchRequest()
+ }, [filterPool])
if (users?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -50,7 +57,7 @@ const UsersTable = props => {
columns={columns}
data={users}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={UserRow}
{...props}
/>
diff --git a/src/fireedge/src/client/components/Tables/Users/row.js b/src/fireedge/src/client/components/Tables/Users/row.js
index fef0d710ef..2dc1fc7111 100644
--- a/src/fireedge/src/client/components/Tables/Users/row.js
+++ b/src/fireedge/src/client/components/Tables/Users/row.js
@@ -29,17 +29,11 @@ const Row = ({ original, value, ...props }) => {
-
- {NAME}
-
-
- {!+ENABLED && }
-
+ {NAME}
+ {!+ENABLED && }
-
- {`#${ID}`}
-
+
{`#${ID}`}
{` ${GNAME}`}
@@ -58,7 +52,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/VNetworkTemplates/columns.js b/src/fireedge/src/client/components/Tables/VNetworkTemplates/columns.js
index f9cf56789c..d6a45bab0f 100644
--- a/src/fireedge/src/client/components/Tables/VNetworkTemplates/columns.js
+++ b/src/fireedge/src/client/components/Tables/VNetworkTemplates/columns.js
@@ -24,8 +24,7 @@ export default [
{
Header: 'Provision ID',
id: 'PROVISION_ID',
- accessor: row => row?.TEMPLATE?.PROVISION?.ID,
- disableSortBy: true
- }
-
+ accessor: (row) => row?.TEMPLATE?.PROVISION?.ID,
+ disableSortBy: true,
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/VNetworkTemplates/index.js b/src/fireedge/src/client/components/Tables/VNetworkTemplates/index.js
index 6e8972af8c..44f1b1c92c 100644
--- a/src/fireedge/src/client/components/Tables/VNetworkTemplates/index.js
+++ b/src/fireedge/src/client/components/Tables/VNetworkTemplates/index.js
@@ -17,7 +17,10 @@
import { useMemo, useEffect } from 'react'
import { useFetch } from 'client/hooks'
-import { useVNetworkTemplate, useVNetworkTemplateApi } from 'client/features/One'
+import {
+ useVNetworkTemplate,
+ useVNetworkTemplateApi,
+} from 'client/features/One'
import { SkeletonTable, EnhancedTable } from 'client/components/Tables'
import VNetworkTemplateColumns from 'client/components/Tables/VNetworkTemplates/columns'
@@ -29,10 +32,13 @@ const VNetworkTemplatesTable = () => {
const vNetworkTemplates = useVNetworkTemplate()
const { getVNetworkTemplates } = useVNetworkTemplateApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getVNetworkTemplates)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getVNetworkTemplates)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [])
+ useEffect(() => {
+ fetchRequest()
+ }, [])
if (vNetworkTemplates?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -43,7 +49,7 @@ const VNetworkTemplatesTable = () => {
columns={columns}
data={vNetworkTemplates}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={VNetworkTemplateRow}
/>
)
diff --git a/src/fireedge/src/client/components/Tables/VNetworkTemplates/row.js b/src/fireedge/src/client/components/Tables/VNetworkTemplates/row.js
index 0fe9cffce8..c8eb00c185 100644
--- a/src/fireedge/src/client/components/Tables/VNetworkTemplates/row.js
+++ b/src/fireedge/src/client/components/Tables/VNetworkTemplates/row.js
@@ -34,17 +34,11 @@ const Row = ({ original, value, ...props }) => {
-
- {NAME}
-
-
- {LOCK && }
-
+ {NAME}
+ {LOCK && }
-
- {`#${ID} ${timeAgo}`}
-
+ {`#${ID} ${timeAgo}`}
{` ${UNAME}`}
@@ -53,10 +47,12 @@ const Row = ({ original, value, ...props }) => {
{` ${GNAME}`}
- {PROVISION_ID &&
-
- {` ${PROVISION_ID}`}
- }
+ {PROVISION_ID && (
+
+
+ {` ${PROVISION_ID}`}
+
+ )}
@@ -67,7 +63,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/VNetworks/columns.js b/src/fireedge/src/client/components/Tables/VNetworks/columns.js
index 3aae073e6a..6bf2bd324b 100644
--- a/src/fireedge/src/client/components/Tables/VNetworks/columns.js
+++ b/src/fireedge/src/client/components/Tables/VNetworks/columns.js
@@ -16,7 +16,8 @@
/* eslint-disable jsdoc/require-jsdoc */
import * as VirtualNetworkModel from 'client/models/VirtualNetwork'
-const getTotalOfResources = resources => [resources?.ID ?? []].flat().length || 0
+const getTotalOfResources = (resources) =>
+ [resources?.ID ?? []].flat().length || 0
export default [
{ Header: 'ID', accessor: 'ID', sortType: 'number' },
@@ -27,25 +28,24 @@ export default [
{
Header: 'Total Clusters',
id: 'CLUSTERS',
- accessor: row => getTotalOfResources(row?.CLUSTERS),
- sortType: 'number'
+ accessor: (row) => getTotalOfResources(row?.CLUSTERS),
+ sortType: 'number',
},
{
Header: 'Used Leases',
accessor: 'USED_LEASES',
- sortType: 'number'
+ sortType: 'number',
},
{
Header: 'Total Leases',
id: 'TOTAL_LEASES',
- accessor: row => VirtualNetworkModel.getTotalLeases(row),
- sortType: 'number'
+ accessor: (row) => VirtualNetworkModel.getTotalLeases(row),
+ sortType: 'number',
},
{
Header: 'Provision ID',
id: 'PROVISION_ID',
- accessor: row => row?.TEMPLATE?.PROVISION?.ID,
- disableSortBy: true
- }
-
+ accessor: (row) => row?.TEMPLATE?.PROVISION?.ID,
+ disableSortBy: true,
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/VNetworks/index.js b/src/fireedge/src/client/components/Tables/VNetworks/index.js
index 235beaecdb..fb5ec87fef 100644
--- a/src/fireedge/src/client/components/Tables/VNetworks/index.js
+++ b/src/fireedge/src/client/components/Tables/VNetworks/index.js
@@ -19,20 +19,27 @@ import { useMemo, useEffect } from 'react'
import { useFetch } from 'client/hooks'
import { useVNetwork, useVNetworkApi } from 'client/features/One'
-import { SkeletonTable, EnhancedTable, EnhancedTableProps } from 'client/components/Tables'
+import {
+ SkeletonTable,
+ EnhancedTable,
+ EnhancedTableProps,
+} from 'client/components/Tables'
import VNetworkColumns from 'client/components/Tables/VNetworks/columns'
import VNetworkRow from 'client/components/Tables/VNetworks/row'
-const VNetworksTable = props => {
+const VNetworksTable = (props) => {
const columns = useMemo(() => VNetworkColumns, [])
const vNetworks = useVNetwork()
const { getVNetworks } = useVNetworkApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getVNetworks)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getVNetworks)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [])
+ useEffect(() => {
+ fetchRequest()
+ }, [])
if (vNetworks?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -43,7 +50,7 @@ const VNetworksTable = props => {
columns={columns}
data={vNetworks}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={VNetworkRow}
{...props}
/>
diff --git a/src/fireedge/src/client/components/Tables/VNetworks/row.js b/src/fireedge/src/client/components/Tables/VNetworks/row.js
index 75b20972b6..f45bca1682 100644
--- a/src/fireedge/src/client/components/Tables/VNetworks/row.js
+++ b/src/fireedge/src/client/components/Tables/VNetworks/row.js
@@ -27,27 +27,29 @@ import * as VirtualNetworkModel from 'client/models/VirtualNetwork'
const Row = ({ original, value, ...props }) => {
const classes = rowStyles()
const {
- ID, NAME, UNAME, GNAME, LOCK, CLUSTERS,
- USED_LEASES, TOTAL_LEASES, PROVISION_ID
+ ID,
+ NAME,
+ UNAME,
+ GNAME,
+ LOCK,
+ CLUSTERS,
+ USED_LEASES,
+ TOTAL_LEASES,
+ PROVISION_ID,
} = value
- const { percentOfUsed, percentLabel } = VirtualNetworkModel.getLeasesInfo(original)
+ const { percentOfUsed, percentLabel } =
+ VirtualNetworkModel.getLeasesInfo(original)
return (
-
- {NAME}
-
-
- {LOCK && }
-
+ {NAME}
+ {LOCK && }
-
- {`#${ID}`}
-
+ {`#${ID}`}
{` ${UNAME}`}
@@ -60,10 +62,12 @@ const Row = ({ original, value, ...props }) => {
{` ${CLUSTERS}`}
- {PROVISION_ID &&
-
- {` ${PROVISION_ID}`}
- }
+ {PROVISION_ID && (
+
+
+ {` ${PROVISION_ID}`}
+
+ )}
@@ -81,7 +85,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/VRouters/columns.js b/src/fireedge/src/client/components/Tables/VRouters/columns.js
index 1bc6109c49..757c4baaa9 100644
--- a/src/fireedge/src/client/components/Tables/VRouters/columns.js
+++ b/src/fireedge/src/client/components/Tables/VRouters/columns.js
@@ -14,7 +14,8 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
/* eslint-disable jsdoc/require-jsdoc */
-const getTotalOfResources = resources => [resources?.ID ?? []].flat().length || 0
+const getTotalOfResources = (resources) =>
+ [resources?.ID ?? []].flat().length || 0
export default [
{ Header: 'ID', accessor: 'ID', sortType: 'number' },
@@ -24,12 +25,12 @@ export default [
{
Header: 'Total VMs',
id: 'VMS',
- accessor: row => getTotalOfResources(row?.VMS),
- sortType: 'number'
+ accessor: (row) => getTotalOfResources(row?.VMS),
+ sortType: 'number',
},
{
Header: 'Group',
id: 'TEMPLATE_ID',
- accessor: row => row?.TEMPLATE?.TEMPLATE_ID
- }
+ accessor: (row) => row?.TEMPLATE?.TEMPLATE_ID,
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/VRouters/index.js b/src/fireedge/src/client/components/Tables/VRouters/index.js
index ced5d201d5..4f8800a577 100644
--- a/src/fireedge/src/client/components/Tables/VRouters/index.js
+++ b/src/fireedge/src/client/components/Tables/VRouters/index.js
@@ -29,10 +29,13 @@ const VRoutersTable = () => {
const vRouters = useVRouter()
const { getVRouters } = useVRouterApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getVRouters)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getVRouters)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [])
+ useEffect(() => {
+ fetchRequest()
+ }, [])
if (vRouters?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -43,7 +46,7 @@ const VRoutersTable = () => {
columns={columns}
data={vRouters}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={VRouterRow}
/>
)
diff --git a/src/fireedge/src/client/components/Tables/VRouters/row.js b/src/fireedge/src/client/components/Tables/VRouters/row.js
index 24a89bad7c..5e521da88d 100644
--- a/src/fireedge/src/client/components/Tables/VRouters/row.js
+++ b/src/fireedge/src/client/components/Tables/VRouters/row.js
@@ -29,14 +29,10 @@ const Row = ({ original, value, ...props }) => {
-
- {NAME}
-
+ {NAME}
-
- {`#${ID}`}
-
+
{`#${ID}`}
{` ${UNAME}`}
@@ -63,7 +59,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/Virtualized/header.js b/src/fireedge/src/client/components/Tables/Virtualized/header.js
index 692833d9ba..54ad1e249b 100644
--- a/src/fireedge/src/client/components/Tables/Virtualized/header.js
+++ b/src/fireedge/src/client/components/Tables/Virtualized/header.js
@@ -22,27 +22,31 @@ const Header = ({ useTableProps }) => {
/** @type {UseTableInstanceProps} */
const { headerGroups } = useTableProps
- const renderHeaderColumn = useCallback(column => (
-
- {column.render('Header')}
-
- ), [])
+ const renderHeaderColumn = useCallback(
+ (column) => (
+ {column.render('Header')}
+ ),
+ []
+ )
- const renderHeaderGroup = useCallback(headerGroup => (
-
- {headerGroup.headers.map(renderHeaderColumn)}
-
- ), [])
+ const renderHeaderGroup = useCallback(
+ (headerGroup) => (
+
+ {headerGroup.headers.map(renderHeaderColumn)}
+
+ ),
+ []
+ )
return headerGroups.map(renderHeaderGroup)
}
Header.propTypes = {
- useTableProps: PropTypes.object
+ useTableProps: PropTypes.object,
}
Header.defaultProps = {
- useTableProps: {}
+ useTableProps: {},
}
export default Header
diff --git a/src/fireedge/src/client/components/Tables/Virtualized/index.js b/src/fireedge/src/client/components/Tables/Virtualized/index.js
index 4a0017819e..b10380d9a5 100644
--- a/src/fireedge/src/client/components/Tables/Virtualized/index.js
+++ b/src/fireedge/src/client/components/Tables/Virtualized/index.js
@@ -23,7 +23,7 @@ import {
useTable,
useGlobalFilter,
useRowSelect,
- useFlexLayout
+ useFlexLayout,
} from 'react-table'
import { ListVirtualized } from 'client/components/List'
@@ -31,17 +31,17 @@ import Toolbar from 'client/components/Tables/Virtualized/toolbar'
import Header from 'client/components/Tables/Virtualized/header'
import Row from 'client/components/Tables/Virtualized/row'
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles((theme) => ({
root: {
height: '100%',
display: 'flex',
- flexDirection: 'column'
+ flexDirection: 'column',
},
table: {
height: '100%',
overflow: 'auto',
border: `1px solid ${theme.palette.action.disabledBackground}`,
- borderRadius: 6
+ borderRadius: 6,
},
body: {
'& *[role=row]': {
@@ -57,12 +57,12 @@ const useStyles = makeStyles(theme => ({
color: theme.palette.text.primary,
borderTop: `1px solid ${theme.palette.action.disabledBackground}`,
'&:hover': {
- backgroundColor: theme.palette.action.hover
+ backgroundColor: theme.palette.action.hover,
},
'&:first-of-type': {
- borderTopColor: 'transparent'
- }
- }
+ borderTopColor: 'transparent',
+ },
+ },
},
toolbar: {
...theme.typography.body1,
@@ -72,14 +72,14 @@ const useStyles = makeStyles(theme => ({
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
- gap: '1em'
+ gap: '1em',
},
total: {
display: 'flex',
alignItems: 'center',
gap: '1em',
- transition: 200
- }
+ transition: 200,
+ },
}))
const DefaultCell = memo(({ value }) => value ?? '--')
@@ -91,14 +91,17 @@ const VirtualizedTable = ({
columns,
isLoading,
canFetchMore,
- fetchMore
+ fetchMore,
}) => {
const classes = useStyles()
- const defaultColumn = useMemo(() => ({
- // Filter: DefaultFilter,
- Cell: DefaultCell
- }), [])
+ const defaultColumn = useMemo(
+ () => ({
+ // Filter: DefaultFilter,
+ Cell: DefaultCell,
+ }),
+ []
+ )
const useTableProps = useTable(
{ columns, data, defaultColumn },
@@ -111,12 +114,11 @@ const VirtualizedTable = ({
return (
-
- {isLoading && }
- Total loaded: {useTableProps.rows.length}
+ {isLoading && }
+ Total loaded: {useTableProps.rows.length}
@@ -131,12 +133,14 @@ const VirtualizedTable = ({
isLoading={isLoading}
fetchMore={fetchMore}
>
- {virtualItems => virtualItems?.map(virtualRow => (
-
- ))
+ {(virtualItems) =>
+ virtualItems?.map((virtualRow) => (
+
+ ))
}
@@ -150,7 +154,7 @@ VirtualizedTable.propTypes = {
columns: PropTypes.array,
isLoading: PropTypes.bool,
canFetchMore: PropTypes.bool,
- fetchMore: PropTypes.func
+ fetchMore: PropTypes.func,
}
export default VirtualizedTable
diff --git a/src/fireedge/src/client/components/Tables/Virtualized/row.js b/src/fireedge/src/client/components/Tables/Virtualized/row.js
index 4feb9d7175..ed622e6881 100644
--- a/src/fireedge/src/client/components/Tables/Virtualized/row.js
+++ b/src/fireedge/src/client/components/Tables/Virtualized/row.js
@@ -29,12 +29,12 @@ const useStyles = makeStyles(() => ({
position: 'absolute',
top: 0,
left: 0,
- width: '100%'
+ width: '100%',
},
virtual: ({ size, start }) => ({
height: size,
- transform: `translateY(${start}px)`
- })
+ transform: `translateY(${start}px)`,
+ }),
}))
const Row = ({ virtualRow, useTableProps }) => {
@@ -51,14 +51,14 @@ const Row = ({ virtualRow, useTableProps }) => {
prepareRow(row)
- const renderCell = useCallback(cell => (
-
- {cell.render('Cell')}
-
- ), [])
+ const renderCell = useCallback(
+ (cell) =>
{cell.render('Cell')},
+ []
+ )
return (
-
@@ -69,12 +69,12 @@ const Row = ({ virtualRow, useTableProps }) => {
Row.propTypes = {
virtualRow: PropTypes.object,
- useTableProps: PropTypes.object
+ useTableProps: PropTypes.object,
}
Row.defaultProps = {
virtualRow: {},
- useTableProps: {}
+ useTableProps: {},
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/Virtualized/toolbar.js b/src/fireedge/src/client/components/Tables/Virtualized/toolbar.js
index 76a13562f4..def0426a3f 100644
--- a/src/fireedge/src/client/components/Tables/Virtualized/toolbar.js
+++ b/src/fireedge/src/client/components/Tables/Virtualized/toolbar.js
@@ -25,18 +25,18 @@ import { GlobalFilter } from 'client/components/Tables/Enhanced/Utils'
import { Tr } from 'client/components/HOC'
import { T } from 'client/constants'
-const useToolbarStyles = makeStyles(theme => ({
+const useToolbarStyles = makeStyles((theme) => ({
filterWrapper: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
- gap: '1em'
+ gap: '1em',
},
filterButton: {
...theme.typography.body1,
fontWeight: theme.typography.fontWeightBold,
- textTransform: 'none'
- }
+ textTransform: 'none',
+ },
}))
const Toolbar = ({ useTableProps }) => {
@@ -50,9 +50,7 @@ const Toolbar = ({ useTableProps }) => {
return (
-
}
- className={classes.filterButton}
- >
+
} className={classes.filterButton}>
{Tr(T.Filters)}
{
}
Toolbar.propTypes = {
- useTableProps: PropTypes.object
+ useTableProps: PropTypes.object,
}
Toolbar.defaultProps = {
- useTableProps: {}
+ useTableProps: {},
}
export default Toolbar
diff --git a/src/fireedge/src/client/components/Tables/VmTemplates/actions.js b/src/fireedge/src/client/components/Tables/VmTemplates/actions.js
index 244b62e479..4743bb66fd 100644
--- a/src/fireedge/src/client/components/Tables/VmTemplates/actions.js
+++ b/src/fireedge/src/client/components/Tables/VmTemplates/actions.js
@@ -24,7 +24,7 @@ import {
PlayOutline,
Lock,
Group,
- Cart
+ Cart,
} from 'iconoir-react'
import { useAuth } from 'client/features/Auth'
@@ -39,10 +39,10 @@ import {
T,
VM_TEMPLATE_ACTIONS,
MARKETPLACE_APP_ACTIONS,
- RESOURCE_NAMES
+ RESOURCE_NAMES,
} from 'client/constants'
-const MessageToConfirmAction = rows => {
+const MessageToConfirmAction = (rows) => {
const names = rows?.map?.(({ original }) => original?.NAME)
return (
@@ -63,227 +63,253 @@ MessageToConfirmAction.displayName = 'MessageToConfirmAction'
const Actions = () => {
const history = useHistory()
const { view, getResourceView } = useAuth()
- const {
- getVmTemplate,
- getVmTemplates,
- lock,
- unlock,
- clone,
- remove
- } = useVmTemplateApi()
+ const { getVmTemplate, getVmTemplates, lock, unlock, clone, remove } =
+ useVmTemplateApi()
- const vmTemplateActions = useMemo(() => createActions({
- filters: getResourceView('VM-TEMPLATE')?.actions,
- actions: [
- {
- accessor: VM_TEMPLATE_ACTIONS.REFRESH,
- tooltip: T.Refresh,
- icon: RefreshDouble,
- action: async () => {
- await getVmTemplates()
- }
- },
- {
- accessor: VM_TEMPLATE_ACTIONS.CREATE_DIALOG,
- tooltip: T.Create,
- icon: AddSquare,
- action: () => {
- const path = PATH.TEMPLATE.VMS.CREATE
-
- history.push(path)
- }
- },
- {
- accessor: VM_TEMPLATE_ACTIONS.IMPORT_DIALOG,
- tooltip: T.Import,
- icon: Import,
- selected: { max: 1 },
- disabled: true,
- action: rows => {
- // TODO: go to IMPORT form
- }
- },
- {
- accessor: VM_TEMPLATE_ACTIONS.INSTANTIATE_DIALOG,
- tooltip: T.Instantiate,
- icon: PlayOutline,
- selected: { max: 1 },
- action: rows => {
- const template = rows?.[0]?.original ?? {}
- const path = PATH.TEMPLATE.VMS.INSTANTIATE
-
- history.push(path, template)
- }
- },
- {
- accessor: VM_TEMPLATE_ACTIONS.CREATE_APP_DIALOG,
- tooltip: T.CreateMarketApp,
- selected: { max: 1 },
- icon: Cart,
- action: rows => {
- const template = rows?.[0]?.original ?? {}
- const path = PATH.STORAGE.MARKETPLACE_APPS.CREATE
-
- history.push(path, [RESOURCE_NAMES.VM_TEMPLATE, template])
- }
- },
- {
- accessor: VM_TEMPLATE_ACTIONS.UPDATE_DIALOG,
- label: T.Update,
- tooltip: T.Update,
- selected: { max: 1 },
- color: 'secondary',
- action: rows => {
- const vmTemplate = rows?.[0]?.original ?? {}
- const path = PATH.TEMPLATE.VMS.CREATE
-
- history.push(path, vmTemplate)
- }
- },
- {
- accessor: VM_TEMPLATE_ACTIONS.CLONE,
- label: T.Clone,
- tooltip: T.Clone,
- selected: true,
- color: 'secondary',
- options: [{
- dialogProps: {
- title: rows => {
- const isMultiple = rows?.length > 1
- const { ID, NAME } = rows?.[0]?.original
-
- return [
- Tr(isMultiple ? T.CloneSeveralTemplates : T.CloneTemplate),
- !isMultiple && `#${ID} ${NAME}`
- ].filter(Boolean).join(' - ')
- }
- },
- form: rows => {
- const vmTemplates = rows?.map(({ original }) => original)
- const stepProps = { isMultiple: vmTemplates.length > 1 }
- const initialValues = { name: `Copy of ${vmTemplates?.[0]?.NAME}` }
-
- return CloneForm(stepProps, initialValues)
- },
- onSubmit: async (formData, rows) => {
- try {
- const { prefix } = formData
-
- const vmTemplates = rows?.map?.(({ original: { ID, NAME } = {} }) => {
- // overwrite all names with prefix+NAME
- const formatData = prefix ? { name: `${prefix} ${NAME}` } : {}
-
- return { id: ID, data: { ...formData, ...formatData } }
- })
-
- await Promise.all(vmTemplates.map(({ id, data }) => clone(id, data)))
- } finally {
+ const vmTemplateActions = useMemo(
+ () =>
+ createActions({
+ filters: getResourceView('VM-TEMPLATE')?.actions,
+ actions: [
+ {
+ accessor: VM_TEMPLATE_ACTIONS.REFRESH,
+ tooltip: T.Refresh,
+ icon: RefreshDouble,
+ action: async () => {
await getVmTemplates()
- }
- }
- }]
- },
- {
- tooltip: T.Ownership,
- icon: Group,
- selected: true,
- color: 'secondary',
- options: [{
- accessor: VM_TEMPLATE_ACTIONS.CHANGE_OWNER,
- name: T.ChangeOwner,
- disabled: true,
- isConfirmDialog: true,
- onSubmit: () => undefined
- }, {
- accessor: VM_TEMPLATE_ACTIONS.CHANGE_GROUP,
- name: T.ChangeGroup,
- disabled: true,
- isConfirmDialog: true,
- onSubmit: () => undefined
- }, {
- accessor: VM_TEMPLATE_ACTIONS.SHARE,
- disabled: true,
- name: T.Share,
- isConfirmDialog: true,
- onSubmit: () => undefined
- }, {
- accessor: VM_TEMPLATE_ACTIONS.UNSHARE,
- disabled: true,
- name: T.Unshare,
- isConfirmDialog: true,
- onSubmit: () => undefined
- }]
- },
- {
- tooltip: T.Lock,
- icon: Lock,
- selected: true,
- color: 'secondary',
- options: [{
- accessor: VM_TEMPLATE_ACTIONS.LOCK,
- name: T.Lock,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Lock,
- children: MessageToConfirmAction
+ },
},
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => lock(id)))
- await Promise.all(ids.map(id => getVmTemplate(id)))
- }
- }, {
- accessor: VM_TEMPLATE_ACTIONS.UNLOCK,
- name: T.Unlock,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Unlock,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => unlock(id)))
- await Promise.all(ids.map(id => getVmTemplate(id)))
- }
- }]
- },
- {
- accessor: VM_TEMPLATE_ACTIONS.DELETE,
- tooltip: T.Delete,
- icon: Trash,
- selected: true,
- color: 'error',
- options: [{
- isConfirmDialog: true,
- dialogProps: {
- title: T.Delete,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => remove(id)))
- await getVmTemplates()
- }
- }]
- }
- ]
- }), [view])
+ {
+ accessor: VM_TEMPLATE_ACTIONS.CREATE_DIALOG,
+ tooltip: T.Create,
+ icon: AddSquare,
+ action: () => {
+ const path = PATH.TEMPLATE.VMS.CREATE
- const marketplaceAppActions = useMemo(() => createActions({
- filters: getResourceView('MARKETPLACE-APP')?.actions,
- actions: [
- {
- accessor: MARKETPLACE_APP_ACTIONS.CREATE_DIALOG,
- tooltip: T.CreateMarketApp,
- icon: Cart,
- selected: { max: 1 },
- disabled: true,
- action: rows => {
- // TODO: go to Marketplace App CREATE form
- }
- }
- ]
- }), [view])
+ history.push(path)
+ },
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.IMPORT_DIALOG,
+ tooltip: T.Import,
+ icon: Import,
+ selected: { max: 1 },
+ disabled: true,
+ action: (rows) => {
+ // TODO: go to IMPORT form
+ },
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.INSTANTIATE_DIALOG,
+ tooltip: T.Instantiate,
+ icon: PlayOutline,
+ selected: { max: 1 },
+ action: (rows) => {
+ const template = rows?.[0]?.original ?? {}
+ const path = PATH.TEMPLATE.VMS.INSTANTIATE
+
+ history.push(path, template)
+ },
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.CREATE_APP_DIALOG,
+ tooltip: T.CreateMarketApp,
+ selected: { max: 1 },
+ icon: Cart,
+ action: (rows) => {
+ const template = rows?.[0]?.original ?? {}
+ const path = PATH.STORAGE.MARKETPLACE_APPS.CREATE
+
+ history.push(path, [RESOURCE_NAMES.VM_TEMPLATE, template])
+ },
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.UPDATE_DIALOG,
+ label: T.Update,
+ tooltip: T.Update,
+ selected: { max: 1 },
+ color: 'secondary',
+ action: (rows) => {
+ const vmTemplate = rows?.[0]?.original ?? {}
+ const path = PATH.TEMPLATE.VMS.CREATE
+
+ history.push(path, vmTemplate)
+ },
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.CLONE,
+ label: T.Clone,
+ tooltip: T.Clone,
+ selected: true,
+ color: 'secondary',
+ options: [
+ {
+ dialogProps: {
+ title: (rows) => {
+ const isMultiple = rows?.length > 1
+ const { ID, NAME } = rows?.[0]?.original
+
+ return [
+ Tr(
+ isMultiple ? T.CloneSeveralTemplates : T.CloneTemplate
+ ),
+ !isMultiple && `#${ID} ${NAME}`,
+ ]
+ .filter(Boolean)
+ .join(' - ')
+ },
+ },
+ form: (rows) => {
+ const vmTemplates = rows?.map(({ original }) => original)
+ const stepProps = { isMultiple: vmTemplates.length > 1 }
+ const initialValues = {
+ name: `Copy of ${vmTemplates?.[0]?.NAME}`,
+ }
+
+ return CloneForm(stepProps, initialValues)
+ },
+ onSubmit: async (formData, rows) => {
+ try {
+ const { prefix } = formData
+
+ const vmTemplates = rows?.map?.(
+ ({ original: { ID, NAME } = {} }) => {
+ // overwrite all names with prefix+NAME
+ const formatData = prefix
+ ? { name: `${prefix} ${NAME}` }
+ : {}
+
+ return { id: ID, data: { ...formData, ...formatData } }
+ }
+ )
+
+ await Promise.all(
+ vmTemplates.map(({ id, data }) => clone(id, data))
+ )
+ } finally {
+ await getVmTemplates()
+ }
+ },
+ },
+ ],
+ },
+ {
+ tooltip: T.Ownership,
+ icon: Group,
+ selected: true,
+ color: 'secondary',
+ options: [
+ {
+ accessor: VM_TEMPLATE_ACTIONS.CHANGE_OWNER,
+ name: T.ChangeOwner,
+ disabled: true,
+ isConfirmDialog: true,
+ onSubmit: () => undefined,
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.CHANGE_GROUP,
+ name: T.ChangeGroup,
+ disabled: true,
+ isConfirmDialog: true,
+ onSubmit: () => undefined,
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.SHARE,
+ disabled: true,
+ name: T.Share,
+ isConfirmDialog: true,
+ onSubmit: () => undefined,
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.UNSHARE,
+ disabled: true,
+ name: T.Unshare,
+ isConfirmDialog: true,
+ onSubmit: () => undefined,
+ },
+ ],
+ },
+ {
+ tooltip: T.Lock,
+ icon: Lock,
+ selected: true,
+ color: 'secondary',
+ options: [
+ {
+ accessor: VM_TEMPLATE_ACTIONS.LOCK,
+ name: T.Lock,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Lock,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => lock(id)))
+ await Promise.all(ids.map((id) => getVmTemplate(id)))
+ },
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.UNLOCK,
+ name: T.Unlock,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Unlock,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => unlock(id)))
+ await Promise.all(ids.map((id) => getVmTemplate(id)))
+ },
+ },
+ ],
+ },
+ {
+ accessor: VM_TEMPLATE_ACTIONS.DELETE,
+ tooltip: T.Delete,
+ icon: Trash,
+ selected: true,
+ color: 'error',
+ options: [
+ {
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Delete,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => remove(id)))
+ await getVmTemplates()
+ },
+ },
+ ],
+ },
+ ],
+ }),
+ [view]
+ )
+
+ const marketplaceAppActions = useMemo(
+ () =>
+ createActions({
+ filters: getResourceView('MARKETPLACE-APP')?.actions,
+ actions: [
+ {
+ accessor: MARKETPLACE_APP_ACTIONS.CREATE_DIALOG,
+ tooltip: T.CreateMarketApp,
+ icon: Cart,
+ selected: { max: 1 },
+ disabled: true,
+ action: (rows) => {
+ // TODO: go to Marketplace App CREATE form
+ },
+ },
+ ],
+ }),
+ [view]
+ )
return [...vmTemplateActions, ...marketplaceAppActions]
}
diff --git a/src/fireedge/src/client/components/Tables/VmTemplates/columns.js b/src/fireedge/src/client/components/Tables/VmTemplates/columns.js
index f5ca3471eb..8594842b53 100644
--- a/src/fireedge/src/client/components/Tables/VmTemplates/columns.js
+++ b/src/fireedge/src/client/components/Tables/VmTemplates/columns.js
@@ -16,7 +16,7 @@
/* eslint-disable jsdoc/require-jsdoc */
import { CategoryFilter } from 'client/components/Tables/Enhanced/Utils'
import * as Helper from 'client/models/Helper'
-import { } from 'client/constants'
+import {} from 'client/constants'
export default [
{ Header: 'ID', accessor: 'ID', sortType: 'number' },
@@ -28,18 +28,19 @@ export default [
{
Header: 'Logo',
id: 'LOGO',
- accessor: row => row?.TEMPLATE?.LOGO
+ accessor: (row) => row?.TEMPLATE?.LOGO,
},
{
Header: 'Virtual Router',
id: 'VROUTER',
- accessor: row =>
+ accessor: (row) =>
Helper.stringToBoolean(row?.TEMPLATE?.VROUTER) && 'VROUTER',
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- title: 'Virtual Router'
- }),
- filter: 'exact'
- }
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ title: 'Virtual Router',
+ }),
+ filter: 'exact',
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/VmTemplates/index.js b/src/fireedge/src/client/components/Tables/VmTemplates/index.js
index c94275b451..16c20f01e5 100644
--- a/src/fireedge/src/client/components/Tables/VmTemplates/index.js
+++ b/src/fireedge/src/client/components/Tables/VmTemplates/index.js
@@ -20,26 +20,37 @@ import { useAuth } from 'client/features/Auth'
import { useFetch } from 'client/hooks'
import { useVmTemplate, useVmTemplateApi } from 'client/features/One'
-import { SkeletonTable, EnhancedTable, EnhancedTableProps } from 'client/components/Tables'
+import {
+ SkeletonTable,
+ EnhancedTable,
+ EnhancedTableProps,
+} from 'client/components/Tables'
import { createColumns } from 'client/components/Tables/Enhanced/Utils'
import VmTemplateColumns from 'client/components/Tables/VmTemplates/columns'
import VmTemplateRow from 'client/components/Tables/VmTemplates/row'
-const VmTemplatesTable = props => {
+const VmTemplatesTable = (props) => {
const { view, getResourceView, filterPool } = useAuth()
- const columns = useMemo(() => createColumns({
- filters: getResourceView('VM-TEMPLATE')?.filters,
- columns: VmTemplateColumns
- }), [view])
+ const columns = useMemo(
+ () =>
+ createColumns({
+ filters: getResourceView('VM-TEMPLATE')?.filters,
+ columns: VmTemplateColumns,
+ }),
+ [view]
+ )
const vmTemplates = useVmTemplate()
const { getVmTemplates } = useVmTemplateApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getVmTemplates)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getVmTemplates)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [filterPool])
+ useEffect(() => {
+ fetchRequest()
+ }, [filterPool])
if (vmTemplates?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -50,7 +61,7 @@ const VmTemplatesTable = props => {
columns={columns}
data={vmTemplates}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={VmTemplateRow}
{...props}
/>
diff --git a/src/fireedge/src/client/components/Tables/VmTemplates/row.js b/src/fireedge/src/client/components/Tables/VmTemplates/row.js
index 489a751a2d..3e6d0c8cf6 100644
--- a/src/fireedge/src/client/components/Tables/VmTemplates/row.js
+++ b/src/fireedge/src/client/components/Tables/VmTemplates/row.js
@@ -46,23 +46,18 @@ const Row = ({ original, value, ...props }) => {
return (
-
+
-
- {NAME}
-
+ {NAME}
{LOCK && }
{VROUTER && }
-
+
{`#${ID} ${timeAgo}`}
@@ -83,7 +78,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/Vms/actions.js b/src/fireedge/src/client/components/Tables/Vms/actions.js
index ba61171cc5..9b0165907c 100644
--- a/src/fireedge/src/client/components/Tables/Vms/actions.js
+++ b/src/fireedge/src/client/components/Tables/Vms/actions.js
@@ -27,7 +27,7 @@ import {
Group,
Trash,
Lock,
- Cart
+ Cart,
} from 'iconoir-react'
import { useAuth } from 'client/features/Auth'
@@ -40,7 +40,7 @@ import {
ChangeUserForm,
ChangeGroupForm,
MigrateForm,
- SaveAsTemplateForm
+ SaveAsTemplateForm,
} from 'client/components/Forms/Vm'
import { createActions } from 'client/components/Tables/Enhanced/Utils'
@@ -48,7 +48,7 @@ import { PATH } from 'client/apps/sunstone/routesOne'
import { getLastHistory, isAvailableAction } from 'client/models/VirtualMachine'
import { T, VM_ACTIONS, RESOURCE_NAMES } from 'client/constants'
-const isDisabled = action => rows =>
+const isDisabled = (action) => (rows) =>
isAvailableAction(action)(rows, ({ values }) => values?.STATE)
const ListVmNames = ({ rows = [] }) => {
@@ -57,21 +57,21 @@ const ListVmNames = ({ rows = [] }) => {
return rows?.map?.(({ id, original }) => {
const { ID, NAME } = original
const { HID = '', HOSTNAME = '--', DS_ID = '' } = getLastHistory(original)
- const DS_NAME = datastores?.find(ds => ds?.ID === DS_ID)?.NAME ?? '--'
+ const DS_NAME = datastores?.find((ds) => ds?.ID === DS_ID)?.NAME ?? '--'
return (
@@ -79,9 +79,9 @@ const ListVmNames = ({ rows = [] }) => {
})
}
-const SubHeader = rows =>
+const SubHeader = (rows) =>
-const MessageToConfirmAction = rows => (
+const MessageToConfirmAction = (rows) => (
<>
@@ -117,419 +117,457 @@ const Actions = () => {
migrate,
migrateLive,
lock,
- unlock
+ unlock,
} = useVmApi()
- const vmActions = useMemo(() => createActions({
- filters: getResourceView('VM')?.actions,
- actions: [
- {
- accessor: VM_ACTIONS.REFRESH,
- tooltip: T.Refresh,
- icon: RefreshDouble,
- action: async () => {
- await getVms({ state: -1 })
- }
- },
- {
- accessor: VM_ACTIONS.CREATE_DIALOG,
- tooltip: T.Create,
- icon: AddSquare,
- action: () => {
- const path = PATH.TEMPLATE.VMS.INSTANTIATE
+ const vmActions = useMemo(
+ () =>
+ createActions({
+ filters: getResourceView('VM')?.actions,
+ actions: [
+ {
+ accessor: VM_ACTIONS.REFRESH,
+ tooltip: T.Refresh,
+ icon: RefreshDouble,
+ action: async () => {
+ await getVms({ state: -1 })
+ },
+ },
+ {
+ accessor: VM_ACTIONS.CREATE_DIALOG,
+ tooltip: T.Create,
+ icon: AddSquare,
+ action: () => {
+ const path = PATH.TEMPLATE.VMS.INSTANTIATE
- history.push(path)
- }
- },
- {
- accessor: VM_ACTIONS.RESUME,
- disabled: isDisabled(VM_ACTIONS.RESUME),
- tooltip: T.Resume,
- selected: true,
- icon: PlayOutline,
- action: async rows => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => resume(id)))
- ids?.length > 1 && (await Promise.all(ids.map(id => getVm(id))))
- }
- },
- {
- accessor: VM_ACTIONS.CREATE_APP_DIALOG,
- disabled: isDisabled(VM_ACTIONS.CREATE_APP_DIALOG),
- tooltip: T.CreateMarketApp,
- selected: { max: 1 },
- icon: Cart,
- action: rows => {
- const vm = rows?.[0]?.original ?? {}
- const path = PATH.STORAGE.MARKETPLACE_APPS.CREATE
+ history.push(path)
+ },
+ },
+ {
+ accessor: VM_ACTIONS.RESUME,
+ disabled: isDisabled(VM_ACTIONS.RESUME),
+ tooltip: T.Resume,
+ selected: true,
+ icon: PlayOutline,
+ action: async (rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => resume(id)))
+ ids?.length > 1 && (await Promise.all(ids.map((id) => getVm(id))))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.CREATE_APP_DIALOG,
+ disabled: isDisabled(VM_ACTIONS.CREATE_APP_DIALOG),
+ tooltip: T.CreateMarketApp,
+ selected: { max: 1 },
+ icon: Cart,
+ action: (rows) => {
+ const vm = rows?.[0]?.original ?? {}
+ const path = PATH.STORAGE.MARKETPLACE_APPS.CREATE
- history.push(path, [RESOURCE_NAMES.VM, vm])
- }
- },
- {
- accessor: VM_ACTIONS.SAVE_AS_TEMPLATE,
- disabled: isDisabled(VM_ACTIONS.SAVE_AS_TEMPLATE),
- tooltip: T.SaveAsTemplate,
- selected: { max: 1 },
- icon: SaveFloppyDisk,
- options: [{
- dialogProps: {
- title: T.SaveAsTemplate,
- subheader: SubHeader
+ history.push(path, [RESOURCE_NAMES.VM, vm])
+ },
},
- form: SaveAsTemplateForm,
- onSubmit: async (formData, rows) => {
- const vmId = rows?.[0]?.original?.ID
- const response = await saveAsTemplate(vmId, formData)
- enqueueSuccess(response)
- }
- }]
- },
- {
- tooltip: T.Manage,
- icon: SystemShut,
- selected: true,
- color: 'secondary',
- options: [{
- accessor: VM_ACTIONS.SUSPEND,
- disabled: isDisabled(VM_ACTIONS.SUSPEND),
- name: T.Suspend,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Suspend,
- children: MessageToConfirmAction
+ {
+ accessor: VM_ACTIONS.SAVE_AS_TEMPLATE,
+ disabled: isDisabled(VM_ACTIONS.SAVE_AS_TEMPLATE),
+ tooltip: T.SaveAsTemplate,
+ selected: { max: 1 },
+ icon: SaveFloppyDisk,
+ options: [
+ {
+ dialogProps: {
+ title: T.SaveAsTemplate,
+ subheader: SubHeader,
+ },
+ form: SaveAsTemplateForm,
+ onSubmit: async (formData, rows) => {
+ const vmId = rows?.[0]?.original?.ID
+ const response = await saveAsTemplate(vmId, formData)
+ enqueueSuccess(response)
+ },
+ },
+ ],
},
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => suspend(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.STOP,
- disabled: isDisabled(VM_ACTIONS.STOP),
- name: T.Stop,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Stop,
- children: MessageToConfirmAction
+ {
+ tooltip: T.Manage,
+ icon: SystemShut,
+ selected: true,
+ color: 'secondary',
+ options: [
+ {
+ accessor: VM_ACTIONS.SUSPEND,
+ disabled: isDisabled(VM_ACTIONS.SUSPEND),
+ name: T.Suspend,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Suspend,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => suspend(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.STOP,
+ disabled: isDisabled(VM_ACTIONS.STOP),
+ name: T.Stop,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Stop,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => stop(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.POWEROFF,
+ disabled: isDisabled(VM_ACTIONS.POWEROFF),
+ name: T.Poweroff,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Poweroff,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => poweroff(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.POWEROFF_HARD,
+ disabled: isDisabled(VM_ACTIONS.POWEROFF_HARD),
+ name: T.PoweroffHard,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.PoweroffHard,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => poweroffHard(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.REBOOT,
+ disabled: isDisabled(VM_ACTIONS.REBOOT),
+ name: T.Reboot,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Reboot,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => reboot(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.REBOOT_HARD,
+ disabled: isDisabled(VM_ACTIONS.REBOOT_HARD),
+ name: T.RebootHard,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.RebootHard,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => rebootHard(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.UNDEPLOY,
+ disabled: isDisabled(VM_ACTIONS.UNDEPLOY),
+ name: T.Undeploy,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Undeploy,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => undeploy(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.UNDEPLOY_HARD,
+ disabled: isDisabled(VM_ACTIONS.UNDEPLOY_HARD),
+ name: T.UndeployHard,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.UndeployHard,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => undeployHard(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ ],
},
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => stop(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.POWEROFF,
- disabled: isDisabled(VM_ACTIONS.POWEROFF),
- name: T.Poweroff,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Poweroff,
- children: MessageToConfirmAction
+ {
+ tooltip: T.Host,
+ icon: TransitionRight,
+ selected: true,
+ color: 'secondary',
+ options: [
+ {
+ accessor: VM_ACTIONS.DEPLOY,
+ disabled: isDisabled(VM_ACTIONS.DEPLOY),
+ name: T.Deploy,
+ form: MigrateForm,
+ dialogProps: {
+ title: T.Deploy,
+ subheader: SubHeader,
+ },
+ onSubmit: async (formData, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => deploy(id, formData)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.MIGRATE,
+ disabled: isDisabled(VM_ACTIONS.MIGRATE),
+ name: T.Migrate,
+ form: MigrateForm,
+ dialogProps: {
+ title: T.Migrate,
+ subheader: SubHeader,
+ },
+ onSubmit: async (formData, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => migrate(id, formData)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.MIGRATE_LIVE,
+ disabled: isDisabled(VM_ACTIONS.MIGRATE_LIVE),
+ name: T.MigrateLive,
+ form: MigrateForm,
+ dialogProps: {
+ title: T.Migrate,
+ subheader: SubHeader,
+ },
+ onSubmit: async (formData, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => migrateLive(id, formData)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.HOLD,
+ disabled: isDisabled(VM_ACTIONS.HOLD),
+ name: T.Hold,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Hold,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => hold(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.RELEASE,
+ disabled: isDisabled(VM_ACTIONS.RELEASE),
+ name: T.Release,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Release,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => release(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.RESCHED,
+ disabled: isDisabled(VM_ACTIONS.RESCHED),
+ name: T.Reschedule,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Reschedule,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => resched(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.UNRESCHED,
+ disabled: isDisabled(VM_ACTIONS.UNRESCHED),
+ name: T.UnReschedule,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.UnReschedule,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => unresched(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.RECOVER,
+ disabled: isDisabled(VM_ACTIONS.RECOVER),
+ name: T.Recover,
+ dialogProps: {
+ title: T.Recover,
+ subheader: SubHeader,
+ },
+ form: RecoverForm,
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => recover(id)))
+ ids?.length > 1 &&
+ (await Promise.all(ids.map((id) => getVm(id))))
+ },
+ },
+ ],
},
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => poweroff(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.POWEROFF_HARD,
- disabled: isDisabled(VM_ACTIONS.POWEROFF_HARD),
- name: T.PoweroffHard,
- isConfirmDialog: true,
- dialogProps: {
- title: T.PoweroffHard,
- children: MessageToConfirmAction
+ {
+ tooltip: T.Ownership,
+ icon: Group,
+ selected: true,
+ color: 'secondary',
+ options: [
+ {
+ accessor: VM_ACTIONS.CHANGE_OWNER,
+ disabled: isDisabled(VM_ACTIONS.CHANGE_OWNER),
+ name: T.ChangeOwner,
+ dialogProps: {
+ title: T.ChangeOwner,
+ subheader: SubHeader,
+ },
+ form: ChangeUserForm,
+ onSubmit: async (newOwnership, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(
+ ids.map((id) => changeOwnership(id, newOwnership))
+ )
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.CHANGE_GROUP,
+ disabled: isDisabled(VM_ACTIONS.CHANGE_GROUP),
+ name: T.ChangeGroup,
+ dialogProps: {
+ title: T.ChangeGroup,
+ subheader: SubHeader,
+ },
+ form: ChangeGroupForm,
+ onSubmit: async (newOwnership, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(
+ ids.map((id) => changeOwnership(id, newOwnership))
+ )
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ ],
},
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => poweroffHard(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.REBOOT,
- disabled: isDisabled(VM_ACTIONS.REBOOT),
- name: T.Reboot,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Reboot,
- children: MessageToConfirmAction
+ {
+ tooltip: T.Lock,
+ icon: Lock,
+ selected: true,
+ color: 'secondary',
+ options: [
+ {
+ accessor: VM_ACTIONS.LOCK,
+ disabled: isDisabled(VM_ACTIONS.LOCK),
+ name: T.Lock,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Lock,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => lock(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.UNLOCK,
+ disabled: isDisabled(VM_ACTIONS.UNLOCK),
+ name: T.Unlock,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Unlock,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => unlock(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ ],
},
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => reboot(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.REBOOT_HARD,
- disabled: isDisabled(VM_ACTIONS.REBOOT_HARD),
- name: T.RebootHard,
- isConfirmDialog: true,
- dialogProps: {
- title: T.RebootHard,
- children: MessageToConfirmAction
+ {
+ tooltip: T.Terminate,
+ icon: Trash,
+ color: 'error',
+ selected: true,
+ options: [
+ {
+ accessor: VM_ACTIONS.TERMINATE,
+ disabled: isDisabled(VM_ACTIONS.TERMINATE),
+ name: T.Terminate,
+ isConfirmDialog: true,
+ dialogProps: {
+ title: T.Terminate,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => terminate(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ {
+ accessor: VM_ACTIONS.TERMINATE_HARD,
+ name: T.TerminateHard,
+ isConfirmDialog: true,
+ disabled: isDisabled(VM_ACTIONS.TERMINATE_HARD),
+ dialogProps: {
+ title: T.TerminateHard,
+ children: MessageToConfirmAction,
+ },
+ onSubmit: async (_, rows) => {
+ const ids = rows?.map?.(({ original }) => original?.ID)
+ await Promise.all(ids.map((id) => terminateHard(id)))
+ await Promise.all(ids.map((id) => getVm(id)))
+ },
+ },
+ ],
},
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => rebootHard(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.UNDEPLOY,
- disabled: isDisabled(VM_ACTIONS.UNDEPLOY),
- name: T.Undeploy,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Undeploy,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => undeploy(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.UNDEPLOY_HARD,
- disabled: isDisabled(VM_ACTIONS.UNDEPLOY_HARD),
- name: T.UndeployHard,
- isConfirmDialog: true,
- dialogProps: {
- title: T.UndeployHard,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => undeployHard(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }]
- },
- {
- tooltip: T.Host,
- icon: TransitionRight,
- selected: true,
- color: 'secondary',
- options: [{
- accessor: VM_ACTIONS.DEPLOY,
- disabled: isDisabled(VM_ACTIONS.DEPLOY),
- name: T.Deploy,
- form: MigrateForm,
- dialogProps: {
- title: T.Deploy,
- subheader: SubHeader
- },
- onSubmit: async (formData, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => deploy(id, formData)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.MIGRATE,
- disabled: isDisabled(VM_ACTIONS.MIGRATE),
- name: T.Migrate,
- form: MigrateForm,
- dialogProps: {
- title: T.Migrate,
- subheader: SubHeader
- },
- onSubmit: async (formData, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => migrate(id, formData)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.MIGRATE_LIVE,
- disabled: isDisabled(VM_ACTIONS.MIGRATE_LIVE),
- name: T.MigrateLive,
- form: MigrateForm,
- dialogProps: {
- title: T.Migrate,
- subheader: SubHeader
- },
- onSubmit: async (formData, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => migrateLive(id, formData)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.HOLD,
- disabled: isDisabled(VM_ACTIONS.HOLD),
- name: T.Hold,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Hold,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => hold(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.RELEASE,
- disabled: isDisabled(VM_ACTIONS.RELEASE),
- name: T.Release,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Release,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => release(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.RESCHED,
- disabled: isDisabled(VM_ACTIONS.RESCHED),
- name: T.Reschedule,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Reschedule,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => resched(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.UNRESCHED,
- disabled: isDisabled(VM_ACTIONS.UNRESCHED),
- name: T.UnReschedule,
- isConfirmDialog: true,
- dialogProps: {
- title: T.UnReschedule,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => unresched(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.RECOVER,
- disabled: isDisabled(VM_ACTIONS.RECOVER),
- name: T.Recover,
- dialogProps: {
- title: T.Recover,
- subheader: SubHeader
- },
- form: RecoverForm,
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => recover(id)))
- ids?.length > 1 && await Promise.all(ids.map(id => getVm(id)))
- }
- }]
- },
- {
- tooltip: T.Ownership,
- icon: Group,
- selected: true,
- color: 'secondary',
- options: [{
- accessor: VM_ACTIONS.CHANGE_OWNER,
- disabled: isDisabled(VM_ACTIONS.CHANGE_OWNER),
- name: T.ChangeOwner,
- dialogProps: {
- title: T.ChangeOwner,
- subheader: SubHeader
- },
- form: ChangeUserForm,
- onSubmit: async (newOwnership, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => changeOwnership(id, newOwnership)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.CHANGE_GROUP,
- disabled: isDisabled(VM_ACTIONS.CHANGE_GROUP),
- name: T.ChangeGroup,
- dialogProps: {
- title: T.ChangeGroup,
- subheader: SubHeader
- },
- form: ChangeGroupForm,
- onSubmit: async (newOwnership, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => changeOwnership(id, newOwnership)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }]
- },
- {
- tooltip: T.Lock,
- icon: Lock,
- selected: true,
- color: 'secondary',
- options: [{
- accessor: VM_ACTIONS.LOCK,
- disabled: isDisabled(VM_ACTIONS.LOCK),
- name: T.Lock,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Lock,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => lock(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.UNLOCK,
- disabled: isDisabled(VM_ACTIONS.UNLOCK),
- name: T.Unlock,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Unlock,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => unlock(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }]
- },
- {
- tooltip: T.Terminate,
- icon: Trash,
- color: 'error',
- selected: true,
- options: [{
- accessor: VM_ACTIONS.TERMINATE,
- disabled: isDisabled(VM_ACTIONS.TERMINATE),
- name: T.Terminate,
- isConfirmDialog: true,
- dialogProps: {
- title: T.Terminate,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => terminate(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }, {
- accessor: VM_ACTIONS.TERMINATE_HARD,
- name: T.TerminateHard,
- isConfirmDialog: true,
- disabled: isDisabled(VM_ACTIONS.TERMINATE_HARD),
- dialogProps: {
- title: T.TerminateHard,
- children: MessageToConfirmAction
- },
- onSubmit: async (_, rows) => {
- const ids = rows?.map?.(({ original }) => original?.ID)
- await Promise.all(ids.map(id => terminateHard(id)))
- await Promise.all(ids.map(id => getVm(id)))
- }
- }]
- }
- ]
- }), [view])
+ ],
+ }),
+ [view]
+ )
return vmActions
}
diff --git a/src/fireedge/src/client/components/Tables/Vms/columns.js b/src/fireedge/src/client/components/Tables/Vms/columns.js
index 95ea21a306..303a8c0a9e 100644
--- a/src/fireedge/src/client/components/Tables/Vms/columns.js
+++ b/src/fireedge/src/client/components/Tables/Vms/columns.js
@@ -22,7 +22,7 @@ export default [
{
Header: 'State',
id: 'STATE',
- accessor: row => VirtualMachineModel.getState(row)?.name
+ accessor: (row) => VirtualMachineModel.getState(row)?.name,
},
{ Header: 'Owner', accessor: 'UNAME' },
{ Header: 'Group', accessor: 'GNAME' },
@@ -32,12 +32,12 @@ export default [
{
Header: 'Ips',
id: 'IPS',
- accessor: row => VirtualMachineModel.getIps(row).join(','),
- sortType: 'length'
+ accessor: (row) => VirtualMachineModel.getIps(row).join(','),
+ sortType: 'length',
},
{
Header: 'Hostname',
id: 'HOSTNAME',
- accessor: row => VirtualMachineModel.getLastHistory(row)?.HOSTNAME
- }
+ accessor: (row) => VirtualMachineModel.getLastHistory(row)?.HOSTNAME,
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/Vms/index.js b/src/fireedge/src/client/components/Tables/Vms/index.js
index 50bc53aaa8..3dcd4c2942 100644
--- a/src/fireedge/src/client/components/Tables/Vms/index.js
+++ b/src/fireedge/src/client/components/Tables/Vms/index.js
@@ -20,7 +20,11 @@ import { useAuth } from 'client/features/Auth'
import { useFetch } from 'client/hooks'
import { useVm, useVmApi } from 'client/features/One'
-import { SkeletonTable, EnhancedTable, EnhancedTableProps } from 'client/components/Tables'
+import {
+ SkeletonTable,
+ EnhancedTable,
+ EnhancedTableProps,
+} from 'client/components/Tables'
import { createColumns } from 'client/components/Tables/Enhanced/Utils'
import VmColumns from 'client/components/Tables/Vms/columns'
import VmRow from 'client/components/Tables/Vms/row'
@@ -28,36 +32,44 @@ import VmRow from 'client/components/Tables/Vms/row'
const INITIAL_ELEMENT = 0
const INTERVAL_ON_FIRST_RENDER = 2_000
-const VmsTable = props => {
+const VmsTable = (props) => {
const vms = useVm()
const { getVms } = useVmApi()
const { view, getResourceView, filterPool } = useAuth()
- const columns = useMemo(() => createColumns({
- filters: getResourceView('VM')?.filters,
- columns: VmColumns
- }), [view])
+ const columns = useMemo(
+ () =>
+ createColumns({
+ filters: getResourceView('VM')?.filters,
+ columns: VmColumns,
+ }),
+ [view]
+ )
- const { status, data, fetchRequest, loading, reloading, error, STATUS } = useFetch(getVms)
+ const { status, data, fetchRequest, loading, reloading, error, STATUS } =
+ useFetch(getVms)
const { INIT, PENDING } = STATUS
useEffect(() => {
const requests = {
- INIT: () => fetchRequest({
- start: INITIAL_ELEMENT,
- end: -INTERVAL_ON_FIRST_RENDER,
- state: -1 // Any state, except DONE
- }),
+ INIT: () =>
+ fetchRequest({
+ start: INITIAL_ELEMENT,
+ end: -INTERVAL_ON_FIRST_RENDER,
+ state: -1, // Any state, except DONE
+ }),
FETCHED: () => {
- const canFetchMore = !error && data?.vms?.length === INTERVAL_ON_FIRST_RENDER
+ const canFetchMore =
+ !error && data?.vms?.length === INTERVAL_ON_FIRST_RENDER
// fetch the rest of VMs, from 0 to last VM ID fetched
- canFetchMore && fetchRequest({
- start: INITIAL_ELEMENT,
- end: data?.vms[INTERVAL_ON_FIRST_RENDER - 1]?.ID,
- state: -1 // Any state, except DONE
- })
- }
+ canFetchMore &&
+ fetchRequest({
+ start: INITIAL_ELEMENT,
+ end: data?.vms[INTERVAL_ON_FIRST_RENDER - 1]?.ID,
+ state: -1, // Any state, except DONE
+ })
+ },
}
requests[status]?.()
@@ -72,7 +84,7 @@ const VmsTable = props => {
columns={columns}
data={vms}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={VmRow}
{...props}
/>
diff --git a/src/fireedge/src/client/components/Tables/Vms/row.js b/src/fireedge/src/client/components/Tables/Vms/row.js
index a83c35e153..4c1dbed067 100644
--- a/src/fireedge/src/client/components/Tables/Vms/row.js
+++ b/src/fireedge/src/client/components/Tables/Vms/row.js
@@ -28,12 +28,23 @@ import * as Helper from 'client/models/Helper'
const Row = ({ original, value, ...props }) => {
const classes = rowStyles()
- const { ID, NAME, UNAME, GNAME, IPS, STIME, ETIME, HOSTNAME = '--', LOCK } = value
+ const {
+ ID,
+ NAME,
+ UNAME,
+ GNAME,
+ IPS,
+ STIME,
+ ETIME,
+ HOSTNAME = '--',
+ LOCK,
+ } = value
const time = Helper.timeFromMilliseconds(+ETIME || +STIME)
const timeAgo = `${+ETIME ? 'done' : 'started'} ${time.toRelative()}`
- const { color: stateColor, name: stateName } = VirtualMachineModel.getState(original)
+ const { color: stateColor, name: stateName } =
+ VirtualMachineModel.getState(original)
return (
@@ -42,17 +53,13 @@ const Row = ({ original, value, ...props }) => {
-
+
{NAME}
-
- {LOCK && }
-
+ {LOCK && }
-
- {`#${ID} ${timeAgo}`}
-
+ {`#${ID} ${timeAgo}`}
{` ${UNAME}`}
@@ -69,7 +76,7 @@ const Row = ({ original, value, ...props }) => {
{!!IPS?.length && (
-
+
@@ -82,7 +89,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/Zones/columns.js b/src/fireedge/src/client/components/Tables/Zones/columns.js
index 58635b5062..b7a6cf2a62 100644
--- a/src/fireedge/src/client/components/Tables/Zones/columns.js
+++ b/src/fireedge/src/client/components/Tables/Zones/columns.js
@@ -23,20 +23,20 @@ export default [
{
Header: 'State',
id: 'STATE',
- accessor: row => ZoneModel.getState(row)?.name,
+ accessor: (row) => ZoneModel.getState(row)?.name,
disableFilters: false,
- Filter: ({ column }) => CategoryFilter({
- column,
- multiple: true,
- title: 'State'
- }),
- filter: 'includesValue'
+ Filter: ({ column }) =>
+ CategoryFilter({
+ column,
+ multiple: true,
+ title: 'State',
+ }),
+ filter: 'includesValue',
},
{
Header: 'ENDPOINT',
id: 'ENDPOINT',
- accessor: row => row?.TEMPLATE?.ENDPOINT,
- disableSortBy: true
- }
-
+ accessor: (row) => row?.TEMPLATE?.ENDPOINT,
+ disableSortBy: true,
+ },
]
diff --git a/src/fireedge/src/client/components/Tables/Zones/index.js b/src/fireedge/src/client/components/Tables/Zones/index.js
index a059c8fcf1..3a7039df63 100644
--- a/src/fireedge/src/client/components/Tables/Zones/index.js
+++ b/src/fireedge/src/client/components/Tables/Zones/index.js
@@ -29,10 +29,13 @@ const ZonesTable = () => {
const zones = useZone()
const { getZones } = useZoneApi()
- const { status, fetchRequest, loading, reloading, STATUS } = useFetch(getZones)
+ const { status, fetchRequest, loading, reloading, STATUS } =
+ useFetch(getZones)
const { INIT, PENDING } = STATUS
- useEffect(() => { fetchRequest() }, [])
+ useEffect(() => {
+ fetchRequest()
+ }, [])
if (zones?.length === 0 && [INIT, PENDING].includes(status)) {
return
@@ -43,7 +46,7 @@ const ZonesTable = () => {
columns={columns}
data={zones}
isLoading={loading || reloading}
- getRowId={row => String(row.ID)}
+ getRowId={(row) => String(row.ID)}
RowComponent={ZoneRow}
/>
)
diff --git a/src/fireedge/src/client/components/Tables/Zones/row.js b/src/fireedge/src/client/components/Tables/Zones/row.js
index afc9b1b622..65794f8501 100644
--- a/src/fireedge/src/client/components/Tables/Zones/row.js
+++ b/src/fireedge/src/client/components/Tables/Zones/row.js
@@ -37,14 +37,10 @@ const Row = ({ original, value, ...props }) => {
-
- {NAME}
-
+ {NAME}
-
- {`#${ID}`}
-
+
{`#${ID}`}
{` ${ENDPOINT}`}
@@ -59,7 +55,7 @@ Row.propTypes = {
original: PropTypes.object,
value: PropTypes.object,
isSelected: PropTypes.bool,
- handleClick: PropTypes.func
+ handleClick: PropTypes.func,
}
export default Row
diff --git a/src/fireedge/src/client/components/Tables/index.js b/src/fireedge/src/client/components/Tables/index.js
index ed4f43aa5c..e262b0c936 100644
--- a/src/fireedge/src/client/components/Tables/index.js
+++ b/src/fireedge/src/client/components/Tables/index.js
@@ -15,7 +15,9 @@
* ------------------------------------------------------------------------- */
import ClustersTable from 'client/components/Tables/Clusters'
import DatastoresTable from 'client/components/Tables/Datastores'
-import EnhancedTable, { EnhancedTableProps } from 'client/components/Tables/Enhanced'
+import EnhancedTable, {
+ EnhancedTableProps,
+} from 'client/components/Tables/Enhanced'
import GroupsTable from 'client/components/Tables/Groups'
import HostsTable from 'client/components/Tables/Hosts'
import ImagesTable from 'client/components/Tables/Images'
@@ -36,7 +38,6 @@ export {
EnhancedTable,
EnhancedTableProps,
VirtualizedTable,
-
ClustersTable,
DatastoresTable,
GroupsTable,
@@ -50,5 +51,5 @@ export {
VNetworksTable,
VNetworkTemplatesTable,
VRoutersTable,
- ZonesTable
+ ZonesTable,
}
diff --git a/src/fireedge/src/client/components/Tables/styles.js b/src/fireedge/src/client/components/Tables/styles.js
index 0a9d30ac4a..24e3876781 100644
--- a/src/fireedge/src/client/components/Tables/styles.js
+++ b/src/fireedge/src/client/components/Tables/styles.js
@@ -28,14 +28,14 @@ export const rowStyles = makeStyles(
gap: 8,
boxShadow: shadows[1],
[breakpoints.down('md')]: {
- flexWrap: 'wrap'
- }
+ flexWrap: 'wrap',
+ },
},
figure: {
flexBasis: '20%',
paddingTop: '12.5%',
overflow: 'hidden',
- position: 'relative'
+ position: 'relative',
},
image: {
top: 0,
@@ -44,12 +44,12 @@ export const rowStyles = makeStyles(
height: '100%',
objectFit: 'contain',
position: 'absolute',
- userSelect: 'none'
+ userSelect: 'none',
},
main: {
flex: 'auto',
overflow: 'hidden',
- alignSelf: 'start'
+ alignSelf: 'start',
},
title: {
color: palette.text.primary,
@@ -57,11 +57,11 @@ export const rowStyles = makeStyles(
gap: 6,
alignItems: 'center',
flexWrap: 'wrap',
- marginBottom: 8
+ marginBottom: 8,
},
labels: {
display: 'inline-flex',
- gap: 6
+ gap: 6,
},
caption: {
...typography.caption,
@@ -72,8 +72,8 @@ export const rowStyles = makeStyles(
flexWrap: 'wrap',
wordWrap: 'break-word',
'& > .full-width': {
- flexBasis: '100%'
- }
+ flexBasis: '100%',
+ },
},
secondary: {
width: '25%',
@@ -81,15 +81,15 @@ export const rowStyles = makeStyles(
whiteSpace: 'nowrap',
textAlign: 'right',
[breakpoints.down('sm')]: {
- display: 'none'
+ display: 'none',
},
'& > *': {
flexShrink: 0,
- whiteSpace: 'nowrap'
- }
+ whiteSpace: 'nowrap',
+ },
},
actions: {
- flexShrink: 0
- }
+ flexShrink: 0,
+ },
})
)
diff --git a/src/fireedge/src/client/components/Tabs/Cluster/Info/index.js b/src/fireedge/src/client/components/Tabs/Cluster/Info/index.js
index 4e3ac0cd58..b2b9722aa6 100644
--- a/src/fireedge/src/client/components/Tabs/Cluster/Info/index.js
+++ b/src/fireedge/src/client/components/Tabs/Cluster/Info/index.js
@@ -32,14 +32,14 @@ const HIDDEN_ATTRIBUTES_REG = /^(HOST|RESERVED_CPU|RESERVED_MEM)$/
const ClusterInfoTab = ({ tabProps = {} }) => {
const {
information_panel: informationPanel,
- attributes_panel: attributesPanel
+ attributes_panel: attributesPanel,
} = tabProps
const { rename, update } = useClusterApi()
const { handleRefetch, data: cluster = {} } = useContext(TabContext)
const { ID, TEMPLATE } = cluster
- const handleRename = async newName => {
+ const handleRename = async (newName) => {
const response = await rename(ID, newName)
String(response) === String(ID) && (await handleRefetch?.())
}
@@ -57,23 +57,27 @@ const ClusterInfoTab = ({ tabProps = {} }) => {
String(response) === String(ID) && (await handleRefetch?.())
}
- const getActions = actions => Helper.getActionsAvailable(actions)
+ const getActions = (actions) => Helper.getActionsAvailable(actions)
- const { attributes } = Helper.filterAttributes(TEMPLATE, { hidden: HIDDEN_ATTRIBUTES_REG })
+ const { attributes } = Helper.filterAttributes(TEMPLATE, {
+ hidden: HIDDEN_ATTRIBUTES_REG,
+ })
const ATTRIBUTE_FUNCTION = {
handleAdd: handleAttributeInXml,
handleEdit: handleAttributeInXml,
- handleDelete: handleAttributeInXml
+ handleDelete: handleAttributeInXml,
}
return (
-
+
{informationPanel?.enabled && (
{
}
ClusterInfoTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
ClusterInfoTab.displayName = 'ClusterInfoTab'
diff --git a/src/fireedge/src/client/components/Tabs/Cluster/Info/information.js b/src/fireedge/src/client/components/Tabs/Cluster/Info/information.js
index d785bdf0c1..e126460a84 100644
--- a/src/fireedge/src/client/components/Tabs/Cluster/Info/information.js
+++ b/src/fireedge/src/client/components/Tabs/Cluster/Info/information.js
@@ -30,13 +30,13 @@ const InformationPanel = ({ cluster = {}, handleRename, actions }) => {
name: T.Name,
value: NAME,
canEdit: actions?.includes?.(CLUSTER_ACTIONS.RENAME),
- handleEdit: handleRename
- }
+ handleEdit: handleRename,
+ },
]
const overcommitment = [
{ name: T.ReservedMemory, value: RESERVED_MEM },
- { name: T.ReservedCpu, value: RESERVED_CPU }
+ { name: T.ReservedCpu, value: RESERVED_CPU },
]
return (
@@ -52,7 +52,7 @@ InformationPanel.displayName = 'InformationPanel'
InformationPanel.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
handleRename: PropTypes.func,
- cluster: PropTypes.object
+ cluster: PropTypes.object,
}
export default InformationPanel
diff --git a/src/fireedge/src/client/components/Tabs/Cluster/index.js b/src/fireedge/src/client/components/Tabs/Cluster/index.js
index 55f77c9f8d..23c0222f65 100644
--- a/src/fireedge/src/client/components/Tabs/Cluster/index.js
+++ b/src/fireedge/src/client/components/Tabs/Cluster/index.js
@@ -28,9 +28,10 @@ import { camelCase } from 'client/utils'
import TabProvider from 'client/components/Tabs/TabProvider'
import Info from 'client/components/Tabs/Cluster/Info'
-const getTabComponent = tabName => ({
- info: Info
-}[tabName])
+const getTabComponent = (tabName) =>
+ ({
+ info: Info,
+ }[tabName])
const ClusterTabs = memo(({ id }) => {
const { getCluster } = useClusterApi()
@@ -48,22 +49,26 @@ const ClusterTabs = memo(({ id }) => {
useEffect(() => {
const infoTabs = getResourceView('CLUSTER')?.['info-tabs'] ?? {}
- setTabs(() => Object.entries(infoTabs)
- ?.filter(([_, { enabled } = {}]) => !!enabled)
- ?.map(([tabName, tabProps]) => {
- const camelName = camelCase(tabName)
- const TabContent = getTabComponent(camelName)
+ setTabs(() =>
+ Object.entries(infoTabs)
+ ?.filter(([_, { enabled } = {}]) => !!enabled)
+ ?.map(([tabName, tabProps]) => {
+ const camelName = camelCase(tabName)
+ const TabContent = getTabComponent(camelName)
- return TabContent && {
- name: camelName,
- renderContent: props => TabContent({ ...props, tabProps })
- }
- })
- ?.filter(Boolean))
+ return (
+ TabContent && {
+ name: camelName,
+ renderContent: (props) => TabContent({ ...props, tabProps }),
+ }
+ )
+ })
+ ?.filter(Boolean)
+ )
}, [view])
if ((!data && !error) || loading) {
- return
+ return
}
return (
@@ -74,7 +79,7 @@ const ClusterTabs = memo(({ id }) => {
})
ClusterTabs.propTypes = {
- id: PropTypes.string.isRequired
+ id: PropTypes.string.isRequired,
}
ClusterTabs.displayName = 'ClusterTabs'
diff --git a/src/fireedge/src/client/components/Tabs/Common/Attribute/Actions.js b/src/fireedge/src/client/components/Tabs/Common/Attribute/Actions.js
index 6fe3f91963..a5a7de9bf0 100644
--- a/src/fireedge/src/client/components/Tabs/Common/Attribute/Actions.js
+++ b/src/fireedge/src/client/components/Tabs/Common/Attribute/Actions.js
@@ -22,7 +22,7 @@ import {
Edit as EditIcon,
Trash as DeleteIcon,
Check as AcceptIcon,
- Cancel as CancelIcon
+ Cancel as CancelIcon,
} from 'iconoir-react'
import { useClipboard } from 'client/hooks'
@@ -36,7 +36,8 @@ import { T } from 'client/constants'
* @param {string} attr - Attribute name
* @returns {string} Merge action and attributes name
*/
-const getAttributeCy = (action, attr) => `${action}-${camelCase(attr.toLowerCase())}`
+const getAttributeCy = (action, attr) =>
+ `${action}-${camelCase(attr.toLowerCase())}`
/**
* @typedef {object} ActionButtonProps
@@ -54,12 +55,7 @@ const ActionButton = ({ action, name, icon: Icon, handleClick, ...props }) => {
const dataCy = useMemo(() => getAttributeCy(action, name), [name])
return (
- }
- handleClick={handleClick}
- {...props}
- />
+ } handleClick={handleClick} {...props} />
)
}
@@ -67,72 +63,79 @@ ActionButton.propTypes = {
action: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
icon: PropTypes.object.isRequired,
- handleClick: PropTypes.func.isRequired
+ handleClick: PropTypes.func.isRequired,
}
/**
* @param {ActionButtonProps} props - Action button props
* @returns {JSXElementConstructor} Action button with props
*/
-const Copy = memo(({ value, ...props }) => {
- const { copy, isCopied } = useClipboard(1000)
+const Copy = memo(
+ ({ value, ...props }) => {
+ const { copy, isCopied } = useClipboard(1000)
- return (
- {'✔️'}>}
- tooltipProps={{ open: isCopied }}
- handleClick={async () => await copy(value)}
- icon={CopyIcon}
- {...props}
- />
- )
-}, (prev, next) => prev.value === next.value)
+ return (
+
+ {'✔️'}
+
+ >
+ }
+ tooltipProps={{ open: isCopied }}
+ handleClick={async () => await copy(value)}
+ icon={CopyIcon}
+ {...props}
+ />
+ )
+ },
+ (prev, next) => prev.value === next.value
+)
/**
* @param {ActionButtonProps} props - Action button props
* @returns {JSXElementConstructor} Action button with props
*/
-const Add = props =>
+const Add = (props) =>
/**
* @param {ActionButtonProps} props - Action button props
* @returns {JSXElementConstructor} Action button with props
*/
-const Edit = props =>
+const Edit = (props) => (
+
+)
/**
* @param {ActionButtonProps} props - Action button props
* @returns {JSXElementConstructor} Action button with props
*/
-const Delete = props =>
+const Delete = (props) => (
+
+)
/**
* @param {ActionButtonProps} props - Action button props
* @returns {JSXElementConstructor} Action button with props
*/
-const Accept = props =>
+const Accept = (props) => (
+
+)
/**
* @param {ActionButtonProps} props - Action button props
* @returns {JSXElementConstructor} Action button with props
*/
-const Cancel = props =>
+const Cancel = (props) => (
+
+)
Copy.displayName = 'CopyActionButton'
Copy.propTypes = {
name: PropTypes.string.isRequired,
- value: PropTypes.string
+ value: PropTypes.string,
}
-export {
- getAttributeCy,
- ActionButton,
- Copy,
- Add,
- Accept,
- Cancel,
- Delete,
- Edit
-}
+export { getAttributeCy, ActionButton, Copy, Add, Accept, Cancel, Delete, Edit }
diff --git a/src/fireedge/src/client/components/Tabs/Common/Attribute/Attribute.js b/src/fireedge/src/client/components/Tabs/Common/Attribute/Attribute.js
index fad7eca4c6..306c096025 100644
--- a/src/fireedge/src/client/components/Tabs/Common/Attribute/Attribute.js
+++ b/src/fireedge/src/client/components/Tabs/Common/Attribute/Attribute.js
@@ -26,145 +26,149 @@ import { Actions, Inputs } from 'client/components/Tabs/Common/Attribute'
import { Translate } from 'client/components/HOC'
import { T } from 'client/constants'
-const Column = props => (
- (
+ .actions': { display: 'contents' } }}
{...props}
/>
)
-const ActionWrapper = props => (
-
+const ActionWrapper = (props) => (
+
)
-const Attribute = memo(({
- canCopy = false,
- canDelete,
- canEdit,
- handleDelete,
- handleEdit,
- handleGetOptionList,
- link,
- name,
- path = name,
- showActionsOnHover = false,
- value,
- valueInOptionList
-}) => {
- const numberOfParents = useMemo(() => path.split('.').length - 1, [path])
+const Attribute = memo(
+ ({
+ canCopy = false,
+ canDelete,
+ canEdit,
+ handleDelete,
+ handleEdit,
+ handleGetOptionList,
+ link,
+ name,
+ path = name,
+ showActionsOnHover = false,
+ value,
+ valueInOptionList,
+ }) => {
+ const numberOfParents = useMemo(() => path.split('.').length - 1, [path])
- const [isEditing, setIsEditing] = useState(() => false)
- const [options, setOptions] = useState(() => [])
- const { display, show, hide } = useDialog()
- const inputRef = createRef()
+ const [isEditing, setIsEditing] = useState(() => false)
+ const [options, setOptions] = useState(() => [])
+ const { display, show, hide } = useDialog()
+ const inputRef = createRef()
- const handleEditAttribute = async () => {
- await handleEdit?.(path, inputRef.current.value)
- setIsEditing(false)
- }
-
- const handleCancel = () => setIsEditing(false)
-
- const handleActiveEditForm = async () => {
- const response = (await handleGetOptionList?.()) ?? []
- const isFormatValid = response?.every?.(({ text, value } = {}) => !!text && !!value)
-
- if (!handleGetOptionList || isFormatValid) {
- setOptions(response)
- setIsEditing(true)
+ const handleEditAttribute = async () => {
+ await handleEdit?.(path, inputRef.current.value)
+ setIsEditing(false)
}
- }
- const handleDeleteAttribute = async () => {
- try {
- await handleDelete?.(path)
- } finally {
- hide()
+ const handleCancel = () => setIsEditing(false)
+
+ const handleActiveEditForm = async () => {
+ const response = (await handleGetOptionList?.()) ?? []
+ const isFormatValid = response?.every?.(
+ ({ text, value } = {}) => !!text && !!value
+ )
+
+ if (!handleGetOptionList || isFormatValid) {
+ setOptions(response)
+ setIsEditing(true)
+ }
}
- }
- return (
- <>
-
- 0 ? { pl: `${numberOfParents}em` } : undefined}
- >
- {name}
-
-
- {canCopy && }
-
-
-
- {isEditing ? (
- <>
- {handleGetOptionList ? (
-
- ) : (
-
- )}
-
-
- >
- ) : (
- <>
-
- {link
- ? (
-
+ const handleDeleteAttribute = async () => {
+ try {
+ await handleDelete?.(path)
+ } finally {
+ hide()
+ }
+ }
+
+ return (
+ <>
+
+ 0 ? { pl: `${numberOfParents}em` } : undefined
+ }
+ >
+ {name}
+
+
+ {canCopy && }
+
+
+
+ {isEditing ? (
+ <>
+ {handleGetOptionList ? (
+
+ ) : (
+
+ )}
+
+
+ >
+ ) : (
+ <>
+
+ {link ? (
+
{value}
- )
- : value
- }
-
-
- {value && canCopy && (
-
- )}
- {(value || numberOfParents > 0) && canEdit && (
-
- )}
- {canDelete && (
-
- )}
-
- >
- )}
+ ) : (
+ value
+ )}
+
+
+ {value && canCopy && }
+ {(value || numberOfParents > 0) && canEdit && (
+
+ )}
+ {canDelete && }
+
+ >
+ )}
- {display && (
- }
- handleAccept={handleDeleteAttribute}
- handleCancel={hide}
- >
-
-
-
-
- )}
-
- >
- )
-})
+ {display && (
+ }
+ handleAccept={handleDeleteAttribute}
+ handleCancel={hide}
+ >
+
+
+
+
+ )}
+
+ >
+ )
+ }
+)
export const AttributePropTypes = {
canCopy: PropTypes.bool,
@@ -177,11 +181,8 @@ export const AttributePropTypes = {
name: PropTypes.string.isRequired,
path: PropTypes.string,
showActionsOnHover: PropTypes.bool,
- value: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.object
- ]),
- valueInOptionList: PropTypes.string
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
+ valueInOptionList: PropTypes.string,
}
Attribute.propTypes = AttributePropTypes
diff --git a/src/fireedge/src/client/components/Tabs/Common/Attribute/Inputs.js b/src/fireedge/src/client/components/Tabs/Common/Attribute/Inputs.js
index 308796474b..2e90c6708e 100644
--- a/src/fireedge/src/client/components/Tabs/Common/Attribute/Inputs.js
+++ b/src/fireedge/src/client/components/Tabs/Common/Attribute/Inputs.js
@@ -13,7 +13,12 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { forwardRef, useState, ForwardedRef, JSXElementConstructor } from 'react'
+import {
+ forwardRef,
+ useState,
+ ForwardedRef,
+ JSXElementConstructor,
+} from 'react'
import PropTypes from 'prop-types'
import { TextField } from '@mui/material'
@@ -36,8 +41,8 @@ import { Actions } from 'client/components/Tabs/Common/Attribute'
const useStyles = makeStyles({
select: {
- textOverflow: 'ellipsis'
- }
+ textOverflow: 'ellipsis',
+ },
})
const Select = forwardRef(
@@ -50,13 +55,13 @@ const Select = forwardRef(
const classes = useStyles()
const [newValue, setNewValue] = useState(() => initialValue)
- const handleChange = event => setNewValue(event.target.value)
+ const handleChange = (event) => setNewValue(event.target.value)
return (
{
const [newValue, setNewValue] = useState(() => initialValue)
- const handleChange = event => setNewValue(event.target.value)
+ const handleChange = (event) => setNewValue(event.target.value)
return (
*:first-child': {
- flexGrow: 1
- }
- }
+ flexGrow: 1,
+ },
+ },
})
const AttributeCreateForm = memo(({ handleAdd }) => {
@@ -39,16 +39,13 @@ const AttributeCreateForm = memo(({ handleAdd }) => {
const valueInputKey = useMemo(() => `value-${key}`, [key])
const { handleSubmit, reset, control } = useForm({
- defaultValues: { [nameInputKey]: '', [valueInputKey]: '' }
+ defaultValues: { [nameInputKey]: '', [valueInputKey]: '' },
})
- const handleCreateAttribute = async data => {
+ const handleCreateAttribute = async (data) => {
const { [nameInputKey]: name, [valueInputKey]: value } = data
- await handleAdd?.(
- String(name).toUpperCase(),
- String(value).toUpperCase()
- )
+ await handleAdd?.(String(name).toUpperCase(), String(value).toUpperCase())
reset()
}
@@ -59,9 +56,9 @@ const AttributeCreateForm = memo(({ handleAdd }) => {
+ render={({ field, formState }) => (
- }
+ )}
/>
{/* VALUE ATTRIBUTE */}
@@ -69,9 +66,9 @@ const AttributeCreateForm = memo(({ handleAdd }) => {
+ render={({ field, formState }) => (
- }
+ )}
/>
{
})
AttributeCreateForm.propTypes = {
- handleAdd: PropTypes.func
+ handleAdd: PropTypes.func,
}
AttributeCreateForm.displayName = 'AttributeCreateForm'
diff --git a/src/fireedge/src/client/components/Tabs/Common/AttributePanel.js b/src/fireedge/src/client/components/Tabs/Common/AttributePanel.js
index 050662ef3c..6ebcf28b4b 100644
--- a/src/fireedge/src/client/components/Tabs/Common/AttributePanel.js
+++ b/src/fireedge/src/client/components/Tabs/Common/AttributePanel.js
@@ -39,86 +39,92 @@ const {
COPY_ATTRIBUTE: COPY,
ADD_ATTRIBUTE: ADD,
EDIT_ATTRIBUTE: EDIT,
- DELETE_ATTRIBUTE: DELETE
+ DELETE_ATTRIBUTE: DELETE,
} = ACTIONS
// This attributes has special restrictions
const SPECIAL_ATTRIBUTES = {
VCENTER_CCR_REF: {
[EDIT]: false,
- [DELETE]: false
+ [DELETE]: false,
},
VCENTER_HOST: {
[EDIT]: false,
- [DELETE]: false
+ [DELETE]: false,
},
VCENTER_INSTANCE_ID: {
[EDIT]: false,
- [DELETE]: false
+ [DELETE]: false,
},
VCENTER_PASSWORD: {
- [DELETE]: false
+ [DELETE]: false,
},
VCENTER_USER: {
[EDIT]: false,
- [DELETE]: false
+ [DELETE]: false,
},
VCENTER_VERSION: {
[EDIT]: false,
- [DELETE]: false
- }
+ [DELETE]: false,
+ },
}
const useStyles = makeStyles({
container: {
- gridColumn: '1 / -1'
+ gridColumn: '1 / -1',
},
item: {
'& > *:first-child': {
- flex: '1 1 20%'
- }
+ flex: '1 1 20%',
+ },
+ },
+})
+
+const AttributePanel = memo(
+ ({
+ title,
+ attributes = {},
+ handleEdit,
+ handleDelete,
+ handleAdd,
+ actions = [],
+ filtersSpecialAttributes = true,
+ }) => {
+ const classes = useStyles()
+
+ const canUseAction = useCallback(
+ (name, action) =>
+ actions?.includes?.(action) &&
+ (!filtersSpecialAttributes ||
+ SPECIAL_ATTRIBUTES[name]?.[action] === undefined),
+ [actions?.length]
+ )
+
+ const formatAttributes = Object.entries(attributes).map(
+ ([name, value]) => ({
+ name,
+ value,
+ showActionsOnHover: true,
+ canCopy: canUseAction(name, COPY),
+ canEdit: canUseAction(name, EDIT),
+ canDelete: canUseAction(name, DELETE),
+ handleEdit,
+ handleDelete,
+ })
+ )
+
+ return (
+
+ )
}
-})
-
-const AttributePanel = memo(({
- title,
- attributes = {},
- handleEdit,
- handleDelete,
- handleAdd,
- actions = [],
- filtersSpecialAttributes = true
-}) => {
- const classes = useStyles()
-
- const canUseAction = useCallback((name, action) => (
- actions?.includes?.(action) &&
- (!filtersSpecialAttributes || SPECIAL_ATTRIBUTES[name]?.[action] === undefined)
- ), [actions?.length])
-
- const formatAttributes = Object.entries(attributes)
- .map(([name, value]) => ({
- name,
- value,
- showActionsOnHover: true,
- canCopy: canUseAction(name, COPY),
- canEdit: canUseAction(name, EDIT),
- canDelete: canUseAction(name, DELETE),
- handleEdit,
- handleDelete
- }))
-
- return (
-
- )
-})
+)
AttributePanel.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
@@ -127,7 +133,7 @@ AttributePanel.propTypes = {
handleEdit: PropTypes.func,
handleDelete: PropTypes.func,
title: PropTypes.string,
- filtersSpecialAttributes: PropTypes.bool
+ filtersSpecialAttributes: PropTypes.bool,
}
AttributePanel.displayName = 'AttributePanel'
diff --git a/src/fireedge/src/client/components/Tabs/Common/List.js b/src/fireedge/src/client/components/Tabs/Common/List.js
index 94d5d25c3f..3349bc38c9 100644
--- a/src/fireedge/src/client/components/Tabs/Common/List.js
+++ b/src/fireedge/src/client/components/Tabs/Common/List.js
@@ -18,18 +18,27 @@ import { Fragment, isValidElement } from 'react'
import PropTypes from 'prop-types'
import clsx from 'clsx'
-import { List as MList, ListItem, Typography, Paper, alpha } from '@mui/material'
+import {
+ List as MList,
+ ListItem,
+ Typography,
+ Paper,
+ alpha,
+} from '@mui/material'
import makeStyles from '@mui/styles/makeStyles'
-import { Attribute, AttributePropTypes } from 'client/components/Tabs/Common/Attribute'
+import {
+ Attribute,
+ AttributePropTypes,
+} from 'client/components/Tabs/Common/Attribute'
import AttributeCreateForm from 'client/components/Tabs/Common/AttributeCreateForm'
import { Tr } from 'client/components/HOC'
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles((theme) => ({
title: {
fontWeight: theme.typography.fontWeightBold,
- borderBottom: `1px solid ${theme.palette.divider}`
+ borderBottom: `1px solid ${theme.palette.divider}`,
},
item: {
height: '2.4em',
@@ -37,13 +46,13 @@ const useStyles = makeStyles(theme => ({
'& > *': {
flex: '1 1 50%',
overflow: 'hidden',
- minHeight: '100%'
+ minHeight: '100%',
},
'&:hover': {
- backgroundColor: alpha(theme.palette.text.primary, 0.05)
- }
+ backgroundColor: alpha(theme.palette.text.primary, 0.05),
+ },
},
- typo: theme.typography.body2
+ typo: theme.typography.body2,
}))
const AttributeList = ({
@@ -53,7 +62,7 @@ const AttributeList = ({
containerProps = {},
itemProps = {},
listProps = {},
- subListProps = {}
+ subListProps = {},
}) => {
const classes = useStyles()
const { className: itemClassName, ...restOfItemProps } = itemProps
@@ -71,13 +80,17 @@ const AttributeList = ({
{isParent && (
{Object.entries(value).map(([childName, childValue]) => {
- const subAttributeProps = { ...attribute, name: childName, value: childValue }
+ const subAttributeProps = {
+ ...attribute,
+ name: childName,
+ value: childValue,
+ }
const attributePath = `${parentPath || name}.${childName}`
return renderList(subAttributeProps, attributePath)
@@ -89,18 +102,16 @@ const AttributeList = ({
}
return (
-
+
{/* TITLE */}
{title && (
-
- {Tr(title)}
-
+ {Tr(title)}
)}
{/* LIST */}
- {list.map(attr => renderList(attr))}
+ {list.map((attr) => renderList(attr))}
{/* ADD ACTION */}
{handleAdd && (
@@ -114,17 +125,12 @@ const AttributeList = ({
AttributeList.propTypes = {
containerProps: PropTypes.object,
- handleAdd: PropTypes.oneOfType([
- PropTypes.func,
- PropTypes.bool
- ]),
+ handleAdd: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
itemProps: PropTypes.object,
title: PropTypes.any,
- list: PropTypes.arrayOf(
- PropTypes.shape(AttributePropTypes)
- ),
+ list: PropTypes.arrayOf(PropTypes.shape(AttributePropTypes)),
listProps: PropTypes.object,
- subListProps: PropTypes.object
+ subListProps: PropTypes.object,
}
AttributeList.displayName = 'AttributeList'
diff --git a/src/fireedge/src/client/components/Tabs/Common/Ownership.js b/src/fireedge/src/client/components/Tabs/Common/Ownership.js
index 233ea6c4ed..3f767a3290 100644
--- a/src/fireedge/src/client/components/Tabs/Common/Ownership.js
+++ b/src/fireedge/src/client/components/Tabs/Common/Ownership.js
@@ -22,61 +22,52 @@ import { List } from 'client/components/Tabs/Common'
import { T, SERVERADMIN_ID, ACTIONS } from 'client/constants'
import { PATH } from 'client/apps/sunstone/routesOne'
-const Ownership = memo(({
- actions,
- groupId,
- groupName,
- handleEdit,
- userId,
- userName
-}) => {
- const { getUsers } = useUserApi()
- const { getGroups } = useGroupApi()
+const Ownership = memo(
+ ({ actions, groupId, groupName, handleEdit, userId, userName }) => {
+ const { getUsers } = useUserApi()
+ const { getGroups } = useGroupApi()
- const getUserOptions = async () => {
- const response = await getUsers()
+ const getUserOptions = async () => {
+ const response = await getUsers()
- return response
- ?.[RESOURCES.user]
- ?.filter?.(({ ID } = {}) => ID !== SERVERADMIN_ID)
- ?.map?.(({ ID, NAME } = {}) => ({ text: NAME, value: ID })
- )
- }
-
- const getGroupOptions = async () => {
- const response = await getGroups()
-
- return response
- ?.[RESOURCES.group]
- ?.map?.(({ ID, NAME } = {}) => ({ text: NAME, value: ID })
- )
- }
-
- const ownership = [
- {
- name: T.Owner,
- value: userName,
- valueInOptionList: userId,
- link: generatePath(PATH.SYSTEM.USERS.DETAIL, { id: userId }),
- canEdit: actions?.includes?.(ACTIONS.CHANGE_OWNER),
- handleGetOptionList: getUserOptions,
- handleEdit: (_, user) => handleEdit?.({ user })
- },
- {
- name: T.Group,
- value: groupName,
- valueInOptionList: groupId,
- link: generatePath(PATH.SYSTEM.GROUPS.DETAIL, { id: groupId }),
- canEdit: actions?.includes?.(ACTIONS.CHANGE_GROUP),
- handleGetOptionList: getGroupOptions,
- handleEdit: (_, group) => handleEdit?.({ group })
+ return response?.[RESOURCES.user]
+ ?.filter?.(({ ID } = {}) => ID !== SERVERADMIN_ID)
+ ?.map?.(({ ID, NAME } = {}) => ({ text: NAME, value: ID }))
}
- ]
- return (
-
- )
-})
+ const getGroupOptions = async () => {
+ const response = await getGroups()
+
+ return response?.[RESOURCES.group]?.map?.(({ ID, NAME } = {}) => ({
+ text: NAME,
+ value: ID,
+ }))
+ }
+
+ const ownership = [
+ {
+ name: T.Owner,
+ value: userName,
+ valueInOptionList: userId,
+ link: generatePath(PATH.SYSTEM.USERS.DETAIL, { id: userId }),
+ canEdit: actions?.includes?.(ACTIONS.CHANGE_OWNER),
+ handleGetOptionList: getUserOptions,
+ handleEdit: (_, user) => handleEdit?.({ user }),
+ },
+ {
+ name: T.Group,
+ value: groupName,
+ valueInOptionList: groupId,
+ link: generatePath(PATH.SYSTEM.GROUPS.DETAIL, { id: groupId }),
+ canEdit: actions?.includes?.(ACTIONS.CHANGE_GROUP),
+ handleGetOptionList: getGroupOptions,
+ handleEdit: (_, group) => handleEdit?.({ group }),
+ },
+ ]
+
+ return
+ }
+)
Ownership.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
@@ -84,7 +75,7 @@ Ownership.propTypes = {
userName: PropTypes.string.isRequired,
groupId: PropTypes.string.isRequired,
groupName: PropTypes.string.isRequired,
- handleEdit: PropTypes.func
+ handleEdit: PropTypes.func,
}
Ownership.displayName = 'Ownership'
diff --git a/src/fireedge/src/client/components/Tabs/Common/Permissions.js b/src/fireedge/src/client/components/Tabs/Common/Permissions.js
index 3acee5ea84..38f39ac2ff 100644
--- a/src/fireedge/src/client/components/Tabs/Common/Permissions.js
+++ b/src/fireedge/src/client/components/Tabs/Common/Permissions.js
@@ -29,19 +29,19 @@ import * as Helper from 'client/models/Helper'
const CATEGORIES = [
{ title: T.Owner, category: 'owner' },
{ title: T.Group, category: 'group' },
- { title: T.Other, category: 'other' }
+ { title: T.Other, category: 'other' },
]
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles((theme) => ({
list: {
'& > * > *': {
- width: '25%'
- }
+ width: '25%',
+ },
},
title: {
fontWeight: theme.typography.fontWeightBold,
- borderBottom: `1px solid ${theme.palette.divider}`
- }
+ borderBottom: `1px solid ${theme.palette.divider}`,
+ },
}))
const Permissions = memo(({ handleEdit, actions, ...permissions }) => {
@@ -49,16 +49,16 @@ const Permissions = memo(({ handleEdit, actions, ...permissions }) => {
const handleChange = async (name, value) => {
const newPermission = {
- [name]: Helper.stringToBoolean(value) ? '0' : '1'
+ [name]: Helper.stringToBoolean(value) ? '0' : '1',
}
await handleEdit?.(newPermission)
}
- const getIcon = checked => +checked ? :
+ const getIcon = (checked) => (+checked ? : )
return (
-
+
{Tr(T.Permissions)}
@@ -69,7 +69,7 @@ const Permissions = memo(({ handleEdit, actions, ...permissions }) => {
{CATEGORIES.map(({ title, category }) => (
{/* TITLE */}
-
+
{Tr(title)}
@@ -85,10 +85,11 @@ const Permissions = memo(({ handleEdit, actions, ...permissions }) => {
icon={getIcon(permission)}
handleClick={() => handleChange(key, permission)}
/>
- ) : getIcon(permission)}
+ ) : (
+ getIcon(permission)
+ )}
- ))
- }
+ ))}
))}
@@ -107,7 +108,7 @@ Permissions.propTypes = {
otherUse: PropTypes.string.isRequired,
ownerAdmin: PropTypes.string.isRequired,
ownerManage: PropTypes.string.isRequired,
- ownerUse: PropTypes.string.isRequired
+ ownerUse: PropTypes.string.isRequired,
}
Permissions.displayName = 'Permissions'
diff --git a/src/fireedge/src/client/components/Tabs/Common/index.js b/src/fireedge/src/client/components/Tabs/Common/index.js
index a92e08fba9..9896b0ffe7 100644
--- a/src/fireedge/src/client/components/Tabs/Common/index.js
+++ b/src/fireedge/src/client/components/Tabs/Common/index.js
@@ -20,9 +20,4 @@ import Permissions from 'client/components/Tabs/Common/Permissions'
export * from 'client/components/Tabs/Common/Attribute'
-export {
- AttributePanel,
- List,
- Ownership,
- Permissions
-}
+export { AttributePanel, List, Ownership, Permissions }
diff --git a/src/fireedge/src/client/components/Tabs/Host/Info/index.js b/src/fireedge/src/client/components/Tabs/Host/Info/index.js
index e817c5f31b..96c56c382d 100644
--- a/src/fireedge/src/client/components/Tabs/Host/Info/index.js
+++ b/src/fireedge/src/client/components/Tabs/Host/Info/index.js
@@ -29,21 +29,22 @@ import { cloneObject, set } from 'client/utils'
const NSX_ATTRIBUTES_REG = /^NSX_/
const VCENTER_ATTRIBUTES_REG = /^VCENTER_(?!(RESOURCE_POOL)$)/
-const HIDDEN_ATTRIBUTES_REG = /^(HOST|VM|WILDS|ZOMBIES|RESERVED_CPU|RESERVED_MEM|EC2_ACCESS|EC2_SECRET|CAPACITY|REGION_NAME)$/
+const HIDDEN_ATTRIBUTES_REG =
+ /^(HOST|VM|WILDS|ZOMBIES|RESERVED_CPU|RESERVED_MEM|EC2_ACCESS|EC2_SECRET|CAPACITY|REGION_NAME)$/
const HostInfoTab = ({ tabProps = {} }) => {
const {
information_panel: informationPanel,
vcenter_panel: vcenterPanel,
nsx_panel: nsxPanel,
- attributes_panel: attributesPanel
+ attributes_panel: attributesPanel,
} = tabProps
const { rename, updateUserTemplate } = useHostApi()
const { handleRefetch, data: host = {} } = useContext(TabContext)
const { ID, TEMPLATE } = host
- const handleRename = async newName => {
+ const handleRename = async (newName) => {
const response = await rename(ID, newName)
String(response) === String(ID) && (await handleRefetch?.())
}
@@ -61,33 +62,35 @@ const HostInfoTab = ({ tabProps = {} }) => {
String(response) === String(ID) && (await handleRefetch?.())
}
- const getActions = actions => Helper.getActionsAvailable(actions)
+ const getActions = (actions) => Helper.getActionsAvailable(actions)
const {
attributes,
nsx: nsxAttributes,
- vcenter: vcenterAttributes
+ vcenter: vcenterAttributes,
} = Helper.filterAttributes(TEMPLATE, {
extra: {
vcenter: VCENTER_ATTRIBUTES_REG,
- nsx: NSX_ATTRIBUTES_REG
+ nsx: NSX_ATTRIBUTES_REG,
},
- hidden: HIDDEN_ATTRIBUTES_REG
+ hidden: HIDDEN_ATTRIBUTES_REG,
})
const ATTRIBUTE_FUNCTION = {
handleAdd: handleAttributeInXml,
handleEdit: handleAttributeInXml,
- handleDelete: handleAttributeInXml
+ handleDelete: handleAttributeInXml,
}
return (
-
+
{informationPanel?.enabled && (
{
}
HostInfoTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
HostInfoTab.displayName = 'HostInfoTab'
diff --git a/src/fireedge/src/client/components/Tabs/Host/Info/information.js b/src/fireedge/src/client/components/Tabs/Host/Info/information.js
index 5368cbcc51..4b415b0ecd 100644
--- a/src/fireedge/src/client/components/Tabs/Host/Info/information.js
+++ b/src/fireedge/src/client/components/Tabs/Host/Info/information.js
@@ -29,12 +29,8 @@ const InformationPanel = ({ host = {}, handleRename, actions }) => {
const { ID, NAME, IM_MAD, VM_MAD, CLUSTER_ID, CLUSTER } = host
const { name: stateName, color: stateColor } = getState(host)
const datastores = getDatastores(host)
- const {
- percentCpuUsed,
- percentCpuLabel,
- percentMemUsed,
- percentMemLabel
- } = getAllocatedInfo(host)
+ const { percentCpuUsed, percentCpuLabel, percentMemUsed, percentMemLabel } =
+ getAllocatedInfo(host)
const info = [
{ name: T.ID, value: ID },
@@ -42,36 +38,52 @@ const InformationPanel = ({ host = {}, handleRename, actions }) => {
name: T.Name,
value: NAME,
canEdit: actions?.includes?.(VM_ACTIONS.RENAME),
- handleEdit: handleRename
+ handleEdit: handleRename,
},
{
name: T.State,
- value:
+ value: ,
},
{
name: T.Cluster,
value: `#${CLUSTER_ID} ${CLUSTER}`,
- link: !Number.isNaN(+CLUSTER_ID) &&
- generatePath(PATH.INFRASTRUCTURE.CLUSTERS.DETAIL, { id: CLUSTER_ID })
+ link:
+ !Number.isNaN(+CLUSTER_ID) &&
+ generatePath(PATH.INFRASTRUCTURE.CLUSTERS.DETAIL, { id: CLUSTER_ID }),
},
{ name: T.IM_MAD, value: IM_MAD },
- { name: T.VM_MAD, value: VM_MAD }
+ { name: T.VM_MAD, value: VM_MAD },
]
- const capacity = [{
- name: T.AllocatedMemory,
- value:
- }, {
- name: T.AllocatedCpu,
- value:
- }]
+ const capacity = [
+ {
+ name: T.AllocatedMemory,
+ value: (
+
+ ),
+ },
+ {
+ name: T.AllocatedCpu,
+ value: (
+
+ ),
+ },
+ ]
- const datastore = datastores.map(ds => {
+ const datastore = datastores.map((ds) => {
const { percentOfUsed, percentLabel } = getCapacityInfo(ds)
return {
name: `#${ds?.ID}`, // TODO: add datastore name
- value:
+ value: (
+
+ ),
}
})
@@ -93,7 +105,7 @@ InformationPanel.displayName = 'InformationPanel'
InformationPanel.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
handleRename: PropTypes.func,
- host: PropTypes.object
+ host: PropTypes.object,
}
export default InformationPanel
diff --git a/src/fireedge/src/client/components/Tabs/Host/index.js b/src/fireedge/src/client/components/Tabs/Host/index.js
index 8c63f535e0..c18d39a797 100644
--- a/src/fireedge/src/client/components/Tabs/Host/index.js
+++ b/src/fireedge/src/client/components/Tabs/Host/index.js
@@ -28,20 +28,19 @@ import { camelCase } from 'client/utils'
import TabProvider from 'client/components/Tabs/TabProvider'
import Info from 'client/components/Tabs/Host/Info'
-const getTabComponent = tabName => ({
- info: Info
-}[tabName])
+const getTabComponent = (tabName) =>
+ ({
+ info: Info,
+ }[tabName])
const HostTabs = memo(({ id }) => {
const { getHooksSocket } = useSocket()
const { getHost } = useHostApi()
- const {
- data,
- fetchRequest,
- loading,
- error
- } = useFetch(getHost, getHooksSocket({ resource: 'host', id }))
+ const { data, fetchRequest, loading, error } = useFetch(
+ getHost,
+ getHooksSocket({ resource: 'host', id })
+ )
const handleRefetch = () => fetchRequest(id, { reload: true })
@@ -55,22 +54,26 @@ const HostTabs = memo(({ id }) => {
useEffect(() => {
const infoTabs = getResourceView('HOST')?.['info-tabs'] ?? {}
- setTabs(() => Object.entries(infoTabs)
- ?.filter(([_, { enabled } = {}]) => !!enabled)
- ?.map(([tabName, tabProps]) => {
- const camelName = camelCase(tabName)
- const TabContent = getTabComponent(camelName)
+ setTabs(() =>
+ Object.entries(infoTabs)
+ ?.filter(([_, { enabled } = {}]) => !!enabled)
+ ?.map(([tabName, tabProps]) => {
+ const camelName = camelCase(tabName)
+ const TabContent = getTabComponent(camelName)
- return TabContent && {
- name: camelName,
- renderContent: props => TabContent({ ...props, tabProps })
- }
- })
- ?.filter(Boolean))
+ return (
+ TabContent && {
+ name: camelName,
+ renderContent: (props) => TabContent({ ...props, tabProps }),
+ }
+ )
+ })
+ ?.filter(Boolean)
+ )
}, [view])
if ((!data && !error) || loading) {
- return
+ return
}
return (
@@ -81,7 +84,7 @@ const HostTabs = memo(({ id }) => {
})
HostTabs.propTypes = {
- id: PropTypes.string.isRequired
+ id: PropTypes.string.isRequired,
}
HostTabs.displayName = 'HostTabs'
diff --git a/src/fireedge/src/client/components/Tabs/MarketplaceApp/Info/index.js b/src/fireedge/src/client/components/Tabs/MarketplaceApp/Info/index.js
index cdd70bdb64..fe59ab25b7 100644
--- a/src/fireedge/src/client/components/Tabs/MarketplaceApp/Info/index.js
+++ b/src/fireedge/src/client/components/Tabs/MarketplaceApp/Info/index.js
@@ -19,11 +19,19 @@ import PropTypes from 'prop-types'
import { useMarketplaceAppApi } from 'client/features/One'
import { TabContext } from 'client/components/Tabs/TabProvider'
-import { Permissions, Ownership, AttributePanel } from 'client/components/Tabs/Common'
+import {
+ Permissions,
+ Ownership,
+ AttributePanel,
+} from 'client/components/Tabs/Common'
import Information from 'client/components/Tabs/MarketplaceApp/Info/information'
import { Tr } from 'client/components/HOC'
-import { getActionsAvailable, filterAttributes, jsonToXml } from 'client/models/Helper'
+import {
+ getActionsAvailable,
+ filterAttributes,
+ jsonToXml,
+} from 'client/models/Helper'
import { cloneObject, set } from 'client/utils'
import { T } from 'client/constants'
@@ -34,19 +42,20 @@ const MarketplaceAppInfoTab = ({ tabProps = {} }) => {
information_panel: informationPanel,
permissions_panel: permissionsPanel,
ownership_panel: ownershipPanel,
- attributes_panel: attributesPanel
+ attributes_panel: attributesPanel,
} = tabProps
- const { rename, changeOwnership, changePermissions, updateTemplate } = useMarketplaceAppApi()
+ const { rename, changeOwnership, changePermissions, updateTemplate } =
+ useMarketplaceAppApi()
const { handleRefetch, data: marketplaceApp = {} } = useContext(TabContext)
const { ID, UNAME, UID, GNAME, GID, PERMISSIONS, TEMPLATE } = marketplaceApp
- const handleChangeOwnership = async newOwnership => {
+ const handleChangeOwnership = async (newOwnership) => {
const response = await changeOwnership(ID, newOwnership)
String(response) === String(ID) && (await handleRefetch?.())
}
- const handleChangePermission = async newPermission => {
+ const handleChangePermission = async (newPermission) => {
const response = await changePermissions(ID, newPermission)
String(response) === String(ID) && (await handleRefetch?.())
}
@@ -68,17 +77,21 @@ const MarketplaceAppInfoTab = ({ tabProps = {} }) => {
String(response) === String(ID) && (await handleRefetch?.())
}
- const getActions = actions => getActionsAvailable(actions)
+ const getActions = (actions) => getActionsAvailable(actions)
- const { attributes } = filterAttributes(TEMPLATE, { hidden: HIDDEN_ATTRIBUTES_REG })
+ const { attributes } = filterAttributes(TEMPLATE, {
+ hidden: HIDDEN_ATTRIBUTES_REG,
+ })
return (
-
+
{informationPanel?.enabled && (
{
}
MarketplaceAppInfoTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
MarketplaceAppInfoTab.displayName = 'MarketplaceAppInfoTab'
diff --git a/src/fireedge/src/client/components/Tabs/MarketplaceApp/Info/information.js b/src/fireedge/src/client/components/Tabs/MarketplaceApp/Info/information.js
index 8c84be600b..35b96ee4a7 100644
--- a/src/fireedge/src/client/components/Tabs/MarketplaceApp/Info/information.js
+++ b/src/fireedge/src/client/components/Tabs/MarketplaceApp/Info/information.js
@@ -27,7 +27,17 @@ import { T, MARKETPLACE_APP_ACTIONS } from 'client/constants'
import { PATH } from 'client/apps/sunstone/routesOne'
const InformationPanel = ({ marketplaceApp = {}, handleRename, actions }) => {
- const { ID, NAME, REGTIME, LOCK, MARKETPLACE, MARKETPLACE_ID, SIZE, FORMAT, VERSION } = marketplaceApp
+ const {
+ ID,
+ NAME,
+ REGTIME,
+ LOCK,
+ MARKETPLACE,
+ MARKETPLACE_ID,
+ SIZE,
+ FORMAT,
+ VERSION,
+ } = marketplaceApp
const typeName = getType(marketplaceApp)
const { name: stateName, color: stateColor } = getState(marketplaceApp)
@@ -37,27 +47,28 @@ const InformationPanel = ({ marketplaceApp = {}, handleRename, actions }) => {
name: T.Name,
value: NAME,
canEdit: actions?.includes?.(MARKETPLACE_APP_ACTIONS.RENAME),
- handleEdit: handleRename
+ handleEdit: handleRename,
},
{
name: T.Marketplace,
value: `#${MARKETPLACE_ID} ${MARKETPLACE}`,
- link: !Number.isNaN(+MARKETPLACE_ID) &&
- generatePath(PATH.STORAGE.MARKETPLACES.DETAIL, { id: MARKETPLACE_ID })
+ link:
+ !Number.isNaN(+MARKETPLACE_ID) &&
+ generatePath(PATH.STORAGE.MARKETPLACES.DETAIL, { id: MARKETPLACE_ID }),
},
{
name: T.StartTime,
- value: timeToString(REGTIME)
+ value: timeToString(REGTIME),
},
{ name: T.Type, value: typeName },
{ name: T.Size, value: prettyBytes(SIZE, 'MB') },
{
name: T.State,
- value:
+ value: ,
},
{ name: T.Locked, value: levelLockToString(LOCK?.LOCKED) },
{ name: T.Format, value: FORMAT },
- { name: T.Version, value: VERSION }
+ { name: T.Version, value: VERSION },
]
return (
@@ -74,7 +85,7 @@ InformationPanel.displayName = 'InformationPanel'
InformationPanel.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
handleRename: PropTypes.func,
- marketplaceApp: PropTypes.object
+ marketplaceApp: PropTypes.object,
}
export default InformationPanel
diff --git a/src/fireedge/src/client/components/Tabs/MarketplaceApp/Template.js b/src/fireedge/src/client/components/Tabs/MarketplaceApp/Template.js
index bfc9c97509..c856620039 100644
--- a/src/fireedge/src/client/components/Tabs/MarketplaceApp/Template.js
+++ b/src/fireedge/src/client/components/Tabs/MarketplaceApp/Template.js
@@ -25,9 +25,14 @@ import { T } from 'client/constants'
const AppTemplateTab = () => {
const { data: marketplaceApp = {} } = useContext(TabContext)
- const { TEMPLATE: { APPTEMPLATE64, VMTEMPLATE64 } } = marketplaceApp
+ const {
+ TEMPLATE: { APPTEMPLATE64, VMTEMPLATE64 },
+ } = marketplaceApp
- const appTemplate = useMemo(() => decodeBase64(APPTEMPLATE64), [APPTEMPLATE64])
+ const appTemplate = useMemo(
+ () => decodeBase64(APPTEMPLATE64),
+ [APPTEMPLATE64]
+ )
const vmTemplate = useMemo(() => decodeBase64(VMTEMPLATE64), [VMTEMPLATE64])
return (
@@ -38,7 +43,9 @@ const AppTemplateTab = () => {
-
+
{appTemplate}
@@ -50,7 +57,9 @@ const AppTemplateTab = () => {
-
+
{vmTemplate}
diff --git a/src/fireedge/src/client/components/Tabs/MarketplaceApp/index.js b/src/fireedge/src/client/components/Tabs/MarketplaceApp/index.js
index aa74d67455..0c05341c0a 100644
--- a/src/fireedge/src/client/components/Tabs/MarketplaceApp/index.js
+++ b/src/fireedge/src/client/components/Tabs/MarketplaceApp/index.js
@@ -29,10 +29,11 @@ import TabProvider from 'client/components/Tabs/TabProvider'
import Info from 'client/components/Tabs/MarketplaceApp/Info'
import Template from 'client/components/Tabs/MarketplaceApp/Template'
-const getTabComponent = tabName => ({
- info: Info,
- template: Template
-}[tabName])
+const getTabComponent = (tabName) =>
+ ({
+ info: Info,
+ template: Template,
+ }[tabName])
const MarketplaceAppTabs = memo(({ id }) => {
const { getMarketplaceApp } = useMarketplaceAppApi()
@@ -50,22 +51,26 @@ const MarketplaceAppTabs = memo(({ id }) => {
useEffect(() => {
const infoTabs = getResourceView('MARKETPLACE-APP')?.['info-tabs'] ?? {}
- setTabs(() => Object.entries(infoTabs)
- ?.filter(([_, { enabled } = {}]) => !!enabled)
- ?.map(([tabName, tabProps]) => {
- const camelName = camelCase(tabName)
- const TabContent = getTabComponent(camelName)
+ setTabs(() =>
+ Object.entries(infoTabs)
+ ?.filter(([_, { enabled } = {}]) => !!enabled)
+ ?.map(([tabName, tabProps]) => {
+ const camelName = camelCase(tabName)
+ const TabContent = getTabComponent(camelName)
- return TabContent && {
- name: camelName,
- renderContent: props => TabContent({ ...props, tabProps })
- }
- })
- ?.filter(Boolean))
+ return (
+ TabContent && {
+ name: camelName,
+ renderContent: (props) => TabContent({ ...props, tabProps }),
+ }
+ )
+ })
+ ?.filter(Boolean)
+ )
}, [view])
if ((!data && !error) || loading) {
- return
+ return
}
return (
@@ -76,7 +81,7 @@ const MarketplaceAppTabs = memo(({ id }) => {
})
MarketplaceAppTabs.propTypes = {
- id: PropTypes.string.isRequired
+ id: PropTypes.string.isRequired,
}
MarketplaceAppTabs.displayName = 'MarketplaceAppTabs'
diff --git a/src/fireedge/src/client/components/Tabs/TabProvider.js b/src/fireedge/src/client/components/Tabs/TabProvider.js
index b6e3082a5f..d8ebef8201 100644
--- a/src/fireedge/src/client/components/Tabs/TabProvider.js
+++ b/src/fireedge/src/client/components/Tabs/TabProvider.js
@@ -24,7 +24,7 @@ const TabProvider = ({ initialState = {}, children }) => {
const { data } = initialState
useEffect(() => {
- data && setTabInformation(prev => ({ ...prev, data }))
+ data && setTabInformation((prev) => ({ ...prev, data }))
}, [data])
return (
@@ -38,8 +38,8 @@ TabProvider.propTypes = {
initialState: PropTypes.object,
children: PropTypes.oneOfType([
PropTypes.node,
- PropTypes.arrayOf(PropTypes.node)
- ])
+ PropTypes.arrayOf(PropTypes.node),
+ ]),
}
export default TabProvider
diff --git a/src/fireedge/src/client/components/Tabs/User/Info/index.js b/src/fireedge/src/client/components/Tabs/User/Info/index.js
index e271d9633b..52d412f153 100644
--- a/src/fireedge/src/client/components/Tabs/User/Info/index.js
+++ b/src/fireedge/src/client/components/Tabs/User/Info/index.js
@@ -27,12 +27,13 @@ import { T } from 'client/constants'
import * as Helper from 'client/models/Helper'
import { cloneObject, set } from 'client/utils'
-const HIDDEN_ATTRIBUTES_REG = /^(SSH_PUBLIC_KEY|SSH_PRIVATE_KEY|SSH_PASSPHRASE|SUNSTONE|FIREEDGE)$/
+const HIDDEN_ATTRIBUTES_REG =
+ /^(SSH_PUBLIC_KEY|SSH_PRIVATE_KEY|SSH_PASSPHRASE|SUNSTONE|FIREEDGE)$/
const UserInfoTab = ({ tabProps = {} }) => {
const {
information_panel: informationPanel,
- attributes_panel: attributesPanel
+ attributes_panel: attributesPanel,
} = tabProps
const { updateUser } = useUserApi()
@@ -52,23 +53,27 @@ const UserInfoTab = ({ tabProps = {} }) => {
String(response) === String(ID) && (await handleRefetch?.())
}
- const getActions = actions => Helper.getActionsAvailable(actions)
+ const getActions = (actions) => Helper.getActionsAvailable(actions)
- const { attributes } = Helper.filterAttributes(TEMPLATE, { hidden: HIDDEN_ATTRIBUTES_REG })
+ const { attributes } = Helper.filterAttributes(TEMPLATE, {
+ hidden: HIDDEN_ATTRIBUTES_REG,
+ })
const ATTRIBUTE_FUNCTION = {
handleAdd: handleAttributeInXml,
handleEdit: handleAttributeInXml,
- handleDelete: handleAttributeInXml
+ handleDelete: handleAttributeInXml,
}
return (
-
+
{informationPanel?.enabled && (
{
}
UserInfoTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
UserInfoTab.displayName = 'UserInfoTab'
diff --git a/src/fireedge/src/client/components/Tabs/User/Info/information.js b/src/fireedge/src/client/components/Tabs/User/Info/information.js
index b20f8de36a..7b005b07ba 100644
--- a/src/fireedge/src/client/components/Tabs/User/Info/information.js
+++ b/src/fireedge/src/client/components/Tabs/User/Info/information.js
@@ -30,19 +30,17 @@ const InformationPanel = ({ user = {} }) => {
{ name: T.Name, value: NAME },
{
name: T.State,
- value: Helper.booleanToString(isEnabled)
- }
+ value: Helper.booleanToString(isEnabled),
+ },
]
- return (
-
- )
+ return
}
InformationPanel.displayName = 'InformationPanel'
InformationPanel.propTypes = {
- user: PropTypes.object
+ user: PropTypes.object,
}
export default InformationPanel
diff --git a/src/fireedge/src/client/components/Tabs/User/index.js b/src/fireedge/src/client/components/Tabs/User/index.js
index 6fe3d77599..edf0e21b86 100644
--- a/src/fireedge/src/client/components/Tabs/User/index.js
+++ b/src/fireedge/src/client/components/Tabs/User/index.js
@@ -28,9 +28,10 @@ import { camelCase } from 'client/utils'
import TabProvider from 'client/components/Tabs/TabProvider'
import Info from 'client/components/Tabs/User/Info'
-const getTabComponent = tabName => ({
- info: Info
-}[tabName])
+const getTabComponent = (tabName) =>
+ ({
+ info: Info,
+ }[tabName])
const UserTabs = memo(({ id }) => {
const { getUser } = useUserApi()
@@ -48,22 +49,26 @@ const UserTabs = memo(({ id }) => {
useEffect(() => {
const infoTabs = getResourceView('USER')?.['info-tabs'] ?? {}
- setTabs(() => Object.entries(infoTabs)
- ?.filter(([_, { enabled } = {}]) => !!enabled)
- ?.map(([tabName, tabProps]) => {
- const camelName = camelCase(tabName)
- const TabContent = getTabComponent(camelName)
+ setTabs(() =>
+ Object.entries(infoTabs)
+ ?.filter(([_, { enabled } = {}]) => !!enabled)
+ ?.map(([tabName, tabProps]) => {
+ const camelName = camelCase(tabName)
+ const TabContent = getTabComponent(camelName)
- return TabContent && {
- name: camelName,
- renderContent: props => TabContent({ ...props, tabProps })
- }
- })
- ?.filter(Boolean))
+ return (
+ TabContent && {
+ name: camelName,
+ renderContent: (props) => TabContent({ ...props, tabProps }),
+ }
+ )
+ })
+ ?.filter(Boolean)
+ )
}, [view])
if ((!data && !error) || loading) {
- return
+ return
}
return (
@@ -74,7 +79,7 @@ const UserTabs = memo(({ id }) => {
})
UserTabs.propTypes = {
- id: PropTypes.string.isRequired
+ id: PropTypes.string.isRequired,
}
UserTabs.displayName = 'UserTabs'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Capacity/index.js b/src/fireedge/src/client/components/Tabs/Vm/Capacity/index.js
index 1c8197f614..9f1c50b145 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Capacity/index.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Capacity/index.js
@@ -33,13 +33,14 @@ const VmCapacityTab = ({ tabProps: { actions } = {} }) => {
const actionsAvailable = useMemo(() => {
const hypervisor = getHypervisor(vm)
const actionsByHypervisor = getActionsAvailable(actions, hypervisor)
- const actionsByState = actionsByHypervisor
- .filter(action => !isAvailableAction(action)(vm))
+ const actionsByState = actionsByHypervisor.filter(
+ (action) => !isAvailableAction(action)(vm)
+ )
return actionsByState
}, [vm])
- const handleResizeCapacity = async formData => {
+ const handleResizeCapacity = async (formData) => {
const { enforce, ...restOfData } = formData
const template = jsonToXml(restOfData)
@@ -57,7 +58,7 @@ const VmCapacityTab = ({ tabProps: { actions } = {} }) => {
}
VmCapacityTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
VmCapacityTab.displayName = 'VmCapacityTab'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Capacity/information.js b/src/fireedge/src/client/components/Tabs/Vm/Capacity/information.js
index 57a73a32d0..c67edb3b65 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Capacity/information.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Capacity/information.js
@@ -35,37 +35,37 @@ const InformationPanel = ({ actions, vm = {}, handleResizeCapacity }) => {
const capacity = [
{
name: T.PhysicalCpu,
- value: TEMPLATE?.CPU
+ value: TEMPLATE?.CPU,
},
{
name: T.VirtualCpu,
- value: TEMPLATE?.VCPU ?? '-'
+ value: TEMPLATE?.VCPU ?? '-',
},
- (isVCenter && {
+ isVCenter && {
name: T.VirtualCores,
value: (
<>
{`${Tr(T.Cores)} x ${TEMPLATE?.TOPOLOGY?.CORES || '-'} |
${Tr(T.Sockets)} ${TEMPLATE?.TOPOLOGY?.SOCKETS || '-'}`}
>
- )
- }),
+ ),
+ },
{
name: T.Memory,
- value: prettyBytes(+TEMPLATE?.MEMORY, 'MB')
+ value: prettyBytes(+TEMPLATE?.MEMORY, 'MB'),
},
{
name: T.CostCpu,
- value: TEMPLATE?.CPU_COST || 0
+ value: TEMPLATE?.CPU_COST || 0,
},
{
name: T.CostMByte,
- value: TEMPLATE?.MEMORY_COST || 0
- }
+ value: TEMPLATE?.MEMORY_COST || 0,
+ },
].filter(Boolean)
return (
-
+
{actions?.includes?.(VM_ACTIONS.RESIZE_CAPACITY) && (
{
color: 'secondary',
'data-cy': 'resize-capacity',
label: T.Resize,
- variant: 'outlined'
+ variant: 'outlined',
}}
- options={[{
- dialogProps: { title: T.ResizeCapacity },
- form: () => ResizeCapacityForm(undefined, vm.TEMPLATE),
- onSubmit: handleResizeCapacity
- }]}
+ options={[
+ {
+ dialogProps: { title: T.ResizeCapacity },
+ form: () => ResizeCapacityForm(undefined, vm.TEMPLATE),
+ onSubmit: handleResizeCapacity,
+ },
+ ]}
/>
)}
@@ -88,7 +90,7 @@ const InformationPanel = ({ actions, vm = {}, handleResizeCapacity }) => {
{name}
-
+
{value}
@@ -100,7 +102,7 @@ const InformationPanel = ({ actions, vm = {}, handleResizeCapacity }) => {
InformationPanel.propTypes = {
handleResizeCapacity: PropTypes.func,
actions: PropTypes.array,
- vm: PropTypes.object
+ vm: PropTypes.object,
}
InformationPanel.displayName = 'InformationPanel'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Capacity/styles.js b/src/fireedge/src/client/components/Tabs/Vm/Capacity/styles.js
index ed752d4643..c5aa14a18d 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Capacity/styles.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Capacity/styles.js
@@ -15,7 +15,7 @@
* ------------------------------------------------------------------------- */
import makeStyles from '@mui/styles/makeStyles'
-export default makeStyles(theme => ({
+export default makeStyles((theme) => ({
root: {
marginBlock: '0.8em',
padding: '1em',
@@ -23,29 +23,29 @@ export default makeStyles(theme => ({
gap: '1em',
gridAutoFlow: 'column',
[theme.breakpoints.down('md')]: {
- gridAutoFlow: 'initial'
- }
+ gridAutoFlow: 'initial',
+ },
},
item: {
[theme.breakpoints.down('md')]: {
display: 'flex',
gap: '1em',
'& > *': {
- width: '50%'
- }
- }
+ width: '50%',
+ },
+ },
},
actions: {
[theme.breakpoints.down('md')]: {
borderBottom: `1px solid ${theme.palette.divider}`,
- padding: '1em'
+ padding: '1em',
},
[theme.breakpoints.up('md')]: {
order: 1,
- textAlign: 'end'
- }
+ textAlign: 'end',
+ },
},
title: {
- fontWeight: theme.typography.fontWeightMedium
- }
+ fontWeight: theme.typography.fontWeightMedium,
+ },
}))
diff --git a/src/fireedge/src/client/components/Tabs/Vm/History/Item.js b/src/fireedge/src/client/components/Tabs/Vm/History/Item.js
index 845e839077..5ab1f6d4b0 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/History/Item.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/History/Item.js
@@ -38,7 +38,7 @@ const HistoryItem = ({ history }) => {
STIME,
ETIME,
PSTIME,
- PETIME
+ PETIME,
} = history
const now = Math.round(Date.now() / 1000)
@@ -56,10 +56,10 @@ const HistoryItem = ({ history }) => {
const action = VirtualMachine.getHistoryAction(+ACTION)
return (
-
+
-
+
{`#${SEQ} | #${HID} ${HOSTNAME} | Action: ${action}`}
@@ -74,7 +74,9 @@ const HistoryItem = ({ history }) => {
{` ${ownerInfo}`}
)}
-
+
{`| start ${startTime.toRelative()}`}
@@ -91,7 +93,7 @@ const HistoryItem = ({ history }) => {
HistoryItem.propTypes = {
history: PropTypes.object.isRequired,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
HistoryItem.displayName = 'HistoryItem'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/History/List.js b/src/fireedge/src/client/components/Tabs/Vm/History/List.js
index d03e29c5d1..b300b00f1c 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/History/List.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/History/List.js
@@ -28,7 +28,7 @@ const HistoryList = ({ records, actions }) => (
HistoryList.propTypes = {
records: PropTypes.array,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
HistoryList.displayName = 'HistoryList'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/History/index.js b/src/fireedge/src/client/components/Tabs/Vm/History/index.js
index 285a74801b..39ea661d3b 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/History/index.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/History/index.js
@@ -20,7 +20,11 @@ import PropTypes from 'prop-types'
import { TabContext } from 'client/components/Tabs/TabProvider'
import HistoryList from 'client/components/Tabs/Vm/History/List'
-import { getHypervisor, getHistoryRecords, isAvailableAction } from 'client/models/VirtualMachine'
+import {
+ getHypervisor,
+ getHistoryRecords,
+ isAvailableAction,
+} from 'client/models/VirtualMachine'
import { getActionsAvailable } from 'client/models/Helper'
const VmHistoryTab = ({ tabProps: { actions } = {} }) => {
@@ -29,19 +33,18 @@ const VmHistoryTab = ({ tabProps: { actions } = {} }) => {
const [records, actionsAvailable] = useMemo(() => {
const hypervisor = getHypervisor(vm)
const actionsByHypervisor = getActionsAvailable(actions, hypervisor)
- const actionsByState = actionsByHypervisor
- .filter(action => !isAvailableAction(action)(vm))
+ const actionsByState = actionsByHypervisor.filter(
+ (action) => !isAvailableAction(action)(vm)
+ )
return [getHistoryRecords(vm), actionsByState]
}, [vm])
- return (
-
- )
+ return
}
VmHistoryTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
VmHistoryTab.displayName = 'VmHistoryTab'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Info/index.js b/src/fireedge/src/client/components/Tabs/Vm/Info/index.js
index ac6edaadc9..059de95610 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Info/index.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Info/index.js
@@ -19,19 +19,28 @@ import PropTypes from 'prop-types'
import { useVmApi } from 'client/features/One'
import { TabContext } from 'client/components/Tabs/TabProvider'
-import { Permissions, Ownership, AttributePanel } from 'client/components/Tabs/Common'
+import {
+ Permissions,
+ Ownership,
+ AttributePanel,
+} from 'client/components/Tabs/Common'
import Information from 'client/components/Tabs/Vm/Info/information'
import { Tr } from 'client/components/HOC'
import { T } from 'client/constants'
import { getHypervisor } from 'client/models/VirtualMachine'
-import { getActionsAvailable, filterAttributes, jsonToXml } from 'client/models/Helper'
+import {
+ getActionsAvailable,
+ filterAttributes,
+ jsonToXml,
+} from 'client/models/Helper'
import { cloneObject, set } from 'client/utils'
const LXC_ATTRIBUTES_REG = /^LXC_/
const VCENTER_ATTRIBUTES_REG = /^VCENTER_/
const HIDDEN_ATTRIBUTES_REG = /^(USER_INPUTS|BACKUP|HOT_RESIZE)$|SCHED_|ERROR/
-const HIDDEN_MONITORING_REG = /^(CPU|MEMORY|NETTX|NETRX|STATE|DISK_SIZE|SNAPSHOT_SIZE)$/
+const HIDDEN_MONITORING_REG =
+ /^(CPU|MEMORY|NETTX|NETRX|STATE|DISK_SIZE|SNAPSHOT_SIZE)$/
const VmInfoTab = ({ tabProps = {} }) => {
const {
@@ -41,19 +50,21 @@ const VmInfoTab = ({ tabProps = {} }) => {
vcenter_panel: vcenterPanel,
lxc_panel: lxcPanel,
monitoring_panel: monitoringPanel,
- attributes_panel: attributesPanel
+ attributes_panel: attributesPanel,
} = tabProps
- const { changeOwnership, changePermissions, rename, updateUserTemplate } = useVmApi()
+ const { changeOwnership, changePermissions, rename, updateUserTemplate } =
+ useVmApi()
const { handleRefetch, data: vm = {} } = useContext(TabContext)
- const { ID, UNAME, UID, GNAME, GID, PERMISSIONS, USER_TEMPLATE, MONITORING } = vm
+ const { ID, UNAME, UID, GNAME, GID, PERMISSIONS, USER_TEMPLATE, MONITORING } =
+ vm
- const handleChangeOwnership = async newOwnership => {
+ const handleChangeOwnership = async (newOwnership) => {
const response = await changeOwnership(ID, newOwnership)
String(response) === String(ID) && (await handleRefetch?.())
}
- const handleChangePermission = async newPermission => {
+ const handleChangePermission = async (newPermission) => {
const response = await changePermissions(ID, newPermission)
String(response) === String(ID) && (await handleRefetch?.())
}
@@ -77,39 +88,41 @@ const VmInfoTab = ({ tabProps = {} }) => {
}
const getActions = useCallback(
- actions => getActionsAvailable(actions, getHypervisor(vm)),
+ (actions) => getActionsAvailable(actions, getHypervisor(vm)),
[vm]
)
const {
attributes,
lxc: lxcAttributes,
- vcenter: vcenterAttributes
+ vcenter: vcenterAttributes,
} = filterAttributes(USER_TEMPLATE, {
extra: {
vcenter: VCENTER_ATTRIBUTES_REG,
- lxc: LXC_ATTRIBUTES_REG
+ lxc: LXC_ATTRIBUTES_REG,
},
- hidden: HIDDEN_ATTRIBUTES_REG
+ hidden: HIDDEN_ATTRIBUTES_REG,
})
- const {
- attributes: monitoringAttributes
- } = filterAttributes(MONITORING, { hidden: HIDDEN_MONITORING_REG })
+ const { attributes: monitoringAttributes } = filterAttributes(MONITORING, {
+ hidden: HIDDEN_MONITORING_REG,
+ })
const ATTRIBUTE_FUNCTION = {
handleAdd: handleAttributeInXml,
handleEdit: handleAttributeInXml,
- handleDelete: handleAttributeInXml
+ handleDelete: handleAttributeInXml,
}
return (
-
+
{informationPanel?.enabled && (
{
}
VmInfoTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
VmInfoTab.displayName = 'VmInfoTab'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Info/information.js b/src/fireedge/src/client/components/Tabs/Vm/Info/information.js
index 50e938e8fd..2715337a70 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Info/information.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Info/information.js
@@ -34,11 +34,17 @@ const InformationPanel = ({ vm = {}, handleRename, actions }) => {
const { ID, NAME, RESCHED, STIME, ETIME, LOCK, DEPLOY_ID } = vm
const { name: stateName, color: stateColor } = getState(vm)
- const { HID: hostId, HOSTNAME: hostname = '--', CID: clusterId } = getLastHistory(vm)
+ const {
+ HID: hostId,
+ HOSTNAME: hostname = '--',
+ CID: clusterId,
+ } = getLastHistory(vm)
const ips = getIps(vm)
- const [clusterName, setClusterName] = useState(
- () => clusterId === '-1' ? 'default' : clusters.find(c => c.ID === clusterId)?.NAME
+ const [clusterName, setClusterName] = useState(() =>
+ clusterId === '-1'
+ ? 'default'
+ : clusters.find((c) => c.ID === clusterId)?.NAME
)
useEffect(() => {
@@ -56,48 +62,50 @@ const InformationPanel = ({ vm = {}, handleRename, actions }) => {
name: T.Name,
value: NAME,
canEdit: actions?.includes?.(VM_ACTIONS.RENAME),
- handleEdit: handleRename
+ handleEdit: handleRename,
},
{
name: T.State,
- value:
+ value: ,
},
{
name: T.Reschedule,
- value: Helper.booleanToString(+RESCHED)
+ value: Helper.booleanToString(+RESCHED),
},
{
name: T.Locked,
- value: Helper.levelLockToString(LOCK?.LOCKED)
+ value: Helper.levelLockToString(LOCK?.LOCKED),
},
{
name: T.IP,
- value: ips?.length ? : '--'
+ value: ips?.length ? : '--',
},
{
name: T.StartTime,
- value: Helper.timeToString(STIME)
+ value: Helper.timeToString(STIME),
},
{
name: T.EndTime,
- value: Helper.timeToString(ETIME)
+ value: Helper.timeToString(ETIME),
},
hostId && {
name: T.Host,
value: `#${hostId} ${hostname}`,
- link: !Number.isNaN(+hostId) &&
- generatePath(PATH.INFRASTRUCTURE.HOSTS.DETAIL, { id: hostId })
+ link:
+ !Number.isNaN(+hostId) &&
+ generatePath(PATH.INFRASTRUCTURE.HOSTS.DETAIL, { id: hostId }),
},
clusterId && {
name: T.Cluster,
value: clusterName ? `#${clusterId} ${clusterName}` : `#${clusterId} --`,
- link: !Number.isNaN(+clusterId) &&
- generatePath(PATH.INFRASTRUCTURE.CLUSTERS.DETAIL, { id: clusterId })
+ link:
+ !Number.isNaN(+clusterId) &&
+ generatePath(PATH.INFRASTRUCTURE.CLUSTERS.DETAIL, { id: clusterId }),
},
{
name: T.DeployID,
- value: DEPLOY_ID
- }
+ value: DEPLOY_ID,
+ },
].filter(Boolean)
return (
@@ -114,7 +122,7 @@ InformationPanel.displayName = 'InformationPanel'
InformationPanel.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
handleRename: PropTypes.func,
- vm: PropTypes.object
+ vm: PropTypes.object,
}
export default InformationPanel
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Log.js b/src/fireedge/src/client/components/Tabs/Vm/Log.js
index e28ec322d2..411064bd37 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Log.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Log.js
@@ -15,7 +15,7 @@
* ------------------------------------------------------------------------- */
/* eslint-disable jsdoc/require-jsdoc */
-const VmLogTab = data => {
+const VmLogTab = (data) => {
return (
WIP - LOG
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Network/Item.js b/src/fireedge/src/client/components/Tabs/Vm/Network/Item.js
index dda0c6c2bf..d56193dc39 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Network/Item.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Network/Item.js
@@ -22,7 +22,9 @@ import Typography from '@mui/material/Typography'
import Paper from '@mui/material/Paper'
import MAccordion from '@mui/material/Accordion'
import AccordionDetails from '@mui/material/AccordionDetails'
-import AccordionSummary, { accordionSummaryClasses } from '@mui/material/AccordionSummary'
+import AccordionSummary, {
+ accordionSummaryClasses,
+} from '@mui/material/AccordionSummary'
import { Trash as TrashIcon, NavArrowRight as ExpandIcon } from 'iconoir-react'
import { useVmApi } from 'client/features/One'
@@ -35,60 +37,70 @@ import MultipleTags from 'client/components/MultipleTags'
import { Translate } from 'client/components/HOC'
import { T, VM_ACTIONS } from 'client/constants'
-const Accordion = styled(props => (
+const Accordion = styled((props) => (
))(({ theme }) => ({
border: `1px solid ${theme.palette.divider}`,
- '&:before': { display: 'none' }
+ '&:before': { display: 'none' },
}))
-const Summary = styled(AccordionSummary)(({
+const Summary = styled(AccordionSummary)({
[`&.${accordionSummaryClasses.root}`]: {
backgroundColor: 'rgba(0, 0, 0, .03)',
flexDirection: 'row-reverse',
- '&:hover': { backgroundColor: 'rgba(0, 0, 0, .07)' }
+ '&:hover': { backgroundColor: 'rgba(0, 0, 0, .07)' },
},
- [`& .${accordionSummaryClasses.expandIconWrapper}.${accordionSummaryClasses.expanded}`]: {
- transform: 'rotate(90deg)'
- }
-}))
+ [`& .${accordionSummaryClasses.expandIconWrapper}.${accordionSummaryClasses.expanded}`]:
+ {
+ transform: 'rotate(90deg)',
+ },
+})
const Row = styled('div')({
display: 'flex',
width: '100%',
gap: '0.5em',
alignItems: 'center',
- flexWrap: 'nowrap'
+ flexWrap: 'nowrap',
})
const Labels = styled('span')({
display: 'inline-flex',
gap: '0.5em',
- alignItems: 'center'
+ alignItems: 'center',
})
const Details = styled(AccordionDetails)({
display: 'flex',
flexDirection: 'column',
gap: '0.5em',
- marginLeft: '1em'
+ marginLeft: '1em',
})
const SecGroups = styled(Paper)({
display: 'flex',
flexDirection: 'column',
gap: '0.5em',
- padding: '0.8em'
+ padding: '0.8em',
})
const NetworkItem = ({ nic = {}, actions }) => {
- const isMobile = useMediaQuery(theme => theme.breakpoints.down('md'))
+ const isMobile = useMediaQuery((theme) => theme.breakpoints.down('md'))
const { display, show, hide, values } = useDialog()
const { detachNic } = useVmApi()
const { handleRefetch, data: vm } = useContext(TabContext)
- const { NIC_ID, NETWORK = '-', IP, MAC, PCI_ID, ADDRESS, ALIAS, SECURITY_GROUPS } = nic
+ const {
+ NIC_ID,
+ NETWORK = '-',
+ IP,
+ MAC,
+ PCI_ID,
+ ADDRESS,
+ ALIAS,
+ SECURITY_GROUPS,
+ } = nic
const isPciDevice = PCI_ID !== undefined
const hasDetails = useMemo(
@@ -97,7 +109,8 @@ const NetworkItem = ({ nic = {}, actions }) => {
)
const handleDetach = async () => {
- const response = values?.id !== undefined && (await detachNic(vm.ID, values.id))
+ const response =
+ values?.id !== undefined && (await detachNic(vm.ID, values.id))
String(response) === String(vm.ID) && (await handleRefetch?.(vm.ID))
hide()
@@ -118,9 +131,7 @@ const NetworkItem = ({ nic = {}, actions }) => {
})}>
-
- {`${NIC_ID} | ${NETWORK}`}
-
+ {`${NIC_ID} | ${NETWORK}`}
{
{ALIAS?.map(({ NIC_ID, NETWORK = '-', BRIDGE, IP, MAC }) => (
-
- {`${NIC_ID} | ${NETWORK}`}
+
+
+ {`${NIC_ID} | ${NETWORK}`}
{!isMobile && !isPciDevice && detachAction(NIC_ID, true)}
))}
{!!SECURITY_GROUPS?.length && (
-
-
+
+
- {SECURITY_GROUPS
- ?.map(({ ID, NAME, PROTOCOL, RULE_TYPE, ICMP_TYPE, RANGE, NETWORK_ID }, idx) => (
+ {SECURITY_GROUPS?.map(
+ (
+ {
+ ID,
+ NAME,
+ PROTOCOL,
+ RULE_TYPE,
+ ICMP_TYPE,
+ RANGE,
+ NETWORK_ID,
+ },
+ idx
+ ) => (
-
+
{`${ID} | ${NAME}`}
@@ -168,12 +193,13 @@ const NetworkItem = ({ nic = {}, actions }) => {
RULE_TYPE,
RANGE,
NETWORK_ID,
- ICMP_TYPE
+ ICMP_TYPE,
].filter(Boolean)}
/>
- ))}
+ )
+ )}
)}
@@ -185,7 +211,8 @@ const NetworkItem = ({ nic = {}, actions }) => {
title={
+ values={`${values?.isAlias ? T.Alias : T.NIC} #${values?.id}`}
+ />
}
handleAccept={handleDetach}
handleCancel={hide}
@@ -201,7 +228,7 @@ const NetworkItem = ({ nic = {}, actions }) => {
NetworkItem.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
- nic: PropTypes.object
+ nic: PropTypes.object,
}
NetworkItem.displayName = 'NetworkItem'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Network/List.js b/src/fireedge/src/client/components/Tabs/Vm/Network/List.js
index 774f362974..98860b077c 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Network/List.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Network/List.js
@@ -19,13 +19,15 @@ import PropTypes from 'prop-types'
import NetworkItem from 'client/components/Tabs/Vm/Network/Item'
const NetworkList = ({ nics, actions }) => (
-
- {nics.map(nic => {
+
+ {nics.map((nic) => {
const { IP, MAC, ADDRESS } = nic
const key = IP ?? MAC ?? ADDRESS // address only exists form PCI nics
@@ -36,7 +38,7 @@ const NetworkList = ({ nics, actions }) => (
NetworkList.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
- nics: PropTypes.array
+ nics: PropTypes.array,
}
NetworkList.displayName = 'NetworkList'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Network/index.js b/src/fireedge/src/client/components/Tabs/Vm/Network/index.js
index ec44e70daf..c037def443 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Network/index.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Network/index.js
@@ -24,7 +24,11 @@ import NetworkList from 'client/components/Tabs/Vm/Network/List'
import ButtonToTriggerForm from 'client/components/Forms/ButtonToTriggerForm'
import { AttachNicForm } from 'client/components/Forms/Vm'
-import { getNics, getHypervisor, isAvailableAction } from 'client/models/VirtualMachine'
+import {
+ getNics,
+ getHypervisor,
+ isAvailableAction,
+} from 'client/models/VirtualMachine'
import { jsonToXml, getActionsAvailable } from 'client/models/Helper'
import { T, VM_ACTIONS } from 'client/constants'
@@ -34,16 +38,20 @@ const VmNetworkTab = ({ tabProps: { actions } = {} }) => {
const { handleRefetch, data: vm } = useContext(TabContext)
const [nics, actionsAvailable] = useMemo(() => {
- const groupedNics = getNics(vm, { groupAlias: true, securityGroupsFromTemplate: true })
+ const groupedNics = getNics(vm, {
+ groupAlias: true,
+ securityGroupsFromTemplate: true,
+ })
const hypervisor = getHypervisor(vm)
const actionsByHypervisor = getActionsAvailable(actions, hypervisor)
- const actionsByState = actionsByHypervisor
- .filter(action => !isAvailableAction(action)(vm))
+ const actionsByState = actionsByHypervisor.filter(
+ (action) => !isAvailableAction(action)(vm)
+ )
return [groupedNics, actionsByState]
}, [vm])
- const handleAttachNic = async formData => {
+ const handleAttachNic = async (formData) => {
const isAlias = !!formData?.PARENT?.length
const data = { [isAlias ? 'NIC_ALIAS' : 'NIC']: formData }
@@ -61,13 +69,15 @@ const VmNetworkTab = ({ tabProps: { actions } = {} }) => {
color: 'secondary',
'data-cy': 'attach-nic',
label: T.AttachNic,
- variant: 'outlined'
+ variant: 'outlined',
}}
- options={[{
- dialogProps: { title: T.AttachNic },
- form: () => AttachNicForm({ nics }),
- onSubmit: handleAttachNic
- }]}
+ options={[
+ {
+ dialogProps: { title: T.AttachNic },
+ form: () => AttachNicForm({ nics }),
+ onSubmit: handleAttachNic,
+ },
+ ]}
/>
)}
@@ -77,7 +87,7 @@ const VmNetworkTab = ({ tabProps: { actions } = {} }) => {
}
VmNetworkTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
VmNetworkTab.displayName = 'VmNetworkTab'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/SchedActions/Actions.js b/src/fireedge/src/client/components/Tabs/Vm/SchedActions/Actions.js
index 752a90ed36..5df2072e9d 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/SchedActions/Actions.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/SchedActions/Actions.js
@@ -33,7 +33,7 @@ const CreateSchedAction = memo(() => {
const { addScheduledAction } = useVmApi()
const { handleRefetch, data: vm } = useContext(TabContext)
- const handleCreateSchedAction = async formData => {
+ const handleCreateSchedAction = async (formData) => {
const data = { template: Helper.jsonToXml({ SCHED_ACTION: formData }) }
const response = await addScheduledAction(vm.ID, data)
@@ -46,22 +46,24 @@ const CreateSchedAction = memo(() => {
color: 'secondary',
'data-cy': 'create-sched-action',
label: T.AddAction,
- variant: 'outlined'
+ variant: 'outlined',
}}
- options={[{
- cy: 'create-sched-action-punctual',
- name: 'Punctual action',
- dialogProps: { title: T.ScheduledAction },
- form: () => PunctualForm(vm),
- onSubmit: handleCreateSchedAction
- },
- {
- cy: 'create-sched-action-relative',
- name: 'Relative action',
- dialogProps: { title: T.ScheduledAction },
- form: () => RelativeForm(vm),
- onSubmit: handleCreateSchedAction
- }]}
+ options={[
+ {
+ cy: 'create-sched-action-punctual',
+ name: 'Punctual action',
+ dialogProps: { title: T.ScheduledAction },
+ form: () => PunctualForm(vm),
+ onSubmit: handleCreateSchedAction,
+ },
+ {
+ cy: 'create-sched-action-relative',
+ name: 'Relative action',
+ dialogProps: { title: T.ScheduledAction },
+ form: () => RelativeForm(vm),
+ onSubmit: handleCreateSchedAction,
+ },
+ ]}
/>
)
})
@@ -72,10 +74,10 @@ const UpdateSchedAction = memo(({ schedule, name }) => {
const { updateScheduledAction } = useVmApi()
const { handleRefetch, data: vm } = useContext(TabContext)
- const handleUpdate = async formData => {
+ const handleUpdate = async (formData) => {
const data = {
id_sched: ID,
- template: Helper.jsonToXml({ SCHED_ACTION: formData })
+ template: Helper.jsonToXml({ SCHED_ACTION: formData }),
}
const response = await updateScheduledAction(vm.ID, data)
@@ -88,17 +90,20 @@ const UpdateSchedAction = memo(({ schedule, name }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.SCHED_ACTION_UPDATE}-${ID}`,
icon:
,
- tooltip:
+ tooltip:
,
}}
- options={[{
- dialogProps: {
- title:
+ options={[
+ {
+ dialogProps: {
+ title:
,
+ },
+ form: () =>
+ isRelative
+ ? RelativeForm(vm, schedule)
+ : PunctualForm(vm, schedule),
+ onSubmit: handleUpdate,
},
- form: () => isRelative
- ? RelativeForm(vm, schedule)
- : PunctualForm(vm, schedule),
- onSubmit: handleUpdate
- }]}
+ ]}
/>
)
})
@@ -120,16 +125,18 @@ const DeleteSchedAction = memo(({ schedule, name }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.SCHED_ACTION_DELETE}-${ID}`,
icon:
,
- tooltip:
+ tooltip:
,
}}
- options={[{
- isConfirmDialog: true,
- dialogProps: {
- title:
,
- children:
{Tr(T.DoYouWantProceed)}
+ options={[
+ {
+ isConfirmDialog: true,
+ dialogProps: {
+ title:
,
+ children:
{Tr(T.DoYouWantProceed)}
,
+ },
+ onSubmit: handleDelete,
},
- onSubmit: handleDelete
- }]}
+ ]}
/>
)
})
@@ -142,21 +149,26 @@ const CharterAction = memo(() => {
const leases = Object.entries(config?.leases ?? {})
const handleCreateCharter = async () => {
- const schedActions = leases
- .map(([action, { time, warning: { time: warningTime } = {} } = {}]) => ({
+ const schedActions = leases.map(
+ ([action, { time, warning: { time: warningTime } = {} } = {}]) => ({
TIME: `+${+time}`,
ACTION: action,
- ...(warningTime && { WARNING: `-${+warningTime}` })
- }))
+ ...(warningTime && { WARNING: `-${+warningTime}` }),
+ })
+ )
const response = await Promise.all(
- schedActions.map(schedAction => {
- const data = { template: Helper.jsonToXml({ SCHED_ACTION: schedAction }) }
+ schedActions.map((schedAction) => {
+ const data = {
+ template: Helper.jsonToXml({ SCHED_ACTION: schedAction }),
+ }
+
return addScheduledAction(vm.ID, data)
})
)
- response.some(res => String(res) === String(vm?.ID)) && (await handleRefetch?.(vm.ID))
+ response.some((res) => String(res) === String(vm?.ID)) &&
+ (await handleRefetch?.(vm.ID))
}
return (
@@ -164,48 +176,50 @@ const CharterAction = memo(() => {
buttonProps={{
'data-cy': 'create-charter',
icon:
,
- tooltip:
+ tooltip:
,
}}
- options={[{
- isConfirmDialog: true,
- dialogProps: {
- title: Tr(T.ScheduledAction),
- children: (
- <>
- {leases.map(([action, { time } = {}], idx) => {
- const allPeriods = {
- years: time / 365 / 24 / 3600,
- months: time / 30 / 24 / 3600,
- weeks: time / 7 / 24 / 3600,
- days: time / 24 / 3600,
- hours: time / 3600,
- minutes: time / 60
- }
+ options={[
+ {
+ isConfirmDialog: true,
+ dialogProps: {
+ title: Tr(T.ScheduledAction),
+ children: (
+ <>
+ {leases.map(([action, { time } = {}], idx) => {
+ const allPeriods = {
+ years: time / 365 / 24 / 3600,
+ months: time / 30 / 24 / 3600,
+ weeks: time / 7 / 24 / 3600,
+ days: time / 24 / 3600,
+ hours: time / 3600,
+ minutes: time / 60,
+ }
- const [period, parsedTime] = Object
- .entries(allPeriods)
- .find(([_, time]) => time >= 1)
+ const [period, parsedTime] = Object.entries(allPeriods).find(
+ ([_, time]) => time >= 1
+ )
- return (
-
- {`${action} - ${parsedTime} ${period}`}
-
- )
- })}
-
-
{Tr(T.DoYouWantProceed)}
- >
- )
+ return (
+
+ {`${action} - ${parsedTime} ${period}`}
+
+ )
+ })}
+
+
{Tr(T.DoYouWantProceed)}
+ >
+ ),
+ },
+ onSubmit: handleCreateCharter,
},
- onSubmit: handleCreateCharter
- }]}
+ ]}
/>
)
})
const ActionPropTypes = {
schedule: PropTypes.object,
- name: PropTypes.string
+ name: PropTypes.string,
}
CreateSchedAction.propTypes = ActionPropTypes
@@ -221,5 +235,5 @@ export {
CharterAction,
CreateSchedAction,
DeleteSchedAction,
- UpdateSchedAction
+ UpdateSchedAction,
}
diff --git a/src/fireedge/src/client/components/Tabs/Vm/SchedActions/Item.js b/src/fireedge/src/client/components/Tabs/Vm/SchedActions/Item.js
index a3e4474dc6..ebb0ecdb61 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/SchedActions/Item.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/SchedActions/Item.js
@@ -41,29 +41,25 @@ const SchedulingItem = ({ schedule, actions = [] }) => {
const titleAction = `#${ID} ${sentenceCase(ACTION)}`
const isRelative = String(TIME).includes('+')
- const time = timeFromMilliseconds(
- isRelative ? (vmStartTime + +TIME) : +TIME
- )
+ const time = timeFromMilliseconds(isRelative ? vmStartTime + +TIME : +TIME)
const doneTime = timeFromMilliseconds(+DONE)
const now = Math.round(Date.now() / 1000)
- const isWarning = WARNING && (now - vmStartTime) > +WARNING
+ const isWarning = WARNING && now - vmStartTime > +WARNING
const labels = [...new Set([MESSAGE])].filter(Boolean)
const { repeat, end } = VirtualMachine.periodicityToString(schedule)
return (
-
+
-
- {titleAction}
-
+ {titleAction}
{!!labels.length && (
- {labels.map(label => (
+ {labels.map((label) => (
))}
@@ -78,9 +74,7 @@ const SchedulingItem = ({ schedule, actions = [] }) => {
)}
-
- {`${time.toRelative()}`}
-
+ {`${time.toRelative()}`}
{isWarning && }
@@ -101,7 +95,7 @@ const SchedulingItem = ({ schedule, actions = [] }) => {
SchedulingItem.propTypes = {
schedule: PropTypes.object.isRequired,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
SchedulingItem.displayName = 'SchedulingItem'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/SchedActions/List.js b/src/fireedge/src/client/components/Tabs/Vm/SchedActions/List.js
index a6611252a4..96122799cd 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/SchedActions/List.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/SchedActions/List.js
@@ -20,19 +20,15 @@ import SchedulingItem from 'client/components/Tabs/Vm/SchedActions/Item'
const SchedulingList = ({ scheduling, actions }) => (
- {scheduling.map(schedule => (
-
+ {scheduling.map((schedule) => (
+
))}
)
SchedulingList.propTypes = {
scheduling: PropTypes.array,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
SchedulingList.displayName = 'SchedulingList'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/SchedActions/index.js b/src/fireedge/src/client/components/Tabs/Vm/SchedActions/index.js
index e114f6ba4e..d64385f145 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/SchedActions/index.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/SchedActions/index.js
@@ -19,10 +19,17 @@ import PropTypes from 'prop-types'
import { useAuth } from 'client/features/Auth'
import { TabContext } from 'client/components/Tabs/TabProvider'
-import { CreateSchedAction, CharterAction } from 'client/components/Tabs/Vm/SchedActions/Actions'
+import {
+ CreateSchedAction,
+ CharterAction,
+} from 'client/components/Tabs/Vm/SchedActions/Actions'
import SchedulingList from 'client/components/Tabs/Vm/SchedActions/List'
-import { getScheduleActions, getHypervisor, isAvailableAction } from 'client/models/VirtualMachine'
+import {
+ getScheduleActions,
+ getHypervisor,
+ isAvailableAction,
+} from 'client/models/VirtualMachine'
import { getActionsAvailable } from 'client/models/Helper'
import { VM_ACTIONS } from 'client/constants'
@@ -33,8 +40,9 @@ const VmSchedulingTab = ({ tabProps: { actions } = {} }) => {
const [scheduling, actionsAvailable] = useMemo(() => {
const hypervisor = getHypervisor(vm)
const actionsByHypervisor = getActionsAvailable(actions, hypervisor)
- const actionsByState = actionsByHypervisor
- .filter(action => !isAvailableAction(action)(vm))
+ const actionsByState = actionsByHypervisor.filter(
+ (action) => !isAvailableAction(action)(vm)
+ )
return [getScheduleActions(vm), actionsByState]
}, [vm])
@@ -44,9 +52,8 @@ const VmSchedulingTab = ({ tabProps: { actions } = {} }) => {
{actionsAvailable?.includes?.(VM_ACTIONS.SCHED_ACTION_CREATE) && (
)}
- {actionsAvailable?.includes?.(VM_ACTIONS.CHARTER_CREATE) && config?.leases && (
-
- )}
+ {actionsAvailable?.includes?.(VM_ACTIONS.CHARTER_CREATE) &&
+ config?.leases &&
}
>
@@ -54,7 +61,7 @@ const VmSchedulingTab = ({ tabProps: { actions } = {} }) => {
}
VmSchedulingTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
VmSchedulingTab.displayName = 'VmSchedulingTab'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Snapshot/Actions.js b/src/fireedge/src/client/components/Tabs/Vm/Snapshot/Actions.js
index a116d14e67..3f559e58cb 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Snapshot/Actions.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Snapshot/Actions.js
@@ -37,16 +37,23 @@ const RevertAction = memo(({ snapshot }) => {
+ icon:
,
}}
- options={[{
- isConfirmDialog: true,
- dialogProps: {
- title:
,
- children:
{Tr(T.DoYouWantProceed)}
+ options={[
+ {
+ isConfirmDialog: true,
+ dialogProps: {
+ title: (
+
+ ),
+ children:
{Tr(T.DoYouWantProceed)}
,
+ },
+ onSubmit: handleRevert,
},
- onSubmit: handleRevert
- }]}
+ ]}
/>
)
})
@@ -62,23 +69,30 @@ const DeleteAction = memo(({ snapshot }) => {
+ icon:
,
}}
- options={[{
- isConfirmDialog: true,
- dialogProps: {
- title:
,
- children:
{Tr(T.DoYouWantProceed)}
+ options={[
+ {
+ isConfirmDialog: true,
+ dialogProps: {
+ title: (
+
+ ),
+ children:
{Tr(T.DoYouWantProceed)}
,
+ },
+ onSubmit: handleDelete,
},
- onSubmit: handleDelete
- }]}
+ ]}
/>
)
})
const ActionPropTypes = {
snapshot: PropTypes.object,
- name: PropTypes.string
+ name: PropTypes.string,
}
RevertAction.propTypes = ActionPropTypes
@@ -86,7 +100,4 @@ RevertAction.displayName = 'RevertActionButton'
DeleteAction.propTypes = ActionPropTypes
DeleteAction.displayName = 'DeleteActionButton'
-export {
- DeleteAction,
- RevertAction
-}
+export { DeleteAction, RevertAction }
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Snapshot/Item.js b/src/fireedge/src/client/components/Tabs/Vm/Snapshot/Item.js
index 31a1cc748b..5e0d456d5a 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Snapshot/Item.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Snapshot/Item.js
@@ -32,12 +32,10 @@ const SnapshotItem = ({ snapshot, actions = [] }) => {
const timeAgo = `created ${time.toRelative()}`
return (
-
+
-
- {NAME}
-
+ {NAME}
@@ -61,7 +59,7 @@ const SnapshotItem = ({ snapshot, actions = [] }) => {
SnapshotItem.propTypes = {
snapshot: PropTypes.object.isRequired,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
SnapshotItem.displayName = 'SnapshotItem'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Snapshot/List.js b/src/fireedge/src/client/components/Tabs/Vm/Snapshot/List.js
index 992bd1ec57..f2869fb728 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Snapshot/List.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Snapshot/List.js
@@ -28,7 +28,7 @@ const SnapshotList = ({ snapshots, actions }) => (
SnapshotList.propTypes = {
snapshots: PropTypes.array,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
SnapshotList.displayName = 'SnapshotList'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Snapshot/index.js b/src/fireedge/src/client/components/Tabs/Vm/Snapshot/index.js
index 41f165b9fb..8673881378 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Snapshot/index.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Snapshot/index.js
@@ -24,7 +24,11 @@ import SnapshotList from 'client/components/Tabs/Vm/Snapshot/List'
import ButtonToTriggerForm from 'client/components/Forms/ButtonToTriggerForm'
import { CreateSnapshotForm } from 'client/components/Forms/Vm'
-import { getSnapshotList, getHypervisor, isAvailableAction } from 'client/models/VirtualMachine'
+import {
+ getSnapshotList,
+ getHypervisor,
+ isAvailableAction,
+} from 'client/models/VirtualMachine'
import { getActionsAvailable } from 'client/models/Helper'
import { T, VM_ACTIONS } from 'client/constants'
@@ -36,8 +40,9 @@ const VmSnapshotTab = ({ tabProps: { actions } = {} }) => {
const [snapshots, actionsAvailable] = useMemo(() => {
const hypervisor = getHypervisor(vm)
const actionsByHypervisor = getActionsAvailable(actions, hypervisor)
- const actionsByState = actionsByHypervisor
- .filter(action => !isAvailableAction(action)(vm))
+ const actionsByState = actionsByHypervisor.filter(
+ (action) => !isAvailableAction(action)(vm)
+ )
return [getSnapshotList(vm), actionsByState]
}, [vm])
@@ -54,13 +59,15 @@ const VmSnapshotTab = ({ tabProps: { actions } = {} }) => {
color: 'secondary',
'data-cy': 'snapshot-create',
label: T.TakeSnapshot,
- variant: 'outlined'
+ variant: 'outlined',
}}
- options={[{
- dialogProps: { title: T.TakeSnapshot },
- form: () => CreateSnapshotForm(),
- onSubmit: handleSnapshotCreate
- }]}
+ options={[
+ {
+ dialogProps: { title: T.TakeSnapshot },
+ form: () => CreateSnapshotForm(),
+ onSubmit: handleSnapshotCreate,
+ },
+ ]}
/>
)}
@@ -70,7 +77,7 @@ const VmSnapshotTab = ({ tabProps: { actions } = {} }) => {
}
VmSnapshotTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
VmSnapshotTab.displayName = 'VmSnapshotTab'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Storage/Actions.js b/src/fireedge/src/client/components/Tabs/Vm/Storage/Actions.js
index 8b62882a4f..5880b02931 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Storage/Actions.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Storage/Actions.js
@@ -17,12 +17,23 @@
import { memo, useContext } from 'react'
import PropTypes from 'prop-types'
-import { Trash, Edit, UndoAction, SaveActionFloppy, Camera, Expand } from 'iconoir-react'
+import {
+ Trash,
+ Edit,
+ UndoAction,
+ SaveActionFloppy,
+ Camera,
+ Expand,
+} from 'iconoir-react'
import { useVmApi } from 'client/features/One'
import { TabContext } from 'client/components/Tabs/TabProvider'
import ButtonToTriggerForm from 'client/components/Forms/ButtonToTriggerForm'
-import { SaveAsDiskForm, CreateDiskSnapshotForm, ResizeDiskForm } from 'client/components/Forms/Vm'
+import {
+ SaveAsDiskForm,
+ CreateDiskSnapshotForm,
+ ResizeDiskForm,
+} from 'client/components/Forms/Vm'
import { Tr, Translate } from 'client/components/HOC'
import { T, VM_ACTIONS } from 'client/constants'
@@ -39,16 +50,23 @@ const DetachAction = memo(({ disk, name: imageName }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.DETACH_DISK}-${DISK_ID}`,
icon: ,
- tooltip: Tr(T.Detach)
+ tooltip: Tr(T.Detach),
}}
- options={[{
- isConfirmDialog: true,
- dialogProps: {
- title: ,
- children: {Tr(T.DoYouWantProceed)}
+ options={[
+ {
+ isConfirmDialog: true,
+ dialogProps: {
+ title: (
+
+ ),
+ children: {Tr(T.DoYouWantProceed)}
,
+ },
+ onSubmit: handleDetach,
},
- onSubmit: handleDetach
- }]}
+ ]}
/>
)
})
@@ -72,18 +90,28 @@ const SaveAsAction = memo(({ disk, snapshot, name: imageName }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.DISK_SAVEAS}-${diskId}`,
icon: ,
- tooltip: Tr(T.SaveAs)
+ tooltip: Tr(T.SaveAs),
}}
- options={[{
- dialogProps: {
- title: snapshot
- ?
- : ,
- children: {Tr(T.DoYouWantProceed)}
+ options={[
+ {
+ dialogProps: {
+ title: snapshot ? (
+
+ ) : (
+
+ ),
+ children: {Tr(T.DoYouWantProceed)}
,
+ },
+ form: () => SaveAsDiskForm(),
+ onSubmit: handleSaveAs,
},
- form: () => SaveAsDiskForm(),
- onSubmit: handleSaveAs
- }]}
+ ]}
/>
)
})
@@ -103,20 +131,22 @@ const ResizeAction = memo(({ disk, name: imageName }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.RESIZE_DISK}-${DISK_ID}`,
icon: ,
- tooltip: Tr(T.Resize)
+ tooltip: Tr(T.Resize),
}}
- options={[{
- dialogProps: {
- title: (
-
- )
+ options={[
+ {
+ dialogProps: {
+ title: (
+
+ ),
+ },
+ form: () => ResizeDiskForm(undefined, disk),
+ onSubmit: handleResize,
},
- form: () => ResizeDiskForm(undefined, disk),
- onSubmit: handleResize
- }]}
+ ]}
/>
)
})
@@ -136,20 +166,22 @@ const SnapshotCreateAction = memo(({ disk, name: imageName }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.SNAPSHOT_DISK_CREATE}-${DISK_ID}`,
icon: ,
- tooltip: Tr(T.TakeSnapshot)
+ tooltip: Tr(T.TakeSnapshot),
}}
- options={[{
- dialogProps: {
- title: (
-
- )
+ options={[
+ {
+ dialogProps: {
+ title: (
+
+ ),
+ },
+ form: () => CreateDiskSnapshotForm(),
+ onSubmit: handleSnapshotCreate,
},
- form: () => CreateDiskSnapshotForm(),
- onSubmit: handleSnapshotCreate
- }]}
+ ]}
/>
)
})
@@ -172,16 +204,20 @@ const SnapshotRenameAction = memo(({ disk, snapshot }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.SNAPSHOT_DISK_RENAME}-${DISK_ID}-${ID}`,
icon: ,
- tooltip: Tr(T.Edit)
+ tooltip: Tr(T.Edit),
}}
- options={[{
- dialogProps: {
- title: ,
- children: {Tr(T.DoYouWantProceed)}
+ options={[
+ {
+ dialogProps: {
+ title: (
+
+ ),
+ children: {Tr(T.DoYouWantProceed)}
,
+ },
+ form: () => CreateDiskSnapshotForm(undefined, snapshot),
+ onSubmit: handleRename,
},
- form: () => CreateDiskSnapshotForm(undefined, snapshot),
- onSubmit: handleRename
- }]}
+ ]}
/>
)
})
@@ -202,16 +238,20 @@ const SnapshotRevertAction = memo(({ disk, snapshot }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.SNAPSHOT_DISK_REVERT}-${DISK_ID}-${ID}`,
icon: ,
- tooltip: Tr(T.Revert)
+ tooltip: Tr(T.Revert),
}}
- options={[{
- isConfirmDialog: true,
- dialogProps: {
- title: ,
- children: {Tr(T.DoYouWantProceed)}
+ options={[
+ {
+ isConfirmDialog: true,
+ dialogProps: {
+ title: (
+
+ ),
+ children: {Tr(T.DoYouWantProceed)}
,
+ },
+ onSubmit: handleRevert,
},
- onSubmit: handleRevert
- }]}
+ ]}
/>
)
})
@@ -232,16 +272,20 @@ const SnapshotDeleteAction = memo(({ disk, snapshot }) => {
buttonProps={{
'data-cy': `${VM_ACTIONS.SNAPSHOT_DISK_DELETE}-${DISK_ID}-${ID}`,
icon: ,
- tooltip: Tr(T.Delete)
+ tooltip: Tr(T.Delete),
}}
- options={[{
- isConfirmDialog: true,
- dialogProps: {
- title: ,
- children: {Tr(T.DoYouWantProceed)}
+ options={[
+ {
+ isConfirmDialog: true,
+ dialogProps: {
+ title: (
+
+ ),
+ children: {Tr(T.DoYouWantProceed)}
,
+ },
+ onSubmit: handleDelete,
},
- onSubmit: handleDelete
- }]}
+ ]}
/>
)
})
@@ -249,7 +293,7 @@ const SnapshotDeleteAction = memo(({ disk, snapshot }) => {
const ActionPropTypes = {
disk: PropTypes.object,
snapshot: PropTypes.object,
- name: PropTypes.string
+ name: PropTypes.string,
}
DetachAction.propTypes = ActionPropTypes
@@ -274,5 +318,5 @@ export {
SnapshotCreateAction,
SnapshotDeleteAction,
SnapshotRenameAction,
- SnapshotRevertAction
+ SnapshotRevertAction,
}
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Storage/Item.js b/src/fireedge/src/client/components/Tabs/Vm/Storage/Item.js
index b2750ef156..bea7ab6718 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Storage/Item.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Storage/Item.js
@@ -46,7 +46,7 @@ const StorageItem = ({ disk, actions = [] }) => {
SAVE,
CLONE,
IS_CONTEXT,
- SNAPSHOTS
+ SNAPSHOTS,
} = disk
const size = +SIZE ? prettyBytes(+SIZE, 'MB') : '-'
@@ -55,36 +55,36 @@ const StorageItem = ({ disk, actions = [] }) => {
const isImage = IMAGE_ID !== undefined
const type = String(TYPE).toLowerCase()
- const image = IMAGE ?? ({
- fs: `${FORMAT} - ${size}`,
- swap: size
- }[type])
+ const image =
+ IMAGE ??
+ {
+ fs: `${FORMAT} - ${size}`,
+ swap: size,
+ }[type]
- const labels = [...new Set([
- TYPE,
- Helper.stringToBoolean(PERSISTENT) && 'PERSISTENT',
- Helper.stringToBoolean(READONLY) && 'READONLY',
- Helper.stringToBoolean(SAVE) && 'SAVE',
- Helper.stringToBoolean(CLONE) && 'CLONE'
- ])].filter(Boolean)
+ const labels = [
+ ...new Set([
+ TYPE,
+ Helper.stringToBoolean(PERSISTENT) && 'PERSISTENT',
+ Helper.stringToBoolean(READONLY) && 'READONLY',
+ Helper.stringToBoolean(SAVE) && 'SAVE',
+ Helper.stringToBoolean(CLONE) && 'CLONE',
+ ]),
+ ].filter(Boolean)
return (
-
+
-
- {image}
-
+ {image}
- {labels.map(label => (
+ {labels.map((label) => (
))}
-
- {`#${DISK_ID}`}
-
+
{`#${DISK_ID}`}
{TARGET && (
@@ -121,7 +121,7 @@ const StorageItem = ({ disk, actions = [] }) => {
)}
{SNAPSHOTS?.length > 0 && (
- {SNAPSHOTS?.map(snapshot => (
+ {SNAPSHOTS?.map((snapshot) => (
{
StorageItem.propTypes = {
disk: PropTypes.object.isRequired,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
StorageItem.displayName = 'StorageItem'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Storage/List.js b/src/fireedge/src/client/components/Tabs/Vm/Storage/List.js
index 886d344552..9034532b07 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Storage/List.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Storage/List.js
@@ -28,7 +28,7 @@ const StorageList = ({ disks, actions }) => (
StorageList.propTypes = {
disks: PropTypes.array,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
StorageList.displayName = 'StorageList'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Storage/SubItem.js b/src/fireedge/src/client/components/Tabs/Vm/Storage/SubItem.js
index fbd838d06c..7032da826e 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Storage/SubItem.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Storage/SubItem.js
@@ -38,7 +38,7 @@ const StorageSubItem = ({ disk, snapshot = {}, actions = [] }) => {
ACTIVE,
DATE,
SIZE: SNAPSHOT_SIZE,
- MONITOR_SIZE: SNAPSHOT_MONITOR_SIZE
+ MONITOR_SIZE: SNAPSHOT_MONITOR_SIZE,
} = snapshot
const isActive = Helper.stringToBoolean(ACTIVE)
@@ -51,19 +51,17 @@ const StorageSubItem = ({ disk, snapshot = {}, actions = [] }) => {
: '-'
return (
-
+
- {NAME}
+ {NAME}
{isActive && } />}
} />
-
- {`#${ID} ${timeAgo}`}
-
+
{`#${ID} ${timeAgo}`}
{` ${monitorSize}/${size}`}
@@ -93,7 +91,7 @@ const StorageSubItem = ({ disk, snapshot = {}, actions = [] }) => {
StorageSubItem.propTypes = {
disk: PropTypes.object.isRequired,
snapshot: PropTypes.object.isRequired,
- actions: PropTypes.arrayOf(PropTypes.string)
+ actions: PropTypes.arrayOf(PropTypes.string),
}
StorageSubItem.displayName = 'StorageSubItem'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/Storage/index.js b/src/fireedge/src/client/components/Tabs/Vm/Storage/index.js
index 057034fcaa..4bc6a3d61f 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/Storage/index.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/Storage/index.js
@@ -24,7 +24,11 @@ import StorageList from 'client/components/Tabs/Vm/Storage/List'
import ButtonToTriggerForm from 'client/components/Forms/ButtonToTriggerForm'
import { ImageSteps, VolatileSteps } from 'client/components/Forms/Vm'
-import { getDisks, getHypervisor, isAvailableAction } from 'client/models/VirtualMachine'
+import {
+ getDisks,
+ getHypervisor,
+ isAvailableAction,
+} from 'client/models/VirtualMachine'
import { getActionsAvailable, jsonToXml } from 'client/models/Helper'
import { T, VM_ACTIONS } from 'client/constants'
@@ -36,13 +40,14 @@ const VmStorageTab = ({ tabProps: { actions } = {} }) => {
const [disks, hypervisor, actionsAvailable] = useMemo(() => {
const hyperV = getHypervisor(vm)
const actionsByHypervisor = getActionsAvailable(actions, hyperV)
- const actionsByState = actionsByHypervisor
- .filter(action => !isAvailableAction(action)(vm))
+ const actionsByState = actionsByHypervisor.filter(
+ (action) => !isAvailableAction(action)(vm)
+ )
return [getDisks(vm), hyperV, actionsByState]
}, [vm])
- const handleAttachDisk = async formData => {
+ const handleAttachDisk = async (formData) => {
const template = jsonToXml({ DISK: formData })
await attachDisk(vm.ID, template)
@@ -56,7 +61,7 @@ const VmStorageTab = ({ tabProps: { actions } = {} }) => {
color: 'secondary',
'data-cy': 'attach-disk',
label: T.AttachDisk,
- variant: 'outlined'
+ variant: 'outlined',
}}
options={[
{
@@ -64,15 +69,15 @@ const VmStorageTab = ({ tabProps: { actions } = {} }) => {
name: T.Image,
dialogProps: { title: T.AttachImage },
form: () => ImageSteps({ hypervisor }),
- onSubmit: handleAttachDisk
+ onSubmit: handleAttachDisk,
},
{
cy: 'attach-volatile-disk',
name: T.Volatile,
dialogProps: { title: T.AttachVolatile },
form: () => VolatileSteps({ hypervisor }),
- onSubmit: handleAttachDisk
- }
+ onSubmit: handleAttachDisk,
+ },
]}
/>
)}
@@ -83,7 +88,7 @@ const VmStorageTab = ({ tabProps: { actions } = {} }) => {
}
VmStorageTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
VmStorageTab.displayName = 'VmStorageTab'
diff --git a/src/fireedge/src/client/components/Tabs/Vm/index.js b/src/fireedge/src/client/components/Tabs/Vm/index.js
index ce95ff5294..dfcf2b7745 100644
--- a/src/fireedge/src/client/components/Tabs/Vm/index.js
+++ b/src/fireedge/src/client/components/Tabs/Vm/index.js
@@ -36,28 +36,27 @@ import SchedActions from 'client/components/Tabs/Vm/SchedActions'
import Snapshot from 'client/components/Tabs/Vm/Snapshot'
import Storage from 'client/components/Tabs/Vm/Storage'
-const getTabComponent = tabName => ({
- capacity: Capacity,
- configuration: Configuration,
- info: Info,
- log: Log,
- network: Network,
- history: History,
- schedActions: SchedActions,
- snapshot: Snapshot,
- storage: Storage
-}[tabName])
+const getTabComponent = (tabName) =>
+ ({
+ capacity: Capacity,
+ configuration: Configuration,
+ info: Info,
+ log: Log,
+ network: Network,
+ history: History,
+ schedActions: SchedActions,
+ snapshot: Snapshot,
+ storage: Storage,
+ }[tabName])
const VmTabs = memo(({ id }) => {
const { getHooksSocket } = useSocket()
const { getVm } = useVmApi()
- const {
- data,
- fetchRequest,
- loading,
- error
- } = useFetch(getVm, getHooksSocket({ resource: 'vm', id }))
+ const { data, fetchRequest, loading, error } = useFetch(
+ getVm,
+ getHooksSocket({ resource: 'vm', id })
+ )
const handleRefetch = () => fetchRequest(id, { reload: true })
@@ -71,22 +70,26 @@ const VmTabs = memo(({ id }) => {
useEffect(() => {
const infoTabs = getResourceView('VM')?.['info-tabs'] ?? {}
- setTabs(() => Object.entries(infoTabs)
- ?.filter(([_, { enabled } = {}]) => !!enabled)
- ?.map(([tabName, tabProps]) => {
- const camelName = camelCase(tabName)
- const TabContent = getTabComponent(camelName)
+ setTabs(() =>
+ Object.entries(infoTabs)
+ ?.filter(([_, { enabled } = {}]) => !!enabled)
+ ?.map(([tabName, tabProps]) => {
+ const camelName = camelCase(tabName)
+ const TabContent = getTabComponent(camelName)
- return TabContent && {
- name: camelName,
- renderContent: props => TabContent({ ...props, tabProps })
- }
- })
- ?.filter(Boolean))
+ return (
+ TabContent && {
+ name: camelName,
+ renderContent: (props) => TabContent({ ...props, tabProps }),
+ }
+ )
+ })
+ ?.filter(Boolean)
+ )
}, [view])
if ((!data && !error) || loading) {
- return
+ return
}
return (
@@ -97,7 +100,7 @@ const VmTabs = memo(({ id }) => {
})
VmTabs.propTypes = {
- id: PropTypes.string.isRequired
+ id: PropTypes.string.isRequired,
}
VmTabs.displayName = 'VmTabs'
diff --git a/src/fireedge/src/client/components/Tabs/VmTemplate/Info/index.js b/src/fireedge/src/client/components/Tabs/VmTemplate/Info/index.js
index 36228126b4..29c78e0359 100644
--- a/src/fireedge/src/client/components/Tabs/VmTemplate/Info/index.js
+++ b/src/fireedge/src/client/components/Tabs/VmTemplate/Info/index.js
@@ -27,19 +27,19 @@ const VmTemplateInfoTab = ({ tabProps = {} }) => {
const {
information_panel: informationPanel,
permissions_panel: permissionsPanel,
- ownership_panel: ownershipPanel
+ ownership_panel: ownershipPanel,
} = tabProps
const { rename, changeOwnership, changePermissions } = useVmTemplateApi()
const { handleRefetch, data: template = {} } = useContext(TabContext)
const { ID, UNAME, UID, GNAME, GID, PERMISSIONS } = template
- const handleChangeOwnership = async newOwnership => {
+ const handleChangeOwnership = async (newOwnership) => {
const response = await changeOwnership(ID, newOwnership)
String(response) === String(ID) && (await handleRefetch?.())
}
- const handleChangePermission = async newPermission => {
+ const handleChangePermission = async (newPermission) => {
const response = await changePermissions(ID, newPermission)
String(response) === String(ID) && (await handleRefetch?.())
}
@@ -49,15 +49,17 @@ const VmTemplateInfoTab = ({ tabProps = {} }) => {
String(response) === String(ID) && (await handleRefetch?.())
}
- const getActions = actions => Helper.getActionsAvailable(actions)
+ const getActions = (actions) => Helper.getActionsAvailable(actions)
return (
-
+
{informationPanel?.enabled && (
{
}
VmTemplateInfoTab.propTypes = {
- tabProps: PropTypes.object
+ tabProps: PropTypes.object,
}
VmTemplateInfoTab.displayName = 'VmTemplateInfoTab'
diff --git a/src/fireedge/src/client/components/Tabs/VmTemplate/Info/information.js b/src/fireedge/src/client/components/Tabs/VmTemplate/Info/information.js
index 8365cc2686..7ad341eb11 100644
--- a/src/fireedge/src/client/components/Tabs/VmTemplate/Info/information.js
+++ b/src/fireedge/src/client/components/Tabs/VmTemplate/Info/information.js
@@ -30,21 +30,19 @@ const InformationPanel = ({ template = {}, handleRename, actions }) => {
name: T.Name,
value: NAME,
canEdit: actions?.includes?.(VM_TEMPLATE_ACTIONS.RENAME),
- handleEdit: handleRename
+ handleEdit: handleRename,
},
{
name: T.StartTime,
- value: Helper.timeToString(REGTIME)
+ value: Helper.timeToString(REGTIME),
},
{
name: T.Locked,
- value: Helper.levelLockToString(LOCK?.LOCKED)
- }
+ value: Helper.levelLockToString(LOCK?.LOCKED),
+ },
]
- return (
-
- )
+ return
}
InformationPanel.displayName = 'InformationPanel'
@@ -52,7 +50,7 @@ InformationPanel.displayName = 'InformationPanel'
InformationPanel.propTypes = {
actions: PropTypes.arrayOf(PropTypes.string),
handleRename: PropTypes.func,
- template: PropTypes.object
+ template: PropTypes.object,
}
export default InformationPanel
diff --git a/src/fireedge/src/client/components/Tabs/VmTemplate/index.js b/src/fireedge/src/client/components/Tabs/VmTemplate/index.js
index 1578b651d9..bfe5e4d91c 100644
--- a/src/fireedge/src/client/components/Tabs/VmTemplate/index.js
+++ b/src/fireedge/src/client/components/Tabs/VmTemplate/index.js
@@ -29,10 +29,11 @@ import TabProvider from 'client/components/Tabs/TabProvider'
import Info from 'client/components/Tabs/VmTemplate/Info'
import Template from 'client/components/Tabs/VmTemplate/Template'
-const getTabComponent = tabName => ({
- info: Info,
- template: Template
-}[tabName])
+const getTabComponent = (tabName) =>
+ ({
+ info: Info,
+ template: Template,
+ }[tabName])
const VmTemplateTabs = memo(({ id }) => {
const { getVmTemplate } = useVmTemplateApi()
@@ -50,22 +51,26 @@ const VmTemplateTabs = memo(({ id }) => {
useEffect(() => {
const infoTabs = getResourceView('VM-TEMPLATE')?.['info-tabs'] ?? {}
- setTabs(() => Object.entries(infoTabs)
- ?.filter(([_, { enabled } = {}]) => !!enabled)
- ?.map(([tabName, tabProps]) => {
- const camelName = camelCase(tabName)
- const TabContent = getTabComponent(camelName)
+ setTabs(() =>
+ Object.entries(infoTabs)
+ ?.filter(([_, { enabled } = {}]) => !!enabled)
+ ?.map(([tabName, tabProps]) => {
+ const camelName = camelCase(tabName)
+ const TabContent = getTabComponent(camelName)
- return TabContent && {
- name: camelName,
- renderContent: props => TabContent({ ...props, tabProps })
- }
- })
- ?.filter(Boolean))
+ return (
+ TabContent && {
+ name: camelName,
+ renderContent: (props) => TabContent({ ...props, tabProps }),
+ }
+ )
+ })
+ ?.filter(Boolean)
+ )
}, [view])
if ((!data && !error) || loading) {
- return
+ return
}
return (
@@ -76,7 +81,7 @@ const VmTemplateTabs = memo(({ id }) => {
})
VmTemplateTabs.propTypes = {
- id: PropTypes.string.isRequired
+ id: PropTypes.string.isRequired,
}
VmTemplateTabs.displayName = 'VmTemplateTabs'
diff --git a/src/fireedge/src/client/components/Tabs/index.js b/src/fireedge/src/client/components/Tabs/index.js
index 3d35ed8058..33fe044eb3 100644
--- a/src/fireedge/src/client/components/Tabs/index.js
+++ b/src/fireedge/src/client/components/Tabs/index.js
@@ -16,25 +16,30 @@
import { useState, useMemo, JSXElementConstructor } from 'react'
import PropTypes from 'prop-types'
-import { styled, Tabs as MTabs, TabsProps, Tab as MTab, Box, Fade } from '@mui/material'
+import {
+ styled,
+ Tabs as MTabs,
+ TabsProps,
+ Tab as MTab,
+ Box,
+ Fade,
+} from '@mui/material'
import { WarningCircledOutline } from 'iconoir-react'
const WarningIcon = styled(WarningCircledOutline)(({ theme }) => ({
- color: theme.palette.error.main
+ color: theme.palette.error.main,
}))
const Content = ({ name, renderContent: RenderContent, hidden }) => (
theme.spacing(2, 1),
+ p: (theme) => theme.spacing(2, 1),
height: '100%',
- display: hidden ? 'none' : 'block'
+ display: hidden ? 'none' : 'block',
}}
>
- {typeof RenderContent === 'function'
- ?
- : RenderContent}
+ {typeof RenderContent === 'function' ? : RenderContent}
)
@@ -49,44 +54,51 @@ const Content = ({ name, renderContent: RenderContent, hidden }) => (
const Tabs = ({
tabs = [],
tabsProps: { sx, ...tabsProps } = {},
- renderHiddenTabs = false
+ renderHiddenTabs = false,
}) => {
const [tabSelected, setTab] = useState(() => 0)
- const renderTabs = useMemo(() => (
- setTab(tab)}
- sx={{
- position: 'sticky',
- top: 0,
- zIndex: theme => theme.zIndex.appBar,
- ...sx
- }}
- {...tabsProps}
- >
- {tabs.map(({ value, name, label, error, icon: Icon }, idx) => {
- return : (Icon && )}
- value={value ?? idx}
- label={label ?? name}
- />
- }
- )}
-
- ), [tabs, tabSelected])
+ const renderTabs = useMemo(
+ () => (
+ setTab(tab)}
+ sx={{
+ position: 'sticky',
+ top: 0,
+ zIndex: (theme) => theme.zIndex.appBar,
+ ...sx,
+ }}
+ {...tabsProps}
+ >
+ {tabs.map(({ value, name, label, error, icon: Icon }, idx) => {
+ return (
+ : Icon && }
+ value={value ?? idx}
+ label={label ?? name}
+ />
+ )
+ })}
+
+ ),
+ [tabs, tabSelected]
+ )
- const renderAllHiddenTabContents = useMemo(() =>
- tabs.map((tabProps, idx) => {
- const { name, value = idx } = tabProps
- const hidden = tabSelected !== value
+ const renderAllHiddenTabContents = useMemo(
+ () =>
+ tabs.map((tabProps, idx) => {
+ const { name, value = idx } = tabProps
+ const hidden = tabSelected !== value
- return
- }), [tabSelected])
+ return
+ }),
+ [tabSelected]
+ )
return (
<>
@@ -96,7 +108,9 @@ const Tabs = ({
{renderHiddenTabs ? (
renderAllHiddenTabContents
) : (
- (value ?? idx) === tabSelected)} />
+ (value ?? idx) === tabSelected)}
+ />
)}
>
)
@@ -108,16 +122,13 @@ Content.displayName = 'Content'
Tabs.propTypes = {
tabs: PropTypes.array,
tabsProps: PropTypes.object,
- renderHiddenTabs: PropTypes.bool
+ renderHiddenTabs: PropTypes.bool,
}
Content.propTypes = {
name: PropTypes.string,
- renderContent: PropTypes.oneOfType([
- PropTypes.object,
- PropTypes.func
- ]),
- hidden: PropTypes.bool
+ renderContent: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
+ hidden: PropTypes.bool,
}
export default Tabs
diff --git a/src/fireedge/src/client/components/Typography/DevTypography.js b/src/fireedge/src/client/components/Typography/DevTypography.js
index 61c51dd112..14716d2aa5 100644
--- a/src/fireedge/src/client/components/Typography/DevTypography.js
+++ b/src/fireedge/src/client/components/Typography/DevTypography.js
@@ -18,44 +18,36 @@ import PropTypes from 'prop-types'
import { Typography, Chip, Box } from '@mui/material'
-const DevTypography = memo(({
- labelProps = {},
- color = 'secondary',
- chipProps = {},
- children = ''
-}) => (
-
-
- {children}
-
-
-
-))
+const DevTypography = memo(
+ ({ labelProps = {}, color = 'secondary', chipProps = {}, children = '' }) => (
+
+
+ {children}
+
+
+
+ )
+)
DevTypography.propTypes = {
chipProps: PropTypes.object,
color: PropTypes.string,
labelProps: PropTypes.object,
- children: PropTypes.any
+ children: PropTypes.any,
}
DevTypography.displayName = 'DevTypography'
diff --git a/src/fireedge/src/client/components/Typography/TypographyWithPoint.js b/src/fireedge/src/client/components/Typography/TypographyWithPoint.js
index fa1b798d79..a7f2664efe 100644
--- a/src/fireedge/src/client/components/Typography/TypographyWithPoint.js
+++ b/src/fireedge/src/client/components/Typography/TypographyWithPoint.js
@@ -19,7 +19,7 @@ import PropTypes from 'prop-types'
import { Typography } from '@mui/material'
import makeStyles from '@mui/styles/makeStyles'
-const useStateStyles = makeStyles(theme => ({
+const useStateStyles = makeStyles((theme) => ({
root: {
color: theme.palette.text.secondary,
'&::before': {
@@ -29,13 +29,14 @@ const useStateStyles = makeStyles(theme => ({
height: '0.7rem',
width: '0.7rem',
background: ({ color }) => color,
- borderRadius: '50%'
- }
- }
+ borderRadius: '50%',
+ },
+ },
}))
const TypographyWithPoint = ({ pointColor, children, ...props }) => {
const classes = useStateStyles({ color: pointColor })
+
return (
{children}
@@ -48,13 +49,13 @@ TypographyWithPoint.propTypes = {
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.array,
- PropTypes.element
- ])
+ PropTypes.element,
+ ]),
}
TypographyWithPoint.defaultProps = {
pointColor: undefined,
- children: undefined
+ children: undefined,
}
TypographyWithPoint.displayName = 'TypographyWithPoint'
diff --git a/src/fireedge/src/client/components/Typography/index.js b/src/fireedge/src/client/components/Typography/index.js
index ea9a21865b..0d0fdb1244 100644
--- a/src/fireedge/src/client/components/Typography/index.js
+++ b/src/fireedge/src/client/components/Typography/index.js
@@ -16,7 +16,4 @@
import DevTypography from 'client/components/Typography/DevTypography'
import TypographyWithPoint from 'client/components/Typography/TypographyWithPoint'
-export {
- DevTypography,
- TypographyWithPoint
-}
+export { DevTypography, TypographyWithPoint }
diff --git a/src/fireedge/src/client/components/Widgets/TotalProviders/index.js b/src/fireedge/src/client/components/Widgets/TotalProviders/index.js
index ed6e77b87f..a2f4a4b26e 100644
--- a/src/fireedge/src/client/components/Widgets/TotalProviders/index.js
+++ b/src/fireedge/src/client/components/Widgets/TotalProviders/index.js
@@ -37,69 +37,74 @@ const TotalProviders = ({ isLoading }) => {
const chartData = useMemo(() => {
const groups = groupBy(providers, 'TEMPLATE.PLAIN.provider')
- return Object.entries(providerConfig)
- .map(([id, { name, color }]) => ({
- color,
- title: name,
- value: groups[id]?.length ?? 0
- }))
+ return Object.entries(providerConfig).map(([id, { name, color }]) => ({
+ color,
+ title: name,
+ value: groups[id]?.length ?? 0,
+ }))
}, [totalProviders])
- const title = useMemo(() => (
-
-
-
- {T.Providers}
-
-
- {T.InTotal}
-
-
- ), [classes, totalProviders])
+ const title = useMemo(
+ () => (
+
+
+
+ {T.Providers}
+
+ {T.InTotal}
+
+ ),
+ [classes, totalProviders]
+ )
- const legend = useMemo(() => (
-
- {chartData?.map(({ title: titleLegend, value, color }) =>
-
-
-
- {titleLegend}
-
-
- )}
-
- ), [classes, chartData])
+ const legend = useMemo(
+ () => (
+
+ {chartData?.map(({ title: titleLegend, value, color }) => (
+
+
+
+ {titleLegend}
+
+
+ ))}
+
+ ),
+ [classes, chartData]
+ )
- const chart = useMemo(() => (
-
- ), [classes, chartData])
-
- return useMemo(() => (
- !totalProviders && isLoading ? (
- (
+
- ) : (
-
- {title}
-
- {chart}
- {legend}
-
-
- )
- ), [classes, chart, totalProviders, isLoading])
+ ),
+ [classes, chartData]
+ )
+
+ return useMemo(
+ () =>
+ !totalProviders && isLoading ? (
+
+ ) : (
+
+ {title}
+
+ {chart}
+ {legend}
+
+
+ ),
+ [classes, chart, totalProviders, isLoading]
+ )
}
TotalProviders.displayName = 'TotalProviders'
diff --git a/src/fireedge/src/client/components/Widgets/TotalProviders/styles.js b/src/fireedge/src/client/components/Widgets/TotalProviders/styles.js
index 095bfec738..985b8577b4 100644
--- a/src/fireedge/src/client/components/Widgets/TotalProviders/styles.js
+++ b/src/fireedge/src/client/components/Widgets/TotalProviders/styles.js
@@ -15,40 +15,40 @@
* ------------------------------------------------------------------------- */
import makeStyles from '@mui/styles/makeStyles'
-export default makeStyles(theme => ({
+export default makeStyles((theme) => ({
root: {
- padding: '2em'
+ padding: '2em',
},
title: {
padding: '0 2em 2em',
- textAlign: 'left'
+ textAlign: 'left',
},
titlePrimary: {
fontSize: '2rem',
color: theme.palette.text.primary,
'& span': {
- marginLeft: '1rem'
- }
+ marginLeft: '1rem',
+ },
},
titleSecondary: {
fontSize: '1.4rem',
- color: theme.palette.text.secondary
+ color: theme.palette.text.secondary,
},
content: {
display: 'grid',
gridTemplateColumns: 'repeat(auto-fit, minmax(125px, 1fr))',
gridGap: '2em',
- padding: '0 2em'
+ padding: '0 2em',
},
legendSecondary: {
fontSize: '0.9rem',
marginLeft: '1.2rem',
- color: theme.palette.text.secondary
+ color: theme.palette.text.secondary,
},
chart: {
height: 200,
[theme.breakpoints.only('xs')]: {
- display: 'none'
- }
- }
+ display: 'none',
+ },
+ },
}))
diff --git a/src/fireedge/src/client/components/Widgets/TotalProvisionInfrastructures.js b/src/fireedge/src/client/components/Widgets/TotalProvisionInfrastructures.js
index 1aa88ff4d7..648f87c2e8 100644
--- a/src/fireedge/src/client/components/Widgets/TotalProvisionInfrastructures.js
+++ b/src/fireedge/src/client/components/Widgets/TotalProvisionInfrastructures.js
@@ -20,7 +20,7 @@ import {
Server as ClusterIcon,
HardDrive as HostIcon,
Folder as DatastoreIcon,
- NetworkAlt as NetworkIcon
+ NetworkAlt as NetworkIcon,
} from 'iconoir-react'
import { Skeleton, Grid } from '@mui/material'
@@ -36,76 +36,101 @@ const breakpoints = { xs: 12, sm: 6, md: 3 }
const TotalProvisionInfrastructures = ({ isLoading }) => {
const provisions = useProvision()
- const provisionsByProvider = useMemo(() =>
- provisions
- ?.map(provision => ({
+ const provisionsByProvider = useMemo(
+ () =>
+ provisions?.map((provision) => ({
provider: get(provision, 'TEMPLATE.BODY.provider'),
- clusters: get(provision, 'TEMPLATE.BODY.provision.infrastructure.clusters', []).length,
- hosts: get(provision, 'TEMPLATE.BODY.provision.infrastructure.hosts', []).length,
- networks: get(provision, 'TEMPLATE.BODY.provision.infrastructure.networks', []).length,
- datastores: get(provision, 'TEMPLATE.BODY.provision.infrastructure.datastores', []).length
- }))
- , [provisions])
+ clusters: get(
+ provision,
+ 'TEMPLATE.BODY.provision.infrastructure.clusters',
+ []
+ ).length,
+ hosts: get(
+ provision,
+ 'TEMPLATE.BODY.provision.infrastructure.hosts',
+ []
+ ).length,
+ networks: get(
+ provision,
+ 'TEMPLATE.BODY.provision.infrastructure.networks',
+ []
+ ).length,
+ datastores: get(
+ provision,
+ 'TEMPLATE.BODY.provision.infrastructure.datastores',
+ []
+ ).length,
+ })),
+ [provisions]
+ )
- const totals = useMemo(() =>
- provisionsByProvider?.reduce((total, { clusters, hosts, datastores, networks }) => ({
- clusters: clusters + total.clusters,
- hosts: hosts + total.hosts,
- datastores: datastores + total.datastores,
- networks: networks + total.networks
- }), { clusters: 0, hosts: 0, datastores: 0, networks: 0 })
- , [provisionsByProvider])
+ const totals = useMemo(
+ () =>
+ provisionsByProvider?.reduce(
+ (total, { clusters, hosts, datastores, networks }) => ({
+ clusters: clusters + total.clusters,
+ hosts: hosts + total.hosts,
+ datastores: datastores + total.datastores,
+ networks: networks + total.networks,
+ }),
+ { clusters: 0, hosts: 0, datastores: 0, networks: 0 }
+ ),
+ [provisionsByProvider]
+ )
- return useMemo(() => (
-
- {!totals?.clusters?.length && isLoading ? (
- Array.from(Array(TOTAL_WIDGETS)).map((_, index) => (
-
-
-
- ))
- ) : (
- <>
-
- }
- bgColor='#fa7892'
- icon={ClusterIcon}
- />
-
-
- }
- bgColor='#b25aff'
- icon={HostIcon}
- />
-
-
- }
- bgColor='#1fbbc6'
- icon={DatastoreIcon}
- />
-
-
- }
- bgColor='#f09d42'
- icon={NetworkIcon}
- />
-
- >
- )}
-
- ), [totals?.clusters, isLoading])
+ return useMemo(
+ () => (
+
+ {!totals?.clusters?.length && isLoading ? (
+ Array.from(Array(TOTAL_WIDGETS)).map((_, index) => (
+
+
+
+ ))
+ ) : (
+ <>
+
+ }
+ bgColor="#fa7892"
+ icon={ClusterIcon}
+ />
+
+
+ }
+ bgColor="#b25aff"
+ icon={HostIcon}
+ />
+
+
+ }
+ bgColor="#1fbbc6"
+ icon={DatastoreIcon}
+ />
+
+
+ }
+ bgColor="#f09d42"
+ icon={NetworkIcon}
+ />
+
+ >
+ )}
+
+ ),
+ [totals?.clusters, isLoading]
+ )
}
TotalProvisionInfrastructures.displayName = 'TotalProvisionInfrastructures'
diff --git a/src/fireedge/src/client/components/Widgets/TotalProvisionsByState/index.js b/src/fireedge/src/client/components/Widgets/TotalProvisionsByState/index.js
index ea68081948..2d2b4a1767 100644
--- a/src/fireedge/src/client/components/Widgets/TotalProvisionsByState/index.js
+++ b/src/fireedge/src/client/components/Widgets/TotalProvisionsByState/index.js
@@ -34,45 +34,45 @@ const TotalProvisionsByState = ({ isLoading }) => {
const chartData = useMemo(() => {
const groups = groupBy(provisions, 'TEMPLATE.BODY.state')
- return PROVISIONS_STATES.map((_, stateIndex) =>
- groups[stateIndex]?.length ?? 0
+ return PROVISIONS_STATES.map(
+ (_, stateIndex) => groups[stateIndex]?.length ?? 0
)
}, [totalProvisions])
- const title = useMemo(() => (
-
-
-
- {T.Provisions}
-
-
- {T.InTotal}
-
-
- ), [classes, totalProvisions])
+ const title = useMemo(
+ () => (
+
+
+
+ {T.Provisions}
+
+ {T.InTotal}
+
+ ),
+ [classes, totalProvisions]
+ )
- return useMemo(() => (
- !totalProvisions && isLoading ? (
-
- ) : (
-
- {title}
-
-
-
-
- )
- ), [classes, chartData, totalProvisions, isLoading])
+ return useMemo(
+ () =>
+ !totalProvisions && isLoading ? (
+
+ ) : (
+
+ {title}
+
+
+
+
+ ),
+ [classes, chartData, totalProvisions, isLoading]
+ )
}
TotalProvisionsByState.displayName = 'TotalProvisionsByState'
diff --git a/src/fireedge/src/client/components/Widgets/TotalProvisionsByState/styles.js b/src/fireedge/src/client/components/Widgets/TotalProvisionsByState/styles.js
index d04d99c93f..9ee8bc548d 100644
--- a/src/fireedge/src/client/components/Widgets/TotalProvisionsByState/styles.js
+++ b/src/fireedge/src/client/components/Widgets/TotalProvisionsByState/styles.js
@@ -15,30 +15,30 @@
* ------------------------------------------------------------------------- */
import makeStyles from '@mui/styles/makeStyles'
-export default makeStyles(theme => ({
+export default makeStyles((theme) => ({
root: {
height: '100%',
padding: '2em',
display: 'grid',
gridAutoRows: 'auto 1fr',
- alignItems: 'center'
+ alignItems: 'center',
},
title: {
padding: '0 2em 2em',
- textAlign: 'left'
+ textAlign: 'left',
},
titlePrimary: {
fontSize: '2rem',
color: theme.palette.text.primary,
'& span': {
- marginLeft: '1rem'
- }
+ marginLeft: '1rem',
+ },
},
titleSecondary: {
fontSize: '1.4rem',
- color: theme.palette.text.secondary
+ color: theme.palette.text.secondary,
},
content: {
- padding: '0 2em'
- }
+ padding: '0 2em',
+ },
}))
diff --git a/src/fireedge/src/client/components/Widgets/TotalSunstoneResources.js b/src/fireedge/src/client/components/Widgets/TotalSunstoneResources.js
index 6fa2416e37..23e15c1181 100644
--- a/src/fireedge/src/client/components/Widgets/TotalSunstoneResources.js
+++ b/src/fireedge/src/client/components/Widgets/TotalSunstoneResources.js
@@ -20,7 +20,7 @@ import {
User as UserIcon,
Group as GroupIcon,
Archive as ImageIcon,
- NetworkAlt as NetworkIcon
+ NetworkAlt as NetworkIcon,
} from 'iconoir-react'
import { Skeleton, Grid } from '@mui/material'
@@ -38,56 +38,59 @@ const TotalProvisionInfrastructures = ({ isLoading }) => {
const images = useImage()
const vNetworks = useVNetwork()
- return useMemo(() => (
-
- {!users?.length && isLoading ? (
- Array.from(Array(TOTAL_WIDGETS)).map((_, index) => (
-
-
-
- ))
- ) : (
- <>
-
- }
- bgColor='#fa7892'
- icon={UserIcon}
- />
-
-
- }
- bgColor='#b25aff'
- icon={GroupIcon}
- />
-
-
- }
- bgColor='#1fbbc6'
- icon={ImageIcon}
- />
-
-
- }
- bgColor='#f09d42'
- icon={NetworkIcon}
- />
-
- >
- )}
-
- ), [users?.length, isLoading])
+ return useMemo(
+ () => (
+
+ {!users?.length && isLoading ? (
+ Array.from(Array(TOTAL_WIDGETS)).map((_, index) => (
+
+
+
+ ))
+ ) : (
+ <>
+
+ }
+ bgColor="#fa7892"
+ icon={UserIcon}
+ />
+
+
+ }
+ bgColor="#b25aff"
+ icon={GroupIcon}
+ />
+
+
+ }
+ bgColor="#1fbbc6"
+ icon={ImageIcon}
+ />
+
+
+ }
+ bgColor="#f09d42"
+ icon={NetworkIcon}
+ />
+
+ >
+ )}
+
+ ),
+ [users?.length, isLoading]
+ )
}
TotalProvisionInfrastructures.displayName = 'TotalProvisionInfrastructures'
diff --git a/src/fireedge/src/client/components/Widgets/index.js b/src/fireedge/src/client/components/Widgets/index.js
index 5c8852c566..50f5af8d83 100644
--- a/src/fireedge/src/client/components/Widgets/index.js
+++ b/src/fireedge/src/client/components/Widgets/index.js
@@ -22,5 +22,5 @@ export {
TotalProviders,
TotalProvisionInfrastructures,
TotalProvisionsByState,
- TotalSunstoneResources
+ TotalSunstoneResources,
}
diff --git a/src/fireedge/src/client/constants/cluster.js b/src/fireedge/src/client/constants/cluster.js
index abc27da5af..555f6f9873 100644
--- a/src/fireedge/src/client/constants/cluster.js
+++ b/src/fireedge/src/client/constants/cluster.js
@@ -20,5 +20,5 @@ export const CLUSTER_ACTIONS = {
CREATE_DIALOG: 'create_dialog',
DELETE: 'delete',
- RENAME: ACTIONS.RENAME
+ RENAME: ACTIONS.RENAME,
}
diff --git a/src/fireedge/src/client/constants/color.js b/src/fireedge/src/client/constants/color.js
index f1bd652c3c..01329c55d6 100644
--- a/src/fireedge/src/client/constants/color.js
+++ b/src/fireedge/src/client/constants/color.js
@@ -18,30 +18,30 @@ export default {
light: '#e57373',
main: '#ec5840',
dark: '#d32f2f',
- contrastText: '#fff'
+ contrastText: '#fff',
},
warning: {
light: '#ffb74d',
main: '#ff9800',
dark: '#f57c00',
- contrastText: 'rgba(0, 0, 0, 0.87)'
+ contrastText: 'rgba(0, 0, 0, 0.87)',
},
info: {
light: '#64b5f6',
main: '#2196f3',
dark: '#1976d2',
- contrastText: '#fff'
+ contrastText: '#fff',
},
success: {
light: '#3adb76',
main: '#4caf50',
dark: '#388e3c',
- contrastText: '#fff'
+ contrastText: '#fff',
},
debug: {
light: '#7f7f7f',
main: '#6d6d6d',
dark: '#5e5e5e',
- contrastText: '#fff'
- }
+ contrastText: '#fff',
+ },
}
diff --git a/src/fireedge/src/client/constants/datastore.js b/src/fireedge/src/client/constants/datastore.js
index d82134416d..c83d716aa0 100644
--- a/src/fireedge/src/client/constants/datastore.js
+++ b/src/fireedge/src/client/constants/datastore.js
@@ -24,11 +24,11 @@ export const DATASTORE_STATES = [
{
name: STATES.READY,
shortName: 'on',
- color: COLOR.success.main
+ color: COLOR.success.main,
},
{
name: STATES.DISABLED,
shortName: 'off',
- color: COLOR.error.dark
- }
+ color: COLOR.error.dark,
+ },
]
diff --git a/src/fireedge/src/client/constants/flow.js b/src/fireedge/src/client/constants/flow.js
index 2ba9d4e900..f8cfe7c53a 100644
--- a/src/fireedge/src/client/constants/flow.js
+++ b/src/fireedge/src/client/constants/flow.js
@@ -22,120 +22,120 @@ export const APPLICATION_STATES = [
color: COLOR.info.main,
meaning: `
The Application starts in this state, and will stay in
- it until the LCM decides to deploy it`
+ it until the LCM decides to deploy it`,
},
{
name: STATES.DEPLOYING,
color: COLOR.info.main,
- meaning: 'Some Tiers are being deployed'
+ meaning: 'Some Tiers are being deployed',
},
{
name: STATES.RUNNING,
color: COLOR.success.main,
- meaning: 'All Tiers are deployed successfully'
+ meaning: 'All Tiers are deployed successfully',
},
{
name: STATES.UNDEPLOYING,
color: COLOR.error.light,
- meaning: 'Some Tiers are being undeployed'
+ meaning: 'Some Tiers are being undeployed',
},
{
name: STATES.WARNING,
color: COLOR.error.light,
- meaning: 'A VM was found in a failure state'
+ meaning: 'A VM was found in a failure state',
},
{
name: STATES.DONE,
color: COLOR.error.dark,
meaning: `
The Applications will stay in this state after
- a successful undeployment. It can be deleted`
+ a successful undeployment. It can be deleted`,
},
{
name: STATES.FAILED_UNDEPLOYING,
color: COLOR.error.dark,
- meaning: 'An error occurred while undeploying the Application'
+ meaning: 'An error occurred while undeploying the Application',
},
{
name: STATES.FAILED_DEPLOYING,
color: COLOR.error.dark,
- meaning: 'An error occurred while deploying the Application'
+ meaning: 'An error occurred while deploying the Application',
},
{
name: STATES.SCALING,
color: COLOR.error.light,
- meaning: 'A Tier is scaling up or down'
+ meaning: 'A Tier is scaling up or down',
},
{
name: STATES.FAILED_SCALING,
color: COLOR.error.dark,
- meaning: 'An error occurred while scaling the Application'
+ meaning: 'An error occurred while scaling the Application',
},
{
name: STATES.COOLDOWN,
color: COLOR.error.light,
- meaning: 'A Tier is in the cooldown period after a scaling operation'
- }
+ meaning: 'A Tier is in the cooldown period after a scaling operation',
+ },
]
export const TIER_STATES = [
{
name: STATES.PENDING,
color: '',
- meaning: 'The Tier is waiting to be deployed'
+ meaning: 'The Tier is waiting to be deployed',
},
{
name: STATES.DEPLOYING,
color: '',
meaning: `
The VMs are being created, and will be
- monitored until all of them are running`
+ monitored until all of them are running`,
},
{
name: STATES.RUNNING,
color: '',
- meaning: 'All the VMs are running'
+ meaning: 'All the VMs are running',
},
{
name: STATES.WARNING,
color: '',
- meaning: 'A VM was found in a failure state'
+ meaning: 'A VM was found in a failure state',
},
{
name: STATES.SCALING,
color: '',
- meaning: 'The Tier is waiting for VMs to be deployed or to be shutdown'
+ meaning: 'The Tier is waiting for VMs to be deployed or to be shutdown',
},
{
name: STATES.COOLDOWN,
color: '',
- meaning: 'The Tier is in the cooldown period after a scaling operation'
+ meaning: 'The Tier is in the cooldown period after a scaling operation',
},
{
name: STATES.UNDEPLOYING,
color: '',
meaning: `
The VMs are being shutdown. The Tier will stay in
- this state until all VMs are done`
+ this state until all VMs are done`,
},
{
name: STATES.DONE,
color: '',
- meaning: 'All the VMs are done'
+ meaning: 'All the VMs are done',
},
{
name: STATES.FAILED_DEPLOYING,
color: '',
- meaning: 'An error occurred while deploying the VMs'
+ meaning: 'An error occurred while deploying the VMs',
},
{
name: STATES.FAILED_UNDEPLOYING,
color: '',
- meaning: 'An error occurred while undeploying the VMs'
+ meaning: 'An error occurred while undeploying the VMs',
},
{
name: STATES.FAILED_SCALING,
color: '',
- meaning: 'An error occurred while scaling the Tier'
- }
+ meaning: 'An error occurred while scaling the Tier',
+ },
]
diff --git a/src/fireedge/src/client/constants/host.js b/src/fireedge/src/client/constants/host.js
index a177a0b0b6..23cb6161b8 100644
--- a/src/fireedge/src/client/constants/host.js
+++ b/src/fireedge/src/client/constants/host.js
@@ -37,46 +37,46 @@ export const HOST_STATES = [
{
name: STATES.INIT,
shortName: 'init',
- color: COLOR.info.main
+ color: COLOR.info.main,
},
{
name: STATES.MONITORING_MONITORED,
shortName: 'update',
- color: COLOR.info.main
+ color: COLOR.info.main,
},
{
name: STATES.MONITORED,
shortName: 'on',
- color: COLOR.success.main
+ color: COLOR.success.main,
},
{
name: STATES.ERROR,
shortName: 'err',
- color: COLOR.error.dark
+ color: COLOR.error.dark,
},
{
name: STATES.DISABLED,
shortName: 'dsbl',
- color: COLOR.error.light
+ color: COLOR.error.light,
},
{
name: STATES.MONITORING_ERROR,
shortName: 'retry',
- color: COLOR.error.dark
+ color: COLOR.error.dark,
},
{
name: STATES.MONITORING_INIT,
shortName: 'init',
- color: COLOR.info.main
+ color: COLOR.info.main,
},
{
name: STATES.MONITORING_DISABLED,
shortName: 'dsbl',
- color: COLOR.error.light
+ color: COLOR.error.light,
},
{
name: STATES.OFFLINE,
shortName: 'off',
- color: COLOR.error.dark
- }
+ color: COLOR.error.dark,
+ },
]
diff --git a/src/fireedge/src/client/constants/image.js b/src/fireedge/src/client/constants/image.js
index f0231e6c45..cbcfc882d6 100644
--- a/src/fireedge/src/client/constants/image.js
+++ b/src/fireedge/src/client/constants/image.js
@@ -23,7 +23,7 @@ export const IMAGE_TYPES_STR = {
DATABLOCK: 'DATABLOCK',
KERNEL: 'KERNEL',
RAMDISK: 'RAMDISK',
- CONTEXT: 'CONTEXT'
+ CONTEXT: 'CONTEXT',
}
/** @type {IMAGE_TYPES_STR[]} Return the string representation of an Image type */
@@ -33,7 +33,7 @@ export const IMAGE_TYPES = [
IMAGE_TYPES_STR.DATABLOCK,
IMAGE_TYPES_STR.KERNEL,
IMAGE_TYPES_STR.RAMDISK,
- IMAGE_TYPES_STR.CONTEXT
+ IMAGE_TYPES_STR.CONTEXT,
]
/** @enum {string} Disk type */
@@ -47,7 +47,7 @@ export const DISK_TYPES_STR = {
GLUSTER_CDROM: 'GLUSTER CDROM',
SHEEPDOG: 'SHEEPDOG',
SHEEPDOG_CDROM: 'SHEEPDOG CDROM',
- ISCSI: 'ISCII'
+ ISCSI: 'ISCII',
}
/** @enum {DISK_TYPES_STR[]} Return the string representation of a Disk type */
export const DISK_TYPES = [
@@ -60,53 +60,64 @@ export const DISK_TYPES = [
DISK_TYPES_STR.GLUSTER_CDROM,
DISK_TYPES_STR.SHEEPDOG,
DISK_TYPES_STR.SHEEPDOG_CDROM,
- DISK_TYPES_STR.ISCSI
+ DISK_TYPES_STR.ISCSI,
]
/** @type {STATES.StateInfo[]} Image states */
export const IMAGE_STATES = [
- { // 0
+ {
+ // 0
name: STATES.INIT,
- color: COLOR.debug.main
+ color: COLOR.debug.main,
},
- { // 1
+ {
+ // 1
name: STATES.READY,
- color: COLOR.success.main
+ color: COLOR.success.main,
},
- { // 2
+ {
+ // 2
name: STATES.USED,
- color: COLOR.success.main
+ color: COLOR.success.main,
},
- { // 3
+ {
+ // 3
name: STATES.DISABLED,
- color: COLOR.debug.light
+ color: COLOR.debug.light,
},
- { // 4
+ {
+ // 4
name: STATES.LOCKED,
- color: COLOR.warning.main
+ color: COLOR.warning.main,
},
- { // 5
+ {
+ // 5
name: STATES.ERROR,
- color: COLOR.error.main
+ color: COLOR.error.main,
},
- { // 6
+ {
+ // 6
name: STATES.CLONE,
- color: COLOR.info.light
+ color: COLOR.info.light,
},
- { // 7
+ {
+ // 7
name: STATES.DELETE,
- color: COLOR.error.main
+ color: COLOR.error.main,
},
- { // 8
+ {
+ // 8
name: STATES.USED_PERS,
- color: COLOR.error.light
+ color: COLOR.error.light,
},
- { // 9
+ {
+ // 9
name: STATES.LOCKED_USED,
- color: COLOR.warning.light
+ color: COLOR.warning.light,
},
- { // 10
+ {
+ // 10
name: STATES.LOCKED_USED_PERS,
- color: COLOR.error.light
- }
+ color: COLOR.error.light,
+ },
]
diff --git a/src/fireedge/src/client/constants/index.js b/src/fireedge/src/client/constants/index.js
index 164be59955..18f8b9c1b7 100644
--- a/src/fireedge/src/client/constants/index.js
+++ b/src/fireedge/src/client/constants/index.js
@@ -13,14 +13,18 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { defaultApps, defaultAppName, availableLanguages } from 'server/utils/constants/defaults'
+import {
+ defaultApps,
+ defaultAppName,
+ availableLanguages,
+} from 'server/utils/constants/defaults'
import * as Setting from 'client/constants/setting'
export const JWT_NAME = 'FireedgeToken'
export const BY = {
text: 'by OpenNebula',
- url: 'https://opennebula.io/'
+ url: 'https://opennebula.io/',
}
export const TIME_HIDE_LOGO = 1500
@@ -54,7 +58,7 @@ export const FILTER_POOL = {
PRIMARY_GROUP_RESOURCES: '-4',
USER_RESOURCES: '-3',
ALL_RESOURCES: '-2',
- USER_GROUPS_RESOURCES: '-1'
+ USER_GROUPS_RESOURCES: '-1',
}
/** @enum {string} Input types */
@@ -70,21 +74,21 @@ export const INPUT_TYPES = {
SLIDER: 'slider',
TEXT: 'text',
TABLE: 'table',
- TOGGLE: 'toggle'
+ TOGGLE: 'toggle',
}
export const DEBUG_LEVEL = {
ERROR: 'ERROR',
WARN: 'WARN',
INFO: 'INFO',
- DEBUG: 'DEBUG'
+ DEBUG: 'DEBUG',
}
export const SOCKETS = {
CONNECT: 'connect',
DISCONNECT: 'disconnect',
HOOKS: 'hooks',
- PROVISION: 'provision'
+ PROVISION: 'provision',
}
/** @enum {string} Names of resource */
@@ -103,7 +107,7 @@ export const RESOURCE_NAMES = {
VM: 'vm',
VN_TEMPLATE: 'network-template',
VNET: 'virtual-network',
- ZONE: 'zone'
+ ZONE: 'zone',
}
export * as T from 'client/constants/translates'
diff --git a/src/fireedge/src/client/constants/marketplace.js b/src/fireedge/src/client/constants/marketplace.js
index a7e2eeb4ce..16922987eb 100644
--- a/src/fireedge/src/client/constants/marketplace.js
+++ b/src/fireedge/src/client/constants/marketplace.js
@@ -18,14 +18,16 @@ import COLOR from 'client/constants/color'
/** @type {STATES.StateInfo[]} Marketplace states */
export const MARKETPLACE_STATES = [
- { // 0
+ {
+ // 0
name: STATES.ENABLED,
- color: COLOR.success.main
+ color: COLOR.success.main,
},
- { // 1
+ {
+ // 1
name: STATES.DISABLED,
- color: COLOR.debug.main
- }
+ color: COLOR.debug.main,
+ },
]
/**
@@ -40,29 +42,34 @@ export const MARKETPLACE_APP_TYPES = [
'UNKNOWN',
'IMAGE',
'VM TEMPLATE',
- 'SERVICE TEMPLATE'
+ 'SERVICE TEMPLATE',
]
/** @type {STATES.StateInfo[]} Marketplace app states */
export const MARKETPLACE_APP_STATES = [
- { // 0
+ {
+ // 0
name: STATES.INIT,
- color: COLOR.info.main
+ color: COLOR.info.main,
},
- { // 1
+ {
+ // 1
name: STATES.READY,
- color: COLOR.success.main
+ color: COLOR.success.main,
},
- { // 2
+ {
+ // 2
name: STATES.LOCKED,
- color: COLOR.debug.main
+ color: COLOR.debug.main,
},
- { // 3
+ {
+ // 3
name: STATES.ERROR,
- color: COLOR.error.main
+ color: COLOR.error.main,
},
- { // 4
+ {
+ // 4
name: STATES.DISABLED,
- color: COLOR.debug.light
- }
+ color: COLOR.debug.light,
+ },
]
diff --git a/src/fireedge/src/client/constants/marketplaceApp.js b/src/fireedge/src/client/constants/marketplaceApp.js
index 6306c6b41e..5e9d247941 100644
--- a/src/fireedge/src/client/constants/marketplaceApp.js
+++ b/src/fireedge/src/client/constants/marketplaceApp.js
@@ -17,5 +17,5 @@ export const MARKETPLACE_APP_ACTIONS = {
REFRESH: 'refresh',
CREATE_DIALOG: 'create_dialog',
RENAME: 'rename',
- EXPORT: 'export'
+ EXPORT: 'export',
}
diff --git a/src/fireedge/src/client/constants/provision.js b/src/fireedge/src/client/constants/provision.js
index 68b1457518..f98d7d68a1 100644
--- a/src/fireedge/src/client/constants/provision.js
+++ b/src/fireedge/src/client/constants/provision.js
@@ -20,31 +20,31 @@ export const PROVISIONS_STATES = [
{
name: STATES.PENDING,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
{
name: STATES.DEPLOYING,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
{
name: STATES.CONFIGURING,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
{
name: STATES.RUNNING,
color: COLOR.success.main,
- meaning: ''
+ meaning: '',
},
{
name: STATES.ERROR,
color: COLOR.error.dark,
- meaning: ''
+ meaning: '',
},
{
name: STATES.DELETING,
color: COLOR.error.light,
- meaning: ''
- }
+ meaning: '',
+ },
]
diff --git a/src/fireedge/src/client/constants/securityGroup.js b/src/fireedge/src/client/constants/securityGroup.js
index 9b0170bf4d..84e93c0778 100644
--- a/src/fireedge/src/client/constants/securityGroup.js
+++ b/src/fireedge/src/client/constants/securityGroup.js
@@ -52,7 +52,7 @@ export const ICMP_STRING = {
40: '40: Photuris',
41: '41: ICMP messages utilized by experimental mobility protocols such as Seamoby',
253: '253: RFC3692-style Experiment 1',
- 254: '254: RFC3692-style Experiment 2'
+ 254: '254: RFC3692-style Experiment 2',
}
/**
@@ -68,7 +68,7 @@ export const ICMP_V6_STRING = {
3: '3: Time exceeded',
4: '4: Parameter problem',
128: '128/0: Echo request',
- 129: '129/0: Echo reply'
+ 129: '129/0: Echo reply',
}
/** @enum {string} Security group protocol */
@@ -78,11 +78,11 @@ export const PROTOCOL_STRING = {
ICMP: T.ICMP,
ICMPV6: T.ICMPV6,
IPSEC: T.IPSEC,
- ALL: T.All
+ ALL: T.All,
}
/** @enum {string} Security group rule type */
export const RULE_TYPE_STRING = {
OUTBOUND: T.Outbound,
- INBOUND: T.Inbound
+ INBOUND: T.Inbound,
}
diff --git a/src/fireedge/src/client/constants/setting.js b/src/fireedge/src/client/constants/setting.js
index c67fa775a4..cf675a69bc 100644
--- a/src/fireedge/src/client/constants/setting.js
+++ b/src/fireedge/src/client/constants/setting.js
@@ -17,5 +17,5 @@
export const SCHEMES = {
SYSTEM: 'system',
DARK: 'dark',
- LIGHT: 'light'
+ LIGHT: 'light',
}
diff --git a/src/fireedge/src/client/constants/translates.js b/src/fireedge/src/client/constants/translates.js
index 4701766314..edbd9d6f0d 100644
--- a/src/fireedge/src/client/constants/translates.js
+++ b/src/fireedge/src/client/constants/translates.js
@@ -175,7 +175,8 @@ module.exports = {
SomethingWrong: 'Something go wrong',
CannotConnectOneFlow: 'Cannot connect to OneFlow server',
CannotConnectOneProvision: 'Cannot connect to OneProvision server',
- ErrorOneProvisionGUI: 'FireEdge is not correctly configured to operate the OneProvision GUI',
+ ErrorOneProvisionGUI:
+ 'FireEdge is not correctly configured to operate the OneProvision GUI',
ContactYourAdmin: 'Please contact your system administrator',
NotFound: 'Not found',
Timeout: 'Timeout',
@@ -449,7 +450,7 @@ module.exports = {
Could be used to force ID for licensing purposes`,
Firmware: 'Firmware',
FirmwareConcept:
- 'This attribute allows to define the type of firmware used to boot the VM',
+ 'This attribute allows to define the type of firmware used to boot the VM',
FirmwareSecure: 'Firmware secure',
CpuModel: 'CPU Model',
CustomPath: 'Customize with path',
@@ -476,12 +477,10 @@ module.exports = {
LocaltimeConcept:
'The guest clock will be synchronized to the hosts configured timezone when booted',
GuestAgent: 'QEMU Guest Agent',
- GuestAgentConcept:
- `Enables the QEMU Guest Agent communication.
+ GuestAgentConcept: `Enables the QEMU Guest Agent communication.
This does not start the Guest Agent inside the VM`,
VirtioQueues: 'Virtio-scsi Queues',
- VirtioQueuesConcept:
- `Number of vCPU queues to use in the virtio-scsi controller.
+ VirtioQueuesConcept: `Number of vCPU queues to use in the virtio-scsi controller.
Leave blank to use the default value`,
IoThreads: 'Iothreads',
IoThreadsConcept: `
@@ -591,8 +590,10 @@ module.exports = {
AppTemplate: 'App Template',
ImportIntoDatastore: 'Import into Datastore',
DownloadAppToOpenNebula: 'Download App to OpenNebula',
- ExportAppNameConcept: 'Name that the resource will get for description purposes',
- ExportTemplateNameConcept: 'The following template will be created in OpenNebula and the previous images will be referenced in the disks',
+ ExportAppNameConcept:
+ 'Name that the resource will get for description purposes',
+ ExportTemplateNameConcept:
+ 'The following template will be created in OpenNebula and the previous images will be referenced in the disks',
DontAssociateApp: 'Do not import/export associated VM templates/images',
/* User inputs */
@@ -658,5 +659,5 @@ module.exports = {
/* Validation - array */
'validation.array.min': 'Must have at least %s items',
'validation.array.max': 'Must have less than or equal to %s items',
- 'validation.array.length': 'Must have %s items'
+ 'validation.array.length': 'Must have %s items',
}
diff --git a/src/fireedge/src/client/constants/userInput.js b/src/fireedge/src/client/constants/userInput.js
index b7a3cade0e..01fb5e4665 100644
--- a/src/fireedge/src/client/constants/userInput.js
+++ b/src/fireedge/src/client/constants/userInput.js
@@ -55,5 +55,5 @@ export const USER_INPUT_TYPES = {
boolean: 'boolean',
list: 'list',
array: 'array',
- listMultiple: 'list-multiple'
+ listMultiple: 'list-multiple',
}
diff --git a/src/fireedge/src/client/constants/vm.js b/src/fireedge/src/client/constants/vm.js
index 37d062dbf7..0080af477e 100644
--- a/src/fireedge/src/client/constants/vm.js
+++ b/src/fireedge/src/client/constants/vm.js
@@ -19,415 +19,496 @@ import COLOR from 'client/constants/color'
/** @type {STATES.StateInfo[]} Virtual machine states */
export const VM_STATES = [
- { // 0
+ {
+ // 0
name: STATES.INIT,
color: COLOR.info.light,
- meaning: ''
+ meaning: '',
},
- { // 1
+ {
+ // 1
name: STATES.PENDING,
color: COLOR.info.light,
- meaning: ''
+ meaning: '',
},
- { // 2
+ {
+ // 2
name: STATES.HOLD,
color: COLOR.error.light,
- meaning: ''
+ meaning: '',
},
- { // 3
+ {
+ // 3
name: STATES.ACTIVE,
color: COLOR.success.light,
- meaning: ''
+ meaning: '',
},
- { // 4
+ {
+ // 4
name: STATES.STOPPED,
color: COLOR.error.light,
- meaning: ''
+ meaning: '',
},
- { // 5
+ {
+ // 5
name: STATES.SUSPENDED,
color: COLOR.error.light,
- meaning: ''
+ meaning: '',
},
- { // 6
+ {
+ // 6
name: STATES.DONE,
color: COLOR.debug.light,
- meaning: ''
+ meaning: '',
},
- { // 7
+ {
+ // 7
name: STATES.FAILED,
color: COLOR.error.dark,
- meaning: ''
+ meaning: '',
},
- { // 8
+ {
+ // 8
name: STATES.POWEROFF,
color: COLOR.error.light,
- meaning: ''
+ meaning: '',
},
- { // 9
+ {
+ // 9
name: STATES.UNDEPLOYED,
color: COLOR.error.light,
- meaning: ''
+ meaning: '',
},
- { // 10
+ {
+ // 10
name: STATES.CLONING,
color: COLOR.info.light,
- meaning: ''
+ meaning: '',
},
- { // 11
+ {
+ // 11
name: STATES.CLONING_FAILURE,
color: COLOR.error.dark,
- meaning: ''
- }
+ meaning: '',
+ },
]
/** @type {STATES.StateInfo[]} Virtual machine lcm states */
export const VM_LCM_STATES = [
- { // 0
+ {
+ // 0
name: STATES.LCM_INIT,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 1
+ {
+ // 1
name: STATES.PROLOG,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 2
+ {
+ // 2
name: STATES.BOOT,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 3
+ {
+ // 3
name: STATES.RUNNING,
color: COLOR.success.main,
- meaning: ''
+ meaning: '',
},
- { // 4
+ {
+ // 4
name: STATES.MIGRATE,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 5
+ {
+ // 5
name: STATES.SAVE_STOP,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 6
+ {
+ // 6
name: STATES.SAVE_SUSPEND,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 7
+ {
+ // 7
name: STATES.SAVE_MIGRATE,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 8
+ {
+ // 8
name: STATES.PROLOG_MIGRATE,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 9
+ {
+ // 9
name: STATES.PROLOG_RESUME,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 10
+ {
+ // 10
name: STATES.EPILOG_STOP,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 11
+ {
+ // 11
name: STATES.EPILOG,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 12
+ {
+ // 12
name: STATES.SHUTDOWN,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 13
+ {
+ // 13
name: STATES.CANCEL,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 14
+ {
+ // 14
name: STATES.FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 15
+ {
+ // 15
name: STATES.CLEANUP_RESUBMIT,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 16
+ {
+ // 16
name: STATES.UNKNOWN,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 17
+ {
+ // 17
name: STATES.HOTPLUG,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 18
+ {
+ // 18
name: STATES.SHUTDOWN_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 19
+ {
+ // 19
name: STATES.BOOT_UNKNOWN,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 20
+ {
+ // 20
name: STATES.BOOT_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 21
+ {
+ // 21
name: STATES.BOOT_SUSPENDED,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 22
+ {
+ // 22
name: STATES.BOOT_STOPPED,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 23
+ {
+ // 23
name: STATES.CLEANUP_DELETE,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 24
+ {
+ // 24
name: STATES.HOTPLUG_SNAPSHOT,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 25
+ {
+ // 25
name: STATES.HOTPLUG_NIC,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 26
+ {
+ // 26
name: STATES.HOTPLUG_SAVEAS,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 27
+ {
+ // 27
name: STATES.HOTPLUG_SAVEAS_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 28
+ {
+ // 28
name: STATES.HOTPLUG_SAVEAS_SUSPENDED,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 29
+ {
+ // 29
name: STATES.SHUTDOWN_UNDEPLOY,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 30
+ {
+ // 30
name: STATES.EPILOG_UNDEPLOY,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 31
+ {
+ // 31
name: STATES.PROLOG_UNDEPLOY,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 32
+ {
+ // 32
name: STATES.BOOT_UNDEPLOY,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 33
+ {
+ // 33
name: STATES.HOTPLUG_PROLOG_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 34
+ {
+ // 34
name: STATES.HOTPLUG_EPILOG_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 35
+ {
+ // 35
name: STATES.BOOT_MIGRATE,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 36
+ {
+ // 36
name: STATES.BOOT_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 37
+ {
+ // 37
name: STATES.BOOT_MIGRATE_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 38
+ {
+ // 38
name: STATES.PROLOG_MIGRATE_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 39
+ {
+ // 39
name: STATES.PROLOG_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 40
+ {
+ // 40
name: STATES.EPILOG_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 41
+ {
+ // 41
name: STATES.EPILOG_STOP_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 42
+ {
+ // 42
name: STATES.EPILOG_UNDEPLOY_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 43
+ {
+ // 43
name: STATES.PROLOG_MIGRATE_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 44
+ {
+ // 44
name: STATES.PROLOG_MIGRATE_POWEROFF_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 45
+ {
+ // 45
name: STATES.PROLOG_MIGRATE_SUSPEND,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 46
+ {
+ // 46
name: STATES.PROLOG_MIGRATE_SUSPEND_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 47
+ {
+ // 47
name: STATES.BOOT_UNDEPLOY_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 48
+ {
+ // 48
name: STATES.BOOT_STOPPED_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 49
+ {
+ // 49
name: STATES.PROLOG_RESUME_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 50
+ {
+ // 50
name: STATES.PROLOG_UNDEPLOY_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 51
+ {
+ // 51
name: STATES.DISK_SNAPSHOT_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 52
+ {
+ // 52
name: STATES.DISK_SNAPSHOT_REVERT_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 53
+ {
+ // 53
name: STATES.DISK_SNAPSHOT_DELETE_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 54
+ {
+ // 54
name: STATES.DISK_SNAPSHOT_SUSPENDED,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 55
+ {
+ // 55
name: STATES.DISK_SNAPSHOT_REVERT_SUSPENDED,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 56
+ {
+ // 56
name: STATES.DISK_SNAPSHOT_DELETE_SUSPENDED,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 57
+ {
+ // 57
name: STATES.DISK_SNAPSHOT,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 58
+ {
+ // 58
name: STATES.DISK_SNAPSHOT_REVERT,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 59
+ {
+ // 59
name: STATES.DISK_SNAPSHOT_DELETE,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 60
+ {
+ // 60
name: STATES.PROLOG_MIGRATE_UNKNOWN,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 61
+ {
+ // 61
name: STATES.PROLOG_MIGRATE_UNKNOWN_FAILURE,
color: COLOR.warning.main,
- meaning: ''
+ meaning: '',
},
- { // 62
+ {
+ // 62
name: STATES.DISK_RESIZE,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 63
+ {
+ // 63
name: STATES.DISK_RESIZE_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 64
+ {
+ // 64
name: STATES.DISK_RESIZE_UNDEPLOYED,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 65
+ {
+ // 65
name: STATES.HOTPLUG_NIC_POWEROFF,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 66
+ {
+ // 66
name: STATES.HOTPLUG_RESIZE,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 67
+ {
+ // 67
name: STATES.HOTPLUG_SAVEAS_UNDEPLOYED,
color: COLOR.info.main,
- meaning: ''
+ meaning: '',
},
- { // 68
+ {
+ // 68
name: STATES.HOTPLUG_SAVEAS_STOPPED,
color: COLOR.info.main,
- meaning: ''
- }
+ meaning: '',
+ },
]
/** @enum {string} Virtual machine actions */
@@ -504,7 +585,7 @@ export const VM_ACTIONS = {
CHARTER_CREATE: 'charter_create',
// CONFIGURATION
- UPDATE_CONF: 'update_configuration'
+ UPDATE_CONF: 'update_configuration',
}
/** @enum {string} Virtual machine actions by state */
@@ -514,7 +595,7 @@ export const VM_ACTIONS_BY_STATE = {
STATES.HOLD,
STATES.STOPPED,
STATES.UNDEPLOYED,
- STATES.UNKNOWN
+ STATES.UNKNOWN,
],
[VM_ACTIONS.CREATE_APP_DIALOG]: [STATES.POWEROFF],
[VM_ACTIONS.HOLD]: [STATES.PENDING],
@@ -526,7 +607,7 @@ export const VM_ACTIONS_BY_STATE = {
STATES.SUSPENDED,
STATES.POWEROFF,
STATES.RUNNING,
- STATES.UNKNOWN
+ STATES.UNKNOWN,
],
[VM_ACTIONS.POWEROFF_HARD]: [STATES.RUNNING, STATES.UNKNOWN],
[VM_ACTIONS.POWEROFF]: [STATES.RUNNING, STATES.UNKNOWN],
@@ -541,7 +622,7 @@ export const VM_ACTIONS_BY_STATE = {
STATES.POWEROFF,
STATES.UNDEPLOYED,
STATES.CLONING,
- STATES.CLONING_FAILURE
+ STATES.CLONING_FAILURE,
],
[VM_ACTIONS.RELEASE]: [STATES.HOLD],
[VM_ACTIONS.RESCHED]: [STATES.POWEROFF, STATES.RUNNING, STATES.UNKNOWN],
@@ -550,7 +631,7 @@ export const VM_ACTIONS_BY_STATE = {
STATES.SUSPENDED,
STATES.POWEROFF,
STATES.UNDEPLOYED,
- STATES.UNKNOWN
+ STATES.UNKNOWN,
],
[VM_ACTIONS.SAVE_AS_TEMPLATE]: [STATES.POWEROFF],
[VM_ACTIONS.STOP]: [STATES.SUSPENDED, STATES.RUNNING],
@@ -566,7 +647,7 @@ export const VM_ACTIONS_BY_STATE = {
STATES.CLONING,
STATES.CLONING_FAILURE,
STATES.RUNNING,
- STATES.UNKNOWN
+ STATES.UNKNOWN,
],
[VM_ACTIONS.TERMINATE]: [
STATES.RUNNING,
@@ -584,7 +665,7 @@ export const VM_ACTIONS_BY_STATE = {
STATES.BOOT_STOPPED_FAILURE,
STATES.PROLOG_RESUME_FAILURE,
STATES.PROLOG_UNDEPLOY_FAILURE,
- STATES.PROLOG_MIGRATE_UNKNOWN_FAILURE
+ STATES.PROLOG_MIGRATE_UNKNOWN_FAILURE,
],
[VM_ACTIONS.UNDEPLOY_HARD]: [STATES.POWEROFF, STATES.RUNNING, STATES.UNKNOWN],
[VM_ACTIONS.UNDEPLOY]: [STATES.POWEROFF, STATES.RUNNING, STATES.UNKNOWN],
@@ -615,16 +696,24 @@ export const VM_ACTIONS_BY_STATE = {
STATES.POWEROFF,
STATES.UNDEPLOYED,
STATES.CLONING,
- STATES.CLONING_FAILURE
+ STATES.CLONING_FAILURE,
],
// STORAGE
[VM_ACTIONS.ATTACH_DISK]: [STATES.POWEROFF, STATES.RUNNING],
[VM_ACTIONS.DETACH_DISK]: [STATES.POWEROFF, STATES.RUNNING],
- [VM_ACTIONS.SNAPSHOT_DISK_CREATE]: [STATES.SUSPENDED, STATES.POWEROFF, STATES.RUNNING],
+ [VM_ACTIONS.SNAPSHOT_DISK_CREATE]: [
+ STATES.SUSPENDED,
+ STATES.POWEROFF,
+ STATES.RUNNING,
+ ],
[VM_ACTIONS.SNAPSHOT_DISK_RENAME]: [],
[VM_ACTIONS.SNAPSHOT_DISK_REVERT]: [STATES.SUSPENDED, STATES.POWEROFF],
- [VM_ACTIONS.SNAPSHOT_DISK_DELETE]: [STATES.SUSPENDED, STATES.POWEROFF, STATES.RUNNING],
+ [VM_ACTIONS.SNAPSHOT_DISK_DELETE]: [
+ STATES.SUSPENDED,
+ STATES.POWEROFF,
+ STATES.RUNNING,
+ ],
[VM_ACTIONS.RESIZE_DISK]: [STATES.POWEROFF, STATES.RUNNING],
[VM_ACTIONS.DISK_SAVEAS]: [STATES.SUSPENDED, STATES.POWEROFF, STATES.RUNNING],
@@ -674,8 +763,8 @@ export const VM_ACTIONS_BY_STATE = {
STATES.PROLOG_UNDEPLOY_FAILURE,
STATES.DISK_SNAPSHOT_POWEROFF,
STATES.DISK_SNAPSHOT_REVERT_POWEROFF,
- STATES.DISK_SNAPSHOT_DELETE_POWEROFF
- ]
+ STATES.DISK_SNAPSHOT_DELETE_POWEROFF,
+ ],
}
/** @enum {string} Hypervisors */
@@ -683,7 +772,7 @@ export const HYPERVISORS = {
kvm: 'kvm',
vcenter: 'vcenter',
firecracker: 'firecracker',
- lxc: 'lxc'
+ lxc: 'lxc',
}
/** @type {string[]} Actions that can be scheduled */
@@ -706,7 +795,7 @@ export const VM_ACTIONS_WITH_SCHEDULE = [
VM_ACTIONS.SNAPSHOT_DISK_DELETE,
VM_ACTIONS.SNAPSHOT_CREATE,
VM_ACTIONS.SNAPSHOT_REVERT,
- VM_ACTIONS.SNAPSHOT_DELETE
+ VM_ACTIONS.SNAPSHOT_DELETE,
]
/**
@@ -813,7 +902,7 @@ export const HISTORY_ACTIONS = [
'alias-attach',
'alias-detach',
'poweroff-migrate',
- 'poweroff-hard-migrate'
+ 'poweroff-hard-migrate',
]
/**
@@ -834,7 +923,7 @@ export const NIC_ALIAS_IP_ATTRS = [
'IP6_ULA',
'VROUTER_IP',
'VROUTER_IP6_GLOBAL',
- 'VROUTER_IP6_ULA'
+ 'VROUTER_IP6_ULA',
]
/**
@@ -855,5 +944,5 @@ export const EXTERNAL_IP_ATTRS = [
'AWS_PUBLIC_IP_ADDRESS',
'AWS_PRIVATE_IP_ADDRESS',
'AZ_IPADDRESS',
- 'SL_PRIMARYIPADDRESS'
+ 'SL_PRIMARYIPADDRESS',
]
diff --git a/src/fireedge/src/client/constants/vmTemplate.js b/src/fireedge/src/client/constants/vmTemplate.js
index ed666feb04..93e4abd0ef 100644
--- a/src/fireedge/src/client/constants/vmTemplate.js
+++ b/src/fireedge/src/client/constants/vmTemplate.js
@@ -31,7 +31,7 @@ export const VM_TEMPLATE_ACTIONS = {
RENAME: ACTIONS.RENAME,
CHANGE_OWNER: ACTIONS.CHANGE_OWNER,
- CHANGE_GROUP: ACTIONS.CHANGE_GROUP
+ CHANGE_GROUP: ACTIONS.CHANGE_GROUP,
}
export const NUMA_PIN_POLICIES = ['NONE', 'THREAD', 'SHARED', 'CORE']
@@ -51,7 +51,7 @@ export const FIRMWARE_TYPES = ['BIOS']
export const KVM_FIRMWARE_TYPES = FIRMWARE_TYPES.concat([
'/usr/share/OVMF/OVMF_CODE.fd',
- '/usr/share/OVMF/OVMF_CODE.secboot.fd'
+ '/usr/share/OVMF/OVMF_CODE.secboot.fd',
])
export const VCENTER_FIRMWARE_TYPES = FIRMWARE_TYPES.concat(['uefi'])
diff --git a/src/fireedge/src/client/constants/zone.js b/src/fireedge/src/client/constants/zone.js
index a86ebcbe42..c4039a24eb 100644
--- a/src/fireedge/src/client/constants/zone.js
+++ b/src/fireedge/src/client/constants/zone.js
@@ -18,12 +18,14 @@ import COLOR from 'client/constants/color'
/** @type {STATES.StateInfo[]} Zone states */
export const ZONE_STATES = [
- { // 0
+ {
+ // 0
name: STATES.ENABLED,
- color: COLOR.success.main
+ color: COLOR.success.main,
},
- { // 1
+ {
+ // 1
name: STATES.DISABLED,
- color: COLOR.debug.main
- }
+ color: COLOR.debug.main,
+ },
]
diff --git a/src/fireedge/src/client/containers/ApplicationsInstances/DialogInfo/dialog.js b/src/fireedge/src/client/containers/ApplicationsInstances/DialogInfo/dialog.js
index 6192bdf280..28746025b6 100644
--- a/src/fireedge/src/client/containers/ApplicationsInstances/DialogInfo/dialog.js
+++ b/src/fireedge/src/client/containers/ApplicationsInstances/DialogInfo/dialog.js
@@ -22,14 +22,14 @@ import {
DialogContent,
DialogActions,
Button,
- useMediaQuery
+ useMediaQuery,
} from '@mui/material'
import { Tr } from 'client/components/HOC'
import { T } from 'client/constants'
const CustomDialog = ({ title, handleClose, children }) => {
- const isMobile = useMediaQuery(theme => theme.breakpoints.only('xs'))
+ const isMobile = useMediaQuery((theme) => theme.breakpoints.only('xs'))
return (
handleSetData(newValue)}
+ onChange={(newValue) => handleSetData(newValue)}
/>
>
)
@@ -35,13 +35,13 @@ const DockerFile = ({ backButton, handleSetData, currentValue }) => (
DockerFile.propTypes = {
backButton: PropTypes.node,
currentValue: PropTypes.string,
- handleSetData: PropTypes.func
+ handleSetData: PropTypes.func,
}
DockerFile.defaultProps = {
backButton: null,
currentValue: undefined,
- handleSetData: PropTypes.func
+ handleSetData: PropTypes.func,
}
export default DockerFile
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/List/MarketApps.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/List/MarketApps.js
index 4249905853..ae8dec0326 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/List/MarketApps.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/List/MarketApps.js
@@ -39,19 +39,21 @@ const ListMarketApp = ({ backButton, currentValue, handleSetData }) => {
renderResult={({ ID, NAME }) => {
const isSelected = ID === String(currentValue)
- return handleSetData(!isSelected && ID)}
- />
+ return (
+ handleSetData(!isSelected && ID)}
+ />
+ )
}}
searchBoxProps={{
style: {
display: 'flex',
padding: '1rem 0',
- gap: 10
- }
+ gap: 10,
+ },
}}
/>
)
@@ -60,13 +62,13 @@ const ListMarketApp = ({ backButton, currentValue, handleSetData }) => {
ListMarketApp.propTypes = {
backButton: PropTypes.node,
currentValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
- handleSetData: PropTypes.func
+ handleSetData: PropTypes.func,
}
ListMarketApp.defaultProps = {
backButton: null,
currentValue: undefined,
- handleSetData: () => undefined
+ handleSetData: () => undefined,
}
export default ListMarketApp
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/List/Templates.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/List/Templates.js
index 80cd4eaea9..a9779ccb6c 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/List/Templates.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/List/Templates.js
@@ -39,19 +39,21 @@ const ListTemplates = ({ backButton, currentValue, handleSetData }) => {
renderResult={({ ID, NAME }) => {
const isSelected = ID === String(currentValue)
- return handleSetData(!isSelected && ID)}
- />
+ return (
+ handleSetData(!isSelected && ID)}
+ />
+ )
}}
searchBoxProps={{
style: {
display: 'flex',
padding: '1rem 0',
- gap: 10
- }
+ gap: 10,
+ },
}}
/>
)
@@ -60,13 +62,13 @@ const ListTemplates = ({ backButton, currentValue, handleSetData }) => {
ListTemplates.propTypes = {
backButton: PropTypes.node,
currentValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
- handleSetData: PropTypes.func
+ handleSetData: PropTypes.func,
}
ListTemplates.defaultProps = {
backButton: null,
currentValue: undefined,
- handleSetData: () => undefined
+ handleSetData: () => undefined,
}
export default ListTemplates
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/index.js
index 66d02a8f7b..96468d3884 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/index.js
@@ -21,7 +21,7 @@ import makeStyles from '@mui/styles/makeStyles'
import {
NavArrowLeft as BackIcon,
SimpleCart as MarketplaceIcon,
- EmptyPage as TemplateIcon
+ EmptyPage as TemplateIcon,
} from 'iconoir-react'
import { DockerLogo } from 'client/components/Icons'
@@ -37,32 +37,32 @@ const SCREENS = [
{
id: 'id',
button: ,
- content: ListTemplates
+ content: ListTemplates,
},
{
id: 'app',
button: ,
- content: ListMarketApps
+ content: ListMarketApps,
},
{
id: 'docker',
button: ,
- content: DockerFile
- }
+ content: DockerFile,
+ },
]
const useStyles = makeStyles(() => ({
root: {
- flexGrow: 1
+ flexGrow: 1,
},
wrapper: {
height: '100%',
display: 'flex',
justifyContent: 'space-around',
alignItems: 'center',
- flexWrap: 'wrap'
+ flexWrap: 'wrap',
},
- button: { backgroundColor: '#fff' }
+ button: { backgroundColor: '#fff' },
}))
const Template = () => ({
@@ -76,14 +76,14 @@ const Template = () => ({
useEffect(() => {
if (Object.keys(data).length > 0) {
const currentScreen = Object.keys(data)[0]
- setScreen(SCREENS.find(src => src.id === currentScreen))
+ setScreen(SCREENS.find((src) => src.id === currentScreen))
}
}, [])
- const handleSetTemplate = template =>
- setFormData(prevData => ({
+ const handleSetTemplate = (template) =>
+ setFormData((prevData) => ({
...prevData,
- [STEP_ID]: template ? { [screen.id]: template } : undefined
+ [STEP_ID]: template ? { [screen.id]: template } : undefined,
}))
const handleBack = () => {
@@ -106,7 +106,7 @@ const Template = () => ({
) : (
- {SCREENS?.map(scr => (
+ {SCREENS?.map((scr) => (
({
)
- }, [])
+ }, []),
})
export default Template
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/schema.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/schema.js
index 5b3abdd8a6..c81bdac8d1 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/schema.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/Template/schema.js
@@ -19,16 +19,16 @@ import { getValidationFromFields } from 'client/utils'
export const FORM_FIELDS = [
{
name: 'id',
- validation: yup.number().min(0, 'Invalid template')
+ validation: yup.number().min(0, 'Invalid template'),
},
{
name: 'app',
- validation: yup.number().min(0, 'Invalid market app template')
+ validation: yup.number().min(0, 'Invalid market app template'),
},
{
name: 'docker',
- validation: yup.string().trim()
- }
+ validation: yup.string().trim(),
+ },
]
export const STEP_FORM_SCHEMA = yup
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/index.js
index 61ac7f78a4..701aa94e18 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/Steps/index.js
@@ -30,21 +30,19 @@ const Steps = () => {
const steps = [basic, networks, template, policies]
- const resolvers = () => yup.object({
- id: yup
- .string()
- .uuid()
- .default(uuidv4),
- [basic.id]: basic.resolver,
- [networks.id]: networks.resolver,
- [template.id]: template.resolver,
- [policies.id]: policies.resolver,
- parents: yup.array().default([]),
- position: yup.object({
- x: yup.number().round().default(0),
- y: yup.number().round().default(0)
+ const resolvers = () =>
+ yup.object({
+ id: yup.string().uuid().default(uuidv4),
+ [basic.id]: basic.resolver,
+ [networks.id]: networks.resolver,
+ [template.id]: template.resolver,
+ [policies.id]: policies.resolver,
+ parents: yup.array().default([]),
+ position: yup.object({
+ x: yup.number().round().default(0),
+ y: yup.number().round().default(0),
+ }),
})
- })
const defaultValues = resolvers().default()
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/index.js
index a3d28fc404..f221fa9d25 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers/index.js
@@ -14,13 +14,7 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
/* eslint-disable jsdoc/require-jsdoc */
-import {
- useEffect,
- useState,
- useCallback,
- createContext,
- useMemo
-} from 'react'
+import { useEffect, useState, useCallback, createContext, useMemo } from 'react'
import * as yup from 'yup'
import { useWatch } from 'react-hook-form'
@@ -57,19 +51,15 @@ const Tiers = () => {
const [nestedForm, setNestedForm] = useState({})
const form = useWatch({})
- const {
- editingData,
- handleSetList,
- handleSave,
- handleEdit
- } = useListForm({
- key: STEP_ID,
- list: data,
- setList: setFormData,
- defaultValue: defaultValues
- })
+ const { editingData, handleSetList, handleSave, handleEdit } =
+ useListForm({
+ key: STEP_ID,
+ list: data,
+ setList: setFormData,
+ defaultValue: defaultValues,
+ })
- const handleEditTier = id => {
+ const handleEditTier = (id) => {
handleEdit(id)
setShowDialog(true)
}
@@ -111,7 +101,7 @@ const Tiers = () => {
{
+ onSubmit={(values) => {
handleSave(values)
setShowDialog(false)
}}
@@ -122,7 +112,7 @@ const Tiers = () => {
)}
>
)
- }, [])
+ }, []),
}
}
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/index.js
index dfce24c1c0..7771b3d11e 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/Steps/index.js
@@ -29,12 +29,13 @@ const Steps = () => {
const steps = [basic, clusters, networking, tiers]
- const resolvers = () => yup.object({
- [basic.id]: basic.resolver,
- [clusters.id]: clusters.resolver,
- [networking.id]: networking.resolver,
- [tiers.id]: tiers.resolver
- })
+ const resolvers = () =>
+ yup.object({
+ [basic.id]: basic.resolver,
+ [clusters.id]: clusters.resolver,
+ [networking.id]: networking.resolver,
+ [tiers.id]: tiers.resolver,
+ })
const defaultValues = resolvers().default()
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/index.js
index 7ebdfa0b69..9fbf599199 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Create/index.js
@@ -29,7 +29,7 @@ import { useFetch } from 'client/hooks'
import { useApplicationTemplateApi } from 'client/features/One'
import { parseApplicationToForm, parseFormToApplication } from 'client/utils'
-function ApplicationsTemplatesCreateForm () {
+function ApplicationsTemplatesCreateForm() {
const history = useHistory()
const { id } = useParams()
const { steps, defaultValues, resolvers } = Steps()
@@ -37,7 +37,7 @@ function ApplicationsTemplatesCreateForm () {
const {
getApplicationTemplate,
createApplicationTemplate,
- updateApplicationTemplate
+ updateApplicationTemplate,
} = useApplicationTemplateApi()
const { data, fetchRequest, loading, error } = useFetch(
@@ -47,18 +47,20 @@ function ApplicationsTemplatesCreateForm () {
const methods = useForm({
mode: 'onSubmit',
defaultValues,
- resolver: yupResolver(resolvers())
+ resolver: yupResolver(resolvers()),
})
- const onSubmit = formData => {
+ const onSubmit = (formData) => {
const application = parseFormToApplication(formData)
if (id) {
- updateApplicationTemplate(id, application)
- .then(res => res && history.push(PATH.APPLICATIONS_TEMPLATES.LIST))
+ updateApplicationTemplate(id, application).then(
+ (res) => res && history.push(PATH.APPLICATIONS_TEMPLATES.LIST)
+ )
} else {
- createApplicationTemplate(application)
- .then(res => res && history.push(PATH.APPLICATIONS_TEMPLATES.LIST))
+ createApplicationTemplate(application).then(
+ (res) => res && history.push(PATH.APPLICATIONS_TEMPLATES.LIST)
+ )
}
}
@@ -77,7 +79,7 @@ function ApplicationsTemplatesCreateForm () {
}
return (id && !data) || loading ? (
-
+
) : (
({
content: useCallback(
() => ,
[]
- )
+ ),
})
export default BasicConfiguration
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/BasicConfiguration/schema.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/BasicConfiguration/schema.js
index d671e34d2e..a254c64413 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/BasicConfiguration/schema.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/BasicConfiguration/schema.js
@@ -25,7 +25,7 @@ const NAME = {
validation: yup
.string()
.trim()
- .default(() => undefined)
+ .default(() => undefined),
}
const INSTANCES = {
@@ -38,11 +38,9 @@ const INSTANCES = {
.min(1, 'Instances minimum is 1')
.integer('Instances should be an integer number')
.required('Instances field is required')
- .default(1)
+ .default(1),
}
export const FORM_FIELDS = [NAME, INSTANCES]
-export const STEP_FORM_SCHEMA = yup.object(
- getValidationFromFields(FORM_FIELDS)
-)
+export const STEP_FORM_SCHEMA = yup.object(getValidationFromFields(FORM_FIELDS))
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Networking/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Networking/index.js
index 3114857b2b..a5080f7cc2 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Networking/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Networking/index.js
@@ -56,7 +56,7 @@ const Networks = () => ({
/>
))
- }, [])
+ }, []),
})
export default Networks
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Networking/schema.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Networking/schema.js
index 5100edb082..6ad464aad7 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Networking/schema.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Networking/schema.js
@@ -20,18 +20,17 @@ import { getValidationFromFields } from 'client/utils'
const SELECT = {
template: 'template',
- network: 'network'
+ network: 'network',
}
const TYPES_NETWORKS = [
{ text: 'Create', value: 'template_id', select: SELECT.template },
{ text: 'Reserve', value: 'reserve_from', select: SELECT.network },
- { text: 'Existing', value: 'id', select: SELECT.network, extra: false }
+ { text: 'Existing', value: 'id', select: SELECT.network, extra: false },
]
-const hasExtraValue = type => TYPES_NETWORKS.some(
- ({ value, extra }) => value === type && extra === false
-)
+const hasExtraValue = (type) =>
+ TYPES_NETWORKS.some(({ value, extra }) => value === type && extra === false)
const TYPE = {
name: 'type',
@@ -42,7 +41,7 @@ const TYPE = {
.string()
.oneOf(TYPES_NETWORKS.map(({ value }) => value))
.required('Type field is required')
- .default(TYPES_NETWORKS[0].value)
+ .default(TYPES_NETWORKS[0].value),
}
const ID_VNET = {
@@ -50,7 +49,7 @@ const ID_VNET = {
label: 'Select a network',
type: INPUT_TYPES.AUTOCOMPLETE,
dependOf: TYPE.name,
- values: dependValue => {
+ values: (dependValue) => {
const vNetworks = useVNetwork()
const vNetworksTemplates = useVNetworkTemplate()
@@ -73,7 +72,7 @@ const ID_VNET = {
? schema.required('Network field is required')
: schema.required('Network template field is required')
)
- .default(undefined)
+ .default(undefined),
}
const EXTRA = {
@@ -82,12 +81,15 @@ const EXTRA = {
multiline: true,
type: INPUT_TYPES.TEXT,
dependOf: TYPE.name,
- htmlType: dependValue => hasExtraValue(dependValue) ? INPUT_TYPES.HIDDEN : INPUT_TYPES.TEXT,
+ htmlType: (dependValue) =>
+ hasExtraValue(dependValue) ? INPUT_TYPES.HIDDEN : INPUT_TYPES.TEXT,
validation: yup
.string()
.trim()
- .when(TYPE.name, (type, schema) => hasExtraValue(type) ? schema.strip() : schema)
- .default('')
+ .when(TYPE.name, (type, schema) =>
+ hasExtraValue(type) ? schema.strip() : schema
+ )
+ .default(''),
}
export const FORM_FIELDS = [TYPE, ID_VNET, EXTRA]
@@ -96,6 +98,4 @@ export const NETWORK_FORM_SCHEMA = yup.object(
getValidationFromFields(FORM_FIELDS)
)
-export const STEP_FORM_SCHEMA = yup
- .array(NETWORK_FORM_SCHEMA)
- .default([])
+export const STEP_FORM_SCHEMA = yup.array(NETWORK_FORM_SCHEMA).default([])
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers/index.js
index bb4d76c78d..4b361234b9 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers/index.js
@@ -28,11 +28,17 @@ import { ID, FORM_FIELDS, STEP_FORM_SCHEMA } from './schema'
export const STEP_ID = 'tiers'
const Tiers = ({ tiers, vmTemplates }) => {
- const userInputsFields = useMemo(() => vmTemplates.reduce(
- (list, { ID, TEMPLATE: { USER_INPUTS = {} } }) => ({
- ...list, [ID]: FORM_FIELDS(USER_INPUTS)
- }), {})
- , [vmTemplates])
+ const userInputsFields = useMemo(
+ () =>
+ vmTemplates.reduce(
+ (list, { ID, TEMPLATE: { USER_INPUTS = {} } }) => ({
+ ...list,
+ [ID]: FORM_FIELDS(USER_INPUTS),
+ }),
+ {}
+ ),
+ [vmTemplates]
+ )
return {
id: STEP_ID,
@@ -43,11 +49,13 @@ const Tiers = ({ tiers, vmTemplates }) => {
const [tabSelected, setTab] = useState(tiers?.[0]?.id)
const theme = useTheme()
- const { formState: { errors } } = useFormContext()
+ const {
+ formState: { errors },
+ } = useFormContext()
return (
<>
-
+
setTab(tab)}>
{tiers?.map(({ id, tier }, idx) => (
{
value={id}
label={tier?.name}
id={`tab-${id}`}
- icon={ errors[STEP_ID]?.[idx] && (
-
- )}
+ icon={
+ errors[STEP_ID]?.[idx] && (
+
+ )
+ }
/>
))}
- {useMemo(() => tiers?.map(({ id, template }, index) => (
-
-
-
-
- )), [tiers, userInputsFields, tabSelected])}
+ {useMemo(
+ () =>
+ tiers?.map(({ id, template }, index) => (
+
+
+
+
+ )),
+ [tiers, userInputsFields, tabSelected]
+ )}
>
)
- }, [tiers, userInputsFields])
+ }, [tiers, userInputsFields]),
}
}
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers/schema.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers/schema.js
index 37b80f006d..ee34cc06bf 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers/schema.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers/schema.js
@@ -25,12 +25,7 @@ export const ID = {
label: 'ID',
type: INPUT_TYPES.TEXT,
htmlType: INPUT_TYPES.HIDDEN,
- validation: yup
- .string()
- .trim()
- .uuid()
- .required()
- .default(uuidv4)
+ validation: yup.string().trim().uuid().required().default(uuidv4),
}
const requiredSchema = (mandatory, name, schema) =>
@@ -39,66 +34,74 @@ const requiredSchema = (mandatory, name, schema) =>
: schema.notRequired().nullable()
const getRange = (options) =>
- options.split('..').map(option => parseFloat(option))
+ options.split('..').map((option) => parseFloat(option))
const getOptionsFromList = (options, separator = ',') =>
- options?.split(separator).map(value => ({ text: value, value }))
+ options?.split(separator).map((value) => ({ text: value, value }))
const getUserInput = ({ mandatory, name, type, options, defaultValue }) => {
switch (type) {
case 'text':
case 'text64':
- case 'password': return {
- type: INPUT_TYPES.TEXT,
- htmlType: type === 'password' ? 'password' : 'text',
- validation: yup.string()
- .trim()
- .concat(requiredSchema(mandatory, name, yup.string()))
- .default(defaultValue || undefined)
- }
+ case 'password':
+ return {
+ type: INPUT_TYPES.TEXT,
+ htmlType: type === 'password' ? 'password' : 'text',
+ validation: yup
+ .string()
+ .trim()
+ .concat(requiredSchema(mandatory, name, yup.string()))
+ .default(defaultValue || undefined),
+ }
case 'number':
- case 'number-float': return {
- type: INPUT_TYPES.TEXT,
- htmlType: 'number',
- validation: yup.number()
- .typeError(`${name} must be a number`)
- .concat(requiredSchema(mandatory, name, yup.number()))
- .transform(value => !isNaN(value) ? value : null)
- .default(() => parseFloat(defaultValue) ?? undefined)
- }
+ case 'number-float':
+ return {
+ type: INPUT_TYPES.TEXT,
+ htmlType: 'number',
+ validation: yup
+ .number()
+ .typeError(`${name} must be a number`)
+ .concat(requiredSchema(mandatory, name, yup.number()))
+ .transform((value) => (!isNaN(value) ? value : null))
+ .default(() => parseFloat(defaultValue) ?? undefined),
+ }
case 'range':
case 'range-float': {
const [min, max] = getRange(options)
return {
type: INPUT_TYPES.SLIDER,
- validation: yup.number()
+ validation: yup
+ .number()
.typeError(`${name} must be a number`)
.concat(requiredSchema(mandatory, name, yup.number()))
.min(min, `${name} must be greater than or equal to ${min}`)
.max(max, `${name} must be less than or equal to ${max}`)
- .transform(value => !isNaN(value) ? value : undefined)
+ .transform((value) => (!isNaN(value) ? value : undefined))
.default(parseFloat(defaultValue) ?? undefined),
- fieldProps: { min, max, step: type === 'range-float' ? 0.01 : 1 }
+ fieldProps: { min, max, step: type === 'range-float' ? 0.01 : 1 },
}
}
- case 'boolean': return {
- type: INPUT_TYPES.CHECKBOX,
- validation: yup.boolean()
- .concat(requiredSchema(mandatory, name, yup.boolean()))
- .default(defaultValue === 'YES' ?? false)
- }
+ case 'boolean':
+ return {
+ type: INPUT_TYPES.CHECKBOX,
+ validation: yup
+ .boolean()
+ .concat(requiredSchema(mandatory, name, yup.boolean()))
+ .default(defaultValue === 'YES' ?? false),
+ }
case 'list': {
const values = getOptionsFromList(options)
return {
values,
type: INPUT_TYPES.SELECT,
- validation: yup.string()
+ validation: yup
+ .string()
.trim()
.concat(requiredSchema(mandatory, name, yup.string()))
.oneOf(values.map(({ value }) => value))
- .default(defaultValue ?? undefined)
+ .default(defaultValue ?? undefined),
}
}
case 'list-multiple': {
@@ -109,22 +112,25 @@ const getUserInput = ({ mandatory, name, type, options, defaultValue }) => {
values,
type: INPUT_TYPES.SELECT,
multiple: true,
- validation: yup.array(yup.string().trim())
+ validation: yup
+ .array(yup.string().trim())
.concat(requiredSchema(mandatory, name, yup.array()))
- .default(defaultValues)
+ .default(defaultValues),
}
}
- default: return {
- type: INPUT_TYPES.TEXT,
- validation: yup.string()
- .trim()
- .concat(requiredSchema(mandatory, name, yup.string()))
- .default(defaultValue || undefined)
- }
+ default:
+ return {
+ type: INPUT_TYPES.TEXT,
+ validation: yup
+ .string()
+ .trim()
+ .concat(requiredSchema(mandatory, name, yup.string()))
+ .default(defaultValue || undefined),
+ }
}
}
-export const FORM_FIELDS = userInputs =>
+export const FORM_FIELDS = (userInputs) =>
Object.entries(userInputs)?.map(([name, values]) => {
const input = String(values).split('|')
// 0 mandatory; 1 type; 2 description; 3 range/options; 4 defaultValue;
@@ -137,17 +143,19 @@ export const FORM_FIELDS = userInputs =>
return {
name,
label: `${description}${mandatory ? ' *' : ''}`,
- ...getUserInput({ mandatory, name, type, options, defaultValue })
+ ...getUserInput({ mandatory, name, type, options, defaultValue }),
}
})
-export const USER_INPUTS_FORM_SCHEMA = userInputs => yup.object(
- getValidationFromFields(FORM_FIELDS(userInputs))
-)
+export const USER_INPUTS_FORM_SCHEMA = (userInputs) =>
+ yup.object(getValidationFromFields(FORM_FIELDS(userInputs)))
export const STEP_FORM_SCHEMA = ({ tiers, vmTemplates }) => {
const schemasUI = tiers?.reduce((schemas, tier) => {
- const { id: tierId, template: { id } } = tier
+ const {
+ id: tierId,
+ template: { id },
+ } = tier
const vmTemplate = vmTemplates?.find(({ ID }) => id === ID) ?? {}
const { TEMPLATE: { USER_INPUTS = {} } = {} } = vmTemplate
@@ -156,13 +164,20 @@ export const STEP_FORM_SCHEMA = ({ tiers, vmTemplates }) => {
}, {})
return yup
- .array(yup.lazy(value => yup.object({
- ...getValidationFromFields([ID]),
- user_inputs_values: schemasUI[value?.id]
- })))
+ .array(
+ yup.lazy((value) =>
+ yup.object({
+ ...getValidationFromFields([ID]),
+ user_inputs_values: schemasUI[value?.id],
+ })
+ )
+ )
.min(1, 'Should be at least one tier')
.required('Tiers field is required')
- .default(() => tiers.map((tier) => ({
- ...tier, user_inputs_values: schemasUI[tier.id].default()
- })))
+ .default(() =>
+ tiers.map((tier) => ({
+ ...tier,
+ user_inputs_values: schemasUI[tier.id].default(),
+ }))
+ )
}
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/index.js
index 2b523491f8..77d445b1b4 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/Steps/index.js
@@ -21,10 +21,8 @@ import Networking, { STEP_ID as NETWORKING_ID } from './Networking'
import Tiers, { STEP_ID as TIERS_ID } from './Tiers'
const Steps = ({ applicationTemplate = {}, vmTemplates }) => {
- const {
- [TIERS_ID]: appTiers,
- [NETWORKING_ID]: appNetworking
- } = applicationTemplate
+ const { [TIERS_ID]: appTiers, [NETWORKING_ID]: appNetworking } =
+ applicationTemplate
const basic = BasicConfiguration()
const tiers = Tiers({ tiers: appTiers, vmTemplates })
@@ -33,10 +31,16 @@ const Steps = ({ applicationTemplate = {}, vmTemplates }) => {
const steps = [basic, tiers]
appNetworking?.length > 0 && steps.push(networking)
- const resolvers = () => yup
- .object(steps.reduce((res, step) => ({
- ...res, [step.id]: step.resolver
- }), {}))
+ const resolvers = () =>
+ yup.object(
+ steps.reduce(
+ (res, step) => ({
+ ...res,
+ [step.id]: step.resolver,
+ }),
+ {}
+ )
+ )
const defaultValues = resolvers().default()
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/index.js
index 5f100cbd66..4fec24fcc1 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/Form/Deploy/index.js
@@ -27,13 +27,16 @@ import { useGeneralApi } from 'client/features/General'
import { DialogForm } from 'client/components/Dialogs'
import FormStepper from 'client/components/FormStepper'
import Steps from 'client/containers/ApplicationsTemplates/Form/Deploy/Steps'
-import { parseApplicationToForm, parseFormToDeployApplication } from 'client/utils'
+import {
+ parseApplicationToForm,
+ parseFormToDeployApplication,
+} from 'client/utils'
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles((theme) => ({
backdrop: {
zIndex: theme.zIndex.appBar,
- color: theme.palette.common.white
- }
+ color: theme.palette.common.white,
+ },
}))
const DeployForm = ({ applicationTemplate, handleCancel }) => {
@@ -41,16 +44,18 @@ const DeployForm = ({ applicationTemplate, handleCancel }) => {
const [vmTemplates, setVmTemplates] = useState([])
const { enqueueInfo } = useGeneralApi()
- const { getApplicationsTemplates, instantiateApplicationTemplate } = useApplicationTemplateApi()
+ const { getApplicationsTemplates, instantiateApplicationTemplate } =
+ useApplicationTemplateApi()
const { data, fetchRequestAll, loading } = useFetchAll()
- const applicationParsed = useMemo(() =>
- parseApplicationToForm(applicationTemplate)
- , [])
+ const applicationParsed = useMemo(
+ () => parseApplicationToForm(applicationTemplate),
+ []
+ )
const { steps, resolvers } = Steps({
applicationTemplate: applicationParsed,
- vmTemplates
+ vmTemplates,
})
useEffect(() => {
@@ -58,28 +63,31 @@ const DeployForm = ({ applicationTemplate, handleCancel }) => {
const fetchTemplates = tiers
?.map(({ template: { id } }) => id)
- ?.reduce((list, templateId) =>
- list.includes(templateId) ? list : [...list, templateId]
- , [])
- ?.map(templateId =>
- getApplicationsTemplates(templateId).then(vmTemplate =>
- setVmTemplates(prev => [...prev, vmTemplate])
+ ?.reduce(
+ (list, templateId) =>
+ list.includes(templateId) ? list : [...list, templateId],
+ []
+ )
+ ?.map((templateId) =>
+ getApplicationsTemplates(templateId).then((vmTemplate) =>
+ setVmTemplates((prev) => [...prev, vmTemplate])
)
)
fetchRequestAll(fetchTemplates)
}, [applicationParsed])
- const handleSubmit = values => {
- const {
- instances,
- ...application
- } = parseFormToDeployApplication(values, applicationParsed)
+ const handleSubmit = (values) => {
+ const { instances, ...application } = parseFormToDeployApplication(
+ values,
+ applicationParsed
+ )
- return Promise
- .all([...new Array(instances)]
- .map(() => instantiateApplicationTemplate(applicationTemplate.ID, application))
+ return Promise.all(
+ [...new Array(instances)].map(() =>
+ instantiateApplicationTemplate(applicationTemplate.ID, application)
)
+ )
.then(() => handleCancel())
.then(() => enqueueInfo(`Template instantiate - x${instances}`))
}
@@ -87,7 +95,7 @@ const DeployForm = ({ applicationTemplate, handleCancel }) => {
if ((applicationTemplate && !data) || loading) {
return (
-
+
)
}
@@ -100,23 +108,19 @@ const DeployForm = ({ applicationTemplate, handleCancel }) => {
values={resolvers().cast(applicationParsed)}
onCancel={handleCancel}
>
-
+
)
}
DeployForm.propTypes = {
applicationTemplate: PropTypes.object.isRequired,
- handleCancel: PropTypes.func
+ handleCancel: PropTypes.func,
}
DeployForm.defaultProps = {
applicationTemplate: undefined,
- handleCancel: undefined
+ handleCancel: undefined,
}
export default DeployForm
diff --git a/src/fireedge/src/client/containers/ApplicationsTemplates/index.js b/src/fireedge/src/client/containers/ApplicationsTemplates/index.js
index 2cba434ea2..877bd668eb 100644
--- a/src/fireedge/src/client/containers/ApplicationsTemplates/index.js
+++ b/src/fireedge/src/client/containers/ApplicationsTemplates/index.js
@@ -21,7 +21,10 @@ import { Container, Box } from '@mui/material'
import { PATH } from 'client/apps/sunstone/routesFlow'
import { useFetch } from 'client/hooks'
-import { useApplicationTemplate, useApplicationTemplateApi } from 'client/features/One'
+import {
+ useApplicationTemplate,
+ useApplicationTemplateApi,
+} from 'client/features/One'
import DeployForm from 'client/containers/ApplicationsTemplates/Form/Deploy'
import { ListHeader, ListCards } from 'client/components/List'
@@ -29,16 +32,20 @@ import AlertError from 'client/components/Alerts/Error'
import { ApplicationTemplateCard } from 'client/components/Cards'
import { T } from 'client/constants'
-function ApplicationsTemplates () {
+function ApplicationsTemplates() {
const history = useHistory()
const [showDialog, setShowDialog] = useState(false)
const applicationsTemplates = useApplicationTemplate()
const { getApplicationsTemplates } = useApplicationTemplateApi()
- const { error, fetchRequest, loading, reloading } = useFetch(getApplicationsTemplates)
+ const { error, fetchRequest, loading, reloading } = useFetch(
+ getApplicationsTemplates
+ )
- useEffect(() => { fetchRequest() }, [])
+ useEffect(() => {
+ fetchRequest()
+ }, [])
return (
@@ -48,11 +55,11 @@ function ApplicationsTemplates () {
reloadButtonProps={{
'data-cy': 'refresh-application-template-list',
onClick: () => fetchRequest(undefined, { reload: true, delay: 500 }),
- isSubmitting: Boolean(loading || reloading)
+ isSubmitting: Boolean(loading || reloading),
}}
addButtonProps={{
'data-cy': 'create-application-template',
- onClick: () => history.push(PATH.APPLICATIONS_TEMPLATES.CREATE)
+ onClick: () => history.push(PATH.APPLICATIONS_TEMPLATES.CREATE),
}}
/>
@@ -66,9 +73,13 @@ function ApplicationsTemplates () {
CardComponent={ApplicationTemplateCard}
cardsProps={({ value }) => ({
handleEdit: () =>
- history.push(generatePath(PATH.APPLICATIONS_TEMPLATES.EDIT, { id: value?.ID })),
+ history.push(
+ generatePath(PATH.APPLICATIONS_TEMPLATES.EDIT, {
+ id: value?.ID,
+ })
+ ),
handleDeploy: () => setShowDialog(value),
- handleRemove: undefined // TODO
+ handleRemove: undefined, // TODO
})}
/>
)}
diff --git a/src/fireedge/src/client/containers/Clusters/Detail.js b/src/fireedge/src/client/containers/Clusters/Detail.js
index f325ee0aad..3afaaee3a0 100644
--- a/src/fireedge/src/client/containers/Clusters/Detail.js
+++ b/src/fireedge/src/client/containers/Clusters/Detail.js
@@ -19,19 +19,19 @@ import { Container, Box } from '@mui/material'
import ClusterTabs from 'client/components/Tabs/Cluster'
-function ClusterDetail () {
+function ClusterDetail() {
const { id } = useParams()
if (Number.isNaN(+id)) {
- return
+ return
}
return (
{}
diff --git a/src/fireedge/src/client/containers/Clusters/index.js b/src/fireedge/src/client/containers/Clusters/index.js
index e06c053505..5df950978f 100644
--- a/src/fireedge/src/client/containers/Clusters/index.js
+++ b/src/fireedge/src/client/containers/Clusters/index.js
@@ -22,31 +22,40 @@ import ClusterTabs from 'client/components/Tabs/Cluster'
import SplitPane from 'client/components/SplitPane'
import MultipleTags from 'client/components/MultipleTags'
-function Clusters () {
+function Clusters() {
const [selectedRows, onSelectedRowsChange] = useState(() => [])
return (
-
+
{selectedRows?.length > 0 && (
-
- {selectedRows?.length === 1
- ?
- :
+
+ {selectedRows?.length === 1 ? (
+
+ ) : (
+
(
- toggleRowSelected(false)}
- />
- ))}
+ tags={selectedRows?.map(
+ ({ original, id, toggleRowSelected }) => (
+ toggleRowSelected(false)}
+ />
+ )
+ )}
/>
- }
+ )}
)}
diff --git a/src/fireedge/src/client/containers/Dashboard/Provision/index.js b/src/fireedge/src/client/containers/Dashboard/Provision/index.js
index bfced84e58..98b239c6b0 100644
--- a/src/fireedge/src/client/containers/Dashboard/Provision/index.js
+++ b/src/fireedge/src/client/containers/Dashboard/Provision/index.js
@@ -23,7 +23,7 @@ import * as Widgets from 'client/components/Widgets'
import { stringToBoolean } from 'client/models/Helper'
/** @returns {JSXElementConstructor} Provision dashboard container */
-function ProvisionDashboard () {
+function ProvisionDashboard() {
const { status, fetchRequestAll, STATUS } = useFetchAll()
const { INIT, PENDING } = STATUS
@@ -33,22 +33,19 @@ function ProvisionDashboard () {
const { settings: { disableanimations } = {} } = useAuth()
useEffect(() => {
- fetchRequestAll([
- getProviders(),
- getProvisions()
- ])
+ fetchRequestAll([getProviders(), getProvisions()])
}, [])
return (
diff --git a/src/fireedge/src/client/containers/Dashboard/Sunstone/index.js b/src/fireedge/src/client/containers/Dashboard/Sunstone/index.js
index d9eadb94c0..7e8d1fc7e1 100644
--- a/src/fireedge/src/client/containers/Dashboard/Sunstone/index.js
+++ b/src/fireedge/src/client/containers/Dashboard/Sunstone/index.js
@@ -18,12 +18,17 @@ import { Container, Box, Grid } from '@mui/material'
import { useAuth } from 'client/features/Auth'
import { useFetchAll } from 'client/hooks'
-import { useUserApi, useImageApi, useVNetworkApi, useDatastoreApi } from 'client/features/One'
+import {
+ useUserApi,
+ useImageApi,
+ useVNetworkApi,
+ useDatastoreApi,
+} from 'client/features/One'
import * as Widgets from 'client/components/Widgets'
import { stringToBoolean } from 'client/models/Helper'
/** @returns {JSXElementConstructor} Sunstone dashboard container */
-function SunstoneDashboard () {
+function SunstoneDashboard() {
const { status, fetchRequestAll, STATUS } = useFetchAll()
const { INIT, PENDING } = STATUS
@@ -35,24 +40,19 @@ function SunstoneDashboard () {
const { settings: { disableanimations } = {} } = useAuth()
useEffect(() => {
- fetchRequestAll([
- getUsers(),
- getImages(),
- getVNetworks(),
- getDatastores()
- ])
+ fetchRequestAll([getUsers(), getImages(), getVNetworks(), getDatastores()])
}, [])
return (
diff --git a/src/fireedge/src/client/containers/Datastores/index.js b/src/fireedge/src/client/containers/Datastores/index.js
index 46cc72b3ae..018022cb66 100644
--- a/src/fireedge/src/client/containers/Datastores/index.js
+++ b/src/fireedge/src/client/containers/Datastores/index.js
@@ -19,14 +19,14 @@ import { Container, Box } from '@mui/material'
import { DatastoresTable } from 'client/components/Tables'
-function Datastores () {
+function Datastores() {
return (
diff --git a/src/fireedge/src/client/containers/Groups/Detail.js b/src/fireedge/src/client/containers/Groups/Detail.js
index 59831966e0..d4422b3e39 100644
--- a/src/fireedge/src/client/containers/Groups/Detail.js
+++ b/src/fireedge/src/client/containers/Groups/Detail.js
@@ -19,19 +19,19 @@ import { Container, Box } from '@mui/material'
// import GroupTabs from 'client/components/Tabs/Group'
-function GroupDetail () {
+function GroupDetail() {
const { id } = useParams()
if (Number.isNaN(+id)) {
- return
+ return
}
return (
{/* */}
diff --git a/src/fireedge/src/client/containers/Groups/index.js b/src/fireedge/src/client/containers/Groups/index.js
index 86512806d2..f330170379 100644
--- a/src/fireedge/src/client/containers/Groups/index.js
+++ b/src/fireedge/src/client/containers/Groups/index.js
@@ -19,14 +19,14 @@ import { Container, Box } from '@mui/material'
import { GroupsTable } from 'client/components/Tables'
-function Groups () {
+function Groups() {
return (
diff --git a/src/fireedge/src/client/containers/Hosts/Detail.js b/src/fireedge/src/client/containers/Hosts/Detail.js
index f3ec7f4bad..fd91719d52 100644
--- a/src/fireedge/src/client/containers/Hosts/Detail.js
+++ b/src/fireedge/src/client/containers/Hosts/Detail.js
@@ -19,19 +19,19 @@ import { Container, Box } from '@mui/material'
import HostTabs from 'client/components/Tabs/Host'
-function HostDetail () {
+function HostDetail() {
const { id } = useParams()
if (Number.isNaN(+id)) {
- return
+ return
}
return (
diff --git a/src/fireedge/src/client/containers/Hosts/index.js b/src/fireedge/src/client/containers/Hosts/index.js
index 5c4a5508aa..5cdc1ccf18 100644
--- a/src/fireedge/src/client/containers/Hosts/index.js
+++ b/src/fireedge/src/client/containers/Hosts/index.js
@@ -22,31 +22,40 @@ import HostTabs from 'client/components/Tabs/Host'
import SplitPane from 'client/components/SplitPane'
import MultipleTags from 'client/components/MultipleTags'
-function Hosts () {
+function Hosts() {
const [selectedRows, onSelectedRowsChange] = useState(() => [])
return (
-
+
{selectedRows?.length > 0 && (
-
- {selectedRows?.length === 1
- ?
- :
+
+ {selectedRows?.length === 1 ? (
+
+ ) : (
+
(
- toggleRowSelected(false)}
- />
- ))}
+ tags={selectedRows?.map(
+ ({ original, id, toggleRowSelected }) => (
+ toggleRowSelected(false)}
+ />
+ )
+ )}
/>
- }
+ )}
)}
diff --git a/src/fireedge/src/client/containers/Images/index.js b/src/fireedge/src/client/containers/Images/index.js
index 79c72a2982..df41ce6b3e 100644
--- a/src/fireedge/src/client/containers/Images/index.js
+++ b/src/fireedge/src/client/containers/Images/index.js
@@ -22,31 +22,40 @@ import Detail from 'client/components/Tables/Images/detail'
import SplitPane from 'client/components/SplitPane'
import MultipleTags from 'client/components/MultipleTags'
-function Images () {
+function Images() {
const [selectedRows, onSelectedRowsChange] = useState(() => [])
return (
-
+
{selectedRows?.length > 0 && (
-
- {selectedRows?.length === 1
- ?
- :
+
+ {selectedRows?.length === 1 ? (
+
+ ) : (
+
(
- toggleRowSelected(false)}
- />
- ))}
+ tags={selectedRows?.map(
+ ({ original, id, toggleRowSelected }) => (
+ toggleRowSelected(false)}
+ />
+ )
+ )}
/>
- }
+ )}
)}
diff --git a/src/fireedge/src/client/containers/Login/Form.js b/src/fireedge/src/client/containers/Login/Form.js
index e0f883785f..dba6eff250 100644
--- a/src/fireedge/src/client/containers/Login/Form.js
+++ b/src/fireedge/src/client/containers/Login/Form.js
@@ -29,14 +29,22 @@ import { SubmitButton } from 'client/components/FormControl'
import { Tr } from 'client/components/HOC'
import { T } from 'client/constants'
-const Form = ({ onBack, onSubmit, resolver, fields, error, isLoading, transitionProps }) => {
+const Form = ({
+ onBack,
+ onSubmit,
+ resolver,
+ fields,
+ error,
+ isLoading,
+ transitionProps,
+}) => {
const defaultValues = resolver.default()
const classes = loginStyles()
const { handleSubmit, setError, ...methods } = useForm({
reValidateMode: 'onSubmit',
defaultValues,
- resolver: yupResolver(resolver)
+ resolver: yupResolver(resolver),
})
useEffect(() => {
@@ -51,22 +59,22 @@ const Form = ({ onBack, onSubmit, resolver, fields, error, isLoading, transition
{...transitionProps}
>
-
+
-
+
{onBack && (
-
+
{Tr(T.Back)}
)}
theme.breakpoints.only('xs'))
+ const isMobile = useMediaQuery((theme) => theme.breakpoints.only('xs'))
- const { error, isLoading: authLoading, isLoginInProgress: needGroupToContinue } = useAuth()
+ const {
+ error,
+ isLoading: authLoading,
+ isLoginInProgress: needGroupToContinue,
+ } = useAuth()
const { login, getAuthUser, changeGroup, logout } = useAuthApi()
const { fetchRequest: fetchLogin, loading: loginIsLoading } = useFetch(login)
const [dataUserForm, setDataUserForm] = useState(undefined)
- const [step, setStep] = useState(
- () => needGroupToContinue ? STEPS.GROUP_FORM : STEPS.USER_FORM
+ const [step, setStep] = useState(() =>
+ needGroupToContinue ? STEPS.GROUP_FORM : STEPS.USER_FORM
)
const handleSubmitUser = async (dataForm) => {
@@ -58,7 +68,7 @@ function Login () {
}
}
- const handleSubmitGroup = dataForm => changeGroup(dataForm)
+ const handleSubmitGroup = (dataForm) => changeGroup(dataForm)
const handleBack = () => {
logout()
@@ -75,53 +85,64 @@ function Login () {
maxWidth={isMobile ? 'lg' : 'xs'}
className={classes.root}
>
- {isLoading && }
+ {isLoading && (
+
+ )}
- {useMemo(() => (
-
- ), [])}
+ {useMemo(
+ () => (
+
+ ),
+ []
+ )}
- {step === STEPS.USER_FORM && }
- {step === STEPS.FA2_FORM && }
- {step === STEPS.GROUP_FORM && }
+ {step === STEPS.USER_FORM && (
+
+ )}
+ {step === STEPS.FA2_FORM && (
+
+ )}
+ {step === STEPS.GROUP_FORM && (
+
+ )}
diff --git a/src/fireedge/src/client/containers/Login/schema.js b/src/fireedge/src/client/containers/Login/schema.js
index cd2bde20b5..2080700c8e 100644
--- a/src/fireedge/src/client/containers/Login/schema.js
+++ b/src/fireedge/src/client/containers/Login/schema.js
@@ -35,8 +35,8 @@ export const USERNAME = {
autoFocus: true,
required: true,
autoComplete: 'username',
- size: 'medium'
- }
+ size: 'medium',
+ },
}
export const PASSWORD = {
@@ -52,18 +52,16 @@ export const PASSWORD = {
fieldProps: {
required: true,
autoComplete: 'current-password',
- size: 'medium'
- }
+ size: 'medium',
+ },
}
export const REMEMBER = {
name: 'remember',
label: T.KeepLoggedIn,
type: INPUT_TYPES.CHECKBOX,
- validation: yup
- .boolean()
- .default(() => false),
- grid: { md: 12 }
+ validation: yup.boolean().default(() => false),
+ grid: { md: 12 },
}
export const TOKEN = {
@@ -79,8 +77,8 @@ export const TOKEN = {
fieldProps: {
autoFocus: true,
required: true,
- margin: 'normal'
- }
+ margin: 'normal',
+ },
}
export const GROUP = {
@@ -96,29 +94,33 @@ export const GROUP = {
addEmpty: false,
getText: ({ ID, NAME }) => {
const isPrimary = user?.GID === ID ? `(${Tr(T.Primary)})` : ''
+
return `${ID} - ${NAME} ${isPrimary}`
},
- getValue: ({ ID }) => String(ID)
+ getValue: ({ ID }) => String(ID),
})
- return [{ text: T.ShowAll, value: FILTER_POOL.ALL_RESOURCES }]
- .concat(formatGroups)
+ return [{ text: T.ShowAll, value: FILTER_POOL.ALL_RESOURCES }].concat(
+ formatGroups
+ )
},
- validation: yup
- .string()
- .trim()
- .nullable()
- .default(FILTER_POOL.ALL_RESOURCES),
+ validation: yup.string().trim().nullable().default(FILTER_POOL.ALL_RESOURCES),
grid: { md: 12 },
fieldProps: {
- margin: 'normal'
- }
+ margin: 'normal',
+ },
}
export const FORM_USER_FIELDS = [USERNAME, PASSWORD, REMEMBER]
export const FORM_2FA_FIELDS = [TOKEN]
export const FORM_GROUP_FIELDS = [GROUP]
-export const FORM_USER_SCHEMA = yup.object(getValidationFromFields(FORM_USER_FIELDS))
-export const FORM_2FA_SCHEMA = yup.object(getValidationFromFields(FORM_2FA_FIELDS))
-export const FORM_GROUP_SCHEMA = yup.object(getValidationFromFields(FORM_GROUP_FIELDS))
+export const FORM_USER_SCHEMA = yup.object(
+ getValidationFromFields(FORM_USER_FIELDS)
+)
+export const FORM_2FA_SCHEMA = yup.object(
+ getValidationFromFields(FORM_2FA_FIELDS)
+)
+export const FORM_GROUP_SCHEMA = yup.object(
+ getValidationFromFields(FORM_GROUP_FIELDS)
+)
diff --git a/src/fireedge/src/client/containers/Login/styles.js b/src/fireedge/src/client/containers/Login/styles.js
index bfda23d7b0..5a05f42e20 100644
--- a/src/fireedge/src/client/containers/Login/styles.js
+++ b/src/fireedge/src/client/containers/Login/styles.js
@@ -15,20 +15,20 @@
* ------------------------------------------------------------------------- */
import makeStyles from '@mui/styles/makeStyles'
-export default makeStyles(theme => ({
+export default makeStyles((theme) => ({
root: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
- height: '100vh'
+ height: '100vh',
},
progress: {
height: 4,
width: '100%',
[theme.breakpoints.only('xs')]: {
top: 0,
- position: 'fixed'
- }
+ position: 'fixed',
+ },
},
paper: {
overflow: 'hidden',
@@ -36,18 +36,18 @@ export default makeStyles(theme => ({
minHeight: 440,
[theme.breakpoints.up('xs')]: {
display: 'flex',
- flexDirection: 'column'
+ flexDirection: 'column',
},
[theme.breakpoints.only('xs')]: {
border: 'none',
height: 'calc(100vh - 4px)',
- backgroundColor: 'transparent'
- }
+ backgroundColor: 'transparent',
+ },
},
wrapperForm: {
padding: theme.spacing(2, 1),
display: 'flex',
- overflow: 'hidden'
+ overflow: 'hidden',
},
form: {
width: '100%',
@@ -55,13 +55,13 @@ export default makeStyles(theme => ({
display: 'flex',
flexDirection: 'column',
[theme.breakpoints.up('xs')]: {
- justifyContent: 'center'
- }
+ justifyContent: 'center',
+ },
},
loading: {
- opacity: 0.7
+ opacity: 0.7,
},
helper: {
- animation: '1s ease-out 0s 1'
- }
+ animation: '1s ease-out 0s 1',
+ },
}))
diff --git a/src/fireedge/src/client/containers/MarketplaceApps/Create.js b/src/fireedge/src/client/containers/MarketplaceApps/Create.js
index edef09269c..f9ee38df32 100644
--- a/src/fireedge/src/client/containers/MarketplaceApps/Create.js
+++ b/src/fireedge/src/client/containers/MarketplaceApps/Create.js
@@ -27,7 +27,7 @@ import { isDevelopment } from 'client/utils'
*
* @returns {JSXElementConstructor} Marketplace App form
*/
-function CreateMarketplaceApp () {
+function CreateMarketplaceApp() {
const history = useHistory()
const { state: [resourceName, { ID } = {}] = [] } = useLocation()
const initialValues = useMemo(() => ({ type: resourceName, id: ID }), [])
@@ -35,7 +35,7 @@ function CreateMarketplaceApp () {
const { enqueueSuccess } = useGeneralApi()
// const { } = useMarketplaceAppApi()
- const onSubmit = async template => {
+ const onSubmit = async (template) => {
try {
isDevelopment() && console.log({ template })
history.goBack()
diff --git a/src/fireedge/src/client/containers/MarketplaceApps/index.js b/src/fireedge/src/client/containers/MarketplaceApps/index.js
index c7d1c2e30e..8a57153309 100644
--- a/src/fireedge/src/client/containers/MarketplaceApps/index.js
+++ b/src/fireedge/src/client/containers/MarketplaceApps/index.js
@@ -27,12 +27,12 @@ import MultipleTags from 'client/components/MultipleTags'
*
* @returns {JSXElementConstructor} List of Marketplace Apps
*/
-function MarketplaceApps () {
+function MarketplaceApps() {
const [selectedRows, onSelectedRowsChange] = useState(() => [])
const actions = MarketplaceAppActions()
return (
-
+
{selectedRows?.length > 0 && (
-
- {selectedRows?.length === 1
- ?
- :
+
+ {selectedRows?.length === 1 ? (
+
+ ) : (
+
(
- toggleRowSelected(false)}
- />
- ))}
+ tags={selectedRows?.map(
+ ({ original, id, toggleRowSelected }) => (
+ toggleRowSelected(false)}
+ />
+ )
+ )}
/>
- }
+ )}
)}
diff --git a/src/fireedge/src/client/containers/Marketplaces/index.js b/src/fireedge/src/client/containers/Marketplaces/index.js
index 7ebc9ea11b..c1ea8a2178 100644
--- a/src/fireedge/src/client/containers/Marketplaces/index.js
+++ b/src/fireedge/src/client/containers/Marketplaces/index.js
@@ -19,14 +19,14 @@ import { Container, Box } from '@mui/material'
import { MarketplacesTable } from 'client/components/Tables'
-function Marketplaces () {
+function Marketplaces() {
return (
diff --git a/src/fireedge/src/client/containers/Providers/Create.js b/src/fireedge/src/client/containers/Providers/Create.js
index 93b859770b..fec743bf99 100644
--- a/src/fireedge/src/client/containers/Providers/Create.js
+++ b/src/fireedge/src/client/containers/Providers/Create.js
@@ -25,7 +25,7 @@ import { isValidProviderTemplate } from 'client/models/ProviderTemplate'
import { PATH } from 'client/apps/provision/routes'
import { isDevelopment } from 'client/utils'
-function ProviderCreateForm () {
+function ProviderCreateForm() {
const history = useHistory()
const { id } = useParams()
@@ -33,14 +33,16 @@ function ProviderCreateForm () {
const { enqueueSuccess, enqueueError } = useGeneralApi()
const { createProvider, updateProvider } = useProviderApi()
- const onSubmit = async formData => {
+ const onSubmit = async (formData) => {
try {
if (id !== undefined) {
await updateProvider(id, formData)
enqueueSuccess(`Provider updated - ID: ${id}`)
} else {
if (!isValidProviderTemplate(formData, providerConfig)) {
- enqueueError('The template selected has a bad format. Ask your cloud administrator')
+ enqueueError(
+ 'The template selected has a bad format. Ask your cloud administrator'
+ )
history.push(PATH.PROVIDERS.LIST)
}
diff --git a/src/fireedge/src/client/containers/Providers/Sections/info.js b/src/fireedge/src/client/containers/Providers/Sections/info.js
index 61b0cfba2b..486cbc1b3b 100644
--- a/src/fireedge/src/client/containers/Providers/Sections/info.js
+++ b/src/fireedge/src/client/containers/Providers/Sections/info.js
@@ -21,7 +21,7 @@ import { List, ListItem, Typography, Grid, Paper, Divider } from '@mui/material'
import {
Check as CheckIcon,
Square as BlankSquareIcon,
- EyeEmpty as EyeIcon
+ EyeEmpty as EyeIcon,
} from 'iconoir-react'
import { useFetch } from 'client/hooks'
@@ -36,25 +36,29 @@ const Info = memo(({ fetchProps }) => {
const classes = useStyles()
const { getProviderConnection } = useProviderApi()
- const { data: showConnection, fetchRequest, loading } = useFetch(getProviderConnection)
+ const {
+ data: showConnection,
+ fetchRequest,
+ loading,
+ } = useFetch(getProviderConnection)
const { ID, NAME, GNAME, UNAME, PERMISSIONS, TEMPLATE } = fetchProps?.data
const {
connection,
description,
provider: providerName,
- registration_time: time
+ registration_time: time,
} = TEMPLATE?.PROVISION_BODY
const hasConnection = connection && Object.keys(connection).length > 0
- const isChecked = checked =>
+ const isChecked = (checked) =>
checked === '1' ? :
return (
-
+
{Tr(T.Information)}
@@ -66,33 +70,33 @@ const Info = memo(({ fetchProps }) => {
{Tr(T.Name)}
- {NAME}
+ {NAME}
{Tr(T.Description)}
- {description}
+
+ {description}
+
{Tr(T.Provider)}
- {providerName}
+ {providerName}
{Tr(T.RegistrationTime)}
-
- {new Date(time * 1000).toLocaleString()}
-
+ {new Date(time * 1000).toLocaleString()}
{hasConnection && (
-
+
{Tr(T.Credentials)}
{!showConnection && (
}
onClick={() => fetchRequest(ID)}
isSubmitting={loading}
@@ -101,21 +105,23 @@ const Info = memo(({ fetchProps }) => {
)}
- {Object.entries(connection)?.map(([key, value]) =>
- typeof value === 'string' && (
-
- {key}
-
- {showConnection?.[key] ?? value}
-
-
- ))}
+ {Object.entries(connection)?.map(
+ ([key, value]) =>
+ typeof value === 'string' && (
+
+ {key}
+
+ {showConnection?.[key] ?? value}
+
+
+ )
+ )}
)}
-
+
{Tr(T.Permissions)}
@@ -144,7 +150,7 @@ const Info = memo(({ fetchProps }) => {
-
+
{Tr(T.Ownership)}
@@ -167,14 +173,14 @@ const Info = memo(({ fetchProps }) => {
Info.propTypes = {
fetchProps: PropTypes.shape({
- data: PropTypes.object.isRequired
- }).isRequired
+ data: PropTypes.object.isRequired,
+ }).isRequired,
}
Info.defaultProps = {
fetchProps: {
- data: {}
- }
+ data: {},
+ },
}
Info.displayName = 'Info'
diff --git a/src/fireedge/src/client/containers/Providers/Sections/styles.js b/src/fireedge/src/client/containers/Providers/Sections/styles.js
index 70218dfdc1..13b245f5bc 100644
--- a/src/fireedge/src/client/containers/Providers/Sections/styles.js
+++ b/src/fireedge/src/client/containers/Providers/Sections/styles.js
@@ -15,33 +15,33 @@
* ------------------------------------------------------------------------- */
import makeStyles from '@mui/styles/makeStyles'
-export default makeStyles(theme => ({
+export default makeStyles((theme) => ({
marginBottom: {
- marginBottom: theme.spacing(2)
+ marginBottom: theme.spacing(2),
},
list: {
'& p': {
...theme.typography.body2,
overflow: 'hidden',
- textOverflow: 'ellipsis'
+ textOverflow: 'ellipsis',
},
'&.w-50 > *': {
'& > p, & > span': {
- width: '50%'
- }
+ width: '50%',
+ },
},
'&.w-25 > *': {
'& > p, & > span': {
- width: '25%'
- }
- }
+ width: '25%',
+ },
+ },
},
title: {
'& p.bold': {
- fontWeight: theme.typography.fontWeightBold
- }
+ fontWeight: theme.typography.fontWeightBold,
+ },
},
alignToRight: {
- textAlign: 'right'
- }
+ textAlign: 'right',
+ },
}))
diff --git a/src/fireedge/src/client/containers/Providers/index.js b/src/fireedge/src/client/containers/Providers/index.js
index 4b120cb0f5..02beabb595 100644
--- a/src/fireedge/src/client/containers/Providers/index.js
+++ b/src/fireedge/src/client/containers/Providers/index.js
@@ -33,7 +33,7 @@ import { DialogRequest } from 'client/components/Dialogs'
import Information from 'client/containers/Providers/Sections/info'
import { T } from 'client/constants'
-function Providers () {
+function Providers() {
const history = useHistory()
const [showDialog, setShowDialog] = useState(false)
@@ -46,10 +46,12 @@ function Providers () {
const { result, handleChange } = useSearch({
list: providers,
- listOptions: { shouldSort: true, keys: ['ID', 'NAME'] }
+ listOptions: { shouldSort: true, keys: ['ID', 'NAME'] },
})
- useEffect(() => { fetchRequest() }, [])
+ useEffect(() => {
+ fetchRequest()
+ }, [])
const handleCancel = () => setShowDialog(false)
@@ -60,11 +62,11 @@ function Providers () {
reloadButtonProps={{
'data-cy': 'refresh-provider-list',
onClick: () => fetchRequest(undefined, { reload: true }),
- isSubmitting: Boolean(loading || reloading)
+ isSubmitting: Boolean(loading || reloading),
}}
addButtonProps={{
'data-cy': 'create-provider',
- onClick: () => history.push(PATH.PROVIDERS.CREATE)
+ onClick: () => history.push(PATH.PROVIDERS.CREATE),
}}
searchProps={{ handleChange }}
/>
@@ -80,34 +82,38 @@ function Providers () {
cardsProps={({ value: { ID, NAME, TEMPLATE } }) => ({
image: providerConfig[TEMPLATE?.PLAIN?.provider]?.image,
isProvider: true,
- handleClick: () => setShowDialog({
- id: ID,
- title: `#${ID} ${NAME}`
- }),
+ handleClick: () =>
+ setShowDialog({
+ id: ID,
+ title: `#${ID} ${NAME}`,
+ }),
actions: [
{
handleClick: () =>
history.push(generatePath(PATH.PROVIDERS.EDIT, { id: ID })),
icon: ,
- cy: 'provider-edit'
+ cy: 'provider-edit',
},
{
- handleClick: () => setShowDialog({
- id: ID,
- title: `DELETE | #${ID} ${NAME}`,
- handleAccept: () => {
- setShowDialog(false)
+ handleClick: () =>
+ setShowDialog({
+ id: ID,
+ title: `DELETE | #${ID} ${NAME}`,
+ handleAccept: () => {
+ setShowDialog(false)
- return deleteProvider(ID)
- .then(() => enqueueSuccess(`Provider deleted - ID: ${ID}`))
- .then(() => fetchRequest(undefined, { reload: true }))
- }
- }),
+ return deleteProvider(ID)
+ .then(() =>
+ enqueueSuccess(`Provider deleted - ID: ${ID}`)
+ )
+ .then(() => fetchRequest(undefined, { reload: true }))
+ },
+ }),
icon: ,
color: 'error',
- cy: 'provider-delete'
- }
- ]
+ cy: 'provider-delete',
+ },
+ ],
})}
/>
)}
@@ -117,7 +123,7 @@ function Providers () {
request={() => getProvider(showDialog.id)}
dialogProps={{ fixedWidth: true, handleCancel, ...showDialog }}
>
- {fetchProps => }
+ {(fetchProps) => }
)}
diff --git a/src/fireedge/src/client/containers/Provisions/Create.js b/src/fireedge/src/client/containers/Provisions/Create.js
index ccd6158c5a..147657dc43 100644
--- a/src/fireedge/src/client/containers/Provisions/Create.js
+++ b/src/fireedge/src/client/containers/Provisions/Create.js
@@ -18,7 +18,12 @@ import { useEffect, useState, memo } from 'react'
import { Redirect, useHistory } from 'react-router'
import { NavArrowLeft as ArrowBackIcon } from 'iconoir-react'
-import { Container, LinearProgress, IconButton, Typography } from '@mui/material'
+import {
+ Container,
+ LinearProgress,
+ IconButton,
+ Typography,
+} from '@mui/material'
import makeStyles from '@mui/styles/makeStyles'
import { useFetch, useSocket } from 'client/hooks'
@@ -34,17 +39,17 @@ import { T } from 'client/constants'
const useStyles = makeStyles({
container: {
display: 'flex',
- flexDirection: 'column'
+ flexDirection: 'column',
},
title: {
marginBottom: '1em',
display: 'inline-flex',
alignItems: 'center',
- gap: '0.8em'
- }
+ gap: '0.8em',
+ },
})
-function ProvisionCreateForm () {
+function ProvisionCreateForm() {
const classes = useStyles()
const [uuid, setUuid] = useState(undefined)
@@ -54,7 +59,7 @@ function ProvisionCreateForm () {
const { getProviders } = useProviderApi()
const { data, fetchRequest, loading, error } = useFetch(getProviders)
- const onSubmit = async formData => {
+ const onSubmit = async (formData) => {
try {
const response = await createProvision(formData)
enqueueInfo('Creating provision')
@@ -78,7 +83,7 @@ function ProvisionCreateForm () {
}
return !data || loading ? (
-
+
) : (
@@ -93,10 +98,10 @@ const Title = memo(() => {
return (
diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/datastores.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/datastores.js
index 2fd56b554c..57657d0ed0 100644
--- a/src/fireedge/src/client/containers/Provisions/DialogInfo/datastores.js
+++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/datastores.js
@@ -26,16 +26,15 @@ import { DatastoreCard } from 'client/components/Cards'
const Datastores = memo(
({ hidden, data, reloading, refetchProvision, disableAllActions }) => {
- const {
- datastores = []
- } = data?.TEMPLATE?.BODY?.provision?.infrastructure
+ const { datastores = [] } = data?.TEMPLATE?.BODY?.provision?.infrastructure
const { enqueueSuccess } = useGeneralApi()
const { deleteDatastore } = useProvisionApi()
const { getDatastore } = useDatastoreApi()
const { data: list, fetchRequestAll, loading } = useFetchAll()
- const fetchDatastores = () => fetchRequestAll(datastores?.map(({ id }) => getDatastore(id)))
+ const fetchDatastores = () =>
+ fetchRequestAll(datastores?.map(({ id }) => getDatastore(id)))
useEffect(() => {
!hidden && !list && fetchDatastores()
@@ -50,20 +49,28 @@ const Datastores = memo(
list={list}
isLoading={!list && loading}
CardComponent={DatastoreCard}
- cardsProps={({ value: { ID } }) => !disableAllActions && ({
- actions: [{
- handleClick: () => deleteDatastore(ID)
- .then(refetchProvision)
- .then(() => enqueueSuccess(`Datastore deleted - ID: ${ID}`)),
- icon: ,
- cy: `provision-datastore-delete-${ID}`
- }]
- })}
+ cardsProps={({ value: { ID } }) =>
+ !disableAllActions && {
+ actions: [
+ {
+ handleClick: () =>
+ deleteDatastore(ID)
+ .then(refetchProvision)
+ .then(() =>
+ enqueueSuccess(`Datastore deleted - ID: ${ID}`)
+ ),
+ icon: ,
+ cy: `provision-datastore-delete-${ID}`,
+ },
+ ],
+ }
+ }
displayEmpty
breakpoints={{ xs: 12, md: 6 }}
/>
)
- }, (prev, next) =>
+ },
+ (prev, next) =>
prev.hidden === next.hidden && prev.reloading === next.reloading
)
@@ -72,7 +79,7 @@ Datastores.propTypes = {
hidden: PropTypes.bool,
refetchProvision: PropTypes.func,
reloading: PropTypes.bool,
- disableAllActions: PropTypes.bool
+ disableAllActions: PropTypes.bool,
}
Datastores.defaultProps = {
@@ -80,7 +87,7 @@ Datastores.defaultProps = {
hidden: false,
refetchProvision: () => undefined,
reloading: false,
- disableAllActions: false
+ disableAllActions: false,
}
Datastores.displayName = 'Datastores'
diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/hosts.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/hosts.js
index cba257cfa4..dbfcc7ae62 100644
--- a/src/fireedge/src/client/containers/Provisions/DialogInfo/hosts.js
+++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/hosts.js
@@ -26,16 +26,15 @@ import { HostCard } from 'client/components/Cards'
const Hosts = memo(
({ hidden, data, reloading, refetchProvision, disableAllActions }) => {
- const {
- hosts = []
- } = data?.TEMPLATE?.BODY?.provision?.infrastructure
+ const { hosts = [] } = data?.TEMPLATE?.BODY?.provision?.infrastructure
const { enqueueSuccess, enqueueInfo } = useGeneralApi()
const { configureHost, deleteHost } = useProvisionApi()
const { getHost } = useHostApi()
const { data: list, fetchRequestAll, loading } = useFetchAll()
- const fetchHosts = () => fetchRequestAll(hosts?.map(({ id }) => getHost(id)))
+ const fetchHosts = () =>
+ fetchRequestAll(hosts?.map(({ id }) => getHost(id)))
useEffect(() => {
!hidden && !list && fetchHosts()
@@ -50,37 +49,43 @@ const Hosts = memo(
list={list}
isLoading={!list && loading}
CardComponent={HostCard}
- cardsProps={({ value: { ID } }) => !disableAllActions && ({
- actions: [
- {
- handleClick: () => configureHost(ID)
- .then(() => enqueueInfo(`Configuring host - ID: ${ID}`))
- .then(refetchProvision),
- icon: ,
- cy: `provision-host-configure-${ID}`
- },
- {
- handleClick: () => deleteHost(ID)
- .then(refetchProvision)
- .then(() => enqueueSuccess(`Host deleted - ID: ${ID}`)),
- icon: ,
- cy: `provision-host-delete-${ID}`
- }
- ]
- })}
+ cardsProps={({ value: { ID } }) =>
+ !disableAllActions && {
+ actions: [
+ {
+ handleClick: () =>
+ configureHost(ID)
+ .then(() => enqueueInfo(`Configuring host - ID: ${ID}`))
+ .then(refetchProvision),
+ icon: ,
+ cy: `provision-host-configure-${ID}`,
+ },
+ {
+ handleClick: () =>
+ deleteHost(ID)
+ .then(refetchProvision)
+ .then(() => enqueueSuccess(`Host deleted - ID: ${ID}`)),
+ icon: ,
+ cy: `provision-host-delete-${ID}`,
+ },
+ ],
+ }
+ }
displayEmpty
breakpoints={{ xs: 12, md: 6 }}
/>
)
- }, (prev, next) =>
- prev.hidden === next.hidden && prev.reloading === next.reloading)
+ },
+ (prev, next) =>
+ prev.hidden === next.hidden && prev.reloading === next.reloading
+)
Hosts.propTypes = {
data: PropTypes.object.isRequired,
hidden: PropTypes.bool,
refetchProvision: PropTypes.func,
reloading: PropTypes.bool,
- disableAllActions: PropTypes.bool
+ disableAllActions: PropTypes.bool,
}
Hosts.defaultProps = {
@@ -88,7 +93,7 @@ Hosts.defaultProps = {
hidden: false,
refetchProvision: () => undefined,
reloading: false,
- disableAllActions: false
+ disableAllActions: false,
}
Hosts.displayName = 'Hosts'
diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/index.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/index.js
index 04a99d2214..a896484358 100644
--- a/src/fireedge/src/client/containers/Provisions/DialogInfo/index.js
+++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/index.js
@@ -23,7 +23,7 @@ import {
HardDrive as HostIcon,
Folder as DatastoreIcon,
NetworkAlt as NetworkIcon,
- Page as LogIcon
+ Page as LogIcon,
} from 'iconoir-react'
import InfoTab from 'client/containers/Provisions/DialogInfo/info'
@@ -37,54 +37,63 @@ const TABS = [
{ name: 'datastores', icon: DatastoreIcon, content: DatastoresTab },
{ name: 'networks', icon: NetworkIcon, content: NetworksTab },
{ name: 'hosts', icon: HostIcon, content: HostsTab },
- { name: 'log', icon: LogIcon, content: LogTab }
+ { name: 'log', icon: LogIcon, content: LogTab },
]
const DialogInfo = ({ disableAllActions, fetchProps }) => {
const [tabSelected, setTab] = useState(0)
const { data, fetchRequest, reloading } = fetchProps
- const renderTabs = useMemo(() => (
-
- setTab(tab)}
- >
- {TABS.map(({ name, icon: Icon }, idx) =>
- }
- value={idx}
- label={String(name).toUpperCase()}
- />
- )}
-
-
- ), [tabSelected])
+ const renderTabs = useMemo(
+ () => (
+
+ setTab(tab)}
+ >
+ {TABS.map(({ name, icon: Icon }, idx) => (
+ }
+ value={idx}
+ label={String(name).toUpperCase()}
+ />
+ ))}
+
+
+ ),
+ [tabSelected]
+ )
return (
<>
{renderTabs}
- {useMemo(() =>
- TABS.map(({ name, content: Content }, idx) => (
-
-
+ TABS.map(({ name, content: Content }, idx) => (
+ fetchRequest(undefined, { reload: true })}
- reloading={reloading}
- />
-
- )), [tabSelected, reloading])}
+ key={`tab-${name}`}
+ overflow="auto"
+ >
+
+ fetchRequest(undefined, { reload: true })
+ }
+ reloading={reloading}
+ />
+
+ )),
+ [tabSelected, reloading]
+ )}
>
)
}
@@ -94,8 +103,8 @@ DialogInfo.propTypes = {
fetchProps: PropTypes.shape({
data: PropTypes.object.isRequired,
fetchRequest: PropTypes.func,
- reloading: PropTypes.bool
- }).isRequired
+ reloading: PropTypes.bool,
+ }).isRequired,
}
DialogInfo.defaultProps = {
@@ -103,8 +112,8 @@ DialogInfo.defaultProps = {
fetchProps: {
data: {},
fetchRequest: undefined,
- reloading: false
- }
+ reloading: false,
+ },
}
export default DialogInfo
diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/info.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/info.js
index a55df57663..6f144a6bcf 100644
--- a/src/fireedge/src/client/containers/Provisions/DialogInfo/info.js
+++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/info.js
@@ -34,19 +34,20 @@ const Info = memo(({ data = {} }) => {
name,
provider: providerName,
start_time: time,
- provision: { infrastructure = {} }
+ provision: { infrastructure = {} },
} = TEMPLATE?.BODY
- const { id: clusterId = '', name: clusterName = '' } = infrastructure?.clusters?.[0] ?? {}
+ const { id: clusterId = '', name: clusterName = '' } =
+ infrastructure?.clusters?.[0] ?? {}
const stateInfo = PROVISIONS_STATES[state]
- const isChecked = checked =>
+ const isChecked = (checked) =>
checked === '1' ? :
return (
-
+
{Tr(T.Information)}
@@ -58,35 +59,38 @@ const Info = memo(({ data = {} }) => {
{Tr(T.Name)}
- {name}
+ {name}
{Tr(T.Description)}
- {description}
-
-
- {Tr(T.Provider)}
- {providerName}
-
-
- {Tr(T.Cluster)}
- {`${clusterId} - ${clusterName}`}
-
-
- {Tr(T.StartTime)}
-
- {new Date(time * 1000).toLocaleString()}
+
+ {description}
+
+ {Tr(T.Provider)}
+ {providerName}
+
+
+ {Tr(T.Cluster)}
+ {`${clusterId} - ${clusterName}`}
+
+
+ {Tr(T.StartTime)}
+ {new Date(time * 1000).toLocaleString()}
+
{Tr(T.State)}
-
+
-
+
{Tr(T.Permissions)}
@@ -115,7 +119,7 @@ const Info = memo(({ data = {} }) => {
-
+
{Tr(T.Ownership)}
@@ -137,11 +141,11 @@ const Info = memo(({ data = {} }) => {
})
Info.propTypes = {
- data: PropTypes.object.isRequired
+ data: PropTypes.object.isRequired,
}
Info.defaultProps = {
- data: undefined
+ data: undefined,
}
Info.displayName = 'Info'
diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/log.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/log.js
index f131262a43..af2f84ff31 100644
--- a/src/fireedge/src/client/containers/Provisions/DialogInfo/log.js
+++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/log.js
@@ -22,47 +22,59 @@ import { useFetch, useSocket } from 'client/hooks'
import { useProvisionApi } from 'client/features/One'
import DebugLog, { LogUtils } from 'client/components/DebugLog'
-const Log = memo(({ hidden, data: { ID } }) => {
- const { getProvisionSocket } = useSocket()
- const { getProvisionLog } = useProvisionApi()
+const Log = memo(
+ ({ hidden, data: { ID } }) => {
+ const { getProvisionSocket } = useSocket()
+ const { getProvisionLog } = useProvisionApi()
- const {
- data: { uuid = ID, log } = {},
- fetchRequest,
- loading
- } = useFetch(getProvisionLog)
+ const {
+ data: { uuid = ID, log } = {},
+ fetchRequest,
+ loading,
+ } = useFetch(getProvisionLog)
- useEffect(() => {
- (!log && !hidden) && fetchRequest(ID)
- }, [hidden])
+ useEffect(() => {
+ !log && !hidden && fetchRequest(ID)
+ }, [hidden])
- const parsedLog = useMemo(() =>
- log
- ?.map(entry => {
- try { return JSON.parse(entry) } catch { return entry }
- })
- ?.reduce(LogUtils.concatNewMessageToLog, {})
- , [loading])
+ const parsedLog = useMemo(
+ () =>
+ log
+ ?.map((entry) => {
+ try {
+ return JSON.parse(entry)
+ } catch {
+ return entry
+ }
+ })
+ ?.reduce(LogUtils.concatNewMessageToLog, {}),
+ [loading]
+ )
- return loading ? (
-
- ) : (
-
- )
-}, (prev, next) =>
- prev.hidden === next.hidden && prev.reloading === next.reloading
+ return loading ? (
+
+ ) : (
+
+ )
+ },
+ (prev, next) =>
+ prev.hidden === next.hidden && prev.reloading === next.reloading
)
Log.propTypes = {
data: PropTypes.object.isRequired,
hidden: PropTypes.bool,
- fetchRequest: PropTypes.func
+ fetchRequest: PropTypes.func,
}
Log.defaultProps = {
data: {},
hidden: false,
- fetchRequest: () => undefined
+ fetchRequest: () => undefined,
}
Log.displayName = 'Log'
diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js
index d6f60ee2da..32d5d981b5 100644
--- a/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js
+++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js
@@ -26,16 +26,15 @@ import { NetworkCard } from 'client/components/Cards'
const Networks = memo(
({ hidden, data, reloading, refetchProvision, disableAllActions }) => {
- const {
- networks = []
- } = data?.TEMPLATE?.BODY?.provision?.infrastructure
+ const { networks = [] } = data?.TEMPLATE?.BODY?.provision?.infrastructure
const { enqueueSuccess } = useGeneralApi()
const { deleteVNetwork } = useProvisionApi()
const { getVNetwork } = useVNetworkApi()
const { data: list, fetchRequestAll, loading } = useFetchAll()
- const fetchVNetworks = () => fetchRequestAll(networks?.map(({ id }) => getVNetwork(id)))
+ const fetchVNetworks = () =>
+ fetchRequestAll(networks?.map(({ id }) => getVNetwork(id)))
useEffect(() => {
!hidden && !list && fetchVNetworks()
@@ -50,20 +49,26 @@ const Networks = memo(
list={list}
isLoading={!list && loading}
CardComponent={NetworkCard}
- cardsProps={({ value: { ID } }) => !disableAllActions && ({
- actions: [{
- handleClick: () => deleteVNetwork(ID)
- .then(refetchProvision)
- .then(() => enqueueSuccess(`VNetwork deleted - ID: ${ID}`)),
- icon: ,
- cy: `provision-vnet-delete-${ID}`
- }]
- })}
+ cardsProps={({ value: { ID } }) =>
+ !disableAllActions && {
+ actions: [
+ {
+ handleClick: () =>
+ deleteVNetwork(ID)
+ .then(refetchProvision)
+ .then(() => enqueueSuccess(`VNetwork deleted - ID: ${ID}`)),
+ icon: ,
+ cy: `provision-vnet-delete-${ID}`,
+ },
+ ],
+ }
+ }
displayEmpty
breakpoints={{ xs: 12, md: 6 }}
/>
)
- }, (prev, next) =>
+ },
+ (prev, next) =>
prev.hidden === next.hidden && prev.reloading === next.reloading
)
@@ -72,7 +77,7 @@ Networks.propTypes = {
hidden: PropTypes.bool,
refetchProvision: PropTypes.func,
reloading: PropTypes.bool,
- disableAllActions: PropTypes.bool
+ disableAllActions: PropTypes.bool,
}
Networks.defaultProps = {
@@ -80,7 +85,7 @@ Networks.defaultProps = {
hidden: false,
refetchProvision: () => undefined,
reloading: false,
- disableAllActions: false
+ disableAllActions: false,
}
Networks.displayName = 'Networks'
diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/styles.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/styles.js
index 02f2e6ad0b..a025261137 100644
--- a/src/fireedge/src/client/containers/Provisions/DialogInfo/styles.js
+++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/styles.js
@@ -15,26 +15,26 @@
* ------------------------------------------------------------------------- */
import makeStyles from '@mui/styles/makeStyles'
-export default makeStyles(theme => ({
+export default makeStyles((theme) => ({
permissions: {
- marginBottom: theme.spacing(2)
+ marginBottom: theme.spacing(2),
},
list: {
'& p': {
...theme.typography.body2,
overflow: 'hidden',
- textOverflow: 'ellipsis'
+ textOverflow: 'ellipsis',
},
'&.w-50 p': {
- width: '50%'
+ width: '50%',
},
'&.w-25 p': {
- width: '25%'
- }
+ width: '25%',
+ },
},
title: {
'& p.bold': {
- fontWeight: theme.typography.fontWeightBold
- }
- }
+ fontWeight: theme.typography.fontWeightBold,
+ },
+ },
}))
diff --git a/src/fireedge/src/client/containers/Provisions/index.js b/src/fireedge/src/client/containers/Provisions/index.js
index 35905a0416..09bf7b4a22 100644
--- a/src/fireedge/src/client/containers/Provisions/index.js
+++ b/src/fireedge/src/client/containers/Provisions/index.js
@@ -35,7 +35,7 @@ import { DialogRequest } from 'client/components/Dialogs'
import DialogInfo from 'client/containers/Provisions/DialogInfo'
import { T } from 'client/constants'
-function Provisions () {
+function Provisions() {
const history = useHistory()
const [{ content, ...showDialog } = {}, setShowDialog] = useState()
const handleCloseDialog = () => setShowDialog()
@@ -43,21 +43,19 @@ function Provisions () {
const { enqueueInfo } = useGeneralApi()
const provisions = useProvision()
- const {
- getProvisions,
- getProvision,
- configureProvision,
- deleteProvision
- } = useProvisionApi()
+ const { getProvisions, getProvision, configureProvision, deleteProvision } =
+ useProvisionApi()
const { error, fetchRequest, loading, reloading } = useFetch(getProvisions)
const { result, handleChange } = useSearch({
list: provisions,
- listOptions: { shouldSort: true, keys: ['ID', 'NAME'] }
+ listOptions: { shouldSort: true, keys: ['ID', 'NAME'] },
})
- useEffect(() => { fetchRequest() }, [])
+ useEffect(() => {
+ fetchRequest()
+ }, [])
return (
@@ -66,11 +64,11 @@ function Provisions () {
reloadButtonProps={{
'data-cy': 'refresh-provision-list',
onClick: () => fetchRequest(undefined, { reload: true }),
- isSubmitting: Boolean(loading || reloading)
+ isSubmitting: Boolean(loading || reloading),
}}
addButtonProps={{
'data-cy': 'create-provision',
- onClick: () => history.push(PATH.PROVISIONS.CREATE)
+ onClick: () => history.push(PATH.PROVISIONS.CREATE),
}}
searchProps={{ handleChange }}
/>
@@ -84,50 +82,57 @@ function Provisions () {
gridProps={{ 'data-cy': 'provisions' }}
CardComponent={ProvisionCard}
cardsProps={({ value: { ID, NAME } }) => ({
- handleClick: () => setShowDialog({
- id: ID,
- title: `#${ID} ${NAME}`,
- content: props => createElement(DialogInfo, {
- ...props,
- displayName: 'DialogDetailProvision'
- })
- }),
+ handleClick: () =>
+ setShowDialog({
+ id: ID,
+ title: `#${ID} ${NAME}`,
+ content: (props) =>
+ createElement(DialogInfo, {
+ ...props,
+ displayName: 'DialogDetailProvision',
+ }),
+ }),
actions: [
{
- handleClick: () => configureProvision(ID)
- .then(() => enqueueInfo(`Configuring provision - ID: ${ID}`))
- .then(() => fetchRequest(undefined, { reload: true })),
+ handleClick: () =>
+ configureProvision(ID)
+ .then(() =>
+ enqueueInfo(`Configuring provision - ID: ${ID}`)
+ )
+ .then(() => fetchRequest(undefined, { reload: true })),
icon: ,
- cy: 'provision-configure'
- }
+ cy: 'provision-configure',
+ },
],
deleteAction: {
buttonProps: {
'data-cy': 'provision-delete',
icon: ,
- color: 'error'
+ color: 'error',
},
- options: [{
- dialogProps: {
- title: (
-
- )
+ options: [
+ {
+ dialogProps: {
+ title: (
+
+ ),
+ },
+ form: DeleteForm,
+ onSubmit: async (formData) => {
+ try {
+ await deleteProvision(ID, formData)
+ enqueueInfo(`Deleting provision - ID: ${ID}`)
+ } finally {
+ handleCloseDialog()
+ fetchRequest(undefined, { reload: true })
+ }
+ },
},
- form: DeleteForm,
- onSubmit: async formData => {
- try {
- await deleteProvision(ID, formData)
- enqueueInfo(`Deleting provision - ID: ${ID}`)
- } finally {
- handleCloseDialog()
- fetchRequest(undefined, { reload: true })
- }
- }
- }]
- }
+ ],
+ },
})}
/>
)}
@@ -140,10 +145,10 @@ function Provisions () {
fixedWidth: true,
fixedHeight: true,
handleCancel: handleCloseDialog,
- ...showDialog
+ ...showDialog,
}}
>
- {props => content(props)}
+ {(props) => content(props)}
)}
diff --git a/src/fireedge/src/client/containers/Settings/index.js b/src/fireedge/src/client/containers/Settings/index.js
index fdf34f0f42..4dd9d419cf 100644
--- a/src/fireedge/src/client/containers/Settings/index.js
+++ b/src/fireedge/src/client/containers/Settings/index.js
@@ -40,10 +40,10 @@ const Settings = () => {
const { handleSubmit, setError, reset, formState, ...methods } = useForm({
reValidateMode: 'onSubmit',
defaultValues: FORM_SCHEMA.cast(settings),
- resolver: yupResolver(FORM_SCHEMA)
+ resolver: yupResolver(FORM_SCHEMA),
})
- const onSubmit = async dataForm => {
+ const onSubmit = async (dataForm) => {
try {
const template = Helper.jsonToXml({ FIREEDGE: dataForm })
await updateUser(user.ID, { template }).then(getAuthUser)
@@ -54,31 +54,31 @@ const Settings = () => {
return (
-
+
-
+
DEFAULT_SCHEME),
- grid: { md: 12 }
+ grid: { md: 12 },
}
const LANGUAGES = {
@@ -43,7 +49,7 @@ const LANGUAGES = {
.trim()
.required()
.default(() => DEFAULT_LANGUAGE),
- grid: { md: 12 }
+ grid: { md: 12 },
}
const DISABLE_ANIMATIONS = {
@@ -53,7 +59,7 @@ const DISABLE_ANIMATIONS = {
validation: boolean()
.yesOrNo()
.default(() => false),
- grid: { md: 12 }
+ grid: { md: 12 },
}
export const FORM_FIELDS = [SCHEME, LANGUAGES, DISABLE_ANIMATIONS]
diff --git a/src/fireedge/src/client/containers/TestApi/ResponseForm.js b/src/fireedge/src/client/containers/TestApi/ResponseForm.js
index 8442c6f9ff..93f6132357 100644
--- a/src/fireedge/src/client/containers/TestApi/ResponseForm.js
+++ b/src/fireedge/src/client/containers/TestApi/ResponseForm.js
@@ -17,7 +17,15 @@ import { useMemo, SetStateAction, JSXElementConstructor } from 'react'
import { string, func, shape, object } from 'prop-types'
import { useForm, Controller } from 'react-hook-form'
-import { TextField, Grid, Typography, FormControlLabel, Checkbox, Autocomplete, Chip } from '@mui/material'
+import {
+ TextField,
+ Grid,
+ Typography,
+ FormControlLabel,
+ Checkbox,
+ Autocomplete,
+ Chip,
+} from '@mui/material'
import { SubmitButton } from 'client/components/FormControl'
import { RestClient, requestConfig } from 'client/utils'
@@ -33,16 +41,16 @@ import { RestClient, requestConfig } from 'client/utils'
*/
const ResponseForm = ({
handleChangeResponse,
- command: { name, httpMethod, params }
+ command: { name, httpMethod, params },
}) => {
const { control, handleSubmit, formState } = useForm()
const memoParams = useMemo(() => Object.entries(params), [name])
- const onSubmit = async dataForm => {
+ const onSubmit = async (dataForm) => {
try {
const config = requestConfig(dataForm, { name, httpMethod, params })
- const res = await RestClient.request(config) ?? {}
+ const res = (await RestClient.request(config)) ?? {}
handleChangeResponse(JSON.stringify(res, null, '\t'))
} catch (err) {
handleChangeResponse(JSON.stringify(err.data, null, '\t'))
@@ -53,9 +61,9 @@ const ResponseForm = ({
return (
<>
{name || 'Request'}
@@ -63,10 +71,10 @@ const ResponseForm = ({
{memoParams?.map(([paramName, { default: defaultValue }]) => {
const { message: errorMessage } = formState.errors[paramName] ?? {}
@@ -74,57 +82,63 @@ const ResponseForm = ({
return (
({
- boolean: onChange(e.target.checked)}
- />
- )}
- label={paramName}
- labelPlacement='end'
- />,
- object: onChange(newValue ?? '')}
- renderTags={(tags, getTagProps) =>
- tags.map((tag, index) => (
-
- ))
- }
- renderInput={(params) => (
-
+ ({
+ boolean: (
+ onChange(e.target.checked)}
+ />
+ }
label={paramName}
- color='secondary'
- error={Boolean(errorMessage)}
- helperText={errorMessage}
+ labelPlacement="end"
/>
- )}
- />
- }[typeof defaultValue] ?? (
-
- ))}
+ ),
+ object: (
+ onChange(newValue ?? '')}
+ renderTags={(tags, getTagProps) =>
+ tags.map((tag, index) => (
+
+ ))
+ }
+ renderInput={(params) => (
+
+ )}
+ />
+ ),
+ }[typeof defaultValue] ?? (
+
+ ))
+ }
control={control}
name={`${paramName}`}
defaultValue={defaultValue}
@@ -134,7 +148,7 @@ const ResponseForm = ({
})}
@@ -147,17 +161,17 @@ ResponseForm.propTypes = {
command: shape({
name: string.isRequired,
httpMethod: string.isRequired,
- params: object.isRequired
+ params: object.isRequired,
}).isRequired,
- handleChangeResponse: func.isRequired
+ handleChangeResponse: func.isRequired,
}
ResponseForm.defaultProps = {
command: {
name: '',
httpMethod: 'GET',
- params: {}
+ params: {},
},
- handleChangeResponse: () => undefined
+ handleChangeResponse: () => undefined,
}
export default ResponseForm
diff --git a/src/fireedge/src/client/containers/TestApi/index.js b/src/fireedge/src/client/containers/TestApi/index.js
index 21d45e0056..a607d84439 100644
--- a/src/fireedge/src/client/containers/TestApi/index.js
+++ b/src/fireedge/src/client/containers/TestApi/index.js
@@ -31,24 +31,24 @@ const COMMANDS = Object.keys(Commands)?.sort()
* @returns {JSXElementConstructor} - Component that allows you
* to fetch, resolve, and interact with OpenNebula API.
*/
-function TestApi () {
+function TestApi() {
const classes = testApiStyles()
const [name, setName] = useState(() => COMMANDS[0])
const [response, setResponse] = useState('')
const handleChangeCommand = (_, value) => setName(value)
- const handleChangeResponse = res => setResponse(res)
+ const handleChangeResponse = (res) => setResponse(res)
return (
-
+
COMMANDS, [])}
value={name}
onChange={handleChangeCommand}
@@ -64,7 +64,7 @@ function TestApi () {
)}
-
+
diff --git a/src/fireedge/src/client/containers/TestApi/styles.js b/src/fireedge/src/client/containers/TestApi/styles.js
index 74e53e6b7b..10091000fe 100644
--- a/src/fireedge/src/client/containers/TestApi/styles.js
+++ b/src/fireedge/src/client/containers/TestApi/styles.js
@@ -18,6 +18,6 @@ import makeStyles from '@mui/styles/makeStyles'
export default makeStyles({
root: {
minHeight: '100%',
- width: '100%'
- }
+ width: '100%',
+ },
})
diff --git a/src/fireedge/src/client/containers/TestForm/index.js b/src/fireedge/src/client/containers/TestForm/index.js
index 5eb1273ca7..6319df809d 100644
--- a/src/fireedge/src/client/containers/TestForm/index.js
+++ b/src/fireedge/src/client/containers/TestForm/index.js
@@ -25,30 +25,37 @@ import { FormWithSchema } from 'client/components/Forms'
* @returns {JSXElementConstructor}
* - Component that allows you to test a form and their components
*/
-function TestForm () {
- const fields = useMemo(() => [/* To add the fields validation */], [])
+function TestForm() {
+ const fields = useMemo(
+ () => [
+ /* To add the fields validation */
+ ],
+ []
+ )
const resolver = useMemo(() => object() /* To add the form schema */, [])
const methods = useForm({
mode: 'onSubmit',
defaultValues: resolver.default(),
- resolver: yupResolver(resolver, { isSubmit: true })
+ resolver: yupResolver(resolver, { isSubmit: true }),
})
- const onSubmit = values => {
+ const onSubmit = (values) => {
console.log({ values })
}
return (
-
-
+
+
- {'Submit'}
+
+ {'Submit'}
+
diff --git a/src/fireedge/src/client/containers/Users/Detail.js b/src/fireedge/src/client/containers/Users/Detail.js
index 9238103748..55cb5dbf62 100644
--- a/src/fireedge/src/client/containers/Users/Detail.js
+++ b/src/fireedge/src/client/containers/Users/Detail.js
@@ -19,19 +19,19 @@ import { Container, Box } from '@mui/material'
import UserTabs from 'client/components/Tabs/User'
-function UserDetail () {
+function UserDetail() {
const { id } = useParams()
if (Number.isNaN(+id)) {
- return
+ return
}
return (
diff --git a/src/fireedge/src/client/containers/Users/index.js b/src/fireedge/src/client/containers/Users/index.js
index ba005bdc78..6ad7e76724 100644
--- a/src/fireedge/src/client/containers/Users/index.js
+++ b/src/fireedge/src/client/containers/Users/index.js
@@ -19,14 +19,14 @@ import { Container, Box } from '@mui/material'
import { UsersTable } from 'client/components/Tables'
-function Users () {
+function Users() {
return (
diff --git a/src/fireedge/src/client/containers/VNetworkTemplates/index.js b/src/fireedge/src/client/containers/VNetworkTemplates/index.js
index b0b578dbe7..0292e2cf51 100644
--- a/src/fireedge/src/client/containers/VNetworkTemplates/index.js
+++ b/src/fireedge/src/client/containers/VNetworkTemplates/index.js
@@ -19,14 +19,14 @@ import { Container, Box } from '@mui/material'
import { VNetworkTemplatesTable } from 'client/components/Tables'
-function VNetworkTemplates () {
+function VNetworkTemplates() {
return (
diff --git a/src/fireedge/src/client/containers/VirtualMachines/Detail.js b/src/fireedge/src/client/containers/VirtualMachines/Detail.js
index 716061c035..f9f4595655 100644
--- a/src/fireedge/src/client/containers/VirtualMachines/Detail.js
+++ b/src/fireedge/src/client/containers/VirtualMachines/Detail.js
@@ -19,19 +19,19 @@ import { Container, Box } from '@mui/material'
import VmTabs from 'client/components/Tabs/Vm'
-function VirtualMachineDetail () {
+function VirtualMachineDetail() {
const { id } = useParams()
if (Number.isNaN(+id)) {
- return
+ return
}
return (
diff --git a/src/fireedge/src/client/containers/VirtualMachines/index.js b/src/fireedge/src/client/containers/VirtualMachines/index.js
index 9f2ebb08ce..2618ce171c 100644
--- a/src/fireedge/src/client/containers/VirtualMachines/index.js
+++ b/src/fireedge/src/client/containers/VirtualMachines/index.js
@@ -23,12 +23,12 @@ import VmTabs from 'client/components/Tabs/Vm'
import SplitPane from 'client/components/SplitPane'
import MultipleTags from 'client/components/MultipleTags'
-function VirtualMachines () {
+function VirtualMachines() {
const [selectedRows, onSelectedRowsChange] = useState(() => [])
const actions = VmActions()
return (
-
+
{selectedRows?.length > 0 && (
-
- {selectedRows?.length === 1
- ?
- :
+
+ {selectedRows?.length === 1 ? (
+
+ ) : (
+
(
- toggleRowSelected(false)}
- />
- ))}
+ tags={selectedRows?.map(
+ ({ original, id, toggleRowSelected }) => (
+ toggleRowSelected(false)}
+ />
+ )
+ )}
/>
- }
+ )}
)}
diff --git a/src/fireedge/src/client/containers/VirtualNetworks/index.js b/src/fireedge/src/client/containers/VirtualNetworks/index.js
index 4daa3aa4ec..7908103e8e 100644
--- a/src/fireedge/src/client/containers/VirtualNetworks/index.js
+++ b/src/fireedge/src/client/containers/VirtualNetworks/index.js
@@ -19,14 +19,14 @@ import { Container, Box } from '@mui/material'
import { VNetworksTable } from 'client/components/Tables'
-function VirtualNetworks () {
+function VirtualNetworks() {
return (
diff --git a/src/fireedge/src/client/containers/VirtualRouters/index.js b/src/fireedge/src/client/containers/VirtualRouters/index.js
index d5e2a89cd9..87ec337aeb 100644
--- a/src/fireedge/src/client/containers/VirtualRouters/index.js
+++ b/src/fireedge/src/client/containers/VirtualRouters/index.js
@@ -19,14 +19,14 @@ import { Container, Box } from '@mui/material'
import { VRoutersTable } from 'client/components/Tables'
-function VirtualRouters () {
+function VirtualRouters() {
return (
diff --git a/src/fireedge/src/client/containers/VmTemplates/Create.js b/src/fireedge/src/client/containers/VmTemplates/Create.js
index c8028a5d2a..b4e02e967e 100644
--- a/src/fireedge/src/client/containers/VmTemplates/Create.js
+++ b/src/fireedge/src/client/containers/VmTemplates/Create.js
@@ -28,14 +28,14 @@ import { isDevelopment } from 'client/utils'
*
* @returns {JSXElementConstructor} VM Template form
*/
-function CreateVmTemplate () {
+function CreateVmTemplate() {
const history = useHistory()
const { state: { ID: templateId, NAME } = {} } = useLocation()
const { enqueueSuccess } = useGeneralApi()
const { update, allocate } = useVmTemplateApi()
- const onSubmit = async template => {
+ const onSubmit = async (template) => {
try {
if (templateId === undefined) {
await allocate(template)
diff --git a/src/fireedge/src/client/containers/VmTemplates/Instantiate.js b/src/fireedge/src/client/containers/VmTemplates/Instantiate.js
index a8d8a2630a..f58c702e99 100644
--- a/src/fireedge/src/client/containers/VmTemplates/Instantiate.js
+++ b/src/fireedge/src/client/containers/VmTemplates/Instantiate.js
@@ -23,7 +23,7 @@ import { InstantiateForm } from 'client/components/Forms/VmTemplate'
import { PATH } from 'client/apps/sunstone/routesOne'
import { isDevelopment } from 'client/utils'
-function InstantiateVmTemplate () {
+function InstantiateVmTemplate() {
const history = useHistory()
const { state: template = {} } = useLocation()
const { ID: templateId } = template ?? {}
@@ -35,10 +35,12 @@ function InstantiateVmTemplate () {
try {
const { ID, NAME } = templateSelected
- await Promise.all(templates.map(template => instantiate(ID, template)))
+ await Promise.all(templates.map((template) => instantiate(ID, template)))
history.push(templateId ? PATH.TEMPLATE.VMS.LIST : PATH.INSTANCE.VMS.LIST)
- enqueueInfo(`VM Template instantiated x${templates.length} - #${ID} ${NAME}`)
+ enqueueInfo(
+ `VM Template instantiated x${templates.length} - #${ID} ${NAME}`
+ )
} catch (err) {
isDevelopment() && console.error(err)
}
diff --git a/src/fireedge/src/client/containers/VmTemplates/index.js b/src/fireedge/src/client/containers/VmTemplates/index.js
index 6d46216184..19f313ceca 100644
--- a/src/fireedge/src/client/containers/VmTemplates/index.js
+++ b/src/fireedge/src/client/containers/VmTemplates/index.js
@@ -23,12 +23,12 @@ import VmTemplateTabs from 'client/components/Tabs/VmTemplate'
import SplitPane from 'client/components/SplitPane'
import MultipleTags from 'client/components/MultipleTags'
-function VmTemplates () {
+function VmTemplates() {
const [selectedRows, onSelectedRowsChange] = useState(() => [])
const actions = VmTemplateActions()
return (
-
+
{selectedRows?.length > 0 && (
-
- {selectedRows?.length === 1
- ?
- :
+
+ {selectedRows?.length === 1 ? (
+
+ ) : (
+
(
- toggleRowSelected(false)}
- />
- ))}
+ tags={selectedRows?.map(
+ ({ original, id, toggleRowSelected }) => (
+ toggleRowSelected(false)}
+ />
+ )
+ )}
/>
- }
+ )}
)}
diff --git a/src/fireedge/src/client/containers/Zones/index.js b/src/fireedge/src/client/containers/Zones/index.js
index b9352a2f86..0cbd6e4aff 100644
--- a/src/fireedge/src/client/containers/Zones/index.js
+++ b/src/fireedge/src/client/containers/Zones/index.js
@@ -19,14 +19,14 @@ import { Container, Box } from '@mui/material'
import { ZonesTable } from 'client/components/Tables'
-function Zones () {
+function Zones() {
return (
diff --git a/src/fireedge/src/client/dev/_app.js b/src/fireedge/src/client/dev/_app.js
index 29341e39cf..03e89edd28 100644
--- a/src/fireedge/src/client/dev/_app.js
+++ b/src/fireedge/src/client/dev/_app.js
@@ -28,20 +28,22 @@ import { _APPS, APPS } from 'client/constants'
* @param {object} props - Props from server
* @returns {JSXElementConstructor} Returns App
*/
-const DevelopmentApp = props => {
+const DevelopmentApp = (props) => {
let appName = ''
if (isDevelopment() && !isBackend()) {
appName = window.location.pathname
.split(/\//gi)
- .filter(sub => sub?.length > 0)
- .find(resource => APPS.includes(resource))
+ .filter((sub) => sub?.length > 0)
+ .find((resource) => APPS.includes(resource))
}
- return {
- [_APPS.provision.name]: ,
- [_APPS.sunstone.name]:
- }[appName] ??
+ return (
+ {
+ [_APPS.provision.name]: ,
+ [_APPS.sunstone.name]: ,
+ }[appName] ??
+ )
}
DevelopmentApp.displayName = 'DevelopmentApp'
diff --git a/src/fireedge/src/client/features/Auth/actions.js b/src/fireedge/src/client/features/Auth/actions.js
index 105d864a10..4d077d0191 100644
--- a/src/fireedge/src/client/features/Auth/actions.js
+++ b/src/fireedge/src/client/features/Auth/actions.js
@@ -44,7 +44,7 @@ export const login = createAsyncThunk(
jwt: token,
user: { ID: id },
isOneAdmin,
- isLoginInProgress: !!token && !isOneAdmin
+ isLoginInProgress: !!token && !isOneAdmin,
}
} catch (error) {
const { message, data, statusText } = error
@@ -65,32 +65,37 @@ export const getUser = createAsyncThunk(
const userSettings = user?.TEMPLATE?.FIREEDGE ?? {}
const userGroupIds = [user?.GROUPS?.ID].flat()
- if (!groups.some(group => userGroupIds.includes(group?.ID))) {
+ if (!groups.some((group) => userGroupIds.includes(group?.ID))) {
await dispatch(getGroups())
}
// Merge user settings with the existing one
const settings = {
...auth?.settings,
- ...Object.entries(userSettings).reduce((res, [key, value]) =>
- ({ ...res, [String(key).toLowerCase()]: value })
- , {})
+ ...Object.entries(userSettings).reduce(
+ (res, [key, value]) => ({
+ ...res,
+ [String(key).toLowerCase()]: value,
+ }),
+ {}
+ ),
}
return { user, settings, isOneAdmin }
} catch (error) {
dispatch(logout(T.SessionExpired))
}
- }, {
+ },
+ {
condition: (_, { getState }) => {
const { isLoading } = getState().auth
return !isLoading
- }
+ },
}
)
-export const logout = createAction('logout', errorMessage => {
+export const logout = createAction('logout', (errorMessage) => {
removeStoreData([JWT_NAME])
return { error: errorMessage }
@@ -98,7 +103,7 @@ export const logout = createAction('logout', errorMessage => {
export const changeFilter = createAction(
'auth/change-filter',
- filterPool => ({ payload: { filterPool, isLoginInProgress: false } })
+ (filterPool) => ({ payload: { filterPool, isLoginInProgress: false } })
)
export const changeGroup = createAsyncThunk(
@@ -118,8 +123,8 @@ export const changeGroup = createAsyncThunk(
return {
user: {
...user,
- GID: group
- }
+ GID: group,
+ },
}
}
} catch (error) {
diff --git a/src/fireedge/src/client/features/Auth/hooks.js b/src/fireedge/src/client/features/Auth/hooks.js
index f678d7c98e..8c24dd90e5 100644
--- a/src/fireedge/src/client/features/Auth/hooks.js
+++ b/src/fireedge/src/client/features/Auth/hooks.js
@@ -26,14 +26,17 @@ import { name as oneSlice, RESOURCES } from 'client/features/One/slice'
import { RESOURCE_NAMES } from 'client/constants'
export const useAuth = () => {
- const auth = useSelector(state => state[authSlice], shallowEqual)
- const groups = useSelector(state => state[oneSlice][RESOURCES.group], shallowEqual)
+ const auth = useSelector((state) => state[authSlice], shallowEqual)
+ const groups = useSelector(
+ (state) => state[oneSlice][RESOURCES.group],
+ shallowEqual
+ )
const { user, jwt, view, views, isLoginInProgress } = auth
const userGroups = [user?.GROUPS?.ID]
.flat()
- .map(id => groups.find(({ ID }) => ID === id))
+ .map((id) => groups.find(({ ID }) => ID === id))
.filter(Boolean)
const isLogged = !!jwt && !!userGroups?.length && !isLoginInProgress
@@ -51,8 +54,8 @@ export const useAuth = () => {
* }} Returns view of resource
*/
const getResourceView = useCallback(
- resourceName => views?.[view]
- ?.find(({ resource_name: name }) => name === resourceName),
+ (resourceName) =>
+ views?.[view]?.find(({ resource_name: name }) => name === resourceName),
[view]
)
@@ -63,24 +66,22 @@ export const useAuthApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- login: user => unwrapDispatch(actions.login(user)),
+ login: (user) => unwrapDispatch(actions.login(user)),
getAuthUser: () => dispatch(actions.getUser()),
- changeGroup: data => unwrapDispatch(actions.changeGroup(data)),
+ changeGroup: (data) => unwrapDispatch(actions.changeGroup(data)),
logout: () => dispatch(actions.logout()),
getProviderConfig: () =>
unwrapDispatch(provisionActions.getProviderConfig()),
- getSunstoneViews: () =>
- unwrapDispatch(sunstoneActions.getSunstoneViews()),
+ getSunstoneViews: () => unwrapDispatch(sunstoneActions.getSunstoneViews()),
getSunstoneConfig: () =>
unwrapDispatch(sunstoneActions.getSunstoneConfig()),
- changeView: data =>
- dispatch(sunstoneActions.changeView(data))
+ changeView: (data) => dispatch(sunstoneActions.changeView(data)),
}
}
diff --git a/src/fireedge/src/client/features/Auth/services.js b/src/fireedge/src/client/features/Auth/services.js
index 1197585f62..d81038a906 100644
--- a/src/fireedge/src/client/features/Auth/services.js
+++ b/src/fireedge/src/client/features/Auth/services.js
@@ -16,7 +16,7 @@
import { httpCodes } from 'server/utils/constants'
import { RestClient } from 'client/utils'
-export const authService = ({
+export const authService = {
/**
* @param {object} data - User credentials
* @param {string} data.user - Username
@@ -26,8 +26,12 @@ export const authService = ({
* @returns {object} Response data from request
* @throws Fails when response isn't code 200
*/
- login: async data => {
- const res = await RestClient.request({ url: '/api/auth', data, method: 'POST' })
+ login: async (data) => {
+ const res = await RestClient.request({
+ url: '/api/auth',
+ data,
+ method: 'POST',
+ })
if (!res?.id || res?.id !== httpCodes.ok.id) {
if (res?.id === httpCodes.accepted.id) return res
@@ -79,5 +83,5 @@ export const authService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return res?.data ?? {}
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/Auth/slice.js b/src/fireedge/src/client/features/Auth/slice.js
index 00fc1b14f1..96c83ac2bd 100644
--- a/src/fireedge/src/client/features/Auth/slice.js
+++ b/src/fireedge/src/client/features/Auth/slice.js
@@ -15,10 +15,25 @@
* ------------------------------------------------------------------------- */
import { createSlice } from '@reduxjs/toolkit'
-import { login, getUser, logout, changeFilter, changeGroup } from 'client/features/Auth/actions'
+import {
+ login,
+ getUser,
+ logout,
+ changeFilter,
+ changeGroup,
+} from 'client/features/Auth/actions'
import { getProviderConfig } from 'client/features/Auth/provision'
-import { getSunstoneViews, getSunstoneConfig, changeView } from 'client/features/Auth/sunstone'
-import { JWT_NAME, FILTER_POOL, DEFAULT_SCHEME, DEFAULT_LANGUAGE } from 'client/constants'
+import {
+ getSunstoneViews,
+ getSunstoneConfig,
+ changeView,
+} from 'client/features/Auth/sunstone'
+import {
+ JWT_NAME,
+ FILTER_POOL,
+ DEFAULT_SCHEME,
+ DEFAULT_LANGUAGE,
+} from 'client/constants'
import { isBackend } from 'client/utils'
const initial = () => ({
@@ -33,16 +48,16 @@ const initial = () => ({
settings: {
scheme: DEFAULT_SCHEME,
lang: DEFAULT_LANGUAGE,
- disableanimations: 'NO'
+ disableanimations: 'NO',
},
isLoginInProgress: false,
- isLoading: false
+ isLoading: false,
})
const { name, actions, reducer } = createSlice({
name: 'auth',
- initialState: ({ ...initial(), firstRender: true }),
- extraReducers: builder => {
+ initialState: { ...initial(), firstRender: true },
+ extraReducers: (builder) => {
builder
.addMatcher(
({ type }) => type === logout.type,
@@ -60,18 +75,18 @@ const { name, actions, reducer } = createSlice({
// sunstone
getSunstoneViews.fulfilled.type,
getSunstoneConfig.fulfilled.type,
- changeView.type
+ changeView.type,
].includes(type)
},
(state, { payload }) => ({ ...state, ...payload })
)
.addMatcher(
({ type }) => type.startsWith('auth/') && type.endsWith('/pending'),
- state => ({ ...state, isLoading: true, error: null })
+ (state) => ({ ...state, isLoading: true, error: null })
)
.addMatcher(
({ type }) => type.startsWith('auth/') && type.endsWith('/fulfilled'),
- state => ({ ...state, isLoading: false, firstRender: false })
+ (state) => ({ ...state, isLoading: false, firstRender: false })
)
.addMatcher(
({ type }) => type.startsWith('auth/') && type.endsWith('/rejected'),
@@ -81,10 +96,10 @@ const { name, actions, reducer } = createSlice({
isLoginInProgress: false,
isLoading: false,
firstRender: false,
- jwt: null
+ jwt: null,
})
)
- }
+ },
})
export { name, actions, reducer }
diff --git a/src/fireedge/src/client/features/Auth/sunstone.js b/src/fireedge/src/client/features/Auth/sunstone.js
index abe500a1aa..2c78086917 100644
--- a/src/fireedge/src/client/features/Auth/sunstone.js
+++ b/src/fireedge/src/client/features/Auth/sunstone.js
@@ -30,7 +30,7 @@ export const getSunstoneViews = createAsyncThunk(
return {
views,
- view: Object.keys(views)[0]
+ view: Object.keys(views)[0],
}
} catch (error) {
error?.status === httpCodes.unauthorized.id &&
@@ -53,7 +53,6 @@ export const getSunstoneConfig = createAsyncThunk(
}
)
-export const changeView = createAction(
- 'sunstone/change-view',
- view => ({ payload: { view } })
-)
+export const changeView = createAction('sunstone/change-view', (view) => ({
+ payload: { view },
+}))
diff --git a/src/fireedge/src/client/features/General/hooks.js b/src/fireedge/src/client/features/General/hooks.js
index 554364612c..a59160ca2e 100644
--- a/src/fireedge/src/client/features/General/hooks.js
+++ b/src/fireedge/src/client/features/General/hooks.js
@@ -20,55 +20,55 @@ import * as actions from 'client/features/General/actions'
import { name as generalSlice } from 'client/features/General/slice'
import { generateKey } from 'client/utils'
-export const useGeneral = () => (
- useSelector(state => state[generalSlice], shallowEqual)
-)
+export const useGeneral = () =>
+ useSelector((state) => state[generalSlice], shallowEqual)
export const useGeneralApi = () => {
const dispatch = useDispatch()
return {
- fixMenu: isFixed => dispatch(actions.fixMenu(isFixed)),
- changeLoading: isLoading => dispatch(actions.changeLoading(isLoading)),
- changeTitle: title => dispatch(actions.changeTitle(title)),
- changeAppTitle: appTitle => dispatch(actions.changeAppTitle(appTitle)),
- changeZone: zone => dispatch(actions.changeZone(zone)),
+ fixMenu: (isFixed) => dispatch(actions.fixMenu(isFixed)),
+ changeLoading: (isLoading) => dispatch(actions.changeLoading(isLoading)),
+ changeTitle: (title) => dispatch(actions.changeTitle(title)),
+ changeAppTitle: (appTitle) => dispatch(actions.changeAppTitle(appTitle)),
+ changeZone: (zone) => dispatch(actions.changeZone(zone)),
// dismiss all if no key has been defined
- dismissSnackbar: key => dispatch(
- actions.dismissSnackbar({ key, dismissAll: !key })
- ),
- deleteSnackbar: key => dispatch(
- actions.deleteSnackbar({ key })
- ),
+ dismissSnackbar: (key) =>
+ dispatch(actions.dismissSnackbar({ key, dismissAll: !key })),
+ deleteSnackbar: (key) => dispatch(actions.deleteSnackbar({ key })),
- enqueueSnackbar: ({ message, options = {} } = {}) => dispatch(
- actions.enqueueSnackbar({
- key: generateKey(),
- message,
- options
- })
- ),
- enqueueSuccess: message => dispatch(
- actions.enqueueSnackbar({
- key: generateKey(),
- message,
- options: { variant: 'success' }
- })
- ),
- enqueueError: message => dispatch(
- actions.enqueueSnackbar({
- key: generateKey(),
- message,
- options: { variant: 'error' }
- })
- ),
- enqueueInfo: message => dispatch(
- actions.enqueueSnackbar({
- key: generateKey(),
- message,
- options: { variant: 'info' }
- })
- )
+ enqueueSnackbar: ({ message, options = {} } = {}) =>
+ dispatch(
+ actions.enqueueSnackbar({
+ key: generateKey(),
+ message,
+ options,
+ })
+ ),
+ enqueueSuccess: (message) =>
+ dispatch(
+ actions.enqueueSnackbar({
+ key: generateKey(),
+ message,
+ options: { variant: 'success' },
+ })
+ ),
+ enqueueError: (message) =>
+ dispatch(
+ actions.enqueueSnackbar({
+ key: generateKey(),
+ message,
+ options: { variant: 'error' },
+ })
+ ),
+ enqueueInfo: (message) =>
+ dispatch(
+ actions.enqueueSnackbar({
+ key: generateKey(),
+ message,
+ options: { variant: 'info' },
+ })
+ ),
}
}
diff --git a/src/fireedge/src/client/features/General/slice.js b/src/fireedge/src/client/features/General/slice.js
index 4103043eed..5177606821 100644
--- a/src/fireedge/src/client/features/General/slice.js
+++ b/src/fireedge/src/client/features/General/slice.js
@@ -28,13 +28,13 @@ const initial = {
isLoading: false,
isFixMenu: false,
- notifications: []
+ notifications: [],
}
const { name, reducer } = createSlice({
name: 'general',
initialState: initial,
- extraReducers: builder => {
+ extraReducers: (builder) => {
builder
/* UI ACTIONS */
.addCase(actions.fixMenu, (state, { payload }) => {
@@ -61,10 +61,7 @@ const { name, reducer } = createSlice({
return {
...state,
- notifications: [
- ...state.notifications,
- { key, options, message }
- ]
+ notifications: [...state.notifications, { key, options, message }],
}
})
.addCase(actions.dismissSnackbar, (state, { payload }) => {
@@ -72,11 +69,11 @@ const { name, reducer } = createSlice({
return {
...state,
- notifications: state.notifications.map(notification =>
+ notifications: state.notifications.map((notification) =>
dismissAll || notification.key !== key
? { ...notification, dismissed: true }
: { ...notification }
- )
+ ),
}
})
.addCase(actions.deleteSnackbar, (state, { payload }) => {
@@ -85,38 +82,43 @@ const { name, reducer } = createSlice({
return {
...state,
notifications: state.notifications.filter(
- notification => notification.key !== key
- )
+ (notification) => notification.key !== key
+ ),
}
})
/* REQUESTS API MATCHES */
- .addMatcher(({ type }) => type === logout.type, () => initial)
+ .addMatcher(
+ ({ type }) => type === logout.type,
+ () => initial
+ )
.addMatcher(
({ type }) => type.endsWith('/pending') && !type.includes('auth'),
- state => ({ ...state, isLoading: true })
+ (state) => ({ ...state, isLoading: true })
)
.addMatcher(
({ type }) => type.endsWith('/fulfilled') && !type.includes('auth'),
- state => ({ ...state, isLoading: false })
+ (state) => ({ ...state, isLoading: false })
)
.addMatcher(
({ type, meta }) =>
- !meta?.aborted && type.endsWith('/rejected') && !type.includes('auth'),
+ !meta?.aborted &&
+ type.endsWith('/rejected') &&
+ !type.includes('auth'),
(state, { payload }) => ({
...state,
isLoading: false,
notifications: [
...state.notifications,
- (payload?.length > 0 && {
+ payload?.length > 0 && {
key: generateKey(),
message: payload,
- options: { variant: 'error' }
- })
- ].filter(Boolean)
+ options: { variant: 'error' },
+ },
+ ].filter(Boolean),
})
)
- }
+ },
})
export { name, reducer }
diff --git a/src/fireedge/src/client/features/One/application/actions.js b/src/fireedge/src/client/features/One/application/actions.js
index 9974d4256b..11d4a0fc71 100644
--- a/src/fireedge/src/client/features/One/application/actions.js
+++ b/src/fireedge/src/client/features/One/application/actions.js
@@ -28,5 +28,5 @@ export const getApplication = createAction(
export const getApplications = createAction(
`${SERVICE_APPLICATION}/pool`,
applicationService.getApplications,
- response => ({ [RESOURCES.document[100]]: response })
+ (response) => ({ [RESOURCES.document[100]]: response })
)
diff --git a/src/fireedge/src/client/features/One/application/hooks.js b/src/fireedge/src/client/features/One/application/hooks.js
index 56382b4762..0dbc4ed599 100644
--- a/src/fireedge/src/client/features/One/application/hooks.js
+++ b/src/fireedge/src/client/features/One/application/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/application/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useApplication = () => (
- useSelector(state => state[name]?.[RESOURCES.document[100]] ?? [])
-)
+export const useApplication = () =>
+ useSelector((state) => state[name]?.[RESOURCES.document[100]] ?? [])
export const useApplicationApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getApplication: id => unwrapDispatch(actions.getApplication({ id })),
- getApplications: () => unwrapDispatch(actions.getApplications())
+ getApplication: (id) => unwrapDispatch(actions.getApplication({ id })),
+ getApplications: () => unwrapDispatch(actions.getApplications()),
}
}
diff --git a/src/fireedge/src/client/features/One/application/services.js b/src/fireedge/src/client/features/One/application/services.js
index 405ba574cb..60f95ff84b 100644
--- a/src/fireedge/src/client/features/One/application/services.js
+++ b/src/fireedge/src/client/features/One/application/services.js
@@ -17,7 +17,7 @@ import { SERVICE } from 'server/routes/api/oneflow/string-routes'
import { httpCodes } from 'server/utils/constants'
import { RestClient } from 'client/utils'
-export const applicationService = ({
+export const applicationService = {
/**
* Retrieves information for the service.
*
@@ -28,7 +28,7 @@ export const applicationService = ({
*/
getApplication: async ({ id }) => {
const res = await RestClient.request({
- url: `/api/${SERVICE}/list/${id}`
+ url: `/api/${SERVICE}/list/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -44,11 +44,11 @@ export const applicationService = ({
*/
getApplications: async () => {
const res = await RestClient.request({
- url: `/api/${SERVICE}/list`
+ url: `/api/${SERVICE}/list`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.DOCUMENT_POOL?.DOCUMENT ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/applicationTemplate/actions.js b/src/fireedge/src/client/features/One/applicationTemplate/actions.js
index 64ba9c44ed..d42583f35c 100644
--- a/src/fireedge/src/client/features/One/applicationTemplate/actions.js
+++ b/src/fireedge/src/client/features/One/applicationTemplate/actions.js
@@ -28,7 +28,7 @@ export const getApplicationTemplate = createAction(
export const getApplicationsTemplates = createAction(
`${SERVICE_TEMPLATE}/pool`,
applicationTemplateService.getApplicationsTemplates,
- response => ({ [RESOURCES.document[101]]: response })
+ (response) => ({ [RESOURCES.document[101]]: response })
)
export const createApplicationTemplate = createAction(
diff --git a/src/fireedge/src/client/features/One/applicationTemplate/hooks.js b/src/fireedge/src/client/features/One/applicationTemplate/hooks.js
index 6757fe59b6..dacc553046 100644
--- a/src/fireedge/src/client/features/One/applicationTemplate/hooks.js
+++ b/src/fireedge/src/client/features/One/applicationTemplate/hooks.js
@@ -21,27 +21,29 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/applicationTemplate/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useApplicationTemplate = () => (
- useSelector(state => state[name]?.[RESOURCES.document[101]] ?? [])
-)
+export const useApplicationTemplate = () =>
+ useSelector((state) => state[name]?.[RESOURCES.document[101]] ?? [])
export const useApplicationTemplateApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getApplicationTemplate: id => unwrapDispatch(actions.getApplicationTemplate({ id })),
- getApplicationsTemplates: () => unwrapDispatch(actions.getApplicationsTemplates()),
- createApplicationTemplate: data => unwrapDispatch(actions.createApplicationTemplate({ data })),
+ getApplicationTemplate: (id) =>
+ unwrapDispatch(actions.getApplicationTemplate({ id })),
+ getApplicationsTemplates: () =>
+ unwrapDispatch(actions.getApplicationsTemplates()),
+ createApplicationTemplate: (data) =>
+ unwrapDispatch(actions.createApplicationTemplate({ data })),
updateApplicationTemplate: (id, data) =>
unwrapDispatch(actions.updateApplicationTemplate({ id, data })),
instantiateApplicationTemplate: (id, data) =>
- unwrapDispatch(actions.instantiateApplicationTemplate({ id, data }))
+ unwrapDispatch(actions.instantiateApplicationTemplate({ id, data })),
}
}
diff --git a/src/fireedge/src/client/features/One/applicationTemplate/services.js b/src/fireedge/src/client/features/One/applicationTemplate/services.js
index 31a65b4286..9a40cc5cce 100644
--- a/src/fireedge/src/client/features/One/applicationTemplate/services.js
+++ b/src/fireedge/src/client/features/One/applicationTemplate/services.js
@@ -19,7 +19,7 @@ import { RestClient } from 'client/utils'
const { POST, PUT } = defaults?.httpMethod || {}
-export const applicationTemplateService = ({
+export const applicationTemplateService = {
/**
* Retrieves information for the service template.
*
@@ -30,7 +30,7 @@ export const applicationTemplateService = ({
*/
getApplicationTemplate: ({ id }) => {
const res = RestClient.request({
- url: `/api/${SERVICE_TEMPLATE}/list/${id}`
+ url: `/api/${SERVICE_TEMPLATE}/list/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -44,7 +44,7 @@ export const applicationTemplateService = ({
*/
getApplicationsTemplates: async () => {
const res = await RestClient.request({
- url: `/api/${SERVICE_TEMPLATE}/list`
+ url: `/api/${SERVICE_TEMPLATE}/list`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -64,7 +64,7 @@ export const applicationTemplateService = ({
const res = await RestClient.request({
data,
method: POST,
- url: `/api/${SERVICE_TEMPLATE}/create`
+ url: `/api/${SERVICE_TEMPLATE}/create`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -85,7 +85,7 @@ export const applicationTemplateService = ({
const res = RestClient.request({
data,
method: PUT,
- url: `/api/${SERVICE_TEMPLATE}/update/${id}`
+ url: `/api/${SERVICE_TEMPLATE}/update/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -107,15 +107,15 @@ export const applicationTemplateService = ({
data: {
action: {
perform: 'instantiate',
- params: { merge_template: data }
- }
+ params: { merge_template: data },
+ },
},
method: PUT,
- url: `/api/${SERVICE_TEMPLATE}/action/${id}`
+ url: `/api/${SERVICE_TEMPLATE}/action/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return res?.data ?? {}
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/cluster/actions.js b/src/fireedge/src/client/features/One/cluster/actions.js
index 9eb250e328..6088b09e25 100644
--- a/src/fireedge/src/client/features/One/cluster/actions.js
+++ b/src/fireedge/src/client/features/One/cluster/actions.js
@@ -28,5 +28,5 @@ export const getCluster = createAction(
export const getClusters = createAction(
`${CLUSTER}/pool`,
clusterService.getClusters,
- response => ({ [RESOURCES.cluster]: response })
+ (response) => ({ [RESOURCES.cluster]: response })
)
diff --git a/src/fireedge/src/client/features/One/cluster/hooks.js b/src/fireedge/src/client/features/One/cluster/hooks.js
index 1ac29b8654..6fd2396f76 100644
--- a/src/fireedge/src/client/features/One/cluster/hooks.js
+++ b/src/fireedge/src/client/features/One/cluster/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/cluster/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useCluster = () => (
- useSelector(state => state[name]?.[RESOURCES.cluster] ?? [])
-)
+export const useCluster = () =>
+ useSelector((state) => state[name]?.[RESOURCES.cluster] ?? [])
export const useClusterApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getCluster: id => unwrapDispatch(actions.getCluster({ id })),
- getClusters: () => unwrapDispatch(actions.getClusters())
+ getCluster: (id) => unwrapDispatch(actions.getCluster({ id })),
+ getClusters: () => unwrapDispatch(actions.getClusters()),
}
}
diff --git a/src/fireedge/src/client/features/One/cluster/services.js b/src/fireedge/src/client/features/One/cluster/services.js
index 11e3001827..7e00a9514f 100644
--- a/src/fireedge/src/client/features/One/cluster/services.js
+++ b/src/fireedge/src/client/features/One/cluster/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/cluster'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const clusterService = ({
+export const clusterService = {
/**
* Retrieves information for the cluster.
*
@@ -54,5 +54,5 @@ export const clusterService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.CLUSTER_POOL?.CLUSTER ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/datastore/actions.js b/src/fireedge/src/client/features/One/datastore/actions.js
index 165befbfcc..3ac31fec46 100644
--- a/src/fireedge/src/client/features/One/datastore/actions.js
+++ b/src/fireedge/src/client/features/One/datastore/actions.js
@@ -28,5 +28,5 @@ export const getDatastore = createAction(
export const getDatastores = createAction(
`${DATASTORE}/pool`,
datastoreService.getDatastores,
- response => ({ [RESOURCES.datastore]: response })
+ (response) => ({ [RESOURCES.datastore]: response })
)
diff --git a/src/fireedge/src/client/features/One/datastore/hooks.js b/src/fireedge/src/client/features/One/datastore/hooks.js
index 84dbc4d393..b22f59aeb5 100644
--- a/src/fireedge/src/client/features/One/datastore/hooks.js
+++ b/src/fireedge/src/client/features/One/datastore/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/datastore/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useDatastore = () => (
- useSelector(state => state[name]?.[RESOURCES.datastore] ?? [])
-)
+export const useDatastore = () =>
+ useSelector((state) => state[name]?.[RESOURCES.datastore] ?? [])
export const useDatastoreApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getDatastore: id => unwrapDispatch(actions.getDatastore({ id })),
- getDatastores: options => unwrapDispatch(actions.getDatastores(options))
+ getDatastore: (id) => unwrapDispatch(actions.getDatastore({ id })),
+ getDatastores: (options) => unwrapDispatch(actions.getDatastores(options)),
}
}
diff --git a/src/fireedge/src/client/features/One/datastore/services.js b/src/fireedge/src/client/features/One/datastore/services.js
index ae664bcde0..7ab0ebecd0 100644
--- a/src/fireedge/src/client/features/One/datastore/services.js
+++ b/src/fireedge/src/client/features/One/datastore/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/datastore'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const datastoreService = ({
+export const datastoreService = {
/**
* Retrieves information for the datastore.
*
@@ -54,5 +54,5 @@ export const datastoreService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.DATASTORE_POOL?.DATASTORE ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/group/actions.js b/src/fireedge/src/client/features/One/group/actions.js
index 3d07d83591..a0417ee959 100644
--- a/src/fireedge/src/client/features/One/group/actions.js
+++ b/src/fireedge/src/client/features/One/group/actions.js
@@ -20,13 +20,10 @@ import { RESOURCES } from 'client/features/One/slice'
/** @see {@link RESOURCES.group} */
const GROUP = 'group'
-export const getGroup = createAction(
- `${GROUP}/detail`,
- groupService.getGroup
-)
+export const getGroup = createAction(`${GROUP}/detail`, groupService.getGroup)
export const getGroups = createAction(
`${GROUP}/pool`,
groupService.getGroups,
- response => ({ [RESOURCES.group]: response })
+ (response) => ({ [RESOURCES.group]: response })
)
diff --git a/src/fireedge/src/client/features/One/group/hooks.js b/src/fireedge/src/client/features/One/group/hooks.js
index 5d2caf1590..290cacc133 100644
--- a/src/fireedge/src/client/features/One/group/hooks.js
+++ b/src/fireedge/src/client/features/One/group/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/group/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useGroup = () => (
- useSelector(state => state[name]?.[RESOURCES.group] ?? [])
-)
+export const useGroup = () =>
+ useSelector((state) => state[name]?.[RESOURCES.group] ?? [])
export const useGroupApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getGroup: id => unwrapDispatch(actions.getGroup({ id })),
- getGroups: () => unwrapDispatch(actions.getGroups())
+ getGroup: (id) => unwrapDispatch(actions.getGroup({ id })),
+ getGroups: () => unwrapDispatch(actions.getGroups()),
}
}
diff --git a/src/fireedge/src/client/features/One/group/services.js b/src/fireedge/src/client/features/One/group/services.js
index 968f6a648d..3038d953ff 100644
--- a/src/fireedge/src/client/features/One/group/services.js
+++ b/src/fireedge/src/client/features/One/group/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/group'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const groupService = ({
+export const groupService = {
/**
* Retrieves information for the group.
*
@@ -54,5 +54,5 @@ export const groupService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.GROUP_POOL?.GROUP ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/hooks.js b/src/fireedge/src/client/features/One/hooks.js
index 1a7b812444..d94a1b1dc1 100644
--- a/src/fireedge/src/client/features/One/hooks.js
+++ b/src/fireedge/src/client/features/One/hooks.js
@@ -17,9 +17,7 @@
import { useSelector, shallowEqual } from 'react-redux'
import { name } from 'client/features/One/slice'
-export const useOne = () => (
- useSelector(state => state[name], shallowEqual)
-)
+export const useOne = () => useSelector((state) => state[name], shallowEqual)
export * from 'client/features/One/application/hooks'
export * from 'client/features/One/applicationTemplate/hooks'
diff --git a/src/fireedge/src/client/features/One/host/actions.js b/src/fireedge/src/client/features/One/host/actions.js
index ac34b9d73c..826d9e30f8 100644
--- a/src/fireedge/src/client/features/One/host/actions.js
+++ b/src/fireedge/src/client/features/One/host/actions.js
@@ -20,13 +20,10 @@ import { RESOURCES } from 'client/features/One/slice'
/** @see {@link RESOURCES.host} */
const HOST = 'host'
-export const getHost = createAction(
- `${HOST}/detail`,
- hostService.getHost
-)
+export const getHost = createAction(`${HOST}/detail`, hostService.getHost)
export const getHosts = createAction(
`${HOST}/pool`,
hostService.getHosts,
- response => ({ [RESOURCES.host]: response })
+ (response) => ({ [RESOURCES.host]: response })
)
diff --git a/src/fireedge/src/client/features/One/host/hooks.js b/src/fireedge/src/client/features/One/host/hooks.js
index 435e6d926f..14b32795fa 100644
--- a/src/fireedge/src/client/features/One/host/hooks.js
+++ b/src/fireedge/src/client/features/One/host/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/host/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useHost = () => (
- useSelector(state => state[name]?.[RESOURCES.host])
-)
+export const useHost = () =>
+ useSelector((state) => state[name]?.[RESOURCES.host])
export const useHostApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getHost: id => unwrapDispatch(actions.getHost({ id })),
- getHosts: options => unwrapDispatch(actions.getHosts(options))
+ getHost: (id) => unwrapDispatch(actions.getHost({ id })),
+ getHosts: (options) => unwrapDispatch(actions.getHosts(options)),
}
}
diff --git a/src/fireedge/src/client/features/One/host/services.js b/src/fireedge/src/client/features/One/host/services.js
index 2f7f95367c..2231585f70 100644
--- a/src/fireedge/src/client/features/One/host/services.js
+++ b/src/fireedge/src/client/features/One/host/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/host'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const hostService = ({
+export const hostService = {
/**
* Retrieves information for the host.
*
@@ -54,5 +54,5 @@ export const hostService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.HOST_POOL?.HOST ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/image/actions.js b/src/fireedge/src/client/features/One/image/actions.js
index b17bad92cd..a6d63ef559 100644
--- a/src/fireedge/src/client/features/One/image/actions.js
+++ b/src/fireedge/src/client/features/One/image/actions.js
@@ -20,13 +20,10 @@ import { RESOURCES } from 'client/features/One/slice'
/** @see {@link RESOURCES.image} */
const IMAGE = 'image'
-export const getImage = createAction(
- `${IMAGE}/detail`,
- imageService.getImage
-)
+export const getImage = createAction(`${IMAGE}/detail`, imageService.getImage)
export const getImages = createAction(
`${IMAGE}/pool`,
imageService.getImages,
- response => ({ [RESOURCES.image]: response })
+ (response) => ({ [RESOURCES.image]: response })
)
diff --git a/src/fireedge/src/client/features/One/image/hooks.js b/src/fireedge/src/client/features/One/image/hooks.js
index 3728b2606a..f7e6eb4e47 100644
--- a/src/fireedge/src/client/features/One/image/hooks.js
+++ b/src/fireedge/src/client/features/One/image/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/image/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useImage = () => (
- useSelector(state => state[name]?.[RESOURCES.image] ?? [])
-)
+export const useImage = () =>
+ useSelector((state) => state[name]?.[RESOURCES.image] ?? [])
export const useImageApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getImage: id => unwrapDispatch(actions.getImage({ id })),
- getImages: () => unwrapDispatch(actions.getImages())
+ getImage: (id) => unwrapDispatch(actions.getImage({ id })),
+ getImages: () => unwrapDispatch(actions.getImages()),
}
}
diff --git a/src/fireedge/src/client/features/One/image/services.js b/src/fireedge/src/client/features/One/image/services.js
index 218738e38a..d152df92e5 100644
--- a/src/fireedge/src/client/features/One/image/services.js
+++ b/src/fireedge/src/client/features/One/image/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/image'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const imageService = ({
+export const imageService = {
/**
* Retrieves information for the image.
*
@@ -59,5 +59,5 @@ export const imageService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.IMAGE_POOL?.IMAGE ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/marketplace/actions.js b/src/fireedge/src/client/features/One/marketplace/actions.js
index 9cd708bec0..063824d19f 100644
--- a/src/fireedge/src/client/features/One/marketplace/actions.js
+++ b/src/fireedge/src/client/features/One/marketplace/actions.js
@@ -28,5 +28,5 @@ export const getMarketplace = createAction(
export const getMarketplaces = createAction(
`${MARKETPLACE}/pool`,
marketplaceService.getMarketplaces,
- response => ({ [RESOURCES.marketplace]: response })
+ (response) => ({ [RESOURCES.marketplace]: response })
)
diff --git a/src/fireedge/src/client/features/One/marketplace/hooks.js b/src/fireedge/src/client/features/One/marketplace/hooks.js
index e238619c9e..357acb3b3a 100644
--- a/src/fireedge/src/client/features/One/marketplace/hooks.js
+++ b/src/fireedge/src/client/features/One/marketplace/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/marketplace/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useMarketplace = () => (
- useSelector(state => state[name]?.[RESOURCES.marketplace] ?? [])
-)
+export const useMarketplace = () =>
+ useSelector((state) => state[name]?.[RESOURCES.marketplace] ?? [])
export const useMarketplaceApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getMarketplace: id => unwrapDispatch(actions.getMarketplace({ id })),
- getMarketplaces: () => unwrapDispatch(actions.getMarketplaces())
+ getMarketplace: (id) => unwrapDispatch(actions.getMarketplace({ id })),
+ getMarketplaces: () => unwrapDispatch(actions.getMarketplaces()),
}
}
diff --git a/src/fireedge/src/client/features/One/marketplace/services.js b/src/fireedge/src/client/features/One/marketplace/services.js
index 9ce2af3739..5b18015e47 100644
--- a/src/fireedge/src/client/features/One/marketplace/services.js
+++ b/src/fireedge/src/client/features/One/marketplace/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/market'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const marketplaceService = ({
+export const marketplaceService = {
/**
* Retrieves information for the marketplace.
*
@@ -54,5 +54,5 @@ export const marketplaceService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.MARKETPLACE_POOL?.MARKETPLACE ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/marketplaceApp/actions.js b/src/fireedge/src/client/features/One/marketplaceApp/actions.js
index 1b9d290636..70a1753c15 100644
--- a/src/fireedge/src/client/features/One/marketplaceApp/actions.js
+++ b/src/fireedge/src/client/features/One/marketplaceApp/actions.js
@@ -28,7 +28,10 @@ export const getMarketplaceApp = createAction(
export const getMarketplaceApps = createAction(
`${APP}/pool`,
marketplaceAppService.getMarketplaceApps,
- response => ({ [RESOURCES.app]: response })
+ (response) => ({ [RESOURCES.app]: response })
)
-export const exportApp = createAction(`${APP}/export`, marketplaceAppService.export)
+export const exportApp = createAction(
+ `${APP}/export`,
+ marketplaceAppService.export
+)
diff --git a/src/fireedge/src/client/features/One/marketplaceApp/hooks.js b/src/fireedge/src/client/features/One/marketplaceApp/hooks.js
index 50c345e0af..5184d82c26 100644
--- a/src/fireedge/src/client/features/One/marketplaceApp/hooks.js
+++ b/src/fireedge/src/client/features/One/marketplaceApp/hooks.js
@@ -21,21 +21,21 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/marketplaceApp/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useMarketplaceApp = () => (
- useSelector(state => state[name]?.[RESOURCES.app])
-)
+export const useMarketplaceApp = () =>
+ useSelector((state) => state[name]?.[RESOURCES.app])
export const useMarketplaceAppApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getMarketplaceApp: id => unwrapDispatch(actions.getMarketplaceApp({ id })),
+ getMarketplaceApp: (id) =>
+ unwrapDispatch(actions.getMarketplaceApp({ id })),
getMarketplaceApps: () => unwrapDispatch(actions.getMarketplaceApps()),
- exportApp: (id, data) => unwrapDispatch(actions.exportApp({ id, ...data }))
+ exportApp: (id, data) => unwrapDispatch(actions.exportApp({ id, ...data })),
}
}
diff --git a/src/fireedge/src/client/features/One/marketplaceApp/services.js b/src/fireedge/src/client/features/One/marketplaceApp/services.js
index 952e592ca6..c441351f17 100644
--- a/src/fireedge/src/client/features/One/marketplaceApp/services.js
+++ b/src/fireedge/src/client/features/One/marketplaceApp/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/marketapp'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const marketplaceAppService = ({
+export const marketplaceAppService = {
/**
* Retrieves information for the marketplace app.
*
@@ -80,11 +80,11 @@ export const marketplaceAppService = ({
const res = await RestClient.request({
url: `/api/marketapp/export/${id}`,
method: 'POST',
- data
+ data,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res?.data
return res?.data
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/provider/actions.js b/src/fireedge/src/client/features/One/provider/actions.js
index 070526c4d5..97f8d898d5 100644
--- a/src/fireedge/src/client/features/One/provider/actions.js
+++ b/src/fireedge/src/client/features/One/provider/actions.js
@@ -22,10 +22,22 @@ export const getProvider = createAction('provider', providerService.getProvider)
export const getProviders = createAction(
'provider/pool',
providerService.getProviders,
- res => ({ [RESOURCES.document[102]]: res })
+ (res) => ({ [RESOURCES.document[102]]: res })
)
-export const getProviderConnection = createAction('provider', providerService.getProviderConnection)
-export const createProvider = createAction('provider/create', providerService.createProvider)
-export const updateProvider = createAction('provider/update', providerService.updateProvider)
-export const deleteProvider = createAction('provider/delete', providerService.deleteProvider)
+export const getProviderConnection = createAction(
+ 'provider',
+ providerService.getProviderConnection
+)
+export const createProvider = createAction(
+ 'provider/create',
+ providerService.createProvider
+)
+export const updateProvider = createAction(
+ 'provider/update',
+ providerService.updateProvider
+)
+export const deleteProvider = createAction(
+ 'provider/delete',
+ providerService.deleteProvider
+)
diff --git a/src/fireedge/src/client/features/One/provider/hooks.js b/src/fireedge/src/client/features/One/provider/hooks.js
index 3e0e52ddf3..6dc5861686 100644
--- a/src/fireedge/src/client/features/One/provider/hooks.js
+++ b/src/fireedge/src/client/features/One/provider/hooks.js
@@ -21,24 +21,25 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/provider/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useProvider = () => (
- useSelector(state => state[name]?.[RESOURCES.document[102]])
-)
+export const useProvider = () =>
+ useSelector((state) => state[name]?.[RESOURCES.document[102]])
export const useProviderApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getProvider: id => unwrapDispatch(actions.getProvider({ id })),
+ getProvider: (id) => unwrapDispatch(actions.getProvider({ id })),
getProviders: () => dispatch(actions.getProviders()),
- getProviderConnection: id => unwrapDispatch(actions.getProviderConnection({ id })),
- createProvider: data => unwrapDispatch(actions.createProvider({ data })),
- updateProvider: (id, data) => unwrapDispatch(actions.updateProvider({ id, data })),
- deleteProvider: id => unwrapDispatch(actions.deleteProvider({ id }))
+ getProviderConnection: (id) =>
+ unwrapDispatch(actions.getProviderConnection({ id })),
+ createProvider: (data) => unwrapDispatch(actions.createProvider({ data })),
+ updateProvider: (id, data) =>
+ unwrapDispatch(actions.updateProvider({ id, data })),
+ deleteProvider: (id) => unwrapDispatch(actions.deleteProvider({ id })),
}
}
diff --git a/src/fireedge/src/client/features/One/provider/services.js b/src/fireedge/src/client/features/One/provider/services.js
index 879f97a987..4d3327a4c2 100644
--- a/src/fireedge/src/client/features/One/provider/services.js
+++ b/src/fireedge/src/client/features/One/provider/services.js
@@ -19,7 +19,7 @@ import { RestClient } from 'client/utils'
const { POST, PUT, DELETE } = defaults?.httpMethod || {}
-export const providerService = ({
+export const providerService = {
/**
* Retrieves information for the provider.
*
@@ -30,7 +30,7 @@ export const providerService = ({
*/
getProvider: async ({ id }) => {
const res = await RestClient.request({
- url: `/api/${PROVIDER}/list/${id}`
+ url: `/api/${PROVIDER}/list/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -46,7 +46,7 @@ export const providerService = ({
*/
getProviders: async () => {
const res = await RestClient.request({
- url: `/api/${PROVIDER}/list`
+ url: `/api/${PROVIDER}/list`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -66,7 +66,7 @@ export const providerService = ({
*/
getProviderConnection: async ({ id }) => {
const res = await RestClient.request({
- url: `/api/${PROVIDER}/connection/${id}`
+ url: `/api/${PROVIDER}/connection/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -86,7 +86,7 @@ export const providerService = ({
const res = await RestClient.request({
data,
method: POST,
- url: `/api/${PROVIDER}/create`
+ url: `/api/${PROVIDER}/create`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -107,7 +107,7 @@ export const providerService = ({
const res = await RestClient.request({
data,
method: PUT,
- url: `/api/${PROVIDER}/update/${id}`
+ url: `/api/${PROVIDER}/update/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -126,11 +126,11 @@ export const providerService = ({
deleteProvider: async ({ id }) => {
const res = await RestClient.request({
method: DELETE,
- url: `/api/${PROVIDER}/delete/${id}`
+ url: `/api/${PROVIDER}/delete/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return res?.data ?? {}
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/provision/actions.js b/src/fireedge/src/client/features/One/provision/actions.js
index 5dcc2f7dc9..f80773b6e5 100644
--- a/src/fireedge/src/client/features/One/provision/actions.js
+++ b/src/fireedge/src/client/features/One/provision/actions.js
@@ -20,7 +20,7 @@ import { RESOURCES } from 'client/features/One/slice'
export const getProvisionsTemplates = createAction(
'provisions-template/pool',
provisionService.getProvisionsTemplates,
- res => ({ [RESOURCES.document.defaults]: res })
+ (res) => ({ [RESOURCES.document.defaults]: res })
)
export const createProvisionTemplate = createAction(
@@ -28,20 +28,47 @@ export const createProvisionTemplate = createAction(
provisionService.createProvisionTemplate
)
-export const getProvision = createAction('provision', provisionService.getProvision)
+export const getProvision = createAction(
+ 'provision',
+ provisionService.getProvision
+)
export const getProvisions = createAction(
'provision/pool',
provisionService.getProvisions,
- res => ({ [RESOURCES.document[103]]: res })
+ (res) => ({ [RESOURCES.document[103]]: res })
)
-export const createProvision = createAction('provision/create', provisionService.createProvision)
-export const configureProvision = createAction('provision/configure', provisionService.configureProvision)
-export const deleteProvision = createAction('provision/delete', provisionService.deleteProvision)
-export const getProvisionLog = createAction('provision/log', provisionService.getProvisionLog)
+export const createProvision = createAction(
+ 'provision/create',
+ provisionService.createProvision
+)
+export const configureProvision = createAction(
+ 'provision/configure',
+ provisionService.configureProvision
+)
+export const deleteProvision = createAction(
+ 'provision/delete',
+ provisionService.deleteProvision
+)
+export const getProvisionLog = createAction(
+ 'provision/log',
+ provisionService.getProvisionLog
+)
-export const deleteDatastore = createAction('provision/datastore/delete', provisionService.deleteDatastore)
-export const deleteVNetwork = createAction('provision/vnet/delete', provisionService.deleteVNetwork)
-export const deleteHost = createAction('provision/host/delete', provisionService.deleteHost)
-export const configureHost = createAction('provision/host/configure', provisionService.configureHost)
+export const deleteDatastore = createAction(
+ 'provision/datastore/delete',
+ provisionService.deleteDatastore
+)
+export const deleteVNetwork = createAction(
+ 'provision/vnet/delete',
+ provisionService.deleteVNetwork
+)
+export const deleteHost = createAction(
+ 'provision/host/delete',
+ provisionService.deleteHost
+)
+export const configureHost = createAction(
+ 'provision/host/configure',
+ provisionService.configureHost
+)
diff --git a/src/fireedge/src/client/features/One/provision/hooks.js b/src/fireedge/src/client/features/One/provision/hooks.js
index cec06843e8..50e8abcfc0 100644
--- a/src/fireedge/src/client/features/One/provision/hooks.js
+++ b/src/fireedge/src/client/features/One/provision/hooks.js
@@ -21,36 +21,39 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/provision/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useProvisionTemplate = () => (
- useSelector(state => state[name]?.[RESOURCES.document.defaults])
-)
+export const useProvisionTemplate = () =>
+ useSelector((state) => state[name]?.[RESOURCES.document.defaults])
-export const useProvision = () => (
- useSelector(state => state[name]?.[RESOURCES.document[103]])
-)
+export const useProvision = () =>
+ useSelector((state) => state[name]?.[RESOURCES.document[103]])
export const useProvisionApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getProvisionsTemplates: () => unwrapDispatch(actions.getProvisionsTemplates()),
- createProvisionTemplate: () => unwrapDispatch(actions.createProvisionTemplate()),
+ getProvisionsTemplates: () =>
+ unwrapDispatch(actions.getProvisionsTemplates()),
+ createProvisionTemplate: () =>
+ unwrapDispatch(actions.createProvisionTemplate()),
- getProvision: id => unwrapDispatch(actions.getProvision({ id })),
+ getProvision: (id) => unwrapDispatch(actions.getProvision({ id })),
getProvisions: () => dispatch(actions.getProvisions()),
- createProvision: data => unwrapDispatch(actions.createProvision({ data })),
- configureProvision: id => unwrapDispatch(actions.configureProvision({ id })),
- deleteProvision: (id, data) => unwrapDispatch(actions.deleteProvision({ id, ...data })),
- getProvisionLog: id => unwrapDispatch(actions.getProvisionLog({ id })),
+ createProvision: (data) =>
+ unwrapDispatch(actions.createProvision({ data })),
+ configureProvision: (id) =>
+ unwrapDispatch(actions.configureProvision({ id })),
+ deleteProvision: (id, data) =>
+ unwrapDispatch(actions.deleteProvision({ id, ...data })),
+ getProvisionLog: (id) => unwrapDispatch(actions.getProvisionLog({ id })),
- deleteDatastore: id => unwrapDispatch(actions.deleteDatastore({ id })),
- deleteVNetwork: id => unwrapDispatch(actions.deleteVNetwork({ id })),
- deleteHost: id => unwrapDispatch(actions.deleteHost({ id })),
- configureHost: id => unwrapDispatch(actions.configureHost({ id }))
+ deleteDatastore: (id) => unwrapDispatch(actions.deleteDatastore({ id })),
+ deleteVNetwork: (id) => unwrapDispatch(actions.deleteVNetwork({ id })),
+ deleteHost: (id) => unwrapDispatch(actions.deleteHost({ id })),
+ configureHost: (id) => unwrapDispatch(actions.configureHost({ id })),
}
}
diff --git a/src/fireedge/src/client/features/One/provision/services.js b/src/fireedge/src/client/features/One/provision/services.js
index 224cb54cf2..cce4014ad0 100644
--- a/src/fireedge/src/client/features/One/provision/services.js
+++ b/src/fireedge/src/client/features/One/provision/services.js
@@ -19,7 +19,7 @@ import { RestClient } from 'client/utils'
const { POST, PUT, DELETE } = defaults?.httpMethod || {}
-export const provisionService = ({
+export const provisionService = {
// --------------------------------------------
// PROVISION TEMPLATE requests
// --------------------------------------------
@@ -33,7 +33,7 @@ export const provisionService = ({
*/
getProvisionsTemplates: async () => {
const res = await RestClient.request({
- url: `/api/${PROVISION}/defaults`
+ url: `/api/${PROVISION}/defaults`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -47,7 +47,7 @@ export const provisionService = ({
* @returns {Promise} TODO
*/
createProvisionTemplate: () => {
- return Promise.resolve().then(res => res?.data?.DOCUMENT ?? {})
+ return Promise.resolve().then((res) => res?.data?.DOCUMENT ?? {})
},
// --------------------------------------------
@@ -64,7 +64,7 @@ export const provisionService = ({
*/
getProvision: async ({ id }) => {
const res = await RestClient.request({
- url: `/api/${PROVISION}/list/${id}`
+ url: `/api/${PROVISION}/list/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -80,7 +80,7 @@ export const provisionService = ({
*/
getProvisions: async () => {
const res = await RestClient.request({
- url: `/api/${PROVISION}/list`
+ url: `/api/${PROVISION}/list`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -100,7 +100,7 @@ export const provisionService = ({
const res = await RestClient.request({
data,
method: POST,
- url: `/api/${PROVISION}/create`
+ url: `/api/${PROVISION}/create`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) {
@@ -122,7 +122,7 @@ export const provisionService = ({
configureProvision: async ({ id }) => {
const res = await RestClient.request({
method: PUT,
- url: `/api/${PROVISION}/configure/${id}`
+ url: `/api/${PROVISION}/configure/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) {
@@ -148,7 +148,7 @@ export const provisionService = ({
const res = await RestClient.request({
method: DELETE,
url: `/api/${PROVISION}/delete/${id}`,
- data
+ data,
})
if (!res?.id || res?.id !== httpCodes.ok.id) {
@@ -169,7 +169,7 @@ export const provisionService = ({
*/
getProvisionLog: async ({ id }) => {
const res = await RestClient.request({
- url: `/api/${PROVISION}/log/${id}`
+ url: `/api/${PROVISION}/log/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) {
@@ -195,7 +195,7 @@ export const provisionService = ({
deleteDatastore: async ({ id }) => {
const res = await RestClient.request({
method: DELETE,
- url: `/api/${PROVISION}/datastore/${id}`
+ url: `/api/${PROVISION}/datastore/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -214,7 +214,7 @@ export const provisionService = ({
deleteVNetwork: async ({ id }) => {
const res = await RestClient.request({
method: DELETE,
- url: `/api/${PROVISION}/network/${id}`
+ url: `/api/${PROVISION}/network/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -233,7 +233,7 @@ export const provisionService = ({
deleteHost: async ({ id }) => {
const res = await RestClient.request({
method: DELETE,
- url: `/api/${PROVISION}/host/${id}`
+ url: `/api/${PROVISION}/host/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
@@ -252,7 +252,7 @@ export const provisionService = ({
configureHost: async ({ id }) => {
const res = await RestClient.request({
method: PUT,
- url: `/api/${PROVISION}/host/${id}`
+ url: `/api/${PROVISION}/host/${id}`,
})
if (!res?.id || res?.id !== httpCodes.ok.id) {
@@ -261,5 +261,5 @@ export const provisionService = ({
}
return res?.data ?? {}
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/slice.js b/src/fireedge/src/client/features/One/slice.js
index 3b931d2d45..eae08054d5 100644
--- a/src/fireedge/src/client/features/One/slice.js
+++ b/src/fireedge/src/client/features/One/slice.js
@@ -20,7 +20,7 @@ import { updateResourceList } from 'client/features/One/utils'
import { eventUpdateResourceState } from 'client/features/One/socket/actions'
import { updateResourceFromFetch } from 'client/features/One/actions'
-const getNameListFromType = type => RESOURCES[type.split('/')[0]]
+const getNameListFromType = (type) => RESOURCES[type.split('/')[0]]
const RESOURCES = {
acl: 'acl',
@@ -49,8 +49,8 @@ const RESOURCES = {
102: 'providers',
103: 'provisions',
// extra: only for client
- defaults: 'provisionsTemplates'
- }
+ defaults: 'provisionsTemplates',
+ },
}
const initial = {
@@ -80,30 +80,36 @@ const initial = {
[RESOURCES.document[101]]: [],
[RESOURCES.document[102]]: [],
[RESOURCES.document[103]]: [],
- [RESOURCES.document.defaults]: []
+ [RESOURCES.document.defaults]: [],
}
const { name, actions, reducer } = createSlice({
name: 'one',
initialState: initial,
- extraReducers: builder => {
+ extraReducers: (builder) => {
builder
- .addMatcher(({ type }) => type === logout.type, () => initial)
.addMatcher(
- ({ type }) => type.startsWith(RESOURCES.system) && type.endsWith('/fulfilled'),
+ ({ type }) => type === logout.type,
+ () => initial
+ )
+ .addMatcher(
+ ({ type }) =>
+ type.startsWith(RESOURCES.system) && type.endsWith('/fulfilled'),
(state, { payload }) => ({ ...state, ...payload })
)
.addMatcher(
({ type }) =>
type === updateResourceFromFetch.type ||
- (
- type.endsWith('/fulfilled') &&
- (type.includes(eventUpdateResourceState.typePrefix) || type.includes('/detail'))
- ),
+ (type.endsWith('/fulfilled') &&
+ (type.includes(eventUpdateResourceState.typePrefix) ||
+ type.includes('/detail'))),
(state, { payload, type }) => {
// TYPE and DATA can be force by payload
const name = getNameListFromType(payload?.type ?? type)
- const newList = updateResourceList(state[name], payload?.data ?? payload)
+ const newList = updateResourceList(
+ state[name],
+ payload?.data ?? payload
+ )
return { ...state, [name]: newList }
}
@@ -126,11 +132,11 @@ const { name, actions, reducer } = createSlice({
return {
...state,
...(isFulfilled(action) && payload),
- requests: restOfRequests
+ requests: restOfRequests,
}
}
)
- }
+ },
})
export { name, actions, reducer, RESOURCES }
diff --git a/src/fireedge/src/client/features/One/socket/actions.js b/src/fireedge/src/client/features/One/socket/actions.js
index cf7e557b45..f373707a9a 100644
--- a/src/fireedge/src/client/features/One/socket/actions.js
+++ b/src/fireedge/src/client/features/One/socket/actions.js
@@ -25,7 +25,7 @@ const MESSAGE_PROVISION_SUCCESS_CREATED = 'Provision successfully created'
const COMMANDS = {
create: 'create',
update: 'update',
- delete: 'delete'
+ delete: 'delete',
}
/**
@@ -33,7 +33,7 @@ const COMMANDS = {
* @returns {{name: ('vm'|'host'|'image'), value: object}}
* - Name and new value of resource
*/
-export const getResourceFromEventState = data => {
+export const getResourceFromEventState = (data) => {
const { HOOK_OBJECT: name, [name]: value } = data?.HOOK_MESSAGE ?? {}
return { name: String(name).toLowerCase(), value }
@@ -63,8 +63,9 @@ export const getResourceFromEventApi = (data = {}) => {
const resource = RESOURCES[resourceName]
const name = resource?.[value?.TYPE] ?? resource
- const [, { VALUE: output }] = PARAMETERS?.PARAMETER
- ?.filter(({ TYPE }) => TYPE === 'OUT')
+ const [, { VALUE: output }] = PARAMETERS?.PARAMETER?.filter(
+ ({ TYPE }) => TYPE === 'OUT'
+ )
return { action, name, value, success, output }
}
@@ -79,10 +80,12 @@ export const eventApi = createAsyncThunk(
// console.log({ action, name, value, success, output })
- return (success && value && action !== COMMANDS.delete) ? { [name]: value } : {}
+ return success && value && action !== COMMANDS.delete
+ ? { [name]: value }
+ : {}
},
{
- condition: ({ data } = {}) => data?.HOOK_MESSAGE?.HOOK_TYPE === 'API'
+ condition: ({ data } = {}) => data?.HOOK_MESSAGE?.HOOK_TYPE === 'API',
}
)
@@ -110,7 +113,7 @@ export const eventUpdateResourceState = createAsyncThunk(
// update the list if event returns resource value
value !== ''
)
- }
+ },
}
)
@@ -120,20 +123,19 @@ export const eventUpdateResourceState = createAsyncThunk(
export const onCreateProvision = createAsyncThunk(
'socket/create-provision',
(_, { dispatch }) => {
- dispatch(actions.enqueueSnackbar({
- key: generateKey(),
- message: MESSAGE_PROVISION_SUCCESS_CREATED,
- options: { variant: 'success' }
- }))
+ dispatch(
+ actions.enqueueSnackbar({
+ key: generateKey(),
+ message: MESSAGE_PROVISION_SUCCESS_CREATED,
+ options: { variant: 'success' },
+ })
+ )
},
{
condition: (payload = {}) => {
const { command, data } = payload
- return (
- command === 'create' &&
- data === MESSAGE_PROVISION_SUCCESS_CREATED
- )
- }
+ return command === 'create' && data === MESSAGE_PROVISION_SUCCESS_CREATED
+ },
}
)
diff --git a/src/fireedge/src/client/features/One/system/actions.js b/src/fireedge/src/client/features/One/system/actions.js
index a61190e550..ec43ce0bda 100644
--- a/src/fireedge/src/client/features/One/system/actions.js
+++ b/src/fireedge/src/client/features/One/system/actions.js
@@ -26,8 +26,8 @@ export const getOneVersion = createAction(
(response, one) => ({
[RESOURCES.system]: {
...one[RESOURCES.system],
- version: response
- }
+ version: response,
+ },
})
)
@@ -37,7 +37,7 @@ export const getOneConfig = createAction(
(response, one) => ({
[RESOURCES.system]: {
...one[RESOURCES.system],
- config: response
- }
+ config: response,
+ },
})
)
diff --git a/src/fireedge/src/client/features/One/system/hooks.js b/src/fireedge/src/client/features/One/system/hooks.js
index a45d7dd874..edaf142b6d 100644
--- a/src/fireedge/src/client/features/One/system/hooks.js
+++ b/src/fireedge/src/client/features/One/system/hooks.js
@@ -21,24 +21,27 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/system/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useSystem = () => (
- useSelector(state => state[name]?.[RESOURCES.system] ?? [])
-)
+export const useSystem = () =>
+ useSelector((state) => state[name]?.[RESOURCES.system] ?? [])
export const useSystemApi = () => {
const dispatch = useDispatch()
- const unwrapDispatch = useCallback(async action => {
- try {
- const response = await dispatch(action)
- return unwrapResult(response)
- } catch (error) {
- return error
- }
- }, [dispatch])
+ const unwrapDispatch = useCallback(
+ async (action) => {
+ try {
+ const response = await dispatch(action)
+
+ return unwrapResult(response)
+ } catch (error) {
+ return error
+ }
+ },
+ [dispatch]
+ )
return {
getOneVersion: () => unwrapDispatch(actions.getOneVersion()),
- getOneConfig: () => unwrapDispatch(actions.getOneConfig())
+ getOneConfig: () => unwrapDispatch(actions.getOneConfig()),
}
}
diff --git a/src/fireedge/src/client/features/One/system/services.js b/src/fireedge/src/client/features/One/system/services.js
index 4262d62cda..e37a16e5ef 100644
--- a/src/fireedge/src/client/features/One/system/services.js
+++ b/src/fireedge/src/client/features/One/system/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/system'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const systemService = ({
+export const systemService = {
/**
* Returns the OpenNebula core version.
*
@@ -52,5 +52,5 @@ export const systemService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res?.data
return res?.data?.OPENNEBULA_CONFIGURATION
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/user/actions.js b/src/fireedge/src/client/features/One/user/actions.js
index 87e47d3bec..212dcccbbf 100644
--- a/src/fireedge/src/client/features/One/user/actions.js
+++ b/src/fireedge/src/client/features/One/user/actions.js
@@ -20,16 +20,16 @@ import { RESOURCES } from 'client/features/One/slice'
/** @see {@link RESOURCES.user} */
const USER = 'user'
-export const getUser = createAction(
- `${USER}/detail`,
- userService.getUser
-)
+export const getUser = createAction(`${USER}/detail`, userService.getUser)
export const getUsers = createAction(
`${USER}/pool`,
userService.getUsers,
- response => ({ [RESOURCES.user]: response })
+ (response) => ({ [RESOURCES.user]: response })
)
export const updateUser = createAction(`${USER}/update`, userService.updateUser)
-export const changeGroup = createAction(`${USER}/change-group`, userService.changeGroup)
+export const changeGroup = createAction(
+ `${USER}/change-group`,
+ userService.changeGroup
+)
diff --git a/src/fireedge/src/client/features/One/user/hooks.js b/src/fireedge/src/client/features/One/user/hooks.js
index 2a7c040ac7..01335ab06b 100644
--- a/src/fireedge/src/client/features/One/user/hooks.js
+++ b/src/fireedge/src/client/features/One/user/hooks.js
@@ -21,22 +21,22 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/user/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useUser = () => (
- useSelector(state => state[name]?.[RESOURCES.user] ?? [])
-)
+export const useUser = () =>
+ useSelector((state) => state[name]?.[RESOURCES.user] ?? [])
export const useUserApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getUser: id => unwrapDispatch(actions.getUser({ id })),
+ getUser: (id) => unwrapDispatch(actions.getUser({ id })),
getUsers: () => unwrapDispatch(actions.getUsers()),
- changeGroup: data => unwrapDispatch(actions.changeGroup(data)),
- updateUser: (id, data) => unwrapDispatch(actions.updateUser({ id, ...data }))
+ changeGroup: (data) => unwrapDispatch(actions.changeGroup(data)),
+ updateUser: (id, data) =>
+ unwrapDispatch(actions.updateUser({ id, ...data })),
}
}
diff --git a/src/fireedge/src/client/features/One/user/services.js b/src/fireedge/src/client/features/One/user/services.js
index 87e1e38a69..7f414f1960 100644
--- a/src/fireedge/src/client/features/One/user/services.js
+++ b/src/fireedge/src/client/features/One/user/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/user'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const userService = ({
+export const userService = {
/**
* Retrieves information for the user.
*
@@ -64,7 +64,7 @@ export const userService = ({
* @returns {number} User id
* @throws Fails when response isn't code 200
*/
- changeGroup: async params => {
+ changeGroup: async (params) => {
const name = Actions.USER_CHGRP
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -89,7 +89,7 @@ export const userService = ({
* @returns {number} User id
* @throws Fails when response isn't code 200
*/
- updateUser: async params => {
+ updateUser: async (params) => {
const name = Actions.USER_UPDATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -99,5 +99,5 @@ export const userService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return res?.data ?? {}
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/utils.js b/src/fireedge/src/client/features/One/utils.js
index b9c6e06352..05c1ad3d34 100644
--- a/src/fireedge/src/client/features/One/utils.js
+++ b/src/fireedge/src/client/features/One/utils.js
@@ -27,26 +27,36 @@ import { httpCodes } from 'server/utils/constants'
* @returns {AsyncThunkAction} Asynchronous redux action
*/
export const createAction = (type, service, wrapResult) =>
- createAsyncThunk(type, async (payload, { dispatch, getState, rejectWithValue }) => {
- try {
- const { auth: { filterPool }, one } = getState()
+ createAsyncThunk(
+ type,
+ async (payload, { dispatch, getState, rejectWithValue }) => {
+ try {
+ const {
+ auth: { filterPool },
+ one,
+ } = getState()
- const response = await service({
- ...payload,
- filter: filterPool
- })
+ const response = await service({
+ ...payload,
+ filter: filterPool,
+ })
- return wrapResult?.(response, one) ?? response
- } catch (error) {
- const { message, data, status, statusText } = error
+ return wrapResult?.(response, one) ?? response
+ } catch (error) {
+ const { message, data, status, statusText } = error
- status === httpCodes.unauthorized.id && dispatch(logout(T.SessionExpired))
+ status === httpCodes.unauthorized.id &&
+ dispatch(logout(T.SessionExpired))
- return rejectWithValue(message ?? data?.data ?? data?.message ?? statusText)
+ return rejectWithValue(
+ message ?? data?.data ?? data?.message ?? statusText
+ )
+ }
+ },
+ {
+ condition: (_, { getState }) => !getState().one.requests[type],
}
- }, {
- condition: (_, { getState }) => !getState().one.requests[type]
- })
+ )
/**
* @param {object} currentList - Current list of resources from redux
@@ -60,7 +70,7 @@ export const updateResourceList = (currentList, value) => {
// update if exists in current list, if not add it to list
const updatedList = currentItem
- ? currentList?.map(item => item?.ID === id ? value : item)
+ ? currentList?.map((item) => (item?.ID === id ? value : item))
: [value, ...currentList]
return updatedList
diff --git a/src/fireedge/src/client/features/One/vm/actions.js b/src/fireedge/src/client/features/One/vm/actions.js
index a4b08aefb2..ea841737b1 100644
--- a/src/fireedge/src/client/features/One/vm/actions.js
+++ b/src/fireedge/src/client/features/One/vm/actions.js
@@ -33,59 +33,128 @@ export const getVms = createAction(
}
)
-export const terminate = createAction(`${VM}/terminate`,
- ({ id }) => vmService.actionVm({ id, action: 'terminate' }))
-export const terminateHard = createAction(`${VM}/terminate-hard`,
- ({ id }) => vmService.actionVm({ id, action: 'terminate-hard' }))
-export const undeploy = createAction(`${VM}/undeploy`,
- ({ id }) => vmService.actionVm({ id, action: 'undeploy' }))
-export const undeployHard = createAction(`${VM}/undeploy-hard`,
- ({ id }) => vmService.actionVm({ id, action: 'undeploy-hard' }))
-export const poweroff = createAction(`${VM}/poweroff`,
- ({ id }) => vmService.actionVm({ id, action: 'poweroff' }))
-export const poweroffHard = createAction(`${VM}/poweroff-hard`,
- ({ id }) => vmService.actionVm({ id, action: 'poweroff-hard' }))
-export const reboot = createAction(`${VM}/reboot`,
- ({ id }) => vmService.actionVm({ id, action: 'reboot' }))
-export const rebootHard = createAction(`${VM}/reboot-hard`,
- ({ id }) => vmService.actionVm({ id, action: 'reboot-hard' }))
-export const hold = createAction(`${VM}/hold`,
- ({ id }) => vmService.actionVm({ id, action: 'hold' }))
-export const release = createAction(`${VM}/release`,
- ({ id }) => vmService.actionVm({ id, action: 'release' }))
-export const stop = createAction(`${VM}/stop`,
- ({ id }) => vmService.actionVm({ id, action: 'stop' }))
-export const suspend = createAction(`${VM}/suspend`,
- ({ id }) => vmService.actionVm({ id, action: 'suspend' }))
-export const resume = createAction(`${VM}/resume`,
- ({ id }) => vmService.actionVm({ id, action: 'resume' }))
-export const resched = createAction(`${VM}/resched`,
- ({ id }) => vmService.actionVm({ id, action: 'resched' }))
-export const unresched = createAction(`${VM}/unresched`,
- ({ id }) => vmService.actionVm({ id, action: 'unresched' }))
+export const terminate = createAction(`${VM}/terminate`, ({ id }) =>
+ vmService.actionVm({ id, action: 'terminate' })
+)
+export const terminateHard = createAction(`${VM}/terminate-hard`, ({ id }) =>
+ vmService.actionVm({ id, action: 'terminate-hard' })
+)
+export const undeploy = createAction(`${VM}/undeploy`, ({ id }) =>
+ vmService.actionVm({ id, action: 'undeploy' })
+)
+export const undeployHard = createAction(`${VM}/undeploy-hard`, ({ id }) =>
+ vmService.actionVm({ id, action: 'undeploy-hard' })
+)
+export const poweroff = createAction(`${VM}/poweroff`, ({ id }) =>
+ vmService.actionVm({ id, action: 'poweroff' })
+)
+export const poweroffHard = createAction(`${VM}/poweroff-hard`, ({ id }) =>
+ vmService.actionVm({ id, action: 'poweroff-hard' })
+)
+export const reboot = createAction(`${VM}/reboot`, ({ id }) =>
+ vmService.actionVm({ id, action: 'reboot' })
+)
+export const rebootHard = createAction(`${VM}/reboot-hard`, ({ id }) =>
+ vmService.actionVm({ id, action: 'reboot-hard' })
+)
+export const hold = createAction(`${VM}/hold`, ({ id }) =>
+ vmService.actionVm({ id, action: 'hold' })
+)
+export const release = createAction(`${VM}/release`, ({ id }) =>
+ vmService.actionVm({ id, action: 'release' })
+)
+export const stop = createAction(`${VM}/stop`, ({ id }) =>
+ vmService.actionVm({ id, action: 'stop' })
+)
+export const suspend = createAction(`${VM}/suspend`, ({ id }) =>
+ vmService.actionVm({ id, action: 'suspend' })
+)
+export const resume = createAction(`${VM}/resume`, ({ id }) =>
+ vmService.actionVm({ id, action: 'resume' })
+)
+export const resched = createAction(`${VM}/resched`, ({ id }) =>
+ vmService.actionVm({ id, action: 'resched' })
+)
+export const unresched = createAction(`${VM}/unresched`, ({ id }) =>
+ vmService.actionVm({ id, action: 'unresched' })
+)
-export const updateUserTemplate = createAction(`${VM}/update`, vmService.updateUserTemplate)
+export const updateUserTemplate = createAction(
+ `${VM}/update`,
+ vmService.updateUserTemplate
+)
export const rename = createAction(`${VM}/rename`, vmService.rename)
export const resize = createAction(`${VM}/resize`, vmService.resize)
-export const changePermissions = createAction(`${VM}/chmod`, vmService.changePermissions)
-export const changeOwnership = createAction(`${VM}/chown`, vmService.changeOwnership)
-export const attachDisk = createAction(`${VM}/attach/disk`, vmService.attachDisk)
-export const detachDisk = createAction(`${VM}/detach/disk`, vmService.detachDisk)
-export const saveAsDisk = createAction(`${VM}/saveas/disk`, vmService.saveAsDisk)
-export const saveAsTemplate = createAction(`${VM}/saveas/template`, vmService.saveAsTemplate)
-export const resizeDisk = createAction(`${VM}/resize/disk`, vmService.resizeDisk)
-export const createDiskSnapshot = createAction(`${VM}/create/disk-snapshot`, vmService.createDiskSnapshot)
-export const renameDiskSnapshot = createAction(`${VM}/rename/disk-snapshot`, vmService.renameDiskSnapshot)
-export const revertDiskSnapshot = createAction(`${VM}/revert/disk-snapshot`, vmService.revertDiskSnapshot)
-export const deleteDiskSnapshot = createAction(`${VM}/delete/disk-snapshot`, vmService.deleteDiskSnapshot)
+export const changePermissions = createAction(
+ `${VM}/chmod`,
+ vmService.changePermissions
+)
+export const changeOwnership = createAction(
+ `${VM}/chown`,
+ vmService.changeOwnership
+)
+export const attachDisk = createAction(
+ `${VM}/attach/disk`,
+ vmService.attachDisk
+)
+export const detachDisk = createAction(
+ `${VM}/detach/disk`,
+ vmService.detachDisk
+)
+export const saveAsDisk = createAction(
+ `${VM}/saveas/disk`,
+ vmService.saveAsDisk
+)
+export const saveAsTemplate = createAction(
+ `${VM}/saveas/template`,
+ vmService.saveAsTemplate
+)
+export const resizeDisk = createAction(
+ `${VM}/resize/disk`,
+ vmService.resizeDisk
+)
+export const createDiskSnapshot = createAction(
+ `${VM}/create/disk-snapshot`,
+ vmService.createDiskSnapshot
+)
+export const renameDiskSnapshot = createAction(
+ `${VM}/rename/disk-snapshot`,
+ vmService.renameDiskSnapshot
+)
+export const revertDiskSnapshot = createAction(
+ `${VM}/revert/disk-snapshot`,
+ vmService.revertDiskSnapshot
+)
+export const deleteDiskSnapshot = createAction(
+ `${VM}/delete/disk-snapshot`,
+ vmService.deleteDiskSnapshot
+)
export const attachNic = createAction(`${VM}/attach/nic`, vmService.attachNic)
export const detachNic = createAction(`${VM}/detach/nic`, vmService.detachNic)
-export const createSnapshot = createAction(`${VM}/create/snapshot`, vmService.createSnapshot)
-export const revertSnapshot = createAction(`${VM}/revert/snapshot`, vmService.revertSnapshot)
-export const deleteSnapshot = createAction(`${VM}/delete/snapshot`, vmService.deleteSnapshot)
-export const addScheduledAction = createAction(`${VM}/add/scheduled-action`, vmService.addScheduledAction)
-export const updateScheduledAction = createAction(`${VM}/update/scheduled-action`, vmService.updateScheduledAction)
-export const deleteScheduledAction = createAction(`${VM}/delete/scheduled-action`, vmService.deleteScheduledAction)
+export const createSnapshot = createAction(
+ `${VM}/create/snapshot`,
+ vmService.createSnapshot
+)
+export const revertSnapshot = createAction(
+ `${VM}/revert/snapshot`,
+ vmService.revertSnapshot
+)
+export const deleteSnapshot = createAction(
+ `${VM}/delete/snapshot`,
+ vmService.deleteSnapshot
+)
+export const addScheduledAction = createAction(
+ `${VM}/add/scheduled-action`,
+ vmService.addScheduledAction
+)
+export const updateScheduledAction = createAction(
+ `${VM}/update/scheduled-action`,
+ vmService.updateScheduledAction
+)
+export const deleteScheduledAction = createAction(
+ `${VM}/delete/scheduled-action`,
+ vmService.deleteScheduledAction
+)
export const recover = createAction(`${VM}/recover`, vmService.recover)
export const lock = createAction(`${VM}/lock`, vmService.lock)
export const unlock = createAction(`${VM}/unlock`, vmService.unlock)
diff --git a/src/fireedge/src/client/features/One/vm/hooks.js b/src/fireedge/src/client/features/One/vm/hooks.js
index 6844c3b6f5..a5bae2c761 100644
--- a/src/fireedge/src/client/features/One/vm/hooks.js
+++ b/src/fireedge/src/client/features/One/vm/hooks.js
@@ -21,36 +21,35 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/vm/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useVm = () => (
- useSelector(state => state[name]?.[RESOURCES.vm] ?? [])
-)
+export const useVm = () =>
+ useSelector((state) => state[name]?.[RESOURCES.vm] ?? [])
export const useVmApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getVm: id => unwrapDispatch(actions.getVm({ id })),
- getVms: options => unwrapDispatch(actions.getVms(options)),
- terminate: id => unwrapDispatch(actions.terminate({ id })),
- terminateHard: id => unwrapDispatch(actions.terminateHard({ id })),
- undeploy: id => unwrapDispatch(actions.undeploy({ id })),
- undeployHard: id => unwrapDispatch(actions.undeployHard({ id })),
- poweroff: id => unwrapDispatch(actions.poweroff({ id })),
- poweroffHard: id => unwrapDispatch(actions.poweroffHard({ id })),
- reboot: id => unwrapDispatch(actions.reboot({ id })),
- rebootHard: id => unwrapDispatch(actions.rebootHard({ id })),
- hold: id => unwrapDispatch(actions.hold({ id })),
- release: id => unwrapDispatch(actions.release({ id })),
- stop: id => unwrapDispatch(actions.stop({ id })),
- suspend: id => unwrapDispatch(actions.suspend({ id })),
- resume: id => unwrapDispatch(actions.resume({ id })),
- resched: id => unwrapDispatch(actions.resched({ id })),
- unresched: id => unwrapDispatch(actions.unresched({ id })),
+ getVm: (id) => unwrapDispatch(actions.getVm({ id })),
+ getVms: (options) => unwrapDispatch(actions.getVms(options)),
+ terminate: (id) => unwrapDispatch(actions.terminate({ id })),
+ terminateHard: (id) => unwrapDispatch(actions.terminateHard({ id })),
+ undeploy: (id) => unwrapDispatch(actions.undeploy({ id })),
+ undeployHard: (id) => unwrapDispatch(actions.undeployHard({ id })),
+ poweroff: (id) => unwrapDispatch(actions.poweroff({ id })),
+ poweroffHard: (id) => unwrapDispatch(actions.poweroffHard({ id })),
+ reboot: (id) => unwrapDispatch(actions.reboot({ id })),
+ rebootHard: (id) => unwrapDispatch(actions.rebootHard({ id })),
+ hold: (id) => unwrapDispatch(actions.hold({ id })),
+ release: (id) => unwrapDispatch(actions.release({ id })),
+ stop: (id) => unwrapDispatch(actions.stop({ id })),
+ suspend: (id) => unwrapDispatch(actions.suspend({ id })),
+ resume: (id) => unwrapDispatch(actions.resume({ id })),
+ resched: (id) => unwrapDispatch(actions.resched({ id })),
+ unresched: (id) => unwrapDispatch(actions.unresched({ id })),
updateUserTemplate: (id, template, replace) =>
unwrapDispatch(actions.updateUserTemplate({ id, template, replace })),
rename: (id, name) => unwrapDispatch(actions.rename({ id, name })),
@@ -59,11 +58,15 @@ export const useVmApi = () => {
unwrapDispatch(actions.changePermissions({ id, permissions })),
changeOwnership: (id, ownership) =>
unwrapDispatch(actions.changeOwnership({ id, ownership })),
- attachDisk: (id, template) => unwrapDispatch(actions.attachDisk({ id, template })),
+ attachDisk: (id, template) =>
+ unwrapDispatch(actions.attachDisk({ id, template })),
detachDisk: (id, disk) => unwrapDispatch(actions.detachDisk({ id, disk })),
- saveAsDisk: (id, data) => unwrapDispatch(actions.saveAsDisk({ id, ...data })),
- saveAsTemplate: (id, data) => unwrapDispatch(actions.saveAsTemplate({ id, ...data })),
- resizeDisk: (id, data) => unwrapDispatch(actions.resizeDisk({ id, ...data })),
+ saveAsDisk: (id, data) =>
+ unwrapDispatch(actions.saveAsDisk({ id, ...data })),
+ saveAsTemplate: (id, data) =>
+ unwrapDispatch(actions.saveAsTemplate({ id, ...data })),
+ resizeDisk: (id, data) =>
+ unwrapDispatch(actions.resizeDisk({ id, ...data })),
createDiskSnapshot: (id, data) =>
unwrapDispatch(actions.createDiskSnapshot({ id, ...data })),
renameDiskSnapshot: (id, data) =>
@@ -72,7 +75,8 @@ export const useVmApi = () => {
unwrapDispatch(actions.revertDiskSnapshot({ id, ...data })),
deleteDiskSnapshot: (id, data) =>
unwrapDispatch(actions.deleteDiskSnapshot({ id, ...data })),
- attachNic: (id, template) => unwrapDispatch(actions.attachNic({ id, template })),
+ attachNic: (id, template) =>
+ unwrapDispatch(actions.attachNic({ id, template })),
detachNic: (id, nic) => unwrapDispatch(actions.detachNic({ id, nic })),
createSnapshot: (id, data) =>
unwrapDispatch(actions.createSnapshot({ id, ...data })),
@@ -86,11 +90,14 @@ export const useVmApi = () => {
unwrapDispatch(actions.updateScheduledAction({ id, ...data })),
deleteScheduledAction: (id, data) =>
unwrapDispatch(actions.deleteScheduledAction({ id, ...data })),
- recover: (id, operation) => unwrapDispatch(actions.recover({ id, operation })),
+ recover: (id, operation) =>
+ unwrapDispatch(actions.recover({ id, operation })),
lock: (id, data) => unwrapDispatch(actions.lock({ id, ...data })),
- unlock: id => unwrapDispatch(actions.unlock({ id })),
+ unlock: (id) => unwrapDispatch(actions.unlock({ id })),
deploy: (id, data) => unwrapDispatch(actions.deploy({ id, ...data })),
- migrate: (id, data) => unwrapDispatch(actions.migrate({ id, ...data, live: false })),
- migrateLive: (id, data) => unwrapDispatch(actions.migrate({ id, ...data, live: true }))
+ migrate: (id, data) =>
+ unwrapDispatch(actions.migrate({ id, ...data, live: false })),
+ migrateLive: (id, data) =>
+ unwrapDispatch(actions.migrate({ id, ...data, live: true })),
}
}
diff --git a/src/fireedge/src/client/features/One/vm/services.js b/src/fireedge/src/client/features/One/vm/services.js
index cd6588752e..ca6451a2fa 100644
--- a/src/fireedge/src/client/features/One/vm/services.js
+++ b/src/fireedge/src/client/features/One/vm/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/vm'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const vmService = ({
+export const vmService = {
/**
* Retrieves information for the virtual machine.
*
@@ -26,7 +26,7 @@ export const vmService = ({
* @returns {object} Get user identified by id
* @throws Fails when response isn't code 200
*/
- getVm: async params => {
+ getVm: async (params) => {
const name = Actions.VM_INFO
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -50,7 +50,7 @@ export const vmService = ({
* @returns {Array} List of VMs
* @throws Fails when response isn't code 200
*/
- getVms: async params => {
+ getVms: async (params) => {
const name = Actions.VM_POOL_INFO
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -87,7 +87,7 @@ export const vmService = ({
* @returns {Response} Response
* @throws Fails when response isn't code 200
*/
- actionVm: async params => {
+ actionVm: async (params) => {
const name = Actions.VM_ACTION
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -114,7 +114,7 @@ export const vmService = ({
const res = await RestClient.request({
url: `/api/vm/save/${id}`,
method: 'POST',
- data: { name, persistent }
+ data: { name, persistent },
})
if (!res?.id || res?.id !== httpCodes.ok.id) throw res?.data
@@ -131,7 +131,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- rename: async params => {
+ rename: async (params) => {
const name = Actions.VM_RENAME
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -154,7 +154,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- resize: async params => {
+ resize: async (params) => {
const name = Actions.VM_RESIZE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -179,7 +179,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- updateUserTemplate: async params => {
+ updateUserTemplate: async (params) => {
const name = Actions.VM_UPDATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -253,7 +253,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- attachDisk: async params => {
+ attachDisk: async (params) => {
const name = Actions.VM_DISK_ATTACH
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -274,7 +274,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- detachDisk: async params => {
+ detachDisk: async (params) => {
const name = Actions.VM_DISK_DETACH
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -300,7 +300,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- saveAsDisk: async params => {
+ saveAsDisk: async (params) => {
const name = Actions.VM_DISK_SAVEAS
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -323,7 +323,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- resizeDisk: async params => {
+ resizeDisk: async (params) => {
const name = Actions.VM_DISK_RESIZE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -345,7 +345,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- createDiskSnapshot: async params => {
+ createDiskSnapshot: async (params) => {
const name = Actions.VM_DISK_SNAP_CREATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -368,7 +368,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- renameDiskSnapshot: async params => {
+ renameDiskSnapshot: async (params) => {
const name = Actions.VM_DISK_SNAP_RENAME
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -390,7 +390,7 @@ export const vmService = ({
* @returns {number} The snapshot id used
* @throws Fails when response isn't code 200
*/
- revertDiskSnapshot: async params => {
+ revertDiskSnapshot: async (params) => {
const name = Actions.VM_DISK_SNAP_REVERT
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -412,7 +412,7 @@ export const vmService = ({
* @returns {number} The id of the snapshot deleted
* @throws Fails when response isn't code 200
*/
- deleteDiskSnapshot: async params => {
+ deleteDiskSnapshot: async (params) => {
const name = Actions.VM_DISK_SNAP_DELETE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -434,7 +434,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- attachNic: async params => {
+ attachNic: async (params) => {
const name = Actions.VM_NIC_ATTACH
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -455,7 +455,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- detachNic: async params => {
+ detachNic: async (params) => {
const name = Actions.VM_NIC_DETACH
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -476,7 +476,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- createSnapshot: async params => {
+ createSnapshot: async (params) => {
const name = Actions.VM_SNAP_CREATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -497,7 +497,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- revertSnapshot: async params => {
+ revertSnapshot: async (params) => {
const name = Actions.VM_SNAP_REVERT
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -518,7 +518,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- deleteSnapshot: async params => {
+ deleteSnapshot: async (params) => {
const name = Actions.VM_SNAP_DELETE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -539,7 +539,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- addScheduledAction: async params => {
+ addScheduledAction: async (params) => {
const name = Actions.VM_SCHED_ADD
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -561,7 +561,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- updateScheduledAction: async params => {
+ updateScheduledAction: async (params) => {
const name = Actions.VM_SCHED_UPDATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -582,7 +582,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- deleteScheduledAction: async params => {
+ deleteScheduledAction: async (params) => {
const name = Actions.VM_SCHED_DELETE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -608,7 +608,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- recover: async params => {
+ recover: async (params) => {
const name = Actions.VM_RECOVER
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -635,7 +635,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- lock: async params => {
+ lock: async (params) => {
const name = Actions.VM_LOCK
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -655,7 +655,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- unlock: async params => {
+ unlock: async (params) => {
const name = Actions.VM_UNLOCK
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -680,7 +680,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- deploy: async params => {
+ deploy: async (params) => {
const name = Actions.VM_DEPLOY
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -708,7 +708,7 @@ export const vmService = ({
* @returns {number} Virtual machine id
* @throws Fails when response isn't code 200
*/
- migrate: async params => {
+ migrate: async (params) => {
const name = Actions.VM_MIGRATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -718,5 +718,5 @@ export const vmService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res?.data
return res?.data
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/vmGroup/actions.js b/src/fireedge/src/client/features/One/vmGroup/actions.js
index 048d8eeb44..99ec6d4d5e 100644
--- a/src/fireedge/src/client/features/One/vmGroup/actions.js
+++ b/src/fireedge/src/client/features/One/vmGroup/actions.js
@@ -28,5 +28,5 @@ export const getVmGroup = createAction(
export const getVmGroups = createAction(
`${VM_GROUP}/pool`,
vmGroupService.getVmGroups,
- response => ({ [RESOURCES.vmgroup]: response })
+ (response) => ({ [RESOURCES.vmgroup]: response })
)
diff --git a/src/fireedge/src/client/features/One/vmGroup/hooks.js b/src/fireedge/src/client/features/One/vmGroup/hooks.js
index 26a558bb3b..8b5394516e 100644
--- a/src/fireedge/src/client/features/One/vmGroup/hooks.js
+++ b/src/fireedge/src/client/features/One/vmGroup/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/vmGroup/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useVmGroup = () => (
- useSelector(state => state[name]?.[RESOURCES.vmgroup])
-)
+export const useVmGroup = () =>
+ useSelector((state) => state[name]?.[RESOURCES.vmgroup])
export const useVmGroupApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getVmGroup: id => unwrapDispatch(actions.getVmGroup({ id })),
- getVmGroups: () => unwrapDispatch(actions.getVmGroups())
+ getVmGroup: (id) => unwrapDispatch(actions.getVmGroup({ id })),
+ getVmGroups: () => unwrapDispatch(actions.getVmGroups()),
}
}
diff --git a/src/fireedge/src/client/features/One/vmGroup/services.js b/src/fireedge/src/client/features/One/vmGroup/services.js
index 43c9ae87cc..b2bf19bb3d 100644
--- a/src/fireedge/src/client/features/One/vmGroup/services.js
+++ b/src/fireedge/src/client/features/One/vmGroup/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/vmgroup'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const vmGroupService = ({
+export const vmGroupService = {
/**
* Retrieves information for the VM group.
*
@@ -27,7 +27,7 @@ export const vmGroupService = ({
* @returns {object} Get VM group identified by id
* @throws Fails when response isn't code 200
*/
- getVmGroup: async params => {
+ getVmGroup: async (params) => {
const name = Actions.VM_GROUP_INFO
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -60,5 +60,5 @@ export const vmGroupService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.VM_GROUP_POOL?.VM_GROUP ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/vmTemplate/actions.js b/src/fireedge/src/client/features/One/vmTemplate/actions.js
index 2813e4cf48..7bb29d6a46 100644
--- a/src/fireedge/src/client/features/One/vmTemplate/actions.js
+++ b/src/fireedge/src/client/features/One/vmTemplate/actions.js
@@ -28,16 +28,40 @@ export const getVmTemplate = createAction(
export const getVmTemplates = createAction(
`${TEMPLATE}/pool`,
vmTemplateService.getVmTemplates,
- response => ({ [RESOURCES.template]: response })
+ (response) => ({ [RESOURCES.template]: response })
)
-export const instantiate = createAction(`${TEMPLATE}/instantiate`, vmTemplateService.instantiate)
-export const allocate = createAction(`${TEMPLATE}/allocate`, vmTemplateService.allocate)
+export const instantiate = createAction(
+ `${TEMPLATE}/instantiate`,
+ vmTemplateService.instantiate
+)
+export const allocate = createAction(
+ `${TEMPLATE}/allocate`,
+ vmTemplateService.allocate
+)
export const clone = createAction(`${TEMPLATE}/clone`, vmTemplateService.clone)
-export const remove = createAction(`${TEMPLATE}/delete`, vmTemplateService.delete)
-export const update = createAction(`${TEMPLATE}/update`, vmTemplateService.update)
-export const changePermissions = createAction(`${TEMPLATE}/chmod`, vmTemplateService.changePermissions)
-export const changeOwnership = createAction(`${TEMPLATE}/chown`, vmTemplateService.changeOwnership)
-export const rename = createAction(`${TEMPLATE}/rename`, vmTemplateService.rename)
+export const remove = createAction(
+ `${TEMPLATE}/delete`,
+ vmTemplateService.delete
+)
+export const update = createAction(
+ `${TEMPLATE}/update`,
+ vmTemplateService.update
+)
+export const changePermissions = createAction(
+ `${TEMPLATE}/chmod`,
+ vmTemplateService.changePermissions
+)
+export const changeOwnership = createAction(
+ `${TEMPLATE}/chown`,
+ vmTemplateService.changeOwnership
+)
+export const rename = createAction(
+ `${TEMPLATE}/rename`,
+ vmTemplateService.rename
+)
export const lock = createAction(`${TEMPLATE}/lock`, vmTemplateService.lock)
-export const unlock = createAction(`${TEMPLATE}/unlock`, vmTemplateService.unlock)
+export const unlock = createAction(
+ `${TEMPLATE}/unlock`,
+ vmTemplateService.unlock
+)
diff --git a/src/fireedge/src/client/features/One/vmTemplate/hooks.js b/src/fireedge/src/client/features/One/vmTemplate/hooks.js
index ad4fbd55bd..22be0590eb 100644
--- a/src/fireedge/src/client/features/One/vmTemplate/hooks.js
+++ b/src/fireedge/src/client/features/One/vmTemplate/hooks.js
@@ -21,23 +21,24 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/vmTemplate/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useVmTemplate = () => (
- useSelector(state => state[name]?.[RESOURCES.template] ?? [])
-)
+export const useVmTemplate = () =>
+ useSelector((state) => state[name]?.[RESOURCES.template] ?? [])
export const useVmTemplateApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getVmTemplate: (id, data) => unwrapDispatch(actions.getVmTemplate({ id, ...data })),
+ getVmTemplate: (id, data) =>
+ unwrapDispatch(actions.getVmTemplate({ id, ...data })),
getVmTemplates: () => unwrapDispatch(actions.getVmTemplates()),
- instantiate: (id, data) => unwrapDispatch(actions.instantiate({ id, ...data })),
- allocate: template => unwrapDispatch(actions.allocate({ template })),
+ instantiate: (id, data) =>
+ unwrapDispatch(actions.instantiate({ id, ...data })),
+ allocate: (template) => unwrapDispatch(actions.allocate({ template })),
clone: (id, data) => unwrapDispatch(actions.clone({ id, ...data })),
remove: (id, image) => unwrapDispatch(actions.remove({ id, image })),
update: (id, template, replace) =>
@@ -48,6 +49,6 @@ export const useVmTemplateApi = () => {
unwrapDispatch(actions.changeOwnership({ id, ownership })),
rename: (id, name) => unwrapDispatch(actions.rename({ id, name })),
lock: (id, data) => unwrapDispatch(actions.lock({ id, ...data })),
- unlock: id => unwrapDispatch(actions.unlock({ id }))
+ unlock: (id) => unwrapDispatch(actions.unlock({ id })),
}
}
diff --git a/src/fireedge/src/client/features/One/vmTemplate/services.js b/src/fireedge/src/client/features/One/vmTemplate/services.js
index 1a08b2b390..3c4cf6821c 100644
--- a/src/fireedge/src/client/features/One/vmTemplate/services.js
+++ b/src/fireedge/src/client/features/One/vmTemplate/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/template'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const vmTemplateService = ({
+export const vmTemplateService = {
/**
* Retrieves information for the vm template.
*
@@ -28,7 +28,7 @@ export const vmTemplateService = ({
* @returns {object} Get template identified by id
* @throws Fails when response isn't code 200
*/
- getVmTemplate: async params => {
+ getVmTemplate: async (params) => {
const name = Actions.TEMPLATE_INFO
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -51,7 +51,7 @@ export const vmTemplateService = ({
* @returns {Array} List of VM templates
* @throws Fails when response isn't code 200
*/
- getVmTemplates: async params => {
+ getVmTemplates: async (params) => {
const name = Actions.TEMPLATE_POOL_INFO
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -71,7 +71,7 @@ export const vmTemplateService = ({
* @returns {number} Template id
* @throws Fails when response isn't code 200
*/
- allocate: async params => {
+ allocate: async (params) => {
const name = Actions.TEMPLATE_ALLOCATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -95,7 +95,7 @@ export const vmTemplateService = ({
* @returns {number} Template id
* @throws Fails when response isn't code 200
*/
- clone: async params => {
+ clone: async (params) => {
const name = Actions.TEMPLATE_CLONE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -117,7 +117,7 @@ export const vmTemplateService = ({
* @returns {number} Template id
* @throws Fails when response isn't code 200
*/
- delete: async params => {
+ delete: async (params) => {
const name = Actions.TEMPLATE_DELETE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -142,7 +142,7 @@ export const vmTemplateService = ({
* @returns {number} Template id
* @throws Fails when response isn't code 200
*/
- update: async params => {
+ update: async (params) => {
const name = Actions.TEMPLATE_UPDATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -217,7 +217,7 @@ export const vmTemplateService = ({
* @returns {number} Template id
* @throws Fails when response isn't code 200
*/
- rename: async params => {
+ rename: async (params) => {
const name = Actions.TEMPLATE_RENAME
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -244,7 +244,7 @@ export const vmTemplateService = ({
* @returns {number} Template id
* @throws Fails when response isn't code 200
*/
- lock: async params => {
+ lock: async (params) => {
const name = Actions.TEMPLATE_LOCK
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -264,7 +264,7 @@ export const vmTemplateService = ({
* @returns {number} Template id
* @throws Fails when response isn't code 200
*/
- unlock: async params => {
+ unlock: async (params) => {
const name = Actions.TEMPLATE_UNLOCK
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -288,7 +288,7 @@ export const vmTemplateService = ({
* @returns {number} Template id
* @throws Fails when response isn't code 200
*/
- instantiate: async params => {
+ instantiate: async (params) => {
const name = Actions.TEMPLATE_INSTANTIATE
const command = { name, ...Commands[name] }
const config = requestConfig(params, command)
@@ -298,5 +298,5 @@ export const vmTemplateService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return res?.data
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/vnetwork/actions.js b/src/fireedge/src/client/features/One/vnetwork/actions.js
index 54b6c63f2e..3370aaebda 100644
--- a/src/fireedge/src/client/features/One/vnetwork/actions.js
+++ b/src/fireedge/src/client/features/One/vnetwork/actions.js
@@ -28,5 +28,5 @@ export const getVNetwork = createAction(
export const getVNetworks = createAction(
`${VNET}/pool`,
vNetworkService.getVNetworks,
- response => ({ [RESOURCES.vn]: response })
+ (response) => ({ [RESOURCES.vn]: response })
)
diff --git a/src/fireedge/src/client/features/One/vnetwork/hooks.js b/src/fireedge/src/client/features/One/vnetwork/hooks.js
index 59ab64b80c..e924f95e4c 100644
--- a/src/fireedge/src/client/features/One/vnetwork/hooks.js
+++ b/src/fireedge/src/client/features/One/vnetwork/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/vnetwork/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useVNetwork = () => (
- useSelector(state => state[name]?.[RESOURCES.vn] ?? [])
-)
+export const useVNetwork = () =>
+ useSelector((state) => state[name]?.[RESOURCES.vn] ?? [])
export const useVNetworkApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getVNetwork: id => unwrapDispatch(actions.getVNetwork({ id })),
- getVNetworks: () => unwrapDispatch(actions.getVNetworks())
+ getVNetwork: (id) => unwrapDispatch(actions.getVNetwork({ id })),
+ getVNetworks: () => unwrapDispatch(actions.getVNetworks()),
}
}
diff --git a/src/fireedge/src/client/features/One/vnetwork/services.js b/src/fireedge/src/client/features/One/vnetwork/services.js
index 923bb648ea..eaee6e404b 100644
--- a/src/fireedge/src/client/features/One/vnetwork/services.js
+++ b/src/fireedge/src/client/features/One/vnetwork/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/vn'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const vNetworkService = ({
+export const vNetworkService = {
/**
* Retrieves information for the virtual network.
*
@@ -59,5 +59,5 @@ export const vNetworkService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.VNET_POOL?.VNET ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/vnetworkTemplate/actions.js b/src/fireedge/src/client/features/One/vnetworkTemplate/actions.js
index cf56f102f3..d577d987eb 100644
--- a/src/fireedge/src/client/features/One/vnetworkTemplate/actions.js
+++ b/src/fireedge/src/client/features/One/vnetworkTemplate/actions.js
@@ -28,5 +28,5 @@ export const getVNetworkTemplate = createAction(
export const getVNetworkTemplates = createAction(
`${VNET_TEMPLATE}/pool`,
vNetworkTemplateService.getVNetworkTemplates,
- response => ({ [RESOURCES.vntemplate]: response })
+ (response) => ({ [RESOURCES.vntemplate]: response })
)
diff --git a/src/fireedge/src/client/features/One/vnetworkTemplate/hooks.js b/src/fireedge/src/client/features/One/vnetworkTemplate/hooks.js
index 01bc6c8efb..6e395f331c 100644
--- a/src/fireedge/src/client/features/One/vnetworkTemplate/hooks.js
+++ b/src/fireedge/src/client/features/One/vnetworkTemplate/hooks.js
@@ -21,20 +21,20 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/vnetworkTemplate/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useVNetworkTemplate = () => (
- useSelector(state => state[name]?.[RESOURCES.vntemplate] ?? [])
-)
+export const useVNetworkTemplate = () =>
+ useSelector((state) => state[name]?.[RESOURCES.vntemplate] ?? [])
export const useVNetworkTemplateApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getVNetworkTemplate: id => unwrapDispatch(actions.getVNetworkTemplate({ id })),
- getVNetworkTemplates: () => unwrapDispatch(actions.getVNetworkTemplates())
+ getVNetworkTemplate: (id) =>
+ unwrapDispatch(actions.getVNetworkTemplate({ id })),
+ getVNetworkTemplates: () => unwrapDispatch(actions.getVNetworkTemplates()),
}
}
diff --git a/src/fireedge/src/client/features/One/vnetworkTemplate/services.js b/src/fireedge/src/client/features/One/vnetworkTemplate/services.js
index 51df10f194..66c48c8fb8 100644
--- a/src/fireedge/src/client/features/One/vnetworkTemplate/services.js
+++ b/src/fireedge/src/client/features/One/vnetworkTemplate/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/vntemplate'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const vNetworkTemplateService = ({
+export const vNetworkTemplateService = {
/**
* Retrieves information for the virtual network template.
*
@@ -59,5 +59,5 @@ export const vNetworkTemplateService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.VNTEMPLATE_POOL?.VNTEMPLATE ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/vrouter/actions.js b/src/fireedge/src/client/features/One/vrouter/actions.js
index a5f58f5b34..1f33ea11bf 100644
--- a/src/fireedge/src/client/features/One/vrouter/actions.js
+++ b/src/fireedge/src/client/features/One/vrouter/actions.js
@@ -28,5 +28,5 @@ export const getVRouter = createAction(
export const getVRouters = createAction(
`${VROUTER}/pool`,
vRouterService.getVRouters,
- response => ({ [RESOURCES.vrouter]: response })
+ (response) => ({ [RESOURCES.vrouter]: response })
)
diff --git a/src/fireedge/src/client/features/One/vrouter/hooks.js b/src/fireedge/src/client/features/One/vrouter/hooks.js
index fbfbcad6ef..b15fced304 100644
--- a/src/fireedge/src/client/features/One/vrouter/hooks.js
+++ b/src/fireedge/src/client/features/One/vrouter/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/vrouter/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useVRouter = () => (
- useSelector(state => state[name]?.[RESOURCES.vrouter] ?? [])
-)
+export const useVRouter = () =>
+ useSelector((state) => state[name]?.[RESOURCES.vrouter] ?? [])
export const useVRouterApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getVRouter: id => unwrapDispatch(actions.getVRouter({ id })),
- getVRouters: () => unwrapDispatch(actions.getVRouters())
+ getVRouter: (id) => unwrapDispatch(actions.getVRouter({ id })),
+ getVRouters: () => unwrapDispatch(actions.getVRouters()),
}
}
diff --git a/src/fireedge/src/client/features/One/vrouter/services.js b/src/fireedge/src/client/features/One/vrouter/services.js
index 79e45bee0f..f5addf3e72 100644
--- a/src/fireedge/src/client/features/One/vrouter/services.js
+++ b/src/fireedge/src/client/features/One/vrouter/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/vrouter'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const vRouterService = ({
+export const vRouterService = {
/**
* Retrieves information for the virtual router.
*
@@ -59,5 +59,5 @@ export const vRouterService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.VROUTER_POOL?.VROUTER ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/features/One/zone/actions.js b/src/fireedge/src/client/features/One/zone/actions.js
index 4ab70ec5fa..8cab4e76be 100644
--- a/src/fireedge/src/client/features/One/zone/actions.js
+++ b/src/fireedge/src/client/features/One/zone/actions.js
@@ -20,13 +20,10 @@ import { RESOURCES } from 'client/features/One/slice'
/** @see {@link RESOURCES.zone} */
const ZONE = 'zone'
-export const getZone = createAction(
- `${ZONE}/detail`,
- zoneService.getZone
-)
+export const getZone = createAction(`${ZONE}/detail`, zoneService.getZone)
export const getZones = createAction(
`${ZONE}/pool`,
zoneService.getZones,
- response => ({ [RESOURCES.zone]: response })
+ (response) => ({ [RESOURCES.zone]: response })
)
diff --git a/src/fireedge/src/client/features/One/zone/hooks.js b/src/fireedge/src/client/features/One/zone/hooks.js
index 188bee4abc..74a03ad82d 100644
--- a/src/fireedge/src/client/features/One/zone/hooks.js
+++ b/src/fireedge/src/client/features/One/zone/hooks.js
@@ -21,20 +21,19 @@ import { unwrapResult } from '@reduxjs/toolkit'
import * as actions from 'client/features/One/zone/actions'
import { name, RESOURCES } from 'client/features/One/slice'
-export const useZone = () => (
- useSelector(state => state[name]?.[RESOURCES.zone] ?? [])
-)
+export const useZone = () =>
+ useSelector((state) => state[name]?.[RESOURCES.zone] ?? [])
export const useZoneApi = () => {
const dispatch = useDispatch()
const unwrapDispatch = useCallback(
- action => dispatch(action).then(unwrapResult)
- , [dispatch]
+ (action) => dispatch(action).then(unwrapResult),
+ [dispatch]
)
return {
- getZone: id => unwrapDispatch(actions.getZone({ id })),
- getZones: () => unwrapDispatch(actions.getZones())
+ getZone: (id) => unwrapDispatch(actions.getZone({ id })),
+ getZones: () => unwrapDispatch(actions.getZones()),
}
}
diff --git a/src/fireedge/src/client/features/One/zone/services.js b/src/fireedge/src/client/features/One/zone/services.js
index d105637f77..165a9245cf 100644
--- a/src/fireedge/src/client/features/One/zone/services.js
+++ b/src/fireedge/src/client/features/One/zone/services.js
@@ -17,7 +17,7 @@ import { Actions, Commands } from 'server/utils/constants/commands/zone'
import { httpCodes } from 'server/utils/constants'
import { requestConfig, RestClient } from 'client/utils'
-export const zoneService = ({
+export const zoneService = {
/**
* Retrieves information for the zone.
*
@@ -54,5 +54,5 @@ export const zoneService = ({
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return [res?.data?.ZONE_POOL?.ZONE ?? []].flat()
- }
-})
+ },
+}
diff --git a/src/fireedge/src/client/hooks/index.js b/src/fireedge/src/client/hooks/index.js
index a8f8286cb6..661db0c020 100644
--- a/src/fireedge/src/client/hooks/index.js
+++ b/src/fireedge/src/client/hooks/index.js
@@ -33,6 +33,5 @@ export {
useNearScreen,
useSearch,
useSocket,
-
- CLIPBOARD_STATUS
+ CLIPBOARD_STATUS,
}
diff --git a/src/fireedge/src/client/hooks/useClipboard.js b/src/fireedge/src/client/hooks/useClipboard.js
index 7a65640a48..5ec04b9bd6 100644
--- a/src/fireedge/src/client/hooks/useClipboard.js
+++ b/src/fireedge/src/client/hooks/useClipboard.js
@@ -20,7 +20,7 @@ import { useMemo, useState } from 'react'
export const CLIPBOARD_STATUS = {
INIT: 'INIT',
ERROR: 'ERROR',
- COPIED: 'COPIED'
+ COPIED: 'COPIED',
}
const { INIT, ERROR, COPIED } = CLIPBOARD_STATUS
@@ -48,7 +48,7 @@ const useClipboard = ({ tooltipDelay = 2000 } = {}) => {
const [state, setState] = useState(() => INIT)
const isCopied = useMemo(() => state === COPIED, [state])
- const copy = async text => {
+ const copy = async (text) => {
try {
// Use the Async Clipboard API when available.
// Requires a secure browsing context (i.e. HTTPS)
diff --git a/src/fireedge/src/client/hooks/useDialog.js b/src/fireedge/src/client/hooks/useDialog.js
index c32fed652f..82d7a1ab24 100644
--- a/src/fireedge/src/client/hooks/useDialog.js
+++ b/src/fireedge/src/client/hooks/useDialog.js
@@ -15,7 +15,10 @@
* ------------------------------------------------------------------------- */
import { useState } from 'react'
-const callAll = (...fns) => (...args) => fns.forEach(fn => fn && fn?.(...args))
+const callAll =
+ (...fns) =>
+ (...args) =>
+ fns.forEach((fn) => fn && fn?.(...args))
/**
* Hook to manage a dialog.
@@ -34,9 +37,9 @@ const useDialog = () => {
const [display, setDisplay] = useState(false)
const [values, setValues] = useState(null)
- const toggle = () => setDisplay(prev => !prev)
+ const toggle = () => setDisplay((prev) => !prev)
- const show = newValues => {
+ const show = (newValues) => {
setDisplay(true)
newValues && setValues(newValues)
}
@@ -50,7 +53,7 @@ const useDialog = () => {
'aria-controls': 'target',
'aria-expanded': Boolean(display),
...props,
- onClick: callAll(props.onClick, toggle)
+ onClick: callAll(props.onClick, toggle),
})
const getContainerProps = (props = {}) => ({
@@ -59,7 +62,7 @@ const useDialog = () => {
onKeyDown: callAll(
props.onKeyDown,
({ keyCode }) => keyCode === 27 && hide()
- )
+ ),
})
return {
@@ -69,7 +72,7 @@ const useDialog = () => {
hide,
toggle,
getToggleProps,
- getContainerProps
+ getContainerProps,
}
}
diff --git a/src/fireedge/src/client/hooks/useFetch.js b/src/fireedge/src/client/hooks/useFetch.js
index 3a91a31f05..ca81b10800 100644
--- a/src/fireedge/src/client/hooks/useFetch.js
+++ b/src/fireedge/src/client/hooks/useFetch.js
@@ -13,21 +13,28 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { useReducer, useCallback, useEffect, useRef, ReducerState, ReducerAction } from 'react'
+import {
+ useReducer,
+ useCallback,
+ useEffect,
+ useRef,
+ ReducerState,
+ ReducerAction,
+} from 'react'
import { fakeDelay, isDevelopment } from 'client/utils'
const STATUS = {
INIT: 'INIT',
PENDING: 'PENDING',
ERROR: 'ERROR',
- FETCHED: 'FETCHED'
+ FETCHED: 'FETCHED',
}
/** @enum {string} Type of action */
const ACTIONS = {
REQUEST: 'REQUEST',
SUCCESS: 'SUCCESS',
- FAILURE: 'FAILURE'
+ FAILURE: 'FAILURE',
}
const INITIAL_STATE = {
@@ -35,7 +42,7 @@ const INITIAL_STATE = {
error: undefined,
data: undefined,
loading: false,
- reloading: false
+ reloading: false,
}
/**
@@ -47,25 +54,27 @@ const fetchReducer = (state, action) => {
const { type, payload, reload = false } = action
const { data: currentData } = state
- return {
- [ACTIONS.REQUEST]: {
- ...INITIAL_STATE,
- status: STATUS.PENDING,
- data: currentData,
- [reload ? 'reloading' : 'loading']: true
- },
- [ACTIONS.SUCCESS]: {
- ...INITIAL_STATE,
- status: STATUS.FETCHED,
- data: payload
- },
- [ACTIONS.FAILURE]: {
- ...INITIAL_STATE,
- status: STATUS.ERROR,
- data: currentData,
- error: payload
- }
- }[type] ?? state
+ return (
+ {
+ [ACTIONS.REQUEST]: {
+ ...INITIAL_STATE,
+ status: STATUS.PENDING,
+ data: currentData,
+ [reload ? 'reloading' : 'loading']: true,
+ },
+ [ACTIONS.SUCCESS]: {
+ ...INITIAL_STATE,
+ status: STATUS.FETCHED,
+ data: payload,
+ },
+ [ACTIONS.FAILURE]: {
+ ...INITIAL_STATE,
+ status: STATUS.ERROR,
+ data: currentData,
+ error: payload,
+ },
+ }[type] ?? state
+ )
}
/**
@@ -93,11 +102,13 @@ const useFetch = (request, socket) => {
const isFetched = state.data !== undefined && state.status === STATUS.FETCHED
useEffect(() => {
- isFetched && socket?.connect({
- dataFromFetch: state.data,
- callback: socketData =>
- socketData && dispatch({ type: ACTIONS.SUCCESS, payload: socketData })
- })
+ isFetched &&
+ socket?.connect({
+ dataFromFetch: state.data,
+ callback: (socketData) =>
+ socketData &&
+ dispatch({ type: ACTIONS.SUCCESS, payload: socketData }),
+ })
return () => {
socket?.disconnect()
@@ -112,28 +123,31 @@ const useFetch = (request, socket) => {
}
}, [])
- const doFetch = useCallback(async (payload, reload = false) => {
- try {
- dispatch({ type: ACTIONS.REQUEST, reload })
+ const doFetch = useCallback(
+ async (payload, reload = false) => {
+ try {
+ dispatch({ type: ACTIONS.REQUEST, reload })
- const response = await request(payload)
+ const response = await request(payload)
- if (response === undefined) throw response
- if (cancelRequest.current) return
+ if (response === undefined) throw response
+ if (cancelRequest.current) return
- dispatch({ type: ACTIONS.SUCCESS, payload: response })
+ dispatch({ type: ACTIONS.SUCCESS, payload: response })
- return response
- } catch (error) {
- if (cancelRequest.current) return
+ return response
+ } catch (error) {
+ if (cancelRequest.current) return
- const errorMessage = typeof error === 'string' ? error : error?.message
+ const errorMessage = typeof error === 'string' ? error : error?.message
- dispatch({ type: ACTIONS.FAILURE, payload: errorMessage })
+ dispatch({ type: ACTIONS.FAILURE, payload: errorMessage })
- return error
- }
- }, [request, cancelRequest.current, dispatch])
+ return error
+ }
+ },
+ [request, cancelRequest.current, dispatch]
+ )
const fetchRequest = useCallback(
/**
@@ -148,14 +162,18 @@ const useFetch = (request, socket) => {
const { reload = false, delay = 0 } = options
if (!(Number.isInteger(delay) && delay >= 0)) {
- isDevelopment() && console.error(`
+ isDevelopment() &&
+ console.error(`
Delay must be a number >= 0!
If you're using it as a function, it must also return a number >= 0.`)
}
await fakeDelay(delay)
+
return await doFetch(payload, reload)
- }, [request])
+ },
+ [request]
+ )
return { ...state, fetchRequest, STATUS }
}
diff --git a/src/fireedge/src/client/hooks/useFetchAll.js b/src/fireedge/src/client/hooks/useFetchAll.js
index 5446f27158..79a946ff50 100644
--- a/src/fireedge/src/client/hooks/useFetchAll.js
+++ b/src/fireedge/src/client/hooks/useFetchAll.js
@@ -13,21 +13,28 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { useReducer, useCallback, useEffect, useRef, ReducerState, ReducerAction } from 'react'
+import {
+ useReducer,
+ useCallback,
+ useEffect,
+ useRef,
+ ReducerState,
+ ReducerAction,
+} from 'react'
import { fakeDelay, isDevelopment } from 'client/utils'
const STATUS = {
INIT: 'INIT',
PENDING: 'PENDING',
ERROR: 'ERROR',
- FETCHED: 'FETCHED'
+ FETCHED: 'FETCHED',
}
/** @enum {string} Type of action */
const ACTIONS = {
REQUEST: 'REQUEST',
SUCCESS: 'SUCCESS',
- FAILURE: 'FAILURE'
+ FAILURE: 'FAILURE',
}
const INITIAL_STATE = {
@@ -35,7 +42,7 @@ const INITIAL_STATE = {
error: undefined,
data: undefined,
loading: false,
- reloading: false
+ reloading: false,
}
/**
@@ -47,25 +54,27 @@ const fetchReducer = (state, action) => {
const { type, payload, reload = false } = action
const { data: currentData } = state
- return {
- [ACTIONS.REQUEST]: {
- ...INITIAL_STATE,
- status: STATUS.PENDING,
- data: currentData,
- [reload ? 'reloading' : 'loading']: true
- },
- [ACTIONS.SUCCESS]: {
- ...INITIAL_STATE,
- status: STATUS.FETCHED,
- data: payload
- },
- [ACTIONS.FAILURE]: {
- ...INITIAL_STATE,
- status: STATUS.ERROR,
- data: currentData,
- error: payload
- }
- }[type] ?? state
+ return (
+ {
+ [ACTIONS.REQUEST]: {
+ ...INITIAL_STATE,
+ status: STATUS.PENDING,
+ data: currentData,
+ [reload ? 'reloading' : 'loading']: true,
+ },
+ [ACTIONS.SUCCESS]: {
+ ...INITIAL_STATE,
+ status: STATUS.FETCHED,
+ data: payload,
+ },
+ [ACTIONS.FAILURE]: {
+ ...INITIAL_STATE,
+ status: STATUS.ERROR,
+ data: currentData,
+ error: payload,
+ },
+ }[type] ?? state
+ )
}
/**
@@ -86,9 +95,12 @@ const useFetchAll = () => {
const cancelRequest = useRef(false)
const [state, dispatch] = useReducer(fetchReducer, INITIAL_STATE)
- useEffect(() => () => {
- cancelRequest.current = true
- }, [])
+ useEffect(
+ () => () => {
+ cancelRequest.current = true
+ },
+ []
+ )
const doFetches = async (requests, reload = false) => {
try {
@@ -126,14 +138,18 @@ const useFetchAll = () => {
const { reload = false, delay = 0 } = options
if (!(Number.isInteger(delay) && delay >= 0)) {
- isDevelopment() && console.error(`
+ isDevelopment() &&
+ console.error(`
Delay must be a number >= 0!
If you're using it as a function, it must also return a number >= 0.`)
}
await fakeDelay(delay)
+
return await doFetches(requests, reload)
- }, [])
+ },
+ []
+ )
return { ...state, fetchRequestAll, STATUS }
}
diff --git a/src/fireedge/src/client/hooks/useList.js b/src/fireedge/src/client/hooks/useList.js
index b87ae26748..ebf4288171 100644
--- a/src/fireedge/src/client/hooks/useList.js
+++ b/src/fireedge/src/client/hooks/useList.js
@@ -60,13 +60,13 @@ const useList = ({ list, initLength }) => {
fakeDelay(500)
.then(() =>
- setShortList(prev => prev.concat(fullList.slice(prev.length, length)))
+ setShortList((prev) => prev.concat(fullList.slice(prev.length, length)))
)
.then(() => setLoadingNextPage(false))
.then(() => setFinish(shortList.length >= fullList.length))
}, [length, setLength])
- const reset = newList => {
+ const reset = (newList) => {
/* RESET VALUES */
setLength(initLength)
setFullList(newList)
@@ -79,12 +79,12 @@ const useList = ({ list, initLength }) => {
useList.propTypes = {
list: PropTypes.arrayOf(PropTypes.object).isRequired,
- initLength: PropTypes.string
+ initLength: PropTypes.string,
}
useList.defaultProps = {
list: [],
- initLength: 50
+ initLength: 50,
}
export default useList
diff --git a/src/fireedge/src/client/hooks/useListForm.js b/src/fireedge/src/client/hooks/useListForm.js
index 9ac4ac8f62..d16d878cdc 100644
--- a/src/fireedge/src/client/hooks/useListForm.js
+++ b/src/fireedge/src/client/hooks/useListForm.js
@@ -70,11 +70,12 @@ import { set } from 'client/utils'
// ----------------------------------------------------------
const ZERO_DELETE_COUNT = 0
-const NEXT_INDEX = index => index + 1
-const EXISTS_INDEX = index => index !== -1
+const NEXT_INDEX = (index) => index + 1
+const EXISTS_INDEX = (index) => index !== -1
// parent ? [parent.id, index].join('.')
-const defaultGetItemId = item => typeof item === 'object' ? item?.id ?? item?.ID : item
+const defaultGetItemId = (item) =>
+ typeof item === 'object' ? item?.id ?? item?.ID : item
const defaultAddItemId = (item, id) => ({ ...item, id })
// ----------------------------------------------------------
@@ -113,7 +114,7 @@ const useListForm = ({
setList,
defaultValue,
getItemId = defaultGetItemId,
- addItemId = defaultAddItemId
+ addItemId = defaultAddItemId,
}) => {
const [editingData, setEditingData] = useState(() => undefined)
@@ -124,46 +125,43 @@ const useListForm = ({
)
const handleSetList = useCallback(
- newList => setList(
- data => {
+ (newList) =>
+ setList((data) => {
const path = parent ? [parent, key].join('.') : key
const newData = set({ ...data }, path, newList)
return parent ? { ...data, [parent]: newData } : { ...data, ...newData }
- }
- ),
+ }),
[key, parent, setList]
)
const handleSelect = useCallback(
- id => {
- setList(prevList => ({
+ (id) => {
+ setList((prevList) => ({
...prevList,
- [key]: multiple ? [...(prevList[key] ?? []), id] : [id]
+ [key]: multiple ? [...(prevList[key] ?? []), id] : [id],
}))
},
[key, setList, multiple]
)
const handleUnselect = useCallback(
- id => {
- const newList = [...list]
- ?.filter((item, idx) => getItemId(item, idx) !== id)
+ (id) => {
+ const newList = [...list]?.filter(
+ (item, idx) => getItemId(item, idx) !== id
+ )
handleSetList(newList)
},
[list, setList]
)
- const handleClear = useCallback(
- () => {
- setList(prevList => ({ ...prevList, [key]: [] }))
- },
- [key]
- )
+ const handleClear = useCallback(() => {
+ setList((prevList) => ({ ...prevList, [key]: [] }))
+ }, [key])
const handleClone = useCallback(
- id => {
+ (id) => {
const itemIndex = getIndexById(list, id)
const cloneItem = addItemId(list[itemIndex], undefined, itemIndex)
const cloneList = [...list]
@@ -182,9 +180,9 @@ const useListForm = ({
const itemIndex = getIndexById(list, id)
const index = EXISTS_INDEX(itemIndex) ? itemIndex : list.length
- const newList = Object.assign([], [...list],
- { [index]: getItemId(values) ? values : addItemId(values, id, index) }
- )
+ const newList = Object.assign([], [...list], {
+ [index]: getItemId(values) ? values : addItemId(values, id, index),
+ })
handleSetList(newList)
},
@@ -192,7 +190,7 @@ const useListForm = ({
)
const handleEdit = useCallback(
- id => {
+ (id) => {
const index = getIndexById(list, id)
const openData = list[index] ?? defaultValue
@@ -212,7 +210,7 @@ const useListForm = ({
handleSetList,
handleSave,
- handleEdit
+ handleEdit,
}
}
diff --git a/src/fireedge/src/client/hooks/useNearScreen.js b/src/fireedge/src/client/hooks/useNearScreen.js
index f8964a1bc8..4ae1fc2c01 100644
--- a/src/fireedge/src/client/hooks/useNearScreen.js
+++ b/src/fireedge/src/client/hooks/useNearScreen.js
@@ -36,15 +36,17 @@ const useNearScreen = ({ externalRef, distance, once = true }) => {
let observer
const element = externalRef ? externalRef.current : fromRef.current
- const onChange = entries => {
- observer && element && entries.forEach(({ isIntersecting }) => {
- if (isIntersecting) {
- setShow(true)
- once && observer.disconnect()
- } else {
- !once && setShow(false)
- }
- })
+ const onChange = (entries) => {
+ observer &&
+ element &&
+ entries.forEach(({ isIntersecting }) => {
+ if (isIntersecting) {
+ setShow(true)
+ once && observer.disconnect()
+ } else {
+ !once && setShow(false)
+ }
+ })
}
Promise.resolve(
@@ -53,7 +55,7 @@ const useNearScreen = ({ externalRef, distance, once = true }) => {
: import('intersection-observer')
).then(() => {
observer = new IntersectionObserver(onChange, {
- rootMargin: distance
+ rootMargin: distance,
})
if (element) observer.observe(element)
diff --git a/src/fireedge/src/client/hooks/useSearch.js b/src/fireedge/src/client/hooks/useSearch.js
index f948d92c64..19caf6894e 100644
--- a/src/fireedge/src/client/hooks/useSearch.js
+++ b/src/fireedge/src/client/hooks/useSearch.js
@@ -35,12 +35,13 @@ const useSearch = ({ list, listOptions }) => {
const [result, setResult] = useState(undefined)
const listFuse = useMemo(
- () => new Fuse(list, listOptions, Fuse.createIndex(listOptions?.keys, list)),
+ () =>
+ new Fuse(list, listOptions, Fuse.createIndex(listOptions?.keys, list)),
[list, listOptions]
)
const debounceResult = useCallback(
- debounce(value => {
+ debounce((value) => {
const search = listFuse.search(value)?.map(({ item }) => item)
setResult(value ? search : undefined)
@@ -48,7 +49,7 @@ const useSearch = ({ list, listOptions }) => {
[list]
)
- const handleChange = event => {
+ const handleChange = (event) => {
const { value: nextValue } = event?.target
setQuery(nextValue)
diff --git a/src/fireedge/src/client/hooks/useSocket.js b/src/fireedge/src/client/hooks/useSocket.js
index 510913b00b..6a18b61684 100644
--- a/src/fireedge/src/client/hooks/useSocket.js
+++ b/src/fireedge/src/client/hooks/useSocket.js
@@ -21,16 +21,20 @@ import { WEBSOCKET_URL, SOCKETS } from 'client/constants'
import { useAuth } from 'client/features/Auth'
import { useGeneral } from 'client/features/General'
-import { eventUpdateResourceState, getResourceFromEventState } from 'client/features/One/socket/actions'
+import {
+ eventUpdateResourceState,
+ getResourceFromEventState,
+} from 'client/features/One/socket/actions'
import { updateResourceFromFetch } from 'client/features/One/actions'
-const createWebsocket = (path, query) => socketIO({
- path: `${WEBSOCKET_URL}/${path}`,
- query,
- autoConnect: false,
- timeout: 10_000,
- reconnectionAttempts: 5
-})
+const createWebsocket = (path, query) =>
+ socketIO({
+ path: `${WEBSOCKET_URL}/${path}`,
+ query,
+ autoConnect: false,
+ timeout: 10_000,
+ reconnectionAttempts: 5,
+ })
/**
* Hook to manage the OpenNebula sockets.
@@ -51,51 +55,59 @@ const useSocket = () => {
* @returns {{ connect: Function, disconnect: Function }}
* - Functions to manage the socket connections
*/
- const getHooksSocket = useCallback(({ resource, id }) => {
- const socket = createWebsocket(
- SOCKETS.HOOKS,
- { token: jwt, zone, resource, id }
- )
+ const getHooksSocket = useCallback(
+ ({ resource, id }) => {
+ const socket = createWebsocket(SOCKETS.HOOKS, {
+ token: jwt,
+ zone,
+ resource,
+ id,
+ })
- return {
- connect: ({ dataFromFetch, callback }) => {
- dataFromFetch && socket.on(SOCKETS.CONNECT, () => {
- // update redux state from data fetched
- dispatch(updateResourceFromFetch({ data: dataFromFetch, resource }))
- })
+ return {
+ connect: ({ dataFromFetch, callback }) => {
+ dataFromFetch &&
+ socket.on(SOCKETS.CONNECT, () => {
+ // update redux state from data fetched
+ dispatch(
+ updateResourceFromFetch({ data: dataFromFetch, resource })
+ )
+ })
- socket.on(SOCKETS.HOOKS, ({ data } = {}) => {
- // update the list on redux state
- dispatch(eventUpdateResourceState(data))
- // return data from event
- callback(getResourceFromEventState(data).value)
- })
+ socket.on(SOCKETS.HOOKS, ({ data } = {}) => {
+ // update the list on redux state
+ dispatch(eventUpdateResourceState(data))
+ // return data from event
+ callback(getResourceFromEventState(data).value)
+ })
- socket.connect()
- },
- disconnect: () => socket.connected && socket.disconnect()
- }
- }, [jwt, zone])
+ socket.connect()
+ },
+ disconnect: () => socket.connected && socket.disconnect(),
+ }
+ },
+ [jwt, zone]
+ )
/**
* @param {Function} callback - Callback from socket
* @returns {{ on: Function, off: Function }}
* - Functions to manage the socket connections
*/
- const getProvisionSocket = useCallback(callback => {
+ const getProvisionSocket = useCallback((callback) => {
const socket = createWebsocket(SOCKETS.PROVISION, { token: jwt, zone })
socket.on(SOCKETS.PROVISION, callback)
return {
on: () => socket.connect(),
- off: () => socket.disconnect()
+ off: () => socket.disconnect(),
}
}, [])
return {
getHooksSocket,
- getProvisionSocket
+ getProvisionSocket,
}
}
diff --git a/src/fireedge/src/client/models/Datastore.js b/src/fireedge/src/client/models/Datastore.js
index 7f59fb859c..6303217554 100644
--- a/src/fireedge/src/client/models/Datastore.js
+++ b/src/fireedge/src/client/models/Datastore.js
@@ -61,10 +61,12 @@ export const getDeployMode = (datastore = {}) => {
* }} - Datastore used percentage and label.
*/
export const getCapacityInfo = ({ TOTAL_MB, USED_MB } = {}) => {
- const percentOfUsed = +USED_MB * 100 / +TOTAL_MB || 0
+ const percentOfUsed = (+USED_MB * 100) / +TOTAL_MB || 0
const usedBytes = prettyBytes(+USED_MB, 'MB')
const totalBytes = prettyBytes(+TOTAL_MB, 'MB')
- const percentLabel = `${usedBytes} / ${totalBytes} (${Math.round(percentOfUsed)}%)`
+ const percentLabel = `${usedBytes} / ${totalBytes} (${Math.round(
+ percentOfUsed
+ )}%)`
return { percentOfUsed, percentLabel }
}
@@ -79,8 +81,11 @@ export const getCapacityInfo = ({ TOTAL_MB, USED_MB } = {}) => {
*/
export const isMarketExportSupport = ({ NAME } = {}, oneConfig) => {
// When in doubt, allow the action and let oned return failure
- return !NAME || oneConfig?.DS_MAD_CONF?.some(dsMad => (
- dsMad?.NAME === NAME &&
- dsMad?.MARKETPLACE_ACTIONS?.includes?.('export')
- ))
+ return (
+ !NAME ||
+ oneConfig?.DS_MAD_CONF?.some(
+ (dsMad) =>
+ dsMad?.NAME === NAME && dsMad?.MARKETPLACE_ACTIONS?.includes?.('export')
+ )
+ )
}
diff --git a/src/fireedge/src/client/models/Helper.js b/src/fireedge/src/client/models/Helper.js
index e0505c0697..8a8e14bb30 100644
--- a/src/fireedge/src/client/models/Helper.js
+++ b/src/fireedge/src/client/models/Helper.js
@@ -25,6 +25,7 @@ import { T, UserInputObject, USER_INPUT_TYPES } from 'client/constants'
*/
export const jsonToXml = (json, addRoot = true) => {
const parser = new Parser()
+
return parser.parse(addRoot ? { ROOT: json } : json)
}
@@ -34,7 +35,7 @@ export const jsonToXml = (json, addRoot = true) => {
* @param {boolean} bool - Boolean value.
* @returns {'Yes'|'No'} - If true return 'Yes', in other cases, return 'No'.
*/
-export const booleanToString = bool => bool ? T.Yes : T.No
+export const booleanToString = (bool) => (bool ? T.Yes : T.No)
/**
* Converts the string value into a boolean.
@@ -43,7 +44,7 @@ export const booleanToString = bool => bool ? T.Yes : T.No
* @returns {boolean} - If str is "yes" or 1 then returns true,
* in other cases, return false.
*/
-export const stringToBoolean = str =>
+export const stringToBoolean = (str) =>
String(str).toLowerCase() === 'yes' || +str === 1
/**
@@ -53,7 +54,7 @@ export const stringToBoolean = str =>
* @returns {string} - Time string.
* @example 02521251251 => "4/23/1981, 11:04:41 AM"
*/
-export const timeToString = time =>
+export const timeToString = (time) =>
+time ? new Date(+time * 1000).toLocaleString() : '-'
/**
@@ -62,8 +63,7 @@ export const timeToString = time =>
* @param {number|string} time - Time to convert
* @returns {DateTime} - DateTime object.
*/
-export const timeFromMilliseconds = time =>
- DateTime.fromMillis(+time * 1000)
+export const timeFromMilliseconds = (time) => DateTime.fromMillis(+time * 1000)
/**
* Returns the epoch milliseconds of the date.
@@ -71,7 +71,7 @@ export const timeFromMilliseconds = time =>
* @param {number|string} date - Date
* @returns {number} - Total milliseconds.
*/
-export const dateToMilliseconds = date =>
+export const dateToMilliseconds = (date) =>
DateTime.fromJSDate(date).toMillis() / 1000
/**
@@ -80,7 +80,7 @@ export const dateToMilliseconds = date =>
* @param {number|string} date - Date
* @returns {number} - Total milliseconds.
*/
-export const isoDateToMilliseconds = date =>
+export const isoDateToMilliseconds = (date) =>
DateTime.fromISO(date).toMillis() / 1000
/**
@@ -117,13 +117,14 @@ export const timeDiff = (start, end) => {
* @param {number} level - Level code number.
* @returns {string} - Lock level text.
*/
-export const levelLockToString = level => ({
- 0: T.None,
- 1: T.Use,
- 2: T.Manage,
- 3: T.Admin,
- 4: T.All
-}[level] || '-')
+export const levelLockToString = (level) =>
+ ({
+ 0: T.None,
+ 1: T.Use,
+ 2: T.Manage,
+ 3: T.Admin,
+ 4: T.All,
+ }[level] || '-')
/**
* Returns the permission numeric code.
@@ -134,11 +135,10 @@ export const levelLockToString = level => ({
* @param {('YES'|'NO')} category.2 - `true` if access permission is allowed
* @returns {number} Permission code number.
*/
-const getCategoryValue = ([u, m, a]) => (
+const getCategoryValue = ([u, m, a]) =>
(stringToBoolean(u) ? 4 : 0) +
(stringToBoolean(m) ? 2 : 0) +
(stringToBoolean(a) ? 1 : 0)
-)
/**
* Transform the permission from OpenNebula template to octal format.
@@ -155,18 +155,26 @@ const getCategoryValue = ([u, m, a]) => (
* @param {('YES'|'NO')} permissions.OTHER_A - Other access permission.
* @returns {string} - Permissions in octal format.
*/
-export const permissionsToOctal = permissions => {
+export const permissionsToOctal = (permissions) => {
const {
- OWNER_U, OWNER_M, OWNER_A,
- GROUP_U, GROUP_M, GROUP_A,
- OTHER_U, OTHER_M, OTHER_A
+ OWNER_U,
+ OWNER_M,
+ OWNER_A,
+ GROUP_U,
+ GROUP_M,
+ GROUP_A,
+ OTHER_U,
+ OTHER_M,
+ OTHER_A,
} = permissions
return [
[OWNER_U, OWNER_M, OWNER_A],
[GROUP_U, GROUP_M, GROUP_A],
- [OTHER_U, OTHER_M, OTHER_A]
- ].map(getCategoryValue).join('')
+ [OTHER_U, OTHER_M, OTHER_A],
+ ]
+ .map(getCategoryValue)
+ .join('')
}
/**
@@ -202,20 +210,21 @@ export const filterAttributes = (list = {}, options = {}) => {
const addAttributeToList = (listName, [attributeName, attributeValue]) => {
response[listName] = {
...response[listName],
- [attributeName]: attributeValue
+ [attributeName]: attributeValue,
}
}
Object.entries(list)
- .filter(attribute => {
- const [filterName] = Object.entries(extra)
- .find(([_, regexp]) => attribute[0].match(regexp)) ?? []
+ .filter((attribute) => {
+ const [filterName] =
+ Object.entries(extra).find(([_, regexp]) =>
+ attribute[0].match(regexp)
+ ) ?? []
return filterName ? addAttributeToList(filterName, attribute) : true
})
- .forEach(attribute => {
- !attribute[0].match(hidden) &&
- addAttributeToList('attributes', attribute)
+ .forEach((attribute) => {
+ !attribute[0].match(hidden) && addAttributeToList('attributes', attribute)
})
return response
@@ -239,12 +248,12 @@ const OPTIONAL = 'O'
* mandatory | type | description | options | defaultValue
* @returns {UserInputObject} User input object
*/
-export const getUserInputParams = userInputString => {
+export const getUserInputParams = (userInputString) => {
const params = String(userInputString).split(PARAMS_SEPARATOR)
const options = [
USER_INPUT_TYPES.range,
- USER_INPUT_TYPES.rangeFloat
+ USER_INPUT_TYPES.rangeFloat,
].includes(params[1])
? params[3].split(RANGE_SEPARATOR)
: params[3].split(LIST_SEPARATOR)
@@ -256,7 +265,7 @@ export const getUserInputParams = userInputString => {
options: options,
default: params[4],
min: options[0],
- max: options[1]
+ max: options[1],
}
}
@@ -264,7 +273,7 @@ export const getUserInputParams = userInputString => {
* @param {UserInputObject} userInput - User input object
* @returns {string} User input in string format
*/
-export const getUserInputString = userInput => {
+export const getUserInputString = (userInput) => {
const {
mandatory,
mandatoryString = mandatory ? MANDATORY : OPTIONAL,
@@ -274,7 +283,7 @@ export const getUserInputString = userInput => {
max,
range = [min, max].filter(Boolean).join(RANGE_SEPARATOR),
options,
- default: defaultValue
+ default: defaultValue,
} = userInput
// mandatory|type|description|range/options/' '|defaultValue
@@ -283,8 +292,8 @@ export const getUserInputString = userInput => {
range?.length > 0
? uiString.push(range)
: options?.length > 0
- ? uiString.push(options.join(LIST_SEPARATOR))
- : uiString.push(OPTIONS_DEFAULT)
+ ? uiString.push(options.join(LIST_SEPARATOR))
+ : uiString.push(OPTIONS_DEFAULT)
return uiString.concat(defaultValue).join(PARAMS_SEPARATOR)
}
@@ -296,9 +305,10 @@ export const getUserInputString = userInput => {
* @returns {UserInputObject[]} User input object
*/
export const userInputsToArray = (userInputs = {}) => {
- return Object
- .entries(userInputs)
- .map(([name, ui]) => ({ name, ...getUserInputParams(ui) }))
+ return Object.entries(userInputs).map(([name, ui]) => ({
+ name,
+ ...getUserInputParams(ui),
+ }))
}
/**
@@ -307,8 +317,11 @@ export const userInputsToArray = (userInputs = {}) => {
* @param {UserInputObject[]} userInputs - List of user inputs in object format
* @returns {object} User input object
*/
-export const userInputsToObject = userInputs =>
- userInputs.reduce((res, { name, ...userInput }) => ({
- ...res,
- [String(name).toUpperCase()]: getUserInputString(userInput)
- }), {})
+export const userInputsToObject = (userInputs) =>
+ userInputs.reduce(
+ (res, { name, ...userInput }) => ({
+ ...res,
+ [String(name).toUpperCase()]: getUserInputString(userInput),
+ }),
+ {}
+ )
diff --git a/src/fireedge/src/client/models/Host.js b/src/fireedge/src/client/models/Host.js
index 6c12e4ef5c..080a909e6b 100644
--- a/src/fireedge/src/client/models/Host.js
+++ b/src/fireedge/src/client/models/Host.js
@@ -14,7 +14,13 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
import { prettyBytes } from 'client/utils'
-import { DEFAULT_CPU_MODELS, HOST_STATES, HYPERVISORS, PciDevice, StateInfo } from 'client/constants'
+import {
+ DEFAULT_CPU_MODELS,
+ HOST_STATES,
+ HYPERVISORS,
+ PciDevice,
+ StateInfo,
+} from 'client/constants'
/**
* Returns information about the host state.
@@ -22,13 +28,13 @@ import { DEFAULT_CPU_MODELS, HOST_STATES, HYPERVISORS, PciDevice, StateInfo } fr
* @param {object} host - Host
* @returns {StateInfo} Host state object
*/
-export const getState = host => HOST_STATES[+host?.STATE ?? 0]
+export const getState = (host) => HOST_STATES[+host?.STATE ?? 0]
/**
* @param {object} host - Host
* @returns {Array} List of datastores from resource
*/
-export const getDatastores = host =>
+export const getDatastores = (host) =>
[host?.HOST_SHARE?.DATASTORES?.DS ?? []].flat()
/**
@@ -42,25 +48,27 @@ export const getDatastores = host =>
* percentMemLabel: string
* }} Allocated information object
*/
-export const getAllocatedInfo = host => {
+export const getAllocatedInfo = (host) => {
const { CPU_USAGE, TOTAL_CPU, MEM_USAGE, TOTAL_MEM } = host?.HOST_SHARE ?? {}
- const percentCpuUsed = +CPU_USAGE * 100 / +TOTAL_CPU || 0
+ const percentCpuUsed = (+CPU_USAGE * 100) / +TOTAL_CPU || 0
const percentCpuLabel = `${CPU_USAGE} / ${TOTAL_CPU}
(${Math.round(isFinite(percentCpuUsed) ? percentCpuUsed : '--')}%)`
const isMemUsageNegative = +MEM_USAGE < 0
- const percentMemUsed = +MEM_USAGE * 100 / +TOTAL_MEM || 0
+ const percentMemUsed = (+MEM_USAGE * 100) / +TOTAL_MEM || 0
const usedMemBytes = prettyBytes(Math.abs(+MEM_USAGE))
const totalMemBytes = prettyBytes(+TOTAL_MEM)
- const percentMemLabel = `${isMemUsageNegative ? '-' : ''}${usedMemBytes} / ${totalMemBytes}
+ const percentMemLabel = `${
+ isMemUsageNegative ? '-' : ''
+ }${usedMemBytes} / ${totalMemBytes}
(${Math.round(isFinite(percentMemUsed) ? percentMemUsed : '--')}%)`
return {
percentCpuUsed,
percentCpuLabel,
percentMemUsed,
- percentMemLabel
+ percentMemLabel,
}
}
@@ -70,12 +78,12 @@ export const getAllocatedInfo = host => {
* @param {object} host - Host
* @returns {Array} List of hugepages sizes from resource
*/
-export const getHugepageSizes = host => {
+export const getHugepageSizes = (host) => {
const numaNodes = [host?.HOST_SHARE?.NUMA_NODES?.NODE ?? []].flat()
return numaNodes
- .filter(node => node?.NODE_ID && node?.HUGEPAGE)
- .map(node => node.HUGEPAGE.map(({ SIZE }) => +SIZE))
+ .filter((node) => node?.NODE_ID && node?.HUGEPAGE)
+ .map((node) => node.HUGEPAGE.map(({ SIZE }) => +SIZE))
.flat()
}
@@ -85,7 +93,7 @@ export const getHugepageSizes = host => {
* @param {object} host - Host
* @returns {PciDevice[]} List of PCI devices from resource
*/
-export const getPciDevices = host =>
+export const getPciDevices = (host) =>
[host?.HOST_SHARE?.PCI_DEVICES?.PCI ?? []].flat().filter(Boolean)
/**
@@ -94,10 +102,11 @@ export const getPciDevices = host =>
* @param {object[]} hosts - Hosts
* @returns {Array} List of KVM CPU Models from the pool
*/
-export const getKvmCpuModels = (hosts = []) => hosts
- .filter(host => host?.TEMPLATE?.HYPERVISOR === HYPERVISORS.kvm)
- .map(host => host.TEMPLATE?.KVM_CPU_MODELS.split(' '))
- .flat()
+export const getKvmCpuModels = (hosts = []) =>
+ hosts
+ .filter((host) => host?.TEMPLATE?.HYPERVISOR === HYPERVISORS.kvm)
+ .map((host) => host.TEMPLATE?.KVM_CPU_MODELS.split(' '))
+ .flat()
/**
* Returns list of KVM Machines available from the host pool.
@@ -107,8 +116,8 @@ export const getKvmCpuModels = (hosts = []) => hosts
*/
export const getKvmMachines = (hosts = []) => {
const machineTypes = hosts
- .filter(host => host?.TEMPLATE?.HYPERVISOR === HYPERVISORS.kvm)
- .map(host => host.TEMPLATE?.KVM_MACHINES.split(' '))
+ .filter((host) => host?.TEMPLATE?.HYPERVISOR === HYPERVISORS.kvm)
+ .map((host) => host.TEMPLATE?.KVM_MACHINES.split(' '))
.flat()
return [DEFAULT_CPU_MODELS, ...machineTypes]
diff --git a/src/fireedge/src/client/models/Image.js b/src/fireedge/src/client/models/Image.js
index a20903cd8c..4a1b494f14 100644
--- a/src/fireedge/src/client/models/Image.js
+++ b/src/fireedge/src/client/models/Image.js
@@ -13,7 +13,12 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { IMAGE_TYPES, DISK_TYPES, IMAGE_STATES, StateInfo } from 'client/constants'
+import {
+ IMAGE_TYPES,
+ DISK_TYPES,
+ IMAGE_STATES,
+ StateInfo,
+} from 'client/constants'
/**
* Returns the image type.
diff --git a/src/fireedge/src/client/models/Marketplace.js b/src/fireedge/src/client/models/Marketplace.js
index 92737356c7..b8327a33e7 100644
--- a/src/fireedge/src/client/models/Marketplace.js
+++ b/src/fireedge/src/client/models/Marketplace.js
@@ -37,13 +37,15 @@ export const getState = ({ STATE } = {}) => MARKETPLACE_STATES[+STATE]
* }} Marketplace capacity information
*/
export const getCapacityInfo = ({ TOTAL_MB, USED_MB } = {}) => {
- const percentOfUsed = +USED_MB * 100 / +TOTAL_MB || 0
+ const percentOfUsed = (+USED_MB * 100) / +TOTAL_MB || 0
const usedBytes = prettyBytes(+USED_MB, 'MB')
const totalBytes = prettyBytes(+TOTAL_MB, 'MB')
- const percentLabel = `${usedBytes} / ${totalBytes} (${Math.round(percentOfUsed)}%)`
+ const percentLabel = `${usedBytes} / ${totalBytes} (${Math.round(
+ percentOfUsed
+ )}%)`
return {
percentOfUsed,
- percentLabel
+ percentLabel,
}
}
diff --git a/src/fireedge/src/client/models/MarketplaceApp.js b/src/fireedge/src/client/models/MarketplaceApp.js
index face078540..ceaa10d7d1 100644
--- a/src/fireedge/src/client/models/MarketplaceApp.js
+++ b/src/fireedge/src/client/models/MarketplaceApp.js
@@ -13,7 +13,11 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { MARKETPLACE_APP_STATES, MARKETPLACE_APP_TYPES, StateInfo } from 'client/constants'
+import {
+ MARKETPLACE_APP_STATES,
+ MARKETPLACE_APP_TYPES,
+ StateInfo,
+} from 'client/constants'
/**
* Returns the name of marketplace app type.
diff --git a/src/fireedge/src/client/models/ProviderTemplate.js b/src/fireedge/src/client/models/ProviderTemplate.js
index 364ec78a48..01a3b45af6 100644
--- a/src/fireedge/src/client/models/ProviderTemplate.js
+++ b/src/fireedge/src/client/models/ProviderTemplate.js
@@ -32,7 +32,8 @@
* @returns {string[]} Location keys
*/
export const getLocationKeys = (template = {}, providerConfig) => {
- const { location_key: locationKey } = providerConfig?.[template?.provider] ?? {}
+ const { location_key: locationKey } =
+ providerConfig?.[template?.provider] ?? {}
return typeof locationKey === 'string' ? locationKey.split(',') : locationKey
}
@@ -45,9 +46,12 @@ export const getLocationKeys = (template = {}, providerConfig) => {
* @returns {string[]} Location keys
*/
export const getProvisionTypes = (template = {}, providerConfig) => {
- const { provision_type: provisionType } = providerConfig?.[template?.provider] ?? {}
+ const { provision_type: provisionType } =
+ providerConfig?.[template?.provider] ?? {}
- return typeof locationKey === 'string' ? provisionType.split(',') : provisionType
+ return typeof locationKey === 'string'
+ ? provisionType.split(',')
+ : provisionType
}
/**
@@ -65,7 +69,7 @@ export const isValidProviderTemplate = (template, providerConfig) => {
const hasConnection = connection !== undefined
const locationKeyConnectionNotExists =
- !hasConnection || keys?.some(key => connection?.[key] === undefined)
+ !hasConnection || keys?.some((key) => connection?.[key] === undefined)
return (
!(keys && locationKeyConnectionNotExists) ||
@@ -85,10 +89,13 @@ export const getConnectionFixed = (template = {}, providerConfig) => {
const { connection = {} } = template
const keys = getLocationKeys(template, providerConfig)
- return Object.entries(connection).reduce((res, [name, value]) => ({
- ...res,
- ...(keys?.includes(name) && { [name]: value })
- }), {})
+ return Object.entries(connection).reduce(
+ (res, [name, value]) => ({
+ ...res,
+ ...(keys?.includes(name) && { [name]: value }),
+ }),
+ {}
+ )
}
/**
@@ -102,8 +109,11 @@ export const getConnectionEditable = (template = {}, providerConfig) => {
const { connection = {} } = template
const keys = getLocationKeys(template, providerConfig)
- return Object.entries(connection).reduce((res, [name, value]) => ({
- ...res,
- ...(!keys?.includes(name) && { [name]: value })
- }), {})
+ return Object.entries(connection).reduce(
+ (res, [name, value]) => ({
+ ...res,
+ ...(!keys?.includes(name) && { [name]: value }),
+ }),
+ {}
+ )
}
diff --git a/src/fireedge/src/client/models/ProvisionTemplate.js b/src/fireedge/src/client/models/ProvisionTemplate.js
index 7230866a89..56fe9fe17f 100644
--- a/src/fireedge/src/client/models/ProvisionTemplate.js
+++ b/src/fireedge/src/client/models/ProvisionTemplate.js
@@ -38,8 +38,7 @@
* @returns {string} Provider name
*/
export const getProviderName = ({ defaults, hosts }) =>
- defaults?.provision?.provider_name ??
- hosts?.[0]?.provision.provider_name
+ defaults?.provision?.provider_name ?? hosts?.[0]?.provision.provider_name
/**
* Check if the provision template is valid format.
@@ -47,12 +46,9 @@ export const getProviderName = ({ defaults, hosts }) =>
* @param {ProvisionTemplate} template - Provision template
* @returns {boolean} Returns `true` if template is valid
*/
-export const isValidProvisionTemplate = template => {
+export const isValidProvisionTemplate = (template) => {
const { name, provider } = template
const providerName = getProviderName(template)
- return !(
- providerName === undefined ||
- [name, provider].includes(undefined)
- )
+ return !(providerName === undefined || [name, provider].includes(undefined))
}
diff --git a/src/fireedge/src/client/models/SecurityGroup.js b/src/fireedge/src/client/models/SecurityGroup.js
index 303d2686c6..3bc5ad5eda 100644
--- a/src/fireedge/src/client/models/SecurityGroup.js
+++ b/src/fireedge/src/client/models/SecurityGroup.js
@@ -13,7 +13,13 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { T, PROTOCOL_STRING, RULE_TYPE_STRING, ICMP_STRING, ICMP_V6_STRING } from 'client/constants'
+import {
+ T,
+ PROTOCOL_STRING,
+ RULE_TYPE_STRING,
+ ICMP_STRING,
+ ICMP_V6_STRING,
+} from 'client/constants'
/**
* @typedef {object} SecurityGroupRule
@@ -65,7 +71,7 @@ export const prettySecurityGroup = ({
ICMP_TYPE: ICMP_STRING[+icmpType] ?? '',
ICMPv6_TYPE: ICMP_V6_STRING[+icmpv6Type] ?? '',
RANGE: range || T.All,
- ...rest
+ ...rest,
})
/**
@@ -82,5 +88,7 @@ export const getSecurityGroupsFromResource = (resource, securityGroups) => {
? securityGroups
: securityGroups?.split(',')
- return rules.filter(({ SECURITY_GROUP_ID }) => groups?.includes?.(SECURITY_GROUP_ID))
+ return rules.filter(({ SECURITY_GROUP_ID }) =>
+ groups?.includes?.(SECURITY_GROUP_ID)
+ )
}
diff --git a/src/fireedge/src/client/models/VirtualMachine.js b/src/fireedge/src/client/models/VirtualMachine.js
index 3c4221769f..6a59f5e8f5 100644
--- a/src/fireedge/src/client/models/VirtualMachine.js
+++ b/src/fireedge/src/client/models/VirtualMachine.js
@@ -13,7 +13,10 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { getSecurityGroupsFromResource, prettySecurityGroup } from 'client/models/SecurityGroup'
+import {
+ getSecurityGroupsFromResource,
+ prettySecurityGroup,
+} from 'client/models/SecurityGroup'
import { timeToString } from 'client/models/Helper'
import { Tr } from 'client/components/HOC'
@@ -26,7 +29,7 @@ import {
HISTORY_ACTIONS,
HYPERVISORS,
T,
- StateInfo
+ StateInfo,
} from 'client/constants'
/**
@@ -43,20 +46,20 @@ export const filterDoneVms = (vms = []) =>
* @param {string|number} action - Action code
* @returns {HISTORY_ACTIONS} History action name
*/
-export const getHistoryAction = action => HISTORY_ACTIONS[+action]
+export const getHistoryAction = (action) => HISTORY_ACTIONS[+action]
/**
* @param {object} vm - Virtual machine
* @returns {object} History records from resource
*/
-export const getHistoryRecords = vm =>
+export const getHistoryRecords = (vm) =>
[vm?.HISTORY_RECORDS?.HISTORY ?? []].flat()
/**
* @param {object} vm - Virtual machine
* @returns {object} Last history record from resource
*/
-export const getLastHistory = vm => {
+export const getLastHistory = (vm) => {
const records = getHistoryRecords(vm)
return records.at(-1) ?? {}
@@ -66,26 +69,31 @@ export const getLastHistory = vm => {
* @param {object} vm - Virtual machine
* @returns {string} Resource type: VR, FLOW or VM
*/
-export const getType = vm => vm.TEMPLATE?.VROUTER_ID
- ? 'VR' : vm?.USER_TEMPLATE?.USER_TEMPLATE?.SERVICE_ID ? 'FLOW' : 'VM'
+export const getType = (vm) =>
+ vm.TEMPLATE?.VROUTER_ID
+ ? 'VR'
+ : vm?.USER_TEMPLATE?.USER_TEMPLATE?.SERVICE_ID
+ ? 'FLOW'
+ : 'VM'
/**
* @param {object} vm - Virtual machine
* @returns {string} Resource hypervisor
*/
-export const getHypervisor = vm => String(getLastHistory(vm)?.VM_MAD).toLowerCase()
+export const getHypervisor = (vm) =>
+ String(getLastHistory(vm)?.VM_MAD).toLowerCase()
/**
* @param {object} vm - Virtual machine
* @returns {boolean} If the hypervisor is vCenter
*/
-export const isVCenter = vm => getHypervisor(vm) === HYPERVISORS.vcenter
+export const isVCenter = (vm) => getHypervisor(vm) === HYPERVISORS.vcenter
/**
* @param {object} vm - Virtual machine
* @returns {StateInfo} State information from resource
*/
-export const getState = vm => {
+export const getState = (vm) => {
const { STATE, LCM_STATE } = vm ?? {}
const state = VM_STATES[+STATE]
@@ -96,51 +104,53 @@ export const getState = vm => {
* @param {object} vm - Virtual machine
* @returns {Array} List of disks from resource
*/
-export const getDisks = vm => {
+export const getDisks = (vm) => {
const { TEMPLATE = {}, MONITORING = {}, SNAPSHOTS = {} } = vm ?? {}
const diskSnapshots = [SNAPSHOTS].flat().filter(Boolean)
const { DISK, CONTEXT } = TEMPLATE
const monitoringDiskSize = [MONITORING?.DISK_SIZE].flat().filter(Boolean)
- const monitoringSnapshotSize = [MONITORING?.SNAPSHOT_SIZE].flat().filter(Boolean)
+ const monitoringSnapshotSize = [MONITORING?.SNAPSHOT_SIZE]
+ .flat()
+ .filter(Boolean)
- const addExtraData = disk => {
- const diskSnapshot = diskSnapshots
- .find(({ DISK_ID }) => DISK_ID === disk.DISK_ID)?.SNAPSHOT || []
+ const addExtraData = (disk) => {
+ const diskSnapshot =
+ diskSnapshots.find(({ DISK_ID }) => DISK_ID === disk.DISK_ID)?.SNAPSHOT ||
+ []
const snapshotsWithMonitoringData = [diskSnapshot]
.flat()
- .map(snapshot => ({
+ .map((snapshot) => ({
...snapshot,
- MONITOR_SIZE: monitoringSnapshotSize
- .find(({ DISK_ID }) => DISK_ID === disk.DISK_ID)?.SIZE || '-'
+ MONITOR_SIZE:
+ monitoringSnapshotSize.find(({ DISK_ID }) => DISK_ID === disk.DISK_ID)
+ ?.SIZE || '-',
}))
- const diskSizeFromMonitoring = monitoringDiskSize
- .find(({ ID }) => ID === disk.DISK_ID)?.SIZE || '-'
+ const diskSizeFromMonitoring =
+ monitoringDiskSize.find(({ ID }) => ID === disk.DISK_ID)?.SIZE || '-'
return {
...disk,
SNAPSHOTS: snapshotsWithMonitoringData,
- MONITOR_SIZE: diskSizeFromMonitoring
+ MONITOR_SIZE: diskSizeFromMonitoring,
}
}
- const contextDisk = CONTEXT && !isVCenter(vm) && {
- ...CONTEXT,
- IMAGE: 'CONTEXT',
- IS_CONTEXT: true,
- DATASTORE: '-',
- READONLY: '-',
- SAVE: '-',
- CLONE: '-',
- SAVE_AS: '-'
- }
+ const contextDisk = CONTEXT &&
+ !isVCenter(vm) && {
+ ...CONTEXT,
+ IMAGE: 'CONTEXT',
+ IS_CONTEXT: true,
+ DATASTORE: '-',
+ READONLY: '-',
+ SAVE: '-',
+ CLONE: '-',
+ SAVE_AS: '-',
+ }
- return [DISK, contextDisk]
- .flat()
- .filter(Boolean)
- .map(addExtraData)
+ return [DISK, contextDisk].flat().filter(Boolean).map(addExtraData)
}
/**
@@ -163,7 +173,12 @@ export const getNics = (vm, options = {}) => {
const extraIps = [GUEST_IP, ...GUEST_IP_ADDRESSES?.split(',')]
.filter(Boolean)
- .map(ip => ({ NIC_ID: '-', IP: ip, NETWORK: 'Additional IP', BRIDGE: '-' }))
+ .map((ip) => ({
+ NIC_ID: '-',
+ IP: ip,
+ NETWORK: 'Additional IP',
+ BRIDGE: '-',
+ }))
let nics = [NIC, NIC_ALIAS, pciNics, extraIps].flat().filter(Boolean)
@@ -174,16 +189,16 @@ export const getNics = (vm, options = {}) => {
...nic,
ALIAS: [NIC_ALIAS]
.flat()
- .filter(({ NIC_ID }) => ALIAS_IDS?.split(',')?.includes?.(NIC_ID))
+ .filter(({ NIC_ID }) => ALIAS_IDS?.split(',')?.includes?.(NIC_ID)),
}))
}
if (securityGroupsFromTemplate) {
nics = nics.map(({ SECURITY_GROUPS, ...nic }) => ({
...nic,
- SECURITY_GROUPS:
- getSecurityGroupsFromResource(vm, SECURITY_GROUPS)
- ?.map(prettySecurityGroup)
+ SECURITY_GROUPS: getSecurityGroupsFromResource(vm, SECURITY_GROUPS)?.map(
+ prettySecurityGroup
+ ),
}))
}
@@ -194,8 +209,9 @@ export const getNics = (vm, options = {}) => {
* @param {object} vm - Virtual machine
* @returns {Array} List of ips from resource
*/
-export const getIps = vm => {
- const getIpsFromNic = nic => NIC_ALIAS_IP_ATTRS.map(attr => nic[attr]).filter(Boolean)
+export const getIps = (vm) => {
+ const getIpsFromNic = (nic) =>
+ NIC_ALIAS_IP_ATTRS.map((attr) => nic[attr]).filter(Boolean)
return getNics(vm).map(getIpsFromNic).flat()
}
@@ -204,18 +220,21 @@ export const getIps = vm => {
* @param {object} vm - Virtual machine
* @returns {{ nics: Array, alias: Array }} Lists of nics and alias from resource
*/
-export const splitNicAlias = vm =>
- getNics(vm).reduce((result, nic) => {
- result[nic?.PARENT !== undefined ? 'alias' : 'nics'].push(nic)
+export const splitNicAlias = (vm) =>
+ getNics(vm).reduce(
+ (result, nic) => {
+ result[nic?.PARENT !== undefined ? 'alias' : 'nics'].push(nic)
- return result
- }, { nics: [], alias: [] })
+ return result
+ },
+ { nics: [], alias: [] }
+ )
/**
* @param {object} vm - Virtual machine
* @returns {Array} List of snapshots from resource
*/
-export const getSnapshotList = vm => {
+export const getSnapshotList = (vm) => {
const { TEMPLATE = {} } = vm ?? {}
return [TEMPLATE.SNAPSHOT].filter(Boolean).flat()
@@ -225,7 +244,7 @@ export const getSnapshotList = vm => {
* @param {object} vm - Virtual machine
* @returns {Array} List of schedule actions from resource
*/
-export const getScheduleActions = vm => {
+export const getScheduleActions = (vm) => {
const { TEMPLATE = {} } = vm ?? {}
return [TEMPLATE.SCHED_ACTION].filter(Boolean).flat()
@@ -237,23 +256,23 @@ export const getScheduleActions = vm => {
* @param {object} scheduleAction - Schedule action
* @returns {{repeat: string|string[], end: string}} - Periodicity of the action.
*/
-export const periodicityToString = scheduleAction => {
+export const periodicityToString = (scheduleAction) => {
const { REPEAT, DAYS = '', END_TYPE, END_VALUE = '' } = scheduleAction ?? {}
const daysOfWeek = [T.Sun, T.Mon, T.Tue, T.Wed, T.Thu, T.Fri, T.Sat]
- const days = DAYS?.split(',')?.map(day => Tr(daysOfWeek[day])) ?? []
+ const days = DAYS?.split(',')?.map((day) => Tr(daysOfWeek[day])) ?? []
const repeat = {
0: `${Tr(T.Weekly)} ${days.join(',')}`,
1: `${Tr(T.Monthly)} ${DAYS}`,
2: `${Tr(T.Yearly)} ${DAYS}`,
- 3: Tr([T.EachHours, DAYS])
+ 3: Tr([T.EachHours, DAYS]),
}[+REPEAT]
const end = {
0: Tr(T.None),
1: Tr([T.AfterTimes, END_VALUE]),
- 2: `${Tr(T.On)} ${timeToString(END_VALUE)}`
+ 2: `${Tr(T.On)} ${timeToString(END_VALUE)}`,
}[+END_TYPE]
return { repeat, end }
@@ -266,10 +285,14 @@ export const periodicityToString = scheduleAction => {
* @returns {function(Array, Function):boolean}
* - The list of vms that will be perform the action
*/
-export const isAvailableAction = action => (vms = [], getVmState = vm => getState(vm)?.name) => {
- if (VM_ACTIONS_BY_STATE[action]?.length === 0) return false
+export const isAvailableAction =
+ (action) =>
+ (vms = [], getVmState = (vm) => getState(vm)?.name) => {
+ if (VM_ACTIONS_BY_STATE[action]?.length === 0) return false
- const states = [vms].flat().map(getVmState)
+ const states = [vms].flat().map(getVmState)
- return states?.some(state => !VM_ACTIONS_BY_STATE[action]?.includes(state))
-}
+ return states?.some(
+ (state) => !VM_ACTIONS_BY_STATE[action]?.includes(state)
+ )
+ }
diff --git a/src/fireedge/src/client/models/VirtualNetwork.js b/src/fireedge/src/client/models/VirtualNetwork.js
index 847cebe8c8..34f93d4038 100644
--- a/src/fireedge/src/client/models/VirtualNetwork.js
+++ b/src/fireedge/src/client/models/VirtualNetwork.js
@@ -23,7 +23,7 @@
export const getTotalLeases = ({ AR_POOL } = {}) => {
const addressRanges = [AR_POOL?.AR ?? []].flat()
- return addressRanges.reduce((total, { SIZE = 0 }) => total + (+SIZE), 0)
+ return addressRanges.reduce((total, { SIZE = 0 }) => total + +SIZE, 0)
}
/**
@@ -38,8 +38,10 @@ export const getTotalLeases = ({ AR_POOL } = {}) => {
*/
export const getLeasesInfo = ({ USED_LEASES, ...virtualNetwork } = {}) => {
const totalLeases = getTotalLeases(virtualNetwork)
- const percentOfUsed = +USED_LEASES * 100 / +totalLeases || 0
- const percentLabel = `${USED_LEASES} / ${totalLeases} (${Math.round(percentOfUsed)}%)`
+ const percentOfUsed = (+USED_LEASES * 100) / +totalLeases || 0
+ const percentLabel = `${USED_LEASES} / ${totalLeases} (${Math.round(
+ percentOfUsed
+ )}%)`
return { percentOfUsed, percentLabel }
}
diff --git a/src/fireedge/src/client/providers/muiProvider.js b/src/fireedge/src/client/providers/muiProvider.js
index fcce10dd6f..ebf8d05179 100644
--- a/src/fireedge/src/client/providers/muiProvider.js
+++ b/src/fireedge/src/client/providers/muiProvider.js
@@ -21,7 +21,7 @@ import {
CssBaseline,
ThemeProvider,
StyledEngineProvider,
- useMediaQuery
+ useMediaQuery,
} from '@mui/material'
import StylesProvider from '@mui/styles/StylesProvider'
import { createTheme, generateClassName } from 'client/theme'
@@ -70,8 +70,8 @@ MuiProvider.propTypes = {
theme: PropTypes.object,
children: PropTypes.oneOfType([
PropTypes.node,
- PropTypes.arrayOf(PropTypes.node)
- ])
+ PropTypes.arrayOf(PropTypes.node),
+ ]),
}
export default MuiProvider
diff --git a/src/fireedge/src/client/providers/notistackProvider.js b/src/fireedge/src/client/providers/notistackProvider.js
index efd84cb6b5..226b188f5c 100644
--- a/src/fireedge/src/client/providers/notistackProvider.js
+++ b/src/fireedge/src/client/providers/notistackProvider.js
@@ -24,25 +24,25 @@ const useStyles = makeStyles(({ palette }) => ({
marginLeft: 20,
wordBreak: 'break-word',
'& *[role=button], & *[role=button]:hover': {
- color: 'inherit'
- }
+ color: 'inherit',
+ },
},
variantSuccess: {
backgroundColor: palette.success.main,
- color: palette.success.contrastText
+ color: palette.success.contrastText,
},
variantError: {
backgroundColor: palette.error.main,
- color: palette.error.contrastText
+ color: palette.error.contrastText,
},
variantInfo: {
backgroundColor: palette.debug.main,
- color: palette.debug.contrastText
+ color: palette.debug.contrastText,
},
variantWarning: {
backgroundColor: palette.warning.main,
- color: palette.warning.contrastText
- }
+ color: palette.warning.contrastText,
+ },
}))
const NotistackProvider = ({ children }) => {
@@ -62,12 +62,12 @@ const NotistackProvider = ({ children }) => {
NotistackProvider.propTypes = {
children: PropTypes.oneOfType([
PropTypes.node,
- PropTypes.arrayOf(PropTypes.node)
- ])
+ PropTypes.arrayOf(PropTypes.node),
+ ]),
}
NotistackProvider.defaultProps = {
- children: undefined
+ children: undefined,
}
export default NotistackProvider
diff --git a/src/fireedge/src/client/providers/socketProvider.js b/src/fireedge/src/client/providers/socketProvider.js
index 7dd6dd5f22..304d9453a0 100644
--- a/src/fireedge/src/client/providers/socketProvider.js
+++ b/src/fireedge/src/client/providers/socketProvider.js
@@ -23,10 +23,11 @@ import { useSelector, useDispatch } from 'react-redux'
import { WEBSOCKET_URL, SOCKETS } from 'client/constants'
import * as sockets from 'client/features/One/socket/actions'
-const createProvisionWebsocket = query => socketIO({
- path: `${WEBSOCKET_URL}/${SOCKETS.PROVISION}`,
- query
-})
+const createProvisionWebsocket = (query) =>
+ socketIO({
+ path: `${WEBSOCKET_URL}/${SOCKETS.PROVISION}`,
+ query,
+ })
export const SocketContext = createContext(null)
@@ -34,9 +35,9 @@ const SocketProvider = ({ children }) => {
const [socket, setSocket] = useState({})
const dispatch = useDispatch()
- const { jwt, zone } = useSelector(state => ({
+ const { jwt, zone } = useSelector((state) => ({
zone: state?.general?.zone,
- jwt: state?.auth?.jwt
+ jwt: state?.auth?.jwt,
}))
useEffect(() => {
@@ -45,7 +46,7 @@ const SocketProvider = ({ children }) => {
const client = createProvisionWebsocket({ token: jwt, zone })
setSocket(client)
- client.on(SOCKETS.PROVISION, data => {
+ client.on(SOCKETS.PROVISION, (data) => {
dispatch(sockets.onCreateProvision(data))
})
@@ -65,12 +66,12 @@ const SocketProvider = ({ children }) => {
SocketProvider.propTypes = {
children: PropTypes.oneOfType([
PropTypes.node,
- PropTypes.arrayOf(PropTypes.node)
- ])
+ PropTypes.arrayOf(PropTypes.node),
+ ]),
}
SocketProvider.defaultProps = {
- children: undefined
+ children: undefined,
}
export default SocketProvider
diff --git a/src/fireedge/src/client/router/common.js b/src/fireedge/src/client/router/common.js
index a05d847ecc..bbb84f45ff 100644
--- a/src/fireedge/src/client/router/common.js
+++ b/src/fireedge/src/client/router/common.js
@@ -18,15 +18,15 @@ import loadable from '@loadable/component'
const Login = loadable(() => import('client/containers/Login'), { ssr: false })
export const PATH = {
- LOGIN: '/'
+ LOGIN: '/',
}
export const ENDPOINTS = [
{
label: 'Login',
path: PATH.LOGIN,
- Component: Login
- }
+ Component: Login,
+ },
]
export default { PATH, ENDPOINTS }
diff --git a/src/fireedge/src/client/router/dev.js b/src/fireedge/src/client/router/dev.js
index c8fc046e8d..cbbe6a9469 100644
--- a/src/fireedge/src/client/router/dev.js
+++ b/src/fireedge/src/client/router/dev.js
@@ -16,12 +16,16 @@
import loadable from '@loadable/component'
import { Code as DevIcon } from 'iconoir-react'
-const TestApi = loadable(() => import('client/containers/TestApi'), { ssr: false })
-const TestForm = loadable(() => import('client/containers/TestForm'), { ssr: false })
+const TestApi = loadable(() => import('client/containers/TestApi'), {
+ ssr: false,
+})
+const TestForm = loadable(() => import('client/containers/TestForm'), {
+ ssr: false,
+})
export const PATH = {
TEST_API: '/test-api',
- TEST_FORM: '/test-form'
+ TEST_FORM: '/test-form',
}
export const ENDPOINTS = [
@@ -31,7 +35,7 @@ export const ENDPOINTS = [
devMode: true,
sidebar: true,
icon: DevIcon,
- Component: TestApi
+ Component: TestApi,
},
{
label: 'Test Form',
@@ -39,8 +43,8 @@ export const ENDPOINTS = [
devMode: true,
sidebar: true,
icon: DevIcon,
- Component: TestForm
- }
+ Component: TestForm,
+ },
]
export default { PATH, ENDPOINTS }
diff --git a/src/fireedge/src/client/router/index.js b/src/fireedge/src/client/router/index.js
index 33e03df4a1..c60ee61a3b 100644
--- a/src/fireedge/src/client/router/index.js
+++ b/src/fireedge/src/client/router/index.js
@@ -22,7 +22,7 @@ import { LinearProgress } from '@mui/material'
import {
PATH as COMMON_PATH,
- ENDPOINTS as COMMON_ENDPOINTS
+ ENDPOINTS as COMMON_ENDPOINTS,
} from 'client/router/common'
import { ProtectedRoute, NoAuthRoute } from 'client/components/Route'
@@ -31,7 +31,7 @@ import { InternalLayout } from 'client/components/HOC'
const renderRoute = ({ Component, label, ...rest }, index) => (
- } />
+ } />
)
@@ -51,11 +51,16 @@ const Router = ({ redirectWhenAuth, endpoints }) => (
? subRoutes?.map(renderRoute)
: renderRoute(rest, index)
)}
- {COMMON_ENDPOINTS?.map(({ Component, ...rest }, index) =>
-
+ {COMMON_ENDPOINTS?.map(({ Component, ...rest }, index) => (
+
- )}
+ ))}
} />
@@ -70,14 +75,14 @@ Router.propTypes = {
label: PropTypes.string.isRequired,
path: PropTypes.string,
sidebar: PropTypes.bool,
- routes: PropTypes.array
+ routes: PropTypes.array,
})
- )
+ ),
}
Router.defaultProps = {
redirectWhenAuth: '/dashboard',
- endpoints: []
+ endpoints: [],
}
Router.displayName = 'Router'
diff --git a/src/fireedge/src/client/store/index.js b/src/fireedge/src/client/store/index.js
index 2f2abbc682..a0c34ee7ca 100644
--- a/src/fireedge/src/client/store/index.js
+++ b/src/fireedge/src/client/store/index.js
@@ -13,7 +13,11 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { configureStore, getDefaultMiddleware, EnhancedStore } from '@reduxjs/toolkit'
+import {
+ configureStore,
+ getDefaultMiddleware,
+ EnhancedStore,
+} from '@reduxjs/toolkit'
import thunkMiddleware from 'redux-thunk'
import rootReducer from 'client/store/reducers'
@@ -29,7 +33,7 @@ export const createStore = ({ initState = {}, services }) => {
const middleware = getDefaultMiddleware({
immutableCheck: true,
serializableCheck: false,
- thunk: false
+ thunk: false,
})
middleware.push(thunkMiddleware.withExtraArgument({ services }))
@@ -38,7 +42,7 @@ export const createStore = ({ initState = {}, services }) => {
reducer: rootReducer,
devTools: isDevelopment(),
middleware,
- preloadedState: initState
+ preloadedState: initState,
})
return { store }
diff --git a/src/fireedge/src/client/store/reducers.js b/src/fireedge/src/client/store/reducers.js
index abddfb8e1e..c7cc93ba8b 100644
--- a/src/fireedge/src/client/store/reducers.js
+++ b/src/fireedge/src/client/store/reducers.js
@@ -21,7 +21,7 @@ const One = require('client/features/One/slice')
const rootReducer = combineReducers({
general: General.reducer,
auth: Auth.reducer,
- one: One.reducer
+ one: One.reducer,
})
module.exports = rootReducer
diff --git a/src/fireedge/src/client/theme/defaults.js b/src/fireedge/src/client/theme/defaults.js
index d70c7706ac..f7d1924109 100644
--- a/src/fireedge/src/client/theme/defaults.js
+++ b/src/fireedge/src/client/theme/defaults.js
@@ -32,7 +32,7 @@ const systemFont = [
'sans-serif',
'"Apple Color Emoji"',
'"Segoe UI Emoji"',
- '"Segoe UI Symbol"'
+ '"Segoe UI Symbol"',
]
export const breakpoints = {
@@ -40,28 +40,28 @@ export const breakpoints = {
sm: 600,
md: 900,
lg: 1200,
- xl: 1536
+ xl: 1536,
}
export const toolbar = {
regular: 56,
xs: 48,
- sm: 64
+ sm: 64,
}
export const footer = {
- regular: 30
+ regular: 30,
}
export const sidebar = {
minified: 60,
- fixed: 250
+ fixed: 250,
}
const buttonSvgStyle = {
fontSize: '1.25rem',
width: '1em',
- height: '1em'
+ height: '1em',
}
/**
@@ -80,11 +80,11 @@ export default (appTheme, mode = SCHEMES.DARK) => {
secondary,
common: {
black,
- white
+ white,
},
background: {
paper: isDarkMode ? primary.light : white,
- default: isDarkMode ? primary.main : '#f2f4f8'
+ default: isDarkMode ? primary.main : '#f2f4f8',
},
error: {
100: '#fdeae7',
@@ -98,7 +98,7 @@ export default (appTheme, mode = SCHEMES.DARK) => {
light: '#f8c0b7',
main: '#ec5840',
dark: '#f2391b',
- contrastText: white
+ contrastText: white,
},
warning: {
100: '#FFF4DB',
@@ -112,13 +112,13 @@ export default (appTheme, mode = SCHEMES.DARK) => {
light: '#ffe4a3',
main: '#f1a204',
dark: '#f1a204',
- contrastText: 'rgba(0, 0, 0, 0.87)'
+ contrastText: 'rgba(0, 0, 0, 0.87)',
},
info: {
light: '#64b5f6',
main: '#2196f3',
dark: '#01579b',
- contrastText: white
+ contrastText: white,
},
success: {
100: '#bce1bd',
@@ -132,18 +132,18 @@ export default (appTheme, mode = SCHEMES.DARK) => {
light: '#3adb76',
main: '#4caf50',
dark: '#388e3c',
- contrastText: white
+ contrastText: white,
},
debug: {
light: '#e0e0e0',
main: '#757575',
dark: '#424242',
- contrastText: isDarkMode ? white : black
- }
+ contrastText: isDarkMode ? white : black,
+ },
},
breakpoints: {
values: breakpoints,
- keys: Object.keys(breakpoints)
+ keys: Object.keys(breakpoints),
},
typography: {
fontFamily: [UbuntuFont.fontFamily, ...systemFont].join(','),
@@ -153,84 +153,85 @@ export default (appTheme, mode = SCHEMES.DARK) => {
'Monaco',
'Andale Mono',
'Ubuntu Mono',
- 'monospace'
+ 'monospace',
].join(','),
fontFamilySystem: systemFont.join(','),
h1: {
fontSize: 'clamp(2.625rem, 1.2857rem + 3.5714vw, 4rem)',
fontWeight: 800,
- lineHeight: 78 / 70
+ lineHeight: 78 / 70,
},
h2: {
fontSize: 'clamp(1.5rem, 0.9643rem + 1.4286vw, 2.25rem)',
fontWeight: 800,
- lineHeight: 44 / 36
+ lineHeight: 44 / 36,
},
h3: {
fontSize: defaultTheme.typography.pxToRem(36),
lineHeight: 44 / 36,
- letterSpacing: 0
+ letterSpacing: 0,
},
h4: {
fontSize: defaultTheme.typography.pxToRem(28),
lineHeight: 42 / 28,
- letterSpacing: 0
+ letterSpacing: 0,
},
h5: {
fontSize: defaultTheme.typography.pxToRem(24),
lineHeight: 36 / 24,
- letterSpacing: 0
+ letterSpacing: 0,
},
h6: {
fontSize: defaultTheme.typography.pxToRem(20),
lineHeight: 30 / 20,
- letterSpacing: 0
+ letterSpacing: 0,
},
button: {
fontSize: defaultTheme.typography.pxToRem(12),
textTransform: 'initial',
fontWeight: 500,
- letterSpacing: 0
+ letterSpacing: 0,
},
subtitle1: {
fontSize: defaultTheme.typography.pxToRem(18),
lineHeight: 24 / 18,
letterSpacing: 0,
- fontWeight: 500
+ fontWeight: 500,
},
body1: {
fontSize: defaultTheme.typography.pxToRem(16),
lineHeight: 24 / 16,
- letterSpacing: 0
+ letterSpacing: 0,
},
body2: {
fontSize: defaultTheme.typography.pxToRem(14),
lineHeight: 21 / 14,
- letterSpacing: 0
+ letterSpacing: 0,
},
caption: {
display: 'inline-block',
fontSize: defaultTheme.typography.pxToRem(12),
lineHeight: 18 / 12,
letterSpacing: 0,
- fontWeight: 500
+ fontWeight: 500,
},
fontWeightLight: 300,
fontWeightRegular: 400,
fontWeightMedium: 500,
fontWeightBold: 700,
- fontWeightExtraBold: 800
+ fontWeightExtraBold: 800,
},
mixins: {
toolbar: {
minHeight: toolbar.regular,
- [`@media (min-width:${breakpoints.xs}px) and (orientation: landscape)`]: {
- minHeight: toolbar.xs
- },
+ [`@media (min-width:${breakpoints.xs}px) and (orientation: landscape)`]:
+ {
+ minHeight: toolbar.xs,
+ },
[`@media (min-width:${breakpoints.sm}px)`]: {
- minHeight: toolbar.sm
- }
- }
+ minHeight: toolbar.sm,
+ },
+ },
},
components: {
MuiCssBaseline: {
@@ -241,72 +242,78 @@ export default (appTheme, mode = SCHEMES.DARK) => {
color: isDarkMode ? secondary.main : secondary.dark,
textDecoration: 'none',
'&:hover': {
- textDecoration: 'underline'
- }
+ textDecoration: 'underline',
+ },
},
- fieldset: { border: 'none' }
- }
+ fieldset: { border: 'none' },
+ },
},
MuiPaper: {
styleOverrides: {
- root: { backgroundImage: 'unset' }
- }
+ root: { backgroundImage: 'unset' },
+ },
},
MuiButtonBase: {
defaultProps: {
- disableTouchRipple: true
- }
+ disableTouchRipple: true,
+ },
},
MuiListItemButton: {
styleOverrides: {
root: {
'&.Mui-selected, &.Mui-selected:hover': {
- backgroundColor: alpha(secondary.main, 0.60)
- }
- }
- }
+ backgroundColor: alpha(secondary.main, 0.6),
+ },
+ },
+ },
},
MuiButton: {
defaultProps: {
- disableTouchRipple: true
+ disableTouchRipple: true,
},
styleOverrides: {
root: {
padding: '5px 16px',
- '& svg:nth-of-type(1)': buttonSvgStyle
+ '& svg:nth-of-type(1)': buttonSvgStyle,
},
endIcon: {
marginLeft: 4,
width: '1rem',
- height: '1rem'
+ height: '1rem',
},
text: {
color: isDarkMode ? white : grey[900],
'&:hover': {
- backgroundColor: isDarkMode ? alpha(white, 0.1) : alpha(grey[900], 0.1)
- }
+ backgroundColor: isDarkMode
+ ? alpha(white, 0.1)
+ : alpha(grey[900], 0.1),
+ },
},
outlined: {
border: '1px solid',
- borderColor: isDarkMode ? alpha(grey[100], 0.45) : alpha(grey[700], 0.45),
+ borderColor: isDarkMode
+ ? alpha(grey[100], 0.45)
+ : alpha(grey[700], 0.45),
borderRadius: defaultTheme.shape.borderRadius,
- color: isDarkMode ? white : grey[900]
- }
- }
+ color: isDarkMode ? white : grey[900],
+ },
+ },
},
MuiIconButton: {
styleOverrides: {
- root: { '& svg:nth-of-type(1)': buttonSvgStyle }
+ root: { '& svg:nth-of-type(1)': buttonSvgStyle },
},
- variants: [{
- props: { color: 'default' },
- style: { '&:hover': { color: secondary.main } }
- }]
+ variants: [
+ {
+ props: { color: 'default' },
+ style: { '&:hover': { color: secondary.main } },
+ },
+ ],
},
MuiIcon: {
styleOverrides: {
- root: { '& svg:nth-of-type(1)': buttonSvgStyle }
- }
+ root: { '& svg:nth-of-type(1)': buttonSvgStyle },
+ },
},
MuiAppBar: {
styleOverrides: {
@@ -325,23 +332,23 @@ export default (appTheme, mode = SCHEMES.DARK) => {
'&:hover': {
border: 'none',
backgroundColor: 'transparent',
- color: alpha(white, 0.7)
- }
- }
- }
- }
+ color: alpha(white, 0.7),
+ },
+ },
+ },
+ },
},
MuiLink: {
defaultProps: {
- underline: 'hover'
- }
+ underline: 'hover',
+ },
},
MuiFormControl: {
styleOverrides: {
root: {
- margin: '.5rem 0'
- }
- }
+ margin: '.5rem 0',
+ },
+ },
},
MuiTextField: {
defaultProps: {
@@ -349,16 +356,17 @@ export default (appTheme, mode = SCHEMES.DARK) => {
size: 'small',
color: 'secondary',
SelectProps: {
- native: true
- }
- }
+ native: true,
+ },
+ },
},
MuiTabs: {
styleOverrides: {
root: {
backgroundColor: isDarkMode ? secondary.dark : secondary.main,
borderRadius: 8,
- boxShadow: '0px 20px 25px rgba(0, 0, 0, 0.05), 0px 10px 10px rgba(0, 0, 0, 0.02)'
+ boxShadow:
+ '0px 20px 25px rgba(0, 0, 0, 0.05), 0px 10px 10px rgba(0, 0, 0, 0.02)',
},
indicator: {
backgroundColor: 'transparent',
@@ -369,10 +377,10 @@ export default (appTheme, mode = SCHEMES.DARK) => {
left: 30,
right: 30,
height: '100%',
- backgroundColor: white
- }
- }
- }
+ backgroundColor: white,
+ },
+ },
+ },
},
MuiTab: {
styleOverrides: {
@@ -381,20 +389,20 @@ export default (appTheme, mode = SCHEMES.DARK) => {
textTransform: 'capitalize',
fontSize: '1rem',
'&.Mui-selected': {
- color: white
- }
- }
- }
+ color: white,
+ },
+ },
+ },
},
MuiToggleButtonGroup: {
styleOverrides: {
root: {
- backgroundColor: isDarkMode ? primary.main : '#f2f4f8'
- }
+ backgroundColor: isDarkMode ? primary.main : '#f2f4f8',
+ },
},
defaultProps: {
- color: 'secondary'
- }
+ color: 'secondary',
+ },
},
MuiToggleButton: {
styleOverrides: {
@@ -406,25 +414,29 @@ export default (appTheme, mode = SCHEMES.DARK) => {
'&.Mui-selected': {
borderColor: `${secondary[500]} !important`,
color: isDarkMode ? white : secondary[800],
- backgroundColor: isDarkMode ? alpha(secondary[800], 0.2) : secondary[100]
- }
- }
- }
+ backgroundColor: isDarkMode
+ ? alpha(secondary[800], 0.2)
+ : secondary[100],
+ },
+ },
+ },
},
MuiList: {
defaultProps: {
- dense: true
- }
+ dense: true,
+ },
},
MuiChip: {
- variants: [{
- props: { variant: 'text' },
- style: {
- border: 0,
- backgroundColor: 'transparent'
- }
- }]
- }
- }
+ variants: [
+ {
+ props: { variant: 'text' },
+ style: {
+ border: 0,
+ backgroundColor: 'transparent',
+ },
+ },
+ ],
+ },
+ },
}
}
diff --git a/src/fireedge/src/client/theme/fonts.js b/src/fireedge/src/client/theme/fonts.js
index c1d5dbb530..f2e6dbe092 100644
--- a/src/fireedge/src/client/theme/fonts.js
+++ b/src/fireedge/src/client/theme/fonts.js
@@ -26,5 +26,5 @@ export const UbuntuFont = {
url(${FONTS_URL}/Ubuntu/ubuntu.woff) format('woff'),
url(${FONTS_URL}/Ubuntu/ubuntu.ttf) format('truetype'),
url(${FONTS_URL}/Ubuntu/ubuntu.svg#Ubuntu) format('svg');
- `
+ `,
}
diff --git a/src/fireedge/src/client/theme/index.js b/src/fireedge/src/client/theme/index.js
index feb2452673..7f3d89b0ba 100644
--- a/src/fireedge/src/client/theme/index.js
+++ b/src/fireedge/src/client/theme/index.js
@@ -14,13 +14,16 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
/* eslint-disable jsdoc/require-jsdoc */
-import { createTheme as createMuiTheme, responsiveFontSizes } from '@mui/material'
+import {
+ createTheme as createMuiTheme,
+ responsiveFontSizes,
+} from '@mui/material'
import createGenerateClassName from '@mui/styles/createGenerateClassName'
import defaultTheme from 'client/theme/defaults'
export const generateClassName = createGenerateClassName({
- productionPrefix: 'one-'
+ productionPrefix: 'one-',
})
export const createTheme = (theme, scheme) =>
diff --git a/src/fireedge/src/client/utils/environments.js b/src/fireedge/src/client/utils/environments.js
index db03431cd7..132c6d1793 100644
--- a/src/fireedge/src/client/utils/environments.js
+++ b/src/fireedge/src/client/utils/environments.js
@@ -16,7 +16,7 @@
/** @enum {string} Mode */
const MODE = {
development: 'development',
- production: 'production'
+ production: 'production',
}
/** @returns {boolean} `true` if is load in the server */
diff --git a/src/fireedge/src/client/utils/helpers.js b/src/fireedge/src/client/utils/helpers.js
index 3e668fb500..48320ad541 100644
--- a/src/fireedge/src/client/utils/helpers.js
+++ b/src/fireedge/src/client/utils/helpers.js
@@ -24,7 +24,8 @@ import { HYPERVISORS } from 'client/constants'
* @param {number} ms - Delay in milliseconds
* @returns {Promise} Promise resolved with a delay
*/
-export const fakeDelay = ms => new Promise(resolve => setTimeout(resolve, ms))
+export const fakeDelay = (ms) =>
+ new Promise((resolve) => setTimeout(resolve, ms))
/**
* Determines if url is external.
@@ -32,7 +33,7 @@ export const fakeDelay = ms => new Promise(resolve => setTimeout(resolve, ms))
* @param {string} url - URL
* @returns {boolean} `true` if url is external
*/
-export const isExternalURL = url => RegExp(/^(http|https):/g).test(url)
+export const isExternalURL = (url) => /^(http|https):/g.test(url)
/**
* Generates a random key.
@@ -49,9 +50,11 @@ export const generateKey = () =>
* @param {...string} values - Rest of text
* @returns {string} Clean and secure string
*/
-export function sanitize (text, ...values) {
- const dirty = text.reduce((prev, next, i) =>
- `${prev}${next}${values[i] || ''}`, '')
+export function sanitize(text, ...values) {
+ const dirty = text.reduce(
+ (prev, next, i) => `${prev}${next}${values[i] || ''}`,
+ ''
+ )
return DOMPurify.sanitize(dirty)
}
@@ -66,7 +69,9 @@ export function sanitize (text, ...values) {
export const decodeBase64 = (string, defaultValue = {}) => {
try {
return decodeURIComponent(escape(atob(string)))
- } catch (e) { return defaultValue }
+ } catch (e) {
+ return defaultValue
+ }
}
/**
@@ -103,6 +108,7 @@ export const prettyBytes = (value, unit = 'KB', fractionDigits = 0) => {
*/
export const addOpacityToColor = (color, opacity) => {
const opacityHex = Math.round(opacity * 255).toString(16)
+
return `${color}${opacityHex}`
}
@@ -112,11 +118,14 @@ export const addOpacityToColor = (color, opacity) => {
* @param {Array} fields - Field schemas
* @returns {object} List of validations
*/
-export const getValidationFromFields = fields =>
- fields.reduce((schema, field) => ({
- ...schema,
- [field?.name]: field?.validation
- }), {})
+export const getValidationFromFields = (fields) =>
+ fields.reduce(
+ (schema, field) => ({
+ ...schema,
+ [field?.name]: field?.validation,
+ }),
+ {}
+ )
/**
* Returns fields in schema object.
@@ -127,7 +136,7 @@ export const getValidationFromFields = fields =>
* [{ name: 'VM.NAME', validation: string() }]
* => object({ 'VM': object({ NAME: string() }) })
*/
-export const getObjectSchemaFromFields = fields =>
+export const getObjectSchemaFromFields = (fields) =>
fields.reduce((schema, field) => {
const { name, validation } = field
@@ -166,10 +175,12 @@ export const getObjectSchemaFromFields = fields =>
// Needs to find the next schema in field path
const nextIdx = idx + 1
const nextPath = paths.at(nextIdx)
+
return getSchemaByPath(path, sumSchemas(nextPath, nextIdx))
}
schema = schema.concat(sumSchemas())
+
return schema
}, object())
@@ -178,10 +189,15 @@ export const getObjectSchemaFromFields = fields =>
* @param {HYPERVISORS} hypervisor - Hypervisor
* @returns {Array} Filtered fields
*/
-export const filterFieldsByHypervisor = (fields, hypervisor = HYPERVISORS.kvm) =>
+export const filterFieldsByHypervisor = (
+ fields,
+ hypervisor = HYPERVISORS.kvm
+) =>
fields
- .map(field => typeof field === 'function' ? field(hypervisor) : field)
- .filter(({ notOnHypervisors } = {}) => !notOnHypervisors?.includes?.(hypervisor))
+ .map((field) => (typeof field === 'function' ? field(hypervisor) : field))
+ .filter(
+ ({ notOnHypervisors } = {}) => !notOnHypervisors?.includes?.(hypervisor)
+ )
/**
* Filter an object list by property.
@@ -192,7 +208,7 @@ export const filterFieldsByHypervisor = (fields, hypervisor = HYPERVISORS.kvm) =
*/
export const filterBy = (arr, predicate) => {
const callback =
- typeof predicate === 'function' ? predicate : output => output[predicate]
+ typeof predicate === 'function' ? predicate : (output) => output[predicate]
return [
...arr
@@ -203,7 +219,7 @@ export const filterBy = (arr, predicate) => {
return map
}, new Map())
- .values()
+ .values(),
]
}
@@ -216,13 +232,17 @@ export const filterBy = (arr, predicate) => {
* @returns {*} Value of property
*/
export const get = (obj, path, defaultValue = undefined) => {
- const travel = regexp =>
+ const travel = (regexp) =>
String.prototype.split
.call(path, regexp)
.filter(Boolean)
- .reduce((res, key) => (res !== null && res !== undefined ? res[key] : res), obj)
+ .reduce(
+ (res, key) => (res !== null && res !== undefined ? res[key] : res),
+ obj
+ )
const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/)
+
return result === undefined || result === obj ? defaultValue : result
}
@@ -279,7 +299,7 @@ export const groupBy = (list, key) =>
* @param {object} obj - Object
* @returns {object} Object cloned
*/
-export const cloneObject = obj => JSON.parse(JSON.stringify(obj))
+export const cloneObject = (obj) => JSON.parse(JSON.stringify(obj))
/**
* Removes undefined and null values from object.
@@ -287,13 +307,15 @@ export const cloneObject = obj => JSON.parse(JSON.stringify(obj))
* @param {object} obj - Object value
* @returns {object} - Cleaned object
*/
-export const cleanEmptyObject = obj => {
+export const cleanEmptyObject = (obj) => {
const entries = Object.entries(obj)
.filter(([_, value]) =>
// filter object/array values without attributes
isMergeableObject(value)
- ? Object.values(value).some(v => v != null)
- : Array.isArray(value) ? value.length > 0 : true
+ ? Object.values(value).some((v) => v != null)
+ : Array.isArray(value)
+ ? value.length > 0
+ : true
)
.map(([key, value]) => {
let cleanedValue = value
@@ -309,9 +331,11 @@ export const cleanEmptyObject = obj => {
return entries?.length > 0
? entries.reduce((cleanedObject, [key, value]) => {
- // `value == null` checks against undefined and null
- return value == null ? cleanedObject : { ...cleanedObject, [key]: value }
- }, {})
+ // `value == null` checks against undefined and null
+ return value == null
+ ? cleanedObject
+ : { ...cleanedObject, [key]: value }
+ }, {})
: undefined
}
@@ -321,12 +345,14 @@ export const cleanEmptyObject = obj => {
* @param {Array} arr - Array value
* @returns {object} - Cleaned object
*/
-export const cleanEmptyArray = arr => arr
- .map(value => isMergeableObject(value) ? cleanEmpty(value) : value)
- .filter(value =>
- !(value == null) || // `value == null` checks against undefined and null
- (Array.isArray(value) && value.length > 0)
- )
+export const cleanEmptyArray = (arr) =>
+ arr
+ .map((value) => (isMergeableObject(value) ? cleanEmpty(value) : value))
+ .filter(
+ (value) =>
+ !(value == null) || // `value == null` checks against undefined and null
+ (Array.isArray(value) && value.length > 0)
+ )
/**
* Removes undefined and null values from variable.
@@ -334,8 +360,10 @@ export const cleanEmptyArray = arr => arr
* @param {Array|object} variable - Variable
* @returns {Array|object} - Cleaned variable
*/
-export const cleanEmpty = variable =>
- Array.isArray(variable) ? cleanEmptyArray(variable) : cleanEmptyObject(variable)
+export const cleanEmpty = (variable) =>
+ Array.isArray(variable)
+ ? cleanEmptyArray(variable)
+ : cleanEmptyObject(variable)
/**
* Check if value is in base64.
@@ -350,8 +378,10 @@ export const isBase64 = (stringToValidate, options = {}) => {
const { exact = true } = options
- const BASE64_REG = /(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)/g
- const EXACT_BASE64_REG = /(?:^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$)/
+ const BASE64_REG =
+ /(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)/g
+ const EXACT_BASE64_REG =
+ /(?:^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$)/
const regex = exact ? EXACT_BASE64_REG : BASE64_REG
@@ -364,7 +394,8 @@ export const isBase64 = (stringToValidate, options = {}) => {
* @param {string|number} value - Number to check
* @returns {boolean} Returns `true` if string is divisible by 4
*/
-export const isDivisibleBy4 = value => /[048]|\d*([02468][048]|[13579][26])/g.test(value)
+export const isDivisibleBy4 = (value) =>
+ /[048]|\d*([02468][048]|[13579][26])/g.test(value)
/**
* Check if value is divisible by another number.
@@ -381,5 +412,5 @@ export const isDivisibleBy = (number, divisor) => !(number % divisor)
* @param {number} value - Number
* @returns {number[]} Returns list of numbers
*/
-export const getFactorsOfNumber = value =>
- [...Array(+value + 1).keys()].filter(idx => value % idx === 0)
+export const getFactorsOfNumber = (value) =>
+ [...Array(+value + 1).keys()].filter((idx) => value % idx === 0)
diff --git a/src/fireedge/src/client/utils/merge.js b/src/fireedge/src/client/utils/merge.js
index c18fe19cd0..23b7209bb5 100644
--- a/src/fireedge/src/client/utils/merge.js
+++ b/src/fireedge/src/client/utils/merge.js
@@ -23,19 +23,21 @@
* @param {object|Array} val - Value
* @returns {boolean} Returns `true` if value isn't regex or date object
*/
-export const isMergeableObject = val => {
- var nonNullObject = val && typeof val === 'object'
+export const isMergeableObject = (val) => {
+ const nonNullObject = val && typeof val === 'object'
- return nonNullObject &&
- Object.prototype.toString.call(val) !== '[object RegExp]' &&
- Object.prototype.toString.call(val) !== '[object Date]'
+ return (
+ nonNullObject &&
+ Object.prototype.toString.call(val) !== '[object RegExp]' &&
+ Object.prototype.toString.call(val) !== '[object Date]'
+ )
}
/**
* @param {object|Array} val - Value
* @returns {object|Array} Empty value
*/
-export const emptyTarget = val => Array.isArray(val) ? [] : {}
+export const emptyTarget = (val) => (Array.isArray(val) ? [] : {})
/**
* @param {Array} value - Value
@@ -43,8 +45,9 @@ export const emptyTarget = val => Array.isArray(val) ? [] : {}
* @returns {*} Returns the value as clone if required
*/
export const cloneIfNecessary = (value, options) => {
- return (options?.clone === true && isMergeableObject(value))
- ? deepmerge(emptyTarget(value), value, options) : value
+ return options?.clone === true && isMergeableObject(value)
+ ? deepmerge(emptyTarget(value), value, options)
+ : value
}
/**
@@ -54,7 +57,7 @@ export const cloneIfNecessary = (value, options) => {
* @returns {Array} Two arrays merged
*/
export const defaultArrayMerge = (target, source, options) => {
- var destination = target.slice()
+ const destination = target.slice()
source.forEach(function (e, i) {
if (typeof destination[i] === 'undefined') {
destination[i] = cloneIfNecessary(e, options)
@@ -64,6 +67,7 @@ export const defaultArrayMerge = (target, source, options) => {
destination.push(cloneIfNecessary(e, options))
}
})
+
return destination
}
@@ -74,7 +78,7 @@ export const defaultArrayMerge = (target, source, options) => {
* @returns {object} Two object merged
*/
export const mergeObject = (target, source, options) => {
- var destination = {}
+ const destination = {}
if (isMergeableObject(target)) {
Object.keys(target).forEach(function (key) {
destination[key] = cloneIfNecessary(target[key], options)
@@ -87,6 +91,7 @@ export const mergeObject = (target, source, options) => {
destination[key] = deepmerge(target[key], source[key], options)
}
})
+
return destination
}
@@ -99,7 +104,7 @@ export const mergeObject = (target, source, options) => {
* @returns {object} Two object merged
*/
export const deepmerge = (target, source, options = {}) => {
- var array = Array.isArray(source)
+ const array = Array.isArray(source)
const { arrayMerge = defaultArrayMerge } = options
if (array) {
@@ -111,9 +116,11 @@ export const deepmerge = (target, source, options = {}) => {
}
}
-deepmerge.all = function deepmergeAll (array, options) {
+deepmerge.all = function deepmergeAll(array, options) {
if (!Array.isArray(array) || array.length < 2) {
- throw new Error('first argument should be an array with at least two elements')
+ throw new Error(
+ 'first argument should be an array with at least two elements'
+ )
}
// we are sure there are at least 2 values, so it is safe to have no initial value
diff --git a/src/fireedge/src/client/utils/parser/index.js b/src/fireedge/src/client/utils/parser/index.js
index 3cbf07572e..0ab7506188 100644
--- a/src/fireedge/src/client/utils/parser/index.js
+++ b/src/fireedge/src/client/utils/parser/index.js
@@ -22,5 +22,5 @@ export {
templateToObject,
parseApplicationToForm,
parseFormToApplication,
- parseFormToDeployApplication
+ parseFormToDeployApplication,
}
diff --git a/src/fireedge/src/client/utils/parser/parseApplicationToForm.js b/src/fireedge/src/client/utils/parser/parseApplicationToForm.js
index b69b2bfbc1..99447fb3c9 100644
--- a/src/fireedge/src/client/utils/parser/parseApplicationToForm.js
+++ b/src/fireedge/src/client/utils/parser/parseApplicationToForm.js
@@ -22,7 +22,7 @@ import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/For
import { templateToObject } from 'client/utils'
-const parseNetwork = input => {
+const parseNetwork = (input) => {
const [name, values] = input
const network = String(values).split('|')
// 0 mandatory; 1 network (user input type); 2 description; 3 empty; 4 info_network;
@@ -42,11 +42,11 @@ const parseNetwork = input => {
description,
type,
idVnet,
- extra
+ extra,
}
}
-const parseCluster = tiers => {
+const parseCluster = (tiers) => {
const NUM_REG = /(\d+)/g
const clusters = tiers?.map(({ vm_template_contents: content = '' }) => {
@@ -55,7 +55,7 @@ const parseCluster = tiers => {
return schedRequirements?.match(NUM_REG)?.join()
})
- return clusters?.find(i => i !== undefined)
+ return clusters?.find((i) => i !== undefined)
}
const parseTiers = (roles, networking) =>
@@ -73,7 +73,7 @@ const parseTiers = (roles, networking) =>
vm_template_contents: content = '',
elasticity_policies: elasticityPolicies = [],
scheduled_policies: scheduledPolicies = [],
- position = { x: 0, y: 0 }
+ position = { x: 0, y: 0 },
} = data
const hash = templateToObject(content)
@@ -82,7 +82,8 @@ const parseTiers = (roles, networking) =>
const networks =
nics?.map(({ network_id: networkId }) => {
const nicName = networkId?.replace('$', '')
- const network = networking?.find(vnet => vnet.name === nicName)
+ const network = networking?.find((vnet) => vnet.name === nicName)
+
return network.id
}) ?? []
@@ -96,14 +97,15 @@ const parseTiers = (roles, networking) =>
...JSON.parse(JSON.stringify(rest)),
...(recurrence && {
time_format: 'recurrence',
- time_expression: recurrence
+ time_expression: recurrence,
}),
...(time && {
time_format: 'start_time',
- time_expression: time
- })
+ time_expression: time,
+ }),
}
- })
+ }
+ )
return [
...res,
@@ -117,16 +119,17 @@ const parseTiers = (roles, networking) =>
max_vms: maxVms,
cooldown,
elasticity,
- scheduled
+ scheduled,
},
position,
- tier: { name, cardinality, shutdown_action: shutdownAction }
- }
+ tier: { name, cardinality, shutdown_action: shutdownAction },
+ },
]
}, [])
.reduce((res, tier, _, src) => {
- const parents = tier.parents?.map(name => {
- const parent = src.find(item => item.tier.name === name)
+ const parents = tier.parents?.map((name) => {
+ const parent = src.find((item) => item.tier.name === name)
+
return parent?.id
})
@@ -139,12 +142,12 @@ const parseTiers = (roles, networking) =>
* @param {object} data - OpenNebula service
* @returns {object} Form data
*/
-const mapApplicationToForm = data => {
+const mapApplicationToForm = (data) => {
const {
NAME,
TEMPLATE: {
- BODY: { networks = [], roles, ...application }
- }
+ BODY: { networks = [], roles, ...application },
+ },
} = data
const networking = Object.entries(networks)?.map(parseNetwork) ?? []
@@ -154,11 +157,11 @@ const mapApplicationToForm = data => {
return {
[APPLICATION_ID]: {
...application,
- name: NAME
+ name: NAME,
},
[NETWORKING_ID]: networking,
[CLUSTER_ID]: cluster,
- [TIERS_ID]: tiers
+ [TIERS_ID]: tiers,
}
}
diff --git a/src/fireedge/src/client/utils/parser/parseFormToApplication.js b/src/fireedge/src/client/utils/parser/parseFormToApplication.js
index d18e8338fe..05438ae0c3 100644
--- a/src/fireedge/src/client/utils/parser/parseFormToApplication.js
+++ b/src/fireedge/src/client/utils/parser/parseFormToApplication.js
@@ -18,7 +18,7 @@ import { STEP_ID as CLUSTER_ID } from 'client/containers/ApplicationsTemplates/F
import { STEP_ID as NETWORKING_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Networking'
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Tiers'
-const mapNetworkToUserInput = network => {
+const mapNetworkToUserInput = (network) => {
const { mandatory, description, type, idVnet, extra } = network
const mandatoryValue = mandatory ? 'M' : 'O'
@@ -39,14 +39,14 @@ const mapNetworkToUserInput = network => {
* @returns {Array} Roles
*/
export const mapTiersToRoles = (tiers, networking, cluster) =>
- tiers?.map(data => {
+ tiers?.map((data) => {
const { template, networks, parents, policies, position, tier } = data
const { shutdown_action: action, ...information } = tier
const { elasticity, scheduled, ...adjustments } = policies
const networksValue = networks
?.reduce((res, id, idx) => {
- const network = networking.find(net => net.id === id)
+ const network = networking.find((net) => net.id === id)
const networkString = `NIC = [\n NAME = "NIC${idx}",\n NETWORK_ID = "$${network.name}" ]\n`
return [...res, networkString]
@@ -55,7 +55,8 @@ export const mapTiersToRoles = (tiers, networking, cluster) =>
?.concat(`SCHED_REQUIREMENTS = "ClUSTER_ID=\\"${cluster}\\""`)
const parentsValue = parents?.reduce((res, id) => {
- const parent = tiers.find(t => t.id === id)
+ const parent = tiers.find((t) => t.id === id)
+
return [...res, parent?.tier?.name]
}, [])
@@ -66,7 +67,7 @@ export const mapTiersToRoles = (tiers, networking, cluster) =>
const scheduledValues = scheduled.map(
({ id, time_format: format, time_expression: expression, ...rest }) => ({
...JSON.parse(JSON.stringify(rest)),
- ...(expression && { [format]: expression })
+ ...(expression && { [format]: expression }),
})
)
@@ -79,7 +80,7 @@ export const mapTiersToRoles = (tiers, networking, cluster) =>
vm_template_contents: networksValue,
elasticity_policies: elasticityValues,
scheduled_policies: scheduledValues,
- position
+ position,
}
})
@@ -89,12 +90,12 @@ export const mapTiersToRoles = (tiers, networking, cluster) =>
* @param {object} formData - Form data
* @returns {object} Formatted data ready to create or update the template.
*/
-const mapFormToApplication = formData => {
+const mapFormToApplication = (formData) => {
const {
[APPLICATION_ID]: application,
[NETWORKING_ID]: networking,
[CLUSTER_ID]: cluster,
- [TIERS_ID]: tiers
+ [TIERS_ID]: tiers,
} = formData
const { shutdown_action: action, ...information } = application
@@ -106,11 +107,11 @@ const mapFormToApplication = formData => {
networking?.reduce(
(res, { name, ...network }) => ({
...res,
- [name]: mapNetworkToUserInput(network)
+ [name]: mapNetworkToUserInput(network),
}),
{}
) ?? {},
- roles: mapTiersToRoles(tiers, networking, cluster)
+ roles: mapTiersToRoles(tiers, networking, cluster),
}
}
diff --git a/src/fireedge/src/client/utils/parser/parseFormToDeployApplication.js b/src/fireedge/src/client/utils/parser/parseFormToDeployApplication.js
index 5c21eaba3c..12a1ea34ec 100644
--- a/src/fireedge/src/client/utils/parser/parseFormToDeployApplication.js
+++ b/src/fireedge/src/client/utils/parser/parseFormToDeployApplication.js
@@ -30,12 +30,12 @@ import { mapUserInputs, deepmerge } from 'client/utils'
* @returns {Array} Roles
*/
export const mapTiersToRoles = (tiers, networking, cluster) =>
- tiers?.map(data => {
+ tiers?.map((data) => {
const { template, parents, networks, user_inputs_values = {}, tier } = data
const networksValue = networks
?.reduce((res, id, idx) => {
- const network = networking.find(net => net.id === id)
+ const network = networking.find((net) => net.id === id)
const networkString = `NIC = [\n NAME = "NIC${idx}",\n NETWORK_ID = "$${network.name}" ]\n`
return [...res, networkString]
@@ -44,7 +44,8 @@ export const mapTiersToRoles = (tiers, networking, cluster) =>
?.concat(`SCHED_REQUIREMENTS = "ClUSTER_ID=\\"${cluster}\\""`)
const parentsValue = parents?.reduce((res, id) => {
- const parent = tiers.find(t => t.id === id)
+ const parent = tiers.find((t) => t.id === id)
+
return [...res, parent?.tier?.name]
}, [])
@@ -53,7 +54,7 @@ export const mapTiersToRoles = (tiers, networking, cluster) =>
parents: parentsValue,
vm_template: template?.id ?? template?.app,
vm_template_contents: networksValue,
- user_inputs_values: mapUserInputs(user_inputs_values)
+ user_inputs_values: mapUserInputs(user_inputs_values),
}
})
@@ -69,16 +70,16 @@ const parseFormToDeployApplication = (formData, template) => {
[BASIC_ID]: application,
[NETWORKING_ID]: networking,
[CLUSTER_ID]: cluster,
- [TIERS_ID]: tiers
+ [TIERS_ID]: tiers,
} = deepmerge(template, formData)
return {
...application,
custom_attrs_values: {},
networks_values: networking?.map(({ name, type, idVnet }) => ({
- [name]: { [type]: idVnet }
+ [name]: { [type]: idVnet },
})),
- roles: mapTiersToRoles(tiers, networking, cluster)
+ roles: mapTiersToRoles(tiers, networking, cluster),
}
}
diff --git a/src/fireedge/src/client/utils/parser/templateToObject.js b/src/fireedge/src/client/utils/parser/templateToObject.js
index 6931c8fb51..4e0e655089 100644
--- a/src/fireedge/src/client/utils/parser/templateToObject.js
+++ b/src/fireedge/src/client/utils/parser/templateToObject.js
@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const SINGLE_VARIABLE_REG = /^\s*(?[\w\d_-]+)\s*=\s*(?[^[\],]+?)(?:#.*)?$/gm
-const ARRAY_VARIABLE_REG = /\s*(?[\w\d_-]+)\s*=\s*\[(?.*?)\]/gm
+const SINGLE_VARIABLE_REG =
+ /^\s*(?[\w\d_-]+)\s*=\s*(?[^[\],]+?)(?:#.*)?$/gm
+const ARRAY_VARIABLE_REG =
+ /\s*(?[\w\d_-]+)\s*=\s*\[(?.*?)\]/gm
-const sanitizeKey = key => key?.trim().toLowerCase()
+const sanitizeKey = (key) => key?.trim().toLowerCase()
-const sanitizeValue = value => value?.trim().replaceAll(/[\\"]/g, '')
+const sanitizeValue = (value) => value?.trim().replaceAll(/[\\"]/g, '')
/**
* Parses OpenNebula resource template to json.
@@ -26,7 +28,7 @@ const sanitizeValue = value => value?.trim().replaceAll(/[\\"]/g, '')
* @param {string} template - OpenNebula resource template
* @returns {object} JSON of template
*/
-const parseTemplateToObject = template => {
+const parseTemplateToObject = (template) => {
const stringWithoutNewLines = JSON.stringify(template).replaceAll(/\\n/g, '')
return {
@@ -46,16 +48,17 @@ const parseTemplateToObject = template => {
const vars = pieces.reduce((vrs, piece) => {
const [key, value] = piece.split('=')
+
return { ...vrs, [sanitizeKey(key)]: sanitizeValue(value) }
}, {})
return {
...result,
- [masterKey]: [...(result[masterKey] ?? []), vars]
+ [masterKey]: [...(result[masterKey] ?? []), vars],
}
},
{}
- )
+ ),
}
}
diff --git a/src/fireedge/src/client/utils/request.js b/src/fireedge/src/client/utils/request.js
index d73340f8f0..f8988c49ed 100644
--- a/src/fireedge/src/client/utils/request.js
+++ b/src/fireedge/src/client/utils/request.js
@@ -18,7 +18,7 @@ import { defaults } from 'server/utils/constants'
const { from: resourceFrom } = defaults
-const getQueries = params =>
+const getQueries = (params) =>
Object.entries(params)
?.filter(
([, { from, value }]) =>
@@ -27,13 +27,13 @@ const getQueries = params =>
?.map(([name, { value }]) => `${name}=${encodeURI(value)}`)
?.join('&')
-const getResources = params =>
+const getResources = (params) =>
Object.values(params)
?.filter(({ from }) => from === resourceFrom.resource)
?.map(({ value }) => value)
?.join('/')
-const getDataBody = params =>
+const getDataBody = (params) =>
Object.entries(params)
?.filter(([, { from }]) => from === resourceFrom.postBody)
?.reduce((acc, [name, { value }]) => ({ ...acc, [name]: value }), {})
@@ -51,14 +51,13 @@ export const requestConfig = (data, command) => {
const { name, httpMethod, params = {} } = command
/* Spread 'from' values in current params */
- const mappedParams =
- Object.entries(params)?.reduce(
- (params, [paraName, { from }]) => ({
- ...params,
- [paraName]: { from, value: data[paraName] }
- }),
- {}
- )
+ const mappedParams = Object.entries(params)?.reduce(
+ (params, [paraName, { from }]) => ({
+ ...params,
+ [paraName]: { from, value: data[paraName] },
+ }),
+ {}
+ )
const queries = getQueries(mappedParams)
const resources = getResources(mappedParams)
@@ -69,6 +68,6 @@ export const requestConfig = (data, command) => {
return {
url: `${url}/${resources}?${queries}`,
data: body,
- method: httpMethod
+ method: httpMethod,
}
}
diff --git a/src/fireedge/src/client/utils/rest.js b/src/fireedge/src/client/utils/rest.js
index aab5cd2a8c..bbc703f996 100644
--- a/src/fireedge/src/client/utils/rest.js
+++ b/src/fireedge/src/client/utils/rest.js
@@ -23,7 +23,7 @@ import { T, JWT_NAME, APP_URL } from 'client/constants'
const http = axios.create({ baseURL: APP_URL })
-http.interceptors.request.use(config => {
+http.interceptors.request.use((config) => {
const token = findStorageData(JWT_NAME)
token && (config.headers.Authorization = `Bearer ${token}`)
@@ -31,29 +31,27 @@ http.interceptors.request.use(config => {
...config,
headers: {
...config.headers,
- 'Content-Type': 'application/json'
+ 'Content-Type': 'application/json',
},
timeout: 45_000,
timeoutErrorMessage: T.Timeout,
withCredentials: true,
- validateStatus: status =>
- Object.values(httpCodes).some(({ id }) => id === status)
+ validateStatus: (status) =>
+ Object.values(httpCodes).some(({ id }) => id === status),
}
})
http.interceptors.response.use(
- response => {
+ (response) => {
if (response?.data && response?.status < httpCodes.badRequest.id) {
- return typeof response === 'string'
- ? response.data.json()
- : response.data
+ return typeof response === 'string' ? response.data.json() : response.data
}
if (response.status === httpCodes.unauthorized.id) {
const configErrorParser = {
color: 'red',
error: response?.data?.message ?? response?.statusText,
- message: 'Error request: %s'
+ message: 'Error request: %s',
}
isDevelopment() && messageTerminal(configErrorParser)
@@ -61,7 +59,7 @@ http.interceptors.response.use(
return Promise.reject(response)
},
- error => error
+ (error) => error
)
export const RestClient = {
@@ -69,5 +67,5 @@ export const RestClient = {
* @param {AxiosRequestConfig} options - Request configuration
* @returns {AxiosResponse} Response from server
*/
- request: options => http.request(options)
+ request: (options) => http.request(options),
}
diff --git a/src/fireedge/src/client/utils/schema.js b/src/fireedge/src/client/utils/schema.js
index fb12c2d591..9610481793 100644
--- a/src/fireedge/src/client/utils/schema.js
+++ b/src/fireedge/src/client/utils/schema.js
@@ -17,13 +17,26 @@
// eslint-disable-next-line no-unused-vars
import { JSXElementConstructor, SetStateAction } from 'react'
-// eslint-disable-next-line no-unused-vars
-import { GridProps, TextFieldProps, CheckboxProps, InputBaseComponentProps } from '@mui/material'
+import {
+ // eslint-disable-next-line no-unused-vars
+ GridProps,
+ // eslint-disable-next-line no-unused-vars
+ TextFieldProps,
+ // eslint-disable-next-line no-unused-vars
+ CheckboxProps,
+ // eslint-disable-next-line no-unused-vars
+ InputBaseComponentProps,
+} from '@mui/material'
import { string, number, boolean, array, object, BaseSchema } from 'yup'
// eslint-disable-next-line no-unused-vars
import { Row } from 'react-table'
-import { UserInputObject, T, INPUT_TYPES, USER_INPUT_TYPES } from 'client/constants'
+import {
+ UserInputObject,
+ T,
+ INPUT_TYPES,
+ USER_INPUT_TYPES,
+} from 'client/constants'
// ----------------------------------------------------------
// Types
@@ -181,25 +194,27 @@ const SEMICOLON_CHAR = ';'
const requiredSchema = (mandatory, schema) =>
mandatory ? schema.required() : schema.notRequired().nullable()
-const getRange = options => options?.split('..').map(option => parseFloat(option))
+const getRange = (options) =>
+ options?.split('..').map((option) => parseFloat(option))
-const getValuesFromArray = (options, separator = SEMICOLON_CHAR) => options?.split(separator)
+const getValuesFromArray = (options, separator = SEMICOLON_CHAR) =>
+ options?.split(separator)
-const getOptionsFromList = options => options
- ?.map(option => typeof option === 'string'
- ? ({ text: option, value: option })
- : option
- )
- ?.filter(({ text, value } = {}) => text && value)
+const getOptionsFromList = (options) =>
+ options
+ ?.map((option) =>
+ typeof option === 'string' ? { text: option, value: option } : option
+ )
+ ?.filter(({ text, value } = {}) => text && value)
-const parseUserInputValue = value => {
+const parseUserInputValue = (value) => {
if (value === true) {
return 'YES'
} else if (value === false) {
return 'NO'
} else if (
Array.isArray(value) &&
- value.every(v => typeof v === 'string')
+ value.every((v) => typeof v === 'string')
) {
return value.join(',')
} else return value
@@ -216,27 +231,35 @@ const parseUserInputValue = value => {
* @param {number|string|string[]} [userInput.default] - Default value for the input
* @returns {Field} Field properties
*/
-export const schemaUserInput = ({ mandatory, name, type, options, default: defaultValue }) => {
+export const schemaUserInput = ({
+ mandatory,
+ name,
+ type,
+ options,
+ default: defaultValue,
+}) => {
switch (type) {
case USER_INPUT_TYPES.text:
case USER_INPUT_TYPES.text64:
- case USER_INPUT_TYPES.password: return {
- type: INPUT_TYPES.TEXT,
- htmlType: type === 'password' ? 'password' : 'text',
- validation: string()
- .trim()
- .concat(requiredSchema(mandatory, string()))
- .default(defaultValue || undefined)
- }
+ case USER_INPUT_TYPES.password:
+ return {
+ type: INPUT_TYPES.TEXT,
+ htmlType: type === 'password' ? 'password' : 'text',
+ validation: string()
+ .trim()
+ .concat(requiredSchema(mandatory, string()))
+ .default(defaultValue || undefined),
+ }
case USER_INPUT_TYPES.number:
- case USER_INPUT_TYPES.numberFloat: return {
- type: INPUT_TYPES.TEXT,
- htmlType: 'number',
- validation: number()
- .concat(requiredSchema(mandatory, number()))
- .transform(value => !isNaN(value) ? value : null)
- .default(() => parseFloat(defaultValue) ?? undefined)
- }
+ case USER_INPUT_TYPES.numberFloat:
+ return {
+ type: INPUT_TYPES.TEXT,
+ htmlType: 'number',
+ validation: number()
+ .concat(requiredSchema(mandatory, number()))
+ .transform((value) => (!isNaN(value) ? value : null))
+ .default(() => parseFloat(defaultValue) ?? undefined),
+ }
case USER_INPUT_TYPES.range:
case USER_INPUT_TYPES.rangeFloat: {
const [min, max] = getRange(options)
@@ -247,18 +270,19 @@ export const schemaUserInput = ({ mandatory, name, type, options, default: defau
.concat(requiredSchema(mandatory, number()))
.min(min)
.max(max)
- .transform(value => !isNaN(value) ? value : undefined)
+ .transform((value) => (!isNaN(value) ? value : undefined))
.default(parseFloat(defaultValue) ?? undefined),
- fieldProps: { min, max, step: type === 'range-float' ? 0.01 : 1 }
+ fieldProps: { min, max, step: type === 'range-float' ? 0.01 : 1 },
}
}
- case USER_INPUT_TYPES.boolean: return {
- type: INPUT_TYPES.CHECKBOX,
- validation: boolean()
- .concat(requiredSchema(mandatory, boolean()))
- .default(defaultValue === 'YES' ?? false)
- .yesOrNo()
- }
+ case USER_INPUT_TYPES.boolean:
+ return {
+ type: INPUT_TYPES.CHECKBOX,
+ validation: boolean()
+ .concat(requiredSchema(mandatory, boolean()))
+ .default(defaultValue === 'YES' ?? false)
+ .yesOrNo(),
+ }
case USER_INPUT_TYPES.list: {
const values = getOptionsFromList(options)
const firstOption = values?.[0]?.value ?? undefined
@@ -270,7 +294,7 @@ export const schemaUserInput = ({ mandatory, name, type, options, default: defau
.trim()
.concat(requiredSchema(mandatory, string()))
.oneOf(values.map(({ value }) => value))
- .default(() => defaultValue || firstOption)
+ .default(() => defaultValue || firstOption),
}
}
case USER_INPUT_TYPES.array: {
@@ -284,7 +308,7 @@ export const schemaUserInput = ({ mandatory, name, type, options, default: defau
validation: array(string().trim())
.concat(requiredSchema(mandatory, array()))
.default(() => defaultValues)
- .afterSubmit(value => value?.join(SEMICOLON_CHAR))
+ .afterSubmit((value) => value?.join(SEMICOLON_CHAR)),
}
}
case USER_INPUT_TYPES.listMultiple: {
@@ -297,16 +321,17 @@ export const schemaUserInput = ({ mandatory, name, type, options, default: defau
multiple: true,
validation: array(string().trim())
.concat(requiredSchema(mandatory, array()))
- .default(defaultValues)
+ .default(defaultValues),
}
}
- default: return {
- type: INPUT_TYPES.TEXT,
- validation: string()
- .trim()
- .concat(requiredSchema(mandatory, string()))
- .default(defaultValue || undefined)
- }
+ default:
+ return {
+ type: INPUT_TYPES.TEXT,
+ validation: string()
+ .trim()
+ .concat(requiredSchema(mandatory, string()))
+ .default(defaultValue || undefined),
+ }
}
}
@@ -320,9 +345,13 @@ export const schemaUserInput = ({ mandatory, name, type, options, default: defau
* @returns {object} - Returns same object with values can be operated by OpenNebula
*/
export const mapUserInputs = (userInputs = {}) =>
- Object.entries(userInputs)?.reduce((res, [key, value]) => ({
- ...res, [key]: parseUserInputValue(value)
- }), {})
+ Object.entries(userInputs)?.reduce(
+ (res, [key, value]) => ({
+ ...res,
+ [key]: parseUserInputValue(value),
+ }),
+ {}
+ )
/**
* Converts a list of values to usable options.
@@ -335,9 +364,12 @@ export const mapUserInputs = (userInputs = {}) =>
* @returns {SelectOption} Options
*/
export const arrayToOptions = (array = [], options = {}) => {
- const { addEmpty = true, getText = o => o, getValue = o => o } = options
+ const { addEmpty = true, getText = (o) => o, getValue = (o) => o } = options
- const values = array.map(item => ({ text: getText(item), value: getValue(item) }))
+ const values = array.map((item) => ({
+ text: getText(item),
+ value: getValue(item),
+ }))
if (addEmpty) {
typeof addEmpty === 'string'
@@ -365,12 +397,13 @@ export const clearNames = (names = '') =>
* @param {ExtraParams} [extraParams] - Extra parameters
* @returns {CreateStepsCallback} Function to get steps
*/
-export const createSteps = (steps, extraParams = {}) =>
+export const createSteps =
+ (steps, extraParams = {}) =>
(stepProps = {}, initialValues) => {
const { transformInitialValue = () => initialValues } = extraParams
const stepCallbacks = typeof steps === 'function' ? steps(stepProps) : steps
- const performedSteps = stepCallbacks.map(step => step(stepProps))
+ const performedSteps = stepCallbacks.map((step) => step(stepProps))
const schemas = {}
for (const { id, resolver } of performedSteps) {
@@ -389,7 +422,7 @@ export const createSteps = (steps, extraParams = {}) =>
steps: performedSteps,
defaultValues,
resolver: () => allResolver,
- ...extraParams
+ ...extraParams,
}
}
@@ -401,7 +434,8 @@ export const createSteps = (steps, extraParams = {}) =>
* @param {ExtraParams} [extraParams] - Extra parameters
* @returns {CreateFormCallback} Function to get form parameters
*/
-export const createForm = (schema, fields, extraParams = {}) =>
+export const createForm =
+ (schema, fields, extraParams = {}) =>
(props = {}, initialValues) => {
const schemaCallback = typeof schema === 'function' ? schema(props) : schema
const fieldsCallback = typeof fields === 'function' ? fields(props) : fields
@@ -419,6 +453,6 @@ export const createForm = (schema, fields, extraParams = {}) =>
resolver: () => schemaCallback,
fields: () => fieldsCallback,
defaultValues,
- ...extraParams
+ ...extraParams,
}
}
diff --git a/src/fireedge/src/client/utils/storage.js b/src/fireedge/src/client/utils/storage.js
index f4a206c03e..e74bdbc3c6 100644
--- a/src/fireedge/src/client/utils/storage.js
+++ b/src/fireedge/src/client/utils/storage.js
@@ -41,7 +41,7 @@ export const storage = (name = '', data = '', keepData = false) => {
export const removeStoreData = (items = []) => {
const itemsToRemove = !Array.isArray(items) ? [items] : items
- itemsToRemove.forEach(item => {
+ itemsToRemove.forEach((item) => {
root?.localStorage?.removeItem(item)
root?.sessionStorage?.removeItem(item)
})
diff --git a/src/fireedge/src/client/utils/string.js b/src/fireedge/src/client/utils/string.js
index 784a4c3a1a..1da7141194 100644
--- a/src/fireedge/src/client/utils/string.js
+++ b/src/fireedge/src/client/utils/string.js
@@ -20,7 +20,8 @@
* @param {string} input - Input string
* @returns {string} Input string modified
*/
-export const upperCaseFirst = input => input?.charAt(0)?.toUpperCase() + input?.substr(1)
+export const upperCaseFirst = (input) =>
+ input?.charAt(0)?.toUpperCase() + input?.substr(1)
/**
* Transform into a lower case with spaces between words, then capitalize the string.
@@ -32,7 +33,7 @@ export const upperCaseFirst = input => input?.charAt(0)?.toUpperCase() + input?.
* @example // "testString" => "Test string"
* @example // "TESTString" => "Test string"
*/
-export const sentenceCase = input => {
+export const sentenceCase = (input) => {
const sentence = input
?.replace(/[-_]([A-Za-z])/g, ' $1')
?.replace(/([A-Z])([A-Z][a-z])/g, '$1 $2')
@@ -49,9 +50,7 @@ export const sentenceCase = input => {
* @returns {string} string
* @example //=> "testString"
*/
-export const camelCase = input => input
- .toLowerCase()
- .replace(
- /([-_\s][a-z])/ig,
- $1 => $1.toUpperCase().replace(/[-_\s]/g, '')
- )
+export const camelCase = (input) =>
+ input
+ .toLowerCase()
+ .replace(/([-_\s][a-z])/gi, ($1) => $1.toUpperCase().replace(/[-_\s]/g, ''))
diff --git a/src/fireedge/src/client/utils/translation.js b/src/fireedge/src/client/utils/translation.js
index 8e66820a6f..a6e66180ee 100644
--- a/src/fireedge/src/client/utils/translation.js
+++ b/src/fireedge/src/client/utils/translation.js
@@ -14,13 +14,22 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { setLocale, addMethod, number, string, boolean, object, array, date } from 'yup'
+import {
+ setLocale,
+ addMethod,
+ number,
+ string,
+ boolean,
+ object,
+ array,
+ date,
+} from 'yup'
import { T } from 'client/constants'
import { isDivisibleBy, isBase64 } from 'client/utils/helpers'
const buildMethods = () => {
- [number, string, boolean, object, array, date].forEach(schemaType => {
+ ;[number, string, boolean, object, array, date].forEach((schemaType) => {
addMethod(schemaType, 'afterSubmit', function (fn) {
this._mutate = true // allows to mutate the initial schema
this.submit = (...args) =>
@@ -41,13 +50,11 @@ const buildMethods = () => {
})
addMethod(boolean, 'yesOrNo', function (addAfterSubmit = true) {
const schema = this.transform(function (value) {
- return !this.isType(value)
- ? String(value).toUpperCase() === 'YES'
- : value
+ return !this.isType(value) ? String(value).toUpperCase() === 'YES' : value
})
if (addAfterSubmit) {
- schema.afterSubmit(value => value ? 'YES' : 'NO')
+ schema.afterSubmit((value) => (value ? 'YES' : 'NO'))
}
return schema
@@ -56,14 +63,14 @@ const buildMethods = () => {
return this.test(
'is-divisible',
[T['validation.number.isDivisible'], divisor],
- value => isDivisibleBy(value, divisor)
+ (value) => isDivisibleBy(value, divisor)
)
})
addMethod(string, 'isBase64', function () {
return this.test(
'is-base64',
T['validation.string.invalidFormat'],
- value => isBase64(value)
+ (value) => isBase64(value)
)
})
addMethod(string, 'includesInOptions', function (options, separator = ',') {
@@ -74,8 +81,8 @@ const buildMethods = () => {
test: function (values) {
return values
?.split(separator)
- ?.every(value => this.resolve(options).includes(value))
- }
+ ?.every((value) => this.resolve(options).includes(value))
+ },
})
})
}
@@ -94,7 +101,7 @@ const buildTranslationLocale = () => {
oneOf: ({ values }) => [T['validation.mixed.oneOf'], values],
notOneOf: ({ values }) => [T['validation.mixed.notOneOf'], values],
notType: ({ type }) =>
- T[`validation.mixed.notType.${type}`] ?? T['validation.mixed.notType']
+ T[`validation.mixed.notType.${type}`] ?? T['validation.mixed.notType'],
},
string: {
length: ({ length }) => [T['validation.string.length'], length],
@@ -106,7 +113,7 @@ const buildTranslationLocale = () => {
uuid: () => T['validation.string.uuid'],
trim: () => T['validation.string.trim'],
lowercase: () => T['validation.string.lowercase'],
- uppercase: () => T['validation.string.uppercase']
+ uppercase: () => T['validation.string.uppercase'],
},
number: {
min: ({ min }) => [T['validation.number.min'], min],
@@ -115,23 +122,26 @@ const buildTranslationLocale = () => {
moreThan: ({ more }) => [T['validation.number.moreThan'], more],
positive: () => T['validation.number.positive'],
negative: () => T['validation.number.negative'],
- integer: () => T['validation.number.integer']
+ integer: () => T['validation.number.integer'],
},
boolean: {
- isValue: ({ value }) => [T['validation.boolean.isValue'], value]
+ isValue: ({ value }) => [T['validation.boolean.isValue'], value],
},
date: {
min: ({ min }) => [T['validation.date.min'], min],
- max: ({ max }) => [T['validation.date.max'], max]
+ max: ({ max }) => [T['validation.date.max'], max],
},
object: {
- noUnknown: ({ nounknown }) => [T['validation.object.noUnknown'], nounknown]
+ noUnknown: ({ nounknown }) => [
+ T['validation.object.noUnknown'],
+ nounknown,
+ ],
},
array: {
min: ({ min }) => [T['validation.array.min'], min],
max: ({ max }) => [T['validation.array.max'], max],
- length: ({ length }) => [T['validation.array.length'], length]
- }
+ length: ({ length }) => [T['validation.array.length'], length],
+ },
})
}
diff --git a/src/fireedge/src/server/index.js b/src/fireedge/src/server/index.js
index 7c2314ed0e..b468d64df2 100644
--- a/src/fireedge/src/server/index.js
+++ b/src/fireedge/src/server/index.js
@@ -27,20 +27,27 @@ import webpack from 'webpack'
import {
entrypoint404,
entrypointApi,
- entrypointApp
+ entrypointApp,
} from './routes/entrypoints'
import { websockets } from './routes/websockets'
import { guacamole } from './routes/websockets/guacamole'
import { vmrc } from './routes/websockets/vmrc'
import { getFireedgeConfig, messageTerminal } from './utils'
import {
- defaultAppName, defaultApps,
- defaultEvents, defaultHost,
- defaultPort, defaultWebpackMode
+ defaultAppName,
+ defaultApps,
+ defaultEvents,
+ defaultHost,
+ defaultPort,
+ defaultWebpackMode,
} from './utils/constants/defaults'
import { getLoggerMiddleware, initLogger } from './utils/logger'
import {
- genFireedgeKey, genPathResources, getCert, getKey, validateServerIsSecure
+ genFireedgeKey,
+ genPathResources,
+ getCert,
+ getKey,
+ validateServerIsSecure,
} from './utils/server'
// set paths
@@ -74,7 +81,7 @@ if (env && env.NODE_ENV && env.NODE_ENV === defaultWebpackMode) {
app.use(
// eslint-disable-next-line import/no-extraneous-dependencies
require('webpack-dev-middleware')(compiler, {
- publicPath: webpackConfig.output.publicPath
+ publicPath: webpackConfig.output.publicPath,
})
)
@@ -83,14 +90,14 @@ if (env && env.NODE_ENV && env.NODE_ENV === defaultWebpackMode) {
require('webpack-hot-middleware')(compiler, {
log: false,
path: '/__webpack_hmr',
- heartbeat: 10 * 1000
+ heartbeat: 10 * 1000,
})
)
} catch (error) {
if (error) {
messageTerminal({
color: 'red',
- error
+ error,
})
}
}
@@ -117,7 +124,7 @@ app.use(express.json())
app.use(`${basename}/api`, entrypointApi) // opennebula Api routes
const frontApps = Object.keys(defaultApps)
-frontApps.forEach(frontApp => {
+frontApps.forEach((frontApp) => {
app.get(`${basename}/${frontApp}`, entrypointApp)
app.get(`${basename}/${frontApp}/*`, entrypointApp)
})
@@ -126,22 +133,28 @@ app.get('/*', (req, res) => res.redirect(`/${defaultAppName}/provision`))
app.get('*', entrypoint404)
const appServer = validateServerIsSecure()
- ? secureServer({ key: readFileSync(getKey(), 'utf8'), cert: readFileSync(getCert(), 'utf8') }, app)
+ ? secureServer(
+ {
+ key: readFileSync(getKey(), 'utf8'),
+ cert: readFileSync(getCert(), 'utf8'),
+ },
+ app
+ )
: unsecureServer(app)
const sockets = websockets(appServer) || []
let config = {
color: 'red',
- message: 'Server could not be started'
+ message: 'Server could not be started',
}
-appServer.listen(port, host, err => {
+appServer.listen(port, host, (err) => {
if (!err) {
config = {
color: 'green',
error: `${host}:${port}`,
- message: 'Server listen in %s'
+ message: 'Server listen in %s',
}
}
messageTerminal(config)
diff --git a/src/fireedge/src/server/routes/api/2fa/index.js b/src/fireedge/src/server/routes/api/2fa/index.js
index 9a10cab113..7aaa14a847 100644
--- a/src/fireedge/src/server/routes/api/2fa/index.js
+++ b/src/fireedge/src/server/routes/api/2fa/index.js
@@ -20,7 +20,7 @@ const { TFA } = require('./string-routes')
const functionRoutes = {
private: setApiRoutes(tfaRoutes, TFA),
- public: []
+ public: [],
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/2fa/string-routes.js b/src/fireedge/src/server/routes/api/2fa/string-routes.js
index b3f68566da..22edf7a4a8 100644
--- a/src/fireedge/src/server/routes/api/2fa/string-routes.js
+++ b/src/fireedge/src/server/routes/api/2fa/string-routes.js
@@ -17,7 +17,7 @@
const TFA = 'tfa'
const Actions = {
- TFA
+ TFA,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/2fa/tfa-functions.js b/src/fireedge/src/server/routes/api/2fa/tfa-functions.js
index 796f50f28a..b9939c1fd3 100644
--- a/src/fireedge/src/server/routes/api/2fa/tfa-functions.js
+++ b/src/fireedge/src/server/routes/api/2fa/tfa-functions.js
@@ -22,7 +22,7 @@ const {
default2FAIssuer,
defaultEmptyFunction,
default2FAOpennebulaVar,
- default2FAOpennebulaTmpVar
+ default2FAOpennebulaTmpVar,
} = require('server/utils/constants/defaults')
const { httpResponse } = require('server/utils/server')
const { getFireedgeConfig } = require('server/utils/yml')
@@ -31,20 +31,19 @@ const { Actions } = require('server/utils/constants/commands/user')
const {
responseOpennebula,
getDefaultParamsOfOpennebulaCommand,
- generateNewResourceTemplate
+ generateNewResourceTemplate,
} = require('server/utils/opennebula')
// user config
const appConfig = getFireedgeConfig()
-const twoFactorAuthIssuer =
- appConfig.TWO_FACTOR_AUTH_ISSUER || default2FAIssuer
+const twoFactorAuthIssuer = appConfig.TWO_FACTOR_AUTH_ISSUER || default2FAIssuer
const { GET } = httpMethod
const {
ok,
unauthorized,
- internalServerError
+ internalServerError,
} = require('server/utils/constants/http-codes')
/**
@@ -54,7 +53,11 @@ const {
* @param {Function} next - express stepper
* @param {Function} callback - run if have user information
*/
-const getUserInfoAuthenticated = (connect = defaultEmptyFunction, next = defaultEmptyFunction, callback = defaultEmptyFunction) => {
+const getUserInfoAuthenticated = (
+ connect = defaultEmptyFunction,
+ next = defaultEmptyFunction,
+ callback = defaultEmptyFunction
+) => {
connect(
Actions.USER_INFO,
getDefaultParamsOfOpennebulaCommand(Actions.USER_INFO, GET),
@@ -63,7 +66,7 @@ const getUserInfoAuthenticated = (connect = defaultEmptyFunction, next = default
() => undefined,
err,
value,
- info => {
+ (info) => {
if (info !== undefined && info !== null) {
callback(info)
} else {
@@ -85,60 +88,62 @@ const getUserInfoAuthenticated = (connect = defaultEmptyFunction, next = default
* @param {object} userData - user of http request
* @param {Function} oneConnection - function of xmlrpc
*/
-const setup = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const setup = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const { token } = params
const oneConnect = oneConnection()
- getUserInfoAuthenticated(
- oneConnect,
- next,
- userData => {
- if (
- userData &&
- userData.USER &&
- userData.USER.ID &&
- userData.USER.TEMPLATE &&
- userData.USER.TEMPLATE.SUNSTONE &&
- userData.USER.TEMPLATE.SUNSTONE[default2FAOpennebulaTmpVar] &&
- token
- ) {
- const sunstone = userData.USER.TEMPLATE.SUNSTONE
- const secret = sunstone[default2FAOpennebulaTmpVar]
- if (check2Fa(secret, token)) {
- oneConnect(
- Actions.USER_UPDATE,
- [
- parseInt(userData.USER.ID, 10),
- generateNewResourceTemplate(
- userData.USER.TEMPLATE.SUNSTONE || {},
- { [default2FAOpennebulaVar]: secret },
- [default2FAOpennebulaTmpVar]
- ),
- 1
- ],
- (error, value) => {
- responseOpennebula(
- () => undefined,
- error,
- value,
- pass => {
- if (pass !== undefined && pass !== null) {
- res.locals.httpCode = httpResponse(ok)
- }
- next()
- },
- next
- )
- }
- )
- } else {
- res.locals.httpCode = httpResponse(unauthorized)
- next()
- }
+ getUserInfoAuthenticated(oneConnect, next, (userData) => {
+ if (
+ userData &&
+ userData.USER &&
+ userData.USER.ID &&
+ userData.USER.TEMPLATE &&
+ userData.USER.TEMPLATE.SUNSTONE &&
+ userData.USER.TEMPLATE.SUNSTONE[default2FAOpennebulaTmpVar] &&
+ token
+ ) {
+ const sunstone = userData.USER.TEMPLATE.SUNSTONE
+ const secret = sunstone[default2FAOpennebulaTmpVar]
+ if (check2Fa(secret, token)) {
+ oneConnect(
+ Actions.USER_UPDATE,
+ [
+ parseInt(userData.USER.ID, 10),
+ generateNewResourceTemplate(
+ userData.USER.TEMPLATE.SUNSTONE || {},
+ { [default2FAOpennebulaVar]: secret },
+ [default2FAOpennebulaTmpVar]
+ ),
+ 1,
+ ],
+ (error, value) => {
+ responseOpennebula(
+ () => undefined,
+ error,
+ value,
+ (pass) => {
+ if (pass !== undefined && pass !== null) {
+ res.locals.httpCode = httpResponse(ok)
+ }
+ next()
+ },
+ next
+ )
+ }
+ )
} else {
+ res.locals.httpCode = httpResponse(unauthorized)
next()
}
+ } else {
+ next()
}
- )
+ })
}
/**
@@ -150,10 +155,16 @@ const setup = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}
* @param {object} userData - user of http request
* @param {Function} oneConnection - function of xmlrpc
*/
-const qr = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const qr = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const secret = speakeasy.generateSecret({
length: 10,
- name: twoFactorAuthIssuer
+ name: twoFactorAuthIssuer,
})
if (secret && secret.otpauth_url && secret.base32) {
const { otpauth_url: otpURL, base32 } = secret
@@ -163,46 +174,47 @@ const qr = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, o
next()
} else {
const oneConnect = oneConnection()
- getUserInfoAuthenticated(
- oneConnect,
- next,
- userData => {
- if (userData && userData.USER && userData.USER.ID && userData.USER.TEMPLATE) {
- oneConnect(
- Actions.USER_UPDATE,
- [
- parseInt(userData.USER.ID, 10),
- generateNewResourceTemplate(
- userData.USER.TEMPLATE.SUNSTONE || {},
- { [default2FAOpennebulaTmpVar]: base32 },
- [default2FAOpennebulaVar]
- ),
- 1
- ],
- (error, value) => {
- responseOpennebula(
- () => undefined,
- error,
- value,
- pass => {
- if (pass !== undefined && pass !== null) {
- res.locals.httpCode = httpResponse(ok, {
- img: dataURL
- })
- next()
- } else {
- next()
- }
- },
- next
- )
- }
- )
- } else {
- next()
- }
+ getUserInfoAuthenticated(oneConnect, next, (userData) => {
+ if (
+ userData &&
+ userData.USER &&
+ userData.USER.ID &&
+ userData.USER.TEMPLATE
+ ) {
+ oneConnect(
+ Actions.USER_UPDATE,
+ [
+ parseInt(userData.USER.ID, 10),
+ generateNewResourceTemplate(
+ userData.USER.TEMPLATE.SUNSTONE || {},
+ { [default2FAOpennebulaTmpVar]: base32 },
+ [default2FAOpennebulaVar]
+ ),
+ 1,
+ ],
+ (error, value) => {
+ responseOpennebula(
+ () => undefined,
+ error,
+ value,
+ (pass) => {
+ if (pass !== undefined && pass !== null) {
+ res.locals.httpCode = httpResponse(ok, {
+ img: dataURL,
+ })
+ next()
+ } else {
+ next()
+ }
+ },
+ next
+ )
+ }
+ )
+ } else {
+ next()
}
- )
+ })
}
})
} else {
@@ -219,52 +231,54 @@ const qr = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, o
* @param {object} userData - user of http request
* @param {Function} oneConnection - function of xmlrpc
*/
-const del = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const del = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const oneConnect = oneConnection()
- getUserInfoAuthenticated(
- oneConnect,
- next,
- userData => {
- if (
- userData &&
- userData.USER &&
- userData.USER.ID &&
- userData.USER.TEMPLATE &&
- userData.USER.TEMPLATE.SUNSTONE
- ) {
- oneConnect(
- Actions.USER_UPDATE,
- [
- parseInt(userData.USER.ID, 10),
- generateNewResourceTemplate(
- userData.USER.TEMPLATE.SUNSTONE || {},
- {},
- [default2FAOpennebulaTmpVar, default2FAOpennebulaVar]
- ),
- 1
- ],
- (err, value) => {
- responseOpennebula(
- () => undefined,
- err,
- value,
- pass => {
- if (pass !== undefined && pass !== null) {
- res.locals.httpCode = httpResponse(ok)
- }
- next()
- },
- next
- )
- }
- )
- }
+ getUserInfoAuthenticated(oneConnect, next, (userData) => {
+ if (
+ userData &&
+ userData.USER &&
+ userData.USER.ID &&
+ userData.USER.TEMPLATE &&
+ userData.USER.TEMPLATE.SUNSTONE
+ ) {
+ oneConnect(
+ Actions.USER_UPDATE,
+ [
+ parseInt(userData.USER.ID, 10),
+ generateNewResourceTemplate(
+ userData.USER.TEMPLATE.SUNSTONE || {},
+ {},
+ [default2FAOpennebulaTmpVar, default2FAOpennebulaVar]
+ ),
+ 1,
+ ],
+ (err, value) => {
+ responseOpennebula(
+ () => undefined,
+ err,
+ value,
+ (pass) => {
+ if (pass !== undefined && pass !== null) {
+ res.locals.httpCode = httpResponse(ok)
+ }
+ next()
+ },
+ next
+ )
+ }
+ )
}
- )
+ })
}
const tfaApi = {
setup,
qr,
- del
+ del,
}
module.exports = tfaApi
diff --git a/src/fireedge/src/server/routes/api/2fa/tfa.js b/src/fireedge/src/server/routes/api/2fa/tfa.js
index d8984bef4d..249087799c 100644
--- a/src/fireedge/src/server/routes/api/2fa/tfa.js
+++ b/src/fireedge/src/server/routes/api/2fa/tfa.js
@@ -14,7 +14,10 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
const { setup, qr, del } = require('./tfa-functions')
const { POST, DELETE, GET } = httpMethod
@@ -25,26 +28,26 @@ const routes = {
params: {
token: {
from: fromData.postBody,
- name: 'token'
- }
- }
- }
+ name: 'token',
+ },
+ },
+ },
},
[GET]: {
null: {
action: qr,
- params: {}
- }
+ params: {},
+ },
},
[DELETE]: {
null: {
action: del,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
const authApi = {
- routes
+ routes,
}
module.exports = authApi
diff --git a/src/fireedge/src/server/routes/api/auth/auth-functions.js b/src/fireedge/src/server/routes/api/auth/auth-functions.js
index c3dea7711c..ddf0c6bca6 100644
--- a/src/fireedge/src/server/routes/api/auth/auth-functions.js
+++ b/src/fireedge/src/server/routes/api/auth/auth-functions.js
@@ -26,20 +26,23 @@ const {
setRes,
setNodeConnect,
connectOpennebula,
- updaterResponse
+ updaterResponse,
} = require('./functions')
-const { internalServerError, unauthorized } = require('server/utils/constants/http-codes')
+const {
+ internalServerError,
+ unauthorized,
+} = require('server/utils/constants/http-codes')
const { Actions } = require('server/utils/constants/commands/user')
const {
httpMethod,
- defaultEmptyFunction
+ defaultEmptyFunction,
} = require('server/utils/constants/defaults')
const { GET } = httpMethod
const {
- getDefaultParamsOfOpennebulaCommand
+ getDefaultParamsOfOpennebulaCommand,
} = require('server/utils/opennebula')
const { writeInLogger } = require('server/utils/logger')
@@ -52,7 +55,12 @@ const { writeInLogger } = require('server/utils/logger')
* @param {Function} success - success
* @param {Function} error - error
*/
-const loginUser = (err = '', value = '', success = defaultEmptyFunction, error = defaultEmptyFunction) => {
+const loginUser = (
+ err = '',
+ value = '',
+ success = defaultEmptyFunction,
+ error = defaultEmptyFunction
+) => {
if (value && value.USER && !err) {
success(value)
} else {
@@ -69,7 +77,13 @@ const loginUser = (err = '', value = '', success = defaultEmptyFunction, error =
* @param {object} userData - user of http request
* @param {Function} oneConnection - function of xmlrpc
*/
-const auth = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const auth = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const { user, token, type, token2fa, remember } = params
setRes(res)
setNext(next)
@@ -83,7 +97,7 @@ const auth = (res = {}, next = defaultEmptyFunction, params = {}, userData = {},
*
* @param {object} oneValue - opennebula value
*/
- const success = oneValue => {
+ const success = (oneValue) => {
setUser(user || '')
setPass(token || '')
setType(type || '')
@@ -115,6 +129,6 @@ const auth = (res = {}, next = defaultEmptyFunction, params = {}, userData = {},
}
const authApi = {
- auth
+ auth,
}
module.exports = authApi
diff --git a/src/fireedge/src/server/routes/api/auth/auth.js b/src/fireedge/src/server/routes/api/auth/auth.js
index 5ec9b747d2..ac6c75350e 100644
--- a/src/fireedge/src/server/routes/api/auth/auth.js
+++ b/src/fireedge/src/server/routes/api/auth/auth.js
@@ -14,7 +14,10 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
const { auth } = require('./auth-functions')
const { POST } = httpMethod
@@ -25,30 +28,30 @@ const routes = {
params: {
user: {
from: fromData.postBody,
- name: 'user'
+ name: 'user',
},
token: {
from: fromData.postBody,
- name: 'token'
+ name: 'token',
},
type: {
from: fromData.postBody,
- name: 'type'
+ name: 'type',
},
token2fa: {
from: fromData.postBody,
- name: 'token2fa'
+ name: 'token2fa',
},
remember: {
from: fromData.postBody,
- name: 'remember'
- }
- }
- }
- }
+ name: 'remember',
+ },
+ },
+ },
+ },
}
const authApi = {
- routes
+ routes,
}
module.exports = authApi
diff --git a/src/fireedge/src/server/routes/api/auth/functions.js b/src/fireedge/src/server/routes/api/auth/functions.js
index d9e499c08d..756c467122 100644
--- a/src/fireedge/src/server/routes/api/auth/functions.js
+++ b/src/fireedge/src/server/routes/api/auth/functions.js
@@ -27,20 +27,24 @@ const {
defaultNamespace,
defaultEmptyFunction,
defaultSessionLimitExpiration,
- defaultRememberSessionExpiration
+ defaultRememberSessionExpiration,
} = require('server/utils/constants/defaults')
const { getFireedgeConfig } = require('server/utils/yml')
const {
ok,
unauthorized,
accepted,
- internalServerError
+ internalServerError,
} = require('server/utils/constants/http-codes')
const { createJWT, check2Fa } = require('server/utils/jwt')
-const { httpResponse, encrypt, getSunstoneAuth } = require('server/utils/server')
+const {
+ httpResponse,
+ encrypt,
+ getSunstoneAuth,
+} = require('server/utils/server')
const {
responseOpennebula,
- getDefaultParamsOfOpennebulaCommand
+ getDefaultParamsOfOpennebulaCommand,
} = require('server/utils/opennebula')
const appConfig = getFireedgeConfig()
@@ -108,8 +112,9 @@ const getRelativeTime = () => relativeTime
* @param {string} newKey - new key
* @returns {string} get key
*/
-const setKey = newKey => {
+const setKey = (newKey) => {
key = newKey
+
return key
}
@@ -119,8 +124,9 @@ const setKey = newKey => {
* @param {string} newIV - //16 characters
* @returns {string} get IV
*/
-const setIV = newIV => {
+const setIV = (newIV) => {
iv = newIV
+
return iv
}
@@ -130,8 +136,9 @@ const setIV = newIV => {
* @param {string} newUser - new user data
* @returns {string} get user
*/
-const setUser = newUser => {
+const setUser = (newUser) => {
user = newUser
+
return user
}
@@ -141,8 +148,9 @@ const setUser = newUser => {
* @param {string} newPass - set new opennebula password user
* @returns {string} password user
*/
-const setPass = newPass => {
+const setPass = (newPass) => {
pass = newPass
+
return pass
}
@@ -152,8 +160,9 @@ const setPass = newPass => {
* @param {string} newtype - new type (application)
* @returns {string} get type
*/
-const setType = newtype => {
+const setType = (newtype) => {
type = newtype
+
return type
}
@@ -163,8 +172,9 @@ const setType = newtype => {
* @param {string} newTfaToken - new TFA token
* @returns {string} get TFA token
*/
-const setTfaToken = newTfaToken => {
+const setTfaToken = (newTfaToken) => {
tfatoken = newTfaToken
+
return tfatoken
}
@@ -174,8 +184,9 @@ const setTfaToken = newTfaToken => {
* @param {boolean} newRemember - new remember
* @returns {boolean} remember
*/
-const setRemember = newRemember => {
+const setRemember = (newRemember) => {
remember = newRemember
+
return remember
}
@@ -187,6 +198,7 @@ const setRemember = newRemember => {
*/
const setNext = (newNext = defaultEmptyFunction) => {
next = newNext
+
return next
}
@@ -198,6 +210,7 @@ const setNext = (newNext = defaultEmptyFunction) => {
*/
const setReq = (newReq = {}) => {
req = newReq
+
return req
}
@@ -209,6 +222,7 @@ const setReq = (newReq = {}) => {
*/
const setNodeConnect = (newConnect = defaultEmptyFunction) => {
nodeConnect = newConnect
+
return nodeConnect
}
@@ -220,6 +234,7 @@ const setNodeConnect = (newConnect = defaultEmptyFunction) => {
*/
const setRes = (newRes = {}) => {
res = newRes
+
return res
}
@@ -227,8 +242,12 @@ const setRes = (newRes = {}) => {
* Set dates.
*/
const setDates = () => {
- limitToken = remember ? (appConfig.session__remember_expiration || defaultRememberSessionExpiration) : (appConfig.session_expiration || defaultSessionExpiration)
- limitExpirationReuseToken = parseInt(appConfig.session_reuse_token_time, 10) || defaultSessionLimitExpiration
+ limitToken = remember
+ ? appConfig.session__remember_expiration || defaultRememberSessionExpiration
+ : appConfig.session_expiration || defaultSessionExpiration
+ limitExpirationReuseToken =
+ parseInt(appConfig.session_reuse_token_time, 10) ||
+ defaultSessionLimitExpiration
now = DateTime.local()
nowUnix = now.toSeconds()
expireTime = now.plus({ minutes: limitToken })
@@ -246,6 +265,7 @@ const setDates = () => {
const connectOpennebula = (usr = '', pss = '') => {
const connectUser = usr || user
const connectPass = pss || pass
+
return nodeConnect(connectUser, connectPass)
}
@@ -254,7 +274,7 @@ const connectOpennebula = (usr = '', pss = '') => {
*
* @param {string} code - http code
*/
-const updaterResponse = code => {
+const updaterResponse = (code) => {
if (
'id' in code &&
'message' in code &&
@@ -272,7 +292,7 @@ const updaterResponse = code => {
* @param {object} informationUser - user data
* @returns {boolean} return if data is valid
*/
-const validate2faAuthentication = informationUser => {
+const validate2faAuthentication = (informationUser) => {
let rtn = false
if (
informationUser.TEMPLATE &&
@@ -280,8 +300,8 @@ const validate2faAuthentication = informationUser => {
informationUser.TEMPLATE.SUNSTONE[default2FAOpennebulaVar]
) {
/*********************************************************
- * Validate 2FA
- *********************************************************/
+ * Validate 2FA
+ *********************************************************/
if (tfatoken.length <= 0) {
updaterResponse(httpResponse(accepted))
@@ -295,11 +315,12 @@ const validate2faAuthentication = informationUser => {
}
} else {
/*********************************************************
- * Without 2FA
- *********************************************************/
+ * Without 2FA
+ *********************************************************/
rtn = true
}
+
return rtn
}
@@ -310,7 +331,14 @@ const validate2faAuthentication = informationUser => {
* @param {object} informationUser - user data
*/
const genJWT = (token, informationUser) => {
- if (token && token.token && token.time && informationUser && informationUser.ID && informationUser.NAME) {
+ if (
+ token &&
+ token.token &&
+ token.time &&
+ informationUser &&
+ informationUser.ID &&
+ informationUser.NAME
+ ) {
const { ID: id, TEMPLATE: userTemplate, NAME: user } = informationUser
const dataJWT = { id, user, token: token.token }
const expire = token.time || expireTime.toSeconds()
@@ -332,8 +360,14 @@ const genJWT = (token, informationUser) => {
* @returns {object} - user token
*/
const getCreatedTokenOpennebula = (username = '') => {
- if (global && global.users && username && global.users[username] && global.users[username].tokens) {
- var acc = { token: '', time: 0 }
+ if (
+ global &&
+ global.users &&
+ username &&
+ global.users[username] &&
+ global.users[username].tokens
+ ) {
+ let acc = { token: '', time: 0 }
global.users[username].tokens.forEach((curr = {}, index = 0) => {
const currentTime = parseInt(curr.time, 10)
@@ -344,7 +378,9 @@ const getCreatedTokenOpennebula = (username = '') => {
// this select a valid token
if (
- DateTime.fromSeconds(currentTime).minus({ minutes: limitExpirationReuseToken }) >= now &&
+ DateTime.fromSeconds(currentTime).minus({
+ minutes: limitExpirationReuseToken,
+ }) >= now &&
currentTime >= acc.time
) {
acc = { token: curr.token, time: curr.time }
@@ -372,7 +408,7 @@ const setZones = () => {
() => undefined,
err,
value,
- zonesOpennebula => {
+ (zonesOpennebula) => {
if (
zonesOpennebula &&
zonesOpennebula.ZONE_POOL &&
@@ -381,15 +417,18 @@ const setZones = () => {
const oneZones = !Array.isArray(zonesOpennebula.ZONE_POOL.ZONE)
? [zonesOpennebula.ZONE_POOL.ZONE]
: zonesOpennebula.ZONE_POOL.ZONE
- global.zones = oneZones.map(oneZone => {
- const rpc = (oneZone && oneZone.TEMPLATE && oneZone.TEMPLATE.ENDPOINT) || ''
+ global.zones = oneZones.map((oneZone) => {
+ const rpc =
+ (oneZone && oneZone.TEMPLATE && oneZone.TEMPLATE.ENDPOINT) ||
+ ''
const parsedURL = rpc && parse(rpc)
const parsedHost = parsedURL.hostname || ''
+
return {
id: oneZone.ID || '',
name: oneZone.NAME || '',
rpc: rpc,
- zeromq: `tcp://${parsedHost}:2101`
+ zeromq: `tcp://${parsedHost}:2101`,
}
})
}
@@ -416,14 +455,11 @@ const createTokenServerAdmin = (serverAdmin = '', username = '') => {
if (serverAdmin && username && key && iv) {
const expire = parseInt(expireTime.toSeconds(), 10)
rtn = {
- token: encrypt(
- `${serverAdmin}:${username}:${expire}`,
- key,
- iv
- ),
- time: expire
+ token: encrypt(`${serverAdmin}:${username}:${expire}`, key, iv),
+ time: expire,
}
}
+
return rtn
}
@@ -451,9 +487,9 @@ const wrapUserWithServerAdmin = (serverAdminData = {}, userData = {}) => {
userData.TEMPLATE
) {
/*********************************************************
- * equals what is placed in:
- * src/authm_mad/remotes/server_cipher/server_cipher_auth.rb:44
- *********************************************************/
+ * equals what is placed in:
+ * src/authm_mad/remotes/server_cipher/server_cipher_auth.rb:44
+ *********************************************************/
setKey(serverAdminPassword.substring(0, 32))
setIV(serverAdminPassword.substring(0, 16))
@@ -470,14 +506,11 @@ const wrapUserWithServerAdmin = (serverAdminData = {}, userData = {}) => {
}
if (tokenWithServerAdmin) {
- genJWT(
- tokenWithServerAdmin,
- {
- NAME: JWTusername,
- ID: userData.ID,
- TEMPLATE: userData.TEMPLATE
- }
- )
+ genJWT(tokenWithServerAdmin, {
+ NAME: JWTusername,
+ ID: userData.ID,
+ TEMPLATE: userData.TEMPLATE,
+ })
// set global state
if (setGlobalNewToken) {
@@ -487,7 +520,10 @@ const wrapUserWithServerAdmin = (serverAdminData = {}, userData = {}) => {
if (!global.users[JWTusername]) {
global.users[JWTusername] = { tokens: [] }
}
- global.users[JWTusername].tokens.push({ token: tokenWithServerAdmin.token, time: parseInt(expireTime.toSeconds(), 10) })
+ global.users[JWTusername].tokens.push({
+ token: tokenWithServerAdmin.token,
+ time: parseInt(expireTime.toSeconds(), 10),
+ })
}
next()
}
@@ -504,16 +540,23 @@ const wrapUserWithServerAdmin = (serverAdminData = {}, userData = {}) => {
*/
const getServerAdminAndWrapUser = (userData = {}) => {
const serverAdminData = getSunstoneAuth()
- if (serverAdminData &&
+ if (
+ serverAdminData &&
serverAdminData.username &&
serverAdminData.key &&
serverAdminData.iv
) {
setKey(serverAdminData.key)
setIV(serverAdminData.iv)
- const tokenWithServerAdmin = createTokenServerAdmin(serverAdminData.username, serverAdminData.username)
+ const tokenWithServerAdmin = createTokenServerAdmin(
+ serverAdminData.username,
+ serverAdminData.username
+ )
if (tokenWithServerAdmin.token) {
- const oneConnect = connectOpennebula(`${serverAdminData.username}:${serverAdminData.username}`, tokenWithServerAdmin.token)
+ const oneConnect = connectOpennebula(
+ `${serverAdminData.username}:${serverAdminData.username}`,
+ tokenWithServerAdmin.token
+ )
oneConnect(
ActionUsers.USER_INFO,
getDefaultParamsOfOpennebulaCommand(ActionUsers.USER_INFO, GET),
@@ -522,8 +565,10 @@ const getServerAdminAndWrapUser = (userData = {}) => {
updaterResponse,
err,
value,
- (serverAdminData = {}) => wrapUserWithServerAdmin(serverAdminData, userData),
- next)
+ (serverAdminData = {}) =>
+ wrapUserWithServerAdmin(serverAdminData, userData),
+ next
+ )
},
false
)
@@ -536,7 +581,7 @@ const getServerAdminAndWrapUser = (userData = {}) => {
*
* @param {object} userData - opennebula user data
*/
-const login = userData => {
+const login = (userData) => {
let rtn = false
if (userData) {
const findTextError = `[${namespace}.${ActionUsers.USER_INFO}]`
@@ -574,7 +619,7 @@ const functionRoutes = {
updaterResponse,
setNodeConnect,
connectOpennebula,
- getCreatedTokenOpennebula
+ getCreatedTokenOpennebula,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/auth/index.js b/src/fireedge/src/server/routes/api/auth/index.js
index 21dabcf297..234388e183 100644
--- a/src/fireedge/src/server/routes/api/auth/index.js
+++ b/src/fireedge/src/server/routes/api/auth/index.js
@@ -20,7 +20,7 @@ const { AUTH } = require('./string-routes')
const functionRoutes = {
private: [],
- public: setApiRoutes(authRoutes, AUTH)
+ public: setApiRoutes(authRoutes, AUTH),
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/auth/string-routes.js b/src/fireedge/src/server/routes/api/auth/string-routes.js
index f209c20655..4d0a613c13 100644
--- a/src/fireedge/src/server/routes/api/auth/string-routes.js
+++ b/src/fireedge/src/server/routes/api/auth/string-routes.js
@@ -17,7 +17,7 @@
const AUTH = 'auth'
const Actions = {
- AUTH
+ AUTH,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/files/files.js b/src/fireedge/src/server/routes/api/files/files.js
index c1462eef04..139ad1c8c9 100644
--- a/src/fireedge/src/server/routes/api/files/files.js
+++ b/src/fireedge/src/server/routes/api/files/files.js
@@ -14,7 +14,10 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { from: fromData, httpMethod } = require('server/utils/constants/defaults')
+const {
+ from: fromData,
+ httpMethod,
+} = require('server/utils/constants/defaults')
const { show, list, upload, update, deleteFile } = require('./functions')
const { GET, POST, PUT, DELETE } = httpMethod
@@ -25,19 +28,19 @@ const publicRoutes = {
params: {
file: {
from: fromData.query,
- name: 'file'
+ name: 'file',
},
token: {
from: fromData.query,
- name: 'token'
+ name: 'token',
},
app: {
from: fromData.query,
- name: 'app'
- }
- }
- }
- }
+ name: 'app',
+ },
+ },
+ },
+ },
}
const privateRoutes = {
@@ -47,10 +50,10 @@ const privateRoutes = {
params: {
app: {
from: fromData.query,
- name: 'app'
- }
- }
- }
+ name: 'app',
+ },
+ },
+ },
},
[POST]: {
null: {
@@ -58,18 +61,18 @@ const privateRoutes = {
params: {
app: {
from: fromData.query,
- name: 'app'
+ name: 'app',
},
files: {
from: 'files',
- name: 'files'
+ name: 'files',
},
root: {
from: fromData.query,
- name: 'public'
- }
- }
- }
+ name: 'public',
+ },
+ },
+ },
},
[PUT]: {
null: {
@@ -77,14 +80,14 @@ const privateRoutes = {
params: {
name: {
from: fromData.query,
- name: 'name'
+ name: 'name',
},
files: {
from: 'files',
- name: 'files'
- }
- }
- }
+ name: 'files',
+ },
+ },
+ },
},
[DELETE]: {
null: {
@@ -92,15 +95,15 @@ const privateRoutes = {
params: {
file: {
from: fromData.query,
- name: 'file'
- }
- }
- }
- }
+ name: 'file',
+ },
+ },
+ },
+ },
}
const fileApi = {
publicRoutes,
- privateRoutes
+ privateRoutes,
}
module.exports = fileApi
diff --git a/src/fireedge/src/server/routes/api/files/functions.js b/src/fireedge/src/server/routes/api/files/functions.js
index aa3d7e1b06..b3a2669e04 100644
--- a/src/fireedge/src/server/routes/api/files/functions.js
+++ b/src/fireedge/src/server/routes/api/files/functions.js
@@ -16,23 +16,23 @@
const { resolve, extname, parse, sep } = require('path')
const { global } = require('window-or-global')
const { jwtDecode } = require('server/utils/jwt')
-const {
- existsSync,
- mkdirsSync,
- moveSync
-} = require('fs-extra')
+const { existsSync, mkdirsSync, moveSync } = require('fs-extra')
-const {
- defaultEmptyFunction
-} = require('server/utils/constants/defaults')
+const { defaultEmptyFunction } = require('server/utils/constants/defaults')
const {
ok,
internalServerError,
- badRequest
+ badRequest,
} = require('server/utils/constants/http-codes')
const { Actions: ActionUser } = require('server/utils/constants/commands/user')
-const { httpResponse, checkValidApp, getFiles, existsFile, removeFile } = require('server/utils/server')
+const {
+ httpResponse,
+ checkValidApp,
+ getFiles,
+ existsFile,
+ removeFile,
+} = require('server/utils/server')
const httpBadRequest = httpResponse(badRequest, '', '')
const groupAdministrator = ['0']
@@ -61,9 +61,17 @@ const checkUserAdmin = (
ActionUser.USER_INFO,
[parseInt(id, 10)],
(err, value) => {
- if (!err && value && value.USER && value.USER.GROUPS && value.USER.GROUPS.ID) {
+ if (
+ !err &&
+ value &&
+ value.USER &&
+ value.USER.GROUPS &&
+ value.USER.GROUPS.ID
+ ) {
let admin = false
- const groups = Array.isArray(value.USER.GROUPS.ID) ? value.USER.GROUPS.ID : [value.USER.GROUPS.ID]
+ const groups = Array.isArray(value.USER.GROUPS.ID)
+ ? value.USER.GROUPS.ID
+ : [value.USER.GROUPS.ID]
for (const group of groups) {
if (groupAdministrator.includes(group)) {
admin = true
@@ -95,13 +103,14 @@ const parseFilePath = (file = '') => {
}
/**
- * Check if file no have owner, but have app
+ * Check if file no have owner, but have app.
*
* @param {string} file - filename
* @returns {boolean} - if user is the file owner
*/
const validateFileWithoutOwner = (file = '') => {
const parsedFile = parseFilePath(file)
+
return (
Array.isArray(parsedFile) &&
parsedFile[0] &&
@@ -119,6 +128,7 @@ const validateFileWithoutOwner = (file = '') => {
*/
const validateFileWithOwner = (file = '', id = '') => {
const parsedFile = parseFilePath(file)
+
return (
Array.isArray(parsedFile) &&
parsedFile[0] &&
@@ -137,7 +147,13 @@ const validateFileWithOwner = (file = '', id = '') => {
* @param {object} userData - user of http request
* @param {Function} oneConnection - xmlrpc connection
*/
-const upload = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const upload = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const { app, files, root } = params
const { id, user, password } = userData
if (
@@ -177,7 +193,11 @@ const upload = (res = {}, next = defaultEmptyFunction, params = {}, userData = {
}
}
}
- res.locals.httpCode = httpResponse(method, data.length ? data : '', message)
+ res.locals.httpCode = httpResponse(
+ method,
+ data.length ? data : '',
+ message
+ )
next()
},
() => {
@@ -199,15 +219,19 @@ const upload = (res = {}, next = defaultEmptyFunction, params = {}, userData = {
* @param {string} defaultFile - default file
* @returns {Array | string} - file
*/
-const getDefaultFilesforApps = (app = '', multiple = false, defaultFile = '') => {
+const getDefaultFilesforApps = (
+ app = '',
+ multiple = false,
+ defaultFile = ''
+) => {
let rtn = ''
switch (app) {
case 'sunstone':
if (global.paths.SUNSTONE_IMAGES) {
const path = global.paths.SUNSTONE_IMAGES
if (multiple) {
- rtn = getFiles(path, true).map(
- file => file.replace(`${path}${sep}`, '')
+ rtn = getFiles(path, true).map((file) =>
+ file.replace(`${path}${sep}`, '')
)
} else {
rtn = `${path}${sep}${defaultFile}`
@@ -219,6 +243,7 @@ const getDefaultFilesforApps = (app = '', multiple = false, defaultFile = '') =>
default:
break
}
+
return rtn
}
@@ -231,17 +256,17 @@ const getDefaultFilesforApps = (app = '', multiple = false, defaultFile = '') =>
* @param {object} userData - user of http request
* @param {Function} oneConnection - one connection XMLRPC
*/
-const list = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const list = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const { user, password, id } = userData
const { app } = params
const rtn = httpBadRequest
- if (
- app &&
- checkValidApp(app) &&
- user &&
- password &&
- id
- ) {
+ if (app && checkValidApp(app) && user && password && id) {
const path = `${global.paths.CPI}${sep}`
const userPath = `${app}${sep}${id}`
@@ -252,15 +277,15 @@ const list = (res = {}, next = defaultEmptyFunction, params = {}, userData = {},
// find root files
const rootPath = `${path}${app}`
- data = data.concat(getFiles(rootPath, false).map(
- file => file.replace(path, '')
- ))
+ data = data.concat(
+ getFiles(rootPath, false).map((file) => file.replace(path, ''))
+ )
// find user files
const pathUser = `${path}${userPath}`
- data = data.concat(getFiles(pathUser, true).map(
- file => file.replace(path, '')
- ))
+ data = data.concat(
+ getFiles(pathUser, true).map((file) => file.replace(path, ''))
+ )
res.locals.httpCode = httpResponse(ok, data)
next()
} else {
@@ -313,21 +338,25 @@ const show = (res = {}, next = defaultEmptyFunction, params = {}) => {
* @param {string} params - data response http
* @param {object} userData - user of http request
*/
-const deleteFile = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const deleteFile = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { file } = params
const { id } = userData
const rtn = httpBadRequest
- if (
- global.paths.CPI &&
- file &&
- id &&
- validateFileWithOwner(file, id)
- ) {
+ if (global.paths.CPI && file && id && validateFileWithOwner(file, id)) {
const pathFile = `${global.paths.CPI}${sep}${file}`
existsFile(
pathFile,
() => {
- res.locals.httpCode = httpResponse(removeFile(pathFile) ? ok : internalServerError, '', '')
+ res.locals.httpCode = httpResponse(
+ removeFile(pathFile) ? ok : internalServerError,
+ '',
+ ''
+ )
next()
},
() => {
@@ -349,7 +378,12 @@ const deleteFile = (res = {}, next = defaultEmptyFunction, params = {}, userData
* @param {string} params - data response http
* @param {object} userData - user of http request
*/
-const update = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const update = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const rtn = httpBadRequest
const { files, name } = params
const { id } = userData
@@ -379,7 +413,11 @@ const update = (res = {}, next = defaultEmptyFunction, params = {}, userData = {
}
}
}
- res.locals.httpCode = httpResponse(method, data.length ? data : '', message)
+ res.locals.httpCode = httpResponse(
+ method,
+ data.length ? data : '',
+ message
+ )
next()
},
() => {
@@ -398,6 +436,6 @@ const functionRoutes = {
deleteFile,
update,
show,
- list
+ list,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/files/index.js b/src/fireedge/src/server/routes/api/files/index.js
index c3e31ebc5e..7a5800180b 100644
--- a/src/fireedge/src/server/routes/api/files/index.js
+++ b/src/fireedge/src/server/routes/api/files/index.js
@@ -15,12 +15,15 @@
* ------------------------------------------------------------------------- */
const { setApiRoutes } = require('server/utils/server')
-const { privateRoutes: filePrivateRoutes, publicRoutes: filePublicRoutes } = require('./files')
+const {
+ privateRoutes: filePrivateRoutes,
+ publicRoutes: filePublicRoutes,
+} = require('./files')
const { FILES } = require('./string-routes')
const functionRoutes = {
private: setApiRoutes(filePrivateRoutes, FILES),
- public: setApiRoutes(filePublicRoutes, FILES)
+ public: setApiRoutes(filePublicRoutes, FILES),
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/files/string-routes.js b/src/fireedge/src/server/routes/api/files/string-routes.js
index aa56d6f9e9..167e2116a3 100644
--- a/src/fireedge/src/server/routes/api/files/string-routes.js
+++ b/src/fireedge/src/server/routes/api/files/string-routes.js
@@ -17,7 +17,7 @@
const FILES = 'files'
const Actions = {
- FILES
+ FILES,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/index.js b/src/fireedge/src/server/routes/api/index.js
index f24e7e4d0f..0de87a593f 100644
--- a/src/fireedge/src/server/routes/api/index.js
+++ b/src/fireedge/src/server/routes/api/index.js
@@ -16,11 +16,15 @@
const { messageTerminal } = require('server/utils/general')
const { getRouteForOpennebulaCommand } = require('server/utils/opennebula')
-const { defaultFilesRoutes, defaultConfigErrorMessage } = require('server/utils/constants/defaults')
+const {
+ defaultFilesRoutes,
+ defaultConfigErrorMessage,
+} = require('server/utils/constants/defaults')
const filesDataPrivate = []
const filesDataPublic = []
-defaultFilesRoutes.map(file => {
+
+defaultFilesRoutes.forEach((file) => {
try {
// eslint-disable-next-line global-require
const fileInfo = require(`./${file}`)
@@ -39,9 +43,11 @@ defaultFilesRoutes.map(file => {
}
}
})
+
const opennebulaActions = getRouteForOpennebulaCommand()
const routes = {
private: [...opennebulaActions, ...filesDataPrivate],
- public: [...filesDataPublic]
+ public: [...filesDataPublic],
}
+
module.exports = routes
diff --git a/src/fireedge/src/server/routes/api/marketapp/functions.js b/src/fireedge/src/server/routes/api/marketapp/functions.js
index dda6c6d2d9..a2fcb3b70d 100644
--- a/src/fireedge/src/server/routes/api/marketapp/functions.js
+++ b/src/fireedge/src/server/routes/api/marketapp/functions.js
@@ -16,13 +16,13 @@
const {
defaultEmptyFunction,
- defaultCommandMarketApp
+ defaultCommandMarketApp,
} = require('server/utils/constants/defaults')
const {
ok,
internalServerError,
- badRequest
+ badRequest,
} = require('server/utils/constants/http-codes')
const { httpResponse, executeCommand } = require('server/utils/server')
@@ -40,12 +40,24 @@ const prependCommand = appConfig.sunstone_prepend || ''
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const exportApp = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const exportApp = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
let rtn = httpBadRequest
- const { id, name, datastore, file, associated, tag, template, vmname } = params
+ const { id, name, datastore, file, associated, tag, template, vmname } =
+ params
if (id && name && datastore) {
let message = ''
- const paramsCommand = ['export', `${id}`, `${name}`, '--datastore', datastore]
+ const paramsCommand = [
+ 'export',
+ `${id}`,
+ `${name}`,
+ '--datastore',
+ datastore,
+ ]
if (file) {
paramsCommand.push('--file-datastore', file)
}
@@ -61,7 +73,11 @@ const exportApp = (res = {}, next = defaultEmptyFunction, params = {}, userData
if (vmname) {
paramsCommand.push('--vmname', vmname)
}
- const executedCommand = executeCommand(defaultCommandMarketApp, paramsCommand, prependCommand)
+ const executedCommand = executeCommand(
+ defaultCommandMarketApp,
+ paramsCommand,
+ prependCommand
+ )
const response = executedCommand.success ? ok : internalServerError
if (executedCommand.data) {
message = executedCommand.data
@@ -73,6 +89,6 @@ const exportApp = (res = {}, next = defaultEmptyFunction, params = {}, userData
}
const functionRoutes = {
- exportApp
+ exportApp,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/marketapp/index.js b/src/fireedge/src/server/routes/api/marketapp/index.js
index 6f767beed4..ba3538d1f4 100644
--- a/src/fireedge/src/server/routes/api/marketapp/index.js
+++ b/src/fireedge/src/server/routes/api/marketapp/index.js
@@ -20,7 +20,7 @@ const { MARKETAPP } = require('./string-routes')
const functionRoutes = {
private: setApiRoutes(marketappRoutes, MARKETAPP),
- public: []
+ public: [],
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/marketapp/marketapp.js b/src/fireedge/src/server/routes/api/marketapp/marketapp.js
index 62cd9b1c03..0846f62348 100644
--- a/src/fireedge/src/server/routes/api/marketapp/marketapp.js
+++ b/src/fireedge/src/server/routes/api/marketapp/marketapp.js
@@ -14,7 +14,10 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
const { exportApp } = require('./functions')
const { POST } = httpMethod
@@ -25,42 +28,42 @@ const routes = {
params: {
id: {
from: fromData.resource,
- name: 'id'
+ name: 'id',
},
name: {
from: fromData.postBody,
- name: 'name'
+ name: 'name',
},
datastore: {
from: fromData.postBody,
- name: 'datastore'
+ name: 'datastore',
},
file: {
from: fromData.postBody,
- name: 'file'
+ name: 'file',
},
associated: {
from: fromData.postBody,
- name: 'associated'
+ name: 'associated',
},
tag: {
from: fromData.postBody,
- name: 'tag'
+ name: 'tag',
},
template: {
from: fromData.postBody,
- name: 'template'
+ name: 'template',
},
vmname: {
from: fromData.postBody,
- name: 'vmname'
- }
- }
- }
- }
+ name: 'vmname',
+ },
+ },
+ },
+ },
}
const authApi = {
- routes
+ routes,
}
module.exports = authApi
diff --git a/src/fireedge/src/server/routes/api/marketapp/string-routes.js b/src/fireedge/src/server/routes/api/marketapp/string-routes.js
index 1ec91fe40c..a2e8f0fa47 100644
--- a/src/fireedge/src/server/routes/api/marketapp/string-routes.js
+++ b/src/fireedge/src/server/routes/api/marketapp/string-routes.js
@@ -17,7 +17,7 @@
const MARKETAPP = 'marketapp'
const Actions = {
- MARKETAPP
+ MARKETAPP,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/oneflow/functions.js b/src/fireedge/src/server/routes/api/oneflow/functions.js
index 594c4e7f0e..58f084b7a5 100644
--- a/src/fireedge/src/server/routes/api/oneflow/functions.js
+++ b/src/fireedge/src/server/routes/api/oneflow/functions.js
@@ -34,7 +34,7 @@ const appConfig = getFireedgeConfig()
*/
const returnSchemaError = (error = []) =>
error
- .map(element => (element && element.stack ? element.stack : ''))
+ .map((element) => (element && element.stack ? element.stack : ''))
.toString()
/**
@@ -43,10 +43,8 @@ const returnSchemaError = (error = []) =>
* @param {string} validate - number to validate
* @returns {number}number to int
*/
-const parseToNumber = validate =>
- isNaN(parseInt(validate, 10))
- ? validate
- : parseInt(validate, 10)
+const parseToNumber = (validate) =>
+ isNaN(parseInt(validate, 10)) ? validate : parseInt(validate, 10)
/**
* Connection to one flow server.
@@ -55,7 +53,11 @@ const parseToNumber = validate =>
* @param {Function} success - callback success function
* @param {Function} error - callback error function
*/
-const oneFlowConnection = (requestData = {}, success = () => undefined, error = () => undefined) => {
+const oneFlowConnection = (
+ requestData = {},
+ success = () => undefined,
+ error = () => undefined
+) => {
const { method, path, user, password, request, post } = requestData
const optionMethod = method || GET
const optionPath = path || '/'
@@ -65,16 +67,16 @@ const oneFlowConnection = (requestData = {}, success = () => undefined, error =
baseURL: appConfig.oneflow_server || defaultOneFlowServer,
url: request ? addPrintf(optionPath, request || '') : optionPath,
headers: {
- Authorization: `Basic ${optionAuth}`
+ Authorization: `Basic ${optionAuth}`,
},
- validateStatus: status => status
+ validateStatus: (status) => status,
}
if (post) {
options.data = post
}
axios(options)
- .then(response => {
+ .then((response) => {
if (response && response.statusText) {
if (response.status >= 200 && response.status < 400) {
if (response.data) {
@@ -82,7 +84,7 @@ const oneFlowConnection = (requestData = {}, success = () => undefined, error =
}
if (
response.config.method &&
- response.config.method.toUpperCase() === DELETE
+ response.config.method.toUpperCase() === DELETE
) {
return Array.isArray(request)
? parseToNumber(request[0])
@@ -94,17 +96,17 @@ const oneFlowConnection = (requestData = {}, success = () => undefined, error =
}
throw Error(response.statusText)
})
- .then(data => {
+ .then((data) => {
success(data)
})
- .catch(e => {
+ .catch((e) => {
error(e)
})
}
const functionRoutes = {
oneFlowConnection,
- returnSchemaError
+ returnSchemaError,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/oneflow/index.js b/src/fireedge/src/server/routes/api/oneflow/index.js
index b7b314eee6..5dd19ebfd4 100644
--- a/src/fireedge/src/server/routes/api/oneflow/index.js
+++ b/src/fireedge/src/server/routes/api/oneflow/index.js
@@ -27,12 +27,12 @@ const { SERVICE, SERVICE_TEMPLATE } = require('./string-routes')
*/
const generatePrivateRoutes = () => [
...setApiRoutes(serviceRoutes, SERVICE),
- ...setApiRoutes(serviceTemplateRoutes, SERVICE_TEMPLATE)
+ ...setApiRoutes(serviceTemplateRoutes, SERVICE_TEMPLATE),
]
const functionRoutes = {
private: generatePrivateRoutes(),
- public: []
+ public: [],
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/oneflow/schemas.js b/src/fireedge/src/server/routes/api/oneflow/schemas.js
index d9ee80881b..3e6448b486 100644
--- a/src/fireedge/src/server/routes/api/oneflow/schemas.js
+++ b/src/fireedge/src/server/routes/api/oneflow/schemas.js
@@ -23,20 +23,20 @@ const action = {
properties: {
perform: {
type: 'string',
- required: true
+ required: true,
},
params: {
type: 'object',
properties: {
merge_template: {
type: 'object',
- required: false
- }
- }
- }
- }
- }
- }
+ required: false,
+ },
+ },
+ },
+ },
+ },
+ },
}
const role = {
@@ -45,46 +45,46 @@ const role = {
properties: {
name: {
type: 'string',
- required: true
+ required: true,
},
cardinality: {
type: 'integer',
default: 1,
- minimum: 0
+ minimum: 0,
},
vm_template: {
type: 'integer',
- required: true
+ required: true,
},
vm_template_contents: {
type: 'string',
- required: false
+ required: false,
},
parents: {
type: 'array',
items: {
- type: 'string'
- }
+ type: 'string',
+ },
},
shutdown_action: {
type: 'string',
enum: ['shutdown', 'shutdown-hard'],
- required: false
+ required: false,
},
min_vms: {
type: 'integer',
required: false,
- minimum: 0
+ minimum: 0,
},
max_vms: {
type: 'integer',
required: false,
- minimum: 0
+ minimum: 0,
},
cooldown: {
type: 'integer',
required: false,
- minimum: 0
+ minimum: 0,
},
elasticity_policies: {
type: 'array',
@@ -94,38 +94,38 @@ const role = {
type: {
type: 'string',
enum: ['CHANGE', 'CARDINALITY', 'PERCENTAGE_CHANGE'],
- required: true
+ required: true,
},
adjust: {
type: 'integer',
- required: true
+ required: true,
},
min_adjust_step: {
type: 'integer',
required: false,
- minimum: 1
+ minimum: 1,
},
period_number: {
type: 'integer',
required: false,
- minimum: 0
+ minimum: 0,
},
period: {
type: 'integer',
required: false,
- minimum: 0
+ minimum: 0,
},
expression: {
type: 'string',
- required: true
+ required: true,
},
cooldown: {
type: 'integer',
required: false,
- minimum: 0
- }
- }
- }
+ minimum: 0,
+ },
+ },
+ },
},
scheduled_policies: {
type: 'array',
@@ -135,29 +135,29 @@ const role = {
type: {
type: 'string',
enum: ['CHANGE', 'CARDINALITY', 'PERCENTAGE_CHANGE'],
- required: true
+ required: true,
},
adjust: {
type: 'integer',
- required: true
+ required: true,
},
min_adjust_step: {
type: 'integer',
required: false,
- minimum: 1
+ minimum: 1,
},
start_time: {
type: 'string',
- required: false
+ required: false,
},
recurrence: {
type: 'string',
- required: false
- }
- }
- }
- }
- }
+ required: false,
+ },
+ },
+ },
+ },
+ },
}
const service = {
@@ -165,61 +165,61 @@ const service = {
properties: {
name: {
type: 'string',
- required: true
+ required: true,
},
deployment: {
type: 'string',
enum: ['none', 'straight'],
- default: 'none'
+ default: 'none',
},
description: {
type: 'string',
- required: false
+ required: false,
},
shutdown_action: {
type: 'string',
enum: ['terminate', 'terminate-hard', 'shutdown', 'shutdown-hard'],
- required: false
+ required: false,
},
roles: {
type: 'array',
items: { $ref: '/Role' },
- required: true
+ required: true,
},
custom_attrs: {
type: 'object',
properties: {},
- required: false
+ required: false,
},
custom_attrs_values: {
type: 'object',
properties: {},
- required: false
+ required: false,
},
networks: {
type: 'object',
properties: {},
- required: false
+ required: false,
},
networks_values: {
type: 'array',
items: {
type: 'object',
- properties: {}
+ properties: {},
},
- required: false
+ required: false,
},
ready_status_gate: {
type: 'boolean',
- required: false
- }
- }
+ required: false,
+ },
+ },
}
const schemas = {
action,
role,
- service
+ service,
}
module.exports = schemas
diff --git a/src/fireedge/src/server/routes/api/oneflow/service-functions.js b/src/fireedge/src/server/routes/api/oneflow/service-functions.js
index 83a5db62c0..4522b28d1f 100644
--- a/src/fireedge/src/server/routes/api/oneflow/service-functions.js
+++ b/src/fireedge/src/server/routes/api/oneflow/service-functions.js
@@ -17,12 +17,15 @@
const { Validator } = require('jsonschema')
const { action } = require('./schemas')
const { oneFlowConnection } = require('./functions')
-const { httpMethod, defaultEmptyFunction } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ defaultEmptyFunction,
+} = require('server/utils/constants/defaults')
const { httpResponse, parsePostData } = require('server/utils/server')
const {
ok,
internalServerError,
- methodNotAllowed
+ methodNotAllowed,
} = require('server/utils/constants/http-codes')
const { returnSchemaError } = require('./functions')
const { generateNewResourceTemplate } = require('server/utils/opennebula')
@@ -37,7 +40,13 @@ const { GET, POST, DELETE } = httpMethod
* @param {string} data - data response http
*/
const success = (next = defaultEmptyFunction, res = {}, data = '') => {
- if ((next && typeof next === 'function') && (res && res.locals && res.locals.httpCode)) {
+ if (
+ next &&
+ typeof next === 'function' &&
+ res &&
+ res.locals &&
+ res.locals.httpCode
+ ) {
res.locals.httpCode = httpResponse(ok, data)
next()
}
@@ -51,8 +60,17 @@ const success = (next = defaultEmptyFunction, res = {}, data = '') => {
* @param {string} data - data response http
*/
const error = (next = defaultEmptyFunction, res = {}, data = '') => {
- if ((next && typeof next === 'function') && (res && res.locals && res.locals.httpCode)) {
- res.locals.httpCode = httpResponse(internalServerError, data && data.message)
+ if (
+ next &&
+ typeof next === 'function' &&
+ res &&
+ res.locals &&
+ res.locals.httpCode
+ ) {
+ res.locals.httpCode = httpResponse(
+ internalServerError,
+ data && data.message
+ )
next()
}
}
@@ -65,16 +83,29 @@ const error = (next = defaultEmptyFunction, res = {}, data = '') => {
* @param {object} params - params
* @param {object} userData - user data
*/
-const service = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const service = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (user && password) {
const config = { method: GET, path: '/service', user, password }
if (params && params.id) {
config.path = '/service/{0}'
config.request = params.id
- oneFlowConnection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConnection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
- oneFlowConnection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConnection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
}
}
}
@@ -87,11 +118,26 @@ const service = (res = {}, next = defaultEmptyFunction, params = {}, userData =
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceDelete = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const serviceDelete = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (params && params.id && user && password) {
- const config = { method: DELETE, path: '/service/{0}', user, password, request: params.id }
- oneFlowConnection(config, data => success(next, res, data), data => error(next, res, data))
+ const config = {
+ method: DELETE,
+ path: '/service/{0}',
+ user,
+ password,
+ request: params.id,
+ }
+ oneFlowConnection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
res.locals.httpCode = httpResponse(
methodNotAllowed,
@@ -110,22 +156,32 @@ const serviceDelete = (res = {}, next = defaultEmptyFunction, params = {}, userD
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceAddAction = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const serviceAddAction = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (params && params.id && params.action && user && password) {
const v = new Validator()
const postAction = parsePostData(params.action)
const valSchema = v.validate(postAction, action)
- if (valSchema.valid) { // validate if "action" is required
+ if (valSchema.valid) {
+ // validate if "action" is required
const config = {
method: POST,
path: '/service/{0}/action',
user,
password,
request: params.id,
- post: postAction
+ post: postAction,
}
- oneFlowConnection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConnection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
res.locals.httpCode = httpResponse(
internalServerError,
@@ -152,22 +208,32 @@ const serviceAddAction = (res = {}, next = defaultEmptyFunction, params = {}, us
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceAddScale = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const serviceAddScale = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (params && params.id && params.action && user && password) {
const v = new Validator()
const postAction = parsePostData(params.action)
const valSchema = v.validate(postAction, action)
- if (valSchema.valid) { // validate if "action" is required
+ if (valSchema.valid) {
+ // validate if "action" is required
const config = {
method: POST,
path: '/service/{0}/scale',
user,
password,
request: params.id,
- post: postAction
+ post: postAction,
}
- oneFlowConnection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConnection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
res.locals.httpCode = httpResponse(
internalServerError,
@@ -194,22 +260,32 @@ const serviceAddScale = (res = {}, next = defaultEmptyFunction, params = {}, use
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceAddRoleAction = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const serviceAddRoleAction = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (params && params.role && params.id && params.action && user && password) {
const v = new Validator()
const postAction = parsePostData(params.action)
const valSchema = v.validate(postAction, action)
- if (valSchema.valid) { // validate if "action" is required
+ if (valSchema.valid) {
+ // validate if "action" is required
const config = {
method: POST,
path: '/service/{0}/role/{1}',
user,
password,
request: [params.role, params.id],
- post: postAction
+ post: postAction,
}
- oneFlowConnection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConnection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
res.locals.httpCode = httpResponse(
internalServerError,
@@ -237,21 +313,41 @@ const serviceAddRoleAction = (res = {}, next = defaultEmptyFunction, params = {}
* @param {Function} success - callback when have service info data
* @param {Function} error - callback when no have service info data
*/
-const getNodesService = (user = '', password = '', serviceID = 0, success = defaultEmptyFunction, error = defaultEmptyFunction) => {
+const getNodesService = (
+ user = '',
+ password = '',
+ serviceID = 0,
+ success = defaultEmptyFunction,
+ error = defaultEmptyFunction
+) => {
if (user && password && serviceID) {
- const config = { method: GET, path: '/service/{0}', user, password, request: serviceID }
+ const config = {
+ method: GET,
+ path: '/service/{0}',
+ user,
+ password,
+ request: serviceID,
+ }
oneFlowConnection(
config,
(serviceData = {}) => {
const vms = []
- if (serviceData && serviceData.DOCUMENT && serviceData.DOCUMENT.TEMPLATE && serviceData.DOCUMENT.TEMPLATE.BODY && serviceData.DOCUMENT.TEMPLATE.BODY.roles) {
+ if (
+ serviceData &&
+ serviceData.DOCUMENT &&
+ serviceData.DOCUMENT.TEMPLATE &&
+ serviceData.DOCUMENT.TEMPLATE.BODY &&
+ serviceData.DOCUMENT.TEMPLATE.BODY.roles
+ ) {
let roles = serviceData.DOCUMENT.TEMPLATE.BODY.roles
roles = Array.isArray(roles) ? roles : [roles]
- roles.forEach(role => {
+ roles.forEach((role) => {
if (role && role.nodes) {
let nodes = role.nodes
nodes = Array.isArray(nodes) ? nodes : [nodes]
- const filteredNodes = nodes.filter(node => node && node.deploy_id >= 0)
+ const filteredNodes = nodes.filter(
+ (node) => node && node.deploy_id >= 0
+ )
vms.push(...filteredNodes)
}
})
@@ -279,7 +375,9 @@ const parseSchedActionsToString = (schedAction = '') => {
try {
const parsedSchedAction = JSON.parse(schedAction)
if (Array.isArray(parsedSchedAction)) {
- rtn = parsedSchedAction.map(action => generateNewResourceTemplate({}, action, [], wrapper)).join(' ')
+ rtn = parsedSchedAction
+ .map((action) => generateNewResourceTemplate({}, action, [], wrapper))
+ .join(' ')
} else if (typeof parsedSchedAction === 'object') {
rtn = generateNewResourceTemplate({}, parsedSchedAction, [], wrapper)
} else {
@@ -288,6 +386,7 @@ const parseSchedActionsToString = (schedAction = '') => {
} catch (err) {
rtn = schedAction
}
+
return rtn
}
@@ -300,7 +399,13 @@ const parseSchedActionsToString = (schedAction = '') => {
* @param {object} userData - user data
* @param {Function} oneConnection - xmlrpc connection
*/
-const serviceAddSchedAction = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const serviceAddSchedAction = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const { user, password } = userData
if (params && params.id && params.sched_action && user && password) {
const schedTemplate = parseSchedActionsToString(params.sched_action)
@@ -346,9 +451,22 @@ const serviceAddSchedAction = (res = {}, next = defaultEmptyFunction, params = {
* @param {object} userData - user data
* @param {Function} oneConnection - xmlrpc connection
*/
-const serviceUpdateSchedAction = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const serviceUpdateSchedAction = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const { user, password } = userData
- if (params && params.id && params.id_sched && params.sched_action && user && password) {
+ if (
+ params &&
+ params.id &&
+ params.id_sched &&
+ params.sched_action &&
+ user &&
+ password
+ ) {
const schedTemplate = parseSchedActionsToString(params.sched_action)
const nodesUpdated = []
getNodesService(
@@ -392,7 +510,13 @@ const serviceUpdateSchedAction = (res = {}, next = defaultEmptyFunction, params
* @param {object} userData - user data
* @param {Function} oneConnection - xmlrpc connection
*/
-const serviceDeleteSchedAction = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const serviceDeleteSchedAction = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const { user, password } = userData
if (params && params.id && params.id_sched && user && password) {
const nodesUpdated = []
@@ -436,6 +560,6 @@ const serviceApi = {
serviceAddRoleAction,
serviceAddSchedAction,
serviceUpdateSchedAction,
- serviceDeleteSchedAction
+ serviceDeleteSchedAction,
}
module.exports = serviceApi
diff --git a/src/fireedge/src/server/routes/api/oneflow/service.js b/src/fireedge/src/server/routes/api/oneflow/service.js
index 858a117737..b96b4e0f08 100644
--- a/src/fireedge/src/server/routes/api/oneflow/service.js
+++ b/src/fireedge/src/server/routes/api/oneflow/service.js
@@ -14,7 +14,10 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
const {
service,
serviceDelete,
@@ -23,7 +26,7 @@ const {
serviceAddRoleAction,
serviceAddSchedAction,
serviceUpdateSchedAction,
- serviceDeleteSchedAction
+ serviceDeleteSchedAction,
} = require('./service-functions')
const { GET, POST, DELETE, PUT } = httpMethod
@@ -32,40 +35,40 @@ const routes = {
list: {
action: service,
params: {
- id: { from: fromData.resource, name: 'id' }
- }
- }
+ id: { from: fromData.resource, name: 'id' },
+ },
+ },
},
[POST]: {
action: {
action: serviceAddAction,
params: {
id: { from: fromData.resource, name: 'id' },
- action: { from: fromData.postBody }
- }
+ action: { from: fromData.postBody },
+ },
},
scale: {
action: serviceAddScale,
params: {
id: { from: fromData.resource, name: 'id' },
- action: { from: fromData.postBody }
- }
+ action: { from: fromData.postBody },
+ },
},
'role-action': {
action: serviceAddRoleAction,
params: {
role: { from: fromData.resource, name: 'id' },
id: { from: fromData.resource, name: 'id2' },
- action: { from: fromData.postBody }
- }
+ action: { from: fromData.postBody },
+ },
},
sched_action: {
action: serviceAddSchedAction,
params: {
id: { from: fromData.resource, name: 'id' },
- sched_action: { from: fromData.postBody, name: 'sched_action' }
- }
- }
+ sched_action: { from: fromData.postBody, name: 'sched_action' },
+ },
+ },
},
[PUT]: {
sched_action: {
@@ -73,27 +76,27 @@ const routes = {
params: {
id: { from: fromData.resource, name: 'id' },
id_sched: { from: fromData.resource, name: 'id2' },
- sched_action: { from: fromData.postBody, name: 'sched_action' }
- }
- }
+ sched_action: { from: fromData.postBody, name: 'sched_action' },
+ },
+ },
},
[DELETE]: {
delete: {
action: serviceDelete,
- params: { id: { from: fromData.resource, name: 'id', front: true } }
+ params: { id: { from: fromData.resource, name: 'id', front: true } },
},
sched_action: {
action: serviceDeleteSchedAction,
params: {
id: { from: fromData.resource, name: 'id' },
- id_sched: { from: fromData.resource, name: 'id2' }
- }
- }
- }
+ id_sched: { from: fromData.resource, name: 'id2' },
+ },
+ },
+ },
}
const serviceApi = {
- routes
+ routes,
}
module.exports = serviceApi
diff --git a/src/fireedge/src/server/routes/api/oneflow/service_template-functions.js b/src/fireedge/src/server/routes/api/oneflow/service_template-functions.js
index 98897f3afb..f757cea03b 100644
--- a/src/fireedge/src/server/routes/api/oneflow/service_template-functions.js
+++ b/src/fireedge/src/server/routes/api/oneflow/service_template-functions.js
@@ -17,12 +17,15 @@
const { Validator } = require('jsonschema')
const { role, service, action } = require('./schemas')
const { oneFlowConection } = require('./functions')
-const { httpMethod, defaultEmptyFunction } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ defaultEmptyFunction,
+} = require('server/utils/constants/defaults')
const { httpResponse, parsePostData } = require('server/utils/server')
const {
ok,
internalServerError,
- methodNotAllowed
+ methodNotAllowed,
} = require('server/utils/constants/http-codes')
const { returnSchemaError } = require('./functions')
const { GET, POST, DELETE, PUT } = httpMethod
@@ -35,7 +38,13 @@ const { GET, POST, DELETE, PUT } = httpMethod
* @param {string} data - data response http
*/
const success = (next = defaultEmptyFunction, res = {}, data = '') => {
- if ((next && typeof next === 'function') && (res && res.locals && res.locals.httpCode)) {
+ if (
+ next &&
+ typeof next === 'function' &&
+ res &&
+ res.locals &&
+ res.locals.httpCode
+ ) {
res.locals.httpCode = httpResponse(ok, data)
next()
}
@@ -49,8 +58,17 @@ const success = (next = defaultEmptyFunction, res = {}, data = '') => {
* @param {string} data - data response http
*/
const error = (next = defaultEmptyFunction, res = {}, data = '') => {
- if ((next && typeof next === 'function') && (res && res.locals && res.locals.httpCode)) {
- res.locals.httpCode = httpResponse(internalServerError, data && data.message)
+ if (
+ next &&
+ typeof next === 'function' &&
+ res &&
+ res.locals &&
+ res.locals.httpCode
+ ) {
+ res.locals.httpCode = httpResponse(
+ internalServerError,
+ data && data.message
+ )
next()
}
}
@@ -63,7 +81,12 @@ const error = (next = defaultEmptyFunction, res = {}, data = '') => {
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceTemplate = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const serviceTemplate = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (user && password) {
@@ -71,9 +94,17 @@ const serviceTemplate = (res = {}, next = () => undefined, params = {}, userData
if (params && params.id) {
config.path = '/service_template/{0}'
config.request = params.id
- oneFlowConection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
- oneFlowConection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
}
}
}
@@ -86,12 +117,27 @@ const serviceTemplate = (res = {}, next = () => undefined, params = {}, userData
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceTemplateDelete = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const serviceTemplateDelete = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (params && params.id && user && password) {
- const config = { method: DELETE, path: '/service_template/{0}', user, password, request: params.id }
- oneFlowConection(config, data => success(next, res, data), data => error(next, res, data))
+ const config = {
+ method: DELETE,
+ path: '/service_template/{0}',
+ user,
+ password,
+ request: params.id,
+ }
+ oneFlowConection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
res.locals.httpCode = httpResponse(
methodNotAllowed,
@@ -110,7 +156,12 @@ const serviceTemplateDelete = (res = {}, next = () => undefined, params = {}, us
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceTemplateCreate = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const serviceTemplateCreate = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (params && params.template && user && password) {
const v = new Validator()
@@ -123,9 +174,13 @@ const serviceTemplateCreate = (res = {}, next = () => undefined, params = {}, us
path: '/service_template',
user,
password,
- post: template
+ post: template,
}
- oneFlowConection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
res.locals.httpCode = httpResponse(
internalServerError,
@@ -151,7 +206,12 @@ const serviceTemplateCreate = (res = {}, next = () => undefined, params = {}, us
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceTemplateUpdate = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const serviceTemplateUpdate = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (params && params.id && params.template && user && password) {
const v = new Validator()
@@ -165,9 +225,13 @@ const serviceTemplateUpdate = (res = {}, next = () => undefined, params = {}, us
user,
password,
request: params.id,
- post: template
+ post: template,
}
- oneFlowConection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
res.locals.httpCode = httpResponse(
internalServerError,
@@ -194,7 +258,12 @@ const serviceTemplateUpdate = (res = {}, next = () => undefined, params = {}, us
* @param {object} params - params
* @param {object} userData - user data
*/
-const serviceTemplateAction = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const serviceTemplateAction = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
if (params && params.id && params.template && user && password) {
const v = new Validator()
@@ -207,9 +276,13 @@ const serviceTemplateAction = (res = {}, next = () => undefined, params = {}, us
user,
password,
request: params.id,
- post: template
+ post: template,
}
- oneFlowConection(config, data => success(next, res, data), data => error(next, res, data))
+ oneFlowConection(
+ config,
+ (data) => success(next, res, data),
+ (data) => error(next, res, data)
+ )
} else {
res.locals.httpCode = httpResponse(
internalServerError,
@@ -233,6 +306,6 @@ const serviceTemplateApi = {
serviceTemplateDelete,
serviceTemplateCreate,
serviceTemplateUpdate,
- serviceTemplateAction
+ serviceTemplateAction,
}
module.exports = serviceTemplateApi
diff --git a/src/fireedge/src/server/routes/api/oneflow/service_template.js b/src/fireedge/src/server/routes/api/oneflow/service_template.js
index 1a3e80a844..5990b895c6 100644
--- a/src/fireedge/src/server/routes/api/oneflow/service_template.js
+++ b/src/fireedge/src/server/routes/api/oneflow/service_template.js
@@ -14,13 +14,16 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
const {
serviceTemplate,
serviceTemplateDelete,
serviceTemplateCreate,
serviceTemplateUpdate,
- serviceTemplateAction
+ serviceTemplateAction,
} = require('./service_template-functions')
const { GET, POST, DELETE, PUT } = httpMethod
@@ -29,46 +32,46 @@ const routes = {
list: {
action: serviceTemplate,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
},
[POST]: {
create: {
action: serviceTemplateCreate,
params: {
- template: { from: fromData.postBody, front: true }
- }
+ template: { from: fromData.postBody, front: true },
+ },
},
action: {
action: serviceTemplateAction,
params: {
id: { from: fromData.resource, name: 'id', front: true },
- template: { from: fromData.postBody, front: true }
- }
- }
+ template: { from: fromData.postBody, front: true },
+ },
+ },
},
[PUT]: {
update: {
action: serviceTemplateUpdate,
params: {
id: { from: fromData.resource, name: 'id', front: true },
- template: { from: fromData.postBody, front: true }
- }
- }
+ template: { from: fromData.postBody, front: true },
+ },
+ },
},
[DELETE]: {
delete: {
action: serviceTemplateDelete,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
+ },
}
const serviceTemplateApi = {
- routes
+ routes,
}
module.exports = serviceTemplateApi
diff --git a/src/fireedge/src/server/routes/api/oneflow/string-routes.js b/src/fireedge/src/server/routes/api/oneflow/string-routes.js
index 3eed3f8fff..b659316f08 100644
--- a/src/fireedge/src/server/routes/api/oneflow/string-routes.js
+++ b/src/fireedge/src/server/routes/api/oneflow/string-routes.js
@@ -19,7 +19,7 @@ const SERVICE_TEMPLATE = 'service_template'
const Actions = {
SERVICE,
- SERVICE_TEMPLATE
+ SERVICE_TEMPLATE,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/provision/functions.js b/src/fireedge/src/server/routes/api/provision/functions.js
index db90f7afa1..11cbbdfb1e 100644
--- a/src/fireedge/src/server/routes/api/provision/functions.js
+++ b/src/fireedge/src/server/routes/api/provision/functions.js
@@ -27,7 +27,7 @@ const {
existsSync,
mkdirsSync,
renameSync,
- moveSync
+ moveSync,
} = require('fs-extra')
const { getFireedgeConfig, getProvisionConfig } = require('server/utils/yml')
const { messageTerminal } = require('server/utils/general')
@@ -54,17 +54,15 @@ const publish = (eventName = '', message = {}) => {
* @param {Function} callback - function executed when event is emited
*/
const subscriber = (eventName = '', callback = () => undefined) => {
- if (eventName &&
+ if (
+ eventName &&
callback &&
typeof callback === 'function' &&
eventsEmitter.listenerCount(eventName) < 1
) {
- eventsEmitter.on(
- eventName,
- message => {
- callback(message)
- }
- )
+ eventsEmitter.on(eventName, (message) => {
+ callback(message)
+ })
}
}
@@ -86,16 +84,26 @@ const createFolderWithFiles = (path = '', files = [], filename = '') => {
}
rtn.name = name
if (files && Array.isArray(files)) {
- files.forEach(file => {
+ files.forEach((file) => {
if (file && file.name && file.ext) {
- rtn.files.push({ name: file.name, ext: file.ext, path: `${internalPath}/${file.name}.${file.ext}` })
- createTemporalFile(internalPath, file.ext, (file && file.content) || '', file.name)
+ rtn.files.push({
+ name: file.name,
+ ext: file.ext,
+ path: `${internalPath}/${file.name}.${file.ext}`,
+ })
+ createTemporalFile(
+ internalPath,
+ file.ext,
+ (file && file.content) || '',
+ file.name
+ )
}
})
}
} catch (error) {
messageTerminal(defaultError(error && error.message))
}
+
return rtn
}
@@ -108,7 +116,12 @@ const createFolderWithFiles = (path = '', files = [], filename = '') => {
* @param {string} filename - name of the temporal file
* @returns {object} if file is created
*/
-const createTemporalFile = (path = '', ext = '', content = '', filename = '') => {
+const createTemporalFile = (
+ path = '',
+ ext = '',
+ content = '',
+ filename = ''
+) => {
let rtn
const name = filename || v4().replace(/-/g, '').toUpperCase()
const file = `${path}/${name}.${ext}`
@@ -121,6 +134,7 @@ const createTemporalFile = (path = '', ext = '', content = '', filename = '') =>
} catch (error) {
messageTerminal(defaultError(error && error.message))
}
+
return rtn
}
@@ -145,6 +159,7 @@ const createYMLContent = (content = '') => {
} catch (error) {
messageTerminal(defaultError(error && error.message))
}
+
return rtn
}
@@ -188,6 +203,7 @@ const renameFolder = (path = '', name = '', type = 'replace', callback) => {
messageTerminal(defaultError(error && error.message))
}
}
+
return rtn
}
@@ -208,6 +224,7 @@ const moveToFolder = (path = '', relative = '/../') => {
messageTerminal(defaultError(error && error.message))
}
}
+
return rtn
}
@@ -217,7 +234,10 @@ const moveToFolder = (path = '', relative = '/../') => {
* @returns {Array} command optional params
*/
const addOptionalCreateCommand = () => {
- const optionalCreateCommand = getSpecificConfig('oneprovision_optional_create_command')
+ const optionalCreateCommand = getSpecificConfig(
+ 'oneprovision_optional_create_command'
+ )
+
return [optionalCreateCommand].filter(Boolean) // return array position valids, no undefined or nulls
}
@@ -233,7 +253,7 @@ const findRecursiveFolder = (path = '', finder = '', rtn = false) => {
if (path && finder) {
try {
const dirs = readdirSync(path)
- dirs.forEach(dir => {
+ dirs.forEach((dir) => {
const name = `${path}/${dir}`
if (statSync(name).isDirectory()) {
if (basename(name) === finder) {
@@ -247,6 +267,7 @@ const findRecursiveFolder = (path = '', finder = '', rtn = false) => {
messageTerminal(defaultError(error && error.message))
}
}
+
return rtn
}
@@ -264,6 +285,7 @@ const getEndpoint = () => {
const host = parseUrl.host || ''
rtn = ['--endpoint', `${protocol}//${host}`]
}
+
return rtn
}
@@ -284,6 +306,7 @@ const getSpecificConfig = (key = '') => {
return appConfig[key]
}
}
+
return ''
}
@@ -298,7 +321,7 @@ const functionRoutes = {
publish,
addOptionalCreateCommand,
subscriber,
- getSpecificConfig
+ getSpecificConfig,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/provision/index.js b/src/fireedge/src/server/routes/api/provision/index.js
index 7773e0d944..68e69f460a 100644
--- a/src/fireedge/src/server/routes/api/provision/index.js
+++ b/src/fireedge/src/server/routes/api/provision/index.js
@@ -29,12 +29,12 @@ const { PROVIDER, PROVISION, PROVISION_TEMPLATE } = require('./string-routes')
const generatePrivateRoutes = () => [
...setApiRoutes(provisionRoutes, PROVISION),
...setApiRoutes(provisionTemplateRoutes, PROVISION_TEMPLATE),
- ...setApiRoutes(providerRoutes, PROVIDER)
+ ...setApiRoutes(providerRoutes, PROVIDER),
]
const functionRoutes = {
private: generatePrivateRoutes(),
- public: []
+ public: [],
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/provision/provider-functions.js b/src/fireedge/src/server/routes/api/provision/provider-functions.js
index e9700e1c87..f656b28d05 100644
--- a/src/fireedge/src/server/routes/api/provision/provider-functions.js
+++ b/src/fireedge/src/server/routes/api/provision/provider-functions.js
@@ -22,26 +22,23 @@ const {
defaultHideCredentials,
defaultHideCredentialReplacer,
defaultEmptyFunction,
- defaultProvidersConfigPath
+ defaultProvidersConfigPath,
} = require('server/utils/constants/defaults')
-const {
- ok,
- internalServerError
-} = require('server/utils/constants/http-codes')
+const { ok, internalServerError } = require('server/utils/constants/http-codes')
const {
httpResponse,
parsePostData,
getFilesbyEXT,
existsFile,
executeCommand,
- removeFile
+ removeFile,
} = require('server/utils/server')
const {
createTemporalFile,
createYMLContent,
getEndpoint,
- getSpecificConfig
+ getSpecificConfig,
} = require('./functions')
const httpInternalError = httpResponse(internalServerError, '', '')
@@ -54,7 +51,12 @@ const httpInternalError = httpResponse(internalServerError, '', '')
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const getProviderConfig = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const getProviderConfig = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const path = `${global.paths.PROVISION_PATH}${defaultProvidersConfigPath}`
const extFiles = 'yaml'
let response = internalServerError
@@ -70,8 +72,7 @@ const getProviderConfig = (res = {}, next = defaultEmptyFunction, params = {}, u
if (content && name) {
try {
message[name] = parse(content)
- } catch (error) {
- }
+ } catch (error) {}
}
}
/**
@@ -83,27 +84,17 @@ const getProviderConfig = (res = {}, next = defaultEmptyFunction, params = {}, u
message = error
}
- const files = getFilesbyEXT(
- path,
- extFiles,
- fillErrorMessage
- )
+ const files = getFilesbyEXT(path, extFiles, fillErrorMessage)
if (files.length) {
response = ok
- files.map(file => {
- existsFile(
- file,
- (content) => {
- if (typeof message === 'string') {
- message = {}
- }
- fillProviders(
- content,
- basename(file, `.${extFiles}`)
- )
+ files.forEach((file) => {
+ existsFile(file, (content) => {
+ if (typeof message === 'string') {
+ message = {}
}
- )
+ fillProviders(content, basename(file, `.${extFiles}`))
+ })
})
}
@@ -119,15 +110,30 @@ const getProviderConfig = (res = {}, next = defaultEmptyFunction, params = {}, u
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const getConnectionProviders = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const getConnectionProviders = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (user && password) {
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
if (params && params.id) {
- const paramsCommand = ['show', `${params.id}`.toLowerCase(), ...authCommand, ...endpoint, '--json']
- const executedCommand = executeCommand(defaultCommandProvider, paramsCommand, getSpecificConfig('oneprovision_prepend_command'))
+ const paramsCommand = [
+ 'show',
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ '--json',
+ ]
+ const executedCommand = executeCommand(
+ defaultCommandProvider,
+ paramsCommand,
+ getSpecificConfig('oneprovision_prepend_command')
+ )
try {
const response = executedCommand.success ? ok : internalServerError
const data = JSON.parse(executedCommand.data)
@@ -138,8 +144,12 @@ const getConnectionProviders = (res = {}, next = defaultEmptyFunction, params =
data.DOCUMENT.TEMPLATE.PROVISION_BODY &&
data.DOCUMENT.TEMPLATE.PROVISION_BODY.connection
) {
- res.locals.httpCode = httpResponse(response, data.DOCUMENT.TEMPLATE.PROVISION_BODY.connection)
+ res.locals.httpCode = httpResponse(
+ response,
+ data.DOCUMENT.TEMPLATE.PROVISION_BODY.connection
+ )
next()
+
return
}
} catch (error) {
@@ -159,7 +169,12 @@ const getConnectionProviders = (res = {}, next = defaultEmptyFunction, params =
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const getListProviders = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const getListProviders = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (user && password) {
@@ -167,9 +182,19 @@ const getListProviders = (res = {}, next = defaultEmptyFunction, params = {}, us
const authCommand = ['--user', user, '--password', password]
let paramsCommand = ['list', ...authCommand, ...endpoint, '--json']
if (params && params.id) {
- paramsCommand = ['show', `${params.id}`.toLowerCase(), ...authCommand, ...endpoint, '--json']
+ paramsCommand = [
+ 'show',
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ '--json',
+ ]
}
- const executedCommand = executeCommand(defaultCommandProvider, paramsCommand, getSpecificConfig('oneprovision_prepend_command'))
+ const executedCommand = executeCommand(
+ defaultCommandProvider,
+ paramsCommand,
+ getSpecificConfig('oneprovision_prepend_command')
+ )
try {
const response = executedCommand.success ? ok : internalServerError
const data = JSON.parse(executedCommand.data)
@@ -180,10 +205,11 @@ const getListProviders = (res = {}, next = defaultEmptyFunction, params = {}, us
* @param {object} provision - provision
* @returns {object} provision with TEMPLATE.PLAIN in JSON
*/
- const parseTemplatePlain = provision => {
+ const parseTemplatePlain = (provision) => {
if (provision && provision.TEMPLATE && provision.TEMPLATE.PLAIN) {
provision.TEMPLATE.PLAIN = JSON.parse(provision.TEMPLATE.PLAIN)
}
+
return provision
}
@@ -205,7 +231,7 @@ const getListProviders = (res = {}, next = defaultEmptyFunction, params = {}, us
) {
const encryptedData = {}
Object.keys(data.DOCUMENT.TEMPLATE.PROVISION_BODY.connection).forEach(
- key => {
+ (key) => {
encryptedData[key] = defaultHideCredentialReplacer
}
)
@@ -218,6 +244,7 @@ const getListProviders = (res = {}, next = defaultEmptyFunction, params = {}, us
}
res.locals.httpCode = httpResponse(response, data)
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
@@ -235,7 +262,12 @@ const getListProviders = (res = {}, next = defaultEmptyFunction, params = {}, us
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const createProviders = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const createProviders = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
const rtn = httpInternalError
if (params && params.resource && user && password) {
@@ -244,22 +276,37 @@ const createProviders = (res = {}, next = defaultEmptyFunction, params = {}, use
const resource = parsePostData(params.resource)
const content = createYMLContent(resource)
if (content) {
- const file = createTemporalFile(`${global.paths.CPI}/${defaultFolderTmpProvision}`, 'yaml', content)
+ const file = createTemporalFile(
+ `${global.paths.CPI}/${defaultFolderTmpProvision}`,
+ 'yaml',
+ content
+ )
if (file && file.name && file.path) {
const paramsCommand = ['create', file.path, ...authCommand, ...endpoint]
- const executedCommand = executeCommand(defaultCommandProvider, paramsCommand)
+ const executedCommand = executeCommand(
+ defaultCommandProvider,
+ paramsCommand
+ )
res.locals.httpCode = httpResponse(internalServerError)
if (executedCommand && executedCommand.data) {
if (executedCommand.success) {
const data = executedCommand.data
- const dataInternal = data && Array.isArray(data.match('\\d+')) ? data.match('\\d+').join() : data
+ const dataInternal =
+ data && Array.isArray(data.match('\\d+'))
+ ? data.match('\\d+').join()
+ : data
res.locals.httpCode = httpResponse(ok, dataInternal)
} else {
- res.locals.httpCode = httpResponse(internalServerError, '', executedCommand.data)
+ res.locals.httpCode = httpResponse(
+ internalServerError,
+ '',
+ executedCommand.data
+ )
}
}
removeFile(file.path)
next()
+
return
}
}
@@ -276,23 +323,42 @@ const createProviders = (res = {}, next = defaultEmptyFunction, params = {}, use
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const updateProviders = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const updateProviders = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
const rtn = httpInternalError
if (params && params.resource && params.id && user && password) {
const authCommand = ['--user', user, '--password', password]
const endpoint = getEndpoint()
const resource = parsePostData(params.resource)
- const file = createTemporalFile(`${global.paths.CPI}/${defaultFolderTmpProvision}`, 'json', JSON.stringify(resource))
+ const file = createTemporalFile(
+ `${global.paths.CPI}/${defaultFolderTmpProvision}`,
+ 'json',
+ JSON.stringify(resource)
+ )
if (file && file.name && file.path) {
- const paramsCommand = ['update', params.id, file.path, ...authCommand, ...endpoint]
- const executedCommand = executeCommand(defaultCommandProvider, paramsCommand)
+ const paramsCommand = [
+ 'update',
+ params.id,
+ file.path,
+ ...authCommand,
+ ...endpoint,
+ ]
+ const executedCommand = executeCommand(
+ defaultCommandProvider,
+ paramsCommand
+ )
res.locals.httpCode = httpResponse(internalServerError)
if (executedCommand && executedCommand.success) {
res.locals.httpCode = httpResponse(ok)
}
removeFile(file.path)
next()
+
return
}
}
@@ -308,22 +374,41 @@ const updateProviders = (res = {}, next = defaultEmptyFunction, params = {}, use
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const deleteProvider = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const deleteProvider = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.id && user && password) {
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
- const paramsCommand = ['delete', `${params.id}`.toLowerCase(), ...authCommand, ...endpoint]
- const executedCommand = executeCommand(defaultCommandProvider, paramsCommand, getSpecificConfig('oneprovision_prepend_command'))
+ const paramsCommand = [
+ 'delete',
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ ]
+ const executedCommand = executeCommand(
+ defaultCommandProvider,
+ paramsCommand,
+ getSpecificConfig('oneprovision_prepend_command')
+ )
const data = executedCommand.data || ''
try {
if (executedCommand && executedCommand.success) {
res.locals.httpCode = httpResponse(ok)
} else {
- res.locals.httpCode = httpResponse(internalServerError, '', executedCommand.data)
+ res.locals.httpCode = httpResponse(
+ internalServerError,
+ '',
+ executedCommand.data
+ )
}
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', data)
@@ -339,6 +424,6 @@ const providerFunctionsApi = {
getListProviders,
createProviders,
updateProviders,
- deleteProvider
+ deleteProvider,
}
module.exports = providerFunctionsApi
diff --git a/src/fireedge/src/server/routes/api/provision/provider.js b/src/fireedge/src/server/routes/api/provision/provider.js
index 94bb26c569..5f9138f30c 100644
--- a/src/fireedge/src/server/routes/api/provision/provider.js
+++ b/src/fireedge/src/server/routes/api/provision/provider.js
@@ -21,7 +21,7 @@ const {
createProviders,
updateProviders,
deleteProvider,
- getProviderConfig
+ getProviderConfig,
} = require('./provider-functions')
const { httpMethod } = require('server/utils/constants/defaults')
@@ -32,48 +32,48 @@ const routes = {
list: {
action: getListProviders,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
connection: {
action: getConnectionProviders,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
config: {
action: getProviderConfig,
- params: {}
- }
+ params: {},
+ },
},
[POST]: {
create: {
action: createProviders,
params: {
- resource: { from: fromData.postBody, front: true }
- }
- }
+ resource: { from: fromData.postBody, front: true },
+ },
+ },
},
[PUT]: {
update: {
action: updateProviders,
params: {
resource: { from: fromData.postBody, front: true },
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
},
[DELETE]: {
delete: {
action: deleteProvider,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
+ },
}
const providerApi = {
- routes
+ routes,
}
module.exports = providerApi
diff --git a/src/fireedge/src/server/routes/api/provision/provision-functions.js b/src/fireedge/src/server/routes/api/provision/provision-functions.js
index e0c4629fe2..73afdfe09d 100644
--- a/src/fireedge/src/server/routes/api/provision/provision-functions.js
+++ b/src/fireedge/src/server/routes/api/provision/provision-functions.js
@@ -27,7 +27,7 @@ const {
ok,
notFound,
accepted,
- internalServerError
+ internalServerError,
} = require('server/utils/constants/http-codes')
const {
httpResponse,
@@ -38,14 +38,14 @@ const {
getFilesbyEXT,
executeCommand,
executeCommandAsync,
- removeFile
+ removeFile,
} = require('server/utils/server')
const { checkEmptyObject } = require('server/utils/general')
const {
defaultFolderTmpProvision,
defaultCommandProvision,
defaultEmptyFunction,
- defaultErrorTemplate
+ defaultErrorTemplate,
} = require('server/utils/constants/defaults')
const {
createTemporalFile,
@@ -57,7 +57,7 @@ const {
publish,
getEndpoint,
addOptionalCreateCommand,
- getSpecificConfig
+ getSpecificConfig,
} = require('./functions')
const { provision } = require('./schemas')
@@ -65,11 +65,11 @@ const httpInternalError = httpResponse(internalServerError, '', '')
const logFile = {
name: 'stdouterr',
- ext: 'log'
+ ext: 'log',
}
const provisionFile = {
name: 'provision',
- ext: 'yaml'
+ ext: 'yaml',
}
const regexp = /^ID: \d+/
const regexpStartJSON = /^{/
@@ -96,9 +96,18 @@ const executeWithEmit = (command = [], actions = {}, dataForLog = {}) => {
actions &&
dataForLog
) {
- const err = actions.err && typeof actions.err === 'function' ? actions.err : defaultEmptyFunction
- const out = actions.out && typeof actions.out === 'function' ? actions.out : defaultEmptyFunction
- const close = actions.close && typeof actions.close === 'function' ? actions.close : defaultEmptyFunction
+ const err =
+ actions.err && typeof actions.err === 'function'
+ ? actions.err
+ : defaultEmptyFunction
+ const out =
+ actions.out && typeof actions.out === 'function'
+ ? actions.out
+ : defaultEmptyFunction
+ const close =
+ actions.close && typeof actions.close === 'function'
+ ? actions.close
+ : defaultEmptyFunction
// data for log
const id = (dataForLog && dataForLog.id) || ''
@@ -122,30 +131,42 @@ const executeWithEmit = (command = [], actions = {}, dataForLog = {}) => {
* @param {string} line - command CLI line
*/
const publisher = (line = '') => {
- const resposeData = callback(line, uuid) || { id, data: line, command: commandName, commandId: uuid }
+ const resposeData = callback(line, uuid) || {
+ id,
+ data: line,
+ command: commandName,
+ commandId: uuid,
+ }
publish(defaultCommandProvision, resposeData)
}
- message.toString().split(regexpSplitLine).map(line => {
- if (line) {
- if (
- (regexpStartJSON.test(line) && regexpEndJSON.test(line)) ||
- (!regexpStartJSON.test(line) && !regexpEndJSON.test(line) && pendingMessages.length === 0)
- ) {
- lastLine = line
- publisher(lastLine)
- } else if (
- (regexpStartJSON.test(line) && !regexpEndJSON.test(line)) ||
- (!regexpStartJSON.test(line) && !regexpEndJSON.test(line) && pendingMessages.length > 0)
- ) {
- pendingMessages += line
- } else {
- lastLine = pendingMessages + line
- publisher(lastLine)
- pendingMessages = ''
+ message
+ .toString()
+ .split(regexpSplitLine)
+ .forEach((line) => {
+ if (line) {
+ if (
+ (regexpStartJSON.test(line) && regexpEndJSON.test(line)) ||
+ (!regexpStartJSON.test(line) &&
+ !regexpEndJSON.test(line) &&
+ pendingMessages.length === 0)
+ ) {
+ lastLine = line
+ publisher(lastLine)
+ } else if (
+ (regexpStartJSON.test(line) && !regexpEndJSON.test(line)) ||
+ (!regexpStartJSON.test(line) &&
+ !regexpEndJSON.test(line) &&
+ pendingMessages.length > 0)
+ ) {
+ pendingMessages += line
+ } else {
+ lastLine = pendingMessages + line
+ publisher(lastLine)
+ pendingMessages = ''
+ }
}
- }
- })
+ })
}
executeCommandAsync(
@@ -153,19 +174,20 @@ const executeWithEmit = (command = [], actions = {}, dataForLog = {}) => {
command,
getSpecificConfig('oneprovision_prepend_command'),
{
- err: message => {
+ err: (message) => {
emit(message, err)
},
- out: message => {
+ out: (message) => {
emit(message, out)
},
- close: success => {
+ close: (success) => {
close(success, lastLine)
- }
+ },
}
)
rtn = true
}
+
return rtn
}
@@ -202,7 +224,7 @@ const logData = (id, fullPath = false) => {
const stringPath = `${path}/${logFile.name}.${logFile.ext}`
existsFile(
stringPath,
- filedata => {
+ (filedata) => {
rtn = { uuid, log: filedata.split(regexpSplitLine) }
if (fullPath) {
rtn.fullPath = stringPath
@@ -218,14 +240,17 @@ const logData = (id, fullPath = false) => {
} else {
existsFile(
relFileYML,
- filedata => {
+ (filedata) => {
const fileData = parse(filedata) || {}
if (fileData[id]) {
const findPending = findRecursiveFolder(basePath, fileData[id])
if (findPending) {
rtnFound(findPending, fileData[id])
} else {
- const findError = findRecursiveFolder(basePath, fileData[id] + appendError)
+ const findError = findRecursiveFolder(
+ basePath,
+ fileData[id] + appendError
+ )
if (findError) {
rtnFound(findError, fileData[id])
} else {
@@ -240,6 +265,7 @@ const logData = (id, fullPath = false) => {
)
}
}
+
return rtn
}
@@ -251,7 +277,12 @@ const logData = (id, fullPath = false) => {
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const getProvisionDefaults = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const getProvisionDefaults = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const extFiles = 'yml'
const { user, password } = userData
let rtn = httpInternalError
@@ -288,8 +319,7 @@ const getProvisionDefaults = (res = {}, next = defaultEmptyFunction, params = {}
}
try {
providers[name].push(parse(content))
- } catch (error) {
- }
+ } catch (error) {}
}
}
/**
@@ -302,7 +332,13 @@ const getProvisionDefaults = (res = {}, next = defaultEmptyFunction, params = {}
const fillProvisions = (content = '', filePath = '', path = '') => {
if (content && filePath && path) {
const name = basename(filePath).replace(`.${extFiles}`, '')
- const paramsCommand = ['validate', '--dump', filePath, ...authCommand, ...endpoint]
+ const paramsCommand = [
+ 'validate',
+ '--dump',
+ filePath,
+ ...authCommand,
+ ...endpoint,
+ ]
const executedCommand = executeCommand(
defaultCommandProvision,
paramsCommand,
@@ -323,47 +359,39 @@ const getProvisionDefaults = (res = {}, next = defaultEmptyFunction, params = {}
directories.forEach((directory = {}) => {
if (directory.filename && directory.path) {
// description
- existsFile(
- `${directory.path}/description.md`,
- fillDescription
- )
+ existsFile(`${directory.path}/description.md`, fillDescription)
// providers
- getDirectories(
- `${directory.path}/providers`
- ).map((provider = {}) => {
- if (provider.filename && provider.path) {
- getFilesbyEXT(
- provider.path,
- extFiles
- ).map(file => {
- existsFile(
- file,
- (content) => fillProviders(
- content,
- provider.filename
+ getDirectories(`${directory.path}/providers`).forEach(
+ (provider = {}) => {
+ if (provider.filename && provider.path) {
+ getFilesbyEXT(provider.path, extFiles).forEach((file) => {
+ existsFile(file, (content) =>
+ fillProviders(content, provider.filename)
)
- )
- })
+ })
+ }
}
- })
+ )
// provisions
- getFilesbyEXT(
- `${directory.path}/provisions`,
- extFiles
- ).map(file => {
- existsFile(
- file,
- (content, filePath) => fillProvisions(content, filePath, dirname(file))
- )
- })
+ getFilesbyEXT(`${directory.path}/provisions`, extFiles).forEach(
+ (file) => {
+ existsFile(file, (content, filePath) =>
+ fillProvisions(content, filePath, dirname(file))
+ )
+ }
+ )
- if (description && !checkEmptyObject(providers) && !checkEmptyObject(provisions)) {
+ if (
+ description &&
+ !checkEmptyObject(providers) &&
+ !checkEmptyObject(provisions)
+ ) {
files[directory.filename] = {
description,
providers,
- provisions
+ provisions,
}
// clear
description = ''
@@ -386,13 +414,24 @@ const getProvisionDefaults = (res = {}, next = defaultEmptyFunction, params = {}
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const getListResourceProvision = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const getListResourceProvision = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.resource && user && password) {
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
- const paramsCommand = [`${params.resource}`.toLowerCase(), 'list', ...authCommand, ...endpoint, '--json']
+ const paramsCommand = [
+ `${params.resource}`.toLowerCase(),
+ 'list',
+ ...authCommand,
+ ...endpoint,
+ '--json',
+ ]
const executedCommand = executeCommand(
defaultCommandProvision,
paramsCommand,
@@ -400,8 +439,12 @@ const getListResourceProvision = (res = {}, next = defaultEmptyFunction, params
)
try {
const response = executedCommand.success ? ok : internalServerError
- res.locals.httpCode = httpResponse(response, JSON.parse(executedCommand.data))
+ res.locals.httpCode = httpResponse(
+ response,
+ JSON.parse(executedCommand.data)
+ )
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
@@ -419,7 +462,12 @@ const getListResourceProvision = (res = {}, next = defaultEmptyFunction, params
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const getListProvisions = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const getListProvisions = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (user && password) {
@@ -427,7 +475,13 @@ const getListProvisions = (res = {}, next = defaultEmptyFunction, params = {}, u
const authCommand = ['--user', user, '--password', password]
let paramsCommand = ['list', ...authCommand, ...endpoint, '--json']
if (params && params.id) {
- paramsCommand = ['show', `${params.id}`.toLowerCase(), ...authCommand, ...endpoint, '--json']
+ paramsCommand = [
+ 'show',
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ '--json',
+ ]
}
const executedCommand = executeCommand(
defaultCommandProvision,
@@ -444,10 +498,11 @@ const getListProvisions = (res = {}, next = defaultEmptyFunction, params = {}, u
* @param {object} provision - provision
* @returns {object} provision with TEMPLATE.BODY in JSON
*/
- const parseTemplateBody = provision => {
+ const parseTemplateBody = (provision) => {
if (provision && provision.TEMPLATE && provision.TEMPLATE.BODY) {
provision.TEMPLATE.BODY = JSON.parse(provision.TEMPLATE.BODY)
}
+
return provision
}
@@ -458,6 +513,7 @@ const getListProvisions = (res = {}, next = defaultEmptyFunction, params = {}, u
}
res.locals.httpCode = httpResponse(response, data)
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
@@ -475,13 +531,24 @@ const getListProvisions = (res = {}, next = defaultEmptyFunction, params = {}, u
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const deleteResource = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const deleteResource = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.resource && params.id && user && password) {
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
- const paramsCommand = [`${params.resource}`.toLowerCase(), 'delete', `${params.id}`.toLowerCase(), ...authCommand, ...endpoint]
+ const paramsCommand = [
+ `${params.resource}`.toLowerCase(),
+ 'delete',
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ ]
const executedCommand = executeCommand(
defaultCommandProvision,
paramsCommand,
@@ -489,7 +556,10 @@ const deleteResource = (res = {}, next = defaultEmptyFunction, params = {}, user
)
try {
const response = executedCommand.success ? ok : internalServerError
- rtn = httpResponse(response, executedCommand.data ? JSON.parse(executedCommand.data) : params.id)
+ rtn = httpResponse(
+ response,
+ executedCommand.data ? JSON.parse(executedCommand.data) : params.id
+ )
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
}
@@ -507,7 +577,13 @@ const deleteResource = (res = {}, next = defaultEmptyFunction, params = {}, user
* @param {object} userData - user of http request
* @param {Function} oneConnection - function xmlrpc
*/
-const deleteProvision = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const deleteProvision = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const basePath = `${global.paths.CPI}/provision`
const relFile = `${basePath}/${relName}`
const relFileYML = `${relFile}.${ext}`
@@ -519,13 +595,25 @@ const deleteProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
const cleanup = params.cleanup ? ['--cleanup'] : []
- const paramsCommand = [command, params.id, '--batch', '--debug', '--json', ...cleanup, ...authCommand, ...endpoint]
+ const paramsCommand = [
+ command,
+ params.id,
+ '--batch',
+ '--debug',
+ '--json',
+ ...cleanup,
+ ...authCommand,
+ ...endpoint,
+ ]
// get Log file
const dataLog = logData(params.id, true)
// create stream for write into file
- const stream = dataLog && dataLog.fullPath && createWriteStream(dataLog.fullPath, { flags: 'a' })
+ const stream =
+ dataLog &&
+ dataLog.fullPath &&
+ createWriteStream(dataLog.fullPath, { flags: 'a' })
/**
* This function is performed for each command line response.
@@ -534,7 +622,12 @@ const deleteProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
* @param {string} uuid - uuid commnand
*/
const emit = (lastLine, uuid) => {
- const renderLine = { id: params.id, data: lastLine, command: command, commandId: uuid }
+ const renderLine = {
+ id: params.id,
+ data: lastLine,
+ command: command,
+ commandId: uuid,
+ }
stream && stream.write && stream.write(`${JSON.stringify(renderLine)}\n`)
}
@@ -547,42 +640,54 @@ const deleteProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
const close = (success, lastLine) => {
if (success) {
stream && stream.end && stream.end()
- existsFile(
- relFileYML,
- filedata => {
- let uuid = ''
- if (!checkSync(relFileLOCK)) {
- lockSync(relFileLOCK)
- const fileData = parse(filedata) || {}
- if (fileData[params.id]) {
- uuid = fileData[params.id]
- delete fileData[params.id]
- createTemporalFile(
- basePath,
- ext,
- createYMLContent(
- Object.keys(fileData).length !== 0 && fileData.constructor === Object && fileData
- ),
- relName
- )
- }
- unlockSync(relFileLOCK)
- if (uuid) {
- // provisions in deploy
- const findFolder = findRecursiveFolder(`${global.paths.CPI}/provision`, uuid)
- findFolder && removeFile(findFolder)
- // provisions in error
- const findFolderERROR = findRecursiveFolder(`${global.paths.CPI}/provision`, uuid + appendError)
- findFolderERROR && removeFile(findFolderERROR)
- }
+ existsFile(relFileYML, (filedata) => {
+ let uuid = ''
+ if (!checkSync(relFileLOCK)) {
+ lockSync(relFileLOCK)
+ const fileData = parse(filedata) || {}
+ if (fileData[params.id]) {
+ uuid = fileData[params.id]
+ delete fileData[params.id]
+ createTemporalFile(
+ basePath,
+ ext,
+ createYMLContent(
+ Object.keys(fileData).length !== 0 &&
+ fileData.constructor === Object &&
+ fileData
+ ),
+ relName
+ )
+ }
+ unlockSync(relFileLOCK)
+ if (uuid) {
+ // provisions in deploy
+ const findFolder = findRecursiveFolder(
+ `${global.paths.CPI}/provision`,
+ uuid
+ )
+ findFolder && removeFile(findFolder)
+ // provisions in error
+ const findFolderERROR = findRecursiveFolder(
+ `${global.paths.CPI}/provision`,
+ uuid + appendError
+ )
+ findFolderERROR && removeFile(findFolderERROR)
}
}
+ })
+ const findFolder = findRecursiveFolder(
+ `${global.paths.CPI}/provision`,
+ params.id
)
- const findFolder = findRecursiveFolder(`${global.paths.CPI}/provision`, params.id)
findFolder && removeFile(findFolder)
} else {
const connect = oneConnection(user, password)
- connect(Actions.DOCUMENT_UPDATE, [parseInt(params.id, 10), sprintf(defaultErrorTemplate, lastLine), 1], defaultEmptyFunction)
+ connect(
+ Actions.DOCUMENT_UPDATE,
+ [parseInt(params.id, 10), sprintf(defaultErrorTemplate, lastLine), 1],
+ defaultEmptyFunction
+ )
}
}
@@ -594,8 +699,12 @@ const deleteProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
)
// response Http
- res.locals.httpCode = httpResponse(executedCommand ? accepted : internalServerError, params.id)
+ res.locals.httpCode = httpResponse(
+ executedCommand ? accepted : internalServerError,
+ params.id
+ )
next()
+
return
}
res.locals.httpCode = rtn
@@ -610,13 +719,24 @@ const deleteProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const hostCommand = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const hostCommand = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.action && params.id && user && password) {
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
- const paramsCommand = ['host', `${params.action}`.toLowerCase(), `${params.id}`.toLowerCase(), ...authCommand, ...endpoint]
+ const paramsCommand = [
+ 'host',
+ `${params.action}`.toLowerCase(),
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ ]
const executedCommand = executeCommand(
defaultCommandProvision,
paramsCommand,
@@ -624,8 +744,12 @@ const hostCommand = (res = {}, next = defaultEmptyFunction, params = {}, userDat
)
try {
const response = executedCommand.success ? ok : internalServerError
- res.locals.httpCode = httpResponse(response, executedCommand.data ? JSON.parse(executedCommand.data) : params.id)
+ res.locals.httpCode = httpResponse(
+ response,
+ executedCommand.data ? JSON.parse(executedCommand.data) : params.id
+ )
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
@@ -643,13 +767,32 @@ const hostCommand = (res = {}, next = defaultEmptyFunction, params = {}, userDat
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const hostCommandSSH = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const hostCommandSSH = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
- if (params && params.action && params.id && params.command && user && password) {
+ if (
+ params &&
+ params.action &&
+ params.id &&
+ params.command &&
+ user &&
+ password
+ ) {
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
- const paramsCommand = ['host', `${params.action}`.toLowerCase(), `${params.id}`.toLowerCase(), `${params.command}`.toLowerCase(), ...authCommand, ...endpoint]
+ const paramsCommand = [
+ 'host',
+ `${params.action}`.toLowerCase(),
+ `${params.id}`.toLowerCase(),
+ `${params.command}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ ]
const executedCommand = executeCommand(
defaultCommandProvision,
paramsCommand,
@@ -657,8 +800,12 @@ const hostCommandSSH = (res = {}, next = defaultEmptyFunction, params = {}, user
)
try {
const response = executedCommand.success ? ok : internalServerError
- res.locals.httpCode = httpResponse(response, executedCommand.data ? JSON.parse(executedCommand.data) : params.id)
+ res.locals.httpCode = httpResponse(
+ response,
+ executedCommand.data ? JSON.parse(executedCommand.data) : params.id
+ )
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
@@ -677,7 +824,13 @@ const hostCommandSSH = (res = {}, next = defaultEmptyFunction, params = {}, user
* @param {object} userData - user of http request
* @param {Function} oneConnection - function of xmlrpc
*/
-const createProvision = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const createProvision = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const basePath = `${global.paths.CPI}/provision`
const relFile = `${basePath}/${relName}`
const relFileYML = `${relFile}.${ext}`
@@ -692,7 +845,13 @@ const createProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
const command = 'create'
const authCommand = ['--user', user, '--password', password]
const endpoint = getEndpoint()
- const files = createFolderWithFiles(`${global.paths.CPI}/provision/${id}/tmp`, [{ name: logFile.name, ext: logFile.ext }, { name: provisionFile.name, ext: provisionFile.ext, content }])
+ const files = createFolderWithFiles(
+ `${global.paths.CPI}/provision/${id}/tmp`,
+ [
+ { name: logFile.name, ext: logFile.ext },
+ { name: provisionFile.name, ext: provisionFile.ext, content },
+ ]
+ )
if (files && files.name && files.files) {
/**
* Find file in created files.
@@ -702,7 +861,11 @@ const createProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
* @param {Array} arr - array of files
* @returns {Array} path file
*/
- const find = (val = '', ext = '', arr = files.files) => arr.find(e => e && e.path && e.ext && e.name && e.name === val && e.ext === ext)
+ const find = (val = '', ext = '', arr = files.files) =>
+ arr.find(
+ (e) =>
+ e && e.path && e.ext && e.name && e.name === val && e.ext === ext
+ )
const config = find(provisionFile.name, provisionFile.ext)
const log = find(logFile.name, logFile.ext)
@@ -713,10 +876,19 @@ const createProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
* @param {string} filedata - provision data
*/
const create = (filedata = '') => {
- const paramsCommand = [command, config.path, '--batch', '--debug', '--json', ...optionalCommand, ...authCommand, ...endpoint]
+ const paramsCommand = [
+ command,
+ config.path,
+ '--batch',
+ '--debug',
+ '--json',
+ ...optionalCommand,
+ ...authCommand,
+ ...endpoint,
+ ]
// stream file log
- var stream = createWriteStream(log.path, { flags: 'a' })
+ const stream = createWriteStream(log.path, { flags: 'a' })
/**
* This function is performed for each command line response.
@@ -734,12 +906,23 @@ const createProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
if (id && !fileData[id]) {
lockSync(relFileLOCK)
fileData[id] = files.name
- createTemporalFile(basePath, ext, createYMLContent(fileData), relName)
+ createTemporalFile(
+ basePath,
+ ext,
+ createYMLContent(fileData),
+ relName
+ )
unlockSync(relFileLOCK)
}
}
- const renderLine = { id: files.name, data: lastLine, command: command, commandId: uuid }
+ const renderLine = {
+ id: files.name,
+ data: lastLine,
+ command: command,
+ commandId: uuid,
+ }
stream.write(`${JSON.stringify(renderLine)}\n`)
+
return renderLine
}
}
@@ -753,30 +936,35 @@ const createProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
const close = (success, lastLine) => {
stream.end()
if (success && regexp.test(lastLine)) {
- const newPath = renameFolder(config.path, lastLine.match('\\d+'), 'replace')
+ const newPath = renameFolder(
+ config.path,
+ lastLine.match('\\d+'),
+ 'replace'
+ )
if (newPath) {
- existsFile(
- relFileYML,
- filedata => {
- if (!checkSync(relFileLOCK)) {
- lockSync(relFileLOCK)
- const fileData = parse(filedata) || {}
- const findKey = Object.keys(fileData).find(key => fileData[key] === files.name)
- if (findKey) {
- delete fileData[findKey]
- createTemporalFile(
- basePath,
- ext,
- createYMLContent(
- Object.keys(fileData).length !== 0 && fileData.constructor === Object && fileData
- ),
- relName
- )
- }
- unlockSync(relFileLOCK)
+ existsFile(relFileYML, (filedata) => {
+ if (!checkSync(relFileLOCK)) {
+ lockSync(relFileLOCK)
+ const fileData = parse(filedata) || {}
+ const findKey = Object.keys(fileData).find(
+ (key) => fileData[key] === files.name
+ )
+ if (findKey) {
+ delete fileData[findKey]
+ createTemporalFile(
+ basePath,
+ ext,
+ createYMLContent(
+ Object.keys(fileData).length !== 0 &&
+ fileData.constructor === Object &&
+ fileData
+ ),
+ relName
+ )
}
+ unlockSync(relFileLOCK)
}
- )
+ })
moveToFolder(newPath, '/../../../')
}
}
@@ -793,19 +981,18 @@ const createProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
existsFile(
relFileYML,
- filedata => {
+ (filedata) => {
create(filedata)
},
() => {
- createFile(
- relFileYML, '', filedata => {
- create(filedata)
- }
- )
+ createFile(relFileYML, '', (filedata) => {
+ create(filedata)
+ })
}
)
res.locals.httpCode = httpResponse(accepted, files.name)
next()
+
return
}
}
@@ -823,20 +1010,38 @@ const createProvision = (res = {}, next = defaultEmptyFunction, params = {}, use
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const configureProvision = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const configureProvision = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
const rtn = httpInternalError
if (params && params.id && user && password) {
const command = 'configure'
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
- const paramsCommand = [command, params.id, '--debug', '--json', '--fail_cleanup', '--batch', '--force', ...authCommand, ...endpoint]
+ const paramsCommand = [
+ command,
+ params.id,
+ '--debug',
+ '--json',
+ '--fail_cleanup',
+ '--batch',
+ '--force',
+ ...authCommand,
+ ...endpoint,
+ ]
// get Log file
const dataLog = logData(params.id, true)
// create stream for write into file
- const stream = dataLog && dataLog.fullPath && createWriteStream(dataLog.fullPath, { flags: 'a' })
+ const stream =
+ dataLog &&
+ dataLog.fullPath &&
+ createWriteStream(dataLog.fullPath, { flags: 'a' })
/**
* This function is performed for each command line response.
@@ -845,7 +1050,12 @@ const configureProvision = (res = {}, next = defaultEmptyFunction, params = {},
* @param {string} uuid - UUID command
*/
const emit = (lastLine, uuid) => {
- const renderLine = { id: params.id, data: lastLine, command: command, commandId: uuid }
+ const renderLine = {
+ id: params.id,
+ data: lastLine,
+ command: command,
+ commandId: uuid,
+ }
stream && stream.write && stream.write(`${JSON.stringify(renderLine)}\n`)
}
@@ -867,8 +1077,12 @@ const configureProvision = (res = {}, next = defaultEmptyFunction, params = {},
)
// response Http
- res.locals.httpCode = httpResponse(executedCommand ? accepted : internalServerError, params.id)
+ res.locals.httpCode = httpResponse(
+ executedCommand ? accepted : internalServerError,
+ params.id
+ )
next()
+
return
}
res.locals.httpCode = rtn
@@ -883,20 +1097,37 @@ const configureProvision = (res = {}, next = defaultEmptyFunction, params = {},
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const configureHost = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const configureHost = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
const rtn = httpInternalError
if (params && params.id && user && password) {
const command = 'configure'
const endpoint = getEndpoint()
const authCommand = ['--user', user, '--password', password]
- const paramsCommand = ['host', command, `${params.id}`.toLowerCase(), '--debug', '--fail_cleanup', '--batch', ...authCommand, ...endpoint]
+ const paramsCommand = [
+ 'host',
+ command,
+ `${params.id}`.toLowerCase(),
+ '--debug',
+ '--fail_cleanup',
+ '--batch',
+ ...authCommand,
+ ...endpoint,
+ ]
// get Log file
const dataLog = logData(params.id, true)
// create stream for write into file
- const stream = dataLog && dataLog.fullPath && createWriteStream(dataLog.fullPath, { flags: 'a' })
+ const stream =
+ dataLog &&
+ dataLog.fullPath &&
+ createWriteStream(dataLog.fullPath, { flags: 'a' })
/**
* This function is performed for each command line response.
@@ -905,7 +1136,12 @@ const configureHost = (res = {}, next = defaultEmptyFunction, params = {}, userD
* @param {string} uuid - uuid command
*/
const emit = (lastLine, uuid) => {
- const renderLine = { id: params.id, data: lastLine, command: `host ${command}`, commandId: uuid }
+ const renderLine = {
+ id: params.id,
+ data: lastLine,
+ command: `host ${command}`,
+ commandId: uuid,
+ }
stream && stream.write && stream.write(`${JSON.stringify(renderLine)}\n`)
}
@@ -927,8 +1163,12 @@ const configureHost = (res = {}, next = defaultEmptyFunction, params = {}, userD
)
// response Http
- res.locals.httpCode = httpResponse(executedCommand ? accepted : internalServerError, params.id)
+ res.locals.httpCode = httpResponse(
+ executedCommand ? accepted : internalServerError,
+ params.id
+ )
next()
+
return
}
res.locals.httpCode = rtn
@@ -943,7 +1183,12 @@ const configureHost = (res = {}, next = defaultEmptyFunction, params = {}, userD
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const validate = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const validate = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.resource && user && password) {
@@ -955,9 +1200,19 @@ const validate = (res = {}, next = defaultEmptyFunction, params = {}, userData =
if (valSchema.valid) {
const content = createYMLContent(resource)
if (content) {
- const file = createTemporalFile(`${global.paths.CPI}/${defaultFolderTmpProvision}`, 'yaml', content)
+ const file = createTemporalFile(
+ `${global.paths.CPI}/${defaultFolderTmpProvision}`,
+ 'yaml',
+ content
+ )
if (file && file.name && file.path) {
- const paramsCommand = ['validate', '--dump', file.path, ...authCommand, ...endpoint]
+ const paramsCommand = [
+ 'validate',
+ '--dump',
+ file.path,
+ ...authCommand,
+ ...endpoint,
+ ]
const executedCommand = executeCommand(
defaultCommandProvision,
paramsCommand,
@@ -970,13 +1225,14 @@ const validate = (res = {}, next = defaultEmptyFunction, params = {}, userData =
removeFile(file)
res.locals.httpCode = httpResponse(response)
next()
+
return
}
}
} else {
const errors = []
if (valSchema && valSchema.errors) {
- valSchema.errors.forEach(error => {
+ valSchema.errors.forEach((error) => {
errors.push(error.stack.replace(/^instance./, ''))
})
rtn = httpResponse(internalServerError, '', errors.toString())
@@ -994,7 +1250,11 @@ const validate = (res = {}, next = defaultEmptyFunction, params = {}, userData =
* @param {Function} next - express stepper
* @param {object} params - params of http request
*/
-const getLogProvisions = (res = {}, next = defaultEmptyFunction, params = {}) => {
+const getLogProvisions = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {}
+) => {
let rtn = httpInternalError
if (params && params.id) {
const foundLogs = logData(params.id)
@@ -1020,6 +1280,6 @@ const provisionFunctionsApi = {
createProvision,
configureProvision,
configureHost,
- validate
+ validate,
}
module.exports = provisionFunctionsApi
diff --git a/src/fireedge/src/server/routes/api/provision/provision.js b/src/fireedge/src/server/routes/api/provision/provision.js
index dad1c92266..382e3815ed 100644
--- a/src/fireedge/src/server/routes/api/provision/provision.js
+++ b/src/fireedge/src/server/routes/api/provision/provision.js
@@ -14,7 +14,10 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
const {
getListResourceProvision,
getListProvisions,
@@ -27,7 +30,7 @@ const {
configureProvision,
configureHost,
validate,
- getProvisionDefaults
+ getProvisionDefaults,
} = require('./provision-functions')
const { GET, POST, DELETE, PUT } = httpMethod
@@ -36,192 +39,192 @@ const routes = {
list: {
action: getListProvisions,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
cluster: {
action: getListResourceProvision,
params: {
- resource: { from: fromData.resource, name: 'method' }
- }
+ resource: { from: fromData.resource, name: 'method' },
+ },
},
datastore: {
action: getListResourceProvision,
params: {
- resource: { from: fromData.resource, name: 'method' }
- }
+ resource: { from: fromData.resource, name: 'method' },
+ },
},
host: {
action: getListResourceProvision,
params: {
- resource: { from: fromData.resource, name: 'method' }
- }
+ resource: { from: fromData.resource, name: 'method' },
+ },
},
image: {
action: getListResourceProvision,
params: {
- resource: { from: fromData.resource, name: 'method' }
- }
+ resource: { from: fromData.resource, name: 'method' },
+ },
},
network: {
action: getListResourceProvision,
params: {
- resource: { from: fromData.resource, name: 'method' }
- }
+ resource: { from: fromData.resource, name: 'method' },
+ },
},
template: {
action: getListResourceProvision,
params: {
- resource: { from: fromData.resource, name: 'method' }
- }
+ resource: { from: fromData.resource, name: 'method' },
+ },
},
vntemplate: {
action: getListResourceProvision,
params: {
- resource: { from: fromData.resource, name: 'method' }
- }
+ resource: { from: fromData.resource, name: 'method' },
+ },
},
log: {
action: getLogProvisions,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
defaults: {
action: getProvisionDefaults,
- params: {}
- }
+ params: {},
+ },
},
[POST]: {
create: {
action: createProvision,
params: {
- resource: { from: fromData.postBody, front: true }
+ resource: { from: fromData.postBody, front: true },
},
- websocket: true
+ websocket: true,
},
validate: {
action: validate,
params: {
- resource: { from: fromData.postBody, front: true }
- }
+ resource: { from: fromData.postBody, front: true },
+ },
},
host: {
poweroff: {
action: hostCommand,
params: {
action: { from: fromData.resource, name: 'id' },
- id: { from: fromData.resource, name: 'id2', front: true }
- }
+ id: { from: fromData.resource, name: 'id2', front: true },
+ },
},
reboot: {
action: hostCommand,
params: {
action: { from: fromData.resource, name: 'id' },
- id: { from: fromData.resource, name: 'id2', front: true }
- }
+ id: { from: fromData.resource, name: 'id2', front: true },
+ },
},
resume: {
action: hostCommand,
params: {
action: { from: fromData.resource, name: 'id' },
- id: { from: fromData.resource, name: 'id2', front: true }
- }
+ id: { from: fromData.resource, name: 'id2', front: true },
+ },
},
ssh: {
action: hostCommandSSH,
params: {
action: { from: fromData.resource, name: 'id' },
id: { from: fromData.resource, name: 'id2', front: true },
- command: { from: fromData.postBody, name: 'command', front: true }
- }
- }
- }
+ command: { from: fromData.postBody, name: 'command', front: true },
+ },
+ },
+ },
},
[DELETE]: {
delete: {
action: deleteProvision,
params: {
id: { from: fromData.resource, name: 'id', front: true },
- cleanup: { from: fromData.postBody, name: 'cleanup', front: true }
+ cleanup: { from: fromData.postBody, name: 'cleanup', front: true },
},
- websocket: true
+ websocket: true,
},
datastore: {
action: deleteResource,
params: {
resource: { from: fromData.resource, name: 'method' },
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
flowtemplate: {
action: deleteResource,
params: {
resource: { from: fromData.resource, name: 'method' },
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
host: {
action: deleteResource,
params: {
resource: { from: fromData.resource, name: 'method' },
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
image: {
action: deleteResource,
params: {
resource: { from: fromData.resource, name: 'method' },
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
network: {
action: deleteResource,
params: {
resource: { from: fromData.resource, name: 'method' },
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
vntemplate: {
action: deleteResource,
params: {
resource: { from: fromData.resource, name: 'method' },
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
template: {
action: deleteResource,
params: {
resource: { from: fromData.resource, name: 'method' },
- id: { from: fromData.resource, name: 'id', front: true }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
},
cluster: {
action: deleteResource,
params: {
resource: { from: fromData.resource, name: 'method' },
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
},
[PUT]: {
configure: {
action: configureProvision,
params: {
- id: { from: fromData.resource, name: 'id' }
+ id: { from: fromData.resource, name: 'id' },
},
- websocket: true
+ websocket: true,
},
host: {
action: configureHost,
params: {
- id: { from: fromData.resource, name: 'id' }
- }
- }
- }
+ id: { from: fromData.resource, name: 'id' },
+ },
+ },
+ },
}
const provisionApi = {
- routes
+ routes,
}
module.exports = provisionApi
diff --git a/src/fireedge/src/server/routes/api/provision/provision_template-functions.js b/src/fireedge/src/server/routes/api/provision/provision_template-functions.js
index 29376d1fe3..58c414b60e 100644
--- a/src/fireedge/src/server/routes/api/provision/provision_template-functions.js
+++ b/src/fireedge/src/server/routes/api/provision/provision_template-functions.js
@@ -17,24 +17,21 @@
const { Validator } = require('jsonschema')
const {
defaultFolderTmpProvision,
- defaultCommandProvisionTemplate
+ defaultCommandProvisionTemplate,
} = require('server/utils/constants/defaults')
-const {
- ok,
- internalServerError
-} = require('server/utils/constants/http-codes')
+const { ok, internalServerError } = require('server/utils/constants/http-codes')
const {
httpResponse,
parsePostData,
executeCommand,
- removeFile
+ removeFile,
} = require('server/utils/server')
const {
createYMLContent,
createTemporalFile,
getEndpoint,
- getSpecificConfig
+ getSpecificConfig,
} = require('./functions')
const { provider } = require('./schemas')
@@ -48,7 +45,12 @@ const httpInternalError = httpResponse(internalServerError, '', '')
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const getListProvisionTemplates = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const getListProvisionTemplates = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (user && password) {
@@ -56,13 +58,27 @@ const getListProvisionTemplates = (res = {}, next = () => undefined, params = {}
const authCommand = ['--user', user, '--password', password]
let paramsCommand = ['list', ...authCommand, '--json']
if (params && params.id) {
- paramsCommand = ['show', `${params.id}`.toLowerCase(), ...authCommand, ...endpoint, '--json']
+ paramsCommand = [
+ 'show',
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ '--json',
+ ]
}
- const executedCommand = executeCommand(defaultCommandProvisionTemplate, paramsCommand, getSpecificConfig('oneprovision_prepend_command'))
+ const executedCommand = executeCommand(
+ defaultCommandProvisionTemplate,
+ paramsCommand,
+ getSpecificConfig('oneprovision_prepend_command')
+ )
try {
const response = executedCommand.success ? ok : internalServerError
- res.locals.httpCode = httpResponse(response, JSON.parse(executedCommand.data))
+ res.locals.httpCode = httpResponse(
+ response,
+ JSON.parse(executedCommand.data)
+ )
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
@@ -80,7 +96,12 @@ const getListProvisionTemplates = (res = {}, next = () => undefined, params = {}
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const createProvisionTemplate = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const createProvisionTemplate = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.resource && user && password) {
@@ -92,23 +113,41 @@ const createProvisionTemplate = (res = {}, next = () => undefined, params = {},
if (valSchema.valid) {
const content = createYMLContent(resource)
if (content) {
- const file = createTemporalFile(`${global.paths.CPI}/${defaultFolderTmpProvision}`, 'yaml', content)
+ const file = createTemporalFile(
+ `${global.paths.CPI}/${defaultFolderTmpProvision}`,
+ 'yaml',
+ content
+ )
if (file && file.name && file.path) {
- const paramsCommand = ['create', file.path, ...authCommand, ...endpoint]
- const executedCommand = executeCommand(defaultCommandProvisionTemplate, paramsCommand, getSpecificConfig('oneprovision_prepend_command'))
+ const paramsCommand = [
+ 'create',
+ file.path,
+ ...authCommand,
+ ...endpoint,
+ ]
+ const executedCommand = executeCommand(
+ defaultCommandProvisionTemplate,
+ paramsCommand,
+ getSpecificConfig('oneprovision_prepend_command')
+ )
res.locals.httpCode = httpResponse(internalServerError)
- if (executedCommand && executedCommand.success && executedCommand.data) {
+ if (
+ executedCommand &&
+ executedCommand.success &&
+ executedCommand.data
+ ) {
res.locals.httpCode = httpResponse(ok, executedCommand.data)
}
removeFile(file.path)
next()
+
return
}
}
} else {
const errors = []
if (valSchema && valSchema.errors) {
- valSchema.errors.forEach(error => {
+ valSchema.errors.forEach((error) => {
errors.push(error.stack.replace(/^instance./, ''))
})
rtn = httpResponse(internalServerError, '', errors.toString())
@@ -127,18 +166,36 @@ const createProvisionTemplate = (res = {}, next = () => undefined, params = {},
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const instantiateProvisionTemplate = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const instantiateProvisionTemplate = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.id && user && password) {
const authCommand = ['--user', user, '--password', password]
const endpoint = getEndpoint()
- const paramsCommand = ['instantiate', `${params.id}`.toLowerCase(), ...authCommand, ...endpoint]
- const executedCommand = executeCommand(defaultCommandProvisionTemplate, paramsCommand, getSpecificConfig('oneprovision_prepend_command'))
+ const paramsCommand = [
+ 'instantiate',
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ ]
+ const executedCommand = executeCommand(
+ defaultCommandProvisionTemplate,
+ paramsCommand,
+ getSpecificConfig('oneprovision_prepend_command')
+ )
try {
const response = executedCommand.success ? ok : internalServerError
- res.locals.httpCode = httpResponse(response, JSON.parse(executedCommand.data))
+ res.locals.httpCode = httpResponse(
+ response,
+ JSON.parse(executedCommand.data)
+ )
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
@@ -156,7 +213,12 @@ const instantiateProvisionTemplate = (res = {}, next = () => undefined, params =
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const updateProvisionTemplate = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const updateProvisionTemplate = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.resource && params.id && user && password) {
@@ -168,23 +230,42 @@ const updateProvisionTemplate = (res = {}, next = () => undefined, params = {},
if (valSchema.valid) {
const content = createYMLContent(resource)
if (content) {
- const file = createTemporalFile(`${global.paths.CPI}/${defaultFolderTmpProvision}`, 'yaml', content)
+ const file = createTemporalFile(
+ `${global.paths.CPI}/${defaultFolderTmpProvision}`,
+ 'yaml',
+ content
+ )
if (file && file.name && file.path) {
- const paramsCommand = ['update', params.id, file.path, ...authCommand, ...endpoint]
- const executedCommand = executeCommand(defaultCommandProvisionTemplate, paramsCommand, getSpecificConfig('oneprovision_prepend_command'))
+ const paramsCommand = [
+ 'update',
+ params.id,
+ file.path,
+ ...authCommand,
+ ...endpoint,
+ ]
+ const executedCommand = executeCommand(
+ defaultCommandProvisionTemplate,
+ paramsCommand,
+ getSpecificConfig('oneprovision_prepend_command')
+ )
res.locals.httpCode = httpResponse(internalServerError)
- if (executedCommand && executedCommand.success && executedCommand.data) {
+ if (
+ executedCommand &&
+ executedCommand.success &&
+ executedCommand.data
+ ) {
res.locals.httpCode = httpResponse(ok, executedCommand.data)
}
removeFile(file.path)
next()
+
return
}
}
} else {
const errors = []
if (valSchema && valSchema.errors) {
- valSchema.errors.forEach(error => {
+ valSchema.errors.forEach((error) => {
errors.push(error.stack.replace(/^instance./, ''))
})
rtn = httpResponse(internalServerError, '', errors.toString())
@@ -203,18 +284,36 @@ const updateProvisionTemplate = (res = {}, next = () => undefined, params = {},
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const deleteProvisionTemplate = (res = {}, next = () => undefined, params = {}, userData = {}) => {
+const deleteProvisionTemplate = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {}
+) => {
const { user, password } = userData
let rtn = httpInternalError
if (params && params.id && user && password) {
const authCommand = ['--user', user, '--password', password]
const endpoint = getEndpoint()
- const paramsCommand = ['delete', `${params.id}`.toLowerCase(), ...authCommand, ...endpoint]
- const executedCommand = executeCommand(defaultCommandProvisionTemplate, paramsCommand, getSpecificConfig('oneprovision_prepend_command'))
+ const paramsCommand = [
+ 'delete',
+ `${params.id}`.toLowerCase(),
+ ...authCommand,
+ ...endpoint,
+ ]
+ const executedCommand = executeCommand(
+ defaultCommandProvisionTemplate,
+ paramsCommand,
+ getSpecificConfig('oneprovision_prepend_command')
+ )
try {
const response = executedCommand.success ? ok : internalServerError
- res.locals.httpCode = httpResponse(response, JSON.parse(executedCommand.data))
+ res.locals.httpCode = httpResponse(
+ response,
+ JSON.parse(executedCommand.data)
+ )
next()
+
return
} catch (error) {
rtn = httpResponse(internalServerError, '', executedCommand.data)
@@ -229,6 +328,6 @@ const provisionTemplateFunctionsApi = {
createProvisionTemplate,
instantiateProvisionTemplate,
updateProvisionTemplate,
- deleteProvisionTemplate
+ deleteProvisionTemplate,
}
module.exports = provisionTemplateFunctionsApi
diff --git a/src/fireedge/src/server/routes/api/provision/provision_template.js b/src/fireedge/src/server/routes/api/provision/provision_template.js
index 9c6258734c..692b6bd253 100644
--- a/src/fireedge/src/server/routes/api/provision/provision_template.js
+++ b/src/fireedge/src/server/routes/api/provision/provision_template.js
@@ -20,7 +20,7 @@ const {
createProvisionTemplate,
instantiateProvisionTemplate,
updateProvisionTemplate,
- deleteProvisionTemplate
+ deleteProvisionTemplate,
} = require('./provision_template-functions')
const { httpMethod } = require('server/utils/constants/defaults')
@@ -31,44 +31,44 @@ const routes = {
list: {
action: getListProvisionTemplates,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
},
[POST]: {
create: {
action: createProvisionTemplate,
params: {
- resource: { from: fromData.postBody, front: true }
- }
+ resource: { from: fromData.postBody, front: true },
+ },
},
instantiate: {
action: instantiateProvisionTemplate,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
},
[PUT]: {
update: {
action: updateProvisionTemplate,
params: {
resource: { from: fromData.postBody, front: true },
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
},
[DELETE]: {
delete: {
action: deleteProvisionTemplate,
params: {
- id: { from: fromData.resource, name: 'id', front: true }
- }
- }
- }
+ id: { from: fromData.resource, name: 'id', front: true },
+ },
+ },
+ },
}
const provisionTemplateApi = {
- routes
+ routes,
}
module.exports = provisionTemplateApi
diff --git a/src/fireedge/src/server/routes/api/provision/schemas.js b/src/fireedge/src/server/routes/api/provision/schemas.js
index 93d06a5c1d..07585f3883 100644
--- a/src/fireedge/src/server/routes/api/provision/schemas.js
+++ b/src/fireedge/src/server/routes/api/provision/schemas.js
@@ -20,7 +20,7 @@ const provision = {
properties: {
name: {
type: 'string',
- required: true
+ required: true,
},
defaults: {
type: 'object',
@@ -30,29 +30,29 @@ const provision = {
type: 'object',
properties: {
driver: {
- type: 'string'
+ type: 'string',
},
packet_token: {
- type: 'string'
+ type: 'string',
},
packet_project: {
- type: 'string'
+ type: 'string',
},
facility: {
- type: 'string'
+ type: 'string',
},
plan: {
- type: 'string'
+ type: 'string',
},
os: {
- type: 'string'
- }
- }
+ type: 'string',
+ },
+ },
},
configuration: {
- type: 'object'
- }
- }
+ type: 'object',
+ },
+ },
},
hosts: {
type: 'array',
@@ -62,38 +62,38 @@ const provision = {
properties: {
reserved_cpu: {
type: 'integer',
- required: true
+ required: true,
},
im_mad: {
type: 'string',
enum: ['kvm', 'firecraker'],
- required: true
+ required: true,
},
vm_mad: {
type: 'string',
enum: ['kvm', 'firecraker'],
- required: true
+ required: true,
},
provision: {
type: 'object',
properties: {
hostname: {
type: 'string',
- required: true
+ required: true,
},
os: {
type: 'string',
- required: true
- }
+ required: true,
+ },
},
- required: true
- }
- }
- }
+ required: true,
+ },
+ },
+ },
},
clusters: {
type: 'array',
- required: true
+ required: true,
},
datastores: {
type: 'array',
@@ -103,18 +103,18 @@ const provision = {
properties: {
name: {
type: 'string',
- required: false
+ required: false,
},
type: {
type: 'string',
- required: false
+ required: false,
},
tm_mad: {
type: 'string',
- required: false
- }
- }
- }
+ required: false,
+ },
+ },
+ },
},
networks: {
type: 'array',
@@ -122,19 +122,19 @@ const provision = {
items: {
name: {
type: 'string',
- required: false
+ required: false,
},
vn_mad: {
type: 'string',
- required: false
+ required: false,
},
bridge: {
type: 'string',
- required: false
+ required: false,
},
description: {
type: 'string',
- required: false
+ required: false,
},
ar: {
type: 'array',
@@ -143,26 +143,26 @@ const provision = {
properties: {
ip: {
type: 'string',
- required: true
+ required: true,
},
size: {
type: 'integer',
- required: true
+ required: true,
},
type: {
type: 'string',
- required: true
- }
- }
+ required: true,
+ },
+ },
},
- required: false
- }
- }
- }
- }
+ required: false,
+ },
+ },
+ },
+ },
}
const schemas = {
- provision
+ provision,
}
module.exports = schemas
diff --git a/src/fireedge/src/server/routes/api/provision/string-routes.js b/src/fireedge/src/server/routes/api/provision/string-routes.js
index fa13dd1674..79f9ebb4fb 100644
--- a/src/fireedge/src/server/routes/api/provision/string-routes.js
+++ b/src/fireedge/src/server/routes/api/provision/string-routes.js
@@ -21,7 +21,7 @@ const PROVISION_TEMPLATE = 'provision-template'
const Actions = {
PROVIDER,
PROVISION,
- PROVISION_TEMPLATE
+ PROVISION_TEMPLATE,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/sunstone/index.js b/src/fireedge/src/server/routes/api/sunstone/index.js
index 56e39fc5d9..e26bc9c4e8 100644
--- a/src/fireedge/src/server/routes/api/sunstone/index.js
+++ b/src/fireedge/src/server/routes/api/sunstone/index.js
@@ -21,7 +21,7 @@ const { SUNSTONE } = require('./string-routes')
const functionRoutes = {
private: setApiRoutes(sunstoneRoutes, SUNSTONE),
- public: []
+ public: [],
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/sunstone/string-routes.js b/src/fireedge/src/server/routes/api/sunstone/string-routes.js
index e393b03bdd..25b2dad99e 100644
--- a/src/fireedge/src/server/routes/api/sunstone/string-routes.js
+++ b/src/fireedge/src/server/routes/api/sunstone/string-routes.js
@@ -17,7 +17,7 @@
const SUNSTONE = 'sunstone'
const Actions = {
- SUNSTONE
+ SUNSTONE,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/sunstone/sunstone-functions.js b/src/fireedge/src/server/routes/api/sunstone/sunstone-functions.js
index 9e42a9565f..59c414b0b7 100644
--- a/src/fireedge/src/server/routes/api/sunstone/sunstone-functions.js
+++ b/src/fireedge/src/server/routes/api/sunstone/sunstone-functions.js
@@ -20,12 +20,14 @@ const { defaultEmptyFunction } = require('server/utils/constants/defaults')
const { existsFile, httpResponse, getFiles } = require('server/utils/server')
const { sensitiveDataRemoverConfig } = require('server/utils/opennebula')
const { Actions: ActionsUser } = require('server/utils/constants/commands/user')
-const { Actions: ActionsGroup } = require('server/utils/constants/commands/group')
+const {
+ Actions: ActionsGroup,
+} = require('server/utils/constants/commands/group')
const {
ok,
internalServerError,
- notFound
+ notFound,
} = require('server/utils/constants/http-codes')
const sensitiveData = ['support_url', 'support_token']
@@ -39,7 +41,11 @@ const httpInternalError = httpResponse(internalServerError, '', '')
* @param {string} idGroup - id of group
* @param {Function} callback - run function when have group information
*/
-const getInfoGroup = (connect = defaultEmptyFunction, idGroup, callback = defaultEmptyFunction) => {
+const getInfoGroup = (
+ connect = defaultEmptyFunction,
+ idGroup,
+ callback = defaultEmptyFunction
+) => {
connect(
ActionsGroup.GROUP_INFO,
[parseInt(idGroup, 10), false],
@@ -71,9 +77,22 @@ const responseHttp = (res = {}, next = defaultEmptyFunction, httpCode) => {
* @param {object} userData - user of http request
* @param {Function} oneConnection - xmlrpc function
*/
-const getViews = (res = {}, next = () => undefined, params = {}, userData = {}, oneConnection = defaultEmptyFunction) => {
+const getViews = (
+ res = {},
+ next = () => undefined,
+ params = {},
+ userData = {},
+ oneConnection = defaultEmptyFunction
+) => {
const { user, password } = userData
- if (user && password && global && global.paths && global.paths.SUNSTONE_VIEWS && global.paths.SUNSTONE_PATH) {
+ if (
+ user &&
+ password &&
+ global &&
+ global.paths &&
+ global.paths.SUNSTONE_VIEWS &&
+ global.paths.SUNSTONE_PATH
+ ) {
const connect = oneConnection(user, password)
connect(
ActionsUser.USER_INFO,
@@ -87,34 +106,33 @@ const getViews = (res = {}, next = () => undefined, params = {}, userData = {},
if (vmgroupData && vmgroupData.GROUP && vmgroupData.GROUP.NAME) {
existsFile(
global.paths.SUNSTONE_VIEWS,
- filedata => {
+ (filedata) => {
const jsonFileData = parse(filedata) || {}
- if (jsonFileData && jsonFileData.groups && jsonFileData.default) {
- const views = jsonFileData.groups[vmgroupData.GROUP.NAME] || jsonFileData.default
+ if (
+ jsonFileData &&
+ jsonFileData.groups &&
+ jsonFileData.default
+ ) {
+ const views =
+ jsonFileData.groups[vmgroupData.GROUP.NAME] ||
+ jsonFileData.default
const rtn = {}
- views.forEach(view => {
+ views.forEach((view) => {
getFiles(
`${global.paths.SUNSTONE_PATH}${view}`
- ).forEach(viewPath => {
- existsFile(
- viewPath,
- (viewData = '') => {
- if (!rtn[view]) {
- rtn[view] = []
- }
- const jsonViewData = parse(viewData) || {}
- if (jsonViewData && jsonViewData.resource_name) {
- rtn[view].push(jsonViewData)
- }
+ ).forEach((viewPath) => {
+ existsFile(viewPath, (viewData = '') => {
+ if (!rtn[view]) {
+ rtn[view] = []
}
- )
+ const jsonViewData = parse(viewData) || {}
+ if (jsonViewData && jsonViewData.resource_name) {
+ rtn[view].push(jsonViewData)
+ }
+ })
})
})
- responseHttp(
- res,
- next,
- httpResponse(ok, rtn)
- )
+ responseHttp(res, next, httpResponse(ok, rtn))
}
},
() => {
@@ -145,30 +163,27 @@ const getViews = (res = {}, next = () => undefined, params = {}, userData = {},
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const getConfig = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const getConfig = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
let error
- const config = getSunstoneConfig(
- err => {
- error = err
- }
- )
+ const config = getSunstoneConfig((err) => {
+ error = err
+ })
responseHttp(
res,
next,
error
? httpResponse(notFound, error)
- : httpResponse(
- ok,
- sensitiveDataRemoverConfig(
- config,
- sensitiveData
- )
- )
+ : httpResponse(ok, sensitiveDataRemoverConfig(config, sensitiveData))
)
}
const sunstoneApi = {
getViews,
- getConfig
+ getConfig,
}
module.exports = sunstoneApi
diff --git a/src/fireedge/src/server/routes/api/sunstone/sunstone.js b/src/fireedge/src/server/routes/api/sunstone/sunstone.js
index e5072ed9b1..191866b053 100644
--- a/src/fireedge/src/server/routes/api/sunstone/sunstone.js
+++ b/src/fireedge/src/server/routes/api/sunstone/sunstone.js
@@ -15,27 +15,24 @@
* ------------------------------------------------------------------------- */
const { httpMethod } = require('server/utils/constants/defaults')
-const {
- getConfig,
- getViews
-} = require('./sunstone-functions')
+const { getConfig, getViews } = require('./sunstone-functions')
const { GET } = httpMethod
const routes = {
[GET]: {
views: {
action: getViews,
- params: {}
+ params: {},
},
config: {
action: getConfig,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
const sunstoneApi = {
- routes
+ routes,
}
module.exports = sunstoneApi
diff --git a/src/fireedge/src/server/routes/api/support/index.js b/src/fireedge/src/server/routes/api/support/index.js
index 1f041f5df1..bb5cb54a9f 100644
--- a/src/fireedge/src/server/routes/api/support/index.js
+++ b/src/fireedge/src/server/routes/api/support/index.js
@@ -20,7 +20,7 @@ const publicRoutes = []
const functionRoutes = {
private: privateRoutes,
- public: publicRoutes
+ public: publicRoutes,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/vcenter/command-flags.js b/src/fireedge/src/server/routes/api/vcenter/command-flags.js
index 5dc81a41ca..9d0d2796f9 100644
--- a/src/fireedge/src/server/routes/api/vcenter/command-flags.js
+++ b/src/fireedge/src/server/routes/api/vcenter/command-flags.js
@@ -23,7 +23,7 @@ const resources = {
DATASTORES,
TEMPLATES,
NETWORKS,
- IMAGES
+ IMAGES,
}
const questions = {
@@ -31,34 +31,40 @@ const questions = {
[TEMPLATES]: [
{
question: 'Type',
- flag: '--type'
- }, {
+ flag: '--type',
+ },
+ {
question: 'Folder',
- flag: '--folder'
- }, {
+ flag: '--folder',
+ },
+ {
question: 'Linked Clone',
- flag: '--linked-clone'
- }
+ flag: '--linked-clone',
+ },
],
[NETWORKS]: [
{
question: 'Size',
- flag: '--size'
- }, {
+ flag: '--size',
+ },
+ {
question: 'Type',
- flag: '--type'
- }, {
+ flag: '--type',
+ },
+ {
question: 'MAC',
- flag: '--mac'
- }, {
+ flag: '--mac',
+ },
+ {
question: 'Cluster(s) to import',
- flag: '--cluster-imports'
- }, {
+ flag: '--cluster-imports',
+ },
+ {
question: 'Unimported Cluster(s)',
- flag: '--cluster-unimported'
- }
+ flag: '--cluster-unimported',
+ },
],
- [IMAGES]: []
+ [IMAGES]: [],
}
module.exports = { resources, questions }
diff --git a/src/fireedge/src/server/routes/api/vcenter/functions.js b/src/fireedge/src/server/routes/api/vcenter/functions.js
index df76c26bbb..8874f9b1d9 100644
--- a/src/fireedge/src/server/routes/api/vcenter/functions.js
+++ b/src/fireedge/src/server/routes/api/vcenter/functions.js
@@ -16,16 +16,19 @@
const {
defaultEmptyFunction,
- defaultCommandVcenter
+ defaultCommandVcenter,
} = require('server/utils/constants/defaults')
const {
ok,
internalServerError,
- badRequest
+ badRequest,
} = require('server/utils/constants/http-codes')
const { httpResponse, executeCommand } = require('server/utils/server')
-const { consoleParseToString, consoleParseToJSON } = require('server/utils/opennebula')
+const {
+ consoleParseToString,
+ consoleParseToJSON,
+} = require('server/utils/opennebula')
const { resources } = require('./command-flags')
const { getSunstoneConfig } = require('server/utils/yml')
@@ -37,7 +40,7 @@ const regexExclude = [
/^Connecting to.*/gi,
/^Exploring vCenter.*/gi,
// eslint-disable-next-line no-control-regex
- /^\u001b\[.*?m\u001b\[.*?m# vCenter.*/gi
+ /^\u001b\[.*?m\u001b\[.*?m# vCenter.*/gi,
]
const validObjects = Object.values(resources)
@@ -49,28 +52,29 @@ const validObjects = Object.values(resources)
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const importVcenter = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const importVcenter = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
let rtn = httpBadRequest
// check params
- if (params && params.vobject && validObjects.includes(params.vobject) && params.host) {
+ if (
+ params &&
+ params.vobject &&
+ validObjects.includes(params.vobject) &&
+ params.host
+ ) {
const vobject = `${params.vobject}`.toLowerCase()
- let paramsCommand = [
- params.answers ? 'import' : 'import_defaults'
- ]
+ let paramsCommand = [params.answers ? 'import' : 'import_defaults']
if (params.id) {
- paramsCommand.push(
- `${params.id}`
- )
+ paramsCommand.push(`${params.id}`)
}
- let vobjectAndHost = [
- '-o',
- `${vobject}`,
- '-h',
- `${params.host}`
- ]
+ let vobjectAndHost = ['-o', `${vobject}`, '-h', `${params.host}`]
if (vobject === resources.IMAGES && params.datastore) {
const datastoreParameter = ['-d', params.datastore]
@@ -83,14 +87,15 @@ const importVcenter = (res = {}, next = defaultEmptyFunction, params = {}, userD
} */
paramsCommand = [...paramsCommand, ...vobjectAndHost]
- const executedCommand = executeCommand(defaultCommandVcenter, paramsCommand, prependCommand)
+ const executedCommand = executeCommand(
+ defaultCommandVcenter,
+ paramsCommand,
+ prependCommand
+ )
const response = executedCommand.success ? ok : internalServerError
let message = ''
if (executedCommand.data) {
- message = consoleParseToString(
- executedCommand.data,
- regexExclude
- )
+ message = consoleParseToString(executedCommand.data, regexExclude)
}
rtn = httpResponse(response, message)
}
@@ -106,9 +111,19 @@ const importVcenter = (res = {}, next = defaultEmptyFunction, params = {}, userD
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const list = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const list = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
let rtn = httpBadRequest
- if (params && params.vobject && validObjects.includes(params.vobject) && params.host) {
+ if (
+ params &&
+ params.vobject &&
+ validObjects.includes(params.vobject) &&
+ params.host
+ ) {
const vobject = `${params.vobject}`.toLowerCase()
let paramsCommand = [
'list',
@@ -116,22 +131,23 @@ const list = (res = {}, next = defaultEmptyFunction, params = {}, userData = {})
`${vobject}`,
'-h',
`${params.host}`,
- '--csv'
+ '--csv',
]
if (vobject === resources.IMAGES && params.datastore) {
const newParameters = ['-d', params.datastore]
paramsCommand = [...paramsCommand, ...newParameters]
}
- const executedCommand = executeCommand(defaultCommandVcenter, paramsCommand, prependCommand)
+ const executedCommand = executeCommand(
+ defaultCommandVcenter,
+ paramsCommand,
+ prependCommand
+ )
const response = executedCommand.success ? ok : internalServerError
let message = ''
if (executedCommand.data) {
message = consoleParseToJSON(
- consoleParseToString(
- executedCommand.data,
- regexExclude
- ),
+ consoleParseToString(executedCommand.data, regexExclude),
/^IMID,.*/gi
)
}
@@ -149,9 +165,19 @@ const list = (res = {}, next = defaultEmptyFunction, params = {}, userData = {})
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const listAll = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const listAll = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
let rtn = httpBadRequest
- if (params && params.vobject && validObjects.includes(params.vobject) && params.host) {
+ if (
+ params &&
+ params.vobject &&
+ validObjects.includes(params.vobject) &&
+ params.host
+ ) {
const vobject = `${params.vobject}`.toLowerCase()
let paramsCommand = [
'list_all',
@@ -159,22 +185,23 @@ const listAll = (res = {}, next = defaultEmptyFunction, params = {}, userData =
`${vobject}`,
'-h',
`${params.host}`,
- '--csv'
+ '--csv',
]
if (vobject === resources.IMAGES && params.datastore) {
const newParameters = ['-d', params.datastore]
paramsCommand = [...paramsCommand, ...newParameters]
}
- const executedCommand = executeCommand(defaultCommandVcenter, paramsCommand, prependCommand)
+ const executedCommand = executeCommand(
+ defaultCommandVcenter,
+ paramsCommand,
+ prependCommand
+ )
const response = executedCommand.success ? ok : internalServerError
let message = ''
if (executedCommand.data) {
message = consoleParseToJSON(
- consoleParseToString(
- executedCommand.data,
- regexExclude
- ),
+ consoleParseToString(executedCommand.data, regexExclude),
/^IMID,.*/gi
)
}
@@ -192,22 +219,25 @@ const listAll = (res = {}, next = defaultEmptyFunction, params = {}, userData =
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const cleartags = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const cleartags = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
let rtn = httpBadRequest
// check params
if (params && params.id) {
- const paramsCommand = [
- 'cleartags',
- `${params.id}`
- ]
- const executedCommand = executeCommand(defaultCommandVcenter, paramsCommand, prependCommand)
+ const paramsCommand = ['cleartags', `${params.id}`]
+ const executedCommand = executeCommand(
+ defaultCommandVcenter,
+ paramsCommand,
+ prependCommand
+ )
const response = executedCommand.success ? ok : internalServerError
let message = ''
if (executedCommand.data) {
- message = consoleParseToString(
- executedCommand.data,
- regexExclude
- )
+ message = consoleParseToString(executedCommand.data, regexExclude)
}
rtn = httpResponse(response, message)
}
@@ -223,7 +253,12 @@ const cleartags = (res = {}, next = defaultEmptyFunction, params = {}, userData
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const hosts = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const hosts = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
let rtn = httpBadRequest
// check params
if (params && params.vcenter && params.user && params.pass) {
@@ -235,16 +270,17 @@ const hosts = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}
`${params.user}`,
'--vpass',
`${params.pass}`,
- '--use-defaults'
+ '--use-defaults',
]
- const executedCommand = executeCommand(defaultCommandVcenter, paramsCommand, prependCommand)
+ const executedCommand = executeCommand(
+ defaultCommandVcenter,
+ paramsCommand,
+ prependCommand
+ )
const response = executedCommand.success ? ok : internalServerError
let message = ''
if (executedCommand.data) {
- message = consoleParseToString(
- executedCommand.data,
- regexExclude
- )
+ message = consoleParseToString(executedCommand.data, regexExclude)
}
rtn = httpResponse(response, message)
}
@@ -257,6 +293,6 @@ const functionRoutes = {
list,
listAll,
cleartags,
- hosts
+ hosts,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/vcenter/index.js b/src/fireedge/src/server/routes/api/vcenter/index.js
index 85e2371429..857363d544 100644
--- a/src/fireedge/src/server/routes/api/vcenter/index.js
+++ b/src/fireedge/src/server/routes/api/vcenter/index.js
@@ -20,7 +20,7 @@ const { VCENTER } = require('./string-routes')
const functionRoutes = {
private: setApiRoutes(vcenterRoutes, VCENTER),
- public: []
+ public: [],
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/vcenter/string-routes.js b/src/fireedge/src/server/routes/api/vcenter/string-routes.js
index 2596a74e55..29ea6b3d4a 100644
--- a/src/fireedge/src/server/routes/api/vcenter/string-routes.js
+++ b/src/fireedge/src/server/routes/api/vcenter/string-routes.js
@@ -17,7 +17,7 @@
const VCENTER = 'vcenter'
const Actions = {
- VCENTER
+ VCENTER,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/vcenter/vcenter.js b/src/fireedge/src/server/routes/api/vcenter/vcenter.js
index 43a1388d03..07067dd6f5 100644
--- a/src/fireedge/src/server/routes/api/vcenter/vcenter.js
+++ b/src/fireedge/src/server/routes/api/vcenter/vcenter.js
@@ -14,8 +14,17 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
-const { importVcenter, list, listAll, cleartags, hosts } = require('./functions')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
+const {
+ importVcenter,
+ list,
+ listAll,
+ cleartags,
+ hosts,
+} = require('./functions')
const { POST, GET } = httpMethod
const routes = {
@@ -25,52 +34,52 @@ const routes = {
params: {
vobject: {
from: fromData.resource,
- name: 'id'
+ name: 'id',
},
host: {
from: fromData.postBody,
- name: 'host'
+ name: 'host',
},
datastore: {
from: fromData.postBody,
- name: 'datastore'
+ name: 'datastore',
},
id: {
from: fromData.postBody,
- name: 'id'
+ name: 'id',
},
answers: {
from: fromData.postBody,
- name: 'answers'
- }
- }
+ name: 'answers',
+ },
+ },
},
cleartags: {
action: cleartags,
params: {
id: {
from: fromData.resource,
- name: 'id'
- }
- }
+ name: 'id',
+ },
+ },
},
hosts: {
action: hosts,
params: {
vcenter: {
from: fromData.postBody,
- name: 'vcenter'
+ name: 'vcenter',
},
user: {
from: fromData.postBody,
- name: 'user'
+ name: 'user',
},
pass: {
from: fromData.postBody,
- name: 'pass'
- }
- }
- }
+ name: 'pass',
+ },
+ },
+ },
},
[GET]: {
list: {
@@ -78,39 +87,39 @@ const routes = {
params: {
vobject: {
from: fromData.resource,
- name: 'id'
+ name: 'id',
},
host: {
from: fromData.query,
- name: 'host'
+ name: 'host',
},
datastore: {
from: fromData.query,
- name: 'datastore'
- }
- }
+ name: 'datastore',
+ },
+ },
},
listall: {
action: listAll,
params: {
vobject: {
from: fromData.resource,
- name: 'id'
+ name: 'id',
},
host: {
from: fromData.query,
- name: 'host'
+ name: 'host',
},
datastore: {
from: fromData.query,
- name: 'datastore'
- }
- }
- }
- }
+ name: 'datastore',
+ },
+ },
+ },
+ },
}
const authApi = {
- routes
+ routes,
}
module.exports = authApi
diff --git a/src/fireedge/src/server/routes/api/vm/functions.js b/src/fireedge/src/server/routes/api/vm/functions.js
index c9d1a4ed24..bfffc62e90 100644
--- a/src/fireedge/src/server/routes/api/vm/functions.js
+++ b/src/fireedge/src/server/routes/api/vm/functions.js
@@ -16,13 +16,13 @@
const {
defaultEmptyFunction,
- defaultCommandVM
+ defaultCommandVM,
} = require('server/utils/constants/defaults')
const {
ok,
internalServerError,
- badRequest
+ badRequest,
} = require('server/utils/constants/http-codes')
const { httpResponse, executeCommand } = require('server/utils/server')
@@ -41,7 +41,12 @@ const regexpSplitLine = /\r|\n/
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const saveAsTemplate = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const saveAsTemplate = (
+ res = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
let rtn = httpBadRequest
const { id, name, persistent } = params
if (id && name) {
@@ -52,7 +57,11 @@ const saveAsTemplate = (res = {}, next = defaultEmptyFunction, params = {}, user
paramsCommand.push('--persistent')
}
- const executedCommand = executeCommand(defaultCommandVM, paramsCommand, prependCommand)
+ const executedCommand = executeCommand(
+ defaultCommandVM,
+ paramsCommand,
+ prependCommand
+ )
const response = executedCommand.success ? ok : internalServerError
@@ -66,6 +75,6 @@ const saveAsTemplate = (res = {}, next = defaultEmptyFunction, params = {}, user
}
const functionRoutes = {
- saveAsTemplate
+ saveAsTemplate,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/vm/index.js b/src/fireedge/src/server/routes/api/vm/index.js
index c9d936650f..37db8f1d73 100644
--- a/src/fireedge/src/server/routes/api/vm/index.js
+++ b/src/fireedge/src/server/routes/api/vm/index.js
@@ -20,7 +20,7 @@ const { VM } = require('./string-routes')
const functionRoutes = {
private: setApiRoutes(vmRoutes, VM),
- public: []
+ public: [],
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/vm/string-routes.js b/src/fireedge/src/server/routes/api/vm/string-routes.js
index 44fc057baf..acce84223f 100644
--- a/src/fireedge/src/server/routes/api/vm/string-routes.js
+++ b/src/fireedge/src/server/routes/api/vm/string-routes.js
@@ -17,7 +17,7 @@
const VM = 'vm'
const Actions = {
- VM
+ VM,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/vm/vm.js b/src/fireedge/src/server/routes/api/vm/vm.js
index a81d652ecf..adfc317d7a 100644
--- a/src/fireedge/src/server/routes/api/vm/vm.js
+++ b/src/fireedge/src/server/routes/api/vm/vm.js
@@ -14,7 +14,10 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
const { saveAsTemplate } = require('./functions')
const { POST } = httpMethod
@@ -25,22 +28,22 @@ const routes = {
params: {
id: {
from: fromData.resource,
- name: 'id'
+ name: 'id',
},
name: {
from: fromData.postBody,
- name: 'name'
+ name: 'name',
},
persistent: {
from: fromData.postBody,
- name: 'persistent'
- }
- }
- }
- }
+ name: 'persistent',
+ },
+ },
+ },
+ },
}
const authApi = {
- routes
+ routes,
}
module.exports = authApi
diff --git a/src/fireedge/src/server/routes/api/zendesk/functions.js b/src/fireedge/src/server/routes/api/zendesk/functions.js
index 0cb1d78ac7..6ef576e3d4 100644
--- a/src/fireedge/src/server/routes/api/zendesk/functions.js
+++ b/src/fireedge/src/server/routes/api/zendesk/functions.js
@@ -37,12 +37,13 @@ const getSession = (username = '', token = '') => {
return curr.token && curr.token === token
}
)
+
return session
}
}
const functions = {
- getSession
+ getSession,
}
module.exports = functions
diff --git a/src/fireedge/src/server/routes/api/zendesk/index.js b/src/fireedge/src/server/routes/api/zendesk/index.js
index 42bf66adfd..3d9c7c0a67 100644
--- a/src/fireedge/src/server/routes/api/zendesk/index.js
+++ b/src/fireedge/src/server/routes/api/zendesk/index.js
@@ -20,7 +20,7 @@ const { ZENDESK } = require('./string-routes')
const functionRoutes = {
private: setApiRoutes(zendeskRoutes, ZENDESK),
- public: []
+ public: [],
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/zendesk/string-routes.js b/src/fireedge/src/server/routes/api/zendesk/string-routes.js
index 5b81ffe225..17ff2f4bca 100644
--- a/src/fireedge/src/server/routes/api/zendesk/string-routes.js
+++ b/src/fireedge/src/server/routes/api/zendesk/string-routes.js
@@ -17,7 +17,7 @@
const ZENDESK = 'zendesk'
const Actions = {
- ZENDESK
+ ZENDESK,
}
module.exports = Actions
diff --git a/src/fireedge/src/server/routes/api/zendesk/zendesk-functions.js b/src/fireedge/src/server/routes/api/zendesk/zendesk-functions.js
index 623057ba35..3f9f1837f9 100644
--- a/src/fireedge/src/server/routes/api/zendesk/zendesk-functions.js
+++ b/src/fireedge/src/server/routes/api/zendesk/zendesk-functions.js
@@ -17,7 +17,11 @@
const { env } = require('process')
const zendesk = require('node-zendesk')
const { getSunstoneConfig } = require('server/utils/yml')
-const { defaultEmptyFunction, defaultSeverities, defaultWebpackMode } = require('server/utils/constants/defaults')
+const {
+ defaultEmptyFunction,
+ defaultSeverities,
+ defaultWebpackMode,
+} = require('server/utils/constants/defaults')
const { httpResponse } = require('server/utils/server')
const { getSession } = require('./functions')
@@ -25,34 +29,33 @@ const {
ok,
internalServerError,
badRequest,
- unauthorized
+ unauthorized,
} = require('server/utils/constants/http-codes')
-const formatCreate = (
- {
- subject = '',
- body = '',
- version = '',
- severity = ''
- }
-) => {
+const formatCreate = ({
+ subject = '',
+ body = '',
+ version = '',
+ severity = '',
+}) => {
let rtn
if (subject && body && version && severity) {
rtn = {
request: {
subject,
comment: {
- body
+ body,
},
custom_fields: [
{ id: 391130, value: version }, // version
- { id: 391197, value: severity } // severity
+ { id: 391197, value: severity }, // severity
],
can_be_solved_by_me: false,
- tags: [severity]
- }
+ tags: [severity],
+ },
}
}
+
return rtn
}
@@ -63,17 +66,18 @@ const formatComment = ({ body = '', solved = '', attachments = [] }) => {
request: {
comment: {
body,
- public: true
- }
- }
+ public: true,
+ },
+ },
}
if (solved) {
rtn.solved = 'true'
}
if (attachments && Array.isArray(attachments) && attachments.length > 0) {
- rtn.request.comment.uploads = attachments.filter(att => att)
+ rtn.request.comment.uploads = attachments.filter((att) => att)
}
}
+
return rtn
}
@@ -82,15 +86,14 @@ const parseBufferError = (err) => {
let errorJson = {}
if (err && err.result) {
try {
- errorJson = JSON.parse(
- err.result.toString()
- )
+ errorJson = JSON.parse(err.result.toString())
} catch {}
if (errorJson && errorJson.error) {
rtn = errorJson.error.title ? `${errorJson.error.title}: ` : ''
rtn += errorJson.error.message ? errorJson.error.message : ''
}
}
+
return rtn
}
@@ -104,7 +107,12 @@ const httpBadRequest = httpResponse(badRequest, '', '')
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const login = (response = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const login = (
+ response = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
const sunstoneConfig = getSunstoneConfig()
const remoteUri = sunstoneConfig.support_url || ''
@@ -121,7 +129,7 @@ const login = (response = {}, next = defaultEmptyFunction, params = {}, userData
username: params.user,
password: params.pass,
remoteUri,
- debug: env.NODE_ENV === defaultWebpackMode
+ debug: env.NODE_ENV === defaultWebpackMode,
}
const session = getSession(userData.user, userData.password)
/** ZENDESK AUTH */
@@ -139,7 +147,7 @@ const login = (response = {}, next = defaultEmptyFunction, params = {}, userData
if (result && result.authenticity_token) {
const zendeskUserData = {
...zendeskData,
- id: result.id
+ id: result.id,
}
session.zendesk = zendeskUserData
}
@@ -161,12 +169,13 @@ const login = (response = {}, next = defaultEmptyFunction, params = {}, userData
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const list = (response = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
- if (
- userData &&
- userData.user &&
- userData.password
- ) {
+const list = (
+ response = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
+ if (userData && userData.user && userData.password) {
const session = getSession(userData.user, userData.password)
if (session.zendesk && session.zendesk.id) {
/** LIST ZENDESK */
@@ -184,7 +193,7 @@ const list = (response = {}, next = defaultEmptyFunction, params = {}, userData
let pendings = 0
let opens = 0
const tickets = Array.isArray(result) ? result : result
- tickets.forEach(ticket => {
+ tickets.forEach((ticket) => {
if (ticket && ticket.status) {
switch (ticket.status) {
case 'pending':
@@ -199,14 +208,11 @@ const list = (response = {}, next = defaultEmptyFunction, params = {}, userData
data = {
tickets: result,
pendings,
- opens
+ opens,
}
}
- response.locals.httpCode = httpResponse(
- method,
- data
- )
+ response.locals.httpCode = httpResponse(method, data)
next()
}
)
@@ -228,34 +234,31 @@ const list = (response = {}, next = defaultEmptyFunction, params = {}, userData
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const comments = (response = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
- if (
- params.id &&
- userData &&
- userData.user &&
- userData.password
- ) {
+const comments = (
+ response = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
+ if (params.id && userData && userData.user && userData.password) {
const session = getSession(userData.user, userData.password)
if (session.zendesk) {
/** GET COMMENTS ON TICKET ZENDESK */
const zendeskClient = zendesk.createClient(session.zendesk)
- zendeskClient.requests.listComments(
- params.id,
- (err, req, result) => {
- let method = ok
- let data = ''
+ zendeskClient.requests.listComments(params.id, (err, req, result) => {
+ let method = ok
+ let data = ''
- if (err) {
- method = internalServerError
- data = parseBufferError(err)
- } else if (result) {
- data = result
- }
-
- response.locals.httpCode = httpResponse(method, data)
- next()
+ if (err) {
+ method = internalServerError
+ data = parseBufferError(err)
+ } else if (result) {
+ data = result
}
- )
+
+ response.locals.httpCode = httpResponse(method, data)
+ next()
+ })
} else {
response.locals.httpCode = httpResponse(unauthorized)
next()
@@ -274,7 +277,12 @@ const comments = (response = {}, next = defaultEmptyFunction, params = {}, userD
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const create = (response = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const create = (
+ response = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
if (
params &&
params.subject &&
@@ -291,21 +299,18 @@ const create = (response = {}, next = defaultEmptyFunction, params = {}, userDat
/** CREATE TICKET ZENDESK */
const zendeskClient = zendesk.createClient(session.zendesk)
const ticket = formatCreate(params)
- zendeskClient.requests.create(
- ticket,
- (err, req, result) => {
- let method = ok
- let data = ''
- if (err) {
- method = internalServerError
- data = parseBufferError(err)
- } else if (result) {
- data = result
- }
- response.locals.httpCode = httpResponse(method, data)
- next()
+ zendeskClient.requests.create(ticket, (err, req, result) => {
+ let method = ok
+ let data = ''
+ if (err) {
+ method = internalServerError
+ data = parseBufferError(err)
+ } else if (result) {
+ data = result
}
- )
+ response.locals.httpCode = httpResponse(method, data)
+ next()
+ })
} else {
response.locals.httpCode = httpResponse(unauthorized)
next()
@@ -324,7 +329,12 @@ const create = (response = {}, next = defaultEmptyFunction, params = {}, userDat
* @param {object} params - params of http request
* @param {object} userData - user of http request
*/
-const update = (response = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
+const update = (
+ response = {},
+ next = defaultEmptyFunction,
+ params = {},
+ userData = {}
+) => {
if (
params.id &&
params.body &&
@@ -339,44 +349,49 @@ const update = (response = {}, next = defaultEmptyFunction, params = {}, userDat
const sendRequest = (params = {}) => {
/** UPDATE TICKET ZENDESK */
const ticket = formatComment(params)
- zendeskClient.requests.update(
- params.id,
- ticket,
- (err, req, result) => {
- let method = ok
- let data = ''
+ zendeskClient.requests.update(params.id, ticket, (err, req, result) => {
+ let method = ok
+ let data = ''
- if (err) {
- method = internalServerError
- data = parseBufferError(err)
- } else if (result) {
- data = result
- }
- response.locals.httpCode = httpResponse(method, data)
- next()
+ if (err) {
+ method = internalServerError
+ data = parseBufferError(err)
+ } else if (result) {
+ data = result
}
- )
+ response.locals.httpCode = httpResponse(method, data)
+ next()
+ })
}
/** UPLOAD FILES */
let attachments
- if (params && params.attachments && zendeskClient.attachments && typeof zendeskClient.attachments.upload === 'function') {
+ if (
+ params &&
+ params.attachments &&
+ zendeskClient.attachments &&
+ typeof zendeskClient.attachments.upload === 'function'
+ ) {
params.attachments.forEach((att = {}) => {
if (att && att.originalname && att.path) {
zendeskClient.attachments.upload(
att.path,
{
- filename: att.originalname
+ filename: att.originalname,
},
(err, req, result) => {
- const token = (result && result.upload && result.upload.token) || ''
+ const token =
+ (result && result.upload && result.upload.token) || ''
if (attachments) {
attachments.push(token)
} else {
attachments = [token]
}
if (!err && token) {
- if (attachments && attachments.length === params.attachments.length) {
+ if (
+ attachments &&
+ attachments.length === params.attachments.length
+ ) {
sendRequest({ ...params, attachments })
}
}
@@ -402,6 +417,6 @@ const functionRoutes = {
list,
comments,
create,
- update
+ update,
}
module.exports = functionRoutes
diff --git a/src/fireedge/src/server/routes/api/zendesk/zendesk.js b/src/fireedge/src/server/routes/api/zendesk/zendesk.js
index b93dc46510..adcf160a67 100644
--- a/src/fireedge/src/server/routes/api/zendesk/zendesk.js
+++ b/src/fireedge/src/server/routes/api/zendesk/zendesk.js
@@ -14,7 +14,10 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const { httpMethod, from: fromData } = require('server/utils/constants/defaults')
+const {
+ httpMethod,
+ from: fromData,
+} = require('server/utils/constants/defaults')
const { login, list, comments, create, update } = require('./zendesk-functions')
const { POST, GET, PUT } = httpMethod
@@ -25,35 +28,35 @@ const routes = {
params: {
user: {
from: fromData.postBody,
- name: 'user'
+ name: 'user',
},
pass: {
from: fromData.postBody,
- name: 'pass'
- }
- }
+ name: 'pass',
+ },
+ },
},
create: {
action: create,
params: {
subject: {
from: fromData.postBody,
- name: 'subject'
+ name: 'subject',
},
body: {
from: fromData.postBody,
- name: 'body'
+ name: 'body',
},
version: {
from: fromData.postBody,
- name: 'version'
+ name: 'version',
},
severity: {
from: fromData.postBody,
- name: 'severity'
- }
- }
- }
+ name: 'severity',
+ },
+ },
+ },
},
[PUT]: {
update: {
@@ -61,41 +64,41 @@ const routes = {
params: {
id: {
from: fromData.resource,
- name: 'id'
+ name: 'id',
},
body: {
from: fromData.postBody,
- name: 'body'
+ name: 'body',
},
solved: {
from: fromData.postBody,
- name: 'solved'
+ name: 'solved',
},
attachments: {
from: 'files',
- name: 'attachments'
- }
- }
- }
+ name: 'attachments',
+ },
+ },
+ },
},
[GET]: {
list: {
action: list,
- params: {}
+ params: {},
},
comments: {
action: comments,
params: {
id: {
from: fromData.resource,
- name: 'id'
- }
- }
- }
- }
+ name: 'id',
+ },
+ },
+ },
+ },
}
const authApi = {
- routes
+ routes,
}
module.exports = authApi
diff --git a/src/fireedge/src/server/routes/entrypoints/Api.js b/src/fireedge/src/server/routes/entrypoints/Api.js
index c8c0fcea02..2dddbef2da 100644
--- a/src/fireedge/src/server/routes/entrypoints/Api.js
+++ b/src/fireedge/src/server/routes/entrypoints/Api.js
@@ -31,7 +31,7 @@ const {
responseOpennebula,
httpResponse,
getDataZone,
- fillResourceforHookConnection
+ fillResourceforHookConnection,
} = require('../../utils')
const { writeInLogger } = require('../../utils/logger')
@@ -45,7 +45,7 @@ const {
getQueriesState,
getIdUserOpennebula,
getUserOpennebula,
- getPassOpennebula
+ getPassOpennebula,
} = require('./middlewares')
const {
@@ -54,7 +54,7 @@ const {
httpMethod: httpMethods,
from: fromData,
defaultOpennebulaZones,
- defaultWebpackMode
+ defaultWebpackMode,
} = defaults
const router = express.Router()
@@ -104,19 +104,21 @@ router.all(
* @param {string} password - opennebula pass
* @returns {Function} opennebula executer calls to XMLRPC
*/
- const connectOpennebula = (
- user,
- password
- ) => opennebulaConnect(user, password, rpc)
+ const connectOpennebula = (user, password) =>
+ opennebulaConnect(user, password, rpc)
const { resource } = req.params
- const routeFunction = checkIfIsARouteFunction(resource, httpMethod, !!userId.length)
+ const routeFunction = checkIfIsARouteFunction(
+ resource,
+ httpMethod,
+ !!userId.length
+ )
res.locals.httpCode = httpResponse(methodNotAllowed)
const dataSources = {
[fromData.resource]: getParamsState(),
[fromData.query]: req.query,
- [fromData.postBody]: req.body
+ [fromData.postBody]: req.body,
}
if (routeFunction) {
@@ -130,14 +132,11 @@ router.all(
)
req.serverDataSource = dataSources
if (valRouteFunction) {
- valRouteFunction(
- req,
- res,
- next,
- connectOpennebula,
- userId,
- { id: userId, user, password }
- )
+ valRouteFunction(req, res, next, connectOpennebula, userId, {
+ id: userId,
+ user,
+ password,
+ })
} else {
next()
}
@@ -186,7 +185,7 @@ router.all(
*
* @param {object} code - http code
*/
- const updaterResponse = code => {
+ const updaterResponse = (code) => {
if ('id' in code && 'message' in code) {
res.locals.httpCode = code
}
@@ -211,16 +210,14 @@ router.all(
writeInLogger([command, JSON.stringify(value)], 'worker: %s : %s')
responseOpennebula(updaterResponse, err, value, response, next)
}
- worker.postMessage(
- {
- globalState: (global && global.paths) || {},
- user,
- password,
- rpc,
- command,
- paramsCommand
- }
- )
+ worker.postMessage({
+ globalState: (global && global.paths) || {},
+ user,
+ password,
+ rpc,
+ command,
+ paramsCommand,
+ })
} else {
next()
}
diff --git a/src/fireedge/src/server/routes/entrypoints/App.js b/src/fireedge/src/server/routes/entrypoints/App.js
index c1b631f8ff..cae0d2b8b1 100644
--- a/src/fireedge/src/server/routes/entrypoints/App.js
+++ b/src/fireedge/src/server/routes/entrypoints/App.js
@@ -23,7 +23,9 @@ const { ServerStyleSheets } = require('@mui/styles')
const rootReducer = require('client/store/reducers')
const { getFireedgeConfig } = require('server/utils/yml')
const {
- availableLanguages, defaultWebpackMode, defaultApps
+ availableLanguages,
+ defaultWebpackMode,
+ defaultApps,
} = require('server/utils/constants/defaults')
const { APP_URL, STATIC_FILES_URL } = require('client/constants')
const { upperCaseFirst } = require('client/utils')
@@ -33,10 +35,10 @@ const appConfig = getFireedgeConfig()
const langs = appConfig.langs || availableLanguages
const scriptLanguages = []
const languages = Object.keys(langs)
-languages.map(language =>
+languages.map((language) =>
scriptLanguages.push({
key: language,
- value: `${langs[language]}`
+ value: `${langs[language]}`,
})
)
@@ -52,11 +54,16 @@ router.get('*', (req, res) => {
let storeRender = ''
// production
- if (env && (!env.NODE_ENV || (env.NODE_ENV && env.NODE_ENV !== defaultWebpackMode))) {
+ if (
+ env &&
+ (!env.NODE_ENV || (env.NODE_ENV && env.NODE_ENV !== defaultWebpackMode))
+ ) {
const apps = Object.keys(defaultApps)
- const parseUrl = req.url.split(/\//gi).filter(sub => sub && sub.length > 0)
+ const parseUrl = req.url
+ .split(/\//gi)
+ .filter((sub) => sub && sub.length > 0)
- parseUrl.forEach(element => {
+ parseUrl.forEach((element) => {
if (element && apps.includes(element)) {
app = element
title = element
@@ -65,18 +72,17 @@ router.get('*', (req, res) => {
const App = require(`../../../client/apps/${app}/index.js`).default
const sheets = new ServerStyleSheets()
- const composeEnhancer = (root && root.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose
+ const composeEnhancer =
+ (root && root.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose
// SSR redux store
store = createStore(rootReducer, composeEnhancer(applyMiddleware(thunk)))
- storeRender = ``
+ storeRender = ``
component = renderToString(
- sheets.collect(
-
- )
+ sheets.collect()
)
css = ``
diff --git a/src/fireedge/src/server/routes/entrypoints/index.js b/src/fireedge/src/server/routes/entrypoints/index.js
index 84a4b4cc32..6b3a81a10a 100644
--- a/src/fireedge/src/server/routes/entrypoints/index.js
+++ b/src/fireedge/src/server/routes/entrypoints/index.js
@@ -21,5 +21,5 @@ const entrypointApp = require('./App')
module.exports = {
entrypoint404,
entrypointApi,
- entrypointApp
+ entrypointApp,
}
diff --git a/src/fireedge/src/server/routes/entrypoints/middlewares/api/index.js b/src/fireedge/src/server/routes/entrypoints/middlewares/api/index.js
index 0cd6e93341..a10eeedd8a 100644
--- a/src/fireedge/src/server/routes/entrypoints/middlewares/api/index.js
+++ b/src/fireedge/src/server/routes/entrypoints/middlewares/api/index.js
@@ -20,14 +20,14 @@ const { global } = require('window-or-global')
const {
private: authenticated,
- public: nonAuthenticated
+ public: nonAuthenticated,
} = require('../../../api')
const { httpCodes, params, defaults } = require('server/utils/constants')
const {
validateAuth,
getAllowedQueryParams,
createParamsState,
- createQueriesState
+ createQueriesState,
} = require('server/utils')
const { defaultWebpackMode } = defaults
@@ -83,17 +83,19 @@ const getPassOpennebula = () => passOpennebula
*/
const userValidation = (user = '', token = '') => {
let rtn = false
- if (user &&
+ if (
+ user &&
token &&
global &&
global.users &&
global.users[user] &&
global.users[user].tokens &&
Array.isArray(global.users[user].tokens) &&
- global.users[user].tokens.some(x => x && x.token === token)
+ global.users[user].tokens.some((x) => x && x.token === token)
) {
rtn = true
}
+
return rtn
}
@@ -118,7 +120,7 @@ const validateResourceAndSession = (req, res, next) => {
* @param {object} rtnCommand - command
* @returns {object} command
*/
- const finderCommand = rtnCommand =>
+ const finderCommand = (rtnCommand) =>
rtnCommand && rtnCommand.endpoint && rtnCommand.endpoint === resource
if (authenticated.some(finderCommand)) {
const session = validateAuth(req)
@@ -128,26 +130,30 @@ const validateResourceAndSession = (req, res, next) => {
passOpennebula = session.jti
if (env && (!env.NODE_ENV || env.NODE_ENV !== defaultWebpackMode)) {
/*********************************************************
- * Validate user in production mode
- *********************************************************/
+ * Validate user in production mode
+ *********************************************************/
if (userValidation(userOpennebula, passOpennebula)) {
next()
+
return
}
} else {
/*********************************************************
- * Validate user in development mode
- *********************************************************/
+ * Validate user in development mode
+ *********************************************************/
if (global && !global.users) {
global.users = {}
}
if (!global.users[userOpennebula]) {
- global.users[userOpennebula] = { tokens: [{ token: passOpennebula, time: session.exp }] }
+ global.users[userOpennebula] = {
+ tokens: [{ token: passOpennebula, time: session.exp }],
+ }
}
if (userValidation(userOpennebula, passOpennebula)) {
next()
+
return
}
}
@@ -156,6 +162,7 @@ const validateResourceAndSession = (req, res, next) => {
}
if (nonAuthenticated.some(finderCommand)) {
next()
+
return
}
}
@@ -172,16 +179,17 @@ const setOptionalParameters = (req, res, next) => {
if (req && req.params) {
let start = true
const keys = Object.keys(req.params)
- keys.forEach(param => {
+ keys.forEach((param) => {
if (start) {
// The params[0] is the resource
start = false
+
return start
}
if (req.params[param]) {
const matches = req.params[param].match(/(^[\w]*=)/gi)
if (matches && matches[0]) {
- params.forEach(parameter => {
+ params.forEach((parameter) => {
if (
matches[0].replace(/=/g, '').toLowerCase() ===
parameter.toLowerCase()
@@ -199,6 +207,7 @@ const setOptionalParameters = (req, res, next) => {
paramsState[param] = req.params[param]
}
}
+
return ''
})
}
@@ -215,7 +224,7 @@ const setOptionalQueries = (req, res, next) => {
if (req && req.query) {
const keys = Object.keys(req.query)
const queries = getAllowedQueryParams()
- keys.forEach(query => {
+ keys.forEach((query) => {
if (req.query[query] && queries.includes(query)) {
queriesState[query] = req.query[query]
}
@@ -244,5 +253,5 @@ module.exports = {
getQueriesState,
getIdUserOpennebula,
getUserOpennebula,
- getPassOpennebula
+ getPassOpennebula,
}
diff --git a/src/fireedge/src/server/routes/entrypoints/middlewares/index.js b/src/fireedge/src/server/routes/entrypoints/middlewares/index.js
index 27300847d9..c7b4a345e2 100644
--- a/src/fireedge/src/server/routes/entrypoints/middlewares/index.js
+++ b/src/fireedge/src/server/routes/entrypoints/middlewares/index.js
@@ -23,7 +23,7 @@ const {
getQueriesState,
getIdUserOpennebula,
getUserOpennebula,
- getPassOpennebula
+ getPassOpennebula,
} = require('./api')
module.exports = {
@@ -35,5 +35,5 @@ module.exports = {
getQueriesState,
getIdUserOpennebula,
getUserOpennebula,
- getPassOpennebula
+ getPassOpennebula,
}
diff --git a/src/fireedge/src/server/routes/websockets/guacamole/index.js b/src/fireedge/src/server/routes/websockets/guacamole/index.js
index 358521009a..3c6a72cf77 100644
--- a/src/fireedge/src/server/routes/websockets/guacamole/index.js
+++ b/src/fireedge/src/server/routes/websockets/guacamole/index.js
@@ -37,24 +37,31 @@ const formatError = 'Error: %s'
const configError = (error) => ({
color: 'red',
message: formatError,
- error: error && error.message
+ error: error && error.message,
})
// guacamole client options
const clientOptions = {
crypt: {
cypher: 'AES-256-CBC',
- key: (global && global.paths && global.paths.FIREEDGE_KEY) || ''
+ key: (global && global.paths && global.paths.FIREEDGE_KEY) || '',
},
allowedUnencryptedConnectionSettings: {
rdp: ['width', 'height', 'dpi'],
vnc: ['width', 'height', 'dpi'],
ssh: ['color-scheme', 'font-name', 'font-size', 'width', 'height', 'dpi'],
- telnet: ['color-scheme', 'font-name', 'font-size', 'width', 'height', 'dpi']
+ telnet: [
+ 'color-scheme',
+ 'font-name',
+ 'font-size',
+ 'width',
+ 'height',
+ 'dpi',
+ ],
},
log: {
- level: 'ERRORS'
- }
+ level: 'ERRORS',
+ },
}
const clientCallbacks = {
@@ -62,8 +69,9 @@ const clientCallbacks = {
if (settings.expiration && settings.expiration < Date.now()) {
return callback(new Error('Token expired'))
}
+
return callback(null, settings)
- }
+ },
}
const appConfig = getFireedgeConfig()
@@ -76,7 +84,7 @@ const guacdHost = guacd.host || 'localhost'
*
* @param {object} appServer - express app
*/
-const guacamole = appServer => {
+const guacamole = (appServer) => {
if (
appServer &&
appServer.constructor &&
@@ -98,5 +106,5 @@ const guacamole = appServer => {
module.exports = {
endpointGuacamole,
- guacamole
+ guacamole,
}
diff --git a/src/fireedge/src/server/routes/websockets/hooks/index.js b/src/fireedge/src/server/routes/websockets/hooks/index.js
index 502612ee60..5c14b493be 100644
--- a/src/fireedge/src/server/routes/websockets/hooks/index.js
+++ b/src/fireedge/src/server/routes/websockets/hooks/index.js
@@ -23,7 +23,7 @@ const {
middlewareValidateResourceForHookConnection,
getResourceDataForRequest,
getDataZone,
- getQueryData
+ getQueryData,
} = require('server/utils/server')
/**
@@ -51,28 +51,25 @@ const main = (app = {}, type = '') => {
})
zeromqSock.on('message', (...args) => {
const mssgs = []
- Array.prototype.slice.call(args).forEach(arg => {
+ Array.prototype.slice.call(args).forEach((arg) => {
mssgs.push(arg.toString())
})
if (mssgs[0] && mssgs[1]) {
- xml2json(
- atob(mssgs[1]),
- (error, result) => {
- if (error) {
- const configErrorParser = {
- color: 'red',
- error,
- message: 'Error parser: %s'
- }
- messageTerminal(configErrorParser)
- } else {
- server.emit(type, {
- command: mssgs[0],
- data: result
- })
+ xml2json(atob(mssgs[1]), (error, result) => {
+ if (error) {
+ const configErrorParser = {
+ color: 'red',
+ error,
+ message: 'Error parser: %s',
}
+ messageTerminal(configErrorParser)
+ } else {
+ server.emit(type, {
+ command: mssgs[0],
+ data: result,
+ })
}
- )
+ })
}
})
}
@@ -81,12 +78,12 @@ const main = (app = {}, type = '') => {
const configErrorHooks = {
color: 'red',
error,
- message: '%s'
+ message: '%s',
}
messageTerminal(configErrorHooks)
}
}
module.exports = {
- main
+ main,
}
diff --git a/src/fireedge/src/server/routes/websockets/index.js b/src/fireedge/src/server/routes/websockets/index.js
index 6faa1c76fa..35b85a63ee 100644
--- a/src/fireedge/src/server/routes/websockets/index.js
+++ b/src/fireedge/src/server/routes/websockets/index.js
@@ -18,7 +18,7 @@ const socketIO = require('socket.io')
const { messageTerminal, checkEmptyObject } = require('server/utils/general')
const {
defaultFilesWebsockets,
- defaultConfigErrorMessage
+ defaultConfigErrorMessage,
} = require('server/utils/constants/defaults')
/**
@@ -35,42 +35,43 @@ const websockets = (appServer = {}) => {
appServer.constructor.name &&
appServer.constructor.name === 'Server'
) {
- Object.entries(defaultFilesWebsockets).forEach(([filename = '', info = {}]) => {
- if (filename && info && !checkEmptyObject(info)) {
- const path = info && info.path
- const methods = info && info.methods
- if (path && methods) {
- const io = socketIO(
- {
+ Object.entries(defaultFilesWebsockets).forEach(
+ ([filename = '', info = {}]) => {
+ if (filename && info && !checkEmptyObject(info)) {
+ const path = info && info.path
+ const methods = info && info.methods
+ if (path && methods) {
+ const io = socketIO({
path,
cors: {
origin: '*',
methods,
- credentials: true
+ credentials: true,
+ },
+ }).listen(appServer)
+ try {
+ // eslint-disable-next-line global-require
+ const fileInfo = require(`./${filename}`)
+ if (fileInfo.main && typeof fileInfo.main === 'function') {
+ sockets.push(io)
+ fileInfo.main(io, filename)
+ }
+ } catch (error) {
+ if (error instanceof Error) {
+ const config = defaultConfigErrorMessage
+ config.error = error.message
+ messageTerminal(config)
}
- }
- ).listen(appServer)
- try {
- // eslint-disable-next-line global-require
- const fileInfo = require(`./${filename}`)
- if (fileInfo.main && typeof fileInfo.main === 'function') {
- sockets.push(io)
- fileInfo.main(io, filename)
- }
- } catch (error) {
- if (error instanceof Error) {
- const config = defaultConfigErrorMessage
- config.error = error.message
- messageTerminal(config)
}
}
}
}
- })
+ )
}
+
return sockets
}
module.exports = {
- websockets
+ websockets,
}
diff --git a/src/fireedge/src/server/routes/websockets/provision/index.js b/src/fireedge/src/server/routes/websockets/provision/index.js
index b576aff9d7..6673eb182b 100644
--- a/src/fireedge/src/server/routes/websockets/provision/index.js
+++ b/src/fireedge/src/server/routes/websockets/provision/index.js
@@ -27,7 +27,7 @@ const { subscriber } = require('server/routes/api/provision/functions')
const configErrorProvision = (error = '') => ({
color: 'red',
error,
- message: '%s'
+ message: '%s',
})
/**
@@ -38,24 +38,19 @@ const configErrorProvision = (error = '') => ({
*/
const main = (app = {}, type = '') => {
try {
- app
- .use(middlewareValidateAuthWebsocket)
- .on('connection', (server = {}) => {
- server.on('disconnect', () => {
- messageTerminal(configErrorProvision('disconnect'))
- })
- subscriber(
- 'oneprovision',
- data => {
- app.emit(type, data)
- }
- )
+ app.use(middlewareValidateAuthWebsocket).on('connection', (server = {}) => {
+ server.on('disconnect', () => {
+ messageTerminal(configErrorProvision('disconnect'))
})
+ subscriber('oneprovision', (data) => {
+ app.emit(type, data)
+ })
+ })
} catch (error) {
messageTerminal(configErrorProvision(error))
}
}
module.exports = {
- main
+ main,
}
diff --git a/src/fireedge/src/server/routes/websockets/vmrc/index.js b/src/fireedge/src/server/routes/websockets/vmrc/index.js
index 2fe3b16e51..35bd253959 100644
--- a/src/fireedge/src/server/routes/websockets/vmrc/index.js
+++ b/src/fireedge/src/server/routes/websockets/vmrc/index.js
@@ -20,7 +20,10 @@ const { createProxyMiddleware } = require('http-proxy-middleware')
const { readFileSync } = require('fs-extra')
const { getFireedgeConfig } = require('server/utils/yml')
const { messageTerminal } = require('server/utils/general')
-const { genPathResources, validateServerIsSecure } = require('server/utils/server')
+const {
+ genPathResources,
+ validateServerIsSecure,
+} = require('server/utils/server')
const { writeInLogger } = require('server/utils/logger')
const { endpointVmrc, defaultPort } = require('server/utils/constants/defaults')
@@ -31,7 +34,7 @@ const port = appConfig.port || defaultPort
const protocol = validateServerIsSecure() ? 'https' : 'http'
const url = `${protocol}://localhost:${port}`
const config = {
- color: 'red'
+ color: 'red',
}
const vmrcProxy = createProxyMiddleware(endpointVmrc, {
target: url,
@@ -39,14 +42,14 @@ const vmrcProxy = createProxyMiddleware(endpointVmrc, {
ws: true,
secure: /^(https):\/\/[^ "]+$/.test(url),
logLevel: 'debug',
- pathRewrite: path => path.replace(endpointVmrc, '/ticket'),
- onError: err => {
+ pathRewrite: (path) => path.replace(endpointVmrc, '/ticket'),
+ onError: (err) => {
config.error = err.message
config.message = 'Error connection : %s'
messageTerminal(config)
},
// eslint-disable-next-line consistent-return
- router: req => {
+ router: (req) => {
if (req && req.url) {
const parseURL = parse(req.url)
if (parseURL && parseURL.pathname) {
@@ -56,13 +59,14 @@ const vmrcProxy = createProxyMiddleware(endpointVmrc, {
const esxi = readFileSync(
`${global.paths.VMRC_TOKENS || ''}/${ticket}`
).toString()
+
return esxi
} catch (error) {
writeInLogger(ticket, 'Error to read vmrc token file: %s')
}
}
}
- }
+ },
})
/**
@@ -70,7 +74,7 @@ const vmrcProxy = createProxyMiddleware(endpointVmrc, {
*
* @param {object} appServer - express app
*/
-const vmrc = appServer => {
+const vmrc = (appServer) => {
if (
appServer &&
appServer.on &&
@@ -83,5 +87,5 @@ const vmrc = appServer => {
}
module.exports = {
- vmrc
+ vmrc,
}
diff --git a/src/fireedge/src/server/utils/constants/commands/acl.js b/src/fireedge/src/server/utils/constants/commands/acl.js
index f39e334c61..358b121488 100644
--- a/src/fireedge/src/server/utils/constants/commands/acl.js
+++ b/src/fireedge/src/server/utils/constants/commands/acl.js
@@ -15,7 +15,7 @@
* ------------------------------------------------------------------------- */
const {
from: { resource, postBody },
- httpMethod: { GET, POST, DELETE }
+ httpMethod: { GET, POST, DELETE },
} = require('../defaults')
const ACL_ADDRULE = 'acl.addrule'
@@ -25,7 +25,7 @@ const ACL_INFO = 'acl.info'
const Actions = {
ACL_ADDRULE,
ACL_DELRULE,
- ACL_INFO
+ ACL_INFO,
}
module.exports = {
@@ -37,17 +37,17 @@ module.exports = {
params: {
user: {
from: postBody,
- default: '0x100000000'
+ default: '0x100000000',
},
resource: {
from: postBody,
- default: '0x1000000000'
+ default: '0x1000000000',
},
right: {
from: postBody,
- default: '0x1'
- }
- }
+ default: '0x1',
+ },
+ },
},
[ACL_DELRULE]: {
// inspected
@@ -55,14 +55,14 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[ACL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/cluster.js b/src/fireedge/src/server/utils/constants/commands/cluster.js
index 1425b62a47..6e8291430c 100644
--- a/src/fireedge/src/server/utils/constants/commands/cluster.js
+++ b/src/fireedge/src/server/utils/constants/commands/cluster.js
@@ -15,7 +15,7 @@
* ------------------------------------------------------------------------- */
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const CLUSTER_ALLOCATE = 'cluster.allocate'
@@ -43,7 +43,7 @@ const Actions = {
CLUSTER_DELVNET,
CLUSTER_RENAME,
CLUSTER_INFO,
- CLUSTER_POOL_INFO
+ CLUSTER_POOL_INFO,
}
module.exports = {
@@ -55,9 +55,9 @@ module.exports = {
params: {
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[CLUSTER_DELETE]: {
// inspected
@@ -65,9 +65,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[CLUSTER_UPDATE]: {
// inspected
@@ -75,17 +75,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[CLUSTER_ADDHOST]: {
// inspected
@@ -93,13 +93,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
host: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[CLUSTER_DELHOST]: {
// inspected
@@ -107,13 +107,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
host: {
from: query,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[CLUSTER_ADDDATASTORE]: {
// inspected
@@ -121,13 +121,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
datastore: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[CLUSTER_DELDATASTORE]: {
// inspected
@@ -135,13 +135,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
datastore: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[CLUSTER_ADDVNET]: {
// inspected
@@ -149,13 +149,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
vnet: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[CLUSTER_DELVNET]: {
// inspected
@@ -163,13 +163,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
vnet: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[CLUSTER_RENAME]: {
// inspected
@@ -177,13 +177,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[CLUSTER_INFO]: {
// inspected
@@ -191,18 +191,18 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[CLUSTER_POOL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/datastore.js b/src/fireedge/src/server/utils/constants/commands/datastore.js
index 986fc26b36..7d8518994c 100644
--- a/src/fireedge/src/server/utils/constants/commands/datastore.js
+++ b/src/fireedge/src/server/utils/constants/commands/datastore.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const DATASTORE_ALLOCATE = 'datastore.allocate'
@@ -38,7 +38,7 @@ const Actions = {
DATASTORE_RENAME,
DATASTORE_ENABLE,
DATASTORE_INFO,
- DATASTORE_POOL_INFO
+ DATASTORE_POOL_INFO,
}
module.exports = {
@@ -50,13 +50,13 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
+ default: '',
},
cluster: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[DATASTORE_DELETE]: {
// inspected
@@ -64,9 +64,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[DATASTORE_UPDATE]: {
// inspected
@@ -74,17 +74,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[DATASTORE_CHMOD]: {
// inspected
@@ -92,45 +92,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[DATASTORE_CHOWN]: {
// inspected
@@ -138,17 +138,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: -1
+ default: -1,
},
group: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[DATASTORE_RENAME]: {
// inspected
@@ -156,13 +156,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[DATASTORE_ENABLE]: {
// inspected
@@ -170,13 +170,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
enable: {
from: postBody,
- default: true
- }
- }
+ default: true,
+ },
+ },
},
[DATASTORE_INFO]: {
// inspected
@@ -184,18 +184,18 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[DATASTORE_POOL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/document.js b/src/fireedge/src/server/utils/constants/commands/document.js
index 8a8ed170df..9a07818919 100644
--- a/src/fireedge/src/server/utils/constants/commands/document.js
+++ b/src/fireedge/src/server/utils/constants/commands/document.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const DOCUMENT_ALLOCATE = 'document.allocate'
@@ -42,7 +42,7 @@ const Actions = {
DOCUMENT_INFO,
DOCUMENT_LOCK,
DOCUMENT_UNLOCK,
- DOCUMENT_POOL_INFO
+ DOCUMENT_POOL_INFO,
}
module.exports = {
@@ -54,13 +54,13 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
+ default: '',
},
type: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[DOCUMENT_CLONE]: {
// inspected
@@ -68,13 +68,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[DOCUMENT_DELETE]: {
// inspected
@@ -82,9 +82,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[DOCUMENT_UPDATE]: {
// inspected
@@ -92,17 +92,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[DOCUMENT_CHMOD]: {
// inspected
@@ -110,45 +110,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[DOCUMENT_CHOWN]: {
// inspected
@@ -156,17 +156,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: -1
+ default: -1,
},
group: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[DOCUMENT_RENAME]: {
// inspected
@@ -174,13 +174,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[DOCUMENT_INFO]: {
// inspected
@@ -188,13 +188,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[DOCUMENT_LOCK]: {
// inspected
@@ -202,13 +202,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
lock: {
from: postBody,
- default: 4
- }
- }
+ default: 4,
+ },
+ },
},
[DOCUMENT_UNLOCK]: {
// inspected
@@ -216,9 +216,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[DOCUMENT_POOL_INFO]: {
// inspected
@@ -226,21 +226,21 @@ module.exports = {
params: {
filter: {
from: query,
- default: -1
+ default: -1,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
+ default: -1,
},
type: {
from: query,
- default: 100
- }
- }
- }
- }
+ default: 100,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/group.js b/src/fireedge/src/server/utils/constants/commands/group.js
index 5719821f22..e8626e7918 100644
--- a/src/fireedge/src/server/utils/constants/commands/group.js
+++ b/src/fireedge/src/server/utils/constants/commands/group.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const GROUP_ALLOCATE = 'group.allocate'
@@ -40,7 +40,7 @@ const Actions = {
GROUP_QUOTA,
GROUP_POOL_INFO,
GROUP_QUOTA_INFO,
- GROUP_QUOTA_UPDATE
+ GROUP_QUOTA_UPDATE,
}
module.exports = {
@@ -52,9 +52,9 @@ module.exports = {
params: {
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[GROUP_DELETE]: {
// inspected
@@ -62,9 +62,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[GROUP_INFO]: {
// inspected
@@ -72,13 +72,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: -1
+ default: -1,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[GROUP_UPDATE]: {
// inspected
@@ -86,17 +86,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[GROUP_ADDADMIN]: {
// inspected
@@ -104,13 +104,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[GROUP_DELADMIN]: {
// inspected
@@ -118,13 +118,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[GROUP_QUOTA]: {
// inspected
@@ -132,23 +132,23 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: resource,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[GROUP_POOL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
+ params: {},
},
[GROUP_QUOTA_INFO]: {
// inspected
httpMethod: GET,
- params: {}
+ params: {},
},
[GROUP_QUOTA_UPDATE]: {
// inspected
@@ -156,9 +156,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
- }
- }
+ default: '',
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/hook.js b/src/fireedge/src/server/utils/constants/commands/hook.js
index 3991935f48..8b348dc54e 100644
--- a/src/fireedge/src/server/utils/constants/commands/hook.js
+++ b/src/fireedge/src/server/utils/constants/commands/hook.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const HOOK_ALLOCATE = 'hook.allocate'
@@ -38,7 +38,7 @@ const Actions = {
HOOK_UNLOCK,
HOOK_RETRY,
HOOK_POOL_INFO,
- HOOK_LOG_INFO
+ HOOK_LOG_INFO,
}
module.exports = {
@@ -50,9 +50,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[HOOK_DELETE]: {
// inspected
@@ -60,9 +60,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[HOOK_DELETE]: {
// inspected
@@ -70,17 +70,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[HOOK_RENAME]: {
// inspected
@@ -88,13 +88,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[HOOK_INFO]: {
// inspected
@@ -102,13 +102,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[HOOK_LOCK]: {
// inspected
@@ -116,13 +116,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
lock: {
from: postBody,
- default: 4
- }
- }
+ default: 4,
+ },
+ },
},
[HOOK_UNLOCK]: {
// inspected
@@ -130,9 +130,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[HOOK_RETRY]: {
// inspected
@@ -140,13 +140,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
execution: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[HOOK_POOL_INFO]: {
// inspected
@@ -154,17 +154,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -1
+ default: -1,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[HOOK_LOG_INFO]: {
// inspected
@@ -172,21 +172,21 @@ module.exports = {
params: {
minimun: {
from: postBody, // epoch time
- default: ''
+ default: '',
},
maximun: {
from: postBody, // epoch time
- default: ''
+ default: '',
},
id: {
from: postBody,
- default: '' // check
+ default: '', // check
},
execution: {
from: postBody,
- default: 0
- }
- }
- }
- }
+ default: 0,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/host.js b/src/fireedge/src/server/utils/constants/commands/host.js
index 14723be61c..1f195c4ce8 100644
--- a/src/fireedge/src/server/utils/constants/commands/host.js
+++ b/src/fireedge/src/server/utils/constants/commands/host.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, PUT, DELETE }
+ httpMethod: { GET, PUT, DELETE },
} = require('../defaults')
const HOST_ALLOCATE = 'host.allocate'
@@ -38,7 +38,7 @@ const Actions = {
HOST_INFO,
HOST_MONITORING,
HOST_POOL_INFO,
- HOST_POOL_MONITORING
+ HOST_POOL_MONITORING,
}
module.exports = {
@@ -50,21 +50,21 @@ module.exports = {
params: {
hostname: {
from: postBody,
- default: ''
+ default: '',
},
information: {
from: postBody,
- default: ''
+ default: '',
},
manager: {
from: postBody,
- default: ''
+ default: '',
},
cluster: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[HOST_DELETE]: {
// inspected
@@ -72,9 +72,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[HOST_STATUS]: {
// inspected
@@ -82,13 +82,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
status: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[HOST_UPDATE]: {
// inspected
@@ -96,17 +96,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[HOST_RENAME]: {
// inspected
@@ -114,13 +114,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[HOST_INFO]: {
// inspected
@@ -128,13 +128,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[HOST_MONITORING]: {
// inspected
@@ -142,19 +142,19 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[HOST_POOL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
+ params: {},
},
[HOST_POOL_MONITORING]: {
// inspected
httpMethod: GET,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/image.js b/src/fireedge/src/server/utils/constants/commands/image.js
index 2db275c886..f801acea1a 100644
--- a/src/fireedge/src/server/utils/constants/commands/image.js
+++ b/src/fireedge/src/server/utils/constants/commands/image.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const IMAGE_ALLOCATE = 'image.allocate'
@@ -54,7 +54,7 @@ const Actions = {
IMAGE_INFO,
IMAGE_LOCK,
IMAGE_UNLOCK,
- IMAGE_POOL_INFO
+ IMAGE_POOL_INFO,
}
module.exports = {
@@ -66,17 +66,17 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
+ default: '',
},
datastore: {
from: postBody,
- default: 0
+ default: 0,
},
capacity: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[IMAGE_CLONE]: {
// inspected
@@ -84,17 +84,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
+ default: '',
},
datastore: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[IMAGE_DELETE]: {
// inspected
@@ -102,9 +102,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[IMAGE_ENABLE]: {
// inspected
@@ -112,13 +112,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
enable: {
from: postBody,
- default: true
- }
- }
+ default: true,
+ },
+ },
},
[IMAGE_PERSISTENT]: {
// inspected
@@ -126,13 +126,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
persistent: {
from: postBody,
- default: true
- }
- }
+ default: true,
+ },
+ },
},
[IMAGE_CHTYPE]: {
// inspected
@@ -140,13 +140,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
type: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[IMAGE_UPDATE]: {
// inspected
@@ -154,17 +154,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[IMAGE_CHMOD]: {
// inspected
@@ -172,45 +172,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[IMAGE_CHOWN]: {
// inspected
@@ -218,17 +218,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: -1
+ default: -1,
},
group: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[IMAGE_RENAME]: {
// inspected
@@ -236,13 +236,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[IMAGE_SNAPDEL]: {
// inspected
@@ -250,13 +250,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
snapshot: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[IMAGE_SNAPREV]: {
// inspected
@@ -264,13 +264,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
snapshot: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[IMAGE_SNAPFLAT]: {
// inspected
@@ -278,13 +278,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
snapshot: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[IMAGE_INFO]: {
// inspected
@@ -292,13 +292,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[IMAGE_LOCK]: {
// inspected
@@ -306,13 +306,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
lock: {
from: postBody,
- default: 4
- }
- }
+ default: 4,
+ },
+ },
},
[IMAGE_UNLOCK]: {
// inspected
@@ -320,9 +320,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[IMAGE_POOL_INFO]: {
// inspected
@@ -330,17 +330,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -1
+ default: -1,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/index.js b/src/fireedge/src/server/utils/constants/commands/index.js
index d7b310bce1..06ee7d3109 100644
--- a/src/fireedge/src/server/utils/constants/commands/index.js
+++ b/src/fireedge/src/server/utils/constants/commands/index.js
@@ -57,5 +57,5 @@ module.exports = {
...vn,
...vntemplate,
...vrouter,
- ...zone
+ ...zone,
}
diff --git a/src/fireedge/src/server/utils/constants/commands/market.js b/src/fireedge/src/server/utils/constants/commands/market.js
index 84e0dde3e9..8b69e1abab 100644
--- a/src/fireedge/src/server/utils/constants/commands/market.js
+++ b/src/fireedge/src/server/utils/constants/commands/market.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const MARKET_ALLOCATE = 'market.allocate'
@@ -36,7 +36,7 @@ const Actions = {
MARKET_CHOWN,
MARKET_RENAME,
MARKET_INFO,
- MARKET_POOL_INFO
+ MARKET_POOL_INFO,
}
module.exports = {
@@ -48,9 +48,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[MARKET_DELETE]: {
// inspected
@@ -58,9 +58,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[MARKET_UPDATE]: {
// inspected
@@ -68,17 +68,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
update: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[MARKET_CHMOD]: {
// inspected
@@ -86,45 +86,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[MARKET_CHOWN]: {
// inspected
@@ -132,17 +132,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
userId: {
from: postBody,
- default: -1
+ default: -1,
},
groupId: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[MARKET_RENAME]: {
// inspected
@@ -150,13 +150,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[MARKET_INFO]: {
// inspected
@@ -164,18 +164,18 @@ module.exports = {
params: {
id: {
from: resource,
- default: -1
+ default: -1,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[MARKET_POOL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/marketapp.js b/src/fireedge/src/server/utils/constants/commands/marketapp.js
index affdcfcd6c..cac92e0f76 100644
--- a/src/fireedge/src/server/utils/constants/commands/marketapp.js
+++ b/src/fireedge/src/server/utils/constants/commands/marketapp.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, PUT, DELETE }
+ httpMethod: { GET, PUT, DELETE },
} = require('../defaults')
const MARKETAPP_ALLOCATE = 'marketapp.allocate'
@@ -42,7 +42,7 @@ const Actions = {
MARKETAPP_INFO,
MARKETAPP_LOCK,
MARKETAPP_UNLOCK,
- MARKETAPP_POOL_INFO
+ MARKETAPP_POOL_INFO,
}
module.exports = {
@@ -54,13 +54,13 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
+ default: '',
},
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[MARKETAPP_DELETE]: {
// inspected
@@ -68,9 +68,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[MARKETAPP_ENABLE]: {
// inspected
@@ -78,13 +78,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
enable: {
from: postBody,
- default: true
- }
- }
+ default: true,
+ },
+ },
},
[MARKETAPP_UPDATE]: {
// inspected
@@ -92,17 +92,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[MARKETAPP_CHMOD]: {
// inspected
@@ -110,45 +110,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[MARKETAPP_CHOWN]: {
// inspected
@@ -156,17 +156,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
userId: {
from: postBody,
- default: -1
+ default: -1,
},
groupId: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[MARKETAPP_RENAME]: {
// inspected
@@ -174,13 +174,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[MARKETAPP_INFO]: {
// inspected
@@ -188,9 +188,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[MARKETAPP_LOCK]: {
// inspected
@@ -198,13 +198,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
lock: {
from: postBody,
- default: 4
- }
- }
+ default: 4,
+ },
+ },
},
[MARKETAPP_UNLOCK]: {
// inspected
@@ -212,9 +212,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[MARKETAPP_POOL_INFO]: {
// inspected
@@ -222,17 +222,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -1
+ default: -1,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/secgroup.js b/src/fireedge/src/server/utils/constants/commands/secgroup.js
index 93adfbf29e..6c9c375bd2 100644
--- a/src/fireedge/src/server/utils/constants/commands/secgroup.js
+++ b/src/fireedge/src/server/utils/constants/commands/secgroup.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const SECGROUP_ALLOCATE = 'secgroup.allocate'
@@ -40,7 +40,7 @@ const Actions = {
SECGROUP_CHOWN,
SECGROUP_RENAME,
SECGROUP_INFO,
- SECGROUP_POOL_INFO
+ SECGROUP_POOL_INFO,
}
module.exports = {
@@ -52,9 +52,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[SECGROUP_CLONE]: {
// inspected
@@ -62,13 +62,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[SECGROUP_DELETE]: {
// inspected
@@ -76,9 +76,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[SECGROUP_UPDATE]: {
// inspected
@@ -86,17 +86,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[SECGROUP_COMMIT]: {
// inspected
@@ -104,13 +104,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
vms: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[SECGROUP_CHMOD]: {
// inspected
@@ -118,45 +118,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[SECGROUP_CHOWN]: {
// inspected
@@ -164,17 +164,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: -1
+ default: -1,
},
group: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[SECGROUP_RENAME]: {
// inspected
@@ -182,13 +182,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[SECGROUP_INFO]: {
// inspected
@@ -196,13 +196,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[SECGROUP_POOL_INFO]: {
// inspected
@@ -210,17 +210,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -3
+ default: -3,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/system.js b/src/fireedge/src/server/utils/constants/commands/system.js
index 4de622f662..9f01a30308 100644
--- a/src/fireedge/src/server/utils/constants/commands/system.js
+++ b/src/fireedge/src/server/utils/constants/commands/system.js
@@ -15,7 +15,7 @@
* ------------------------------------------------------------------------- */
const {
- httpMethod: { GET }
+ httpMethod: { GET },
} = require('../defaults')
const SYSTEM_VERSION = 'system.version'
@@ -23,7 +23,7 @@ const SYSTEM_CONFIG = 'system.config'
const Actions = {
SYSTEM_VERSION,
- SYSTEM_CONFIG
+ SYSTEM_CONFIG,
}
module.exports = {
@@ -32,12 +32,12 @@ module.exports = {
[SYSTEM_VERSION]: {
// inspected
httpMethod: GET,
- params: {}
+ params: {},
},
[SYSTEM_CONFIG]: {
// inspected
httpMethod: GET,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/template.js b/src/fireedge/src/server/utils/constants/commands/template.js
index 0a48cdfec1..3eb7ff3fae 100644
--- a/src/fireedge/src/server/utils/constants/commands/template.js
+++ b/src/fireedge/src/server/utils/constants/commands/template.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const TEMPLATE_ALLOCATE = 'template.allocate'
@@ -44,7 +44,7 @@ const Actions = {
TEMPLATE_LOCK,
TEMPLATE_UNLOCK,
TEMPLATE_INFO,
- TEMPLATE_POOL_INFO
+ TEMPLATE_POOL_INFO,
}
module.exports = {
@@ -56,9 +56,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[TEMPLATE_CLONE]: {
// inspected
@@ -66,17 +66,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
+ default: '',
},
image: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[TEMPLATE_DELETE]: {
// inspected
@@ -84,13 +84,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
image: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[TEMPLATE_INSTANTIATE]: {
// inspected
@@ -98,25 +98,25 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
+ default: '',
},
hold: {
from: postBody,
- default: false
+ default: false,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
persistent: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[TEMPLATE_UPDATE]: {
// inspected
@@ -124,17 +124,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[TEMPLATE_CHMOD]: {
// inspected
@@ -142,49 +142,49 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
image: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[TEMPLATE_CHOWN]: {
// inspected
@@ -192,17 +192,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: -1
+ default: -1,
},
group: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[TEMPLATE_RENAME]: {
// inspected
@@ -210,13 +210,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[TEMPLATE_LOCK]: {
// inspected
@@ -224,17 +224,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
level: {
from: postBody,
- default: 4
+ default: 4,
},
test: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[TEMPLATE_UNLOCK]: {
// inspected
@@ -242,9 +242,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[TEMPLATE_INFO]: {
// inspected
@@ -252,17 +252,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
extended: {
from: query,
- default: false
+ default: false,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[TEMPLATE_POOL_INFO]: {
// inspected
@@ -270,17 +270,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -1
+ default: -1,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/user.js b/src/fireedge/src/server/utils/constants/commands/user.js
index e627374add..0a34f04dbb 100644
--- a/src/fireedge/src/server/utils/constants/commands/user.js
+++ b/src/fireedge/src/server/utils/constants/commands/user.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const USER_ALLOCATE = 'user.allocate'
@@ -48,7 +48,7 @@ const Actions = {
USER_INFO,
USER_POOL_INFO,
USER_QUOTA_INFO,
- USER_QUOTA_UPDATE
+ USER_QUOTA_UPDATE,
}
module.exports = {
@@ -60,21 +60,21 @@ module.exports = {
params: {
username: {
from: postBody,
- default: 0
+ default: 0,
},
password: {
from: postBody,
- default: ''
+ default: '',
},
driver: {
from: postBody,
- default: ''
+ default: '',
},
group: {
from: postBody,
- default: []
- }
- }
+ default: [],
+ },
+ },
},
[USER_DELETE]: {
// inspected
@@ -82,9 +82,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[USER_PASSWD]: {
// inspected
@@ -92,13 +92,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
password: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[USER_LOGIN]: {
// inspected
@@ -106,21 +106,21 @@ module.exports = {
params: {
user: {
from: postBody,
- default: ''
+ default: '',
},
token: {
from: postBody,
- default: ''
+ default: '',
},
expire: {
from: postBody,
- default: 0
+ default: 0,
},
gid: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[USER_UPDATE]: {
// inspected
@@ -128,17 +128,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 1
- }
- }
+ default: 1,
+ },
+ },
},
[USER_CHAUTH]: {
// inspected
@@ -146,17 +146,17 @@ module.exports = {
params: {
id: {
from: postBody,
- default: 0
+ default: 0,
},
driver: {
from: postBody,
- default: ''
+ default: '',
},
password: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[USER_QUOTA]: {
// inspected
@@ -164,13 +164,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[USER_CHGRP]: {
// inspected
@@ -178,13 +178,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
group: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[USER_ADDGROUP]: {
// inspected
@@ -192,13 +192,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
group: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[USER_DELGROUP]: {
// inspected
@@ -206,13 +206,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
group: {
from: query,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[USER_INFO]: {
// inspected
@@ -220,23 +220,23 @@ module.exports = {
params: {
id: {
from: resource,
- default: -1
+ default: -1,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[USER_POOL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
+ params: {},
},
[USER_QUOTA_INFO]: {
// inspected
httpMethod: GET,
- params: {}
+ params: {},
},
[USER_QUOTA_UPDATE]: {
// inspected
@@ -244,9 +244,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
- }
- }
+ default: '',
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/vdc.js b/src/fireedge/src/server/utils/constants/commands/vdc.js
index faa8e66080..839c562142 100644
--- a/src/fireedge/src/server/utils/constants/commands/vdc.js
+++ b/src/fireedge/src/server/utils/constants/commands/vdc.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const VDC_ALLOCATE = 'vdc.allocate'
@@ -52,7 +52,7 @@ const Actions = {
VDC_ADDVNET,
VDC_DELVNET,
VDC_INFO,
- VDC_POOL_INFO
+ VDC_POOL_INFO,
}
module.exports = {
@@ -64,13 +64,13 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
+ default: '',
},
cluster: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VDC_DELETE]: {
// inspected
@@ -78,9 +78,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_UPDATE]: {
// inspected
@@ -88,17 +88,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_RENAME]: {
// inspected
@@ -106,13 +106,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VDC_INFO]: {
// inspected
@@ -120,18 +120,18 @@ module.exports = {
params: {
id: {
from: resource,
- default: -1
+ default: -1,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VDC_POOL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
+ params: {},
},
[VDC_ADDGROUP]: {
// inspected
@@ -139,13 +139,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
group: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_DELGROUP]: {
// inspected
@@ -153,13 +153,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
group: {
from: query,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_ADDCLUSTER]: {
// inspected
@@ -167,17 +167,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
zone: {
from: postBody,
- default: 0
+ default: 0,
},
cluster: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_DELCLUSTER]: {
// inspected
@@ -185,17 +185,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
zone: {
from: query,
- default: 0
+ default: 0,
},
cluster: {
from: query,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_ADDHOST]: {
// inspected
@@ -203,17 +203,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
zone: {
from: postBody,
- default: 0
+ default: 0,
},
host: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_DELHOST]: {
// inspected
@@ -221,17 +221,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
zone: {
from: postBody,
- default: 0
+ default: 0,
},
host: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_ADDDATASTORE]: {
// inspected
@@ -239,17 +239,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
zone: {
from: postBody,
- default: 0
+ default: 0,
},
datastore: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_DELDATASTORE]: {
// inspected
@@ -257,17 +257,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
zone: {
from: postBody,
- default: 0
+ default: 0,
},
datastore: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_ADDVNET]: {
// inspected
@@ -275,17 +275,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
zone: {
from: postBody,
- default: 0
+ default: 0,
},
vnet: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VDC_DELVNET]: {
// inspected
@@ -293,17 +293,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
zone: {
from: query,
- default: 0
+ default: 0,
},
vnet: {
from: query,
- default: 0
- }
- }
- }
- }
+ default: 0,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/vm.js b/src/fireedge/src/server/utils/constants/commands/vm.js
index db266c022e..34d0b6e674 100644
--- a/src/fireedge/src/server/utils/constants/commands/vm.js
+++ b/src/fireedge/src/server/utils/constants/commands/vm.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const VM_ALLOCATE = 'vm.allocate'
@@ -94,7 +94,7 @@ const Actions = {
VM_POOL_MONITORING,
VM_POOL_ACCOUNTING,
VM_POOL_SHOWBACK,
- VM_POOL_CALCULATE_SHOWBACK
+ VM_POOL_CALCULATE_SHOWBACK,
}
module.exports = {
@@ -106,13 +106,13 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
+ default: '',
},
status: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VM_DEPLOY]: {
// inspected
@@ -120,21 +120,21 @@ module.exports = {
params: {
id: {
from: resource,
- default: -1
+ default: -1,
},
host: {
from: postBody,
- default: -1
+ default: -1,
},
enforce: {
from: postBody,
- default: false
+ default: false,
},
datastore: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VM_ACTION]: {
// inspected
@@ -142,13 +142,13 @@ module.exports = {
params: {
action: {
from: postBody,
- default: 'stop'
+ default: 'stop',
},
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_MIGRATE]: {
// inspected
@@ -156,29 +156,29 @@ module.exports = {
params: {
id: {
from: resource,
- default: -1
+ default: -1,
},
host: {
from: postBody,
- default: -1
+ default: -1,
},
live: {
from: postBody,
- default: false
+ default: false,
},
enforce: {
from: postBody,
- default: false
+ default: false,
},
datastore: {
from: postBody,
- default: -1
+ default: -1,
},
type: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_DISK_SAVEAS]: {
// inspected
@@ -186,25 +186,25 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
disk: {
from: postBody,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
+ default: '',
},
type: {
from: postBody,
- default: ''
+ default: '',
},
snapshot: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VM_DISK_SNAP_CREATE]: {
// inspected
@@ -212,17 +212,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
disk: {
from: postBody,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_DISK_SNAP_DELETE]: {
// inspected
@@ -230,17 +230,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
disk: {
from: query,
- default: 0
+ default: 0,
},
snapshot: {
from: query,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_DISK_SNAP_REVERT]: {
// inspected
@@ -248,17 +248,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
disk: {
from: postBody,
- default: 0
+ default: 0,
},
snapshot: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_DISK_SNAP_RENAME]: {
// inspected
@@ -266,21 +266,21 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
disk: {
from: postBody,
- default: 0
+ default: 0,
},
snapshot: {
from: postBody,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_DISK_ATTACH]: {
// inspected
@@ -288,13 +288,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_DISK_DETACH]: {
// inspected
@@ -302,13 +302,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
disk: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_DISK_RESIZE]: {
// inspected
@@ -316,17 +316,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
disk: {
from: postBody,
- default: 0
+ default: 0,
},
size: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_NIC_ATTACH]: {
// inspected
@@ -334,13 +334,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_NIC_DETACH]: {
// inspected
@@ -348,13 +348,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
nic: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_CHMOD]: {
// inspected
@@ -362,45 +362,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VM_CHOWN]: {
// inspected
@@ -408,17 +408,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: -1
+ default: -1,
},
group: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VM_RENAME]: {
// inspected
@@ -426,13 +426,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_SNAP_CREATE]: {
// inspected
@@ -440,13 +440,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_SNAP_REVERT]: {
// inspected
@@ -454,13 +454,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
snapshot: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_SNAP_DELETE]: {
// inspected
@@ -468,13 +468,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
snapshot: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_RESIZE]: {
// inspected
@@ -482,17 +482,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
enforce: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VM_UPDATE]: {
// inspected
@@ -500,17 +500,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_CONF_UPDATE]: {
// inspected
@@ -518,13 +518,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: resource,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_RECOVER]: {
// inspected
@@ -532,13 +532,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
operation: {
from: postBody,
- default: 1
- }
- }
+ default: 1,
+ },
+ },
},
[VM_INFO]: {
// inspected
@@ -546,13 +546,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VM_MONITORING]: {
// inspected
@@ -560,9 +560,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_LOCK]: {
// inspected
@@ -570,17 +570,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
level: {
from: postBody,
- default: 4
+ default: 4,
},
test: {
from: postBody,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VM_UNLOCK]: {
// inspected
@@ -588,52 +588,52 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_SCHED_ADD]: {
httpMethod: POST,
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_SCHED_UPDATE]: {
httpMethod: PUT,
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
id_sched: {
from: postBody,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_SCHED_DELETE]: {
httpMethod: DELETE,
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
id_sched: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_POOL_INFO]: {
// inspected
@@ -641,25 +641,25 @@ module.exports = {
params: {
filter: {
from: query,
- default: -2
+ default: -2,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
+ default: -1,
},
state: {
from: query,
- default: -2
+ default: -2,
},
filterByKey: {
from: query,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_POOL_INFO_EXTENDED]: {
// inspected
@@ -667,25 +667,25 @@ module.exports = {
params: {
filter: {
from: query,
- default: -2
+ default: -2,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
+ default: -1,
},
state: {
from: query,
- default: -2
+ default: -2,
},
filterBykey: {
from: query,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_POOL_MONITORING]: {
// inspected
@@ -693,9 +693,9 @@ module.exports = {
params: {
filter: {
from: query,
- default: -2
- }
- }
+ default: -2,
+ },
+ },
},
[VM_POOL_ACCOUNTING]: {
// inspected
@@ -703,17 +703,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -2
+ default: -2,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VM_POOL_SHOWBACK]: {
// inspected
@@ -721,25 +721,25 @@ module.exports = {
params: {
filter: {
from: query,
- default: -2
+ default: -2,
},
startMonth: {
filter: query,
- default: -1
+ default: -1,
},
startYear: {
filter: query,
- default: -1
+ default: -1,
},
endMonth: {
filter: query,
- default: -1
+ default: -1,
},
endYear: {
filter: query,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VM_POOL_CALCULATE_SHOWBACK]: {
// inspected
@@ -747,21 +747,21 @@ module.exports = {
params: {
startMonth: {
filter: query,
- default: -1
+ default: -1,
},
startYear: {
filter: query,
- default: -1
+ default: -1,
},
endMonth: {
filter: query,
- default: -1
+ default: -1,
},
endYear: {
filter: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/vmgroup.js b/src/fireedge/src/server/utils/constants/commands/vmgroup.js
index b2606f3a10..a556b40271 100644
--- a/src/fireedge/src/server/utils/constants/commands/vmgroup.js
+++ b/src/fireedge/src/server/utils/constants/commands/vmgroup.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const VM_GROUP_ALLOCATE = 'vmgroup.allocate'
@@ -40,7 +40,7 @@ const Actions = {
VM_GROUP_INFO,
VM_GROUP_LOCK,
VM_GROUP_UNLOCK,
- VM_GROUP_POOL_INFO
+ VM_GROUP_POOL_INFO,
}
module.exports = {
@@ -52,9 +52,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VM_GROUP_DELETE]: {
// inspected
@@ -62,9 +62,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_GROUP_UPDATE]: {
// inspected
@@ -72,17 +72,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_GROUP_CHMOD]: {
// inspected
@@ -90,45 +90,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VM_GROUP_CHOWN]: {
// inspected
@@ -136,17 +136,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: -1
+ default: -1,
},
group: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VM_GROUP_RENAME]: {
// inspected
@@ -154,13 +154,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- defaul: ''
- }
- }
+ defaul: '',
+ },
+ },
},
[VM_GROUP_INFO]: {
// inspected
@@ -168,13 +168,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VM_GROUP_LOCK]: {
// inspected
@@ -182,13 +182,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
lock: {
from: postBody,
- default: 4
- }
- }
+ default: 4,
+ },
+ },
},
[VM_GROUP_UNLOCK]: {
// inspected
@@ -196,9 +196,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VM_GROUP_POOL_INFO]: {
// inspected
@@ -206,17 +206,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -1
+ default: -1,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/vn.js b/src/fireedge/src/server/utils/constants/commands/vn.js
index 95a344dea7..f36eb2e418 100644
--- a/src/fireedge/src/server/utils/constants/commands/vn.js
+++ b/src/fireedge/src/server/utils/constants/commands/vn.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const VN_ALLOCATE = 'vn.allocate'
@@ -54,7 +54,7 @@ const Actions = {
VN_INFO,
VN_LOCK,
VN_UNLOCK,
- VN_POOL_INFO
+ VN_POOL_INFO,
}
module.exports = {
@@ -66,13 +66,13 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
+ default: '',
},
cluster: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VN_DELETE]: {
// inspected
@@ -80,9 +80,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VN_AR_ADD]: {
// inspected
@@ -90,13 +90,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VN_AR_RM]: {
// inspected
@@ -104,13 +104,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
address: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VN_AR_UPDATE]: {
// inspected
@@ -118,13 +118,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VN_RESERVE]: {
// inspected
@@ -132,13 +132,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VN_AR_FREE]: {
// inspected
@@ -146,13 +146,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
range: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VN_HOLD]: {
// inspected
@@ -160,13 +160,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VN_RELEASE]: {
// inspected
@@ -174,13 +174,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VN_UPDATE]: {
// inspected
@@ -188,17 +188,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VN_CHMOD]: {
// inspected
@@ -206,45 +206,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VN_CHOWN]: {
// inspected
@@ -252,17 +252,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
user: {
from: postBody,
- default: -1
+ default: -1,
},
group: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VN_RENAME]: {
// inspected
@@ -270,13 +270,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VN_INFO]: {
// inspected
@@ -284,13 +284,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VN_LOCK]: {
// inspected
@@ -298,13 +298,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
level: {
from: postBody,
- default: 4
- }
- }
+ default: 4,
+ },
+ },
},
[VN_UNLOCK]: {
// inspected
@@ -312,9 +312,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VN_POOL_INFO]: {
// inspected
@@ -322,17 +322,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -3
+ default: -3,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/vntemplate.js b/src/fireedge/src/server/utils/constants/commands/vntemplate.js
index 7e4108457a..9d25e976aa 100644
--- a/src/fireedge/src/server/utils/constants/commands/vntemplate.js
+++ b/src/fireedge/src/server/utils/constants/commands/vntemplate.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const VNTEMPLATE_ALLOCATE = 'vntemplate.allocate'
@@ -44,7 +44,7 @@ const Actions = {
VNTEMPLATE_INFO,
VNTEMPLATE_LOCK,
VNTEMPLATE_UNLOCK,
- VNTEMPLATE_POOL_INFO
+ VNTEMPLATE_POOL_INFO,
}
module.exports = {
@@ -56,9 +56,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VNTEMPLATE_CLONE]: {
// inspected
@@ -66,13 +66,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VNTEMPLATE_DELETE]: {
// inspected
@@ -80,9 +80,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VNTEMPLATE_INSTANTIATE]: {
// inspected
@@ -90,17 +90,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
+ default: '',
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VNTEMPLATE_UPDATE]: {
// inspected
@@ -108,17 +108,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VNTEMPLATE_CHMOD]: {
// inspected
@@ -126,45 +126,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VNTEMPLATE_CHOWN]: {
// inspected
@@ -172,17 +172,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
userId: {
from: postBody,
- default: -1
+ default: -1,
},
groupId: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VNTEMPLATE_RENAME]: {
// inspected
@@ -190,13 +190,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VNTEMPLATE_INFO]: {
// inspected
@@ -204,13 +204,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VNTEMPLATE_LOCK]: {
// inspected
@@ -218,13 +218,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
lock: {
from: postBody,
- default: 4
- }
- }
+ default: 4,
+ },
+ },
},
[VNTEMPLATE_UNLOCK]: {
// inspected
@@ -232,9 +232,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VNTEMPLATE_POOL_INFO]: {
// inspected
@@ -242,17 +242,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -1
+ default: -1,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/vrouter.js b/src/fireedge/src/server/utils/constants/commands/vrouter.js
index ae6aad3528..aa87869cfe 100644
--- a/src/fireedge/src/server/utils/constants/commands/vrouter.js
+++ b/src/fireedge/src/server/utils/constants/commands/vrouter.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const VROUTER_ALLOCATE = 'vrouter.allocate'
@@ -46,7 +46,7 @@ const Actions = {
VROUTER_INFO,
VROUTER_LOCK,
VROUTER_UNLOCK,
- VROUTER_POOL_INFO
+ VROUTER_POOL_INFO,
}
module.exports = {
@@ -58,9 +58,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VROUTER_DELETE]: {
// inspected
@@ -68,13 +68,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
images: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VROUTER_INSTANTIATE]: {
// inspected
@@ -82,29 +82,29 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
number: {
from: postBody,
- default: 1
+ default: 1,
},
templateId: {
from: postBody,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
+ default: '',
},
pending: {
from: postBody,
- default: false
+ default: false,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VROUTER_NIC_ATTACH]: {
// inspected
@@ -112,13 +112,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VROUTER_NIC_DETACH]: {
// inspected
@@ -126,13 +126,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
nic: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VROUTER_UPDATE]: {
// inspected
@@ -140,17 +140,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
update: {
from: postBody,
- default: 1
- }
- }
+ default: 1,
+ },
+ },
},
[VROUTER_CHMOD]: {
// inspected
@@ -158,45 +158,45 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
ownerUse: {
from: postBody,
- default: -1
+ default: -1,
},
ownerManage: {
from: postBody,
- default: -1
+ default: -1,
},
ownerAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
groupUse: {
from: postBody,
- default: -1
+ default: -1,
},
groupManage: {
from: postBody,
- default: -1
+ default: -1,
},
groupAdmin: {
from: postBody,
- default: -1
+ default: -1,
},
otherUse: {
from: postBody,
- default: -1
+ default: -1,
},
otherManage: {
from: postBody,
- default: -1
+ default: -1,
},
otherAdmin: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VROUTER_CHOWN]: {
// inspected
@@ -204,17 +204,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
userId: {
from: postBody,
- default: -1
+ default: -1,
},
groupId: {
from: postBody,
- default: -1
- }
- }
+ default: -1,
+ },
+ },
},
[VROUTER_RENAME]: {
// inspected
@@ -222,13 +222,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[VROUTER_INFO]: {
// inspected
@@ -236,13 +236,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: -1
+ default: -1,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[VROUTER_LOCK]: {
// inspected
@@ -250,13 +250,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
lock: {
from: postBody,
- default: 4
- }
- }
+ default: 4,
+ },
+ },
},
[VROUTER_UNLOCK]: {
// inspected
@@ -264,9 +264,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[VROUTER_POOL_INFO]: {
// inspected
@@ -274,17 +274,17 @@ module.exports = {
params: {
filter: {
from: query,
- default: -1
+ default: -1,
},
start: {
from: query,
- default: -1
+ default: -1,
},
end: {
from: query,
- default: -1
- }
- }
- }
- }
+ default: -1,
+ },
+ },
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/commands/zone.js b/src/fireedge/src/server/utils/constants/commands/zone.js
index 60ab5c0eb8..0476468bcd 100644
--- a/src/fireedge/src/server/utils/constants/commands/zone.js
+++ b/src/fireedge/src/server/utils/constants/commands/zone.js
@@ -16,7 +16,7 @@
const {
from: { resource, postBody, query },
- httpMethod: { GET, POST, PUT, DELETE }
+ httpMethod: { GET, POST, PUT, DELETE },
} = require('../defaults')
const ZONE_ALLOCATE = 'zone.allocate'
@@ -34,7 +34,7 @@ const Actions = {
ZONE_RENAME,
ZONE_INFO,
ZONE_RAFTSTATUS,
- ZONE_POOL_INFO
+ ZONE_POOL_INFO,
}
module.exports = {
@@ -46,9 +46,9 @@ module.exports = {
params: {
template: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[ZONE_DELETE]: {
// inspected
@@ -56,9 +56,9 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[ZONE_UPDATE]: {
// inspected
@@ -66,17 +66,17 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
template: {
from: postBody,
- default: ''
+ default: '',
},
replace: {
from: postBody,
- default: 0
- }
- }
+ default: 0,
+ },
+ },
},
[ZONE_RENAME]: {
// inspected
@@ -84,13 +84,13 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
name: {
from: postBody,
- default: ''
- }
- }
+ default: '',
+ },
+ },
},
[ZONE_INFO]: {
// inspected
@@ -98,23 +98,23 @@ module.exports = {
params: {
id: {
from: resource,
- default: 0
+ default: 0,
},
decrypt: {
from: query,
- default: false
- }
- }
+ default: false,
+ },
+ },
},
[ZONE_RAFTSTATUS]: {
// inspected
httpMethod: GET,
- params: {}
+ params: {},
},
[ZONE_POOL_INFO]: {
// inspected
httpMethod: GET,
- params: {}
- }
- }
+ params: {},
+ },
+ },
}
diff --git a/src/fireedge/src/server/utils/constants/defaults.js b/src/fireedge/src/server/utils/constants/defaults.js
index 6a516a0c4e..a546731329 100644
--- a/src/fireedge/src/server/utils/constants/defaults.js
+++ b/src/fireedge/src/server/utils/constants/defaults.js
@@ -27,12 +27,12 @@ const apps = {
[appNameSunstone]: {
theme: appNameSunstone,
name: appNameSunstone,
- assets: true
+ assets: true,
},
[appNameProvision]: {
name: appNameProvision,
- theme: appNameProvision
- }
+ theme: appNameProvision,
+ },
}
const default2FAOpennebulaVar = 'TWO_FACTOR_AUTH_SECRET'
const defaultIp = 'localhost'
@@ -52,17 +52,17 @@ const defaults = {
defaultAppName: appName,
defaultConfigErrorMessage: {
color: 'red',
- message: 'file not found: %s'
+ message: 'file not found: %s',
},
defaultFilesWebsockets: {
hooks: {
path: `${baseUrl}${baseUrlWebsockets}hooks`,
- methods: ['GET', 'POST']
+ methods: ['GET', 'POST'],
},
provision: {
path: `${baseUrl}${baseUrlWebsockets}${appNameProvision}`,
- methods: ['GET', 'POST']
- }
+ methods: ['GET', 'POST'],
+ },
},
defaultFilesRoutes: [
'2fa',
@@ -75,32 +75,32 @@ const defaults = {
'vm',
'zendesk',
appNameProvision,
- appNameSunstone
+ appNameSunstone,
],
defaultApps: apps,
httpMethod: {
GET: 'GET',
POST: 'POST',
PUT: 'PUT',
- DELETE: 'DELETE'
+ DELETE: 'DELETE',
},
defaultHash: {
hash: 'sha256',
- digest: 'hex'
+ digest: 'hex',
},
defaultFileStats: '-stats.json',
from: {
resource: 'RESOURCE',
query: 'QUERY',
- postBody: 'POST_BODY'
+ postBody: 'POST_BODY',
},
defaultOpennebulaZones: [
{
id: '0',
name: 'OpenNebula',
rpc: `${protocol}://${defaultIp}:2633/RPC2`,
- zeromq: `tcp://${defaultIp}:2101`
- }
+ zeromq: `tcp://${defaultIp}:2101`,
+ },
],
defaultConfigParseXML: {
attributeNamePrefix: '',
@@ -110,7 +110,7 @@ const defaults = {
allowBooleanAttributes: false,
parseNodeValue: false,
parseAttributeValue: true,
- trimValues: true
+ trimValues: true,
},
defaultCommandProvision: 'oneprovision',
defaultCommandProvisionTemplate: 'oneprovision-template',
@@ -154,7 +154,12 @@ const defaults = {
defaultGetMethod: 'info',
defaultMessageProblemOpennebula: 'Problem with connection or xml parser',
defaultIP: defaultIp,
- defaultSeverities: [`${severityPrepend}1`, `${severityPrepend}2`, `${severityPrepend}3`, `${severityPrepend}4`],
+ defaultSeverities: [
+ `${severityPrepend}1`,
+ `${severityPrepend}2`,
+ `${severityPrepend}3`,
+ `${severityPrepend}4`,
+ ],
defaultProtocolHotReload: 'http',
defaultHost: '0.0.0.0',
defaultPort: 2616,
@@ -198,8 +203,8 @@ const defaults = {
uk: 'Ukrainian',
vi: 'Vietnamese',
zh_CN: 'Chinese (China)',
- zh_TW: 'Chinese (Taiwan)'
- }
+ zh_TW: 'Chinese (Taiwan)',
+ },
}
module.exports = defaults
diff --git a/src/fireedge/src/server/utils/constants/http-codes.js b/src/fireedge/src/server/utils/constants/http-codes.js
index d9955a7721..e9ea382138 100644
--- a/src/fireedge/src/server/utils/constants/http-codes.js
+++ b/src/fireedge/src/server/utils/constants/http-codes.js
@@ -17,36 +17,36 @@
const httpCodes = {
badRequest: {
id: 400,
- message: 'Bad Request'
+ message: 'Bad Request',
},
unauthorized: {
id: 401,
- message: 'Unauthorized'
+ message: 'Unauthorized',
},
notFound: {
id: 404,
- message: 'Not Found'
+ message: 'Not Found',
},
methodNotAllowed: {
id: 405,
- message: 'Method not Allowed'
+ message: 'Method not Allowed',
},
internalServerError: {
id: 500,
- message: 'Internal Server Error'
+ message: 'Internal Server Error',
},
serviceUnavailable: {
id: 503,
- message: 'Service Unavailable'
+ message: 'Service Unavailable',
},
accepted: {
id: 202,
- message: 'Accepted'
+ message: 'Accepted',
},
ok: {
id: 200,
- message: 'OK'
- }
+ message: 'OK',
+ },
}
module.exports = httpCodes
diff --git a/src/fireedge/src/server/utils/constants/index.js b/src/fireedge/src/server/utils/constants/index.js
index abd0a3f952..5c75971d7f 100644
--- a/src/fireedge/src/server/utils/constants/index.js
+++ b/src/fireedge/src/server/utils/constants/index.js
@@ -23,5 +23,5 @@ module.exports = {
defaults,
httpCodes,
params,
- opennebulaCommands
+ opennebulaCommands,
}
diff --git a/src/fireedge/src/server/utils/general.js b/src/fireedge/src/server/utils/general.js
index 568585acc6..a141286d75 100644
--- a/src/fireedge/src/server/utils/general.js
+++ b/src/fireedge/src/server/utils/general.js
@@ -25,13 +25,7 @@ const { sprintf } = require('sprintf-js')
* @param {string} config.error - error mesage
* @param {string} config.message - formar error
*/
-const messageTerminal = (
- {
- color = 'red',
- error = '',
- message = '%s'
- }
-) => {
+const messageTerminal = ({ color = 'red', error = '', message = '%s' }) => {
const reset = '\x1b[0m'
let consoleColor = ''
switch (color) {
@@ -63,6 +57,7 @@ const addPrintf = (string = '', args = '') => {
typeof replacers[number] !== 'undefined' ? replacers[number] : match
)
}
+
return rtn
}
@@ -78,5 +73,5 @@ const checkEmptyObject = (obj = {}) =>
module.exports = {
messageTerminal,
addPrintf,
- checkEmptyObject
+ checkEmptyObject,
}
diff --git a/src/fireedge/src/server/utils/index.js b/src/fireedge/src/server/utils/index.js
index 6246d20774..1c81be26a0 100644
--- a/src/fireedge/src/server/utils/index.js
+++ b/src/fireedge/src/server/utils/index.js
@@ -29,7 +29,7 @@ const {
getAllowedQueryParams,
getRouteForOpennebulaCommand,
checkOpennebulaCommand,
- fillResourceforHookConnection
+ fillResourceforHookConnection,
} = require('./opennebula')
/**
@@ -40,10 +40,11 @@ const {
const createParamsState = () => {
const rtn = {}
if (params && Array.isArray(params)) {
- params.forEach(param => {
+ params.forEach((param) => {
rtn[param] = null
})
}
+
return rtn
}
@@ -56,10 +57,11 @@ const createQueriesState = () => {
const rtn = {}
const queries = getAllowedQueryParams()
if (queries && Array.isArray(queries)) {
- queries.forEach(query => {
+ queries.forEach((query) => {
rtn[query] = null
})
}
+
return rtn
}
@@ -81,6 +83,7 @@ const checkMethodRouteFunction = (routeFunction, httpMethod = '') => {
) {
rtn = routeFunction.action
}
+
return rtn
}
@@ -103,7 +106,7 @@ const checkIfIsARouteFunction = (route, httpMethod, authenticated) => {
* @param {object} rtnCommand - command to validate
* @returns {object} command
*/
- const finderCommand = rtnCommand =>
+ const finderCommand = (rtnCommand) =>
rtnCommand &&
rtnCommand.endpoint &&
rtnCommand.endpoint === route &&
@@ -117,6 +120,7 @@ const checkIfIsARouteFunction = (route, httpMethod, authenticated) => {
rtn = find
}
}
+
return rtn
}
@@ -139,5 +143,5 @@ module.exports = {
httpResponse,
getDataZone,
checkEmptyObject,
- fillResourceforHookConnection
+ fillResourceforHookConnection,
}
diff --git a/src/fireedge/src/server/utils/index.worker.js b/src/fireedge/src/server/utils/index.worker.js
index c637b068d3..3ecc991a55 100644
--- a/src/fireedge/src/server/utils/index.worker.js
+++ b/src/fireedge/src/server/utils/index.worker.js
@@ -14,9 +14,7 @@
* limitations under the License. *
* ------------------------------------------------------------------------- */
-const {
- opennebulaConnect
-} = require('../../../src/server/utils/opennebula')
+const { opennebulaConnect } = require('../../../src/server/utils/opennebula')
// eslint-disable-next-line no-undef
onmessage = function (ev = {}) {
@@ -30,7 +28,14 @@ onmessage = function (ev = {}) {
}
if (ev && ev.data) {
- const { globalState = {}, user = '', password = '', rpc = '', command = '', paramsCommand = [] } = ev.data
+ const {
+ globalState = {},
+ user = '',
+ password = '',
+ rpc = '',
+ command = '',
+ paramsCommand = [],
+ } = ev.data
if (globalState && user && password && rpc && command) {
pass = false
global.paths = globalState
diff --git a/src/fireedge/src/server/utils/jwt.js b/src/fireedge/src/server/utils/jwt.js
index 0cf787152f..d13042a536 100644
--- a/src/fireedge/src/server/utils/jwt.js
+++ b/src/fireedge/src/server/utils/jwt.js
@@ -29,11 +29,7 @@ const speakeasy = require('speakeasy')
* @param {number} exp - epoch expire time
* @returns {string} JWT
*/
-const createJWT = (
- { id: iss, user: aud, token: jti },
- iat = '',
- exp = ''
-) => {
+const createJWT = ({ id: iss, user: aud, token: jti }, iat = '', exp = '') => {
let rtn = null
if (iss && aud && jti && iat && exp) {
const payload = {
@@ -41,10 +37,11 @@ const createJWT = (
aud,
jti,
iat,
- exp
+ exp,
}
rtn = jwtEncode(payload)
}
+
return rtn
}
@@ -59,6 +56,7 @@ const jwtEncode = (payload = {}) => {
if (global && global.paths && global.paths.FIREEDGE_KEY) {
rtn = jwt.encode(payload, global.paths.FIREEDGE_KEY)
}
+
return rtn
}
@@ -76,7 +74,7 @@ const jwtDecode = (token = '') => {
messageTerminal({
color: 'red',
message: 'invalid: %s',
- error: messageError
+ error: messageError,
})
}
}
@@ -111,22 +109,23 @@ const validateAuth = (req = {}) => {
aud,
jti,
iat,
- exp
+ exp,
}
}
- } catch (error) {
- }
+ } catch (error) {}
} else {
- const messageError = token || (global && global.paths && global.paths.FIREEDGE_KEY)
+ const messageError =
+ token || (global && global.paths && global.paths.FIREEDGE_KEY)
if (messageError) {
messageTerminal({
color: 'red',
message: 'invalid: %s',
- error: messageError
+ error: messageError,
})
}
}
}
+
return rtn
}
@@ -143,9 +142,10 @@ const check2Fa = (secret = '', token = '') => {
rtn = speakeasy.totp.verify({
secret,
encoding: 'base32',
- token
+ token,
})
}
+
return rtn
}
@@ -153,5 +153,5 @@ module.exports = {
jwtDecode,
createJWT,
validateAuth,
- check2Fa
+ check2Fa,
}
diff --git a/src/fireedge/src/server/utils/logger.js b/src/fireedge/src/server/utils/logger.js
index 89d89dd064..0abe45f77e 100644
--- a/src/fireedge/src/server/utils/logger.js
+++ b/src/fireedge/src/server/utils/logger.js
@@ -33,8 +33,9 @@ const initLogger = () => {
if (env && env.NODE_ENV && env.NODE_ENV === defaultWebpackMode) {
trans.push(
new transports.Console({
- format: format.simple()
- }))
+ format: format.simple(),
+ })
+ )
} else {
trans.push(
new transports.File({
@@ -44,25 +45,27 @@ const initLogger = () => {
handleExceptions: true,
format: format.simple(),
maxsize: 5242880, // 5MB
- colorize: false
+ colorize: false,
})
)
}
logger = createLogger({
transports: trans,
- exitOnError: false
+ exitOnError: false,
})
logger.stream = {
write: (message = '') => {
writeInLogger(message)
- }
+ },
}
if (env && env.NODE_ENV && env.NODE_ENV === defaultWebpackMode) {
- logger.clear().add(new transports.Console({
- format: format.simple()
- }))
+ logger.clear().add(
+ new transports.Console({
+ format: format.simple(),
+ })
+ )
}
}
}
diff --git a/src/fireedge/src/server/utils/opennebula.js b/src/fireedge/src/server/utils/opennebula.js
index 4e7c9f9e58..f4dcd1f679 100644
--- a/src/fireedge/src/server/utils/opennebula.js
+++ b/src/fireedge/src/server/utils/opennebula.js
@@ -29,7 +29,7 @@ const {
defaultEmptyFunction,
defaultConfigParseXML,
defaultNamespace,
- defaultMessageProblemOpennebula
+ defaultMessageProblemOpennebula,
} = require('./constants/defaults')
const { getFireedgeConfig } = require('./yml')
@@ -44,9 +44,11 @@ const regexRemoveBlanks = /\s+/gi
// eslint-disable-next-line no-control-regex
const regexANSIColor = /\u001b\[.*?m/gi
// regex string with CSV format
-const csvFormat = /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*)*$/
+const csvFormat =
+ /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*)*$/
// regex sanitize string CSV formated
-const csvSanitize = /(?!\s*$)\s*(?:'([^'\\]*(?:\\[\S\s][^'\\]*)*)'|"([^"\\]*(?:\\[\S\s][^"\\]*)*)"|([^,'"\s\\]*(?:\s+[^,'"\s\\]+)*))\s*(?:,|$)/g
+const csvSanitize =
+ /(?!\s*$)\s*(?:'([^'\\]*(?:\\[\S\s][^'\\]*)*)'|"([^"\\]*(?:\\[\S\s][^"\\]*)*)"|([^,'"\s\\]*(?:\s+[^,'"\s\\]+)*))\s*(?:,|$)/g
// regex single quote
const singleQuote = /\\'/g
// regex double quote
@@ -73,7 +75,7 @@ const xml2json = (xml = '', callback = defaultEmptyFunction) => {
rtn = [error]
}
- // eslint-disable-next-line standard/no-callback-literal
+ // eslint-disable-next-line node/no-callback-literal
callback(...rtn)
}
@@ -84,10 +86,20 @@ const xml2json = (xml = '', callback = defaultEmptyFunction) => {
* @param {string} action - action (only valid i the action terminate in .info)
* @param {Array} parameters - parameters of xmlrpc. If parameters[0] >=0 is a id of resource
*/
-const fillResourceforHookConnection = (username = '', action = '', parameters = '') => {
+const fillResourceforHookConnection = (
+ username = '',
+ action = '',
+ parameters = ''
+) => {
let match
// parameters[0] is the resource ID
- if (username && action && (match = action.match(regexInfoAction)) && match[1] && parameters[0] >= 0) {
+ if (
+ username &&
+ action &&
+ (match = action.match(regexInfoAction)) &&
+ match[1] &&
+ parameters[0] >= 0
+ ) {
if (global && !global.users) {
global.users = {}
}
@@ -121,7 +133,12 @@ const opennebulaConnect = (username = '', password = '', zoneURL = '') => {
xmlClient = rpc.createClient(zoneURL)
}
if (xmlClient && xmlClient.methodCall) {
- rtn = (action = '', parameters = [], callback = () => undefined, fillHookResource = true) => {
+ rtn = (
+ action = '',
+ parameters = [],
+ callback = () => undefined,
+ fillHookResource = true
+ ) => {
if (action && parameters && Array.isArray(parameters) && callback) {
// user config
const appConfig = getFireedgeConfig()
@@ -135,6 +152,7 @@ const opennebulaConnect = (username = '', password = '', zoneURL = '') => {
xml2json(err.body, (error, result) => {
if (error) {
callback(error, undefined) // error parse xml
+
return
}
if (
@@ -148,16 +166,23 @@ const opennebulaConnect = (username = '', password = '', zoneURL = '') => {
result.methodResponse.fault.value.struct.member
)
) {
- const errorData = result.methodResponse.fault.value.struct.member.find(
- element => element.value && element.value.string
- )
+ const errorData =
+ result.methodResponse.fault.value.struct.member.find(
+ (element) => element.value && element.value.string
+ )
if (errorData) {
// success
- fillHookResource && fillResourceforHookConnection(username, action, parameters)
+ fillHookResource &&
+ fillResourceforHookConnection(
+ username,
+ action,
+ parameters
+ )
callback(undefined, errorData.value.string)
}
}
})
+
return
} else if (value && value[0] && value[1]) {
let messageCall
@@ -170,15 +195,24 @@ const opennebulaConnect = (username = '', password = '', zoneURL = '') => {
xml2json(messageCall, (error, result) => {
if (error) {
callback(error, undefined) // error parse xml
+
return
}
// success
- fillHookResource && fillResourceforHookConnection(username, action, parameters)
+ fillHookResource &&
+ fillResourceforHookConnection(
+ username,
+ action,
+ parameters
+ )
callback(
undefined,
- error === null && !String(result) ? JSON.stringify(messageCall) : result
+ error === null && !String(result)
+ ? JSON.stringify(messageCall)
+ : result
)
})
+
return
}
}
@@ -189,6 +223,7 @@ const opennebulaConnect = (username = '', password = '', zoneURL = '') => {
}
}
}
+
return rtn
}
@@ -222,7 +257,7 @@ const getMethodForOpennebulaCommand = () => {
const rtn = []
if (commandsParams) {
const commands = Object.keys(commandsParams)
- commands.forEach(command => {
+ commands.forEach((command) => {
if (command && command.length) {
const commandString = command.split('.')
if (!rtn.includes(commandString[1])) {
@@ -231,6 +266,7 @@ const getMethodForOpennebulaCommand = () => {
}
})
}
+
return rtn
}
@@ -271,11 +307,11 @@ const getAllowedQueryParams = () => {
const allowedQuerys = Object.keys(commandsParams)
if (from && from.query) {
const { query } = from
- allowedQuerys.forEach(allowedQuery => {
+ allowedQuerys.forEach((allowedQuery) => {
const command = commandsParams[allowedQuery]
if (command && command.params) {
const internalParams = Object.keys(command.params)
- internalParams.forEach(internalParam => {
+ internalParams.forEach((internalParam) => {
if (
command.params[internalParam] &&
command.params[internalParam].from &&
@@ -288,6 +324,7 @@ const getAllowedQueryParams = () => {
}
})
}
+
return rtn
}
@@ -300,7 +337,7 @@ const getRouteForOpennebulaCommand = () => {
const rtn = []
if (commandsParams) {
const commands = Object.keys(commandsParams)
- commands.forEach(command => {
+ commands.forEach((command) => {
if (command && command.length) {
let commandString = command.split('.')
commandString = commandString[0]
@@ -311,7 +348,7 @@ const getRouteForOpennebulaCommand = () => {
* @param {object} rtnCommand - command to validate
* @returns {string} - command
*/
- const finderCommand = rtnCommand =>
+ const finderCommand = (rtnCommand) =>
rtnCommand &&
rtnCommand.endpoint &&
rtnCommand.endpoint === commandString
@@ -321,6 +358,7 @@ const getRouteForOpennebulaCommand = () => {
}
})
}
+
return rtn
}
@@ -330,16 +368,17 @@ const getRouteForOpennebulaCommand = () => {
* @param {object} dataSource - source data
* @returns {boolean} check if exists
*/
-const checkPositionInDataSource = dataSource => {
+const checkPositionInDataSource = (dataSource) => {
let rtn = true
if (dataSource && from) {
const fromKeys = Object.values(from)
- fromKeys.forEach(key => {
+ fromKeys.forEach((key) => {
if (!(key && dataSource && key in dataSource)) {
rtn = false
}
})
}
+
return rtn
}
/**
@@ -365,39 +404,41 @@ const checkOpennebulaCommand = (
commandsParams[command].httpMethod === method
) {
rtn = commandParams
- ? dataSource => {
- let rtnParams = false
- if (dataSource && checkPositionInDataSource(dataSource)) {
- const { params: paramsForCommand } = commandsParams[command]
- const internalParams = []
- Object.keys(paramsForCommand).forEach(param => {
- const parameter = paramsForCommand[param]
- if (
- 'default' in parameter &&
+ ? (dataSource) => {
+ let rtnParams = false
+ if (dataSource && checkPositionInDataSource(dataSource)) {
+ const { params: paramsForCommand } = commandsParams[command]
+ const internalParams = []
+ Object.keys(paramsForCommand).forEach((param) => {
+ const parameter = paramsForCommand[param]
+ if (
+ 'default' in parameter &&
'from' in parameter &&
parameter.from in dataSource &&
param in dataSource[parameter.from] &&
dataSource[parameter.from][param]
- ) {
- internalParams.push(
- upcast.to(
- dataSource[parameter.from][param],
- upcast.type(parameter.default)
+ ) {
+ internalParams.push(
+ upcast.to(
+ dataSource[parameter.from][param],
+ upcast.type(parameter.default)
+ )
)
- )
- } else {
- internalParams.push(parameter.default)
+ } else {
+ internalParams.push(parameter.default)
+ }
+ })
+ if (internalParams) {
+ rtnParams = internalParams
}
- })
- if (internalParams) {
- rtnParams = internalParams
}
+
+ return rtnParams
}
- return rtnParams
- }
: commandsParams[command]
}
}
+
return rtn
}
@@ -414,7 +455,7 @@ const getDefaultParamsOfOpennebulaCommand = (command = '', httpCode = '') => {
const getDefaultValues = checkOpennebulaCommand(command, httpCode, false)
if (getDefaultValues && getDefaultValues.params) {
const defaultParams = Object.keys(getDefaultValues.params)
- defaultParams.forEach(defaultParam => {
+ defaultParams.forEach((defaultParam) => {
if (
getDefaultValues.params &&
defaultParam &&
@@ -426,6 +467,7 @@ const getDefaultParamsOfOpennebulaCommand = (command = '', httpCode = '') => {
})
}
}
+
return rtn
}
@@ -445,15 +487,17 @@ const generateNewResourceTemplate = (
wrapper = 'SUNSTONE=[%1$s]'
) => {
const positions = Object.entries({ ...current, ...addPositions })
- .filter(position => {
+ .filter((position) => {
let element = position
if (Array.isArray(position)) {
element = position[0]
}
+
return element && !removedPositions.includes(element)
})
.map(([position, value]) => `${position}=${value}`)
.join(', ')
+
return sprintf(wrapper, positions)
}
@@ -468,21 +512,25 @@ const consoleParseToString = (stringConsole = '', excludeRegexs = []) => {
const rtn = []
if (stringConsole) {
const lines = stringConsole.split(regexLine)
- lines.forEach(line => {
+ lines.forEach((line) => {
let pass = true
if (Array.isArray(excludeRegexs)) {
- excludeRegexs.forEach(rex => {
+ excludeRegexs.forEach((rex) => {
if (rex.test(line)) {
pass = false
}
})
}
- line = line.replace(regexRemoveBlanks, ' ').replace(regexANSIColor, '').trim()
+ line = line
+ .replace(regexRemoveBlanks, ' ')
+ .replace(regexANSIColor, '')
+ .trim()
if (line && pass) {
rtn.push(line)
}
})
}
+
return rtn
}
@@ -495,14 +543,23 @@ const consoleParseToString = (stringConsole = '', excludeRegexs = []) => {
*/
const consoleParseToJSON = (arrayConsole = [], regexHeader = '') => {
let rtn = []
- if (regexHeader && Array.isArray(arrayConsole) && arrayConsole[0] && regexHeader.test(arrayConsole[0])) {
+ if (
+ regexHeader &&
+ Array.isArray(arrayConsole) &&
+ arrayConsole[0] &&
+ regexHeader.test(arrayConsole[0])
+ ) {
const header = arrayConsole[0].split(',')
arrayConsole.forEach((row = '', i = 0) => {
if (row && i > 0) {
const explodeRow = CSVtoArray(row)
rtn.push(
explodeRow.map((value, index) => {
- return { [header[index]]: stringWrappedBrakets.test(value) ? CSVtoArray(value.replace(brakets, '')) : value }
+ return {
+ [header[index]]: stringWrappedBrakets.test(value)
+ ? CSVtoArray(value.replace(brakets, ''))
+ : value,
+ }
})
)
}
@@ -510,6 +567,7 @@ const consoleParseToJSON = (arrayConsole = [], regexHeader = '') => {
} else {
rtn = arrayConsole
}
+
return rtn
}
@@ -521,22 +579,24 @@ const consoleParseToJSON = (arrayConsole = [], regexHeader = '') => {
*/
const CSVtoArray = (text = '') => {
const rtn = []
- if (csvFormat.test(text)) { // if input string is not well formed CSV string.
- text.replace(csvSanitize,
- (m0, m1, m2, m3) => {
- if (m1 !== undefined) {
- rtn.push(m1.replace(singleQuote, "'"))
- } else if (m2 !== undefined) {
- rtn.push(m2.replace(doubleQuote, '"'))
- } else if (m3 !== undefined) {
- rtn.push(m3)
- }
- return ''
- })
+ if (csvFormat.test(text)) {
+ // if input string is not well formed CSV string.
+ text.replace(csvSanitize, (m0, m1, m2, m3) => {
+ if (m1 !== undefined) {
+ rtn.push(m1.replace(singleQuote, "'"))
+ } else if (m2 !== undefined) {
+ rtn.push(m2.replace(doubleQuote, '"'))
+ } else if (m3 !== undefined) {
+ rtn.push(m3)
+ }
+
+ return ''
+ })
if (lastValueRegexCsv.test(text)) {
rtn.push('')
}
}
+
return rtn
}
@@ -550,12 +610,13 @@ const CSVtoArray = (text = '') => {
const sensitiveDataRemoverConfig = (config = {}, keys = []) => {
const rtn = config
if (Array.isArray(keys)) {
- keys.forEach(key => {
+ keys.forEach((key) => {
if (Object.hasOwnProperty.call(config, key)) {
delete rtn[key]
}
})
}
+
return config
}
@@ -574,5 +635,5 @@ module.exports = {
xml2json,
consoleParseToString,
consoleParseToJSON,
- sensitiveDataRemoverConfig
+ sensitiveDataRemoverConfig,
}
diff --git a/src/fireedge/src/server/utils/server.js b/src/fireedge/src/server/utils/server.js
index b93267ecc0..0c19963b70 100644
--- a/src/fireedge/src/server/utils/server.js
+++ b/src/fireedge/src/server/utils/server.js
@@ -19,9 +19,23 @@ const { Map } = require('immutable')
const multer = require('multer')
const { global } = require('window-or-global')
const { resolve } = require('path')
-// eslint-disable-next-line node/no-deprecated-api
-const { createCipheriv, createCipher, createDecipheriv, createDecipher, createHash } = require('crypto')
-const { existsSync, readFileSync, createWriteStream, readdirSync, statSync, removeSync } = require('fs-extra')
+const {
+ createCipheriv,
+ // eslint-disable-next-line node/no-deprecated-api
+ createCipher,
+ createDecipheriv,
+ // eslint-disable-next-line node/no-deprecated-api
+ createDecipher,
+ createHash,
+} = require('crypto')
+const {
+ existsSync,
+ readFileSync,
+ createWriteStream,
+ readdirSync,
+ statSync,
+ removeSync,
+} = require('fs-extra')
const { internalServerError } = require('./constants/http-codes')
const { messageTerminal } = require('server/utils/general')
const { validateAuth } = require('server/utils/jwt')
@@ -51,7 +65,7 @@ const {
defaultSunstoneConfig,
defaultProvisionPath,
defaultProvisionConfig,
- defaultEmptyFunction
+ defaultEmptyFunction,
} = require('./constants/defaults')
const upload = multer({ dest: '/tmp' })
@@ -70,7 +84,7 @@ let key = ''
const setFunctionRoute = (method, endpoint, action) => ({
httpMethod: method,
endpoint,
- action
+ action,
})
/**
@@ -85,7 +99,9 @@ const setApiRoutes = (routes = {}, path = '') => {
if (Object.keys(routes).length > 0 && routes.constructor === Object) {
Object.keys(routes).forEach((route) => {
rtn.push(
- setFunctionRoute(route, path,
+ setFunctionRoute(
+ route,
+ path,
(req, res, next, connection, userId, user) => {
addFunctionAsRoute(req, res, next, routes[route], user, connection)
}
@@ -93,6 +109,7 @@ const setApiRoutes = (routes = {}, path = '') => {
)
})
}
+
return rtn
}
@@ -136,12 +153,15 @@ const parseFiles = (files = []) => {
let rtn
if (files && Array.isArray(files)) {
rtn = {}
- files.forEach(file => {
+ files.forEach((file) => {
if (file.fieldname) {
- rtn[file.fieldname] ? rtn[file.fieldname].push(file) : rtn[file.fieldname] = [file]
+ rtn[file.fieldname]
+ ? rtn[file.fieldname].push(file)
+ : (rtn[file.fieldname] = [file])
}
})
}
+
return rtn
}
@@ -156,14 +176,34 @@ const parseFiles = (files = []) => {
* @param {Function} oneConnection - function one XMLRPC
* @param {string} index - resource index
*/
-const addFunctionAsRoute = (req = {}, res = {}, next = defaultEmptyFunction, routes = {}, user = {}, oneConnection = defaultEmptyFunction, index = 0) => {
+const addFunctionAsRoute = (
+ req = {},
+ res = {},
+ next = defaultEmptyFunction,
+ routes = {},
+ user = {},
+ oneConnection = defaultEmptyFunction,
+ index = 0
+) => {
if (req && req.serverDataSource && res && next && routes) {
const serverDataSource = req.serverDataSource
const resources = Object.keys(serverDataSource[fromData.resource])
- const route = routes[`${serverDataSource[fromData.resource][resources[index]]}`.toLowerCase()]
- if (fromData && fromData.resource && serverDataSource[fromData.resource] && route) {
+ const route =
+ routes[
+ `${serverDataSource[fromData.resource][resources[index]]}`.toLowerCase()
+ ]
+ if (
+ fromData &&
+ fromData.resource &&
+ serverDataSource[fromData.resource] &&
+ route
+ ) {
if (Object.keys(route).length > 0 && route.constructor === Object) {
- if (route.action && route.params && typeof route.action === 'function') {
+ if (
+ route.action &&
+ route.params &&
+ typeof route.action === 'function'
+ ) {
const uploadFiles = getRequestFiles(route.params)
if (uploadFiles && uploadFiles.length) {
const files = upload.array(uploadFiles)
@@ -174,22 +214,46 @@ const addFunctionAsRoute = (req = {}, res = {}, next = defaultEmptyFunction, rou
messageTerminal({
color: 'red',
message: 'Error: %s',
- error: errorData
+ error: errorData,
})
}
const dataSources = {
[fromData.resource]: serverDataSource[fromData.resource],
[fromData.query]: req.query,
- [fromData.postBody]: req.body
+ [fromData.postBody]: req.body,
}
dataSources.files = parseFiles(req && req.files)
- executeAction(route.action, res, next, route.params, dataSources, user, oneConnection)
+ executeAction(
+ route.action,
+ res,
+ next,
+ route.params,
+ dataSources,
+ user,
+ oneConnection
+ )
})
} else {
- executeAction(route.action, res, next, route.params, serverDataSource, user, oneConnection)
+ executeAction(
+ route.action,
+ res,
+ next,
+ route.params,
+ serverDataSource,
+ user,
+ oneConnection
+ )
}
} else {
- addFunctionAsRoute(req, res, next, route, user, oneConnection, index + 1)
+ addFunctionAsRoute(
+ req,
+ res,
+ next,
+ route,
+ user,
+ oneConnection,
+ index + 1
+ )
}
} else {
next()
@@ -209,10 +273,14 @@ const addFunctionAsRoute = (req = {}, res = {}, next = defaultEmptyFunction, rou
*/
const validateServerIsSecure = () => {
const folder = 'cert/'
- const dirCerts = env && env.NODE_ENV === defaultWebpackMode ? ['../', '../', '../', folder] : ['../', folder]
+ const dirCerts =
+ env && env.NODE_ENV === defaultWebpackMode
+ ? ['../', '../', '../', folder]
+ : ['../', folder]
const pathfile = resolve(__dirname, ...dirCerts)
cert = `${pathfile}/cert.pem`
key = `${pathfile}/key.pem`
+
return existsSync && key && cert && existsSync(key) && existsSync(cert)
}
/**
@@ -255,6 +323,7 @@ const httpResponse = (response = null, data = '', message = '', file = '') => {
rtn.data && delete rtn.data
rtn.file = file
}
+
return rtn
}
@@ -266,13 +335,10 @@ const httpResponse = (response = null, data = '', message = '', file = '') => {
*/
const getQueryData = (server = {}) => {
let rtn = {}
- if (
- server &&
- server.handshake &&
- server.handshake.query
- ) {
+ if (server && server.handshake && server.handshake.query) {
rtn = server.handshake.query
}
+
return rtn
}
@@ -287,9 +353,10 @@ const validateAuthWebsocket = (server = {}) => {
const { token } = getQueryData(server)
if (token) {
rtn = validateAuth({
- headers: { authorization: token }
+ headers: { authorization: token },
})
}
+
return rtn
}
@@ -302,6 +369,7 @@ const validateAuthWebsocket = (server = {}) => {
const getResourceDataForRequest = (server = {}) => {
const { id, resource } = getQueryData(server)
const { aud: username } = validateAuthWebsocket(server)
+
return { id, resource, username }
}
@@ -311,7 +379,10 @@ const getResourceDataForRequest = (server = {}) => {
* @param {object} server - express app
* @param {Function} next - express stepper
*/
-const middlewareValidateResourceForHookConnection = (server = {}, next = () => undefined) => {
+const middlewareValidateResourceForHookConnection = (
+ server = {},
+ next = () => undefined
+) => {
const { id, resource, username } = getResourceDataForRequest(server)
if (
id &&
@@ -322,7 +393,8 @@ const middlewareValidateResourceForHookConnection = (server = {}, next = () => u
global.users[username] &&
global.users[username].resourcesHooks &&
global.users[username].resourcesHooks[resource.toLowerCase()] >= 0 &&
- global.users[username].resourcesHooks[resource.toLowerCase()] === parseInt(id, 10)
+ global.users[username].resourcesHooks[resource.toLowerCase()] ===
+ parseInt(id, 10)
) {
next()
} else {
@@ -336,7 +408,10 @@ const middlewareValidateResourceForHookConnection = (server = {}, next = () => u
* @param {object} server - express app
* @param {Function} next - express stepper
*/
-const middlewareValidateAuthWebsocket = (server = {}, next = () => undefined) => {
+const middlewareValidateAuthWebsocket = (
+ server = {},
+ next = () => undefined
+) => {
if (validateAuthWebsocket(server)) {
next()
} else {
@@ -356,7 +431,9 @@ const encrypt = (data = '', key = '', iv = '') => {
let rtn
if (data && key) {
try {
- const cipher = iv ? createCipheriv(defaultTypeCrypto, key, iv) : createCipher(defaultTypeCrypto, key)
+ const cipher = iv
+ ? createCipheriv(defaultTypeCrypto, key, iv)
+ : createCipher(defaultTypeCrypto, key)
let encryptData = cipher.update(data, 'ascii', 'base64')
encryptData += cipher.final('base64')
rtn = encryptData
@@ -366,10 +443,11 @@ const encrypt = (data = '', key = '', iv = '') => {
messageTerminal({
color: 'red',
message: 'Error: %s',
- error: errorData
+ error: errorData,
})
}
}
+
return rtn
}
@@ -385,7 +463,9 @@ const decrypt = (data = '', key = '', iv = '') => {
let rtn
if (data && key) {
try {
- const cipher = iv ? createDecipheriv(defaultTypeCrypto, key, iv) : createDecipher(defaultTypeCrypto, key)
+ const cipher = iv
+ ? createDecipheriv(defaultTypeCrypto, key, iv)
+ : createDecipher(defaultTypeCrypto, key)
let decryptData = cipher.update(data, 'base64', 'ascii')
decryptData += cipher.final('ascii')
rtn = decryptData
@@ -395,10 +475,11 @@ const decrypt = (data = '', key = '', iv = '') => {
messageTerminal({
color: 'red',
message: 'Error: %s',
- error: errorData
+ error: errorData,
})
}
}
+
return rtn
}
@@ -410,7 +491,11 @@ const decrypt = (data = '', key = '', iv = '') => {
* @param {Function} error - function executed when file no exists
* @returns {boolean} validate if file exists
*/
-const existsFile = (path = '', success = defaultEmptyFunction, error = defaultEmptyFunction) => {
+const existsFile = (
+ path = '',
+ success = defaultEmptyFunction,
+ error = defaultEmptyFunction
+) => {
let rtn = false
let file
let errorData
@@ -426,7 +511,7 @@ const existsFile = (path = '', success = defaultEmptyFunction, error = defaultEm
messageTerminal({
color: 'red',
message: 'Error: %s',
- error: errorData
+ error: errorData,
})
}
if (rtn) {
@@ -434,6 +519,7 @@ const existsFile = (path = '', success = defaultEmptyFunction, error = defaultEm
} else {
error(errorData)
}
+
return rtn
}
@@ -446,7 +532,12 @@ const existsFile = (path = '', success = defaultEmptyFunction, error = defaultEm
* @param {Function} error - run function when file creation failed
* @returns {boolean} check if file is created
*/
-const createFile = (path = '', data = '', callback = () => undefined, error = () => undefined) => {
+const createFile = (
+ path = '',
+ data = '',
+ callback = () => undefined,
+ error = () => undefined
+) => {
let rtn = false
try {
const stream = createWriteStream(path)
@@ -456,6 +547,7 @@ const createFile = (path = '', data = '', callback = () => undefined, error = ()
} catch (err) {
error(err)
}
+
return rtn
}
@@ -470,22 +562,26 @@ const genFireedgeKey = () => {
uuidv4 = uuidv4.replace(/-/g, '').toUpperCase()
existsFile(
global.paths.FIREEDGE_KEY_PATH,
- filedata => {
+ (filedata) => {
if (filedata) {
uuidv4 = filedata
}
},
() => {
createFile(
- global.paths.FIREEDGE_KEY_PATH, uuidv4.replace(/-/g, ''), () => undefined, err => {
+ global.paths.FIREEDGE_KEY_PATH,
+ uuidv4.replace(/-/g, ''),
+ () => undefined,
+ (err) => {
const errorData = (err && err.message) || ''
writeInLogger(errorData)
messageTerminal({
color: 'red',
message: 'Error: %s',
- error: errorData
+ error: errorData,
})
- })
+ }
+ )
}
)
}
@@ -504,6 +600,7 @@ const replaceEscapeSequence = (text = '') => {
if (text) {
rtn = text.replace(/\r|\n/g, '')
}
+
return rtn
}
@@ -515,30 +612,36 @@ const replaceEscapeSequence = (text = '') => {
const getSunstoneAuth = () => {
let rtn
if (global && global.paths && global.paths.SUNSTONE_AUTH_PATH) {
- existsFile(global.paths.SUNSTONE_AUTH_PATH,
- filedata => {
+ existsFile(
+ global.paths.SUNSTONE_AUTH_PATH,
+ (filedata) => {
if (filedata) {
const serverAdminData = filedata.split(':')
if (serverAdminData[0] && serverAdminData[1]) {
const { hash, digest } = defaultHash
const username = replaceEscapeSequence(serverAdminData[0])
- const password = createHash(hash).update(replaceEscapeSequence(serverAdminData[1])).digest(digest)
+ const password = createHash(hash)
+ .update(replaceEscapeSequence(serverAdminData[1]))
+ .digest(digest)
const key = password.substring(0, 32)
const iv = key.substring(0, 16)
rtn = { username, key, iv }
}
}
- }, err => {
+ },
+ (err) => {
const errorData = err.message || ''
const config = {
color: 'red',
message: 'Error: %s',
- error: errorData
+ error: errorData,
}
writeInLogger(errorData)
messageTerminal(config)
- })
+ }
+ )
}
+
return rtn
}
@@ -551,15 +654,17 @@ const getSunstoneAuth = () => {
*/
const getDataZone = (zone = '0', configuredZones) => {
let rtn
- const zones = (global && global.zones) || configuredZones || defaultOpennebulaZones
+ const zones =
+ (global && global.zones) || configuredZones || defaultOpennebulaZones
if (zones && Array.isArray(zones)) {
rtn = zones[0]
if (zone !== null) {
rtn = zones.find(
- zn => zn && zn.id !== undefined && String(zn.id) === zone
+ (zn) => zn && zn.id !== undefined && String(zn.id) === zone
)
}
}
+
return rtn
}
@@ -571,8 +676,14 @@ const genPathResources = () => {
const ONE_LOCATION = env && env.ONE_LOCATION
const LOG_LOCATION = !ONE_LOCATION ? defaultLogPath : `${ONE_LOCATION}/var`
- const SHARE_LOCATION = !ONE_LOCATION ? defaultSharePath : `${ONE_LOCATION}/share`
- const SYSTEM_LOCATION = (devMode && resolve(__dirname, '../../client')) || (!ONE_LOCATION ? resolve(defaultSystemPath) : resolve(`${ONE_LOCATION}${defaultSourceSystemPath}`))
+ const SHARE_LOCATION = !ONE_LOCATION
+ ? defaultSharePath
+ : `${ONE_LOCATION}/share`
+ const SYSTEM_LOCATION =
+ (devMode && resolve(__dirname, '../../client')) ||
+ (!ONE_LOCATION
+ ? resolve(defaultSystemPath)
+ : resolve(`${ONE_LOCATION}${defaultSourceSystemPath}`))
const VAR_LOCATION = !ONE_LOCATION ? defaultVarPath : `${ONE_LOCATION}/var`
const ETC_LOCATION = !ONE_LOCATION ? defaultEtcPath : `${ONE_LOCATION}/etc`
const VMRC_LOCATION = !ONE_LOCATION ? defaultVarPath : ONE_LOCATION
@@ -633,11 +744,16 @@ const genPathResources = () => {
* @returns {Array} - params file
*/
const getRequestFiles = (params = {}) => {
- if (params && Object.keys(params).length > 0 && params.constructor === Object) {
+ if (
+ params &&
+ Object.keys(params).length > 0 &&
+ params.constructor === Object
+ ) {
const arrayParams = Object.keys(params)
const fileParams = arrayParams.filter((key = '') => {
return key && params[key] && params[key].from === 'files'
})
+
return fileParams
}
}
@@ -651,13 +767,18 @@ const getRequestFiles = (params = {}) => {
*/
const getRequestParameters = (params = {}, req = {}) => {
const rtn = {}
- if (params && Object.keys(params).length > 0 && params.constructor === Object) {
+ if (
+ params &&
+ Object.keys(params).length > 0 &&
+ params.constructor === Object
+ ) {
Object.entries(params).forEach(([param, value]) => {
if (param && value && value.from && req[value.from]) {
rtn[param] = value.name ? req[value.from][value.name] : req[value.from]
}
})
}
+
return rtn
}
@@ -671,7 +792,7 @@ const getRequestParameters = (params = {}, req = {}) => {
const defaultError = (err = '', message = 'Error: %s') => ({
color: 'red',
message,
- error: err || ''
+ error: err || '',
})
/**
@@ -686,7 +807,7 @@ const getFiles = (path = '', recursive = false, files = []) => {
if (path) {
try {
const dirs = readdirSync(path)
- dirs.forEach(dir => {
+ dirs.forEach((dir) => {
const name = `${path}/${dir}`
if (recursive && statSync(name).isDirectory()) {
const internal = getFiles(name, recursive)
@@ -705,6 +826,7 @@ const getFiles = (path = '', recursive = false, files = []) => {
messageTerminal(defaultError(errorData))
}
}
+
return files
}
@@ -716,13 +838,17 @@ const getFiles = (path = '', recursive = false, files = []) => {
* @param {Function} errorCallback - run this function if it cant read directory
* @returns {Array} array of pathfiles
*/
-const getFilesbyEXT = (dir = '', ext = '', errorCallback = defaultEmptyFunction) => {
+const getFilesbyEXT = (
+ dir = '',
+ ext = '',
+ errorCallback = defaultEmptyFunction
+) => {
const pathFiles = []
if (dir && ext) {
const exp = new RegExp('\\w*\\.' + ext + '+$\\b', 'gi')
try {
const files = readdirSync(dir)
- files.forEach(file => {
+ files.forEach((file) => {
const name = `${dir}/${file}`
if (statSync(name).isDirectory()) {
getFiles(name)
@@ -739,6 +865,7 @@ const getFilesbyEXT = (dir = '', ext = '', errorCallback = defaultEmptyFunction)
errorCallback(errorMsg)
}
}
+
return pathFiles
}
@@ -754,7 +881,7 @@ const getDirectories = (dir = '', errorCallback = () => undefined) => {
if (dir) {
try {
const files = readdirSync(dir)
- files.forEach(file => {
+ files.forEach((file) => {
const name = `${dir}/${file}`
if (statSync(name).isDirectory()) {
directories.push({ filename: file, path: name })
@@ -767,6 +894,7 @@ const getDirectories = (dir = '', errorCallback = () => undefined) => {
errorCallback(errorMsg)
}
}
+
return directories
}
@@ -791,6 +919,7 @@ const parsePostData = (postData = {}) => {
rtn[key] = value
}
})
+
return rtn
}
@@ -808,7 +937,7 @@ const addPrependCommand = (command = '', resource = '', prepend = '') => {
let newRsc = rsc
if (prepend) {
- const splitPrepend = prepend.split(' ').filter(el => el !== '')
+ const splitPrepend = prepend.split(' ').filter((el) => el !== '')
newCommand = splitPrepend[0]
// remove command
splitPrepend.shift()
@@ -821,7 +950,7 @@ const addPrependCommand = (command = '', resource = '', prepend = '') => {
return {
cmd: newCommand,
- rsc: newRsc
+ rsc: newRsc,
}
}
@@ -834,7 +963,12 @@ const addPrependCommand = (command = '', resource = '', prepend = '') => {
* @param {object} options - optional params for the command
* @returns {object} CLI output
*/
-const executeCommand = (command = '', resource = '', prependCommand = '', options = {}) => {
+const executeCommand = (
+ command = '',
+ resource = '',
+ prependCommand = '',
+ options = {}
+) => {
let rtn = { success: false, data: null }
const { cmd, rsc } = addPrependCommand(command, resource, prependCommand)
const execute = spawnSync(cmd, rsc, options)
@@ -845,13 +979,11 @@ const executeCommand = (command = '', resource = '', prependCommand = '', option
} else if (execute.stderr && execute.stderr.length > 0) {
rtn = { success: false, data: execute.stderr.toString() }
messageTerminal(
- defaultError(
- execute.stderr.toString(),
- 'Error command: %s'
- )
+ defaultError(execute.stderr.toString(), 'Error command: %s')
)
}
}
+
return rtn
}
/**
@@ -878,6 +1010,7 @@ const removeFile = (path = '') => {
messageTerminal(defaultError(error && error.message))
}
}
+
return rtn
}
@@ -896,12 +1029,21 @@ const executeCommandAsync = (
callbacks = {
err: defaultEmptyFunction,
out: defaultEmptyFunction,
- close: defaultEmptyFunction
+ close: defaultEmptyFunction,
}
) => {
- const err = callbacks && callbacks.err && typeof callbacks.err === 'function' ? callbacks.err : defaultEmptyFunction
- const out = callbacks && callbacks.out && typeof callbacks.out === 'function' ? callbacks.out : defaultEmptyFunction
- const close = callbacks && callbacks.close && typeof callbacks.close === 'function' ? callbacks.close : defaultEmptyFunction
+ const err =
+ callbacks && callbacks.err && typeof callbacks.err === 'function'
+ ? callbacks.err
+ : defaultEmptyFunction
+ const out =
+ callbacks && callbacks.out && typeof callbacks.out === 'function'
+ ? callbacks.out
+ : defaultEmptyFunction
+ const close =
+ callbacks && callbacks.close && typeof callbacks.close === 'function'
+ ? callbacks.close
+ : defaultEmptyFunction
const { cmd, rsc } = addPrependCommand(command, resource, prependCommand)
@@ -915,7 +1057,7 @@ const executeCommandAsync = (
out(data)
})
- execute.on('error', error => {
+ execute.on('error', (error) => {
messageTerminal(defaultError(error && error.message, 'Error command: %s'))
})
@@ -959,5 +1101,5 @@ module.exports = {
executeCommand,
executeCommandAsync,
checkValidApp,
- removeFile
+ removeFile,
}
diff --git a/src/fireedge/src/server/utils/yml.js b/src/fireedge/src/server/utils/yml.js
index f1f6558200..fede5aeca7 100644
--- a/src/fireedge/src/server/utils/yml.js
+++ b/src/fireedge/src/server/utils/yml.js
@@ -17,12 +17,19 @@
const { env } = require('process')
const { resolve } = require('path')
const { parse } = require('yaml')
-const { defaultConfigFile, defaultWebpackMode, defaultSunstoneConfig, defaultProvisionConfig, defaultEmptyFunction } = require('./constants/defaults')
+const {
+ defaultConfigFile,
+ defaultWebpackMode,
+ defaultSunstoneConfig,
+ defaultProvisionConfig,
+ defaultEmptyFunction,
+} = require('./constants/defaults')
const { existsFile, defaultError } = require('server/utils/server')
const { messageTerminal } = require('server/utils/general')
const { global } = require('window-or-global')
-const defaultPath = env && env.NODE_ENV === defaultWebpackMode ? ['../', '../', '../'] : ['../']
+const defaultPath =
+ env && env.NODE_ENV === defaultWebpackMode ? ['../', '../', '../'] : ['../']
const basePaths = [__dirname, ...defaultPath, 'etc']
/**
@@ -34,10 +41,8 @@ const basePaths = [__dirname, ...defaultPath, 'etc']
*/
const readYAMLFile = (pathfile = '', errorFunction = defaultEmptyFunction) => {
let rtn = {}
- const err = error => {
- messageTerminal(
- defaultError(error)
- )
+ const err = (error) => {
+ messageTerminal(defaultError(error))
if (typeof errorFunction === 'function') {
errorFunction(error)
}
@@ -45,7 +50,7 @@ const readYAMLFile = (pathfile = '', errorFunction = defaultEmptyFunction) => {
if (pathfile) {
existsFile(
pathfile,
- filedata => {
+ (filedata) => {
try {
rtn = parse(filedata)
} catch (error) {
@@ -55,6 +60,7 @@ const readYAMLFile = (pathfile = '', errorFunction = defaultEmptyFunction) => {
err
)
}
+
return rtn
}
@@ -65,7 +71,10 @@ const readYAMLFile = (pathfile = '', errorFunction = defaultEmptyFunction) => {
* @returns {object} fireedge configurations
*/
const getFireedgeConfig = (callbackError = defaultEmptyFunction) => {
- const pathfile = (global && global.paths && global.paths.FIREEDGE_CONFIG) || resolve(...basePaths, defaultConfigFile)
+ const pathfile =
+ (global && global.paths && global.paths.FIREEDGE_CONFIG) ||
+ resolve(...basePaths, defaultConfigFile)
+
return readYAMLFile(pathfile, callbackError)
}
@@ -76,7 +85,10 @@ const getFireedgeConfig = (callbackError = defaultEmptyFunction) => {
* @returns {object} sunstone configurations
*/
const getSunstoneConfig = (callbackError = defaultEmptyFunction) => {
- const pathfile = (global && global.paths && global.paths.SUNSTONE_CONFIG) || resolve(...basePaths, 'sunstone', defaultSunstoneConfig)
+ const pathfile =
+ (global && global.paths && global.paths.SUNSTONE_CONFIG) ||
+ resolve(...basePaths, 'sunstone', defaultSunstoneConfig)
+
return readYAMLFile(pathfile, callbackError)
}
@@ -87,12 +99,15 @@ const getSunstoneConfig = (callbackError = defaultEmptyFunction) => {
* @returns {object} provision configurations
*/
const getProvisionConfig = (callbackError = defaultEmptyFunction) => {
- const pathfile = (global && global.paths && global.paths.PROVISION_CONFIG) || resolve(...basePaths, 'provision', defaultProvisionConfig)
+ const pathfile =
+ (global && global.paths && global.paths.PROVISION_CONFIG) ||
+ resolve(...basePaths, 'provision', defaultProvisionConfig)
+
return readYAMLFile(pathfile, callbackError)
}
module.exports = {
getFireedgeConfig,
getSunstoneConfig,
- getProvisionConfig
+ getProvisionConfig,
}