Skip to content

Commit

Permalink
feat(browser-setting): add item rng.speedChart.windowSize
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed Jul 4, 2020
1 parent cded9c5 commit 339a55f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/app/@dataflow/extra/browser-setting-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
Expand Down
6 changes: 5 additions & 1 deletion src/app/@dataflow/extra/browser-setting-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/components/speed-chart/speed-chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -40,7 +41,7 @@ import { FormatBytes } from '../../utils/format-bytes';
],
})
export class RngSpeedChartComponent implements OnInit {
constructor() {}
constructor(private browserSettingService: BrowserSettingService) {}
public lineChartData: ChartDataSets[] = [
{
data: [
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 339a55f

Please sign in to comment.