diff --git a/client/src/components/Template/Title.tsx b/client/src/components/Template/Title.tsx index 612df1a6..77025251 100644 --- a/client/src/components/Template/Title.tsx +++ b/client/src/components/Template/Title.tsx @@ -21,6 +21,7 @@ export enum TitleColors { DEBUG = '#b614b6', ANSIBLE_CONF = '#c1660e', COMPOSE = '#8e7418', + HOST_URL = '#368e18', } export type PageContainerTitleProps = { diff --git a/client/src/pages/Admin/Settings/components/AuthenticationSettings.tsx b/client/src/pages/Admin/Settings/components/AuthenticationSettings.tsx index 66d19888..503c6b46 100644 --- a/client/src/pages/Admin/Settings/components/AuthenticationSettings.tsx +++ b/client/src/pages/Admin/Settings/components/AuthenticationSettings.tsx @@ -1,5 +1,6 @@ -import { MynauiApi } from '@/components/Icons/CustomIcons'; +import { LinkAlt, MynauiApi } from '@/components/Icons/CustomIcons'; import Title, { TitleColors } from '@/components/Template/Title'; +import { postMasterNodeUrlValue } from '@/services/rest/settings'; import { postResetApiKey } from '@/services/rest/usersettings'; import { useModel } from '@@/exports'; import { InfoCircleFilled, WarningOutlined } from '@ant-design/icons'; @@ -14,13 +15,18 @@ import { Row, Col, Flex, + InputRef, } from 'antd'; import React, { useState } from 'react'; const AuthenticationSettings: React.FC = () => { const { initialState } = useModel('@@initialState'); + const nodeUrlRef = React.useRef(null); const { currentUser } = initialState || {}; const [apiKey, setApiKey] = useState(currentUser?.settings.apiKey); + const [masterNodeUrl, setMasterNodeUrl] = useState( + currentUser?.settings.masterNodeUrl, + ); const onClickResetApiKey = async () => { await postResetApiKey().then((res) => { @@ -29,8 +35,62 @@ const AuthenticationSettings: React.FC = () => { }); }; + const onClickUpdateSsmUrl = async () => { + await postMasterNodeUrlValue( + nodeUrlRef?.current?.input?.value as string, + ).then((res) => { + setMasterNodeUrl(res.data.value); + message.success({ content: 'SSM URL successfully saved', duration: 6 }); + }); + }; + return ( + } + /> + } + style={{ marginTop: 16 }} + > + + + + + + + {' '} + SSM URL + + + + + + + + + + + , +) { + return request(`/api/settings/keys/master-node-url`, { + method: 'POST', + ...{}, + data: { value: value }, + ...(options || {}), + }); +} diff --git a/server/src/controllers/rest/settings/keys.ts b/server/src/controllers/rest/settings/keys.ts new file mode 100644 index 00000000..2c6a9ce9 --- /dev/null +++ b/server/src/controllers/rest/settings/keys.ts @@ -0,0 +1,11 @@ +import { SsmAnsible } from 'ssm-shared-lib'; +import { setToCache } from '../../../data/cache'; +import { SuccessResponse } from '../../../middlewares/api/ApiResponse'; + +export const postMasterNodeUrlValue = async (req, res) => { + const { value } = req.body; + await setToCache(SsmAnsible.DefaultSharedExtraVarsList.MASTER_NODE_URL, value); + new SuccessResponse('Set master node url value', { + value, + }).send(res); +}; diff --git a/server/src/controllers/rest/settings/keys.validator.ts b/server/src/controllers/rest/settings/keys.validator.ts new file mode 100644 index 00000000..f23d8493 --- /dev/null +++ b/server/src/controllers/rest/settings/keys.validator.ts @@ -0,0 +1,4 @@ +import { body } from 'express-validator'; +import validator from '../../../middlewares/Validator'; + +export const postMasterNodeUrlValueValidator = [body('value').exists().isString(), validator]; diff --git a/server/src/routes/settings.ts b/server/src/routes/settings.ts index 136dc9f7..902d9cd7 100644 --- a/server/src/routes/settings.ts +++ b/server/src/routes/settings.ts @@ -16,6 +16,8 @@ import { postDevicesSettings } from '../controllers/rest/settings/devices'; import { postDevicesSettingsValidator } from '../controllers/rest/settings/devices.validator'; import { postDeviceStatsSettings } from '../controllers/rest/settings/devicestats'; import { postDeviceStatsSettingsValidator } from '../controllers/rest/settings/devicestats.validator'; +import { postMasterNodeUrlValue } from '../controllers/rest/settings/keys'; +import { postMasterNodeUrlValueValidator } from '../controllers/rest/settings/keys.validator'; import { postLogsSettings } from '../controllers/rest/settings/logs'; import { postLogsSettingsValidator } from '../controllers/rest/settings/logs.validator'; @@ -27,6 +29,7 @@ router.post(`/dashboard/:key`, postDashboardSettingsValidator, postDashboardSett router.post(`/devices/:key`, postDevicesSettingsValidator, postDevicesSettings); router.post(`/logs/:key`, postLogsSettingsValidator, postLogsSettings); router.post(`/device-stats/:key`, postDeviceStatsSettingsValidator, postDeviceStatsSettings); +router.post(`/keys/master-node-url`, postMasterNodeUrlValueValidator, postMasterNodeUrlValue); router.post( `/container-stats/:key`, postContainerStatsSettingsValidator,