|
| 1 | +import { Component, OnInit } from '@angular/core'; |
| 2 | +import { ActivatedRoute, Router } from '@angular/router'; |
| 3 | + |
| 4 | +import { TranslateService } from '@ngx-translate/core'; |
| 5 | + |
| 6 | +import { Transaction } from '../../models/transaction'; |
| 7 | + |
| 8 | +import { ErrorService } from '../../services/error.service'; |
| 9 | +import { NavigatorService } from '../../services/navigator.service'; |
| 10 | +import { BlocksService } from '../../services/blocks.service'; |
| 11 | + |
| 12 | +@Component({ |
| 13 | + selector: 'app-block-raw', |
| 14 | + templateUrl: './block-raw.component.html', |
| 15 | + styleUrls: ['./block-raw.component.css'] |
| 16 | +}) |
| 17 | +export class BlockRawComponent implements OnInit { |
| 18 | + |
| 19 | + block: any; |
| 20 | + |
| 21 | + constructor( |
| 22 | + private route: ActivatedRoute, |
| 23 | + private router: Router, |
| 24 | + private navigatorService: NavigatorService, |
| 25 | + private blocksService: BlocksService, |
| 26 | + private errorService: ErrorService) { } |
| 27 | + |
| 28 | + ngOnInit() { |
| 29 | + this.route.params.forEach(params => this.onBlockQuery(params['query'])); |
| 30 | + } |
| 31 | + |
| 32 | + private onBlockQuery(query: string) { |
| 33 | + this.blocksService.getRaw(query).subscribe( |
| 34 | + response => this.onBlockRetrieved(response), |
| 35 | + response => this.onError(response) |
| 36 | + ); |
| 37 | + } |
| 38 | + |
| 39 | + private onBlockRetrieved(response: any) { |
| 40 | + this.block = response; |
| 41 | + } |
| 42 | + |
| 43 | + private onError(response: any) { |
| 44 | + this.errorService.renderServerErrors(null, response); |
| 45 | + } |
| 46 | +} |
0 commit comments