Skip to content

Commit

Permalink
Merge pull request #30 from SquirrelCorporation/feature-ansible-galaxy
Browse files Browse the repository at this point in the history
Feature ansible galaxy
  • Loading branch information
SquirrelDeveloper authored Jun 17, 2024
2 parents 0f06380 + 5bf33ea commit 137817a
Show file tree
Hide file tree
Showing 53 changed files with 896 additions and 244 deletions.
8 changes: 4 additions & 4 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
],
"dependencies": {
"ssm-shared-lib": "file:../shared-lib/",
"antd": "^5.18.0",
"antd": "^5.18.1",
"@ant-design/icons": "^5.3.7",
"@ant-design/pro-components": "^2.7.10",
"@ant-design/use-emotion-css": "1.0.4",
"@ant-design/charts": "^2.1.1",
"@antv/g2plot": "^2.4.31",
"@umijs/max": "^4.2.10",
"@umijs/max": "^4.2.11",
"@umijs/route-utils": "^4.0.1",
"@umijs/plugin-antd-dayjs": "^0.3.0",
"umi-presets-pro": "^2.0.3",
Expand Down Expand Up @@ -94,13 +94,13 @@
"@types/react-dom": "^18.3.0",
"@types/react-helmet": "^6.1.11",
"@umijs/fabric": "^4.0.1",
"@umijs/lint": "^4.2.10",
"@umijs/lint": "^4.2.11",
"cross-env": "^7.0.3",
"eslint": "^9.4.0",
"express": "^4.19.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.5",
"lint-staged": "^15.2.7",
"mockjs": "^1.1.0",
"prettier": "^3.3.2",
"swagger-ui-dist": "^5.17.14",
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/DeviceComponents/DeviceLogos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CPULogo } from '@/components/DeviceComponents/CPULogo';
import { OsLogo } from '@/components/DeviceComponents/OsLogo/OsLogo';
import Avatar from 'antd/es/avatar/avatar';
import React from 'react';
import { DeviceItem } from 'ssm-shared-lib/distribution/types/api';
import { API } from 'ssm-shared-lib';

type DeviceLogosProps = {
device?: DeviceItem;
device?: API.DeviceItem;
};

const DeviceLogos: React.FC<DeviceLogosProps> = (props: DeviceLogosProps) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import React, { useEffect, useState } from 'react';
import { API } from 'ssm-shared-lib';
import Cron from 'react-js-cron';
import 'react-js-cron/dist/styles.css';
import { privateKeyRegexp } from 'ssm-shared-lib/distribution/validation';
import { Validation } from 'ssm-shared-lib';

const connectionTypes = [
{
Expand Down Expand Up @@ -402,7 +402,7 @@ export const DockerConnectionForm = (props: ConfigurationFormDockerProps) => {
{ required: true },
{ required: true },
{
pattern: privateKeyRegexp,
pattern: Validation.privateKeyRegexp,
message:
'The ssh key doesnt seems in a correct format',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import {
} from '@ant-design/pro-components';
import { Avatar, Card, Col, Flex, Row, Space, Switch, Tooltip } from 'antd';
import React from 'react';
import { AnsibleBecomeMethod } from 'ssm-shared-lib/distribution/enums/ansible';
import { privateKeyRegexp } from 'ssm-shared-lib/distribution/validation';
import { Validation, SsmAnsible } from 'ssm-shared-lib';

const connectionTypes = [
{
Expand Down Expand Up @@ -167,7 +166,7 @@ const SSHConnectionForm: React.FC<SSHConnectionFormProps> = (props) => {
},
]}
width="xs"
options={Object.values(AnsibleBecomeMethod).map((e) => ({
options={Object.values(SsmAnsible.AnsibleBecomeMethod).map((e) => ({
value: e,
label: e,
}))}
Expand Down Expand Up @@ -372,7 +371,7 @@ const SSHConnectionForm: React.FC<SSHConnectionFormProps> = (props) => {
rules={[
{ required: true },
{
pattern: privateKeyRegexp,
pattern: Validation.privateKeyRegexp,
message:
'The ssh key doesnt seems in a correct format',
},
Expand Down
21 changes: 12 additions & 9 deletions client/src/pages/Admin/Settings/components/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
postResetSettings,
} from '@/services/rest/settings';
import SystemPerformanceCard from '@/pages/Dashboard/Components/SystemPerformanceCard';
import { GeneralSettingsKeys } from 'ssm-shared-lib/distribution/enums/settings';
import { SettingsKeys } from 'ssm-shared-lib';

const GeneralSettings: React.FC = () => {
const { initialState } = useModel('@@initialState');
Expand Down Expand Up @@ -67,7 +67,7 @@ const GeneralSettings: React.FC = () => {
const onChangeMaxCpu = async (newValue: number | null) => {
if (newValue) {
await postDashboardSetting(
GeneralSettingsKeys.CONSIDER_PERFORMANCE_GOOD_CPU_IF_LOWER,
SettingsKeys.GeneralSettingsKeys.CONSIDER_PERFORMANCE_GOOD_CPU_IF_LOWER,
newValue,
).then(() => {
setDashboardMaxCpuInPercent(newValue);
Expand All @@ -82,7 +82,8 @@ const GeneralSettings: React.FC = () => {
const onChangeMinMem = async (newValue: number | null) => {
if (newValue) {
await postDashboardSetting(
GeneralSettingsKeys.CONSIDER_PERFORMANCE_GOOD_MEM_IF_GREATER,
SettingsKeys.GeneralSettingsKeys
.CONSIDER_PERFORMANCE_GOOD_MEM_IF_GREATER,
newValue,
).then(() => {
setDashboardMinMemInPercent(newValue);
Expand All @@ -97,7 +98,8 @@ const GeneralSettings: React.FC = () => {
const onChangeConsiderDeviceOnline = async (newValue: number | null) => {
if (newValue) {
await postDeviceSetting(
GeneralSettingsKeys.CONSIDER_DEVICE_OFFLINE_AFTER_IN_MINUTES,
SettingsKeys.GeneralSettingsKeys
.CONSIDER_DEVICE_OFFLINE_AFTER_IN_MINUTES,
newValue,
).then(() => {
setConsiderDeviceOnlineInMinutes(newValue);
Expand All @@ -112,7 +114,8 @@ const GeneralSettings: React.FC = () => {
const onChangeAnsibleCleanUp = async (newValue: number | null) => {
if (newValue) {
await postLogsSetting(
GeneralSettingsKeys.CLEAN_UP_ANSIBLE_STATUSES_AND_TASKS_AFTER_IN_SECONDS,
SettingsKeys.GeneralSettingsKeys
.CLEAN_UP_ANSIBLE_STATUSES_AND_TASKS_AFTER_IN_SECONDS,
newValue,
).then(() => {
setAnsibleCleanUpInSeconds(newValue);
Expand All @@ -126,7 +129,7 @@ const GeneralSettings: React.FC = () => {
const onChangeServerLogsRetention = async (newValue: number | null) => {
if (newValue) {
await postLogsSetting(
GeneralSettingsKeys.SERVER_LOG_RETENTION_IN_DAYS,
SettingsKeys.GeneralSettingsKeys.SERVER_LOG_RETENTION_IN_DAYS,
newValue,
).then(() => {
setServerLogsRetentionInDays(newValue);
Expand All @@ -141,7 +144,7 @@ const GeneralSettings: React.FC = () => {
const onChangeRegisterDeviceStatEvery = async (newValue: number | null) => {
if (newValue) {
await postDeviceSetting(
GeneralSettingsKeys.REGISTER_DEVICE_STAT_EVERY_IN_SECONDS,
SettingsKeys.GeneralSettingsKeys.REGISTER_DEVICE_STAT_EVERY_IN_SECONDS,
newValue,
).then(() => {
setRegisterDeviceStatEveryXSeconds(newValue);
Expand All @@ -162,7 +165,7 @@ const GeneralSettings: React.FC = () => {
const onChangeDeviceStatsRetention = async (newValue: number | null) => {
if (newValue) {
await postDeviceStatsSettings(
GeneralSettingsKeys.DEVICE_STATS_RETENTION_IN_DAYS,
SettingsKeys.GeneralSettingsKeys.DEVICE_STATS_RETENTION_IN_DAYS,
newValue,
).then(() => {
setDeviceStatsRetentionInDays(newValue);
Expand All @@ -177,7 +180,7 @@ const GeneralSettings: React.FC = () => {
const onChangeContainerStatsRetention = async (newValue: number | null) => {
if (newValue) {
await postContainerStatsSettings(
GeneralSettingsKeys.CONTAINER_STATS_RETENTION_IN_DAYS,
SettingsKeys.GeneralSettingsKeys.CONTAINER_STATS_RETENTION_IN_DAYS,
newValue,
).then(() => {
setContainerStatsRetentionInDays(newValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
import { DeleteOutline } from 'antd-mobile-icons';
import React, { useEffect, useState } from 'react';
import { API } from 'ssm-shared-lib';
import { ContainerRegistry } from 'ssm-shared-lib/distribution/types/api';

const getRegistryLogo = (provider: string) => {
switch (provider) {
Expand Down Expand Up @@ -83,7 +82,7 @@ const RegistrySettings: React.FC = () => {
if (list?.data) {
setRegistries(
list.data?.registries.sort(
(a: ContainerRegistry, b: ContainerRegistry) =>
(a: API.ContainerRegistry, b: API.ContainerRegistry) =>
a.authSet && !b.authSet ? -1 : 1,
) || [],
);
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/Dashboard/Components/MainChartCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const MainChartCard: React.FC<any> = ({}) => {
useEffect(() => {
asyncFetch();
}, [devices, type, rangePickerValue]);

// see https://ant-design-charts-next.antgroup.com/en/options/plots/component/legend
const config = {
data: graphData,
Expand Down
11 changes: 6 additions & 5 deletions client/src/pages/Dashboard/Components/ServicesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { Tiny } from '@ant-design/charts';
import { InfoCircleFilled } from '@ant-design/icons';
import { Tooltip, Typography } from 'antd';
import React, { useEffect } from 'react';
import { ContainerStatus } from 'ssm-shared-lib/distribution/enums/status';
import { API } from 'ssm-shared-lib';
import { SsmStatus, API } from 'ssm-shared-lib';

const ServicesCard: React.FC = () => {
const [loading, setLoading] = React.useState(false);
Expand All @@ -18,9 +17,11 @@ const ServicesCard: React.FC = () => {
const [stats, setStats] = React.useState();

const asyncFetch = async () => {
await getNbContainersByStatus(ContainerStatus.RUNNING).then((response) => {
setNbRunning(response.data);
});
await getNbContainersByStatus(SsmStatus.ContainerStatus.RUNNING).then(
(response) => {
setNbRunning(response.data);
},
);
await getNbContainersByStatus('all').then((response) => {
setNbTotal(response.data);
});
Expand Down
Loading

0 comments on commit 137817a

Please sign in to comment.