Alexis Hernandez
7 years ago
12 changed files with 151 additions and 4 deletions
@ -0,0 +1,8 @@ |
|||||
|
<div> |
||||
|
<div [hidden]="block != null"> |
||||
|
<alert>{{'message.blockNotFound' | translate}}</alert> |
||||
|
</div> |
||||
|
<div *ngIf="block != null"> |
||||
|
<pre>{{block | json}}</pre> |
||||
|
</div> |
||||
|
</div> |
@ -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<BlockRawComponent>; |
||||
|
|
||||
|
beforeEach(async(() => { |
||||
|
TestBed.configureTestingModule({ |
||||
|
declarations: [ BlockRawComponent ] |
||||
|
}) |
||||
|
.compileComponents(); |
||||
|
})); |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
fixture = TestBed.createComponent(BlockRawComponent); |
||||
|
component = fixture.componentInstance; |
||||
|
fixture.detectChanges(); |
||||
|
}); |
||||
|
|
||||
|
it('should create', () => { |
||||
|
expect(component).toBeTruthy(); |
||||
|
}); |
||||
|
}); |
@ -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); |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
<div> |
||||
|
<tabset class="col-xs-12 col-sm-12 col-md-12 col-xs-12"> |
||||
|
<tab heading="{{'label.details' | translate}}" (select)="selectView('details')"> |
||||
|
<app-block-details *ngIf="isSelected('details')"></app-block-details> |
||||
|
</tab> |
||||
|
<tab heading="{{'label.raw' | translate}}" (select)="selectView('raw')"> |
||||
|
<app-block-raw *ngIf="isSelected('raw')"></app-block-raw> |
||||
|
</tab> |
||||
|
</tabset> |
||||
|
</div> |
@ -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<BlockComponent>; |
||||
|
|
||||
|
beforeEach(async(() => { |
||||
|
TestBed.configureTestingModule({ |
||||
|
declarations: [ BlockComponent ] |
||||
|
}) |
||||
|
.compileComponents(); |
||||
|
})); |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
fixture = TestBed.createComponent(BlockComponent); |
||||
|
component = fixture.componentInstance; |
||||
|
fixture.detectChanges(); |
||||
|
}); |
||||
|
|
||||
|
it('should create', () => { |
||||
|
expect(component).toBeTruthy(); |
||||
|
}); |
||||
|
}); |
@ -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; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue