From 7e582596a77426e042c8135fc9d02da0e7c2a3d4 Mon Sep 17 00:00:00 2001 From: "nathan.liu" Date: Thu, 1 Sep 2022 10:16:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(UI=E8=87=AA=E5=8A=A8=E5=8C=96):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9EUI=E6=8A=A5=E5=91=8A=E5=88=86=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1009465 --user=刘瑶 【UI测试】报告支持分享功能 https://www.tapd.cn/55049933/s/1238555 --- .../metersphere/commons/utils/ShiroUtils.java | 1 + .../controller/IndexController.java | 5 ++ .../io/metersphere/dto/ProjectConfig.java | 3 + .../job/sechedule/CleanUpReportJob.java | 6 +- .../metersphere/service/ProjectService.java | 8 ++- backend/src/main/java/io/metersphere/xpack | 2 +- .../automation/report/ApiReportViewHeader.vue | 21 ++++-- .../project/menu/appmanage/AppManage.vue | 64 +++++++++++++------ frontend/src/business/components/xpack | 2 +- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 3 +- frontend/src/i18n/zh-TW.js | 1 + .../report/ui/share/ShareUiReportTemplate.vue | 36 +++++++++++ .../report/ui/share/share-ui-report.html | 13 ++++ .../report/ui/share/share-ui-report.js | 4 ++ .../src/template/report/ui/uiReportUse.js | 43 +++++++++++++ frontend/vue.config.js | 5 ++ 17 files changed, 185 insertions(+), 33 deletions(-) create mode 100644 frontend/src/template/report/ui/share/ShareUiReportTemplate.vue create mode 100644 frontend/src/template/report/ui/share/share-ui-report.html create mode 100644 frontend/src/template/report/ui/share/share-ui-report.js create mode 100644 frontend/src/template/report/ui/uiReportUse.js diff --git a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java index 5c0b7cd479..4dbc31f1fb 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java @@ -63,6 +63,7 @@ public class ShiroUtils { filterChainDefinitionMap.put("/sharePlanReport", "anon"); filterChainDefinitionMap.put("/sharePerformanceReport", "anon"); filterChainDefinitionMap.put("/shareApiReport", "anon"); + filterChainDefinitionMap.put("/shareUiReport", "anon"); filterChainDefinitionMap.put("/system/theme", "anon"); filterChainDefinitionMap.put("/system/save/baseurl/**", "anon"); diff --git a/backend/src/main/java/io/metersphere/controller/IndexController.java b/backend/src/main/java/io/metersphere/controller/IndexController.java index d0f91da819..7f8519438e 100644 --- a/backend/src/main/java/io/metersphere/controller/IndexController.java +++ b/backend/src/main/java/io/metersphere/controller/IndexController.java @@ -51,4 +51,9 @@ public class IndexController { public String shareApiRedirect() { return "share-api-report.html"; } + + @GetMapping(value = "/shareUiReport") + public String shareUiRedirect() { + return "share-ui-report.html"; + } } diff --git a/backend/src/main/java/io/metersphere/dto/ProjectConfig.java b/backend/src/main/java/io/metersphere/dto/ProjectConfig.java index c30fe48d02..27b9e9dec1 100644 --- a/backend/src/main/java/io/metersphere/dto/ProjectConfig.java +++ b/backend/src/main/java/io/metersphere/dto/ProjectConfig.java @@ -12,6 +12,7 @@ public class ProjectConfig { private String trackShareReportTime; private String performanceShareReportTime; private String apiShareReportTime; + private String uiShareReportTime; private Boolean caseCustomNum = false; private Boolean scenarioCustomNum = false; private String apiQuickMenu; @@ -25,6 +26,8 @@ public class ProjectConfig { private String cleanApiReportExpr; private Boolean cleanLoadReport = false; private String cleanLoadReportExpr; + private Boolean cleanUiReport = false; + private String cleanUiReportExpr; private Boolean urlRepeatable = false; private String triggerUpdate; private Boolean openUpdateTime = false; diff --git a/backend/src/main/java/io/metersphere/job/sechedule/CleanUpReportJob.java b/backend/src/main/java/io/metersphere/job/sechedule/CleanUpReportJob.java index 2832c34553..a32542be1a 100644 --- a/backend/src/main/java/io/metersphere/job/sechedule/CleanUpReportJob.java +++ b/backend/src/main/java/io/metersphere/job/sechedule/CleanUpReportJob.java @@ -53,8 +53,10 @@ public class CleanUpReportJob extends MsScheduleJob { if (BooleanUtils.isTrue(config.getCleanLoadReport())) { this.doCleanUp(projectService::cleanUpLoadReport, config.getCleanLoadReportExpr()); } - // 定时删除 UI 调试模式生成的截图 - projectService.cleanUpUiReportImg(); + if (BooleanUtils.isTrue(config.getCleanUiReport())) { + // 定时删除 UI 调试模式生成的截图 + this.doCleanUp(projectService::cleanUpUiReportImg, config.getCleanUiReportExpr()); + } } catch (Exception e) { LogUtil.error("clean up report error."); LogUtil.error(e.getMessage(), e); diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 0a1f4dbba7..a018dc44e7 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -1027,14 +1027,16 @@ public class ProjectService { } // 删除 UI 报告产生的截图 - public void cleanUpUiReportImg() { + public void cleanUpUiReportImg(long backupTime, String projectId) { try { // 属于定时任务删除调试报告情况 // 获取昨天的当前时间 - Date backupTime = org.apache.commons.lang3.time.DateUtils.addDays(new Date(), -1); +// Date backupTime = org.apache.commons.lang3.time.DateUtils.addDays(new Date(), -1); // 清理类型为 UI 报告类型,且时间为昨天之前的 UI 调试类型报告截图 ApiScenarioReportExample example = new ApiScenarioReportExample(); - example.createCriteria().andCreateTimeLessThan(backupTime.getTime()).andReportTypeEqualTo(ReportTypeConstants.UI_INDEPENDENT.name()) + example.createCriteria() + .andProjectIdEqualTo(projectId) + .andCreateTimeLessThan(backupTime).andReportTypeEqualTo(ReportTypeConstants.UI_INDEPENDENT.name()) .andExecuteTypeEqualTo(ExecuteType.Debug.name()); List apiScenarioReports = apiScenarioReportMapper.selectByExample(example); // 删除调试报告的截图 diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 73584558c6..53c8fbe1c2 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 73584558c69e47496daa0e40b19f162c479693f8 +Subproject commit 53c8fbe1c2a3beff233546305206621047b03dbd diff --git a/frontend/src/business/components/api/automation/report/ApiReportViewHeader.vue b/frontend/src/business/components/api/automation/report/ApiReportViewHeader.vue index 5fda2748ad..59b24c1210 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportViewHeader.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportViewHeader.vue @@ -31,7 +31,7 @@ + + {{ $t('commons.cancel') }} - - @@ -176,13 +176,22 @@ export default { let pram = {}; pram.customData = report.id; pram.shareType = 'API_REPORT'; + let thisHost = window.location.host; + let shareUrl = thisHost + "/shareApiReport"; + if(this.isUi){ + pram.shareType = 'UI_REPORT'; + shareUrl = thisHost + "/shareUiReport"; + } generateShareInfoWithExpired(pram, (data) => { - let thisHost = window.location.host; - this.shareUrl = thisHost + "/shareApiReport" + data.shareUrl; + this.shareUrl = shareUrl + data.shareUrl; }); }, getProjectApplication() { - this.$get('/project_application/get/' + getCurrentProjectID() + "/API_SHARE_REPORT_TIME", res => { + let path = "/API_SHARE_REPORT_TIME"; + if(this.isUi){ + path = "/UI_SHARE_REPORT_TIME"; + } + this.$get('/project_application/get/' + getCurrentProjectID() + path, res => { if (res.data) { let quantity = res.data.typeValue.substring(0, res.data.typeValue.length - 1); let unit = res.data.typeValue.substring(res.data.typeValue.length - 1); diff --git a/frontend/src/business/components/project/menu/appmanage/AppManage.vue b/frontend/src/business/components/project/menu/appmanage/AppManage.vue index 443e1993c5..f11ec1095b 100644 --- a/frontend/src/business/components/project/menu/appmanage/AppManage.vue +++ b/frontend/src/business/components/project/menu/appmanage/AppManage.vue @@ -121,24 +121,45 @@ - - {{ $t('commons.view_settings') }} - - - - - - + + + + {{ this.$t('commons.enable_settings') }} + + + + + + + + + + + {{ $t('commons.view_settings') }} + + + + + + + @@ -297,7 +318,9 @@ export default { cleanApiReport: false, cleanApiReportExpr: "", cleanLoadReport: false, - cleanLoadReportExpr: "" + cleanLoadReportExpr: "", + cleanUiReport: false, + cleanUiReportExpr: "" }, count: 0, isXpack: false, @@ -320,6 +343,7 @@ export default { config: { trackShareReportTime: "", performanceShareReportTime: "", + uiShareReportTime: "", apiShareReportTime: "", caseCustomNum: false, scenarioCustomNum: false, @@ -334,6 +358,8 @@ export default { cleanApiReportExpr: "", cleanLoadReport: false, cleanLoadReportExpr: "", + cleanUiReport: false, + cleanUiReportExpr: "", urlRepeatable: false, shareReport: true, openUpdateTime: false, diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 57f594ed64..5910db5573 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 57f594ed643407d3a5513515dceda4c7ca2c1352 +Subproject commit 5910db55736251f71f6bb024b3c7ae1e3ef4ea24 diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 5fa3241aab..972b35d6f7 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -871,6 +871,7 @@ export default { timing_clean_plan_report: "Regularly clean up test report", timing_clean_api_report: "Regularly clean up api report", timing_clean_load_report: "Regularly clean up performance report", + timing_clean_ui_report: "Regularly clean up ui report", keep_recent: "Keep recent", please_select_cleaning_time: "please select cleaning time!" }, diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 322315bac5..437502861c 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -878,7 +878,8 @@ export default { }, timing_clean_plan_report: "定时清理测试计划报告", timing_clean_api_report: "定时清理接口测试报告", - timing_clean_load_report: "定时清理性能测试报告", + timing_clean_load_report: "定时清理性能测试报告", + timing_clean_ui_report: "定时清理UI测试报告", keep_recent: "保留最近", please_select_cleaning_time: "请选择清理时间!" }, diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index e99d2597ad..27b6128e43 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -876,6 +876,7 @@ export default { timing_clean_plan_report: "定時清理測試計劃報告", timing_clean_api_report: "定時清理接口測試報告", timing_clean_load_report: "定時清理性能測試報告", + timing_clean_ui_report: "定時清理UI測試報告", keep_recent: "保留最近", please_select_cleaning_time: "請選擇清理時間!" }, diff --git a/frontend/src/template/report/ui/share/ShareUiReportTemplate.vue b/frontend/src/template/report/ui/share/ShareUiReportTemplate.vue new file mode 100644 index 0000000000..8b68d48dcf --- /dev/null +++ b/frontend/src/template/report/ui/share/ShareUiReportTemplate.vue @@ -0,0 +1,36 @@ + + + + + diff --git a/frontend/src/template/report/ui/share/share-ui-report.html b/frontend/src/template/report/ui/share/share-ui-report.html new file mode 100644 index 0000000000..c3f76daf2b --- /dev/null +++ b/frontend/src/template/report/ui/share/share-ui-report.html @@ -0,0 +1,13 @@ + + + + + + + + Ui Report + + +
+ + diff --git a/frontend/src/template/report/ui/share/share-ui-report.js b/frontend/src/template/report/ui/share/share-ui-report.js new file mode 100644 index 0000000000..2e57da9f3c --- /dev/null +++ b/frontend/src/template/report/ui/share/share-ui-report.js @@ -0,0 +1,4 @@ +import ShareUiReportTemplate from "@/template/report/ui/share/ShareUiReportTemplate"; +import uiReportUse from "@/template/report/ui/uiReportUse"; + +uiReportUse('#shareUiReport', ShareUiReportTemplate); diff --git a/frontend/src/template/report/ui/uiReportUse.js b/frontend/src/template/report/ui/uiReportUse.js new file mode 100644 index 0000000000..663e38ebf9 --- /dev/null +++ b/frontend/src/template/report/ui/uiReportUse.js @@ -0,0 +1,43 @@ +import Vue from 'vue'; +import ElementUI, {Button, Card, Col, Form, FormItem, Input, Main, Popover, Row, Table, TableColumn} from 'element-ui'; +import '@/assets/theme/index.css'; +import '@/common/css/menu-header.css'; +import '@/common/css/main.css'; +import i18n from "@/i18n/i18n"; +import chart from "@/common/js/chart"; +import filters from "@/common/js/filter"; +import icon from "@/common/js/icon"; +import message from "@/common/js/message"; +import ajax from "@/common/js/ajax"; + + +function uiReportUse(id, template) { + Vue.use(ElementUI, { + i18n: (key, value) => i18n.t(key, value) + }); + + Vue.use(Row); + Vue.use(Col); + Vue.use(Form); + Vue.use(FormItem); + Vue.use(Input); + Vue.use(Button); + Vue.use(chart); + Vue.use(Main); + Vue.use(Card); + Vue.use(TableColumn); + Vue.use(Table); + Vue.use(filters); + Vue.use(icon); + Vue.use(message); + Vue.use(ajax); + Vue.use(Popover); + + new Vue({ + el: id, + i18n, + render: h => h(template) + }); +} + +export default uiReportUse; diff --git a/frontend/vue.config.js b/frontend/vue.config.js index be0ab9fb2c..decd09a025 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -49,6 +49,11 @@ module.exports = { template: "src/template/report/api/share/share-api-report.html", filename: "share-api-report.html", }, + shareUiReport: { + entry: "src/template/report/ui/share/share-ui-report.js", + template: "src/template/report/ui/share/share-ui-report.html", + filename: "share-ui-report.html", + }, enterpriseReport: { entry: "src/template/enterprise/share/share-enterprise-report.js", template: "src/template/enterprise/share/share-enterprise-report.html",