diff --git a/src/fireedge/src/client/components/Tables/Vms/detail.js b/src/fireedge/src/client/components/Tables/Vms/detail.js
index 1eb88e940a..c9555190f7 100644
--- a/src/fireedge/src/client/components/Tables/Vms/detail.js
+++ b/src/fireedge/src/client/components/Tables/Vms/detail.js
@@ -7,7 +7,7 @@ import { useVmApi } from 'client/features/One'
import VmTabs from 'client/components/Tabs/Vm'
-const VmDetail = React.memo(({ id, view = {} }) => {
+const VmDetail = React.memo(({ id }) => {
const { getHooksSocket } = useSocket()
const { getVm } = useVmApi()
@@ -27,21 +27,14 @@ const VmDetail = React.memo(({ id, view = {} }) => {
}
if (error) {
- return
-
-
-
- {`#${ID} - ${NAME}`}
-
-
-
-
Owner: {UNAME}
-
Group: {GNAME}
-
Reschedule: {Helper.booleanToString(+RESCHED)}
-
Locked: {Helper.levelLockToString(LOCK?.LOCKED)}
-
IP: {ips.join(', ') || '--'}
-
Start time: {Helper.timeToString(STIME)}
-
End time: {Helper.timeToString(ETIME)}
-
Host: {hostId ? `#${hostId} ${hostname}` : ''}
-
Cluster: {clusterId ? `#${clusterId} ${clusterName}` : ''}
-
Deploy ID: {DEPLOY_ID}
-
+
)
}
diff --git a/src/fireedge/src/client/components/Tabs/index.js b/src/fireedge/src/client/components/Tabs/index.js
index 43987152ce..922358ec1d 100644
--- a/src/fireedge/src/client/components/Tabs/index.js
+++ b/src/fireedge/src/client/components/Tabs/index.js
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import { Tabs as MTabs, Tab as MTab } from '@material-ui/core'
-const Content = ({ name, renderContent: Content, hidden }) => (
+const Content = ({ name, renderContent: Content, hidden, data }) => (
(
display: hidden ? 'none' : 'block'
}}
>
- {typeof Content === 'function' ? : Content}
+ {typeof Content === 'function' ? : Content}
)
-const Tabs = ({ tabs = [], renderHiddenTabs = false }) => {
+const Tabs = ({ tabs = [], renderHiddenTabs = false, data }) => {
const [tabSelected, setTab] = useState(0)
const renderTabs = useMemo(() => (
setTab(tab)}
>
@@ -52,7 +52,7 @@ const Tabs = ({ tabs = [], renderHiddenTabs = false }) => {
{renderHiddenTabs ? (
renderAllHiddenTabContents
) : (
- (value ?? idx) === tabSelected)} />
+ (value ?? idx) === tabSelected)} />
)}
>
)
@@ -61,13 +61,20 @@ const Tabs = ({ tabs = [], renderHiddenTabs = false }) => {
Tabs.displayName = 'Tabs'
Content.displayName = 'Content'
+Tabs.propTypes = {
+ tabs: PropTypes.array,
+ renderHiddenTabs: PropTypes.bool,
+ data: PropTypes.object
+}
+
Content.propTypes = {
name: PropTypes.string,
renderContent: PropTypes.oneOfType([
PropTypes.object,
PropTypes.func
]),
- hidden: PropTypes.bool
+ hidden: PropTypes.bool,
+ data: PropTypes.object
}
export default Tabs
diff --git a/src/fireedge/src/client/constants/translates.js b/src/fireedge/src/client/constants/translates.js
index 358b06508f..77c4f31b63 100644
--- a/src/fireedge/src/client/constants/translates.js
+++ b/src/fireedge/src/client/constants/translates.js
@@ -145,11 +145,19 @@ module.exports = {
Information: 'Information',
/* general schema */
+ ID: 'ID',
Name: 'Name',
State: 'State',
Description: 'Description',
RegistrationTime: 'Registration time',
StartTime: 'Start time',
+ EndTime: 'End time',
+ Locked: 'Locked',
+
+ /* instances schema */
+ IP: 'IP',
+ Reschedule: 'Reschedule',
+ DeployID: 'Deploy ID',
/* flow schema */
Strategy: 'Strategy',
diff --git a/src/fireedge/src/client/features/Auth/hooks.js b/src/fireedge/src/client/features/Auth/hooks.js
index 22c7550fbb..081decf16d 100644
--- a/src/fireedge/src/client/features/Auth/hooks.js
+++ b/src/fireedge/src/client/features/Auth/hooks.js
@@ -9,7 +9,7 @@ export const useAuth = () => {
const auth = useSelector(state => state.auth, shallowEqual)
const groups = useSelector(state => state.one.groups, shallowEqual)
- const { user, jwt } = auth
+ const { user, jwt, view, views } = auth
const userGroups = [user?.GROUPS?.ID]
.flat()
@@ -18,7 +18,10 @@ export const useAuth = () => {
const isLogged = !!jwt && !!userGroups?.length
- return { ...auth, groups: userGroups, isLogged }
+ const getResourceView = resourceName => views?.[view]
+ ?.find(({ resource_name: name }) => name === resourceName)
+
+ return { ...auth, groups: userGroups, isLogged, getResourceView }
}
export const useAuthApi = () => {
diff --git a/src/fireedge/src/client/features/One/utils.js b/src/fireedge/src/client/features/One/utils.js
index 2ae427dc7b..1d76e153ed 100644
--- a/src/fireedge/src/client/features/One/utils.js
+++ b/src/fireedge/src/client/features/One/utils.js
@@ -23,7 +23,7 @@ export const createAction = (type, service, wrapResult) =>
status === httpCodes.unauthorized.id && dispatch(logout(T.SessionExpired))
- return rejectWithValue(message, data?.message ?? statusText)
+ return rejectWithValue(message ?? data?.data ?? data?.message ?? statusText)
}
}, {
condition: (_, { getState }) => !getState().one.requests[type]
diff --git a/src/fireedge/src/client/features/One/vm/actions.js b/src/fireedge/src/client/features/One/vm/actions.js
index fe9d145fc6..98ed304cf1 100644
--- a/src/fireedge/src/client/features/One/vm/actions.js
+++ b/src/fireedge/src/client/features/One/vm/actions.js
@@ -15,7 +15,7 @@ export const getVms = createAction(
)
export const terminateVm = createAction(
- 'provider/delete',
+ 'vm/delete',
payload => vmService.actionVm({
...payload,
action: {
@@ -24,3 +24,5 @@ export const terminateVm = createAction(
}
})
)
+
+export const changePermissions = createAction('vm/chmod', vmService.changePermissions)
diff --git a/src/fireedge/src/client/features/One/vm/hooks.js b/src/fireedge/src/client/features/One/vm/hooks.js
index 1d72b83bd8..5e2fd7013c 100644
--- a/src/fireedge/src/client/features/One/vm/hooks.js
+++ b/src/fireedge/src/client/features/One/vm/hooks.js
@@ -19,6 +19,7 @@ export const useVmApi = () => {
return {
getVm: id => unwrapDispatch(actions.getVm({ id })),
getVms: options => unwrapDispatch(actions.getVms(options)),
- terminateVm: id => unwrapDispatch(actions.terminateVm({ id }))
+ terminateVm: id => unwrapDispatch(actions.terminateVm({ id })),
+ changePermissions: (id, data) => unwrapDispatch(actions.changePermissions({ id, data }))
}
}
diff --git a/src/fireedge/src/client/features/One/vm/services.js b/src/fireedge/src/client/features/One/vm/services.js
index 1e7c9d90be..c4f69705ef 100644
--- a/src/fireedge/src/client/features/One/vm/services.js
+++ b/src/fireedge/src/client/features/One/vm/services.js
@@ -22,17 +22,30 @@ export const vmService = ({
const command = { name, ...Commands[name] }
return poolRequest(data, command, 'VM')
},
- actionVm: async ({ action, id }) => {
+ actionVm: async ({ id, action }) => {
const name = Actions.VM_ACTION
const { url, options } = requestParams(
- { action, id },
+ { id, action },
{ name, ...Commands[name] }
)
- const res = await RestClient.put(url, options)
+ const res = await RestClient.put(url, options?.data)
if (!res?.id || res?.id !== httpCodes.ok.id) throw res
return res?.data?.VM ?? {}
+ },
+ changePermissions: async ({ id, data }) => {
+ const name = Actions.VM_CHMOD
+ const { url, options } = requestParams(
+ { id, ...data },
+ { name, ...Commands[name] }
+ )
+
+ const res = await RestClient.put(url, options?.data)
+
+ if (!res?.id || res?.id !== httpCodes.ok.id) throw res?.data
+
+ return res
}
})
diff --git a/src/fireedge/src/client/models/Helper.js b/src/fireedge/src/client/models/Helper.js
index aa026d82a7..42a2aec9c0 100644
--- a/src/fireedge/src/client/models/Helper.js
+++ b/src/fireedge/src/client/models/Helper.js
@@ -18,3 +18,23 @@ export const levelLockToString = level => ({
3: 'Admin',
4: 'All'
}[level] || '-')
+
+export const permissionsToOctal = permissions => {
+ const {
+ OWNER_U, OWNER_M, OWNER_A,
+ GROUP_U, GROUP_M, GROUP_A,
+ OTHER_U, OTHER_M, OTHER_A
+ } = permissions
+
+ const getCategoryValue = ([u, m, a]) => (
+ (stringToBoolean(u) ? 4 : 0) +
+ (stringToBoolean(m) ? 2 : 0) +
+ (stringToBoolean(a) ? 1 : 0)
+ )
+
+ return [
+ [OWNER_U, OWNER_M, OWNER_A],
+ [GROUP_U, GROUP_M, GROUP_A],
+ [OTHER_U, OTHER_M, OTHER_A]
+ ].map(getCategoryValue).join('')
+}
diff --git a/src/fireedge/src/client/models/Host.js b/src/fireedge/src/client/models/Host.js
index 20bdfc510f..7687fbe4d7 100644
--- a/src/fireedge/src/client/models/Host.js
+++ b/src/fireedge/src/client/models/Host.js
@@ -7,12 +7,14 @@ export const getAllocatedInfo = ({ HOST_SHARE = {} } = {}) => {
const { CPU_USAGE, TOTAL_CPU, MEM_USAGE, TOTAL_MEM } = HOST_SHARE
const percentCpuUsed = +CPU_USAGE * 100 / +TOTAL_CPU || 0
- const percentCpuLabel = `${CPU_USAGE} / ${TOTAL_CPU} (${Math.round(percentCpuUsed)}%)`
+ const percentCpuLabel = `${CPU_USAGE} / ${TOTAL_CPU}
+ (${Math.round(isFinite(percentCpuUsed) ? percentCpuUsed : '--')}%)`
const percentMemUsed = +MEM_USAGE * 100 / +TOTAL_MEM || 0
const usedMemBytes = prettyBytes(+MEM_USAGE)
const totalMemBytes = prettyBytes(+TOTAL_MEM)
- const percentMemLabel = `${usedMemBytes} / ${totalMemBytes} (${Math.round(percentMemUsed)}%)`
+ const percentMemLabel = `${usedMemBytes} / ${totalMemBytes}
+ (${Math.round(isFinite(percentMemUsed) ? percentMemUsed : '--')}%)`
return {
percentCpuUsed,
diff --git a/src/fireedge/src/client/utils/helpers.js b/src/fireedge/src/client/utils/helpers.js
index a7449b7eac..81b75df312 100644
--- a/src/fireedge/src/client/utils/helpers.js
+++ b/src/fireedge/src/client/utils/helpers.js
@@ -43,6 +43,13 @@ export const addOpacityToColor = (color, opacity) => {
export const capitalize = ([firstLetter, ...restOfWord]) =>
firstLetter.toUpperCase() + restOfWord.join('')
+export const stringToCamelCase = s => s.replace(
+ /([-_\s][a-z])/ig,
+ $1 => $1.toUpperCase().replace(/[-_\s]/g, '')
+)
+
+export const stringToCamelSpace = s => s.replace(/([a-z])([A-Z])/g, '$1 $2')
+
export const getValidationFromFields = fields =>
fields.reduce(
(schema, field) => ({
diff --git a/src/fireedge/src/server/utils/constants/commands/vm.js b/src/fireedge/src/server/utils/constants/commands/vm.js
index 40122ff423..0c1b3a5ea6 100644
--- a/src/fireedge/src/server/utils/constants/commands/vm.js
+++ b/src/fireedge/src/server/utils/constants/commands/vm.js
@@ -155,7 +155,7 @@ module.exports = {
from: postBody,
default: 0
},
- livemigration: {
+ liveMigration: {
from: postBody,
default: false
},
@@ -357,39 +357,39 @@ module.exports = {
from: resource,
default: 0
},
- user_use: {
+ ownerUse: {
from: postBody,
default: -1
},
- user_manage: {
+ ownerManage: {
from: postBody,
default: -1
},
- user_admin: {
+ ownerAdmin: {
from: postBody,
default: -1
},
- group_use: {
+ groupUse: {
from: postBody,
default: -1
},
- group_manage: {
+ groupManage: {
from: postBody,
default: -1
},
- group_admin: {
+ groupAdmin: {
from: postBody,
default: -1
},
- other_use: {
+ otherUse: {
from: postBody,
default: -1
},
- other_manage: {
+ otherManage: {
from: postBody,
default: -1
},
- other_admin: {
+ otherAdmin: {
from: postBody,
default: -1
}
@@ -601,7 +601,7 @@ module.exports = {
from: query,
default: -2
},
- filterbykey: {
+ filterByKey: {
from: query,
default: ''
}
@@ -669,19 +669,19 @@ module.exports = {
from: query,
default: -2
},
- start_month: {
+ startMonth: {
filter: query,
default: -1
},
- start_year: {
+ startYear: {
filter: query,
default: -1
},
- end_month: {
+ endMonth: {
filter: query,
default: -1
},
- end_year: {
+ endYear: {
filter: query,
default: -1
}
@@ -691,19 +691,19 @@ module.exports = {
// inspected
httpMethod: GET,
params: {
- start_month: {
+ startMonth: {
filter: query,
default: -1
},
- start_year: {
+ startYear: {
filter: query,
default: -1
},
- end_month: {
+ endMonth: {
filter: query,
default: -1
},
- end_year: {
+ endYear: {
filter: query,
default: -1
}