From 2228325d825b2151818a835aa1add6dabe9511b3 Mon Sep 17 00:00:00 2001 From: ydzhang Date: Mon, 5 Dec 2022 15:14:10 +0800 Subject: [PATCH 01/56] upload hotfix pages This commit init the front web of sysom hotfix project Changes to be committed: modified: sysom_web/config/routes.js modified: sysom_web/src/locales/zh-CN/menu.js modified: sysom_web/src/locales/zh-CN/pages.js modified: sysom_web/src/pages/Welcome.jsx modified: sysom_web/src/pages/Welcome.less new file: sysom_web/src/pages/hotfix/Make/index.jsx new file: sysom_web/src/pages/hotfix/service.js --- sysom_web/config/routes.js | 15 +++++ sysom_web/src/locales/zh-CN/menu.js | 4 +- sysom_web/src/locales/zh-CN/pages.js | 7 +++ sysom_web/src/pages/Welcome.jsx | 4 ++ sysom_web/src/pages/Welcome.less | 2 +- sysom_web/src/pages/hotfix/Make/index.jsx | 68 +++++++++++++++++++++++ sysom_web/src/pages/hotfix/service.js | 14 +++++ 7 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 sysom_web/src/pages/hotfix/Make/index.jsx create mode 100644 sysom_web/src/pages/hotfix/service.js diff --git a/sysom_web/config/routes.js b/sysom_web/config/routes.js index 26c95fde..43a44352 100644 --- a/sysom_web/config/routes.js +++ b/sysom_web/config/routes.js @@ -240,6 +240,21 @@ export default [ }, ], }, + { + path: '/hotfix', + name: 'hotfix', + routes: [ + { + path: '/hotfix', + redirect: '/hotfix/make', + }, + { + path: '/hotfix/make', + name: 'make', + component: './hotfix/Make', + }, + ] + }, { path: '/', redirect: '/welcome', diff --git a/sysom_web/src/locales/zh-CN/menu.js b/sysom_web/src/locales/zh-CN/menu.js index f79cbdfd..f207650c 100644 --- a/sysom_web/src/locales/zh-CN/menu.js +++ b/sysom_web/src/locales/zh-CN/menu.js @@ -82,5 +82,7 @@ export default { 'menu.journal.alarm': '告警日志', 'menu.journal.task': '任务日志', 'menu.security': '安全中心', - 'menu.security.list': '漏洞中心' + 'menu.security.list': '漏洞中心', + 'menu.hotfix': '热补丁中心', + 'menu.hotfix.make': '热补丁制作' }; diff --git a/sysom_web/src/locales/zh-CN/pages.js b/sysom_web/src/locales/zh-CN/pages.js index 5f57148e..e1362af1 100644 --- a/sysom_web/src/locales/zh-CN/pages.js +++ b/sysom_web/src/locales/zh-CN/pages.js @@ -143,4 +143,11 @@ export default { 'pages.security.Historical.fix_fail': 'CVE修复失败,失败原因:', 'pages.security.notification.fix.success': '系统漏洞已修复', 'pages.security.notification.fix.success.content': '如您正在运行漏洞涉及到的服务,建议您重启相关服务使漏洞修复生效。', + 'pages.hotfix.title': '热补丁列表', + 'pages.hotfix.created_at': '创建时间', + 'pages.hotfix.kernel_version': '内核版本', + 'pages.hotfix.create_user': '创建人', + 'pages.hotfix.progress': '进度', + 'pages.hotfix.path': '路径', + 'pages.hotfix.action': '操作', }; \ No newline at end of file diff --git a/sysom_web/src/pages/Welcome.jsx b/sysom_web/src/pages/Welcome.jsx index d44ba2b6..42f38994 100644 --- a/sysom_web/src/pages/Welcome.jsx +++ b/sysom_web/src/pages/Welcome.jsx @@ -13,6 +13,7 @@ const imgBanner = [ {key:4,banner:"#1a2933",title:"监控中心",urls:'/monitor',des:""}, {key:3,banner:"#1a2933",title:"诊断中心",urls:'/diagnose',des:""}, {key:5,banner:"#1a2933",title:"安全中心",urls:'/security',des:""}, + {key:5,banner:"#1a2933",title:"热补丁中心",urls:'/hotfix',des:""}, ] const Welcome = () => { @@ -64,6 +65,9 @@ const Welcome = () => { 漏洞中心 + + 热补丁制作 +
diff --git a/sysom_web/src/pages/Welcome.less b/sysom_web/src/pages/Welcome.less index 4049bf77..187d3ded 100644 --- a/sysom_web/src/pages/Welcome.less +++ b/sysom_web/src/pages/Welcome.less @@ -24,7 +24,7 @@ } .menuCenter{ position: absolute; - width: 46%; + width: 50%; left: 50%; transform: translate(-50%,-5%); line-height: 48px!important; diff --git a/sysom_web/src/pages/hotfix/Make/index.jsx b/sysom_web/src/pages/hotfix/Make/index.jsx new file mode 100644 index 00000000..c9c2a1b0 --- /dev/null +++ b/sysom_web/src/pages/hotfix/Make/index.jsx @@ -0,0 +1,68 @@ +import { useRef } from 'react'; +import { useIntl, FormattedMessage } from 'umi'; +import { PageContainer } from '@ant-design/pro-layout'; +import ProTable from '@ant-design/pro-table'; +import { getHotfixList } from '../service'; + +const HotfixList = () => { + const actionRef = useRef(); + const intl = useIntl(); + + const columns = [ + { + title: , + dataIndex: 'created_at', + valueType: 'message', + hideInSearch: true, + }, + { + title: , + dataIndex: 'kernel_version', + valueType: 'input', + }, + { + title: , + dataIndex: 'creator', + valueType: 'message', + hideInSearch: true, + }, + { + title: , + dataIndex: 'patch_path', + valueType: 'input', + }, + { + title: , + dataIndex: 'building_status', + hideInSearch: true, + valueEnum: { + 0: { text: '等待构建' }, + 1: { text: '正在构建' }, + 2: { text: '构建失败' }, + 3: { text: '构建成功' }, + }, + }, + ]; + return ( + + [ + ]} + request={getHotfixList} + columns={columns} + /> + + ); +}; + +export default HotfixList; \ No newline at end of file diff --git a/sysom_web/src/pages/hotfix/service.js b/sysom_web/src/pages/hotfix/service.js new file mode 100644 index 00000000..9f166652 --- /dev/null +++ b/sysom_web/src/pages/hotfix/service.js @@ -0,0 +1,14 @@ +import { request } from "umi"; + +export async function getHotfixList(params, options) { + const token = localStorage.getItem('token'); + return request('/api/v1/hotfix/get_hotfix_list/', { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + params: params, + ...(options || {}), + }); +} -- Gitee From 05a4344ae388d2e11cb680cb9215e47877140f44 Mon Sep 17 00:00:00 2001 From: ydzhang Date: Mon, 5 Dec 2022 15:33:20 +0800 Subject: [PATCH 02/56] init hotfix app in sysom_api This commit init hotfix app in sysom_api prepared the file of hotfix app Also, added function of getting hotfix list and insert one hotfix record into database Changes to be committed: new file: sysom_server/sysom_api/apps/hotfix/__init__.py new file: sysom_server/sysom_api/apps/hotfix/admin.py new file: sysom_server/sysom_api/apps/hotfix/apps.py new file: sysom_server/sysom_api/apps/hotfix/migrations/0001_initial.py new file: sysom_server/sysom_api/apps/hotfix/migrations/__init__.py new file: sysom_server/sysom_api/apps/hotfix/models.py new file: sysom_server/sysom_api/apps/hotfix/serializer.py new file: sysom_server/sysom_api/apps/hotfix/urls.py new file: sysom_server/sysom_api/apps/hotfix/views.py modified: sysom_server/sysom_api/conf/common.py --- .../sysom_api/apps/hotfix/__init__.py | 0 sysom_server/sysom_api/apps/hotfix/admin.py | 1 + sysom_server/sysom_api/apps/hotfix/apps.py | 34 ++++++++++ .../apps/hotfix/migrations/0001_initial.py | 38 ++++++++++++ .../apps/hotfix/migrations/__init__.py | 0 sysom_server/sysom_api/apps/hotfix/models.py | 29 +++++++++ .../sysom_api/apps/hotfix/serializer.py | 17 +++++ sysom_server/sysom_api/apps/hotfix/urls.py | 15 +++++ sysom_server/sysom_api/apps/hotfix/views.py | 62 +++++++++++++++++++ sysom_server/sysom_api/conf/common.py | 5 ++ 10 files changed, 201 insertions(+) create mode 100644 sysom_server/sysom_api/apps/hotfix/__init__.py create mode 100644 sysom_server/sysom_api/apps/hotfix/admin.py create mode 100644 sysom_server/sysom_api/apps/hotfix/apps.py create mode 100644 sysom_server/sysom_api/apps/hotfix/migrations/0001_initial.py create mode 100644 sysom_server/sysom_api/apps/hotfix/migrations/__init__.py create mode 100644 sysom_server/sysom_api/apps/hotfix/models.py create mode 100644 sysom_server/sysom_api/apps/hotfix/serializer.py create mode 100644 sysom_server/sysom_api/apps/hotfix/urls.py create mode 100644 sysom_server/sysom_api/apps/hotfix/views.py diff --git a/sysom_server/sysom_api/apps/hotfix/__init__.py b/sysom_server/sysom_api/apps/hotfix/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sysom_server/sysom_api/apps/hotfix/admin.py b/sysom_server/sysom_api/apps/hotfix/admin.py new file mode 100644 index 00000000..a23ff81f --- /dev/null +++ b/sysom_server/sysom_api/apps/hotfix/admin.py @@ -0,0 +1 @@ +from django.contrib import admin \ No newline at end of file diff --git a/sysom_server/sysom_api/apps/hotfix/apps.py b/sysom_server/sysom_api/apps/hotfix/apps.py new file mode 100644 index 00000000..dbb827fc --- /dev/null +++ b/sysom_server/sysom_api/apps/hotfix/apps.py @@ -0,0 +1,34 @@ +import logging +import sys +from django.apps import AppConfig +from channel_job import default_channel_job_executor +from django.db.models.signals import post_migrate + +logger = logging.getLogger(__name__) + + +class HotfixConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'apps.hotfix' + + def ready(self): + post_migrate.connect(initialization_subscribe, sender=self) + logger.info(">>> hotfix module loading success") + + +def initialization_subscribe(sender, **kwargs): + load_subscribe_models_data() + + +def load_subscribe_models_data(): + try: + from .models import SubscribeModel + + if not SubscribeModel.objects.filter().first(): + sub = SubscribeModel.objects.create( + title="admin", + ) + sub.users.add(*[1,]) + sub.save() + except Exception as e: + pass \ No newline at end of file diff --git a/sysom_server/sysom_api/apps/hotfix/migrations/0001_initial.py b/sysom_server/sysom_api/apps/hotfix/migrations/0001_initial.py new file mode 100644 index 00000000..1ca3d987 --- /dev/null +++ b/sysom_server/sysom_api/apps/hotfix/migrations/0001_initial.py @@ -0,0 +1,38 @@ +# Generated by Django 3.2.16 on 2022-12-05 07:20 + +from django.db import migrations, models +import lib.utils + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='HotfixModel', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_at', models.CharField(default=lib.utils.human_datetime, max_length=20, verbose_name='创建时间')), + ('deleted_at', models.CharField(max_length=20, null=True)), + ('arch', models.CharField(max_length=10, verbose_name='架构')), + ('kernel_version', models.CharField(max_length=60, verbose_name='内核版本')), + ('patch_path', models.CharField(max_length=255, verbose_name='补丁路径')), + ('patch_name', models.CharField(default='patch', max_length=255, verbose_name='补丁名称')), + ('hotfix_path', models.CharField(max_length=255, verbose_name='rpm存储路径')), + ('building_status', models.IntegerField(default=0, verbose_name='构建状态')), + ('hotfix_necessary', models.IntegerField(default=0, verbose_name='补丁重要性')), + ('hotfix_risk', models.IntegerField(default=0, verbose_name='补丁风险')), + ('description', models.CharField(default='NULL', max_length=300, verbose_name='描述')), + ('log', models.TextField(default='', verbose_name='构建日志')), + ('creator', models.CharField(default='admin', max_length=20, verbose_name='创建者')), + ('normal', models.BooleanField(default=0, verbose_name='正式包')), + ], + options={ + 'db_table': 'sys_hotfix', + }, + ), + ] diff --git a/sysom_server/sysom_api/apps/hotfix/migrations/__init__.py b/sysom_server/sysom_api/apps/hotfix/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sysom_server/sysom_api/apps/hotfix/models.py b/sysom_server/sysom_api/apps/hotfix/models.py new file mode 100644 index 00000000..b054bdc3 --- /dev/null +++ b/sysom_server/sysom_api/apps/hotfix/models.py @@ -0,0 +1,29 @@ +from django.db import models +from lib.base_model import BaseModel +from django.contrib.auth import get_user_model + +# Hotfix sys_hotfix Design +# for building_status->0:waiting; 1:building 2:build failed 3:build success +# for hotfix_necessary->0:optional 1:recommand install 2:must install +# for hotfix_risk -> 0:low risk 1:mid risk 2:high risk +class HotfixModel(BaseModel): + arch = models.CharField(max_length=10, verbose_name="架构") + kernel_version = models.CharField(max_length=60, verbose_name="内核版本") + patch_path = models.CharField(max_length=255, verbose_name="补丁路径") + patch_name = models.CharField(max_length=255, default="patch", verbose_name="补丁名称") + hotfix_path = models.CharField(max_length=255, verbose_name="rpm存储路径") + building_status = models.IntegerField(default=0, verbose_name="构建状态") + hotfix_necessary = models.IntegerField(default=0, verbose_name="补丁重要性") + hotfix_risk = models.IntegerField(default=0, verbose_name="补丁风险") + description = models.CharField(max_length=300, default="NULL", verbose_name="描述") + log = models.TextField(default="", verbose_name="构建日志") + creator = models.CharField(max_length=20, default="admin", verbose_name="创建者") + normal = models.BooleanField(default=0, verbose_name="正式包") + + class Meta: + db_table = 'sys_hotfix' + + def __str__(self): + return self.patch_path + + \ No newline at end of file diff --git a/sysom_server/sysom_api/apps/hotfix/serializer.py b/sysom_server/sysom_api/apps/hotfix/serializer.py new file mode 100644 index 00000000..1ba0ec6c --- /dev/null +++ b/sysom_server/sysom_api/apps/hotfix/serializer.py @@ -0,0 +1,17 @@ +import logging +from rest_framework import serializers +from apps.hotfix.models import HotfixModel +logger = logging.getLogger(__name__) + +from datetime import datetime + +class HotfixSerializer(serializers.ModelSerializer): + patch_name = serializers.SerializerMethodField() + + class Meta: + model = HotfixModel + fields = ('id','created_at','deleted_at','arch','kernel_version','patch_path', + 'building_status','hotfix_necessary','hotfix_risk','creator','patch_name', 'normal') # fields 指定从数据库返回的字段 + + def get_patch_name(self, attr: HotfixModel): + return attr.patch_path.split("/")[-1] diff --git a/sysom_server/sysom_api/apps/hotfix/urls.py b/sysom_server/sysom_api/apps/hotfix/urls.py new file mode 100644 index 00000000..87ff5069 --- /dev/null +++ b/sysom_server/sysom_api/apps/hotfix/urls.py @@ -0,0 +1,15 @@ +from django.urls import path +from django.urls.conf import include + +from rest_framework.routers import DefaultRouter + +from apps.hotfix import views + +router = DefaultRouter() +router.register('host', views.HotfixAPIView) + +urlpatterns = [ + path('api/v1/', include(router.urls)), + path('api/v1/hotfix/create_hotfix/', views.HotfixAPIView.as_view({'post': 'create_hotfix'})), + path('api/v1/hotfix/get_hotfix_list/', views.HotfixAPIView.as_view({'get': 'get_hotfixlist'})), +] diff --git a/sysom_server/sysom_api/apps/hotfix/views.py b/sysom_server/sysom_api/apps/hotfix/views.py new file mode 100644 index 00000000..88263c9a --- /dev/null +++ b/sysom_server/sysom_api/apps/hotfix/views.py @@ -0,0 +1,62 @@ +import re +import logging +import os +import threading +from typing import Any +from drf_yasg import openapi +from drf_yasg.utils import swagger_auto_schema +from rest_framework.request import Request +from rest_framework.views import APIView +from rest_framework import mixins +from django.db.models import Q +from django_filters.rest_framework import DjangoFilterBackend +from rest_framework.exceptions import ValidationError +from django.conf import settings +from rest_framework.viewsets import GenericViewSet + +from apps.hotfix import serializer +from apps.common.common_model_viewset import CommonModelViewSet +from apps.hotfix.models import HotfixModel +from apps.accounts.authentication import Authentication +from lib.response import * +from lib.utils import human_datetime, datetime +from lib.exception import APIException +from concurrent.futures import ThreadPoolExecutor, as_completed +from channel_job import default_channel_job_executor +from channel_job import ChannelJobExecutor +from django.conf import settings + +logger = logging.getLogger(__name__) + +class HotfixAPIView(GenericViewSet, + mixins.ListModelMixin, + mixins.RetrieveModelMixin, + mixins.CreateModelMixin, + mixins.UpdateModelMixin, + mixins.DestroyModelMixin + ): + queryset = HotfixModel.objects.filter(deleted_at=None) + serializer_class = serializer.HotfixSerializer + authentication_classes = [Authentication] + filter_backends = [DjangoFilterBackend] + filterset_fields = ['created_time', 'creator', 'building_status', 'arch'] + http_method_names = ['get', 'post', 'patch', 'delete'] + + def __init__(self, **kwargs: Any) -> None: + super().__init__(**kwargs) + self.channel_job_executor = ChannelJobExecutor() + self.channel_job_executor.initial_from_remote_server(settings.HOTFIX_CONFIG_URL) + self.channel_job_executor.start() + + def create_hotfix(self, request, **kwargs): + request.data["arch"] = request.data["kernel_version"].split(".")[-1] + patch_path = request.data["patch_path"] + obj = HotfixModel.objects.filter(patch_path=patch_path).first() + res = HotfixModel.objects.create(**request.data) + return success(result=res.id, message="invoke create_hotfix") + + def get_hotfixlist(self, request): + queryset = HotfixModel.objects.all().filter(deleted_at=None) + response = serializer.HotfixSerializer(queryset, many=True) + return success(result=response.data, message="invoke get_hotfixlist") + diff --git a/sysom_server/sysom_api/conf/common.py b/sysom_server/sysom_api/conf/common.py index 4b7b4ae3..726ba1a7 100644 --- a/sysom_server/sysom_api/conf/common.py +++ b/sysom_server/sysom_api/conf/common.py @@ -20,6 +20,7 @@ INSTALLED_APPS = [ 'apps.host', 'apps.alarm', 'apps.services', + 'apps.hotfix', 'rest_framework', 'corsheaders', @@ -116,6 +117,10 @@ IS_MICRO_SERVICES = False # 是否微服务 WEB_DIR = os.path.join(BASE_DIR.parent, 'sysom_web') DOWNLOAD_DIR = os.path.join(WEB_DIR, 'download') +################################################################## +# Hotfix Platform settings +################################################################## +HOTFIX_CONFIG_URL = "http://localhost:7003/api/v1/channel/config/get?name=migration_setting" ################################################################## # SSH channel settings -- Gitee From a987223b6c4ef6d2c40b6fd361cad5768be5a90b Mon Sep 17 00:00:00 2001 From: ydzhang Date: Mon, 5 Dec 2022 15:38:40 +0800 Subject: [PATCH 03/56] upload delete hotfix url and method --- sysom_server/sysom_api/apps/hotfix/urls.py | 1 + sysom_server/sysom_api/apps/hotfix/views.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/sysom_server/sysom_api/apps/hotfix/urls.py b/sysom_server/sysom_api/apps/hotfix/urls.py index 87ff5069..058b1d9c 100644 --- a/sysom_server/sysom_api/apps/hotfix/urls.py +++ b/sysom_server/sysom_api/apps/hotfix/urls.py @@ -12,4 +12,5 @@ urlpatterns = [ path('api/v1/', include(router.urls)), path('api/v1/hotfix/create_hotfix/', views.HotfixAPIView.as_view({'post': 'create_hotfix'})), path('api/v1/hotfix/get_hotfix_list/', views.HotfixAPIView.as_view({'get': 'get_hotfixlist'})), + path('api/v1/hotfix/delete_hotfix/', views.HotfixAPIView.as_view({'delete': 'delete_hotfix'})), ] diff --git a/sysom_server/sysom_api/apps/hotfix/views.py b/sysom_server/sysom_api/apps/hotfix/views.py index 88263c9a..c7e4d80c 100644 --- a/sysom_server/sysom_api/apps/hotfix/views.py +++ b/sysom_server/sysom_api/apps/hotfix/views.py @@ -60,3 +60,13 @@ class HotfixAPIView(GenericViewSet, response = serializer.HotfixSerializer(queryset, many=True) return success(result=response.data, message="invoke get_hotfixlist") + def delete_hotfix(self, request): + hotfix = HotfixModel.objects.filter(id=request.data["id"],deleted_at=None).first() + if hotfix is None: + return other_response(message="can not delete this hotfix", result={"msg":"Hotfix not found"}, code=400) + else: + hotfix.deleted_at=human_datetime() + hotfix.save() + print("saved the object") + return success(result={}, message="invoke delete_hotfix") + -- Gitee From 69fff951d518153ab652f59e16272b237a849ea4 Mon Sep 17 00:00:00 2001 From: ydzhang Date: Mon, 5 Dec 2022 16:02:48 +0800 Subject: [PATCH 04/56] add operation column in pages This commit add operation column in pages. Also, added the delete function in front. Changes to be committed: modified: sysom_web/src/locales/zh-CN/pages.js modified: sysom_web/src/pages/hotfix/Make/index.jsx modified: sysom_web/src/pages/hotfix/service.js --- sysom_web/src/locales/zh-CN/pages.js | 4 +- sysom_web/src/pages/hotfix/Make/index.jsx | 47 +++++++++++++++++++++++ sysom_web/src/pages/hotfix/service.js | 14 +++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/sysom_web/src/locales/zh-CN/pages.js b/sysom_web/src/locales/zh-CN/pages.js index e1362af1..36c792f5 100644 --- a/sysom_web/src/locales/zh-CN/pages.js +++ b/sysom_web/src/locales/zh-CN/pages.js @@ -149,5 +149,7 @@ export default { 'pages.hotfix.create_user': '创建人', 'pages.hotfix.progress': '进度', 'pages.hotfix.path': '路径', - 'pages.hotfix.action': '操作', + 'pages.hotfix.delete_hotfix_not_exist': '要删除的hotfixID不存在', + 'pages.hotfix.operation': '操作', + 'pages.hotfix.delete': '删除', }; \ No newline at end of file diff --git a/sysom_web/src/pages/hotfix/Make/index.jsx b/sysom_web/src/pages/hotfix/Make/index.jsx index c9c2a1b0..01659939 100644 --- a/sysom_web/src/pages/hotfix/Make/index.jsx +++ b/sysom_web/src/pages/hotfix/Make/index.jsx @@ -4,6 +4,25 @@ import { PageContainer } from '@ant-design/pro-layout'; import ProTable from '@ant-design/pro-table'; import { getHotfixList } from '../service'; +const handleDelHotfix = async (record) => { + const hide = message.loading('正在删除'); + const token = localStorage.getItem('token'); + try { + let res = await delHotfix(record.id, token); + hide(); + if (res.code == 200) { + message.success('删除成功'); + return true; + } else { + message.error(`删除失败: ${res.message}`); + return false; + } + } catch (error) { + hide(); + return false; + } +} + const HotfixList = () => { const actionRef = useRef(); const intl = useIntl(); @@ -42,6 +61,34 @@ const HotfixList = () => { 3: { text: '构建成功' }, }, }, + { + // This is Operation column + title: , + key: 'option', + dataIndex: 'option', + valueType: 'option', + render: (_, record) => [ + + { + if (record.id == undefined) { + message.error(intl.formatMessage({ + id: 'pages.hotfix.delete_hotfix_not_exist', + defaultMessage: "Not allow to delete this hotfix" + })) + console.log(intl.formatMessage({ + id: 'pages.hotfix.delete_hotfix_not_exist', + defaultMessage: "Not allow to delete this hotfix" + })) + } else { + await handleDelHotfix(record); + actionRef.current?.reload(); + } + }}> + + + + ], + }, ]; return ( diff --git a/sysom_web/src/pages/hotfix/service.js b/sysom_web/src/pages/hotfix/service.js index 9f166652..aab7f971 100644 --- a/sysom_web/src/pages/hotfix/service.js +++ b/sysom_web/src/pages/hotfix/service.js @@ -12,3 +12,17 @@ export async function getHotfixList(params, options) { ...(options || {}), }); } + +export async function delHotFix(id, token, options) { + return request('/api/v1/hotfix/delete_hotfix/', { + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + data: { + id //格式? + }, + ...(options || {}), + }) +} \ No newline at end of file -- Gitee From ec28f89ac5c92806c48306ea6527fe70a594c865 Mon Sep 17 00:00:00 2001 From: ydzhang Date: Mon, 5 Dec 2022 16:38:43 +0800 Subject: [PATCH 05/56] realize the delete button in web --- sysom_web/src/pages/hotfix/Make/index.jsx | 3 ++- sysom_web/src/pages/hotfix/service.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sysom_web/src/pages/hotfix/Make/index.jsx b/sysom_web/src/pages/hotfix/Make/index.jsx index 01659939..e79cbb3d 100644 --- a/sysom_web/src/pages/hotfix/Make/index.jsx +++ b/sysom_web/src/pages/hotfix/Make/index.jsx @@ -2,7 +2,8 @@ import { useRef } from 'react'; import { useIntl, FormattedMessage } from 'umi'; import { PageContainer } from '@ant-design/pro-layout'; import ProTable from '@ant-design/pro-table'; -import { getHotfixList } from '../service'; +import { Popconfirm, message } from 'antd'; +import { getHotfixList, delHotfix } from '../service'; const handleDelHotfix = async (record) => { const hide = message.loading('正在删除'); diff --git a/sysom_web/src/pages/hotfix/service.js b/sysom_web/src/pages/hotfix/service.js index aab7f971..1992e569 100644 --- a/sysom_web/src/pages/hotfix/service.js +++ b/sysom_web/src/pages/hotfix/service.js @@ -13,7 +13,7 @@ export async function getHotfixList(params, options) { }); } -export async function delHotFix(id, token, options) { +export async function delHotfix(id, token, options) { return request('/api/v1/hotfix/delete_hotfix/', { method: 'DELETE', headers: { -- Gitee From 807969971ac2f3f78954ba77a64c491e9daa86f7 Mon Sep 17 00:00:00 2001 From: ydzhang Date: Mon, 5 Dec 2022 17:23:36 +0800 Subject: [PATCH 06/56] Added changeNormal function to web This commit added change Normal function to web. Once change a hotfix into normal, it will not be deleted by auto cleaning program. Changes to be committed: modified: sysom_web/src/locales/zh-CN/pages.js modified: sysom_web/src/pages/hotfix/Make/index.jsx modified: sysom_web/src/pages/hotfix/service.js --- sysom_web/src/locales/zh-CN/pages.js | 5 +-- sysom_web/src/pages/hotfix/Make/index.jsx | 42 +++++++++++++++++++++-- sysom_web/src/pages/hotfix/service.js | 17 ++++++++- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/sysom_web/src/locales/zh-CN/pages.js b/sysom_web/src/locales/zh-CN/pages.js index 36c792f5..7eb12c8f 100644 --- a/sysom_web/src/locales/zh-CN/pages.js +++ b/sysom_web/src/locales/zh-CN/pages.js @@ -146,10 +146,11 @@ export default { 'pages.hotfix.title': '热补丁列表', 'pages.hotfix.created_at': '创建时间', 'pages.hotfix.kernel_version': '内核版本', - 'pages.hotfix.create_user': '创建人', + 'pages.hotfix.creator': '创建人', 'pages.hotfix.progress': '进度', - 'pages.hotfix.path': '路径', + 'pages.hotfix.patch_path': '补丁路径', 'pages.hotfix.delete_hotfix_not_exist': '要删除的hotfixID不存在', 'pages.hotfix.operation': '操作', 'pages.hotfix.delete': '删除', + 'pages.hotfix.building_status': '构建状态' }; \ No newline at end of file diff --git a/sysom_web/src/pages/hotfix/Make/index.jsx b/sysom_web/src/pages/hotfix/Make/index.jsx index e79cbb3d..f45d169e 100644 --- a/sysom_web/src/pages/hotfix/Make/index.jsx +++ b/sysom_web/src/pages/hotfix/Make/index.jsx @@ -2,8 +2,8 @@ import { useRef } from 'react'; import { useIntl, FormattedMessage } from 'umi'; import { PageContainer } from '@ant-design/pro-layout'; import ProTable from '@ant-design/pro-table'; -import { Popconfirm, message } from 'antd'; -import { getHotfixList, delHotfix } from '../service'; +import { Popconfirm, message, Switch, Upload, Button, Select, Collapse} from 'antd'; +import { getHotfixList, delHotfix, setNormal } from '../service'; const handleDelHotfix = async (record) => { const hide = message.loading('正在删除'); @@ -24,6 +24,10 @@ const handleDelHotfix = async (record) => { } } +const changeNormal = (id) => { + setNormal(id) +}; + const HotfixList = () => { const actionRef = useRef(); const intl = useIntl(); @@ -87,9 +91,43 @@ const HotfixList = () => { }}> + | + + 查看日志 ], }, + { + title: , + key: 'normal', + dataIndex: 'normal', + valueType: 'option', + hideInSearch: true, + render: (_, record) => [ + { + + { + if (record.id == undefined) { + message.error(intl.formatMessage({ + id: 'pages.hotfix.delete_hotfix_not_exist', + defaultMessage: "Not allow to delete this hotfix" + })) + console.log(intl.formatMessage({ + id: 'pages.hotfix.delete_hotfix_not_exist', + defaultMessage: "Not allow to delete this hotfix" + })) + } else { + await changeNormal(record.id); + actionRef.current?.reload(); + } + }}> + + + }} + /> + ] + } ]; return ( diff --git a/sysom_web/src/pages/hotfix/service.js b/sysom_web/src/pages/hotfix/service.js index 1992e569..ab546648 100644 --- a/sysom_web/src/pages/hotfix/service.js +++ b/sysom_web/src/pages/hotfix/service.js @@ -1,3 +1,4 @@ +import { async } from "@antv/x6/lib/registry/marker/async"; import { request } from "umi"; export async function getHotfixList(params, options) { @@ -21,7 +22,21 @@ export async function delHotfix(id, token, options) { 'Authorization': token, }, data: { - id //格式? + id + }, + ...(options || {}), + }) +} + +export async function setNormal(id) { + return request('/api/v1/hotfix/delete_hotfix/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': token, + }, + data: { + id }, ...(options || {}), }) -- Gitee From 7e6574bf4f5c430350befad6809635ff472655f5 Mon Sep 17 00:00:00 2001 From: ydzhang Date: Mon, 5 Dec 2022 20:42:02 +0800 Subject: [PATCH 07/56] Added button of showing status of normal --- sysom_web/src/pages/hotfix/Make/index.jsx | 43 +++++++++++------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/sysom_web/src/pages/hotfix/Make/index.jsx b/sysom_web/src/pages/hotfix/Make/index.jsx index f45d169e..bf542a77 100644 --- a/sysom_web/src/pages/hotfix/Make/index.jsx +++ b/sysom_web/src/pages/hotfix/Make/index.jsx @@ -28,6 +28,7 @@ const changeNormal = (id) => { setNormal(id) }; + const HotfixList = () => { const actionRef = useRef(); const intl = useIntl(); @@ -91,7 +92,7 @@ const HotfixList = () => { }}> - | + , 查看日志 @@ -104,28 +105,24 @@ const HotfixList = () => { valueType: 'option', hideInSearch: true, render: (_, record) => [ - { - - { - if (record.id == undefined) { - message.error(intl.formatMessage({ - id: 'pages.hotfix.delete_hotfix_not_exist', - defaultMessage: "Not allow to delete this hotfix" - })) - console.log(intl.formatMessage({ - id: 'pages.hotfix.delete_hotfix_not_exist', - defaultMessage: "Not allow to delete this hotfix" - })) - } else { - await changeNormal(record.id); - actionRef.current?.reload(); - } - }}> - - - }} - /> + { + if (record.id == undefined) { + message.error(intl.formatMessage({ + id: 'pages.hotfix.delete_hotfix_not_exist', + defaultMessage: "Not allow to delete this hotfix" + })) + console.log(intl.formatMessage({ + id: 'pages.hotfix.delete_hotfix_not_exist', + defaultMessage: "Not allow to delete this hotfix" + })) + + } else { + changeNormal(record.id); + actionRef.current?.reload(); + }}} + onCancel={async () => { console.log(record.id); record.normal=0}} > + + ] } ]; -- Gitee From 048dceeec0d8caa3567b26e0634e552e7884d94f Mon Sep 17 00:00:00 2001 From: ydzhang Date: Mon, 5 Dec 2022 22:03:33 +0800 Subject: [PATCH 08/56] Added os select button and file upload button --- sysom_server/sysom_api/apps/hotfix/urls.py | 1 + sysom_server/sysom_api/apps/hotfix/views.py | 7 ++++ sysom_web/src/locales/zh-CN/pages.js | 6 +++- sysom_web/src/pages/Welcome.less | 2 +- sysom_web/src/pages/hotfix/Make/index.jsx | 37 +++++++++++++++++++++ sysom_web/src/pages/hotfix/service.js | 2 +- 6 files changed, 52 insertions(+), 3 deletions(-) diff --git a/sysom_server/sysom_api/apps/hotfix/urls.py b/sysom_server/sysom_api/apps/hotfix/urls.py index 058b1d9c..f8bdd4ba 100644 --- a/sysom_server/sysom_api/apps/hotfix/urls.py +++ b/sysom_server/sysom_api/apps/hotfix/urls.py @@ -13,4 +13,5 @@ urlpatterns = [ path('api/v1/hotfix/create_hotfix/', views.HotfixAPIView.as_view({'post': 'create_hotfix'})), path('api/v1/hotfix/get_hotfix_list/', views.HotfixAPIView.as_view({'get': 'get_hotfixlist'})), path('api/v1/hotfix/delete_hotfix/', views.HotfixAPIView.as_view({'delete': 'delete_hotfix'})), + path('api/v1/hotfix/set_normal/', views.HotfixAPIView.as_view({'post': 'set_normal'})), ] diff --git a/sysom_server/sysom_api/apps/hotfix/views.py b/sysom_server/sysom_api/apps/hotfix/views.py index c7e4d80c..1302e765 100644 --- a/sysom_server/sysom_api/apps/hotfix/views.py +++ b/sysom_server/sysom_api/apps/hotfix/views.py @@ -70,3 +70,10 @@ class HotfixAPIView(GenericViewSet, print("saved the object") return success(result={}, message="invoke delete_hotfix") + def set_normal(self, request): + if request.method == 'POST': + hotfix = HotfixModel.objects.filter(id=request.data["id"]).first() + hotfix.normal = 1 + hotfix.save() + return success(result={"msg":"scuuessfully update normal status"}, message="normal status updated") + diff --git a/sysom_web/src/locales/zh-CN/pages.js b/sysom_web/src/locales/zh-CN/pages.js index 7eb12c8f..981b5a44 100644 --- a/sysom_web/src/locales/zh-CN/pages.js +++ b/sysom_web/src/locales/zh-CN/pages.js @@ -152,5 +152,9 @@ export default { 'pages.hotfix.delete_hotfix_not_exist': '要删除的hotfixID不存在', 'pages.hotfix.operation': '操作', 'pages.hotfix.delete': '删除', - 'pages.hotfix.building_status': '构建状态' + 'pages.hotfix.building_status': '构建状态', + 'pages.hotfix.normal': '转正式包', + 'pages.hotfix.os_type': '操作系统', + 'pages.hotfix.patch_name': '补丁名称', + 'pages.hotfix.upload': '文件上传', }; \ No newline at end of file diff --git a/sysom_web/src/pages/Welcome.less b/sysom_web/src/pages/Welcome.less index 187d3ded..0ccbc885 100644 --- a/sysom_web/src/pages/Welcome.less +++ b/sysom_web/src/pages/Welcome.less @@ -24,7 +24,7 @@ } .menuCenter{ position: absolute; - width: 50%; + width: 60%; left: 50%; transform: translate(-50%,-5%); line-height: 48px!important; diff --git a/sysom_web/src/pages/hotfix/Make/index.jsx b/sysom_web/src/pages/hotfix/Make/index.jsx index bf542a77..57852110 100644 --- a/sysom_web/src/pages/hotfix/Make/index.jsx +++ b/sysom_web/src/pages/hotfix/Make/index.jsx @@ -4,6 +4,7 @@ import { PageContainer } from '@ant-design/pro-layout'; import ProTable from '@ant-design/pro-table'; import { Popconfirm, message, Switch, Upload, Button, Select, Collapse} from 'antd'; import { getHotfixList, delHotfix, setNormal } from '../service'; +import { UploadOutlined } from '@ant-design/icons'; const handleDelHotfix = async (record) => { const hide = message.loading('正在删除'); @@ -28,6 +29,17 @@ const changeNormal = (id) => { setNormal(id) }; +const uploadProps = { + action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', + onChange({ file, fileList }) { + if (file.status !== 'uploading') { + console.log(file, fileList); + } + }, + defaultFileList: [ + + ], +}; const HotfixList = () => { const actionRef = useRef(); @@ -40,6 +52,18 @@ const HotfixList = () => { valueType: 'message', hideInSearch: true, }, + { + title: , + dataIndex: 'os_type', + key: 'os_type', + dataIndex: 'os_type', + hideInTable: true, + render: (_, record) => [ + ], + renderFormItem: (item, _a, form) => { + return