Skip to content

Commit

Permalink
feat(remote.detail): show remote features in fs info
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed Jun 8, 2020
1 parent 61a8872 commit 6850ccc
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/app/@dataflow/rclone/index.ts
Expand Up @@ -18,3 +18,4 @@ export * from './core-memstats-flow';
export * from './core-bwlimit-flow';
export * from './options-get-flow';
export * from './options-set-flow';
export * from './operations-fsinfo-flow';
73 changes: 73 additions & 0 deletions src/app/@dataflow/rclone/operations-fsinfo-flow.ts
@@ -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 }, []];
}
}
2 changes: 2 additions & 0 deletions src/app/pages/manager/homeMode/homeMode.component.ts
Expand Up @@ -26,6 +26,7 @@ import { ConnectionService } from '../../connection.service';
<app-home-view-remote
[easyMode]="true"
[title]="remote"
(click)="showDetail.emit({ remote: remote })"
(dblclick)="jump.emit({ remote: remote })"
>
</app-home-view-remote>
Expand All @@ -41,6 +42,7 @@ export class HomeModeComponent implements OnInit {

@Input() detail: boolean;
@Output() jump = new EventEmitter<NavigationFlowOutNode>();
@Output() showDetail = new EventEmitter<NavigationFlowOutNode>();

remotesTrigger = new Subject<number>();
remotes$: ListRemotesFlow;
Expand Down
89 changes: 89 additions & 0 deletions src/app/pages/manager/homeMode/remote.detail.ts
@@ -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] }));
});
}
}
8 changes: 7 additions & 1 deletion src/app/pages/manager/manager.component.ts
Expand Up @@ -16,6 +16,7 @@ import { ClipboardService } from './clipboard/clipboard.service';
import { MkdirDialogComponent } from './dialogs/mkdir.dialog';
import { FileModeComponent } from './fileMode/fileMode.component';
import { HomeModeComponent } from './homeMode/homeMode.component';
import { RemoteDetailComponent } from './homeMode/remote.detail';
import { TasksDialogComponent } from './tasks/tasks.dialog';
import { TaskService } from './tasks/tasks.service';

Expand All @@ -37,6 +38,7 @@ import { TaskService } from './tasks/tasks.service';
*ngIf="homeMode"
[detail]="detailExpanded"
(jump)="addrJump($event)"
(showDetail)="remoteDetail.remote = $event"
>
</app-manager-home-mode>
<app-manager-file-mode *ngIf="fileMode" [nav$]="nav$" (jump)="addrJump($event)">
Expand All @@ -45,7 +47,7 @@ import { TaskService } from './tasks/tasks.service';
</nb-card>
</div>
<nb-sidebar fixed end class="right-bar" tag="detail">
123
<app-home-remote-detail *ngIf="homeMode"> </app-home-remote-detail>
</nb-sidebar>
<nb-layout-footer [ngClass]="{ mobile: !mainBar, pc: mainBar }">
<nb-actions>
Expand Down Expand Up @@ -98,6 +100,9 @@ import { TaskService } from './tasks/tasks.service';
top: calc(4.75rem * 2 + 0.05rem) !important;
bottom: 65px !important;
}
:host nb-sidebar ::ng-deep .scrollable {
padding: 1.25rem 0 !important;
}
.subcolumn {
margin-bottom: 4.75rem;
margin-top: 1.5rem;
Expand Down Expand Up @@ -154,6 +159,7 @@ export class ManagerComponent implements OnInit, OnDestroy {
@ViewChild(FileModeComponent) file: FileModeComponent;
@ViewChild(HomeModeComponent) home: HomeModeComponent;
@ViewChild(NbSidebarComponent) detail: NbSidebarComponent;
@ViewChild(RemoteDetailComponent) remoteDetail: RemoteDetailComponent;

private navTrigger = new Subject<NavigationFlowOutNode>();
nav$: NavigationFlow;
Expand Down
4 changes: 4 additions & 0 deletions src/app/pages/manager/manager.module.ts
Expand Up @@ -11,6 +11,7 @@ import {
NbIconModule,
NbInputModule,
NbLayoutModule,
NbListModule,
NbProgressBarModule,
NbSidebarModule,
NbSpinnerModule,
Expand All @@ -26,6 +27,7 @@ import { FileModeComponent } from './fileMode/fileMode.component';
import { ListViewComponent } from './fileMode/listView/listView.component';
import { HomeModeComponent } from './homeMode/homeMode.component';
import { RemoteComponent } from './homeMode/remote.component';
import { RemoteDetailComponent } from './homeMode/remote.detail';
import { ManagerRoutingModule } from './manager-routing.module';
import { ManagerComponent } from './manager.component';
import { TasksDialogComponent } from './tasks/tasks.dialog';
Expand All @@ -42,6 +44,7 @@ import { TasksDialogComponent } from './tasks/tasks.dialog';
ClipboardRemotesTableComponent,
TasksDialogComponent,
MkdirDialogComponent,
RemoteDetailComponent,
],
imports: [
CommonModule,
Expand All @@ -61,6 +64,7 @@ import { TasksDialogComponent } from './tasks/tasks.dialog';
NbTabsetModule,
NbAccordionModule,
NbSpinnerModule,
NbListModule,
],
})
export class ManagerModule {}

0 comments on commit 6850ccc

Please sign in to comment.