Skip to content

Commit 2ed8af9

Browse files
committed
fix: 修复点小问题
1 parent 2cc85e9 commit 2ed8af9

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

assets/js/index.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ class SwitchElement extends Element {
392392
this._render_next_index = index;
393393
return this;
394394
};
395+
var oldindex = this.index;
395396
this.index = index;
396397
var buttons_width = this.$buttons.map(e => calcElementWidth(e));
397398
var left = 0;
@@ -408,6 +409,7 @@ class SwitchElement extends Element {
408409
})
409410
}
410411
this.$bar.style("left", `${left}px`).style("width", `${width}px`);
412+
if (oldindex == this.index) return this;
411413
this.origin.dispatchEvent(new CustomEvent("change", {
412414
detail: {
413415
index: index,
@@ -900,6 +902,9 @@ class Tools {
900902
})
901903
return base
902904
}
905+
static formatDate(d) {
906+
return `${d.getFullYear().toString().padStart(4, "0")}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d.getDate().toString().padStart(2, "0")}`
907+
}
903908
}
904909
async function load() {
905910
const $dom_body = new Element(document.body);
@@ -1178,8 +1183,29 @@ async function load() {
11781183
data.daily_bytes, (n) => n, Tools.formatBytes, $i18n.t("dashboard.value.storage.bytes")
11791184
]
11801185
})) {
1181-
const [value, key_unit, value_formatter, i18n] = values;
1186+
var [value, key_unit, value_formatter, i18n] = values;
11821187
if (!value) continue;
1188+
if (key.startsWith("today")) {
1189+
for (let i = 0; i < 24; i++) {
1190+
if (value[i]) continue
1191+
value[i] = 0
1192+
}
1193+
value = Object.fromEntries(
1194+
Object.keys(value).sort((a, b) => parseInt(a) - parseInt(b)).map(v => [v, value[v]])
1195+
)
1196+
} else {
1197+
var server_time = $dashboard_locals.info_runtime
1198+
// object.current_time - object.start_time - object.diff / 1000.0 + (+new Date() - object.resp_timestamp) / 1000.0;
1199+
var time = server_time.start_time - server_time.diff / 1000.0 + (+new Date() - server_time.resp_timestamp) / 1000.0;
1200+
const previous = (time - (time % (24 * 3600)) - 86400 * 30);
1201+
const res = {}
1202+
for (let i = 0; i < 30; i++) {
1203+
var d = Tools.formatDate(new Date((previous + i * 86400) * 1000.0))
1204+
if (value[d]) res[d] = value[d]
1205+
else res[d] = 0
1206+
}
1207+
value = res
1208+
}
11831209
var option = {
11841210
color: [
11851211
$style.getThemeValue("echarts-color-0"),
@@ -1494,18 +1520,6 @@ async function load() {
14941520
var v = storage[storage_id][key_time][val._] || 0;
14951521
storage[storage_id][key_time][val._] = v + val[key]
14961522
}
1497-
if (time == "hourly") {
1498-
for (let i = 0; i < 24; i++) {
1499-
if (storage[storage_id][key_time][i]) continue
1500-
storage[storage_id][key_time][i] = 0
1501-
}
1502-
storage[storage_id][key_time] = Object.fromEntries(
1503-
Object.keys(storage[storage_id][key_time]).sort((a, b) => parseInt(a) - parseInt(b)).map(v => [v, storage[storage_id][key_time][v]])
1504-
)
1505-
} else {
1506-
var server_time = $dashboard_locals.info.runtime
1507-
console.log(server_time)
1508-
}
15091523
}
15101524
}
15111525
}
@@ -1525,7 +1539,7 @@ async function load() {
15251539
}
15261540
$dashboard_locals.statistics_data.total = total;
15271541
$dashboard_locals.statistics_data.storages = storage;
1528-
}, 1000)
1542+
}, 60000)
15291543
clearInterval($dashboard_locals.basic_task_file_info)
15301544
$dashboard_locals.basic_task_file_info = Tools.runTask(setInterval, async () => {
15311545
var hourly = await $channel.send("cluster_statistics_hourly")

core/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import atexit
99
from . import cluster
1010
from . import scheduler
11-
from . import web_old
1211
from . import dashboard
1312
from . import database
1413

core/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"advanced.threads": 128,
1414
"advanced.ssl_dir": ".ssl",
1515
"advanced.host": "",
16-
"advnaced.ssl_cert": "",
16+
"advanced.ssl_cert": "",
1717
"advanced.ssl_key": "",
1818
"advanced.check_sign": True,
1919
"advanced.check_type": "size",
@@ -154,7 +154,7 @@ def xff(self):
154154

155155
@property
156156
def auto_sync_assets(self):
157-
return Config.get("advanced.auto_sync_assets") or True
157+
return bool(Config.get("advanced.auto_sync_assets", True))
158158

159159
@property
160160
def github_token(self):
@@ -170,7 +170,7 @@ def rank_clusters_url(self):
170170

171171
const = Const()
172172

173-
VERSION = "3.3.0"
173+
VERSION = "3.3.1"
174174
API_VERSION = "1.13.1"
175175
USER_AGENT = f"openbmclapi/{API_VERSION} python-openbmclapi/{VERSION}"
176176
PYTHON_VERSION = ".".join(map(str, (sys.version_info.major, sys.version_info.minor, sys.version_info.micro)))

0 commit comments

Comments
 (0)