diff --git a/i18n-edit.babel b/i18n-edit.babel index 7548b2e..b3e7862 100644 --- a/i18n-edit.babel +++ b/i18n-edit.babel @@ -17,1073 +17,284 @@ - charts + app - network-hashrate + lthn - - subtitle - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - title - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - - - - - lang - - - de - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - en - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - es - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - fr - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - ru - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - zh - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - - - menu - - - text - - - about - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - activity - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - api - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - blockchain - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - build - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - dashboard - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - docs - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - explorer - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - help - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - info - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - settings - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - vpn - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - wallet - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - - - - - plugin - - - lthn - - - chain - - - table - - - th - - - age - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - depth - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - difficulty - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - hash - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - height - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - orphan_status - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - reward - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - time - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - timestamp - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - + + chain + + + description + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + heading + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + table + + + age + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + depth + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + difficulty + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + height + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + reward + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + time + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + title - - blockchain-explorer - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - chain-status false @@ -1154,11 +365,110 @@ + + title + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + words - alt_blocks + alt_blocks_count + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + block_size_limit + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + cumulative_difficulty false @@ -1256,6 +566,39 @@ + + hash + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + height false @@ -1421,6 +764,39 @@ + + orphan_status + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + outgoing_connections_count false @@ -1454,6 +830,39 @@ + + start_time + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + status false @@ -1587,7 +996,40 @@ - top_block_hash + timestamp + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + top_height false @@ -1653,7 +1095,7 @@ - tx_pool + tx_pool_size false @@ -1722,6 +1164,734 @@ + + + + + + charts + + + network-hashrate + + + subtitle + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + title + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + + + + + lang + + + de + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + en + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + es + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + fr + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + ru + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + zh + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + + + menu + + + text + + + about + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + activity + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + api + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + blockchain + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + build + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + dashboard + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + docs + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + explorer + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + help + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + info + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + settings + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + vpn + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + wallet + false + + + + + + de-DE + false + + + en-GB + false + + + es-ES + false + + + fr-FR + false + + + ru-RU + false + + + zh-CN + false + + + + + + + + + plugin + + + lthn + daemons @@ -2480,110 +2650,6 @@ view - - chain - - - description - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - heading - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - title - false - - - - - - de-DE - false - - - en-GB - false - - - es-ES - false - - - fr-FR - false - - - ru-RU - false - - - zh-CN - false - - - - - dashboard diff --git a/src/app/modules/chain/blockchain-routing.module.ts b/src/app/modules/chain/blockchain-routing.module.ts index 675c865..d966900 100644 --- a/src/app/modules/chain/blockchain-routing.module.ts +++ b/src/app/modules/chain/blockchain-routing.module.ts @@ -2,12 +2,12 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {RouterModule, Routes} from '@angular/router'; import {BlockchainComponent} from '@module/chain/blockchain.component'; -import {BlockdetailsComponent} from "@module/chain/blockdetails/blockdetails.component"; +import {BlockDetailsComponent} from "@module/chain/components/block/details.component"; const routes: Routes = [ { path: 'chain/block/:id', - component: BlockdetailsComponent, + component: BlockDetailsComponent, data: { title: 'view.chain.title', heading: 'view.chain.heading', diff --git a/src/app/modules/chain/blockchain.component.html b/src/app/modules/chain/blockchain.component.html index 0a04784..0b9b9c0 100644 --- a/src/app/modules/chain/blockchain.component.html +++ b/src/app/modules/chain/blockchain.component.html @@ -1,163 +1,53 @@ -
- - - - View Block by Hash - - - - - - - -
-
- - - Lethean Blockchain Loading - -

- This should only take a few seconds, for support visit sparta.lt.hn -

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - Information - - - - Status: {{info.status }} - Daemon Start: {{info.start_time * 1000 | amTimeAgo }} - Height: {{info.height }} - Target Height: {{info.target_height }} - Top:  - White Peers: {{info.white_peerlist_size }} - Grey Peers: {{info.grey_peerlist_size }} - Difficulty: {{info.difficulty | hashrate }} - Cumulative: {{info.cumulative_difficulty | hashrate }} - Connect INC: {{info.incoming_connections_count }} - Connect OUT: {{info.outgoing_connections_count }} - TX Count: {{info.tx_count }} - TX Pool Size: {{info.tx_pool_size }} - Testnet: {{info.testnet }} - Block Time: {{info.target }} - Alt Blocks: {{info.alt_blocks_count }} - Block Size Limit: {{info.block_size_limit }} - - - - - - Chain Status: -   - +
+
+ + + {{ 'app.lthn.chain.title' | translate }} +   + ({{info.height | number }}/{{info.target_height | number}} = {{ (info.height/info.target_height) | percent:'1.2-3' }}) - + Synchronized - - - - - - - - - -

The data shown here comes from your local data, accurate to the point in time you have synced;

-

Advanced users can "pop off" blocks from their local chain to see the work at particular heights

- - - - - - {{ value | hashrate}} - {{ value | number }} - - {{ value | hashLink }} - - done - close - - {{ value | amFromUnix }} - {{ value | number }} - {{ value | number }} - {{ value }} - {{ value | number }} - {{ value }} - {{ value | number }} - {{ value }} - - - - - - - - - - - + + + + + + + + + + + + + - -
- - +
+
+ + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+
+
- - - -
- -
-
+ diff --git a/src/app/modules/chain/blockchain.component.ts b/src/app/modules/chain/blockchain.component.ts index 239099b..e64a459 100644 --- a/src/app/modules/chain/blockchain.component.ts +++ b/src/app/modules/chain/blockchain.component.ts @@ -1,131 +1,34 @@ -import {Component, OnDestroy, OnInit, TemplateRef, ViewChild} from '@angular/core'; -import {ChartService} from '@module/chart/chart.service'; +import {Component} from '@angular/core'; import {ChainGetInfo} from '@module/chain/interfaces/props/get_info'; -import {interval, Subscription} from 'rxjs'; import {BlockHeader} from '@module/chain/interfaces/types/blockHeader'; -import {ColumnMode} from '@swimlane/ngx-datatable'; +import {FormControl} from '@angular/forms'; import {BlockchainService} from '@module/chain/blockchain.service'; -import {FormControl, Validators} from '@angular/forms'; -import {DrawerDirection, DrawerService} from '@swimlane/ngx-ui'; @Component({ selector: 'lthn-chain', - templateUrl: './blockchain.component.html', - providers: [ChartService] + templateUrl: './blockchain.component.html' }) -export class BlockchainComponent implements OnInit, OnDestroy { +export class BlockchainComponent { - columns: any = []; - - page = { - size: 25, - totalElements: 0, - totalPages: 0, - pageNumber: 0 - }; - - allColumns = [ - {prop: 'height', name: 'plugin.lthn.chain.table.th.height', default: true}, - {prop: 'difficulty', name: 'plugin.lthn.chain.table.th.difficulty', default: true}, - {prop: 'hash', name: 'plugin.lthn.chain.table.th.hash', default: true}, - {prop: 'orphan_status', name: 'plugin.lthn.chain.table.th.orphan_status', default: true}, - //{ prop: 'reward', name: 'plugin.lthn.chain.table.th.reward', default: true }, - {prop: 'timestamp', name: 'plugin.lthn.chain.table.th.timestamp', default: true} - // { prop: 'block_size', name: 'Block Size', default: true }, - //{ prop: 'depth', name: 'plugin.lthn.chain.table.th.depth', default: true }, - //{ prop: 'major_version', name: 'Block Major Version', default: true }, - // { prop: 'minor_version', name: 'Block Minor Version', default: false }, - // { prop: 'nonce', name: 'Block Nonce', default: false }, - // { prop: 'num_txes', name: 'Transactions', default: true }, - // { prop: 'prev_hash', name: 'Last Hash', default: true }, - ]; - ColumnMode = ColumnMode; - blocks: BlockHeader[] ; + blocks: BlockHeader[]; chainInfo: ChainGetInfo; - @ViewChild('editTmpl', { static: false }) editTmpl: TemplateRef; - private sub: Subscription[] = []; + recentTxs: any; buildType: string; status_daemon: number = 0; blockSearch: FormControl; start_height: number = null; end_height: number = null; - constructor( - private chain: BlockchainService, - private drawerService: DrawerService) { - - this.allColumns.forEach((col) => { - if (col.default) { - - this.columns.push( - col - ); - } - }); - } - - - async ngOnInit() { - this.blockSearch = new FormControl('', [Validators.required]); - //this.chain.getInfo() - this.chainInfo = await this.chain.getInfo(); - if (this.chainInfo) { - // we have chain data, and it talks to us set to amber - this.status_daemon = 1; - //console.log(data) - // if chain height + 4 to give 2~ blocks to be considered healthy - if (this.chainInfo.height + 4 > this.chainInfo.target_height) { - this.status_daemon = 2; - } - this.page.totalElements = this.chainInfo.height - } else { - this.status_daemon = 0; - } - await this.getBlocks() + constructor(public chain: BlockchainService) { - this.sub['interval'] = interval(5000).subscribe(async () => this.chainInfo = await this.chain.getInfo()); } - async getBlocks() { - let start_height = this.page.totalElements - this.page.pageNumber * this.page.size - 1 - let end_height = this.page.totalElements - this.page.size - this.page.pageNumber * this.page.size - this.blocks = await this.chain.getBlocks(Math.max(0, end_height), Math.max(0, start_height)); - } - - toggle(col) { - const isChecked = this.isChecked(col); - - if (isChecked) { - this.columns = this.columns.filter(c => { - return c.name !== col.name; - }); - } else { - this.columns.push(col); - } - } - - isChecked(col) { - return ( - this.columns.find(c => { - return c.name === col.name; - }) !== undefined - ); - } + async ngOnInit() { - public ngOnDestroy() { - this.sub.forEach((s) => s.unsubscribe()); } - openDrawer(id) { - this.drawerService.create({ - direction: DrawerDirection.Left, - template: this.editTmpl, - closeOnOutsideClick: true, - context: { id} - }); - } } diff --git a/src/app/modules/chain/blockchain.module.ts b/src/app/modules/chain/blockchain.module.ts index 77c65d2..87c35d7 100644 --- a/src/app/modules/chain/blockchain.module.ts +++ b/src/app/modules/chain/blockchain.module.ts @@ -17,15 +17,18 @@ import {PipesModule} from '@pipe/pipes.module'; import {HashRatePipe} from '@pipe/crypto/hashrate.pipe'; import {MomentModule} from 'ngx-moment'; import {MatProgressBarModule} from '@angular/material/progress-bar'; -import { BlockdetailsComponent } from './blockdetails/blockdetails.component'; import {RouterModule} from "@angular/router"; import {MatFormFieldModule} from "@angular/material/form-field"; import {MatInputModule} from "@angular/material/input"; -import {ReactiveFormsModule} from "@angular/forms"; -import {SectionModule, ToolbarModule} from '@swimlane/ngx-ui'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {ButtonModule, CodeEditorModule, SectionModule, TabsModule, ToolbarModule} from '@swimlane/ngx-ui'; +import {BlockDetailsComponent} from '@module/chain/components/block/details.component'; +import {BlockLedgerComponent} from '@module/chain/components/block/ledger.component'; +import { BlockchainStatsComponent} from '@module/chain/components/stats.component'; +import {BlockchainConfigComponent} from '@module/chain/components/config.component'; @NgModule({ - declarations: [BlockchainComponent, BlockdetailsComponent], + declarations: [BlockchainComponent, BlockDetailsComponent, BlockLedgerComponent, BlockchainStatsComponent, BlockchainConfigComponent], imports: [ CommonModule, ChartModule, @@ -48,7 +51,11 @@ import {SectionModule, ToolbarModule} from '@swimlane/ngx-ui'; MatInputModule, ReactiveFormsModule, SectionModule, - ToolbarModule + ToolbarModule, + TabsModule, + CodeEditorModule, + FormsModule, + ButtonModule ], exports: [ BlockchainComponent], providers: [HashRatePipe] diff --git a/src/app/modules/chain/blockdetails/blockdetails.component.html b/src/app/modules/chain/components/block/details.component.html similarity index 100% rename from src/app/modules/chain/blockdetails/blockdetails.component.html rename to src/app/modules/chain/components/block/details.component.html diff --git a/src/app/modules/chain/blockdetails/blockdetails.component.ts b/src/app/modules/chain/components/block/details.component.ts similarity index 82% rename from src/app/modules/chain/blockdetails/blockdetails.component.ts rename to src/app/modules/chain/components/block/details.component.ts index 4fc03d1..c20ce53 100644 --- a/src/app/modules/chain/blockdetails/blockdetails.component.ts +++ b/src/app/modules/chain/components/block/details.component.ts @@ -4,10 +4,10 @@ import {BlockchainService} from '@module/chain/blockchain.service'; import {BlockHeader} from '@module/chain/interfaces/types/blockHeader'; @Component({ - selector: 'lthn-chain-blockdetails', - templateUrl: './blockdetails.component.html' + selector: 'lthn-chain-block-details', + templateUrl: './details.component.html' }) -export class BlockdetailsComponent implements OnInit, OnDestroy { +export class BlockDetailsComponent implements OnInit, OnDestroy { blockID: string; sub: Subscription; diff --git a/src/app/modules/chain/components/block/ledger.component.html b/src/app/modules/chain/components/block/ledger.component.html new file mode 100644 index 0000000..97ebe00 --- /dev/null +++ b/src/app/modules/chain/components/block/ledger.component.html @@ -0,0 +1,40 @@ + + + + + + + {{ value | hashrate}} + {{ value | number }} + + {{ value | hashLink }} + + done + close + + {{ value | amFromUnix }} + {{ value | number }} + {{ value | number }} + {{ value }} + {{ value | number }} + {{ value }} + {{ value | number }} + {{ value }} + + + diff --git a/src/app/modules/chain/components/block/ledger.component.ts b/src/app/modules/chain/components/block/ledger.component.ts new file mode 100644 index 0000000..3024927 --- /dev/null +++ b/src/app/modules/chain/components/block/ledger.component.ts @@ -0,0 +1,131 @@ +import {Component, OnDestroy, OnInit, TemplateRef, ViewChild} from '@angular/core'; +import {ChartService} from '@module/chart/chart.service'; +import {ChainGetInfo} from '@module/chain/interfaces/props/get_info'; +import {interval, Subscription} from 'rxjs'; +import {BlockHeader} from '@module/chain/interfaces/types/blockHeader'; +import {ColumnMode} from '@swimlane/ngx-datatable'; +import {BlockchainService} from '@module/chain/blockchain.service'; +import {FormControl, Validators} from '@angular/forms'; +import {DrawerDirection, DrawerService} from '@swimlane/ngx-ui'; + +@Component({ + selector: 'lthn-chain-ledger', + templateUrl: './ledger.component.html', + providers: [ChartService] +}) +export class BlockLedgerComponent implements OnInit, OnDestroy { + + columns: any = []; + + page = { + size: 25, + totalElements: 0, + totalPages: 0, + pageNumber: 0 + }; + + allColumns = [ + {prop: 'height', name: 'app.lthn.chain.words.height', default: true}, + {prop: 'difficulty', name: 'app.lthn.chain.words.difficulty', default: true}, + {prop: 'hash', name: 'app.lthn.chain.words.hash', default: true}, + {prop: 'orphan_status', name: 'app.lthn.chain.words.orphan_status', default: true}, + //{ prop: 'reward', name: 'plugin.lthn.chain.table.th.reward', default: true }, + {prop: 'timestamp', name: 'app.lthn.chain.words.timestamp', default: true}, + // { prop: 'block_size', name: 'Block Size', default: true }, + //{ prop: 'depth', name: 'plugin.lthn.chain.table.th.depth', default: true }, + //{ prop: 'major_version', name: 'Block Major Version', default: true }, + // { prop: 'minor_version', name: 'Block Minor Version', default: false }, + // { prop: 'nonce', name: 'Block Nonce', default: false }, + { prop: 'num_txes', name: 'Transactions', default: true }, + // { prop: 'prev_hash', name: 'Last Hash', default: true }, + ]; + ColumnMode = ColumnMode; + blocks: BlockHeader[] ; + chainInfo: ChainGetInfo; + @ViewChild('editTmpl', { static: false }) editTmpl: TemplateRef; + private sub: Subscription[] = []; + recentTxs: any; + buildType: string; + status_daemon: number = 0; + blockSearch: FormControl; + start_height: number = null; + end_height: number = null; + constructor( + private chain: BlockchainService, + private drawerService: DrawerService) { + + this.allColumns.forEach((col) => { + if (col.default) { + + this.columns.push( + col + ); + } + }); + } + + + async ngOnInit() { + this.blockSearch = new FormControl('', [Validators.required]); + + //this.chain.getInfo() + this.chainInfo = await this.chain.getInfo(); + if (this.chainInfo) { + // we have chain data, and it talks to us set to amber + this.status_daemon = 1; + //console.log(data) + // if chain height + 4 to give 2~ blocks to be considered healthy + if (this.chainInfo.height + 4 > this.chainInfo.target_height) { + this.status_daemon = 2; + } + this.page.totalElements = this.chainInfo.height + } else { + this.status_daemon = 0; + } + await this.getBlocks() + + this.sub['interval'] = interval(5000).subscribe(async () => this.chainInfo = await this.chain.getInfo()); + + } + + async getBlocks() { + let start_height = this.page.totalElements - this.page.pageNumber * this.page.size - 1 + let end_height = this.page.totalElements - this.page.size - this.page.pageNumber * this.page.size + + this.blocks = await this.chain.getBlocks(Math.max(0, end_height), Math.max(0, start_height)); + } + + toggle(col) { + const isChecked = this.isChecked(col); + + if (isChecked) { + this.columns = this.columns.filter(c => { + return c.name !== col.name; + }); + } else { + this.columns.push(col); + } + } + + isChecked(col) { + return ( + this.columns.find(c => { + return c.name === col.name; + }) !== undefined + ); + } + + public ngOnDestroy() { + this.sub.forEach((s) => s.unsubscribe()); + } + openDrawer(id) { + this.drawerService.create({ + direction: DrawerDirection.Left, + template: this.editTmpl, + closeOnOutsideClick: true, + context: { id} + + }); + } + +} diff --git a/src/app/modules/chain/components/config.component.html b/src/app/modules/chain/components/config.component.html new file mode 100644 index 0000000..8c17888 --- /dev/null +++ b/src/app/modules/chain/components/config.component.html @@ -0,0 +1,13 @@ + +
+ + + Save File +
+ diff --git a/src/app/modules/chain/components/config.component.ts b/src/app/modules/chain/components/config.component.ts new file mode 100644 index 0000000..4e67202 --- /dev/null +++ b/src/app/modules/chain/components/config.component.ts @@ -0,0 +1,32 @@ +import {Component} from '@angular/core'; +import {ChainGetInfo} from '@module/chain/interfaces/props/get_info'; +import {BlockchainService} from '@module/chain/blockchain.service'; +import {FileSystemService} from '@service/filesystem/file-system.service'; +import {NotificationService, NotificationStyleType, NotificationType} from '@swimlane/ngx-ui'; +@Component({ + selector: 'lthn-chain-config', + templateUrl: './config.component.html' +}) +export class BlockchainConfigComponent { + + public config = '' + chainInfo: ChainGetInfo; + + constructor(public chain: BlockchainService, private fs: FileSystemService, private notify: NotificationService) { + this.load().then(() => console.log('loaded')); + } + + async save() { + await this.fs.writeFile('conf/letheand.conf', this.config) + this.notify.create({ + type: NotificationType.html, + styleType: NotificationStyleType.success, + title: 'Saved Config File' + }) + } + + async load() { + this.config = await this.fs.readFile('conf/letheand.conf') + } + +} diff --git a/src/app/modules/chain/components/stats.component.html b/src/app/modules/chain/components/stats.component.html new file mode 100644 index 0000000..0a64663 --- /dev/null +++ b/src/app/modules/chain/components/stats.component.html @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatisticValue
{{ 'app.lthn.chain.words.status' | translate}}{{ info.status }}
{{ 'app.lthn.chain.words.height' | translate}}{{ info.height | number }}
{{ 'app.lthn.chain.words.start_time' | translate}}{{info.start_time * 1000 | amTimeAgo }}
{{ 'app.lthn.chain.words.target_height' | translate}}{{info.target_height }}
{{ 'app.lthn.chain.words.top_height' | translate}}
{{ 'app.lthn.chain.words.white_peerlist_size' | translate}}{{info.white_peerlist_size }}
{{ 'app.lthn.chain.words.grey_peerlist_size' | translate}}{{info.grey_peerlist_size }}
{{ 'app.lthn.chain.words.difficulty' | translate}}{{info.difficulty | hashrate }}
{{ 'app.lthn.chain.words.cumulative_difficulty' | translate}}{{info.cumulative_difficulty | hashrate }}
{{ 'app.lthn.chain.words.incoming_connections_count' | translate}}{{info.incoming_connections_count }}
{{ 'app.lthn.chain.words.tx_count' | translate}}{{info.tx_count }}
{{ 'app.lthn.chain.words.tx_pool_size' | translate}}{{info.tx_pool_size }}
{{ 'app.lthn.chain.words.testnet' | translate}}{{info.testnet }}
{{ 'app.lthn.chain.words.outgoing_connections_count' | translate}}{{info.outgoing_connections_count }}
{{ 'app.lthn.chain.words.target' | translate}}{{info.target }}
{{ 'app.lthn.chain.words.alt_blocks_count' | translate}}{{info.alt_blocks_count }}
{{ 'app.lthn.chain.words.block_size_limit' | translate}}{{info.block_size_limit }}
diff --git a/src/app/modules/chain/components/stats.component.ts b/src/app/modules/chain/components/stats.component.ts new file mode 100644 index 0000000..909698d --- /dev/null +++ b/src/app/modules/chain/components/stats.component.ts @@ -0,0 +1,16 @@ +import {Component} from '@angular/core'; +import {ChainGetInfo} from '@module/chain/interfaces/props/get_info'; +import {BlockchainService} from '@module/chain/blockchain.service'; + +@Component({ + selector: 'lthn-chain-stats', + templateUrl: './stats.component.html' +}) +export class BlockchainStatsComponent { + + + chainInfo: ChainGetInfo; + + constructor(public chain: BlockchainService) {} + +} diff --git a/src/assets/i18n b/src/assets/i18n index d5edf17..3bbb417 160000 --- a/src/assets/i18n +++ b/src/assets/i18n @@ -1 +1 @@ -Subproject commit d5edf1704fe945f71b368a96e573435aa3751b03 +Subproject commit 3bbb417b14004c3231de1eedb2083e171bfdb80a