9 Commits 88fe1fed4c ... 16c7a6204a

Tác giả SHA1 Thông báo Ngày
  kunickyd 16c7a6204a set to public service 3 năm trước cách đây
  kunickyd d46d18c693 more decimal places for extent coords 3 năm trước cách đây
  kunickyd be199215c6 styling 3 năm trước cách đây
  kunickyd cdd0691520 change date format 3 năm trước cách đây
  kunickyd d948e9fafe stop loading indication during error 3 năm trước cách đây
  kunickyd 06dcd63bf1 styling 3 năm trước cách đây
  kunickyd fd775d6c4a configure iroha proxy 3 năm trước cách đây
  kunickyd 445b9c0986 add user binding & load data indication 3 năm trước cách đây
  kunickyd 2fd3804b1f format date 3 năm trước cách đây

+ 5 - 4
src/app/bc-info/bc-info.component.html

@@ -23,7 +23,7 @@ Data URL: {{bcInfoService.dataUrl}} -->
             </p>
         </span>
         <hr>
-        <button *ngIf="!selectingArea" type="button" class="btn btn-primary" (click)="onSelectArea()">Select
+        <button style="margin-bottom: 5px;" *ngIf="!selectingArea" type="button" class="btn btn-primary" (click)="onSelectArea()">Select
             area</button>
 
         <div *ngIf="selectingArea">
@@ -32,7 +32,7 @@ Data URL: {{bcInfoService.dataUrl}} -->
                 <p><b>Price:</b> {{price}}</p>
             </span>
             <p *ngIf="paymentHash"><b>Payment hash:</b> {{paymentHash}}</p>
-            <div>
+            <div style="margin-bottom: 5px;">
                 <button type="button" [disabled]="!price || buyInProgress" class="btn btn-success" (click)="onBuy()">
                     <span *ngIf="buyInProgress" class="spinner-border spinner-border-sm" role="status"></span>
                     Buy
@@ -42,9 +42,9 @@ Data URL: {{bcInfoService.dataUrl}} -->
                 <a *ngIf="dataUrl" class="btn btn-primary" [href]="dataUrl">Download your data!</a>
             </div>
         </div>
-
+        <hr>
         <div>
-            <p>Purchase history</p>
+            <h5>Purchase history</h5>
             <div>
                 <purchase                    
                     *ngFor="let purchase of lastPurchases; index as i"
@@ -52,6 +52,7 @@ Data URL: {{bcInfoService.dataUrl}} -->
                     [amount]="purchase.amount"
                     [extent]="purchase.extent"
                     [timestamp]="purchase.timestamp"
+                    [user]="user"
                 ></purchase>
             </div>
     </div>

+ 30 - 17
src/app/bc-info/bc-info.component.ts

@@ -68,9 +68,15 @@ export class BcInfoComponent implements HsPanelComponent, OnInit {
   }
 
   async refreshUserBalance(): Promise<void> {
-    this.getUserBalanceInProgress = true;
-    this.userBalance = await this.bcInfoService.getUserBalance(this.user, this.userPrivateKey, this.assetId);
-    this.getUserBalanceInProgress = false;
+    try {
+      this.getUserBalanceInProgress = true;
+      this.userBalance = await this.bcInfoService.getUserBalance(this.user, this.userPrivateKey, this.assetId);
+      this.getUserBalanceInProgress = false;
+    }
+    catch (err) {
+      this.getUserBalanceInProgress = false;
+      throw err;
+    }
   }
 
   async refreshPurchaseHistory(): Promise<void> {
@@ -93,26 +99,33 @@ export class BcInfoComponent implements HsPanelComponent, OnInit {
   }
 
   async onBuy(): Promise<void> {
-    if (!confirm("You sure?")) {
-      return;
-    }
+    try {
+      if (!confirm("You sure?")) {
+        return;
+      }
 
-    this.buyInProgress = true;
+      this.buyInProgress = true;
 
-    let transformedExtent = transformExtent(this.extent, this.mapService.getMap().getView().getProjection(), "EPSG:4326");
-    transformedExtent = this.roundExtentCoords(transformedExtent);
-    //console.log(transformedExtent);
+      let transformedExtent = transformExtent(this.extent, this.mapService.getMap().getView().getProjection(), "EPSG:4326");      
+      transformedExtent = this.roundExtentCoords(transformedExtent);
+      //console.log(transformedExtent);
 
-    this.paymentHash = await this.bcInfoService.transferAssets(this.user, this.userPrivateKey, this.assetId, transformedExtent, this.price);
+      this.paymentHash = await this.bcInfoService.transferAssets(this.user, this.userPrivateKey, this.assetId, transformedExtent, this.price);
 
-    await this.bcInfoService.archiveTransfer(this.user, this.price, this.paymentHash, transformedExtent, Date.now());
+      await this.bcInfoService.archiveTransfer(this.user, this.price, this.paymentHash, transformedExtent, Date.now());
 
-    this.refreshPurchaseHistory();
-    this.refreshUserBalance();
+      this.refreshPurchaseHistory();
+      this.refreshUserBalance();
+
+      this.dataUrl = await this.bcInfoService.requestData(this.paymentHash, this.user);//"https://eo.lesprojekt.cz/produkty/S2/2020/S2A_MSIL2A_20200422T095031_N9999_R079_T33UXQ_20201127T165009_NDVI.tif"
 
-    this.dataUrl = await this.bcInfoService.requestData(this.paymentHash, this.user);//"https://eo.lesprojekt.cz/produkty/S2/2020/S2A_MSIL2A_20200422T095031_N9999_R079_T33UXQ_20201127T165009_NDVI.tif"
+      this.buyInProgress = false;
+    }
+    catch (err) {
+      this.buyInProgress = false;
+      throw err;
+    }
 
-    this.buyInProgress = false;
   }
 
   onCancel(): void {
@@ -153,7 +166,7 @@ export class BcInfoComponent implements HsPanelComponent, OnInit {
     let roundedExtent: number[] = new Array<number>(4);
 
     for (let i = 0; i !== extent.length; i++) {
-      roundedExtent[i] = this.roundTwoDecimalPlaces(extent[i]);
+      roundedExtent[i] = Math.round((extent[i] + Number.EPSILON) * 1000000) / 1000000;
     }
 
     return roundedExtent;

+ 3 - 2
src/app/bc-info/purchase/purchase.component.html

@@ -1,10 +1,11 @@
 <div class="card">
 
     <div class="card-header">
-        <small>{{timestamp}}</small>
+        <small>{{timestamp | date:"dd.MM.yyyy HH:mm:ss"}}</small>
         <span style="float: right;">                            
-            <button style="margin-right: 5px" class="btn btn-secondary btn-sm" (click)="onRequestData()">
+            <button [disabled]="loadingData" style="margin-right: 5px" class="btn btn-secondary btn-sm" (click)="onRequestData()">
                 Data
+                <span *ngIf="loadingData" class="spinner-border spinner-border-sm" role="status"></span>
             </button>
             <button style="margin-right: 5px" class="btn btn-sm" (click)="expanded = !expanded">
                 <i [class]="expanded ? 'icon-arrow-up' : 'icon-arrow-down'"></i>

+ 15 - 5
src/app/bc-info/purchase/purchase.component.ts

@@ -11,16 +11,26 @@ export class Purchase {
     @Input() timestamp: string;
     @Input() extent: Extent;
     @Input() amount: number;
+    @Input() user: string;
 
     expanded: boolean = false;
     loadingData: boolean = false;
 
-    constructor(bcInfoService: BcInfoService) {
-
-    }
+    constructor(private bcInfoService: BcInfoService) {}
 
+    async onRequestData(): Promise<void> {
+        try{
+            this.loadingData = true;
 
-    onRequestData() {
-        window.open("https://eo.lesprojekt.cz/produkty/S2/2020/S2A_MSIL2A_20200422T095031_N9999_R079_T33UXQ_20201127T165009_NDVI.tif");
+            let dataUrl = await this.bcInfoService.requestData(this.hash, this.user);
+            window.open(dataUrl);
+            
+            this.loadingData = false;
+        }
+        catch(err){
+            this.loadingData = false;
+            throw err;
+        }
+        
     }
 }

+ 2 - 2
src/assets/config.json

@@ -1,6 +1,6 @@
 {
-    "CHAIN4ALL_SERVICE_URL": "http://localhost:3000",
-    "IROHA_ADDRESS": "http://10.0.0.156:8080",
+    "CHAIN4ALL_SERVICE_URL": "https://chain4all.lesprojekt.cz",
+    "IROHA_ADDRESS": "https://chain4all.lesprojekt.cz/iroha",
     "ASSET": "coin#test",
     "ADMIN_USER": "admin@test"
 }