Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
Change executable name, fix apiError display, wait for Base feature (#…
Browse files Browse the repository at this point in the history
…247)

* Change SidechainD to CirrusD

* Fix apiError display

* Wait until Base feature is loaded to load Core

* Bump version to 1.2.0

* Check response length, unsubscribe on destroy
  • Loading branch information
dev0tion committed Jul 1, 2019
1 parent 60e9c4d commit 9c5cd73
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 22 deletions.
4 changes: 2 additions & 2 deletions StratisCore.UI/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ app.on('ready', () => {
console.log('Stratis UI was started in development mode. This requires the user to be running the Stratis Full Node Daemon himself.')
} else {
if (sidechain && !nodaemon) {
startDaemon('Stratis.SidechainD');
startDaemon('Stratis.CirrusD');
} else if (!nodaemon) {
startDaemon('Stratis.StratisD')
startDaemon('Stratis.StratisD');
}
}
createTray();
Expand Down
2 changes: 1 addition & 1 deletion StratisCore.UI/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stratis-core",
"description": "Stratis Core Wallet",
"version": "1.1.2",
"version": "1.2.0",
"author": {
"name": "Stratis Group Ltd.",
"email": "support@stratisplatform.com"
Expand Down
1 change: 1 addition & 0 deletions StratisCore.UI/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</g>
</svg>
<div class="loadingText mt-4 col-12 text-center">Loading, please wait...</div>
<div *ngIf="apiConnected" class="loadingText col-12 text-center">Connected to the API. Waiting for node to initialize.</div>
</div>
</div>
</div>
Expand Down
17 changes: 15 additions & 2 deletions StratisCore.UI/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ export class AppComponent implements OnInit, OnDestroy {
constructor(private router: Router, private apiService: ApiService, private globalService: GlobalService, private titleService: Title, private electronService: ElectronService) { }

private subscription: Subscription;
private statusIntervalSubscription: Subscription;
private readonly MaxRetryCount = 50;
private readonly TryDelayMilliseconds = 3000;
public sidechainEnabled;
public apiConnected = false;

loading = true;
loadingFailed = false;
Expand All @@ -36,6 +38,7 @@ export class AppComponent implements OnInit, OnDestroy {

ngOnDestroy() {
this.subscription.unsubscribe();
this.statusIntervalSubscription.unsubscribe();
}

// Attempts to initialise the wallet by contacting the daemon. Will try to do this MaxRetryCount times.
Expand All @@ -56,8 +59,18 @@ export class AppComponent implements OnInit, OnDestroy {

this.subscription = stream$.subscribe(
(data: NodeStatus) => {
this.loading = false;
this.router.navigate(['login']);
this.apiConnected = true;
this.statusIntervalSubscription = this.apiService.getNodeStatusInterval(true)
.subscribe(
response => {
const statusResponse = response.featuresData.filter(x => x.namespace === 'Stratis.Bitcoin.Base.BaseFeature');
if (statusResponse.length > 0 && statusResponse[0].state === 'Initialized') {
this.loading = false;
this.statusIntervalSubscription.unsubscribe();
this.router.navigate(['login']);
}
}
);
}, (error: any) => {
console.log('Failed to start wallet');
this.loading = false;
Expand Down
16 changes: 13 additions & 3 deletions StratisCore.UI/src/app/shared/models/node-status.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class NodeStatus {
constructor(agent: string, version: string, network: string, coinTicker: string, processId: number, consensusHeight: number, blockStoreHeight: number, inboundPeers: [Peer],
outbountPeers: [Peer], enabledFeatures: [string], dataDirectoryPath: string, runningtime: string, difficulty: number, protocolVersion: number, testnet: boolean, relayFee: number, state: string) {
outbountPeers: [Peer], featuresData: [featureData], dataDirectoryPath: string, runningtime: string, difficulty: number, protocolVersion: number, testnet: boolean, relayFee: number, state: string) {
this.agent = agent;
this.version = version;
this.network = network;
Expand All @@ -10,7 +10,7 @@ export class NodeStatus {
this.blockStoreHeight = blockStoreHeight;
this.inboundPeers = inboundPeers;
this.outbountPeers = outbountPeers;
this.enabledFeatures = enabledFeatures;
this.featuresData = featuresData;
this.dataDirectoryPath = dataDirectoryPath;
this.runningTime = runningtime;
this.difficulty = difficulty;
Expand All @@ -29,7 +29,7 @@ export class NodeStatus {
public blockStoreHeight: number;
public inboundPeers: [Peer];
public outbountPeers: [Peer];
public enabledFeatures: [string];
public featuresData: [featureData];
public dataDirectoryPath: string;
public runningTime: string;
public difficulty: number;
Expand All @@ -50,3 +50,13 @@ class Peer {
public remoteSocketEndpoint: string;
public tipHeight: number;
}

class featureData {
constructor(namespace: string, state: string) {
this.namespace = namespace;
this.state = state;
}

public namespace: string;
public state: string;
}
4 changes: 2 additions & 2 deletions StratisCore.UI/src/app/shared/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export class ApiService {
);
}

getNodeStatusInterval(): Observable<NodeStatus> {
getNodeStatusInterval(silent?: boolean): Observable<NodeStatus> {
return this.pollingInterval.pipe(
startWith(0),
switchMap(() => this.http.get<NodeStatus>(this.stratisApiUrl + '/node/status')),
catchError(err => this.handleHttpError(err))
catchError(err => this.handleHttpError(err, silent))
)
}

Expand Down
2 changes: 1 addition & 1 deletion StratisCore.UI/src/app/shared/services/global.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class GlobalService {
this.setDaemonIP();
}

private applicationVersion: string = "1.1.2";
private applicationVersion: string = "1.2.0";
private testnet: boolean = false;
private sidechain: boolean = false;
private mainApiPort: number = 37221;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ <h5 class="modal-title">{{title}}</h5>
<p *ngIf="password.errors.required">Please enter the password for wallet {{ walletName }}</p>
</div>
</div>
<div *ngIf="apiError" class="text-danger">{{ apiError }}</div>
</div>

<div *ngIf="apiError" class="text-danger">{{ apiError }}</div>

<div class="modal-footer">
<button type="button" class="btn btn-outline-light" data-dismiss="modal" (click)="closeClicked()">Cancel</button>
<button type="submit" data-toggle="modal" data-target="#" class="btn btn-stratis-green btn-block" data-dismiss="modal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,14 @@ export class TransactionComponent implements OnInit {
},
error => {
this.loading = false;
if (!error.errors) {
if (error.value.message) {
this.apiError = error.value.message;
if (!error.error.errors) {
if (error.error.value.message) {
this.apiError = error.error.value.message;
} else {
console.log(error);
}
else {
console.log(error);
}
}
else {
this.apiError = error.errors[0] .message;
} else {
this.apiError = error.error.errors[0].message;
}
});
}
Expand Down

0 comments on commit 9c5cd73

Please sign in to comment.