浏览代码

add refresh balance button

kunickyd 3 年之前
父节点
当前提交
2e3d81f475
共有 2 个文件被更改,包括 10 次插入1 次删除
  1. 7 1
      src/app/bc-info/bc-info.component.html
  2. 3 0
      src/app/bc-info/bc-info.component.ts

+ 7 - 1
src/app/bc-info/bc-info.component.html

@@ -11,7 +11,13 @@ Data URL: {{bcInfoService.dataUrl}} -->
         <span>
         <span>
             <p><b>User:</b> {{user}}</p>
             <p><b>User:</b> {{user}}</p>
             <p><b>Asset:</b> {{assetId}}</p>
             <p><b>Asset:</b> {{assetId}}</p>
-            <p><b>Balance:</b> {{userBalance}}</p>
+            <p>
+                <b>Balance:</b> {{userBalance}}
+                <button type="button" [disabled]="getUserBalanceInProgress" class="btn btn-secondary btn-sm" (click)="refreshUserBalance()" title="Refresh balance">
+                    <i *ngIf="!getUserBalanceInProgress" class="icon-refresh"></i>             
+                    <span *ngIf="getUserBalanceInProgress" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> 
+                </button>
+            </p>
         </span>
         </span>
         <hr>
         <hr>
         <button *ngIf="!selectingArea" type="button" class="btn btn-primary" (click)="onSelectArea()">Select
         <button *ngIf="!selectingArea" type="button" class="btn btn-primary" (click)="onSelectArea()">Select

+ 3 - 0
src/app/bc-info/bc-info.component.ts

@@ -31,6 +31,7 @@ export class BcInfoComponent implements HsPanelComponent, OnInit {
 
 
   selectingArea: boolean = false;
   selectingArea: boolean = false;
   buyInProgress: boolean = false;
   buyInProgress: boolean = false;
+  getUserBalanceInProgress: boolean = false;
 
 
   user: string = 'kunickyd@test';
   user: string = 'kunickyd@test';
   assetId: string = "coin#test"
   assetId: string = "coin#test"
@@ -62,7 +63,9 @@ export class BcInfoComponent implements HsPanelComponent, OnInit {
   }
   }
 
 
   async refreshUserBalance(): Promise<void>{
   async refreshUserBalance(): Promise<void>{
+    this.getUserBalanceInProgress = true;
     this.userBalance = await this.bcInfoService.getUserBalance(this.user, this.userPrivateKey, this.assetId);
     this.userBalance = await this.bcInfoService.getUserBalance(this.user, this.userPrivateKey, this.assetId);
+    this.getUserBalanceInProgress = false;
   }
   }
 
 
   isVisible(): boolean {
   isVisible(): boolean {