From 3d8622e7035270f2f531ecf5438db72f753a1126 Mon Sep 17 00:00:00 2001 From: aaajiulong <525763728@qq.com> Date: Wed, 11 Nov 2020 16:12:31 +0800 Subject: [PATCH] refactor: Update examples files --- examples/config.py | 2 +- examples/static/entry/index.js | 4 +-- examples/static/initial.js | 60 +++++++++++++++++----------------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/examples/config.py b/examples/config.py index a953315..4d68d34 100644 --- a/examples/config.py +++ b/examples/config.py @@ -15,7 +15,7 @@ def setting_app(): } import os - path_ = os.getcwd() + '/test.db' + path_ = os.getcwd() + '/flask_state_host.db' app.config['SQLALCHEMY_BINDS'] = {DEFAULT_BIND_SQLITE: 'sqlite:///' + path_} # log_instance = logging.getLogger(__name__) diff --git a/examples/static/entry/index.js b/examples/static/entry/index.js index f2721a0..fab28cf 100644 --- a/examples/static/entry/index.js +++ b/examples/static/entry/index.js @@ -1,6 +1,6 @@ import {init} from '../'; import '../../../packages/flask-state.css'; -import {zh} from '../../../packages/i18n'; -init(null); +import {en, ja, zh} from '../../../packages/i18n'; +init(); init({dom:document.getElementById('test_id'), lang:zh}); diff --git a/examples/static/initial.js b/examples/static/initial.js index 62aa4a7..9cab8ca 100644 --- a/examples/static/initial.js +++ b/examples/static/initial.js @@ -50,40 +50,40 @@ class MachineStatus { '
' + '' + 'days
' + + '

days

' + '' + '

Host Status

' + '
' + - '
memory:
' + - '
cpu:
' + - '
disk usage:
' + - '
LoadAvg:
' + - '
boot seconds:
' + + '
Memory
' + + '
CPU
' + + '
Disk Usage
' + + '
Load Avg
' + + '
Uptime
' + '
' + '

Redis Status

' + '
' + - '
used memory:
' + - '
used memory rss:
' + - '
mem fragmentation ratio:
' + - '
hits ratio:
' + - '
24h hits ratio:
' + - '
uptime in seconds:
' + - '
connected clients:
' + + '
Used Mem
' + + '
Used Mem Rss
' + + '
Mem Fragmentation Ratio
' + + '
Cache Hits Ratio
' + + '
24h Hits Ratio
' + + '
Uptime
' + + '
Connections
' + '
'; if (this.mobile) { str += '
' + '
' + '' + '
' + '
' + @@ -208,10 +208,10 @@ class MachineStatus { if (Object.keys(this.language).length !== 0) { document.getElementById('fs-host-status-title').innerHTML = this.language.host_status; document.getElementById('fs-redis-status-title').innerHTML = this.language.redis_status; - document.getElementById('fs-cpu').innerHTML = this.language.cpu.toLowerCase(); - document.getElementById('fs-memory').innerHTML = this.language.memory.toLowerCase(); - document.getElementById('fs-disk-usage').innerHTML = this.language.disk_usage.toLowerCase(); - document.getElementById('fs-load-avg').innerHTML = this.language.load_avg.toLowerCase(); + document.getElementById('fs-cpu').innerHTML = this.language.cpu; + document.getElementById('fs-memory').innerHTML = this.language.memory; + document.getElementById('fs-disk-usage').innerHTML = this.language.disk_usage; + document.getElementById('fs-load-avg').innerHTML = this.language.load_avg; document.getElementById('fs-boot-seconds').innerHTML = this.language.boot_seconds; document.getElementById('fs-used-memory').innerHTML = this.language.used_memory; document.getElementById('fs-used-memory-rss').innerHTML = this.language.used_memory_rss; @@ -230,9 +230,9 @@ class MachineStatus { this.consoleMemoryChart = echarts.init(document.getElementById('fs-info-memory-chart'), null, {renderer: 'svg'}); this.consoleLoadavgChart = echarts.init(document.getElementById('fs-info-loadavg-chart'), null, {renderer: 'svg'}); this.consoleDiskusageChart = echarts.init(document.getElementById('fs-info-diskusage-chart'), null, {renderer: 'svg'}); - this.cpuOption = MachineStatus.generateChatOption(this.mobile, this.language.cpu || 'CPU', '', this.language.today || 'today'); - this.memoryOption = MachineStatus.generateChatOption(this.mobile, this.language.memory || 'Memory', '', this.language.today || 'today'); - this.diskUsageOption = MachineStatus.generateChatOption(this.mobile, this.language.disk_usage || 'Disk Usage', '', this.language.today || 'today'); + this.cpuOption = MachineStatus.generateChatOption(this.mobile, this.language.cpu || 'CPU', '', this.language.today || 'Today'); + this.memoryOption = MachineStatus.generateChatOption(this.mobile, this.language.memory || 'Memory', '', this.language.today || 'Today'); + this.diskUsageOption = MachineStatus.generateChatOption(this.mobile, this.language.disk_usage || 'Disk Usage', '', this.language.today || 'Today'); this.loadavgOption = MachineStatus.generateChatOption(this.mobile, 'Load Avg', 'loadavg', this.language.minutes || 'min'); } @@ -298,10 +298,10 @@ class MachineStatus { hostInfoKeysList.forEach((item, index) => { switch (item) { case 'used_memory': - hostInfoExtendSpan[index].innerHTML = Math.ceil(currentStatistic[item] / BIT_TO_MB) + 'M'; + hostInfoExtendSpan[index].innerHTML = Math.ceil(currentStatistic[item] / BIT_TO_MB) + ' M'; break; case 'used_memory_rss': - hostInfoExtendSpan[index].innerHTML = Math.ceil(currentStatistic[item] / BIT_TO_MB) + 'M'; + hostInfoExtendSpan[index].innerHTML = Math.ceil(currentStatistic[item] / BIT_TO_MB) + ' M'; break; case 'mem_fragmentation_ratio': let ratio = currentStatistic[item]; @@ -463,7 +463,7 @@ class MachineStatus { ] }; if (tableName === 'loadavg') { - baseData.legend.data = ['1' + lineName, '5' + lineName, '15' + lineName]; + baseData.legend.data = ['1 ' + lineName, '5 ' + lineName, '15 ' + lineName]; baseData.series = []; baseData.legend.data.forEach((name) => { baseData.series.push({ @@ -524,13 +524,13 @@ class MachineStatus { result = secondTime + seconds; } if (minuteTime > 0) { - result = Math.floor(minuteTime) + minutes; + result = Math.floor(minuteTime) + ' ' + minutes; } if (hourTime > 0) { - result = Math.floor(hourTime) + hours; + result = Math.floor(hourTime) + ' ' + hours; } if (dayTime > 0) { - result = Math.floor(dayTime) + days; + result = Math.floor(dayTime) + ' ' + days; } return result; };