Skip to content

Commit

Permalink
feat(list-view): recursively open directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed May 28, 2020
1 parent 08ee080 commit 38f8326
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/app/pages/manager/fileMode/fileMode.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, Input } from '@angular/core';
import { NavigationFlow } from 'src/app/@dataflow/extra';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { NavigationFlow, NavigationFlowOutNode } from 'src/app/@dataflow/extra';
import { ConnectionService } from '../../connection.service';
import { Subject } from 'rxjs';
import { OperationsListFlow, OperationsListFlowInNode } from 'src/app/@dataflow/rclone';
Expand All @@ -8,14 +8,16 @@ import { CombErr } from 'src/app/@dataflow/core';

@Component({
selector: 'manager-fileMode',
template: ` <manager-listView [list$]="list$"> </manager-listView> `,
template: ` <manager-listView [list$]="list$" (jump)="jump.emit($event)"> </manager-listView> `,
styles: [],
})
export class FileModeComponent implements OnInit {
constructor(private connectService: ConnectionService) {}

@Input() nav$: NavigationFlow;

@Output() jump = new EventEmitter<NavigationFlowOutNode>();

private listTrigger = new Subject<number>();
list$: OperationsListFlow;

Expand All @@ -35,7 +37,7 @@ export class FileModeComponent implements OnInit {
return [{ ...navNode[0], ...cmdNode[0] }, []];
}
),
filter(x=>x[1].length !==0 || !!x[0].remote)
filter((x) => x[1].length !== 0 || !!x[0].remote)
);
})();
this.list$.deploy();
Expand Down
27 changes: 24 additions & 3 deletions src/app/pages/manager/fileMode/listView/listView.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import { Columns, Config, DefaultConfig } from 'ngx-easy-table';
import { OperationsListFlowOutItemNode, OperationsListFlow } from 'src/app/@dataflow/rclone';
import { Subscription } from 'rxjs';
import { NavigationFlowOutNode } from 'src/app/@dataflow/extra';

@Component({
selector: 'manager-listView',
template: `
<ngx-table [configuration]="configuration" [data]="data" [columns]="columns"> </ngx-table>
<ngx-table
[configuration]="configuration"
[data]="data"
[columns]="columns"
(event)="eventEmitted($event)"
>
</ngx-table>
`,
styles: [],
})
Expand All @@ -18,14 +25,28 @@ export class ListViewComponent implements OnInit, OnDestroy {

constructor() {}

@Output() jump = new EventEmitter<NavigationFlowOutNode>();
private remote: string;
eventEmitted($event: { event: string; value: { row: OperationsListFlowOutItemNode } }): void {
// console.log('$event', $event);
if ($event.event === 'onDoubleClick') {
// console.log($event.value);
const item = $event.value.row;
if (item.IsDir) {
this.jump.emit({ remote: this.remote, path: item.Path });
}
}
}

@Input() list$: OperationsListFlow;

ngOnInit() {
this.listScrb = this.list$.getOutput().subscribe((x) => {
this.listScrb = this.list$.getSupersetOutput().subscribe((x) => {
if (x[1].length !== 0) {
this.data = undefined;
}
this.data = x[0].list;
this.remote = x[0].remote;
});

this.configuration = { ...DefaultConfig };
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/manager/manager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { HomeModeComponent } from './homeMode/homeMode.component';
<nb-card>
<nb-card-body>
<manager-homeMode *ngIf="homeMode" (jump)="addrJump($event)"> </manager-homeMode>
<manager-fileMode *ngIf="fileMode" [nav$]="nav$"> </manager-fileMode>
<manager-fileMode *ngIf="fileMode" [nav$]="nav$" (jump)="addrJump($event)">
</manager-fileMode>
</nb-card-body>
</nb-card>
</div>
Expand Down

0 comments on commit 38f8326

Please sign in to comment.