-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display dao contract details in UI (#46)
* Started work on a simple component to show DAO contract details * small fixes on the DAO UI * remove double braces * Added total deposits * Add links fomr constract address and some display some more data Co-authored-by: TheDude <david@vsodir.onmicrosoft.com> Co-authored-by: dangershony <dan.gershony@gmail.com>
- Loading branch information
1 parent
3e644e6
commit e7569b7
Showing
10 changed files
with
233 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/Blockcore.Explorer/ClientApp/src/app/explorer/DaoContract/dao-contract.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<app-search></app-search> | ||
|
||
<div class="box"> | ||
<div *ngIf="daoContract"> | ||
<div class="grid-hash"> | ||
<div> | ||
<span class="grid-hash-left"><i class="fas fa-hashtag"></i></span> | ||
<span class="grid-hash-middle breakable">{{daoContract.contractAddress}}</span> | ||
<span class="grid-hash-right"> | ||
<div class="grid-double"> | ||
</div> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="box"> | ||
|
||
<h3><i class="fas fa-receipt"></i> DAO Contract Details</h3> | ||
|
||
<app-progress class="centered" *ngIf="!daoContract"></app-progress> | ||
<app-error class="centered" [error]="error"></app-error> | ||
|
||
<div class="grid-label-value" *ngIf="daoContract"> | ||
<div *ngIf="daoContract"> | ||
<span>Available amount</span> | ||
<span>{{daoContract.currentAmount | amount}} {{setup.Chain.Symbol}}</span> | ||
</div> | ||
<div *ngIf="daoContract.minVotingDuration"> | ||
<span>Min voting duration</span> | ||
<span>{{daoContract.minVotingDuration}}</span> | ||
</div> | ||
<div *ngIf="daoContract.maxVotingDuration"> | ||
<span>Max voting duration</span> | ||
<span>{{daoContract.maxVotingDuration}}</span> | ||
</div> | ||
<div> | ||
<span>Created on Transaction</span> | ||
<span><a [routerLink]="['../../','contract-transaction', daoContract.contractCreateTransactionId]">{{daoContract.contractCreateTransactionId | slice:0:20}}</a></span> | ||
</div> | ||
<div *ngIf="totalDepositsAmount"> | ||
<span>Total deposits amount</span> | ||
<span>{{totalDepositsAmount | amount}} {{setup.Chain.Symbol}}</span> | ||
</div> | ||
<div *ngIf="totalDepositsAmount"> | ||
<span>Amounts on approved proposals</span> | ||
<span>{{totalAmountOnApprovedProposals | amount}} {{setup.Chain.Symbol}}</span> | ||
</div> | ||
|
||
<div *ngIf="daoContract.error"> | ||
<span>Error</span> | ||
<span>{{daoContract.error}}</span> | ||
</div> | ||
|
||
<div> | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<div class="box"> | ||
<h3>Deposits</h3> | ||
|
||
<div *ngIf="daoContract.deposits" class="left"> | ||
<h3>Deposits</h3> | ||
|
||
<div *ngIf="daoContract.deposits"> | ||
<div class="grid grid-odd-line" *ngFor="let item of daoContract.deposits"> | ||
<span class="address left">{{item.senderAddress}}</span> | ||
<span class="right">{{item.amount | amount}}</span> | ||
<span><a [routerLink]="['../../','contract-transaction', item.transactionId]">{{item.transactionId | slice:0:20}}</a></span> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="box"> | ||
<h3>Proposals</h3> | ||
|
||
<div *ngIf="daoContract.proposals" class="left"> | ||
<div> | ||
<div class="grid grid-odd-line" *ngFor="let item of daoContract.proposals"> | ||
<span class="left">{{item.description}}</span> | ||
<!--<span class="left">Start block: {{item.proposalStartedAtBlock}}</span> | ||
<span class="left">End block: {{item.proposalCompletedAtBlock}}</span>--> | ||
<!--<span><a [routerLink]="['../../','address', item.recipient]">{{item.recipient | slice:0:20}}</a></span>--> | ||
<span><a [routerLink]="['../../','contract-transaction', item.payoutTransactionId]">{{item.payoutTransactionId | slice:0:20}}</a></span> | ||
<span class="right">{{item.amount| amount}}</span> | ||
<span class="centered" *ngIf="!item.wasProposalAccepted">rejected</span> | ||
<span class="centered" *ngIf="item.wasProposalAccepted">accepted</span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> |
65 changes: 65 additions & 0 deletions
65
src/Blockcore.Explorer/ClientApp/src/app/explorer/DaoContract/dao-contract.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import {Component, HostBinding, Input, OnDestroy, OnInit} from "@angular/core"; | ||
import {ApiService} from "../../services/api.service"; | ||
import {ActivatedRoute, Router} from "@angular/router"; | ||
import {SetupService} from "../../services/setup.service"; | ||
|
||
@Component({ | ||
selector: 'app-dao-contract-component', | ||
templateUrl: './dao-contract.component.html' | ||
}) | ||
|
||
export class DaoContractComponent implements OnInit,OnDestroy{ | ||
daoContract: any; | ||
error: null; | ||
totalDepositsAmount:number = 0; | ||
totalAmountOnApprovedProposals:number = 0; | ||
deposits: Map<string, any>; | ||
@HostBinding('class.content-centered-top') private _hostClass = true; | ||
|
||
constructor( | ||
private api: ApiService, | ||
private router: Router, | ||
public setup: SetupService, | ||
private activatedRoute: ActivatedRoute) { | ||
|
||
this.activatedRoute.paramMap.subscribe(async params => { | ||
const address: any = params.get('address'); | ||
console.log('Smart contract address:', address); | ||
|
||
try { | ||
this.daoContract = await this.api.getDaoContractTransaction(address); | ||
|
||
this.totalDepositsAmount = this.daoContract.deposits.map((item)=> Number.parseInt(item.amount)).reduce((acc, curr) => acc + curr, 0); | ||
|
||
this.totalAmountOnApprovedProposals = this.daoContract.proposals.map((item)=> { | ||
Number.parseInt(item.amount) * (item.wasProposalAccepted ? 1 : -1) | ||
}).reduce((acc, curr) => acc + curr, 0); | ||
|
||
// this.daoContract.deposits.forEach((item) => | ||
// { | ||
// if (this.deposits[item.senderAddress] == null) | ||
// { | ||
// this.deposits[item.senderAddress] = new item() | ||
// } | ||
// | ||
// this.deposits[item.senderAddress].amount += item.amount; | ||
// this.deposits[item.senderAddress].transactions += 1; | ||
// | ||
// }) | ||
|
||
this.error = null; | ||
} catch (e) { | ||
this.error = e; | ||
} | ||
|
||
console.log(this.daoContract); | ||
}); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters