Fix missing contents

This commit is contained in:
vijikannan 2019-07-19 11:36:21 +05:30
parent 4dbc40fa6c
commit c600c17f44
5 changed files with 107 additions and 32 deletions

View File

@ -18,6 +18,6 @@ import { NotFoundComponent } from './view/home/not-found/not-found.component';
], ],
providers: [], providers: [],
bootstrap: [AppComponent,NotFoundComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }

View File

@ -7,13 +7,24 @@ import {
import { environment } from '../../../environments/environment'; import { environment } from '../../../environments/environment';
import { throwError, Observable, BehaviorSubject } from 'rxjs'; import { throwError, Observable, BehaviorSubject } from 'rxjs';
import { map, catchError } from 'rxjs/operators'; import { map, catchError } from 'rxjs/operators';
import * as io from 'socket.io-client';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class ChartService { export class ChartService {
private server = environment.domain;
private socket;
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
public createSocketConnection() {
this.socket = io.connect(this.server);
this.socket.on('connect', function(socket) {
console.log('Connected!');
});
}
public apiGetRequest(request: any, reqUrl): Observable<any> { public apiGetRequest(request: any, reqUrl): Observable<any> {
return this.http return this.http
.get(`${environment.apiUrl}` + reqUrl, { .get(`${environment.apiUrl}` + reqUrl, {
@ -27,6 +38,14 @@ export class ChartService {
); );
} }
public getLatestblockdetails() {
return Observable.create(observer => {
this.socket.on('latestblockdetail', response => {
observer.next(response);
});
});
}
public GetTimer() { public GetTimer() {
var countDownDate = new Date('Aug 1, 2019 00:00:00').getTime(); var countDownDate = new Date('Aug 1, 2019 00:00:00').getTime();

View File

@ -1,5 +1,16 @@
<div class="view_content py-4"> <div class="view_content py-4">
<div *ngIf="hasdata" class="container"> <div *ngIf="hasdata" class="container">
<div *ngIf="TimeArr" class="box_shadow_large detail_div p-3 mb-4">
<h1 class="test_msg align-middle mb-0 d-inline-block mr-3 pl-3">You are on Testnet</h1>
<h1 class="test_msg align-middle mb-0 float-right d-inline-block pl-3">Mainnet Countdown
<ul class="list-unstyled d-inline-block mb-0 txt_primary timer">
<li class="d-inline-block"><span id="days">{{TimeArr.d}}d:</span></li>
<li class="d-inline-block"><span id="hours">{{TimeArr.h}}h:</span></li>
<li class="d-inline-block"><span id="minutes">{{TimeArr.m}}m:</span></li>
<li class="d-inline-block"><span id="seconds">{{TimeArr.s}}s</span></li>
</ul>
</h1>
</div>
<div *ngIf="hashdata?.BlockchainBlockFetchQuery" class="box_shadow_large bg-white p-3 mb-4"> <div *ngIf="hashdata?.BlockchainBlockFetchQuery" class="box_shadow_large bg-white p-3 mb-4">
<h3 class="mb-0"> <h3 class="mb-0">
<img src="assets/img/block.png" height="30" class="block_rotate float-left mr-2" /> <img src="assets/img/block.png" height="30" class="block_rotate float-left mr-2" />
@ -84,7 +95,7 @@
</a> </a>
</div> </div>
<!-- *ngIf="hashdata?.BlockchainBlockInputFetchQuery.length" --> <!-- *ngIf="hashdata?.BlockchainBlockInputFetchQuery.length" -->
<div id="collapse-1" class="collapse" data-parent="#accordion" aria-labelledby="heading-1"> <div *ngIf="hashdata?.BlockchainBlockInputFetchQuery" id="collapse-1" class="collapse" data-parent="#accordion" aria-labelledby="heading-1">
<div class="card-body"> <div class="card-body">
<div class="view_moble_tble web_hdng"> <div class="view_moble_tble web_hdng">
<div class="row"> <div class="row">
@ -133,7 +144,7 @@
</div> </div>
<div id="collapse-2" class="collapse" data-parent="#accordion" aria-labelledby="heading-2"> <div *ngIf="hashdata?.BlockchainBlockOutputFetchQuery" id="collapse-2" class="collapse" data-parent="#accordion" aria-labelledby="heading-2">
<div class="card-body"> <div class="card-body">
<div class="view_moble_tble web_hdng"> <div class="view_moble_tble web_hdng">
<div class="row"> <div class="row">
@ -195,7 +206,7 @@
</a> </a>
</div> </div>
<div id="collapse-3" class="collapse" data-parent="#accordion" aria-labelledby="heading-3"> <div *ngIf="hashdata?.BlockchainBlockKernalFetchQuery" id="collapse-3" class="collapse" data-parent="#accordion" aria-labelledby="heading-3">
<div class="card-body"> <div class="card-body">
<div class="view_moble_tble web_hdng"> <div class="view_moble_tble web_hdng">
<div class="row"> <div class="row">
@ -262,4 +273,4 @@
<p>Your search term {{params}} is too short, please enter at least six characters if searching by hash.</p> <p>Your search term {{params}} is too short, please enter at least six characters if searching by hash.</p>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2,21 +2,28 @@ import { Component, OnInit } from '@angular/core';
import { HttpParams } from '@angular/common/http'; import { HttpParams } from '@angular/common/http';
import { ChartService } from '../../../shared/services/chart.service'; import { ChartService } from '../../../shared/services/chart.service';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { BlockDetailListComponent } from '../../home/block-detail-list/block-detail-list.component';
@Component({ @Component({
providers: [BlockDetailListComponent],
selector: 'app-block-detail', selector: 'app-block-detail',
templateUrl: './block-detail.component.html', templateUrl: './block-detail.component.html',
styleUrls: ['./block-detail.component.css'], styleUrls: ['./block-detail.component.css'],
}) })
export class BlockDetailComponent implements OnInit { export class BlockDetailComponent implements OnInit {
TimeArr: any;
public hashdata: any; public hashdata: any;
public hasdata: boolean = true; public hasdata: boolean = true;
public params: any; public params: any;
public latestblockHeight: any;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private chartService: ChartService, private chartService: ChartService,
activate_route: ActivatedRoute, activate_route: ActivatedRoute,
private titleService: Title,
private latestcomp: BlockDetailListComponent,
) { ) {
activate_route.params.subscribe(val => { activate_route.params.subscribe(val => {
this.params = this.route.snapshot.params.hash; this.params = this.route.snapshot.params.hash;
@ -25,7 +32,18 @@ export class BlockDetailComponent implements OnInit {
}); });
} }
ngOnInit() {} ngOnInit() {
var self = this;
var x = setInterval(function() {
self.TimeArr = self.chartService.GetTimer()
? self.chartService.GetTimer()
: false;
}, 1000);
this.titleService.setTitle(this.route.snapshot.data.title);
this.latestcomp.gettinglatesthashList().then(res => {
this.latestblockHeight = this.latestcomp.latestblockdetail.block_height;
});
}
public viewhash(hashid) { public viewhash(hashid) {
this.chartService this.chartService

View File

@ -1,11 +1,10 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ChartService } from '../../../shared/services/chart.service'; import { ChartService } from '../../../shared/services/chart.service';
import { HttpParams } from '@angular/common/http'; import { HttpParams } from '@angular/common/http';
import { import * as io from 'socket.io-client';
HttpClient, import { environment } from '../../../../environments/environment';
HttpErrorResponse, import { BehaviorSubject, Observable, Subject } from 'rxjs';
HttpHeaders,
} from '@angular/common/http';
@Component({ @Component({
selector: 'app-block-detail-list', selector: 'app-block-detail-list',
templateUrl: './block-detail-list.component.html', templateUrl: './block-detail-list.component.html',
@ -13,32 +12,60 @@ import {
}) })
export class BlockDetailListComponent implements OnInit { export class BlockDetailListComponent implements OnInit {
public latestblockdetail: any = []; public latestblockdetail: any = [];
public prevouslatestblockdetails: any = [];
constructor(private chartService: ChartService, private http: HttpClient) {} public latestblockdetailObservable: any;
private server = environment.domain;
private socket;
constructor(private chartService: ChartService) {
this.chartService.createSocketConnection();
}
ngOnInit() { ngOnInit() {
this.gettinglatesthashList(); this.gettinglatesthashList();
this.getBlockDetails();
// this.http
// .get('http://localhost:4000/api/test/ok')
// // .get('/api/courses/01.json')
// .subscribe(data => {
// console.log(data);
// });
} }
getBlockDetails() {
this.latestblockdetailObservable = this.chartService
.getLatestblockdetails()
.subscribe(response => {
this.prevouslatestblockdetails = this.latestblockdetail;
this.latestblockdetail = response;
if (
this.prevouslatestblockdetails.block_height !=
this.latestblockdetail.block_height
) {
this.latestblockdetail['blink'] = true;
} else {
this.latestblockdetail['blink'] = false;
}
//console.log(this.latestblockdetail);
});
}
public gettinglatesthashList() { public gettinglatesthashList() {
this.chartService return new Promise((resolve, reject) => {
.apiGetRequest('', '/blockchain_block/latesblockdetails') this.chartService
.subscribe( .apiGetRequest('', '/blockchain_block/latesblockdetails')
res => { .subscribe(
if (res['status'] == 200) { res => {
// var hasharray = res.response; if (res['status'] == 200) {
this.latestblockdetail = res.response; // var hasharray = res.response;
} this.latestblockdetail = res.response;
}, this.latestblockdetail['blink'] = false;
error => {}, resolve();
); }
},
error => {},
);
});
}
ngOnDestroy() {
this.latestblockdetailObservable
? this.latestblockdetailObservable.unsubscribe()
: null;
} }
} }