Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(remote.detail): show remote usages
- Loading branch information
Showing
4 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Observable, of } from 'rxjs'; | ||
import { AjaxFlowInteralNode, CombErr, FlowOutNode } from '../core'; | ||
import { IRcloneServer, NavigationFlowOutNode } from '../extra'; | ||
import { OperationsFsinfoFlowOutNode } from './operations-fsinfo-flow'; | ||
import { PostFlow } from './post-flow'; | ||
|
||
export interface OperationsAboutFlowParamsNode { | ||
/** a remote name string eg "drive:" */ | ||
fs: string; | ||
} | ||
|
||
export interface OperationsAboutFlowInNode | ||
extends NavigationFlowOutNode, | ||
IRcloneServer, | ||
OperationsFsinfoFlowOutNode {} | ||
|
||
export interface OperationsAboutFlowOutItemNode { | ||
free?: number; | ||
other?: number; | ||
total?: number; | ||
trashed?: number; | ||
used?: number; | ||
} | ||
export interface OperationsAboutFlowOutNode extends FlowOutNode { | ||
about: OperationsAboutFlowOutItemNode; | ||
} | ||
|
||
export abstract class OperationsAboutFlow extends PostFlow< | ||
OperationsAboutFlowInNode, | ||
OperationsAboutFlowOutNode, | ||
OperationsAboutFlowParamsNode | ||
> { | ||
// public prerequest$: Observable<CombErr<OperationsAboutFlowInNode>>; | ||
protected cmd = 'operations/about'; | ||
protected cacheSupport = true; | ||
protected params = (pre: CombErr<OperationsAboutFlowInNode>): OperationsAboutFlowParamsNode => { | ||
if (pre[1].length !== 0) return {} as any; | ||
return { fs: `${pre[0].remote}:` }; | ||
}; | ||
protected reconstructAjaxResult(x: AjaxFlowInteralNode): CombErr<OperationsAboutFlowOutNode> { | ||
if (x[1].length !== 0) return [{}, x[1]] as any; | ||
const rsp = x[0].ajaxRsp.response; | ||
return [{ about: rsp }, []]; | ||
} | ||
protected request( | ||
pre: CombErr<OperationsAboutFlowInNode> | ||
): Observable<CombErr<OperationsAboutFlowOutNode>> { | ||
if (pre[1].length !== 0) return of(pre as any); | ||
if (pre[0]['fs-info'].Features.About) return super.request(pre); | ||
return of([{}, [new Error(`${pre[0].remote} unable to get about info`)]] as any); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters