diff --git a/client/src/components/Icons/CustomIcons.tsx b/client/src/components/Icons/CustomIcons.tsx index 34c26183..068c74fa 100644 --- a/client/src/components/Icons/CustomIcons.tsx +++ b/client/src/components/Icons/CustomIcons.tsx @@ -2688,3 +2688,22 @@ const QemuSvg = React.memo((props) => ( export const Qemu = (props: Partial) => ( ); + +const SetActionSvg = React.memo((props) => ( + + + +)); + +export const SetAction = (props: Partial) => ( + +); diff --git a/client/src/pages/Admin/Logs/TaskLogsTerminalModal.tsx b/client/src/pages/Admin/Logs/TaskLogsTerminalModal.tsx index 3882c52a..b5e10dbc 100644 --- a/client/src/pages/Admin/Logs/TaskLogsTerminalModal.tsx +++ b/client/src/pages/Admin/Logs/TaskLogsTerminalModal.tsx @@ -60,7 +60,7 @@ const TaskLogsTerminalModal: React.FC = ({ setIsOpen(true); }} > - Show logs + Logs { if (row.onError) { return ( diff --git a/client/src/pages/Admin/Settings/components/PlaybooksSettings.tsx b/client/src/pages/Admin/Settings/components/PlaybooksSettings.tsx index fdabb717..5d25ea6e 100644 --- a/client/src/pages/Admin/Settings/components/PlaybooksSettings.tsx +++ b/client/src/pages/Admin/Settings/components/PlaybooksSettings.tsx @@ -18,6 +18,7 @@ import { UnorderedListOutlined, } from '@ant-design/icons'; import { ProList } from '@ant-design/pro-components'; +import { history } from '@umijs/max'; import { Avatar, Button, @@ -327,14 +328,34 @@ const PlaybookSettings: React.FC = () => { if (row.onError) { return ( + This repository is on error: {row.onErrorMessage} + + + + + } > diff --git a/client/src/pages/Admin/Settings/components/subcomponents/ContainerStacksGitRepositoryModal.tsx b/client/src/pages/Admin/Settings/components/subcomponents/ContainerStacksGitRepositoryModal.tsx index b276611d..3751210a 100644 --- a/client/src/pages/Admin/Settings/components/subcomponents/ContainerStacksGitRepositoryModal.tsx +++ b/client/src/pages/Admin/Settings/components/subcomponents/ContainerStacksGitRepositoryModal.tsx @@ -11,8 +11,10 @@ import { putContainerStacksGitRepository, syncToDatabaseContainerStacksGitRepository, } from '@/services/rest/container-stacks-repositories'; +import { DeleteOutlined, UnorderedListOutlined } from '@ant-design/icons'; import { ModalForm, ProForm } from '@ant-design/pro-components'; -import { Avatar, Button, Dropdown, MenuProps, message } from 'antd'; +import { history } from '@umijs/max'; +import { Avatar, Button, Dropdown, MenuProps, message, Popconfirm } from 'antd'; import React from 'react'; import { API } from 'ssm-shared-lib'; @@ -114,6 +116,19 @@ const ContainerStacksGitRepositoryModal: React.FC< const editionMode = props.selectedRecord ? [ + , Actions , - , + + , ] : []; @@ -190,6 +207,9 @@ const ContainerStacksGitRepositoryModal: React.FC< } }} submitter={{ + searchConfig: { + submitText: 'Save', + }, render: (_, defaultDoms) => { return [...editionMode, ...defaultDoms]; }, diff --git a/client/src/pages/Admin/Settings/components/subcomponents/PlaybooksGitRepositoryModal.tsx b/client/src/pages/Admin/Settings/components/subcomponents/PlaybooksGitRepositoryModal.tsx index 651e7fd6..027e98f5 100644 --- a/client/src/pages/Admin/Settings/components/subcomponents/PlaybooksGitRepositoryModal.tsx +++ b/client/src/pages/Admin/Settings/components/subcomponents/PlaybooksGitRepositoryModal.tsx @@ -11,8 +11,10 @@ import { putPlaybooksGitRepository, syncToDatabasePlaybooksGitRepository, } from '@/services/rest/playbooks-repositories'; +import { DeleteOutlined, UnorderedListOutlined } from '@ant-design/icons'; import { ModalForm, ProForm } from '@ant-design/pro-components'; -import { Avatar, Button, Dropdown, MenuProps, message } from 'antd'; +import { history } from '@umijs/max'; +import { Avatar, Button, Dropdown, MenuProps, message, Popconfirm } from 'antd'; import React from 'react'; import { API } from 'ssm-shared-lib'; @@ -114,6 +116,19 @@ const PlaybooksGitRepositoryModal: React.FC< const editionMode = props.selectedRecord ? [ + , Actions , - , + + , ] : []; @@ -188,6 +205,9 @@ const PlaybooksGitRepositoryModal: React.FC< } }} submitter={{ + searchConfig: { + submitText: 'Save', + }, render: (_, defaultDoms) => { return [...editionMode, ...defaultDoms]; }, diff --git a/client/src/pages/Admin/Settings/components/subcomponents/PlaybooksLocalRepositoryModal.tsx b/client/src/pages/Admin/Settings/components/subcomponents/PlaybooksLocalRepositoryModal.tsx index c25d0cf4..3f1451f7 100644 --- a/client/src/pages/Admin/Settings/components/subcomponents/PlaybooksLocalRepositoryModal.tsx +++ b/client/src/pages/Admin/Settings/components/subcomponents/PlaybooksLocalRepositoryModal.tsx @@ -1,4 +1,4 @@ -import { SimpleIconsGit } from '@/components/Icons/CustomIcons'; +import { SetAction, SimpleIconsGit } from '@/components/Icons/CustomIcons'; import DirectoryExclusionForm from '@/pages/Admin/Settings/components/subcomponents/forms/DirectoryExclusionForm'; import { deletePlaybooksLocalRepository, @@ -6,8 +6,14 @@ import { putPlaybooksLocalRepositories, syncToDatabasePlaybooksLocalRepository, } from '@/services/rest/playbooks-repositories'; +import { + DeleteOutlined, + TableOutlined, + UnorderedListOutlined, +} from '@ant-design/icons'; import { ModalForm, ProForm, ProFormText } from '@ant-design/pro-components'; -import { Avatar, Button, Dropdown, MenuProps, message } from 'antd'; +import { history } from '@umijs/max'; +import { Avatar, Button, Dropdown, MenuProps, message, Popconfirm } from 'antd'; import React, { FC, useState } from 'react'; import { API } from 'ssm-shared-lib'; @@ -53,6 +59,19 @@ const PlaybooksLocalRepositoryModal: FC = ( }; const editionMode = props.selectedRecord ? [ + , = ( > Actions , - , + + , ] : []; return ( @@ -135,6 +159,9 @@ const PlaybooksLocalRepositoryModal: FC = ( } }} submitter={{ + searchConfig: { + submitText: 'Save', + }, render: (_, defaultDoms) => { return [...editionMode, ...defaultDoms]; }, diff --git a/server/src/helpers/git/credential.ts b/server/src/helpers/git/credential.ts index b20fbdb5..80d8784a 100644 --- a/server/src/helpers/git/credential.ts +++ b/server/src/helpers/git/credential.ts @@ -1,7 +1,6 @@ import { GitProcess } from 'dugite'; import { trim } from 'lodash'; import { SsmGit } from 'ssm-shared-lib'; -import logger from '../../logger'; import { getRemoteUrl } from './inspect'; // TODO: support folderLocation as rawUrl like `/Users/linonetwo/Desktop/repo/playbooks-repository-sync-js/test/mockUpstreamRepo/credential` for test, or gitlab url. @@ -107,7 +106,6 @@ export async function credentialOn( throw new Error(`Unknown service type ${serviceType}`); } } - logger.error(gitUrlWithCredential); await GitProcess.exec(['remote', 'add', remoteName, gitUrlWithCredential], directory); await GitProcess.exec(['remote', 'set-url', remoteName, gitUrlWithCredential], directory); } diff --git a/server/src/logger.ts b/server/src/logger.ts index 461b5f77..ed3484c0 100644 --- a/server/src/logger.ts +++ b/server/src/logger.ts @@ -44,7 +44,7 @@ export const httpLoggerOptions = { // Define a custom error message customErrorMessage: function (req, res, err) { - return `Request errored with status code: ${res.statusCode}`; + return `Request errored with status code: ${res.statusCode} - ${req.method} - ${req.url} - ${err.message}`; }, }; diff --git a/server/src/middlewares/ErrorHandler.ts b/server/src/middlewares/ErrorHandler.ts index 1ba397ef..ae61f612 100644 --- a/server/src/middlewares/ErrorHandler.ts +++ b/server/src/middlewares/ErrorHandler.ts @@ -8,7 +8,7 @@ export const errorHandler = (err: Error, req: Request, res: Response, next: Next if (err instanceof ApiError) { ApiError.handle(err, res, req); } else { - logger.error(err); + logger.error(`${err.message} - ${req.originalUrl} - ${req.method} - ${req.ip}`); if (err.message === 'Unauthorized') { ApiError.handle(new AuthFailureError('Unauthorized'), res, req); return; diff --git a/server/src/modules/automations/actions/AbstractActionComponent.ts b/server/src/modules/automations/actions/AbstractActionComponent.ts index 38e2f5d3..2a880604 100644 --- a/server/src/modules/automations/actions/AbstractActionComponent.ts +++ b/server/src/modules/automations/actions/AbstractActionComponent.ts @@ -44,7 +44,7 @@ abstract class AbstractActionComponent extends EventManager { throw new Error(`Automation with uuid ${this.automationUuid} not found`); } await AutomationRepo.setLastExecutionStatus(automation, 'failed'); - this.childLogger.error('Automation failed'); + this.childLogger.error(`Automation failed - error: ${optionalMessage || 'Unknown reason'}`); this.emit(Events.AUTOMATION_FAILED, { message: optionalMessage || `The automation "${this.moduleName}" failed`, severity: 'error', diff --git a/server/src/modules/automations/actions/DockerVolumeActionComponent.ts b/server/src/modules/automations/actions/DockerVolumeActionComponent.ts index 3ffb279c..0b1c659a 100644 --- a/server/src/modules/automations/actions/DockerVolumeActionComponent.ts +++ b/server/src/modules/automations/actions/DockerVolumeActionComponent.ts @@ -30,7 +30,9 @@ class DockerVolumeActionComponent extends AbstractActionComponent { this.childLogger.info(`Docker Volume Action - executeAction - for volume: ${volumeUuid}`); const volume = await ContainerVolumeRepo.findByUuid(volumeUuid); if (!volume) { - this.childLogger.error(`Volume not found for ${volumeUuid}`); + this.childLogger.error( + `Volume not found. (Volume uuid: ${volumeUuid}, Action: ${this.dockerVolumeAction})`, + ); success = false; } else { try { diff --git a/server/src/modules/repository/git-playbooks-repository/GitPlaybooksRepositoryComponent.ts b/server/src/modules/repository/git-playbooks-repository/GitPlaybooksRepositoryComponent.ts index 35861c38..20e7956f 100644 --- a/server/src/modules/repository/git-playbooks-repository/GitPlaybooksRepositoryComponent.ts +++ b/server/src/modules/repository/git-playbooks-repository/GitPlaybooksRepositoryComponent.ts @@ -64,7 +64,7 @@ class GitPlaybooksRepositoryComponent try { void Shell.FileSystemManager.createDirectory(this.directory, DIRECTORY_ROOT); } catch (error: any) { - logger.warn(error); + this.childLogger.warn(error); } await clone({ ...this.options,