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() }} + +