Skip to content

Commit

Permalink
feat(manager): show snipper when loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed Jun 8, 2020
1 parent 8546f49 commit 078675a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/app/pages/manager/fileMode/fileMode.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export class FileModeComponent implements OnInit {

@ViewChild(ListViewComponent) listView: ListViewComponent;

loading() {
this.listView.loading();
}

refresh() {
this.loading();
this.list$.clearCache();
this.listTrigger.next(1);
}
Expand Down
22 changes: 11 additions & 11 deletions src/app/pages/manager/fileMode/listView/listView.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export class ListViewComponent implements OnInit, OnDestroy {

private listScrb: Subscription;

resetCurrentPage() {
loading() {
this.configuration.isLoading = true;
this.checkAll = false; // TODO: not work around.
this.table.apiEvent({
type: API.setPaginationCurrentPage,
Expand All @@ -113,7 +114,7 @@ export class ListViewComponent implements OnInit, OnDestroy {
const item = $event.value.row;
if (item.IsDir) {
this.jump.emit({ remote: this.remote, path: item.Path });
this.resetCurrentPage();
this.loading();
}
}
}
Expand Down Expand Up @@ -151,10 +152,16 @@ export class ListViewComponent implements OnInit, OnDestroy {
}

ngOnInit() {
this.configuration = { ...DefaultConfig };
this.configuration.searchEnabled = true;
this.configuration.checkboxes = true;
this.configuration.isLoading = true;
// ... etc.
this.listScrb = this.listExtends$.getOutput().subscribe(listNode => {
this.checkAll = false;
this.configuration.isLoading = false;
if (listNode[1].length !== 0) {
this.data = undefined;
this.checkAll = false;
return;
}
this.remote = listNode[0].remote;
Expand All @@ -163,17 +170,10 @@ export class ListViewComponent implements OnInit, OnDestroy {
x.check = false;
x.ManipulateIcon = this.manipulate2Icon(x.Manipulation);
});
this.checkAll = false;
});

this.configuration = { ...DefaultConfig };
this.configuration.searchEnabled = true;
this.configuration.checkboxes = true;
// this.configuration.isLoading = true;
// ... etc.
}
ngOnDestroy() {
this.listScrb.unsubscribe();
this.resetCurrentPage();
this.loading();
}
}
15 changes: 14 additions & 1 deletion src/app/pages/manager/homeMode/homeMode.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { ConnectionService } from '../../connection.service';
@Component({
selector: 'app-manager-home-mode',
template: `
<div class="row justify-content-start">
<div
class="row justify-content-start"
[nbSpinner]="isLoading"
nbSpinnerSize="giant"
nbSpinnerStatus="primary"
nbSpinnerMessage="Loading..."
>
<div class="cloud col-xl-3 col-md-4 col-sm-6" *ngFor="let remote of remotes">
<app-home-view-remote
[easyMode]="true"
Expand All @@ -32,11 +38,17 @@ export class HomeModeComponent implements OnInit {
remotesTrigger = new Subject<number>();
remotes$: ListRemotesFlow;

isLoading = true;
loading() {
this.isLoading = true;
}
refresh() {
this.loading();
this.remotes$.clearCache();
this.remotesTrigger.next(1);
}
ngOnInit() {
this.loading();
const outer = this;
this.remotes$ = new (class extends ListRemotesFlow {
public prerequest$ = combineLatest([
Expand All @@ -47,6 +59,7 @@ export class HomeModeComponent implements OnInit {
this.remotes$.deploy();
this.remotesTrigger.next(1);
this.remotes$.getOutput().subscribe(x => {
this.isLoading = false;
if (x[1].length !== 0) return;
this.remotes = x[0].remotes;
});
Expand Down
6 changes: 6 additions & 0 deletions src/app/pages/manager/manager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,18 @@ export class ManagerComponent implements OnInit, OnDestroy {
isMobile = false;

visable = false;

loading() {
if (this.fileMode) this.file.loading();
else if (this.homeMode) this.home.loading();
}
refresh() {
if (this.homeMode) this.home.refresh();
else if (this.fileMode) this.file.refresh();
}

addrJump(addr: NavigationFlowOutNode) {
this.loading();
this.navTrigger.next(addr);
}

Expand Down
2 changes: 2 additions & 0 deletions src/app/pages/manager/manager.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
NbLayoutModule,
NbProgressBarModule,
NbSidebarModule,
NbSpinnerModule,
NbTabsetModule,
NbTooltipModule,
} from '@nebular/theme';
Expand Down Expand Up @@ -59,6 +60,7 @@ import { TasksDialogComponent } from './tasks/tasks.dialog';
NbBadgeModule,
NbTabsetModule,
NbAccordionModule,
NbSpinnerModule,
],
})
export class ManagerModule {}

0 comments on commit 078675a

Please sign in to comment.