diff --git a/appStore/utils/common.py b/appStore/utils/common.py index ed9de490df32178648bd3b6aab9cadb1f17f0c8b..69339ae2577f98e245fde24be532de5925ecb56f 100644 --- a/appStore/utils/common.py +++ b/appStore/utils/common.py @@ -19,7 +19,6 @@ import subprocess from django.core.paginator import Paginator, EmptyPage from django.http import JsonResponse from rest_framework import pagination, status - from appStore.utils.constants import RESULT_LOG_FILE @@ -38,6 +37,7 @@ def json_response(data=None, code=None, message=None): } return JsonResponse(res) + def list_response(result, code, message): """ :param result: @@ -54,6 +54,7 @@ def list_response(result, code, message): res['message'] = message return JsonResponse(res) + def jwt_response_payload_handler(token, user=None, request=None): """ 自定义jwt认证成功返回数据 @@ -67,6 +68,7 @@ def jwt_response_payload_handler(token, user=None, request=None): 'code': 200, } + def get_error_message(serializer): """ 返回错误信息 @@ -76,6 +78,7 @@ def get_error_message(serializer): for _, error in serializer.errors.items(): return error[0] + class LimsPageSet(pagination.PageNumberPagination): """ 分页设置 @@ -86,6 +89,7 @@ class LimsPageSet(pagination.PageNumberPagination): max_page_size = 1000 page_query_param = 'page' + def get_page(data, objs): """ 进行分页 diff --git a/appStore/utils/customer_view.py b/appStore/utils/customer_view.py index 3891eb0d6e68dae159eeee59ce4b820af893b070..96ae975d515d89429a7f26d28fdc42c6a3ac8ee8 100644 --- a/appStore/utils/customer_view.py +++ b/appStore/utils/customer_view.py @@ -19,7 +19,7 @@ from django.urls import NoReverseMatch from django.utils.decorators import classonlymethod from django.views.decorators.csrf import csrf_exempt -from rest_framework import generics, views +from rest_framework import generics from rest_framework.reverse import reverse from appStore.utils.customer_mixin import CusRetrieveModelMixin, CusListModelMixin, CusCreateModelMixin, \ @@ -184,11 +184,7 @@ class ViewSetMixin(object): return action_urls -class ViewSet(ViewSetMixin, views.APIView): - """ - The base ViewSet class does not provide any actions by default. - """ - pass + class GenericViewSet(ViewSetMixin, generics.GenericAPIView): @@ -200,21 +196,6 @@ class GenericViewSet(ViewSetMixin, generics.GenericAPIView): pass -class CusReadOnlyModelViewSet(CusRetrieveModelMixin, - CusListModelMixin, - GenericViewSet): - """ - 只读 列表和详情 - """ - pass - - -class CusReadOnlyListModelViewSet(CusListModelMixin, - GenericViewSet): - """ - 只读列表 - """ - pass class CusModelViewSet(CusCreateModelMixin, @@ -229,28 +210,3 @@ class CusModelViewSet(CusCreateModelMixin, pass -class CusUpdateModelViewSet(CusUpdateModelMixin, - GenericViewSet): - """ - 只允许更新 - """ - pass - - -class CusCreateModelViewSet(CusCreateModelMixin, - GenericViewSet): - """ - 只允许创建 - """ - pass - - -class CusNotDeViewSet(CusCreateModelMixin, - CusRetrieveModelMixin, - CusUpdateModelMixin, - CusListModelMixin, - GenericViewSet): - """ - 不允许删除 - """ - pass diff --git a/templates/front-project/src/components/AllHeader.vue b/templates/front-project/src/components/AllHeader.vue index 4e3070d0cb3d6ecdac6a1dd40b6c3713d342eb9e..12706ab06445bd32f3f80b9a0fe400d631ecf12d 100644 --- a/templates/front-project/src/components/AllHeader.vue +++ b/templates/front-project/src/components/AllHeader.vue @@ -15,36 +15,39 @@ \ No newline at end of file diff --git a/templates/front-project/src/views/dataViews/Cpu2006Table.vue b/templates/front-project/src/views/dataViews/Cpu2006Table.vue index 6dc2a83c93246bc6bd664054376ab260cabe6d1f..14573adcd6f3da39e94c6ec684034819a4e9c32c 100644 --- a/templates/front-project/src/views/dataViews/Cpu2006Table.vue +++ b/templates/front-project/src/views/dataViews/Cpu2006Table.vue @@ -35,6 +35,7 @@ import {ElTable, ElTableColumn} from 'element-plus'; import TableHeader from "@/components/common/TableHeader.vue"; import {cpu2006} from "@/api/api.js"; import utils from '@/utils/utils'; +import '@/assets/css/global.css'; export default { name: 'cpu2006Table', @@ -59,25 +60,6 @@ export default { created() { this.getData() }, - computed: { - displayTableData() { - if (this.showAllData) { - return this.tableDatas; - } else { - let count = 1; - const modifiedTableData = JSON.parse(JSON.stringify(this.tableDatas)); // 深拷贝原始数据 - modifiedTableData.forEach(row => { - Object.entries(row).forEach(([key, value]) => { - if (typeof value === 'string' && key.startsWith('column') && value.startsWith('平均值')) { - row[key] = value + this.dataName.charAt(0).toUpperCase() + this.dataName.slice(1) + "#" + `${count}`; // 将"平均值"替换为"this.dataName#" - count++; - } - }); - }); - return modifiedTableData; - } - } - }, methods: { getData() { cpu2006(this.paramsData).then((response) => { @@ -90,32 +72,6 @@ export default { this.keysToHide = keysToHide; }); }, - // handleDataLoaded(value) { - // this.showAllData = value; - // // 在这里处理子组件的数据 - // }, - getCellClassName(row, key) { - let value = row[key]; - if (typeof value === 'string' && value.endsWith('%')) { - // 去除百分比符号 "%" - value = value.replace('%', ''); - // 将百分比转换为小数 - value = parseFloat(value); - if (value >= 5) { - return 'green-cell'; - } else if (value < -5) { - return 'red-cell'; - } - } - return ''; - }, - titleObjectSpanMethod({columnIndex}) { - if (columnIndex === 0) { - return [1, 4]; - } else if (columnIndex === 1 || columnIndex === 2 || columnIndex === 3) { - return [0, 0]; - } - }, // 单元格的处理方法 当前行row、当前列column、当前行号rowIndex、当前列号columnIndex objectSpanMethod({rowIndex, columnIndex}) { @@ -174,11 +130,7 @@ export default { diff --git a/templates/front-project/src/views/testViews/ConfigList.vue b/templates/front-project/src/views/testViews/ConfigList.vue index 6ed1d3bb8f7d20327a701d8a892e6775373f0afd..4810ddcaed0da173118418297353ec3ac8709b30 100644 --- a/templates/front-project/src/views/testViews/ConfigList.vue +++ b/templates/front-project/src/views/testViews/ConfigList.vue @@ -13,7 +13,7 @@
- @@ -60,26 +60,18 @@ export default { }, data() { return { - configData: [], + allDatas: [], userConfig: {}, }; }, - computed: { - showData() { - return this.configData.slice( - (this.currentPage - 1) * this.pageSize, - this.currentPage * this.pageSize - ); - }, - }, created() { this.getData() }, methods: { getData(){ user_config('get', {}).then((response) => { - this.configData = response.data.data; - this.total = this.configData.length; + this.allDatas = response.data.data; + this.total = this.allDatas.length; }); }, del(row) { diff --git a/templates/front-project/src/views/testViews/DoTest.vue b/templates/front-project/src/views/testViews/DoTest.vue index 3e1e33d7346370afd2dd26d45f5e1cbb3f550b79..98f3f784a3f7e13647144ac4c694109e52826a01 100644 --- a/templates/front-project/src/views/testViews/DoTest.vue +++ b/templates/front-project/src/views/testViews/DoTest.vue @@ -13,38 +13,38 @@
- + - + - + - + - + - + - + - + - + - + - + @@ -64,7 +64,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -85,7 +85,7 @@ - +
@@ -99,12 +99,12 @@
- @@ -136,7 +136,7 @@ import {ElMessage} from 'element-plus' import {do_test_case, user_config} from "@/api/api"; export default { - name: 'sendTest', + name: 'doTest', components: { AllHeader, Menu, @@ -144,31 +144,31 @@ export default { data() { return { labelPosition: ref('right'), - configName: '', - projectName: '', - userPassword: '', - yamlData: baseYamlData, - testIP: '', - testPassword: '', - message: '', - iterations: { - stream: '', - lmbench: '', - unixbench: '', - fio: '', - iozone: '', - jvm2008: '', - cpu2006: '', - cpu2006_loongarch64: '', - cpu2017: '', + formData: { + configName: '', + projectName: '', + userPassword: '', + yamlData: baseYamlData, + testIP: '', + testPassword: '', + message: '', + iterations: { + stream: '', + lmbench: '', + unixbench: '', + fio: '', + iozone: '', + jvm2008: '', + cpu2006: '', + cpu2006_loongarch64: '', + cpu2017: '', + }, }, - machineOptions: [], yamlDialog: false, - yamlType: '', - configDialog: false, configNameDialog: false, + yamlType: '', configID: 0, configData: '', configDatas: [], @@ -178,55 +178,51 @@ export default { this.getData() }, methods: { - getData() { - if (this.$route.query.configID) { - this.configID = this.$route.query.configID - } - - this.machineOptions = [ - {label: '172.29.220.100', value: '172.29.220.100'}, - {label: '172.29.220.101', value: '172.29.220.101'}, - ] - }, + getData() {}, + //展示yaml文件 showYaml(yamlType) { this.yamlDialog = true this.yamlType = yamlType }, + //关闭对话框 closeInfo() { this.yamlDialog = false this.configDialog = false }, - changeYaml(yamlData) { - this.yamlData = yamlData + //修改yaml文件 + putYaml(yamlData) { + this.formData.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 + this.formData.iterations.stream = 50 + this.formData.iterations.lmbench = 3 + this.formData.iterations.unixbench = 3 + this.formData.iterations.fio = 3 + this.formData.iterations.iozone = 0 + this.formData.iterations.jvm2008 = 1 + this.formData.iterations.cpu2006 = 1 + this.formData.iterations.cpu2017 = 0 + this.formData.yamlData = baseYamlData }, - lastTest(){ + //最后一次测试数据 + 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 - this.iterations.lmbench = config.lmbench_number - this.iterations.unixbench = config.unixbench_number - this.iterations.fio = config.fio_number - this.iterations.iozone = config.iozone_number - this.iterations.jvm2008 = config.jvm2008_number - this.iterations.cpu2006 = config.cpu2006_number - this.iterations.cpu2017 = config.cpu2017_number - this.yamlData = { + this.formData.configName = config.config_name + this.formData.projectName = config.project_name + this.formData.userPassword = config.user_password + this.formData.iterations.stream = config.stream_number + this.formData.iterations.lmbench = config.lmbench_number + this.formData.iterations.unixbench = config.unixbench_number + this.formData.iterations.fio = config.fio_number + this.formData.iterations.iozone = config.iozone_number + this.formData.iterations.jvm2008 = config.jvm2008_number + this.formData.iterations.cpu2006 = config.cpu2006_number + this.formData.iterations.cpu2017 = config.cpu2017_number + this.formData.yamlData = { stream: config.stream_config, lmbench: config.lmbench_config, unixbench: config.unixbench_config, @@ -237,17 +233,19 @@ export default { cpu2006_loongarch64: config.cpu2006_loongarch64_config, cpu2017: config.cpu2017_config, } - this.testIP = config.test_ip - this.testPassword = config.test_password - this.message = config.message + this.formData.testIP = config.test_ip + this.formData.testPassword = config.test_password + this.formData.message = config.message }) }, - + //选中配置列表 select() { - user_config('get').then(response => {this.configDatas = response.data.data}) + user_config('get').then(response => { + this.configDatas = response.data.data + }) this.configDialog = true }, - + //选择框只能单选 handleSelection(val) { this.configData = val[0]; if (val.length > 1) { @@ -255,52 +253,55 @@ export default { this.$refs.configTable.toggleRowSelection(val.pop()); } }, - + //选中配置 selectConfig() { - this.projectName = this.configData.project_name - this.userPassword = this.configData.user_password - this.iterations.stream = this.configData.stream_number - this.iterations.lmbench = this.configData.lmbench_number - this.iterations.unixbench = this.configData.unixbench_number - this.iterations.fio = this.configData.fio_number - this.iterations.iozone = this.configData.iozone_number - this.iterations.jvm2008 = this.configData.jvm2008_number - this.iterations.cpu2006 = this.configData.cpu2006_number - this.iterations.cpu2017 = this.configData.cpu2017_number - this.yamlData.stream = this.configData.stream_config - this.yamlData.lmbench = this.configData.lmbench_config - this.yamlData.unixbench = this.configData.unixbench_config - this.yamlData.fio = this.configData.fio_config - this.yamlData.iozone = this.configData.iozone_config - this.yamlData.cpu2006 = this.configData.cpu2006_config - this.yamlData.cpu2006_loongarch64_config = this.configData.cpu2006_loongarch64_config_config - this.yamlData.cpu2017 = this.configData.cpu2017_config - this.testIP = this.configData.test_ip - this.testPassword = this.configData.test_password - this.message = this.configData.message + this.configID = this.configData.id + this.formData.configName = this.configData.config_name + this.formData.projectName = this.configData.project_name + this.formData.userPassword = this.configData.user_password + this.formData.iterations.stream = this.configData.stream_number + this.formData.iterations.lmbench = this.configData.lmbench_number + this.formData.iterations.unixbench = this.configData.unixbench_number + this.formData.iterations.fio = this.configData.fio_number + this.formData.iterations.iozone = this.configData.iozone_number + this.formData.iterations.jvm2008 = this.configData.jvm2008_number + this.formData.iterations.cpu2006 = this.configData.cpu2006_number + this.formData.iterations.cpu2017 = this.configData.cpu2017_number + this.formData.yamlData.stream = this.configData.stream_config + this.formData.yamlData.lmbench = this.configData.lmbench_config + this.formData.yamlData.unixbench = this.configData.unixbench_config + this.formData.yamlData.fio = this.configData.fio_config + this.formData.yamlData.iozone = this.configData.iozone_config + this.formData.yamlData.cpu2006 = this.configData.cpu2006_config + this.formData.yamlData.cpu2006_loongarch64_config = this.configData.cpu2006_loongarch64_config_config + this.formData.yamlData.cpu2017 = this.configData.cpu2017_config + this.formData.testIP = this.configData.test_ip + this.formData.testPassword = this.configData.test_password + this.formData.message = this.configData.message this.configDialog = false }, - + //更新配置 update() { if (this.check()) { + console.log(this.configID) if (this.configID) { const formData = { id: this.configID, - config_name: this.configName, - project_name: this.projectName, - test_ip: this.testIP, - test_password: this.testPassword, - user_password: this.userPassword, - stream: this.iterations.stream, - lmbench: this.iterations.lmbench, - unixbench: this.iterations.unixbench, - fio: this.iterations.fio, - iozone: this.iterations.iozone, - jvm2008: this.iterations.jvm2008, - cpu2006: this.iterations.cpu2006, - cpu2017: this.iterations.cpu2017, - yaml: this.yamlData, - message: this.message + config_name: this.formData.configName, + project_name: this.formData.projectName, + test_ip: this.formData.testIP, + test_password: this.formData.testPassword, + user_password: this.formData.userPassword, + stream: this.formData.iterations.stream, + lmbench: this.formData.iterations.lmbench, + unixbench: this.formData.iterations.unixbench, + fio: this.formData.iterations.fio, + iozone: this.formData.iterations.iozone, + jvm2008: this.formData.iterations.jvm2008, + cpu2006: this.formData.iterations.cpu2006, + cpu2017: this.formData.iterations.cpu2017, + yaml: this.formData.yamlData, + message: this.formData.message, } user_config('put', formData).then(response => { ElMessage({message: response.data.message, type: 'success'}) @@ -308,89 +309,92 @@ export default { } } }, - + //新增配置 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, - user_password: this.userPassword, - stream: this.iterations.stream, - lmbench: this.iterations.lmbench, - unixbench: this.iterations.unixbench, - fio: this.iterations.fio, - iozone: this.iterations.iozone, - jvm2008: this.iterations.jvm2008, - cpu2006: this.iterations.cpu2006, - cpu2017: this.iterations.cpu2017, - yaml: this.yamlData, - message: this.message + config_name: this.formData.configName, + project_name: this.formData.projectName, + test_ip: this.formData.testIP, + test_password: this.formData.testPassword, + user_password: this.formData.userPassword, + stream: this.formData.iterations.stream, + lmbench: this.formData.iterations.lmbench, + unixbench: this.formData.iterations.unixbench, + fio: this.formData.iterations.fio, + iozone: this.formData.iterations.iozone, + jvm2008: this.formData.iterations.jvm2008, + cpu2006: this.formData.iterations.cpu2006, + cpu2017: this.formData.iterations.cpu2017, + yaml: this.formData.yamlData, + message: this.formData.message } user_config('post', formData).then(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, - user_password: this.userPassword, - stream: this.iterations.stream, - lmbench: this.iterations.lmbench, - unixbench: this.iterations.unixbench, - fio: this.iterations.fio, - iozone: this.iterations.iozone, - jvm2008: this.iterations.jvm2008, - cpu2006: this.iterations.cpu2006, - cpu2017: this.iterations.cpu2017, - yaml: this.yamlData, - message: this.message + config_name: this.formData.configName, + project_name: this.formData.projectName, + test_ip: this.formData.testIP, + test_password: this.formData.testPassword, + user_password: this.formData.userPassword, + stream: this.formData.iterations.stream, + lmbench: this.formData.iterations.lmbench, + unixbench: this.formData.iterations.unixbench, + fio: this.formData.iterations.fio, + iozone: this.formData.iterations.iozone, + jvm2008: this.formData.iterations.jvm2008, + cpu2006: this.formData.iterations.cpu2006, + cpu2017: this.formData.iterations.cpu2017, + yaml: this.formData.yamlData, + message: this.formData.message } do_test_case(formData).then(response => { console.log(response.data) - this.projectName = '' - this.testIP = '' - this.testPassword = '' - this.userPassword = '' - this.iterations.stream = '' - this.iterations.lmbench = '' - this.iterations.unixbench = '' - this.iterations.fio = '' - this.iterations.iozone = '' - this.iterations.jvm2008 = '' - this.iterations.cpu2006 = '' - this.iterations.cpu2017 = '' - this.yamlData = '' - this.message = '' + this.formData.configName = '' + this.formData.projectName = '' + this.formData.testIP = '' + this.formData.testPassword = '' + this.formData.userPassword = '' + this.formData.iterations.stream = '' + this.formData.iterations.lmbench = '' + this.formData.iterations.unixbench = '' + this.formData.iterations.fio = '' + this.formData.iterations.iozone = '' + this.formData.iterations.jvm2008 = '' + this.formData.iterations.cpu2006 = '' + this.formData.iterations.cpu2017 = '' + this.formData.yamlData = '' + this.formData.message = '' }); ElMessage({message: '发起测试完成', type: 'success'}); } }, + //验证数据 check() { - if (!this.projectName) { + if (!this.formData.projectName) { ElMessage({message: "项目名称不能为空", type: 'error'}); return false; } - if (!this.userPassword) { + if (!this.formData.userPassword) { ElMessage({message: "kytuning用户密码不能为空", type: 'error'}); return false; } const iterations = { - stream: this.iterations.stream !== '' ? parseInt(this.iterations.stream) : 0, - lmbench: this.iterations.lmbench !== '' ? parseInt(this.iterations.lmbench) : 0, - unixbench: this.iterations.unixbench !== '' ? parseInt(this.iterations.unixbench) : 0, - fio: this.iterations.fio !== '' ? parseInt(this.iterations.fio) : 0, - iozone: this.iterations.iozone !== '' ? parseInt(this.iterations.iozone) : 0, - jvm2008: this.iterations.jvm2008 !== '' ? parseInt(this.iterations.jvm2008) : 0, - cpu2006: this.iterations.cpu2006 !== '' ? parseInt(this.iterations.cpu2006) : 0, - cpu2017: this.iterations.cpu2017 !== '' ? parseInt(this.iterations.cpu2017) : 0, + stream: this.formData.iterations.stream !== '' ? parseInt(this.formData.iterations.stream) : 0, + lmbench: this.formData.iterations.lmbench !== '' ? parseInt(this.formData.iterations.lmbench) : 0, + unixbench: this.formData.iterations.unixbench !== '' ? parseInt(this.formData.iterations.unixbench) : 0, + fio: this.formData.iterations.fio !== '' ? parseInt(this.formData.iterations.fio) : 0, + iozone: this.formData.iterations.iozone !== '' ? parseInt(this.formData.iterations.iozone) : 0, + jvm2008: this.formData.iterations.jvm2008 !== '' ? parseInt(this.formData.iterations.jvm2008) : 0, + cpu2006: this.formData.iterations.cpu2006 !== '' ? parseInt(this.formData.iterations.cpu2006) : 0, + cpu2017: this.formData.iterations.cpu2017 !== '' ? parseInt(this.formData.iterations.cpu2017) : 0, }; let result = true for (const key in iterations) { @@ -401,7 +405,7 @@ export default { } } //处理可迭代次数 - this.iterations = iterations + this.formData.iterations = iterations return result; }, testlink() { diff --git a/templates/front-project/src/views/testViews/TestList.vue b/templates/front-project/src/views/testViews/TestList.vue index 839b4dd9efd928d80ef31314375ef39b2f97a154..698d8fef30632916a9e0c8345ea48e1e4442bd82 100644 --- a/templates/front-project/src/views/testViews/TestList.vue +++ b/templates/front-project/src/views/testViews/TestList.vue @@ -28,7 +28,7 @@ @@ -60,7 +60,7 @@ import {ElMessage} from 'element-plus'; import AllHeader from "@/components/common/AllHeader"; import Menu from "@/components/common/AllMenu"; -import {test_case, down_message} from "@/api/api"; +import {test_case} from "@/api/api"; import utils from '@/utils/utils'; export default { @@ -72,43 +72,19 @@ export default { mixins: [utils], data() { return { - tableDatas: [], + allDatas: [], }; }, - computed: { - showData() { - return this.tableDatas.slice( - (this.currentPage - 1) * this.pageSize, - this.currentPage * this.pageSize - ); - }, - }, created() { this.getData() }, methods: { getData(){ test_case('get', {}).then((response) => { - this.tableDatas = response.data.data; - this.total = this.tableDatas.length; + this.allDatas = response.data.data; + this.total = this.allDatas.length; }); }, - down(row) { - down_message({result_log_name: row.result_log_name}).then((response) => { - const url = window.URL.createObjectURL(new Blob([response.data])) - const link = document.createElement('a') - link.href = url - link.setAttribute('download', 'log.tar') - document.body.appendChild(link) - link.click() - }).catch(error => { - if (error.code === "ERR_BAD_REQUEST"){ElMessage({message: "下载失败没有找到对应日志", type: 'warning'})} - console.log(error) - }).finally(() => { - // excelDisabled 将被设置为 true,然后立即被设置为 false,禁用的时间非常短,不足以被用户察觉到。 - this.excelDisabled = false; - }); - }, del(row) { this.$confirm(`确认删除此行数据吗?`, '提示', { confirmButtonText: '确定',