总览面板页面的定时任务数,支持点击查看当前已经配置项目及其cron表达式
This commit is contained in:
parent
d012393c94
commit
b065b5d124
|
@ -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,
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
}
|
|
@ -3,6 +3,10 @@
|
|||
{% block styles %}
|
||||
{{ super() }}
|
||||
<link href="{{ url_for('static', filename='css/main/index.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='plugins/tippyjs/tippy.js/themes/light.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='plugins/tippyjs/tippy.js/themes/light-border.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='plugins/tippyjs/tippy.js/themes/material.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='plugins/tippyjs/tippy.js/themes/translucent.css') }}" rel="stylesheet">
|
||||
{% endblock styles %}
|
||||
|
||||
{% block body_attribs %}
|
||||
|
@ -52,7 +56,31 @@ class="bg-gradient-grey"
|
|||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="font-weight-bold text-info text-uppercase mb-1">定时任务数</div>
|
||||
<div class="h5 mb-0 font-weight-bold">{{ scheduler_enable_count }}</div>
|
||||
<div class="h5 mb-0 font-weight-bold cursor-pointer" id="show-project-scheduler-info" style="text-decoration:underline;">
|
||||
{{ scheduler_enable_count }}
|
||||
</div>
|
||||
<div style="display: none;">
|
||||
<div class="table-responsive" style="width: 30vw; height: 30vh;">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">项目编号</th>
|
||||
<th scope="col">项目名称</th>
|
||||
<th scope="col">cron表达式</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for scheduler in schedulers %}
|
||||
<tr>
|
||||
<td>{{ scheduler.id }}</td>
|
||||
<td><a href="/module/?project_id={{ scheduler.id }}" target="_blank">{{ scheduler.name }}</a></td>
|
||||
<td>{{ scheduler.cron }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-clock fa-2x" style="color:#dcdeea!important"></i>
|
||||
|
@ -110,6 +138,8 @@ class="bg-gradient-grey"
|
|||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script src="{{ url_for('static', filename='plugins/echarts/echarts.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='plugins/tippyjs/@popperjs/core/dist/umd/popper.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='plugins/tippyjs/tippy.js/dist/tippy-bundle.umd.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/main/index.js') }}"></script>
|
||||
<script>
|
||||
var echart_line_last_dispatch_dataset_source = {{ echart_line_last_dispatch_dataset_source|safe }};
|
||||
|
|
Loading…
Reference in New Issue