From b83265a5af120062359fa89eb8b9d742945d8549 Mon Sep 17 00:00:00 2001 From: qz_cx Date: Fri, 10 Oct 2025 13:44:00 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81Click=20on=20the=20data=20to=20jump?= =?UTF-8?q?=20to=20the=20data=20details=202=E3=80=81All=20page=20functions?= =?UTF-8?q?=20have=20been=20completed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appStore/project/views.py | 72 +++++++-------- appStore/testCase/models.py | 2 +- appStore/userConfig/models.py | 1 + appStore/userConfig/views.py | 2 + templates/front-project/src/utils/utils.js | 9 ++ .../src/views/testViews/ConfigList.vue | 18 +--- .../src/views/testViews/DoTest.vue | 91 +++++++++++-------- 7 files changed, 102 insertions(+), 93 deletions(-) diff --git a/appStore/project/views.py b/appStore/project/views.py index e42e537..2712454 100644 --- a/appStore/project/views.py +++ b/appStore/project/views.py @@ -97,12 +97,12 @@ class ProjectViewSet(CusModelViewSet): def merge_data(self, request, *args, **kwargs): env_id = request.data.get('env_id', None) env_ids = request.data.get('env_ids', None) - user_name = Project.objects.filter(env_id=env_id[0]).first().user_name + user_name = Project.objects.filter(env_id=env_id).first().user_name if not (request.user.is_superuser or request.user.chinese_name == user_name): return json_response({}, status.HTTP_205_RESET_CONTENT, '只能合并自己管理的数据') # 1、判断是否属于同一个项目等 - base_project = Project.objects.filter(env_id=env_id[0]).first() + base_project = Project.objects.filter(env_id=env_id).first() project_names = list(set([d.project_name for d in Project.objects.filter(env_id__in=env_ids)])) user_names = list(set([d.user_name for d in Project.objects.filter(env_id__in=env_ids)])) os_versions = list(set([d.os_version for d in Project.objects.filter(env_id__in=env_ids)])) @@ -123,46 +123,46 @@ class ProjectViewSet(CusModelViewSet): cpu2006_number = -1 cpu2017_number = -1 # 多数据测试项目,project的表中在直接替换成这个数据 - if Unixbench.objects.filter(env_id=env_id[0]): - unixbench_mark_name_list = set([d.mark_name for d in Unixbench.objects.filter(env_id=env_id[0])]) + if Unixbench.objects.filter(env_id=env_id): + unixbench_mark_name_list = set([d.mark_name for d in Unixbench.objects.filter(env_id=env_id)]) unixbench_number = max(int(string[-1]) for string in unixbench_mark_name_list) - if Fio.objects.filter(env_id=env_id[0]): - fio_mark_name_list = set([d.mark_name for d in Fio.objects.filter(env_id=env_id[0])]) + if Fio.objects.filter(env_id=env_id): + fio_mark_name_list = set([d.mark_name for d in Fio.objects.filter(env_id=env_id)]) fio_number = max(int(string[-1]) for string in fio_mark_name_list) - if Iozone.objects.filter(env_id=env_id[0]): - iozone_mark_name_list = set([d.mark_name for d in Iozone.objects.filter(env_id=env_id[0])]) + if Iozone.objects.filter(env_id=env_id): + iozone_mark_name_list = set([d.mark_name for d in Iozone.objects.filter(env_id=env_id)]) iozone_number = max(int(string[-1]) for string in iozone_mark_name_list) - if Jvm2008.objects.filter(env_id=env_id[0]): - jvm2008_mark_name_list = set([d.mark_name for d in Jvm2008.objects.filter(env_id=env_id[0])]) + if Jvm2008.objects.filter(env_id=env_id): + jvm2008_mark_name_list = set([d.mark_name for d in Jvm2008.objects.filter(env_id=env_id)]) jvm2008_number = max(int(string[-1]) for string in jvm2008_mark_name_list) - if Cpu2006.objects.filter(env_id=env_id[0]): - cpu2006_mark_name_list = set([d.mark_name for d in Cpu2006.objects.filter(env_id=env_id[0])]) + if Cpu2006.objects.filter(env_id=env_id): + cpu2006_mark_name_list = set([d.mark_name for d in Cpu2006.objects.filter(env_id=env_id)]) cpu2006_number = max(int(string[-1]) for string in cpu2006_mark_name_list) - if Cpu2017.objects.filter(env_id=env_id[0]): - cpu2017_mark_name_list = set([d.mark_name for d in Cpu2017.objects.filter(env_id=env_id[0])]) + if Cpu2017.objects.filter(env_id=env_id): + cpu2017_mark_name_list = set([d.mark_name for d in Cpu2017.objects.filter(env_id=env_id)]) cpu2017_number = max(int(string[-1]) for string in cpu2017_mark_name_list) for id in env_ids: if Stream.objects.filter(env_id=id): - log.info('处理的stream的id是 %d,把stream_env = %d 改为 %d ,', Stream.objects.filter(env_id=id).first().id, id, env_id[0]) - Stream.objects.filter(env_id=id).update(env_id=env_id[0]) + log.info('处理的stream的id是 %d,把stream_env = %d 改为 %d ,', Stream.objects.filter(env_id=id).first().id, id, env_id) + Stream.objects.filter(env_id=id).update(env_id=env_id) if Lmbench.objects.filter(env_id=id): - log.info('处理的lmbench的id是 %d,把lmbench_env = %d 改为 %d ,', Lmbench.objects.filter(env_id=id).first().id, id, env_id[0]) - Lmbench.objects.filter(env_id=id).update(env_id=env_id[0]) + log.info('处理的lmbench的id是 %d,把lmbench_env = %d 改为 %d ,', Lmbench.objects.filter(env_id=id).first().id, id, env_id) + Lmbench.objects.filter(env_id=id).update(env_id=env_id) max_unixbench_number = 0 if Unixbench.objects.filter(env_id=id): for obj in Unixbench.objects.filter(env_id=id): new_unixbench_number = unixbench_number + (int(obj.mark_name[-1]) + 1) max_unixbench_number = max(max_unixbench_number, new_unixbench_number) new_mark_name = obj.mark_name[:-1] + str(new_unixbench_number) - obj.env_id = env_id[0] + obj.env_id = env_id obj.mark_name = new_mark_name - log.info('处理的unixbench的id是 %d,把unixbench_env = %d 改为 %d ,', obj.id, id, env_id[0]) + log.info('处理的unixbench的id是 %d,把unixbench_env = %d 改为 %d ,', obj.id, id, env_id) obj.save() unixbench_number = max_unixbench_number max_fio_number = 0 @@ -171,9 +171,9 @@ class ProjectViewSet(CusModelViewSet): new_fio_number = fio_number + (int(obj.mark_name[-1]) + 1) max_fio_number = max(max_fio_number, new_fio_number) new_mark_name = obj.mark_name[:-1] + str(new_fio_number) - obj.env_id = env_id[0] + obj.env_id = env_id obj.mark_name = new_mark_name - log.info('处理的fio的id是 %d,把fio_env = %d 改为 %d ,', obj.id, id, env_id[0]) + log.info('处理的fio的id是 %d,把fio_env = %d 改为 %d ,', obj.id, id, env_id) obj.save() fio_number = max_fio_number max_iozone_number = 0 @@ -182,9 +182,9 @@ class ProjectViewSet(CusModelViewSet): new_iozone_number = iozone_number + (int(obj.mark_name[-1]) + 1) max_iozone_number = max(max_iozone_number, new_iozone_number) new_mark_name = obj.mark_name[:-1] + str(new_iozone_number) - obj.env_id = env_id[0] + obj.env_id = env_id obj.mark_name = new_mark_name - log.info('处理的iozone的id是 %d,把iozone_env = %d 改为 %d ,', obj.id, id, env_id[0]) + log.info('处理的iozone的id是 %d,把iozone_env = %d 改为 %d ,', obj.id, id, env_id) obj.save() iozone_number = max_iozone_number max_jvm2008_number = 0 @@ -193,9 +193,9 @@ class ProjectViewSet(CusModelViewSet): new_jvm2008_number = jvm2008_number + (int(obj.mark_name[-1]) + 1) max_jvm2008_number = max(max_jvm2008_number, new_jvm2008_number) new_mark_name = obj.mark_name[:-1] + str(new_jvm2008_number) - obj.env_id = env_id[0] + obj.env_id = env_id obj.mark_name = new_mark_name - log.info('处理的jvm2008的id是 %d,把jvm2008_env = %d 改为 %d ,', obj.id, id, env_id[0]) + log.info('处理的jvm2008的id是 %d,把jvm2008_env = %d 改为 %d ,', obj.id, id, env_id) obj.save() jvm2008_number = max_jvm2008_number max_cpu2006_number = 0 @@ -204,9 +204,9 @@ class ProjectViewSet(CusModelViewSet): new_cpu2006_number = cpu2006_number + (int(obj.mark_name[-1]) + 1) max_cpu2006_number = max(max_cpu2006_number, new_cpu2006_number) new_mark_name = obj.mark_name[:-1] + str(new_cpu2006_number) - obj.env_id = env_id[0] + obj.env_id = env_id obj.mark_name = new_mark_name - log.info('处理的cpu2006的id是 %d,把cpu2006_env = %d 改为 %d ,', obj.id, id, env_id[0]) + log.info('处理的cpu2006的id是 %d,把cpu2006_env = %d 改为 %d ,', obj.id, id, env_id) obj.save() cpu2006_number = max_cpu2006_number max_cpu2017_number = 0 @@ -215,9 +215,9 @@ class ProjectViewSet(CusModelViewSet): new_cpu2017_number = cpu2017_number + (int(obj.mark_name[-1]) + 1) max_cpu2017_number = max(max_cpu2017_number, new_cpu2017_number) new_mark_name = obj.mark_name[:-1] + str(new_cpu2017_number) - obj.env_id = env_id[0] + obj.env_id = env_id obj.mark_name = new_mark_name - log.info('处理的cpu2017的id是 %d,把cpu2017_env = %d 改为 %d ,', obj.id, id, env_id[0]) + log.info('处理的cpu2017的id是 %d,把cpu2017_env = %d 改为 %d ,', obj.id, id, env_id) obj.save() cpu2017_number = max_cpu2017_number @@ -225,7 +225,7 @@ class ProjectViewSet(CusModelViewSet): # 3、合并all_json_data文件 json_file_path = '/var/www/html/all_json_data_file/' # 找到需要合并的全部数据 - base_env_time = Env.objects.filter(id=env_id[0]).first().time + base_env_time = Env.objects.filter(id=env_id).first().time compar_env_times = list(set([d.time for d in Env.objects.filter(id__in=env_ids)])) if os.path.exists(json_file_path + base_env_time+'.json'): @@ -339,14 +339,14 @@ class ProjectViewSet(CusModelViewSet): cpu2017_max_number = cpu2017_max_number + max(compar_cpu2017_keys) + 1 if compar_cpu2017_keys else cpu2017_max_number new_json_file = json_file_path + str(base_env_time)+'.json' - os.rename(new_json_file, new_json_file + '-env_' + str(env_id[0]) + '-base-old') + os.rename(new_json_file, new_json_file + '-env_' + str(env_id) + '-base-old') with open(new_json_file, 'w', encoding='utf-8') as f_new: json.dump(data_, f_new) # 5、删除旧的数据 for name in compar_env_times: - os.rename(json_file_path + str(name)+'.json', json_file_path + str(name)+'.json-env_' + str(env_id[0]) +'-compar-old') + os.rename(json_file_path + str(name)+'.json', json_file_path + str(name)+'.json-env_' + str(env_id) +'-compar-old') log.info(new_json_file, '数据和', json_file_path + str(name) + '.json' + '数据合并完成') @@ -354,9 +354,9 @@ class ProjectViewSet(CusModelViewSet): Env.objects.filter(id__in=env_ids).delete() Project.objects.filter(env_id__in=env_ids).delete() # 5、修改project表对应测试项目的值 - stream_number = len(Stream.objects.filter(env_id=env_id[0])) - lmbench_number = len(Lmbench.objects.filter(env_id=env_id[0])) - Project.objects.filter(env_id=env_id[0]).update(stream=stream_number, lmbench=lmbench_number, + stream_number = len(Stream.objects.filter(env_id=env_id)) + lmbench_number = len(Lmbench.objects.filter(env_id=env_id)) + Project.objects.filter(env_id=env_id).update(stream=stream_number, lmbench=lmbench_number, unixbench=unixbench_number + 1, fio=fio_number + 1, iozone=iozone_number + 1, jvm2008=jvm2008_number + 1, cpu2006=cpu2006_number + 1, cpu2017=cpu2017_number + 1) diff --git a/appStore/testCase/models.py b/appStore/testCase/models.py index 9e8f5ba..80c476a 100644 --- a/appStore/testCase/models.py +++ b/appStore/testCase/models.py @@ -25,7 +25,7 @@ class TestCase(models.Model): jvm2008 = models.IntegerField(default=0, verbose_name='几组jvm2008数据') cpu2006 = models.IntegerField(default=0, verbose_name='几组cpu2006数据') cpu2017 = models.IntegerField(default=0, verbose_name='几组cpu2017数据') - user_name = models.CharField(max_length=255, verbose_name='测试人员', ) + user_name = models.CharField(max_length=255, verbose_name='测试人员') test_result = models.CharField(max_length=255, verbose_name='测试结果反馈', null=True, blank=True) # 如果有多项也是拼接 result_log_name = models.CharField(max_length=255, verbose_name='日志文件路径的base部分') is_error = models.BooleanField(default=False,verbose_name="是否是错误列表所需要的") diff --git a/appStore/userConfig/models.py b/appStore/userConfig/models.py index a977a80..d447127 100644 --- a/appStore/userConfig/models.py +++ b/appStore/userConfig/models.py @@ -10,6 +10,7 @@ from django.db import models # Create your models here. class UserConfig(models.Model): """用户配置表""" + config_name = models.CharField(max_length=50, verbose_name='配置文件名称') user_name = models.CharField(max_length=50, verbose_name='用户名称') user_password = models.CharField(max_length=50, verbose_name='用户密码') project_name = models.CharField(max_length=50, verbose_name='测试项目名称') diff --git a/appStore/userConfig/views.py b/appStore/userConfig/views.py index 60d661a..97b4fa3 100644 --- a/appStore/userConfig/views.py +++ b/appStore/userConfig/views.py @@ -35,6 +35,7 @@ class UserConfigViewSet(CusModelViewSet): user_config_data = {} user_config_data['user_name'] = request.user.username user_config_data['user_password'] = request.data.get('user_password') + user_config_data['config_name'] = request.data.get('config_name') user_config_data['project_name'] = request.data.get('project_name') user_config_data['test_ip'] = request.data.get('test_ip') user_config_data['test_password'] = request.data.get('test_password') @@ -75,6 +76,7 @@ class UserConfigViewSet(CusModelViewSet): config_data = UserConfig.objects.get(id=id) #get=filter.first() if not config_data: return json_response({}, status.HTTP_205_RESET_CONTENT, '没有该数据') + config_data.config_name = request.data.get('config_name') config_data.user_password = request.data.get('user_password') config_data.project_name = request.data.get('project_name') config_data.test_ip = request.data.get('test_ip') diff --git a/templates/front-project/src/utils/utils.js b/templates/front-project/src/utils/utils.js index e2013a3..6fe997f 100644 --- a/templates/front-project/src/utils/utils.js +++ b/templates/front-project/src/utils/utils.js @@ -14,6 +14,7 @@ export default { itemKey: 0, //更新数据后生成随机数从而刷新页面数据 }; }, + methods: { //分页 handleSizeChange(val) { @@ -37,5 +38,13 @@ export default { this.$refs.testTable.toggleRowSelection(val.pop()); } }, + //数据页面时点击后跳转至对应数据详情页面 + handleRowClick(row) { + const List1 = [row.stream, row.lmbench, row.unixbench, row.fio, row.iozone, row.jvm2008, row.cpu2006, row.cpu2017] + const List2 = ['stream', 'lmbench', 'unixbench', 'fio', 'iozone', 'jvm2008', 'cpu2006', 'cpu2017'] + const firstNonZeroIndex = List1.findIndex(num => num !== 0); + this.selectedType = List2[firstNonZeroIndex] + this.$router.push({name: this.selectedType, "params": {baseId: row.env_id, comparsionIds: ''}}); + }, }, }; \ No newline at end of file diff --git a/templates/front-project/src/views/testViews/ConfigList.vue b/templates/front-project/src/views/testViews/ConfigList.vue index 3ec90fd..6ed1d3b 100644 --- a/templates/front-project/src/views/testViews/ConfigList.vue +++ b/templates/front-project/src/views/testViews/ConfigList.vue @@ -15,21 +15,10 @@
- - - - - - - - - - - + - + @@ -93,9 +82,6 @@ export default { this.total = this.configData.length; }); }, - modify(row) { - this.$router.push({path: '/test/do_test/', "query": {configID:row.id }}) - }, del(row) { this.$confirm(`确认删除此行数据吗?`, '提示', { confirmButtonText: '确定', diff --git a/templates/front-project/src/views/testViews/DoTest.vue b/templates/front-project/src/views/testViews/DoTest.vue index 308d751..3e1e33d 100644 --- a/templates/front-project/src/views/testViews/DoTest.vue +++ b/templates/front-project/src/views/testViews/DoTest.vue @@ -12,6 +12,9 @@
+ + + @@ -56,7 +59,8 @@ cpu2006_loongarch64 cpu2017 - 一键摸底 + 一键摸底 + 还原上次测试 @@ -80,7 +84,7 @@ - + @@ -109,8 +113,7 @@ - - + @@ -141,6 +144,7 @@ export default { data() { return { labelPosition: ref('right'), + configName: '', projectName: '', userPassword: '', yamlData: baseYamlData, @@ -164,6 +168,7 @@ export default { yamlType: '', configDialog: false, + configNameDialog: false, configID: 0, configData: '', configDatas: [], @@ -177,9 +182,40 @@ export default { if (this.$route.query.configID) { this.configID = this.$route.query.configID } - user_config('get', {configID: this.configID}).then(response => { + + this.machineOptions = [ + {label: '172.29.220.100', value: '172.29.220.100'}, + {label: '172.29.220.101', value: '172.29.220.101'}, + ] + }, + showYaml(yamlType) { + this.yamlDialog = true + this.yamlType = yamlType + }, + closeInfo() { + this.yamlDialog = false + this.configDialog = false + }, + changeYaml(yamlData) { + this.yamlData = yamlData + this.yamlDialog = false; + }, + doBase() { + this.iterations.stream = 50 + this.iterations.lmbench = 3 + this.iterations.unixbench = 3 + this.iterations.fio = 3 + this.iterations.iozone = 0 + this.iterations.jvm2008 = 1 + this.iterations.cpu2006 = 1 + this.iterations.cpu2017 = 0 + this.yamlData = baseYamlData + }, + lastTest(){ + user_config('get', {configID: 0}).then(response => { const config = response.data.data[0] this.configID = config.id + this.configName = config.config_name this.projectName = config.project_name this.userPassword = config.user_password this.iterations.stream = config.stream_number @@ -205,40 +241,10 @@ export default { this.testPassword = config.test_password this.message = config.message }) - - this.machineOptions =[ - {label: 'localhost1', value: 'localhost1'}, - {label: 'localhost2', value: 'localhost2'}, - ] - }, - showYaml(yamlType) { - this.yamlDialog = true - this.yamlType = yamlType - }, - closeInfo() { - this.yamlDialog = false - this.configDialog = false - }, - changeYaml(yamlData) { - this.yamlData = yamlData - this.yamlDialog = false; - }, - doBase() { - this.iterations.stream = 50 - this.iterations.lmbench = 3 - this.iterations.unixbench = 3 - this.iterations.fio = 3 - this.iterations.iozone = 0 - this.iterations.jvm2008 = 1 - this.iterations.cpu2006 = 1 - this.iterations.cpu2017 = 0 - this.yamlData = baseYamlData }, select() { - user_config('get').then(response => { - this.configDatas = response.data.data - }) + user_config('get').then(response => {this.configDatas = response.data.data}) this.configDialog = true }, @@ -280,6 +286,7 @@ export default { if (this.configID) { const formData = { id: this.configID, + config_name: this.configName, project_name: this.projectName, test_ip: this.testIP, test_password: this.testPassword, @@ -296,14 +303,17 @@ export default { message: this.message } user_config('put', formData).then(response => { - console.log(response) + ElMessage({message: response.data.message, type: 'success'}) }) } } }, + add() { if (this.check()) { + this.configNameDialog = true const formData = { + config_name: this.configName, project_name: this.projectName, test_ip: this.testIP, test_password: this.testPassword, @@ -320,13 +330,14 @@ export default { message: this.message } user_config('post', formData).then(response => { - console.log(response) + ElMessage({message: response.data.message, type: 'success'}) }) } }, sendTest() { if (this.check()) { const formData = { + config_name: this.configName, project_name: this.projectName, test_ip: this.testIP, test_password: this.testPassword, @@ -343,7 +354,7 @@ export default { message: this.message } do_test_case(formData).then(response => { - console.log(response.data.code); + console.log(response.data) this.projectName = '' this.testIP = '' this.testPassword = '' @@ -359,7 +370,7 @@ export default { this.yamlData = '' this.message = '' }); - ElMessage({message: '发起测试完成,正在跳转只测试列表页面', type: 'success'}); + ElMessage({message: '发起测试完成', type: 'success'}); } }, check() { -- Gitee