diff --git a/src/app/@dataflow/extra/browser-setting-flow.ts b/src/app/@dataflow/extra/browser-setting-flow.ts index d316476..7e50e0a 100644 --- a/src/app/@dataflow/extra/browser-setting-flow.ts +++ b/src/app/@dataflow/extra/browser-setting-flow.ts @@ -23,10 +23,23 @@ export interface IBrowserSetting { * - 如果与 rclone 服务器响应时间小于 100ms(通常在局域网下), 可以适当调低数值 */ 'rng.request-interval': number; + /** + * 速度图表的时间跨度, 速度图表只会保留最近一段时间内的数据 + * + * 单位: 秒(s) + * + * 原则: + * - 应小于 `rng.request-interval`(转化为相同单位后) + * + * 影响范围: + * - dashboard 和 Job manager 中的速度图表时间跨度 + */ + 'rng.speedChart.windowSize': number; } export const brwoserSettingDefault: IBrowserSetting = { 'rng.request-interval': 3000, + 'rng.speedChart.windowSize': 60, }; export type NestedPartial = { diff --git a/src/app/@dataflow/extra/browser-setting-schema.json b/src/app/@dataflow/extra/browser-setting-schema.json index ccaeb66..0e7ce32 100644 --- a/src/app/@dataflow/extra/browser-setting-schema.json +++ b/src/app/@dataflow/extra/browser-setting-schema.json @@ -8,9 +8,13 @@ "rng.request-interval": { "description": "请求间隔, 需要定时从rclone服务器中获取数据的时间间隔.\n\n单位: 毫秒(ms)\n\n影响范围:\n - 响应时间的刷新频率(位于主侧栏左上角)\n - Dashboard 和 Job Manager 的更新间隔\n\n建议:\n - 如果与 rclone 服务器响应时间小于 100ms(通常在局域网下), 可以适当调低数值", "type": "number" + }, + "rng.speedChart.windowSize": { + "description": "速度图表的时间跨度, 速度图表只会保留最近一段时间内的数据\n\n单位: 秒(s)\n\n原则:\n - 应小于 `rng.request-interval`(转化为相同单位后)\n\n影响范围:\n - dashboard 和 Job manager 中的速度图表时间跨度", + "type": "number" } }, - "required": ["rng.request-interval"], + "required": ["rng.request-interval", "rng.speedChart.windowSize"], "type": "object" } } diff --git a/src/app/components/speed-chart/speed-chart.component.ts b/src/app/components/speed-chart/speed-chart.component.ts index bbc4a0d..2fc9ace 100644 --- a/src/app/components/speed-chart/speed-chart.component.ts +++ b/src/app/components/speed-chart/speed-chart.component.ts @@ -4,6 +4,7 @@ import * as moment from 'moment'; import { BaseChartDirective, Color } from 'ng2-charts'; import { pairwise } from 'rxjs/operators'; import { CoreStatsFlow } from '../../@dataflow/rclone'; +import { BrowserSettingService } from '../../pages/settings/browser-setting/browser-setting.service'; import { FormatBytes } from '../../utils/format-bytes'; @Component({ @@ -40,7 +41,7 @@ import { FormatBytes } from '../../utils/format-bytes'; ], }) export class RngSpeedChartComponent implements OnInit { - constructor() {} + constructor(private browserSettingService: BrowserSettingService) {} public lineChartData: ChartDataSets[] = [ { data: [ @@ -182,6 +183,9 @@ export class RngSpeedChartComponent implements OnInit { speedDiff = 0; ngOnInit() { + this.browserSettingService + .partialBrowserSetting$('rng.speedChart.windowSize') + .subscribe(([v, err]) => (this.treadhold = v)); const statsOut = this.stats$.getOutput(); statsOut.subscribe(node => { if (node[1].length !== 0) return;