diff --git a/web-ui/src/app/app-routing.module.ts b/web-ui/src/app/app-routing.module.ts index 427d753..b3f535e 100644 --- a/web-ui/src/app/app-routing.module.ts +++ b/web-ui/src/app/app-routing.module.ts @@ -4,13 +4,13 @@ import { Routes, RouterModule } from '@angular/router'; import { HomeComponent } from './components/home/home.component'; import { TransactionComponent } from './components/transaction/transaction.component'; import { AddressDetailsComponent } from './components/address-details/address-details.component'; -import { BlockDetailsComponent } from './components/block-details/block-details.component'; +import { BlockComponent } from './components/block/block.component'; import { MasternodeDetailsComponent } from './components/masternode-details/masternode-details.component'; const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'addresses/:address', component: AddressDetailsComponent }, - { path: 'blocks/:blockhash', component: BlockDetailsComponent }, + { path: 'blocks/:query', component: BlockComponent }, { path: 'transactions/:txid', component: TransactionComponent }, { path: 'masternodes/:ip', component: MasternodeDetailsComponent }, { path: '**', redirectTo: '' } diff --git a/web-ui/src/app/app.module.ts b/web-ui/src/app/app.module.ts index 8ed157a..7d4f693 100644 --- a/web-ui/src/app/app.module.ts +++ b/web-ui/src/app/app.module.ts @@ -42,6 +42,8 @@ import { MasternodesComponent } from './components/masternodes/masternodes.compo import { MasternodeDetailsComponent } from './components/masternode-details/masternode-details.component'; import { TransactionRawComponent } from './components/transaction-raw/transaction-raw.component'; import { TransactionComponent } from './components/transaction/transaction.component'; +import { BlockComponent } from './components/block/block.component'; +import { BlockRawComponent } from './components/block-raw/block-raw.component'; @NgModule({ declarations: [ @@ -59,7 +61,9 @@ import { TransactionComponent } from './components/transaction/transaction.compo MasternodesComponent, MasternodeDetailsComponent, TransactionRawComponent, - TransactionComponent + TransactionComponent, + BlockComponent, + BlockRawComponent ], imports: [ AppRoutingModule, diff --git a/web-ui/src/app/components/block-details/block-details.component.ts b/web-ui/src/app/components/block-details/block-details.component.ts index 348e72f..ad79a56 100644 --- a/web-ui/src/app/components/block-details/block-details.component.ts +++ b/web-ui/src/app/components/block-details/block-details.component.ts @@ -26,7 +26,7 @@ export class BlockDetailsComponent implements OnInit { private errorService: ErrorService) { } ngOnInit() { - this.route.params.forEach(params => this.onBlockhash(params['blockhash'])); + this.route.params.forEach(params => this.onBlockhash(params['query'])); } private onBlockhash(blockhash: string) { diff --git a/web-ui/src/app/components/block-raw/block-raw.component.css b/web-ui/src/app/components/block-raw/block-raw.component.css new file mode 100644 index 0000000..e69de29 diff --git a/web-ui/src/app/components/block-raw/block-raw.component.html b/web-ui/src/app/components/block-raw/block-raw.component.html new file mode 100644 index 0000000..a484b7e --- /dev/null +++ b/web-ui/src/app/components/block-raw/block-raw.component.html @@ -0,0 +1,8 @@ +
+
+ {{'message.blockNotFound' | translate}} +
+
+
{{block | json}}
+
+
diff --git a/web-ui/src/app/components/block-raw/block-raw.component.spec.ts b/web-ui/src/app/components/block-raw/block-raw.component.spec.ts new file mode 100644 index 0000000..623118b --- /dev/null +++ b/web-ui/src/app/components/block-raw/block-raw.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BlockRawComponent } from './block-raw.component'; + +describe('BlockRawComponent', () => { + let component: BlockRawComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ BlockRawComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(BlockRawComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/web-ui/src/app/components/block-raw/block-raw.component.ts b/web-ui/src/app/components/block-raw/block-raw.component.ts new file mode 100644 index 0000000..7f97862 --- /dev/null +++ b/web-ui/src/app/components/block-raw/block-raw.component.ts @@ -0,0 +1,46 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +import { TranslateService } from '@ngx-translate/core'; + +import { Transaction } from '../../models/transaction'; + +import { ErrorService } from '../../services/error.service'; +import { NavigatorService } from '../../services/navigator.service'; +import { BlocksService } from '../../services/blocks.service'; + +@Component({ + selector: 'app-block-raw', + templateUrl: './block-raw.component.html', + styleUrls: ['./block-raw.component.css'] +}) +export class BlockRawComponent implements OnInit { + + block: any; + + constructor( + private route: ActivatedRoute, + private router: Router, + private navigatorService: NavigatorService, + private blocksService: BlocksService, + private errorService: ErrorService) { } + + ngOnInit() { + this.route.params.forEach(params => this.onBlockQuery(params['query'])); + } + + private onBlockQuery(query: string) { + this.blocksService.getRaw(query).subscribe( + response => this.onBlockRetrieved(response), + response => this.onError(response) + ); + } + + private onBlockRetrieved(response: any) { + this.block = response; + } + + private onError(response: any) { + this.errorService.renderServerErrors(null, response); + } +} diff --git a/web-ui/src/app/components/block/block.component.css b/web-ui/src/app/components/block/block.component.css new file mode 100644 index 0000000..e69de29 diff --git a/web-ui/src/app/components/block/block.component.html b/web-ui/src/app/components/block/block.component.html new file mode 100644 index 0000000..2407ec7 --- /dev/null +++ b/web-ui/src/app/components/block/block.component.html @@ -0,0 +1,10 @@ +
+ + + + + + + + +
diff --git a/web-ui/src/app/components/block/block.component.spec.ts b/web-ui/src/app/components/block/block.component.spec.ts new file mode 100644 index 0000000..cdd4437 --- /dev/null +++ b/web-ui/src/app/components/block/block.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BlockComponent } from './block.component'; + +describe('BlockComponent', () => { + let component: BlockComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ BlockComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(BlockComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/web-ui/src/app/components/block/block.component.ts b/web-ui/src/app/components/block/block.component.ts new file mode 100644 index 0000000..95347d8 --- /dev/null +++ b/web-ui/src/app/components/block/block.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-block', + templateUrl: './block.component.html', + styleUrls: ['./block.component.css'] +}) +export class BlockComponent implements OnInit { + + currentView = 'details'; + + constructor() { } + + ngOnInit() { + } + + selectView(view: string) { + this.currentView = view; + } + + isSelected(view: string): boolean { + return this.currentView === view; + } +} diff --git a/web-ui/src/app/services/blocks.service.ts b/web-ui/src/app/services/blocks.service.ts index 99425c7..327227c 100644 --- a/web-ui/src/app/services/blocks.service.ts +++ b/web-ui/src/app/services/blocks.service.ts @@ -22,6 +22,11 @@ export class BlocksService { return this.http.get(url); } + getRaw(query: string): Observable { + const url = `${this.baseUrl}/${query}/raw`; + return this.http.get(url); + } + getLatest(): Observable { return this.http.get(this.baseUrl); }