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: [],
bootstrap: [AppComponent,NotFoundComponent]
bootstrap: [AppComponent]
})
export class AppModule { }

View File

@ -7,13 +7,24 @@ import {
import { environment } from '../../../environments/environment';
import { throwError, Observable, BehaviorSubject } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import * as io from 'socket.io-client';
@Injectable({
providedIn: 'root',
})
export class ChartService {
private server = environment.domain;
private socket;
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> {
return this.http
.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() {
var countDownDate = new Date('Aug 1, 2019 00:00:00').getTime();

View File

@ -1,5 +1,16 @@
<div class="view_content py-4">
<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">
<h3 class="mb-0">
<img src="assets/img/block.png" height="30" class="block_rotate float-left mr-2" />
@ -84,7 +95,7 @@
</a>
</div>
<!-- *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="view_moble_tble web_hdng">
<div class="row">
@ -133,7 +144,7 @@
</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="view_moble_tble web_hdng">
<div class="row">
@ -195,7 +206,7 @@
</a>
</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="view_moble_tble web_hdng">
<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>
</div>
</div>
</div>
</div>

View File

@ -2,21 +2,28 @@ import { Component, OnInit } from '@angular/core';
import { HttpParams } from '@angular/common/http';
import { ChartService } from '../../../shared/services/chart.service';
import { ActivatedRoute } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { BlockDetailListComponent } from '../../home/block-detail-list/block-detail-list.component';
@Component({
providers: [BlockDetailListComponent],
selector: 'app-block-detail',
templateUrl: './block-detail.component.html',
styleUrls: ['./block-detail.component.css'],
})
export class BlockDetailComponent implements OnInit {
TimeArr: any;
public hashdata: any;
public hasdata: boolean = true;
public params: any;
public latestblockHeight: any;
constructor(
private route: ActivatedRoute,
private chartService: ChartService,
activate_route: ActivatedRoute,
private titleService: Title,
private latestcomp: BlockDetailListComponent,
) {
activate_route.params.subscribe(val => {
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) {
this.chartService

View File

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