Skip to content

Commit

Permalink
Merge pull request #8 from letheanVPN/6-bootstate-do-quick-check-at-s…
Browse files Browse the repository at this point in the history
…tep-one

adds file download progress bar on step 3 of bootstate check.
  • Loading branch information
Snider authored Apr 28, 2022
2 parents 312d292 + f193283 commit 2552f22
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/app/modules/status/bootstate/bootstate.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
<lthn-login></lthn-login>
</div>
</div>
<div *ngIf="step.title == 'app.boot.download-check'"><p>Checking for updates.</p>
<div *ngIf="step.title == 'app.boot.download-check'">
<div *ngIf="downloadNeeded"><h3>Downloading Blockchain Binaries</h3>
<ngx-progress-spinner
mode="indeterminate"

appearance="icon"
></ngx-progress-spinner></div>
Downloaded: {{downloadStats.total | number}}
Of {{downloadStats.size | number}}
<mat-progress-bar mode="determinate" color="accent" [value]="downloadStats.total/downloadStats.size*100" ></mat-progress-bar></div>
</div>
<div *ngIf="step.title == 'app.boot.start-runtime'"><p>Everything looks ok, starting.</p></div>
</ng-template>
Expand Down
26 changes: 24 additions & 2 deletions src/app/modules/status/bootstate/bootstate.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {AppConfigService} from '@service/app-config.service';
import {FileSystemService} from '@service/filesystem/file-system.service';
import {BlockchainService} from '@module/chain/blockchain.service';
import {interval, Subscription} from 'rxjs';
import {WebsocketService} from '@service/websocket.service';

@Component({
selector: 'lthn-app-bootstate',
Expand All @@ -13,6 +14,14 @@ import {interval, Subscription} from 'rxjs';
export class BootstateComponent implements OnInit {

readonly StepperPosition = StepperPosition;

downloadStats: {
file: string,
dir: string,
fullPath: string,
size: number,
total: number,
}
readonly steps: Array<{ readonly title: string; readonly icon?: string; readonly completeIcon?: string }> = [
{title: 'app.boot.server-check', icon: 'ngx-icon ngx-server'},
{title: 'app.boot.folder-check', icon: 'ngx-icon ngx-folder'},
Expand All @@ -28,7 +37,7 @@ export class BootstateComponent implements OnInit {
downloaded: Subscription;
serverCheck: Subscription;

constructor(private app: AppConfigService, private fs: FileSystemService, private chain: BlockchainService) {
constructor(private app: AppConfigService, private fs: FileSystemService, private chain: BlockchainService, private ws: WebsocketService) {
}

async ngOnInit() {
Expand Down Expand Up @@ -64,7 +73,7 @@ export class BootstateComponent implements OnInit {
await this.app.loadConfig('conf/app.ini');
await this.initApp()
} catch (e) {
return false;
//return false;
}
this.next();
this.serverCheck.unsubscribe()
Expand Down Expand Up @@ -108,6 +117,7 @@ export class BootstateComponent implements OnInit {

async checkDownloads() {

this.downloadProgress()
try {

if (await this.fs.listFiles('cli').then(res => res.length) < 3) {
Expand Down Expand Up @@ -148,5 +158,17 @@ export class BootstateComponent implements OnInit {
return await this.fs.listFiles('cli').then(res => res.length) > 3;

}

downloadProgress(){
let that = this;
const subject = this.ws.connect().subscribe((data) => {
that.downloadStats = JSON.parse(atob(data[1]));
if(this.downloadStats.total == this.downloadStats.size){
subject.unsubscribe();
}
})
this.ws.sendMessage('daemon:download')

}
}

4 changes: 3 additions & 1 deletion src/app/modules/status/status.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BootstateComponent } from './bootstate/bootstate.component';
import {ProgressSpinnerModule, SectionModule, StepperModule} from '@swimlane/ngx-ui';
import {TranslateModule} from '@ngx-translate/core';
import {AuthModule} from '@module/auth/auth.module';
import {MatProgressBarModule} from '@angular/material/progress-bar';

@NgModule({
declarations: [StatusComponent, NoDaemonRunningDialog, BootstateComponent],
Expand All @@ -26,7 +27,8 @@ import {AuthModule} from '@module/auth/auth.module';
StepperModule,
TranslateModule,
AuthModule,
ProgressSpinnerModule
ProgressSpinnerModule,
MatProgressBarModule
]
})
export class StatusModule {
Expand Down

0 comments on commit 2552f22

Please sign in to comment.