From b065b5d1240072b838033ac4e14ed9f04100d3bf Mon Sep 17 00:00:00 2001 From: azhengzz <820108271@qq.com> Date: Sat, 27 Feb 2021 15:03:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E8=A7=88=E9=9D=A2=E6=9D=BF=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E7=82=B9=E5=87=BB=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E5=B7=B2=E7=BB=8F=E9=85=8D=E7=BD=AE=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=8F=8A=E5=85=B6cron=E8=A1=A8=E8=BE=BE=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ApiAutomationTest/app/routes/main/routes.py | 21 ++++++------ ApiAutomationTest/app/static/js/main/index.js | 28 ++++++++++++++++ .../app/templates/main/index.html | 32 ++++++++++++++++++- 3 files changed, 70 insertions(+), 11 deletions(-) diff --git a/ApiAutomationTest/app/routes/main/routes.py b/ApiAutomationTest/app/routes/main/routes.py index cebe07b..bbffd37 100644 --- a/ApiAutomationTest/app/routes/main/routes.py +++ b/ApiAutomationTest/app/routes/main/routes.py @@ -5,8 +5,8 @@ from flask_login import login_required, current_user from datetime import datetime, timedelta from app.routes.main import bp -from app.models import Dispatcher, Scheduler, Case -from app.cores.dictionaries import REPORT_RESULT +from app.models import Dispatcher, Scheduler, Case, Project +from app.cores.dictionaries import REPORT_RESULT, ELEMENT_TYPE @bp.route('/') @@ -59,18 +59,19 @@ def index(): source['失败'] += 1 elif dispatcher.report.result == REPORT_RESULT.ABORT: source['中止'] += 1 - # echart_line_last_dispatch_dataset_source = [ - # {'date': '20201231', '构建': 20, '成功': 13, '失败': 5, '错误': 2, '中止': 0}, - # {'date': '20201230', '构建': 10, '成功': 3, '失败': 5, '错误': 2, '中止': 0}, - # {'date': '20201229', '构建': 15, '成功': 8, '失败': 2, '错误': 5, '中止': 0}, - # {'date': '20201228', '构建': 25, '成功': 13, '失败': 10, '错误': 2, '中止': 0}, - # ] # 获取正在运行的定时任务数 - scheduler_enable_count = len(Scheduler.query.filter_by(enable=True).all()) + # scheduler_enable_count = len(Scheduler.query.filter_by(enable=True).all()) + # 获取正在运行的定时任务信息 + schedulers = [] + for row in Scheduler.query.filter_by(element_type=ELEMENT_TYPE.PROJECT, enable=True).all(): + project = Project.query.filter_by(id=row.element_id).first() + if project: + schedulers.append(dict(id=row.element_id, name=project.name, cron=row.cron)) # 获取总案例个数 total_case_count = len(Case.query.all()) return render_template('main/index.html', - scheduler_enable_count=scheduler_enable_count, + schedulers=schedulers, + scheduler_enable_count=len(schedulers), total_dispatcher_count=total_dispatcher_count, total_dispatcher_count_current_user=total_dispatcher_count_current_user, total_case_count=total_case_count, diff --git a/ApiAutomationTest/app/static/js/main/index.js b/ApiAutomationTest/app/static/js/main/index.js index 08fac5a..2654d9b 100644 --- a/ApiAutomationTest/app/static/js/main/index.js +++ b/ApiAutomationTest/app/static/js/main/index.js @@ -3,8 +3,14 @@ $(document).ready(function () { // 渲染报告图表 renderLastDispatchEcharts(); renderLastDispatchCurrentUserEcharts(); + + // 弹出框展示已启动定时任务的项目及其cron表达式 + tippyProjectSchedulerInfo(); }); +// 元素 +let $show_project_scheduler_info = $('#show-project-scheduler-info'); + // 近期构建数据 function renderLastDispatchEcharts() { // 基于准备好的dom,初始化echarts实例 @@ -176,3 +182,25 @@ function renderLastDispatchCurrentUserEcharts() { echart.setOption(option); } + +// 弹出框展示已启动定时任务的项目及其cron表达式 +function tippyProjectSchedulerInfo() { + tippy($show_project_scheduler_info[0], { + trigger: 'click', + hideOnClick: true, + placement: 'bottom', + arrow: false, + allowHTML: true, + interactive: true, + content: function (){ + return $show_project_scheduler_info.next().html(); + }, + // appendTo: 'parent', + appendTo: () => document.body, + // zIndex默认9999 当有模态框显示时,提示框依然会展示在最上层且可以操作点击,因此更改zIndex为0,将其放置于模态框下层 + // 但如果设置为0时,handsontable表格会和tippy框样式重叠,尝试了多个zIndex数值,发现大于200可以解决重叠问题 + // zIndex: 200, + theme: 'light', + maxWidth: 'none', + }); +} \ No newline at end of file diff --git a/ApiAutomationTest/app/templates/main/index.html b/ApiAutomationTest/app/templates/main/index.html index 7d0a950..dbb9131 100644 --- a/ApiAutomationTest/app/templates/main/index.html +++ b/ApiAutomationTest/app/templates/main/index.html @@ -3,6 +3,10 @@ {% block styles %} {{ super() }} + + + + {% endblock styles %} {% block body_attribs %} @@ -52,7 +56,31 @@ class="bg-gradient-grey"
定时任务数
-
{{ scheduler_enable_count }}
+
+ {{ scheduler_enable_count }} +
+
+
+ + + + + + + + + + {% for scheduler in schedulers %} + + + + + + {% endfor %} + +
项目编号项目名称cron表达式
{{ scheduler.id }}{{ scheduler.name }}{{ scheduler.cron }}
+
+
@@ -110,6 +138,8 @@ class="bg-gradient-grey" {% block scripts %} {{ super() }} + +