Skip to content

Commit

Permalink
feat(speed-charts): a simple speed chart
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed May 19, 2020
1 parent f370c57 commit 7174123
Show file tree
Hide file tree
Showing 13 changed files with 311 additions and 24 deletions.
70 changes: 61 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
"@nebular/eva-icons": "^5.0.0",
"@nebular/theme": "^5.0.0",
"bootstrap": "^4.5.0",
"chart.js": "^2.9.3",
"eva-icons": "^1.1.3",
"nebular-icons": "^1.1.0",
"ng2-charts": "^2.3.2",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
Expand Down
4 changes: 2 additions & 2 deletions src/app/@dataflow/extra/name-validation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SupersetFlow, FlowInNode, CombErr } from '../core';
import { Observable, of } from 'rxjs';
import { IUser, UsersFlowNode } from './users-flow';
import { IUser, UsersFlowOutNode } from './users-flow';

export interface NameValidationPreNode extends UsersFlowNode {
export interface NameValidationPreNode extends UsersFlowOutNode {
currentName: string;
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/@dataflow/extra/users-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ export interface IUser extends IRcloneServer {
name: string;
}

export interface UsersFlowNode extends FlowInNode {
export interface UsersFlowOutNode extends FlowInNode {
users: IUser[];
loginUser: IUser;
}

export abstract class UsersFlow extends BareFlow<FlowInNode, UsersFlowNode> {
export abstract class UsersFlow extends BareFlow<FlowInNode, UsersFlowOutNode> {
public static readonly defaultUser: IUser[] = [
{ name: 'localhost', url: 'http://localhost:5572' },
];
private static trigger$ = new Subject<number>();
protected request(pre: CombErr<FlowInNode>): Observable<CombErr<UsersFlowNode>> {
protected request(pre: CombErr<FlowInNode>): Observable<CombErr<UsersFlowOutNode>> {
return of([{ users: UsersFlow.getAll(), loginUser: UsersFlow.getLogin() }, []]);
}
public static getAll(): IUser[] {
Expand Down
33 changes: 33 additions & 0 deletions src/app/@dataflow/rclone/core-stats-flow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { PostFlow } from './post-flow';
import { NoopAuthFlowSupNode } from './noop-auth-flow';
import { FlowOutNode, CombErr } from '../core';
import { AjaxFlowInteralNode } from '../core/ajax-flow';
import { IRcloneServer } from '../extra';

export interface CoreStatsFlowOutNode extends FlowOutNode {
'core-stats': {
bytes: number;
checks: number;
deletes: number;
elapsedTime: number;
errors: number;
fatalError: boolean;
retryError: boolean;
speed: number;
transfers: number;
};
}

export interface CoreStatsFlowSupNode extends CoreStatsFlowOutNode, NoopAuthFlowSupNode {}

export abstract class CoreStatsFlow extends PostFlow<IRcloneServer, CoreStatsFlowOutNode> {
// public prerequest$: Observable<CombErr<IRcloneServer>>;
protected cmd: string = 'core/stats';
protected params: object = {};
protected cacheSupport: boolean = false;
protected reconstructAjaxResult(x: AjaxFlowInteralNode): CombErr<CoreStatsFlowOutNode> {
if (x[1].length !== 0) return [{}, x[1]] as any;
const rsp = x[0].ajaxRsp.response;
return [{ 'core-stats': rsp }, []];
}
}
1 change: 1 addition & 0 deletions src/app/@dataflow/rclone/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './post-flow';
export * from './noop-auth-flow';
export * from './core-stats-flow';
2 changes: 1 addition & 1 deletion src/app/pages/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Component, OnInit } from '@angular/core';
</div>
<div class="row">
<div class="col-sm-12 col-md-6 col-xl-6">
<nb-card><nb-card-body>speed</nb-card-body></nb-card>
<dashboard-speed-card> </dashboard-speed-card>
</div>
<div class="col-sm-12 col-md-6 col-xl-6">
<nb-card><nb-card-body>core/stats</nb-card-body></nb-card>
Expand Down
9 changes: 6 additions & 3 deletions src/app/pages/dashboard/dashboard.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { CommonModule } from '@angular/common';

import { DashboardRoutingModule } from './dashboard-routing.module';
import { DashboardComponent } from './dashboard.component';
import { NbCardModule } from '@nebular/theme';
import { NbCardModule, NbButtonModule, NbIconModule } from '@nebular/theme';
import { SpeedCardComponent } from './speed-card/speed-card.component';
import { SpeedChartsComponent } from './speed-card/speed-charts.component';
import { ChartsModule } from 'ng2-charts';

@NgModule({
declarations: [DashboardComponent],
imports: [CommonModule, DashboardRoutingModule, NbCardModule],
declarations: [DashboardComponent, SpeedCardComponent, SpeedChartsComponent],
imports: [CommonModule, DashboardRoutingModule, NbCardModule, NbButtonModule, NbIconModule, ChartsModule],
})
export class DashboardModule {}
41 changes: 41 additions & 0 deletions src/app/pages/dashboard/speed-card/speed-card.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'dashboard-speed-card',
template: `
<nb-flip-card #flip [showToggleButton]="false">
<nb-card-front>
<nb-card>
<nb-card-header>
<span>Speed Chart</span>
<button nbButton size="small" shape="round" appearance="ghost" (click)="flip.toggle()">
<nb-icon icon="options-2"></nb-icon>
</button>
</nb-card-header>
<nb-card-body>
<dashboard-speed-charts> </dashboard-speed-charts>
</nb-card-body>
</nb-card>
</nb-card-front>
<nb-card-back>
<nb-card>
<nb-card-header>
<span>Speed Limitation</span>
<button nbButton size="small" shape="round" appearance="ghost" (click)="flip.toggle()">
<nb-icon icon="arrow-back"></nb-icon>
</button>
</nb-card-header>
<nb-card-body>
123
</nb-card-body>
</nb-card>
</nb-card-back>
</nb-flip-card>
`,
styles: [],
})
export class SpeedCardComponent implements OnInit {
constructor() {}

ngOnInit() {}
}

0 comments on commit 7174123

Please sign in to comment.