You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.3 KiB
TypeScript
85 lines
3.3 KiB
TypeScript
5 years ago
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||
5 years ago
|
import { Subject } from 'rxjs';
|
||
5 years ago
|
import { takeUntil } from 'rxjs/operators';
|
||
5 years ago
|
import { Store } from '@ngrx/store';
|
||
|
|
||
5 years ago
|
import { MatTableDataSource, MatSort, MatPaginator, MatPaginatorIntl } from '@angular/material';
|
||
5 years ago
|
import { SelNodeChild } from '../../../shared/models/RTLconfig';
|
||
|
import { Channel } from '../../../shared/models/lndModels';
|
||
|
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, ScreenSizeEnum } from '../../../shared/services/consts-enums-functions';
|
||
|
import { LoggerService } from '../../../shared/services/logger.service';
|
||
|
import { CommonService } from '../../../shared/services/common.service';
|
||
5 years ago
|
|
||
5 years ago
|
import { LNDEffects } from '../../store/lnd.effects';
|
||
|
import * as RTLActions from '../../../store/rtl.actions';
|
||
|
import * as fromRTLReducer from '../../../store/rtl.reducers';
|
||
5 years ago
|
|
||
|
@Component({
|
||
5 years ago
|
selector: 'rtl-channel-restore-table',
|
||
|
templateUrl: './channel-restore-table.component.html',
|
||
5 years ago
|
styleUrls: ['./channel-restore-table.component.scss'],
|
||
|
providers: [
|
||
|
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Channels') }
|
||
|
]
|
||
5 years ago
|
})
|
||
5 years ago
|
export class ChannelRestoreTableComponent implements OnInit {
|
||
5 years ago
|
@ViewChild(MatSort, { static: true }) sort: MatSort;
|
||
5 years ago
|
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
|
||
|
public pageSize = PAGE_SIZE;
|
||
|
public pageSizeOptions = PAGE_SIZE_OPTIONS;
|
||
5 years ago
|
public selNode: SelNodeChild = {};
|
||
5 years ago
|
public displayedColumns = ['channel_point', 'actions'];
|
||
5 years ago
|
public selChannel: Channel;
|
||
|
public channels: any;
|
||
|
public allRestoreExists = false;
|
||
|
public flgLoading: Array<Boolean | 'error'> = [true]; // 0: channels
|
||
|
public flgSticky = false;
|
||
5 years ago
|
public screenSize = '';
|
||
|
public screenSizeEnum = ScreenSizeEnum;
|
||
5 years ago
|
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
||
|
|
||
5 years ago
|
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private lndEffects: LNDEffects, private commonService: CommonService) {
|
||
|
this.screenSize = this.commonService.getScreenSize();
|
||
|
}
|
||
5 years ago
|
|
||
|
ngOnInit() {
|
||
|
this.store.dispatch(new RTLActions.RestoreChannelsList());
|
||
|
this.store.select('lnd')
|
||
|
.pipe(takeUntil(this.unSubs[0]))
|
||
|
.subscribe((rtlStore) => {
|
||
|
this.selNode = rtlStore.nodeSettings;
|
||
|
this.logger.info(rtlStore);
|
||
|
});
|
||
|
this.lndEffects.setRestoreChannelList
|
||
|
.pipe(takeUntil(this.unSubs[0]))
|
||
|
.subscribe((resRCList) => {
|
||
|
this.allRestoreExists = resRCList.all_restore_exists;
|
||
|
this.channels = new MatTableDataSource([...resRCList.files]);
|
||
|
this.channels.data = resRCList.files;
|
||
|
this.channels.sort = this.sort;
|
||
5 years ago
|
this.channels.paginator = this.paginator;
|
||
5 years ago
|
if (this.flgLoading[0] !== 'error' || (resRCList && resRCList.files)) {
|
||
|
this.flgLoading[0] = false;
|
||
|
}
|
||
|
this.logger.info(resRCList);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
onRestoreChannels(selChannel: Channel) {
|
||
|
this.store.dispatch(new RTLActions.OpenSpinner('Restoring Channels...'));
|
||
|
this.store.dispatch(new RTLActions.RestoreChannels({channelPoint: (selChannel.channel_point) ? selChannel.channel_point : 'ALL'}));
|
||
|
}
|
||
|
|
||
|
applyFilter(selFilter: string) {
|
||
|
this.channels.filter = selFilter;
|
||
|
}
|
||
|
|
||
|
ngOnDestroy() {
|
||
|
this.unSubs.forEach(completeSub => {
|
||
|
completeSub.next();
|
||
|
completeSub.complete();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
}
|