-
Notifications
You must be signed in to change notification settings - Fork 44
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 features in fs info
- Loading branch information
Showing
6 changed files
with
176 additions
and
1 deletion.
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,73 @@ | ||
import { AjaxFlowInteralNode, CombErr, FlowOutNode } from '../core'; | ||
import { IRcloneServer, NavigationFlowOutNode } from '../extra'; | ||
import { PostFlow } from './post-flow'; | ||
|
||
export interface OperationsFsinfoFlowParamsNode { | ||
/** a remote name string eg "drive:" */ | ||
fs: string; | ||
} | ||
|
||
export interface OperationsFsinfoFlowInNode extends NavigationFlowOutNode, IRcloneServer {} | ||
|
||
export interface OperationsFsinfoFlowOutItemNode { | ||
Features: { | ||
About: boolean; | ||
BucketBased: boolean; | ||
CanHaveEmptyDirectories: boolean; | ||
CaseInsensitive: boolean; | ||
ChangeNotify: boolean; | ||
CleanUp: boolean; | ||
Copy: boolean; | ||
DirCacheFlush: boolean; | ||
DirMove: boolean; | ||
DuplicateFiles: boolean; | ||
GetTier: boolean; | ||
ListR: boolean; | ||
MergeDirs: boolean; | ||
Move: boolean; | ||
OpenWriterAt: boolean; | ||
PublicLink: boolean; | ||
Purge: boolean; | ||
PutStream: boolean; | ||
PutUnchecked: boolean; | ||
ReadMimeType: boolean; | ||
ServerSideAcrossConfigs: boolean; | ||
SetTier: boolean; | ||
SetWrapper: boolean; | ||
UnWrap: boolean; | ||
WrapFs: boolean; | ||
WriteMimeType: boolean; | ||
}; | ||
// Names of hashes available | ||
Hashes: ('MD5' | 'SHA-1' | 'DropboxHash' | 'QuickXorHash')[]; | ||
// Name as created | ||
Name: string; | ||
// Precision of timestamps in ns | ||
Precision: number; | ||
// Path as created | ||
Root: string; | ||
// how the remote will appear in logs | ||
String: string; | ||
} | ||
export interface OperationsFsinfoFlowOutNode extends FlowOutNode { | ||
'fs-info': OperationsFsinfoFlowOutItemNode; | ||
} | ||
|
||
export abstract class OperationsFsinfoFlow extends PostFlow< | ||
OperationsFsinfoFlowInNode, | ||
OperationsFsinfoFlowOutNode, | ||
OperationsFsinfoFlowParamsNode | ||
> { | ||
// public prerequest$: Observable<CombErr<OperationsFsinfoFlowInNode>>; | ||
protected cmd = 'operations/fsinfo'; | ||
protected cacheSupport = true; | ||
protected params = (pre: CombErr<OperationsFsinfoFlowInNode>): OperationsFsinfoFlowParamsNode => { | ||
if (pre[1].length !== 0) return {} as any; | ||
return { fs: `${pre[0].remote}:` }; | ||
}; | ||
protected reconstructAjaxResult(x: AjaxFlowInteralNode): CombErr<OperationsFsinfoFlowOutNode> { | ||
if (x[1].length !== 0) return [{}, x[1]] as any; | ||
const rsp = x[0].ajaxRsp.response; | ||
return [{ 'fs-info': rsp }, []]; | ||
} | ||
} |
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,89 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { combineLatest, Subject } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
import { CombErr } from '../../../@dataflow/core'; | ||
import { NavigationFlowOutNode } from '../../../@dataflow/extra'; | ||
import { OperationsFsinfoFlow, OperationsFsinfoFlowInNode } from '../../../@dataflow/rclone'; | ||
import { ConnectionService } from '../../connection.service'; | ||
|
||
@Component({ | ||
selector: 'app-home-remote-detail', | ||
template: ` | ||
<h5>{{ _remote }}</h5> | ||
<nb-accordion> | ||
<nb-accordion-item *ngIf="feature.length"> | ||
<nb-accordion-item-header>Feature</nb-accordion-item-header> | ||
<nb-accordion-item-body> | ||
<nb-list [nbSpinner]="loadingFsinfo" nbSpinnerSize="giant" nbSpinnerStatus="primary"> | ||
<nb-list-item *ngFor="let item of feature"> | ||
<nb-icon | ||
[icon]="item.v ? 'checkmark-circle' : 'close-circle-outline'" | ||
[status]="item.v ? 'success' : 'danger'" | ||
> | ||
</nb-icon> | ||
<div>{{ item.k }}</div> | ||
</nb-list-item> | ||
</nb-list> | ||
</nb-accordion-item-body> | ||
</nb-accordion-item> | ||
</nb-accordion> | ||
`, | ||
styles: [ | ||
` | ||
h5 { | ||
padding: 0 1.25rem; | ||
} | ||
nb-list { | ||
margin: 0 -0.5rem; | ||
} | ||
nb-list-item { | ||
padding: 0.5rem 0; | ||
} | ||
nb-list-item > nb-icon { | ||
width: 1rem; | ||
height: 1rem; | ||
} | ||
nb-list-item > div { | ||
padding-left: 0.5rem; | ||
} | ||
`, | ||
], | ||
}) | ||
export class RemoteDetailComponent implements OnInit { | ||
constructor(private cmdService: ConnectionService) {} | ||
protected _remote = ''; | ||
protected loadingFsinfo = false; | ||
protected feature: { k: string; v: boolean }[] = []; | ||
set remote(x: NavigationFlowOutNode) { | ||
this._remote = x.remote || ''; | ||
this.loadingFsinfo = true; | ||
this.trigger.next(x.remote); | ||
} | ||
|
||
private trigger = new Subject<string>(); | ||
fsinfo$: OperationsFsinfoFlow; | ||
ngOnInit() { | ||
const outer = this; | ||
this.loadingFsinfo = false; | ||
this.fsinfo$ = new (class extends OperationsFsinfoFlow { | ||
public prerequest$ = combineLatest([ | ||
outer.trigger, | ||
outer.cmdService.listCmd$.verify(this.cmd), | ||
]).pipe( | ||
map( | ||
([remote, cmdNode]): CombErr<OperationsFsinfoFlowInNode> => { | ||
if (cmdNode[1].length !== 0) return [{}, cmdNode[1]] as any; | ||
return [{ ...cmdNode[0], remote }, []]; | ||
} | ||
) | ||
); | ||
})(); | ||
this.fsinfo$.deploy(); | ||
this.fsinfo$.getOutput().subscribe(x => { | ||
this.loadingFsinfo = false; | ||
if (x[1].length !== 0) return; | ||
const fsinfo = x[0]['fs-info']; | ||
this.feature = Object.keys(fsinfo.Features).map(k => ({ k, v: fsinfo.Features[k] })); | ||
}); | ||
} | ||
} |
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