From 7d4801c1f25db31af519612b39c0decb8ab0c079 Mon Sep 17 00:00:00 2001 From: bigeagle Date: Fri, 6 May 2016 10:54:54 +0800 Subject: [PATCH] added detailed syncing status page --- index.html | 3 ++- static/css/style.scss | 17 ++++++++++++++++ static/js/status.es6 | 45 +++++++++++++++++++++++++++++++++++++++++++ status.html | 39 ++++++++++++++++++++++++++----------- 4 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 static/js/status.es6 diff --git a/index.html b/index.html index 6401963..72e8ab2 100644 --- a/index.html +++ b/index.html @@ -69,7 +69,8 @@ permalink: /

相关链接

diff --git a/static/css/style.scss b/static/css/style.scss index ea853fc..ecfca6b 100644 --- a/static/css/style.scss +++ b/static/css/style.scss @@ -97,6 +97,23 @@ $font_local: 'Heiti SC', 'Hiragino Sans GB', 'STHeiti', 'Source Han Sans CN', 'W } } +#status-page { + .thead { + font-weight: bold; + } + #mirror-list { + .status-syncing { + background-color: #e3fffd; + } + :hover { + background-color: #e0f3fc; + } + .status-fail, .status-failed { + background-color: #fff4e3; + } + } +} + #help-page { margin-top: 40px; margin-bottom: 40px; diff --git a/static/js/status.es6 b/static/js/status.es6 new file mode 100644 index 0000000..78685c7 --- /dev/null +++ b/static/js/status.es6 @@ -0,0 +1,45 @@ +--- +--- +$(document).ready(() => { + var mir_tmpl = $("#template").text(); + + $.get("/static/status/disk.json", (d) => { + var used_percent = Math.round(d.used_kb * 100 / d.total_kb); + $('#disk-usage-bar') + .attr("aria-valuenow", used_percent) + .css("width", used_percent + "%") + .html("" + d.used_readable + " / " + d.total_readable + ""); + }); + + window.refreshMirrorList = () => { + $.getJSON("/static/tunasync.json", (status_data) => { + var mirrors=[], mir_data=status_data; + + mir_data.sort((a, b) => { return a.name < b.name ? -1: 1 }); + + for(var k in mir_data) { + var d = mir_data[k]; + if (d.is_master === undefined) { + d.is_master = true; + } + // Strip the second component of last_update + if (d.last_update_ts) { + let date = new Date(d.last_update_ts * 1000); + if (date.getFullYear() > 2000) { + d.last_update = `${('000'+date.getFullYear()).substr(-4)}-${('0'+(date.getMonth()+1)).substr(-2)}-${('0'+(date.getDay()+1)).substr(-2)}` + + ` ${('0'+date.getHours()).substr(-2)}:${('0'+date.getMinutes()).substr(-2)}`; + } else { + d.last_update = "0000-00-00 00:00"; + } + } else { + d.last_update = d.last_update.replace(/(\d\d:\d\d):\d\d(\s\+\d\d\d\d)?/, '$1'); + } + mirrors.push(d); + } + var result = Mark.up(mir_tmpl, {mirrors: mirrors}); + $('#mirror-list').html(result); + }); + setTimeout(refreshMirrorList, 10000); + }; + refreshMirrorList(); +}); diff --git a/status.html b/status.html index d8d69d2..28449a1 100644 --- a/status.html +++ b/status.html @@ -9,7 +9,7 @@ permalink: /status/
-

# 服务器监控

+

# 服务器监控

# 网络流量

@@ -56,20 +56,37 @@ permalink: /status/
+

# 同步状态

+
+
+
+
Name
+
Last Update
+
Upstream
+
Status
+
Size
+
+
+
+
+
{% include footer.html %} - + {% endraw %} +