Permalink
Browse files

feat(assets): add an asset details dialog

  • Loading branch information...
1 parent 8234110 commit b57c154b987513c37ec7386151adc0cdb6d36372 @beregovoy68 beregovoy68 committed Nov 16, 2016
Showing with 91 additions and 1 deletion.
  1. +1 −0 Gruntfile.js
  2. +43 −1 src/index.html
  3. +41 −0 src/js/portfolio/asset.details.controller.js
  4. +6 −0 src/js/portfolio/asset.list.controller.js
View
@@ -156,6 +156,7 @@ module.exports = function (grunt) {
'src/js/portfolio/portfolio.module.js',
'src/js/portfolio/asset.list.controller.js',
'src/js/portfolio/asset.transfer.controller.js',
+ 'src/js/portfolio/asset.details.controller.js',
'src/js/portfolio/asset.filter.js',
'src/js/**/*.spec.js'
View
@@ -463,11 +463,52 @@ <h2 id="AccHeader">{{accounts.caption}}</h2>
<td>
<button ng-click="assetList.assetTransfer(tx.id)">Transfer</button><span class="divider-2"></span>
<button>Reissue</button><span class="divider-2"></span>
- <button>Details</button>
+ <button ng-click="assetList.assetDetails(tx.id)">Details</button>
</td>
</tr>
</tbody>
</table>
+ <div class="noDisp" ng-controller="assetDetailsController as details">
+ <div id="asset-details-dialog" waves-dialog cancel-button-visible="false">
+ <h2>ASSET DETAILS</h2>
+ <table>
+ <tbody>
+ <tr>
+ <td>Issuer address:</td>
+ <td ng-if="!details.isSenderCopiable">{{details.sender}}</td>
+ <td ng-if="details.isSenderCopiable"><span class="clipSpan" tooltipster tooltip-theme="tooltipster-theme1" ngclipboard data-clipboard-text="{{details.sender}}" title="Copy this address to the clipboard." ngclipboard-success="clipboardOk()">{{details.sender}}</span></td>
+ </tr>
+ <tr>
+ <td>Identifier:</td>
+ <td><span class="clipSpan" tooltipster tooltip-theme="tooltipster-theme1" ngclipboard data-clipboard-text="{{details.assetId}}" title="Copy this asset id to the clipboard." ngclipboard-success="clipboardOk()">{{details.assetId}}</span></td>
+ </tr>
+
+ <tr>
+ <td>Name:</td>
+ <td>{{details.name}}</td>
+ </tr>
+ <tr>
+ <td colspan="2">Details:</td>
+ </tr>
+ <tr>
+ <td colspan="2">{{details.description}}</td>
+ </tr>
+ <tr>
+ <td>Total tokens:</td>
+ <td>{{details.totalTokens}}</td>
+ </tr>
+ <tr>
+ <td>Reissuable:</td>
+ <td>{{details.reissuable}}</td>
+ </tr>
+ <tr>
+ <td>Issue date:</td>
+ <td>{{details.timestamp | formatting}}</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
<div ng-controller="assetTransferController as transfer">
<div id="transfer-asset-dialog" waves-dialog ok-button-caption="TRANSFER" on-dialog-ok="transfer.submitTransfer()">
<form id="transfer-asset-form" name="transferAssetForm" novalidate ng-validate="transfer.validationOptions">
@@ -823,6 +864,7 @@ <h2 id="AccHeader">{{accounts.caption}}</h2>
<script src="js/portfolio/portfolio.module.js"></script>
<script src="js/portfolio/asset.list.controller.js"></script>
<script src="js/portfolio/asset.transfer.controller.js"></script>
+ <script src="js/portfolio/asset.details.controller.js"></script>
<script src="js/portfolio/asset.filter.js"></script>
<script src="js/style.js"></script>
@@ -0,0 +1,41 @@
+(function () {
+ 'use strict';
+
+ function WavesAssetDetailsController($scope, events, applicationContext) {
+ var details = this;
+
+ function transformAddress(address) {
+ var result = address;
+
+ if (isMyAddress(result))
+ result = 'You';
+
+ return result;
+ }
+
+ function isMyAddress(address) {
+ return address === applicationContext.account.address;
+ }
+
+ $scope.$on(events.ASSET_SELECTED, function (event, assetId) {
+ var asset = applicationContext.cache.assets[assetId];
+ if (angular.isUndefined(asset))
+ throw new Error('Failed to find asset details by id ' + assetId);
+
+ details.assetId = assetId;
+ details.name = asset.currency.displayName;
+ details.description = asset.description;
+ details.sender = transformAddress(asset.sender);
+ details.isSenderCopiable = !isMyAddress(asset.sender);
+ details.timestamp = asset.timestamp;
+ details.totalTokens = asset.totalTokens.formatAmount();
+ details.reissuable = asset.reissuable ? 'Yes' : 'No';
+ });
+ }
+
+ WavesAssetDetailsController.$inject = ['$scope', 'portfolio.events', 'applicationContext'];
+
+ angular
+ .module('app.portfolio')
+ .controller('assetDetailsController', WavesAssetDetailsController);
+})();
@@ -9,6 +9,7 @@
assetList.assets = [];
assetList.assetTransfer = assetTransfer;
+ assetList.assetDetails = assetDetails;
loadDataFromBackend();
$scope.$on('$destroy', function () {
@@ -31,6 +32,11 @@
dialogService.open('#transfer-asset-dialog');
}
+ function assetDetails(assetId) {
+ $scope.$broadcast(events.ASSET_SELECTED, assetId);
+ dialogService.open('#asset-details-dialog');
+ }
+
function tryToLoadAssetDataFromCache(asset) {
if (angular.isUndefined(applicationContext.cache.assets[asset.id]))
return false;

0 comments on commit b57c154

Please sign in to comment.