From 09fccd3bcccf7f2842cb3dcb17f965cafacc2bde Mon Sep 17 00:00:00 2001 From: Klas <31806893+klassare@users.noreply.github.com> Date: Sun, 23 Sep 2018 19:14:29 +0200 Subject: [PATCH] Staging (#10) * topbar * offline signing option * decode signed operation hash UI * fix new data structure * update api for operations * Account table re-adjusted * set up zeronet * minor changes * delegator pipe update * truncatePipe * time-ago pipe * tooltips for app-activity * add class for constants * switch to betanet * update betanet chain_id * ActivityComponent revamped * fix signed decoding * move online signing warning * tweak row padding * minor UI fix * minor fix * small change buttons * context-menu for electron * fix TypeError at Menu.popup * allow to unset delegate in integrity check * code cleanup * change walletService to public in home-page * delegate UI fix * minor text changes * minor spelling * spelling * test of TranslateService * fix account import bug * update to betanet * test code transferred to homePage and Language button * homePageComponent and startComponent translated into fr * 3 more components translated * ru and jp json completed * 6 components translated * finishing translation * translation completed * fix electron issue * update css for home-page component * fix start component height * lifecycle hook for 'Show help' btn * top-bar-btn vertical aligned * translation text * update for zeronet * first send modal modified * update operation service for multiple transactions * send modals 90% completed * Fix Show More btn * Show More btn in activityComponent * more btn * added portuguese * jp updated * Fee input added * korean language added * minor change * version number * fix translation race condition * add support for multi-send in account * add alphanet * add total fee for multi-send * randomize api server * fix some translation race errors * fix operations from api * fix css heights --- package-lock.json | 18 +- package.json | 12 +- src/app/app.component.html | 2 +- src/app/app.component.ts | 27 +- src/app/app.module.ts | 24 +- .../components/account/account.component.html | 11 +- .../activate/activate.component.html | 14 +- .../activity/activity.component.html | 43 ++- .../activity/activity.component.scss | 19 + .../components/activity/activity.component.ts | 29 +- .../components/backup/backup.component.html | 37 +- .../components/bakery/bakery.component.html | 19 +- .../delegate/delegate.component.html | 36 +- .../home-page/home-page.component.html | 129 ++++++- .../home-page/home-page.component.scss | 59 ++- .../home-page/home-page.component.ts | 56 ++- .../components/import/import.component.html | 20 +- src/app/components/import/import.component.ts | 35 +- .../mnemonic-import.component.html | 58 +-- .../mnemonic-import.component.scss | 2 +- .../mnemonic-import.component.ts | 46 ++- .../new-account/new-account.component.html | 41 +-- .../new-account/new-account.component.ts | 24 +- .../new-wallet/new-wallet.component.html | 74 ++-- .../new-wallet/new-wallet.component.scss | 9 +- .../offline-signing.component.html | 77 ++-- .../offline-signing.component.scss | 4 +- .../offline-signing.component.ts | 85 +++-- .../overview/overview.component.html | 37 +- .../overview/overview.component.scss | 8 + .../components/overview/overview.component.ts | 11 +- .../components/receive/receive.component.html | 8 +- src/app/components/send/send.component.html | 147 +++++--- src/app/components/send/send.component.scss | 17 + src/app/components/send/send.component.ts | 197 +++++++++- src/app/components/start/start.component.html | 6 +- src/app/components/start/start.component.scss | 2 +- src/app/constants.ts | 27 +- src/app/pipes/time-ago.pipe.ts | 89 ++++- src/app/services/activity.service.ts | 21 +- src/app/services/balance.service.ts | 11 +- src/app/services/coordinator.service.ts | 21 +- src/app/services/operation.service.ts | 96 +++-- src/app/services/tzscan.service.ts | 95 ++--- src/app/services/wallet.service.ts | 3 + src/assets/i18n/en.json | 331 +++++++++++++++++ src/assets/i18n/fr.json | 331 +++++++++++++++++ src/assets/i18n/jp.json | 331 +++++++++++++++++ src/assets/i18n/kor.json | 335 ++++++++++++++++++ src/assets/i18n/por.json | 329 +++++++++++++++++ src/assets/i18n/ru.json | 331 +++++++++++++++++ src/assets/i18n/template.json | 79 +++++ src/electron/package.json | 2 +- 53 files changed, 3384 insertions(+), 491 deletions(-) create mode 100644 src/assets/i18n/en.json create mode 100644 src/assets/i18n/fr.json create mode 100644 src/assets/i18n/jp.json create mode 100644 src/assets/i18n/kor.json create mode 100644 src/assets/i18n/por.json create mode 100644 src/assets/i18n/ru.json create mode 100644 src/assets/i18n/template.json diff --git a/package-lock.json b/package-lock.json index 7ee716777..cbe532510 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "kukai", - "version": "1.0.4", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -236,6 +236,16 @@ "webpack-sources": "1.1.0" } }, + "@ngx-translate/core": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@ngx-translate/core/-/core-9.1.1.tgz", + "integrity": "sha1-rhA5KINrip4Gn9Li52+iGYzH5ig=" + }, + "@ngx-translate/http-loader": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@ngx-translate/http-loader/-/http-loader-2.0.1.tgz", + "integrity": "sha1-qmd4jmS/qGUmkad7Ais7QDEgkRM=" + }, "@schematics/angular": { "version": "0.1.17", "resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-0.1.17.tgz", @@ -1997,6 +2007,12 @@ "wrap-ansi": "2.1.0" } }, + "cloc": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/cloc/-/cloc-2.3.3.tgz", + "integrity": "sha1-rL1ndlnZun9n9iaar+q3JxVNf9g=", + "dev": true + }, "clone": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", diff --git a/package.json b/package.json index 081376263..ccc8a3bb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kukai", - "version": "1.1.0", + "version": "1.2.0", "license": "MIT", "scripts": { "ng": "ng", @@ -19,7 +19,8 @@ "package-electron-linux-ia32": "electron-packager dist --overwrite --asar --platform=linux --arch=ia32 --icon=dist/assets/icons/png/1024x1024.png --prune=true --out=release-builds", "package-electron-linux-x64": "electron-packager dist --overwrite --asar --platform=linux --arch=x64 --icon=dist/assets/icons/png/1024x1024.png --prune=true --out=release-builds", "package-electron-all": "npm run build-electron && npm run package-electron-win && npm run package-electron-mac && npm run package-electron-linux", - "run-electron": "npm run build-electron && electron dist" + "run-electron": "npm run build-electron && electron dist", + "count": "cloc app/" }, "private": true, "dependencies": { @@ -33,6 +34,8 @@ "@angular/platform-browser-dynamic": "^5.2.0", "@angular/router": "^5.2.0", "@ng-bootstrap/ng-bootstrap": "^1.0.1", + "@ngx-translate/core": "9.1.1", + "@ngx-translate/http-loader": "2.0.1", "@types/crypto-js": "^3.1.39", "aes-js": "^3.1.1", "angular-cli-ghpages": "^0.5.2", @@ -65,9 +68,11 @@ "@types/jasmine": "~2.8.3", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", + "cloc": "^2.3.3", "codelyzer": "^4.0.1", "electron": "^2.0.4", "electron-packager": "^12.1.0", + "font-awesome": "^4.7.0", "jasmine-core": "~2.8.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~2.0.0", @@ -78,7 +83,6 @@ "protractor": "~5.1.2", "ts-node": "~4.1.0", "tslint": "~5.9.1", - "typescript": "~2.5.3", - "font-awesome": "^4.7.0" + "typescript": "~2.5.3" } } diff --git a/src/app/app.component.html b/src/app/app.component.html index 71bda04ef..b010bf29a 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8bd549dec..317ccf5f7 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,21 +1,26 @@ import { Component, OnInit } from '@angular/core'; + import { WalletService } from './services/wallet.service'; import { CoordinatorService } from './services/coordinator.service'; +import { TranslateService } from '@ngx-translate/core'; @Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'] + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.scss'] }) export class AppComponent implements OnInit { - constructor( - private walletService: WalletService, - private coordinatorService: CoordinatorService) { } - ngOnInit() { - this.walletService.loadStoredWallet(); - if (this.walletService.wallet) { - this.coordinatorService.startAll(); + constructor( + private walletService: WalletService, + private coordinatorService: CoordinatorService + ) { } + + ngOnInit() { + this.walletService.loadStoredWallet(); + + if (this.walletService.wallet) { + this.coordinatorService.startAll(); + } } - } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index e7513fa7c..911bb1d6b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,14 +1,19 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { HttpClientModule } from '@angular/common/http'; +import { HttpClientModule, HttpClient } from '@angular/common/http'; import { AppRoutingModule } from './app-routing.module'; import { BsModalService } from 'ngx-bootstrap/modal'; +// For translation +import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; +import {TranslateHttpLoader} from '@ngx-translate/http-loader'; + // External libraries import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader/component-loader.factory'; import { ModalModule, AlertModule, ProgressbarModule, ButtonsModule, BsDropdownModule, TabsModule } from 'ngx-bootstrap'; +import { CollapseModule } from 'ngx-bootstrap/collapse'; import { AppComponent } from './app.component'; @@ -52,6 +57,13 @@ import { DelegatorNamePipe } from './pipes/delegator-name.pipe'; import { TruncatePipe } from './pipes/truncate.pipe'; import { TimeAgoPipe } from './pipes/time-ago.pipe'; +// AoT requires an exported function for factories +export function HttpLoaderFactory(http: HttpClient) { + return new TranslateHttpLoader(http, './assets/i18n/', '.json'); +} + + + @NgModule({ declarations: [ AppComponent, @@ -87,12 +99,20 @@ import { TimeAgoPipe } from './pipes/time-ago.pipe'; AppRoutingModule, HttpClientModule, NgbModule.forRoot(), + CollapseModule.forRoot(), ModalModule.forRoot(), AlertModule.forRoot(), ProgressbarModule.forRoot(), ButtonsModule.forRoot(), BsDropdownModule.forRoot(), - TabsModule.forRoot() + TabsModule.forRoot(), + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }) // lazy loading will need TranslateModule.forChild() in the lazy loaded modules ], providers: [ // Services diff --git a/src/app/components/account/account.component.html b/src/app/components/account/account.component.html index 7733d80fe..91b4ac29b 100644 --- a/src/app/components/account/account.component.html +++ b/src/app/components/account/account.component.html @@ -1,7 +1,7 @@
-

Account

+

{{ 'ACCOUNTCOMPONENT.ACCOUNT' | translate }}

@@ -13,7 +13,7 @@

Account

- Balance: {{ balance / 1000000 | number:'1.0' }} ꜩ + {{ 'ACCOUNTCOMPONENT.BALANCE' | translate }} {{ balance / 1000000 | number:'1.0' }} ꜩ (${{ balanceUSD | number:'1.00'}} USD)
@@ -26,13 +26,18 @@

Account

+ +

+ {{ 'ACCOUNTCOMPONENT.EMPTY' | translate }} +

\ No newline at end of file diff --git a/src/app/components/activate/activate.component.html b/src/app/components/activate/activate.component.html index 19d58b8e9..ef65293eb 100644 --- a/src/app/components/activate/activate.component.html +++ b/src/app/components/activate/activate.component.html @@ -2,33 +2,33 @@
-

Activate your ICO Wallet

+

{{ 'ACTIVATECOMPONENT.TITLE' | translate }}

- Your public key hash + {{ 'ACTIVATECOMPONENT.PKH' | translate }}
- Your activation code + {{ 'ACTIVATECOMPONENT.CODE' | translate }}
-

Wallets created during the ICO need to be activated.

-

No private key is required for the activation process.

+

{{ 'ACTIVATECOMPONENT.INFO1' | translate }}

+

{{ 'ACTIVATECOMPONENT.INFO2' | translate }}

diff --git a/src/app/components/activity/activity.component.html b/src/app/components/activity/activity.component.html index ccd2d0c59..671ed5bf4 100644 --- a/src/app/components/activity/activity.component.html +++ b/src/app/components/activity/activity.component.html @@ -1,20 +1,20 @@
- + - - - - - - - + + + + + + + - - + + + +
Txn HashBlockDateTypeCounterparty Amount (ꜩ)Status{{ 'ACTIVITYCOMPONENT.TXNHASH' | translate }}{{ 'ACTIVITYCOMPONENT.BLOCK' | translate }}{{ 'ACTIVITYCOMPONENT.DATE' | translate }}{{ 'ACTIVITYCOMPONENT.TYPE' | translate }}{{ 'ACTIVITYCOMPONENT.COUNTERPARTY' | translate }} {{ 'ACTIVITYCOMPONENT.AMOUNT' | translate }} (ꜩ){{ 'ACTIVITYCOMPONENT.STATUS' | translate }}
@@ -45,10 +45,11 @@ - - From - from - to + + + {{ 'ACTIVITYCOMPONENT.FROM' | translate }} + {{ 'ACTIVITYCOMPONENT.FROM' | translate }} + {{ 'ACTIVITYCOMPONENT.TO' | translate }}
@@ -68,6 +69,18 @@ {{ getStatus(transaction) }}
@@ -75,7 +88,7 @@

- Wallet not configured! + {{ 'ACTIVITYCOMPONENT.EMPTY' | translate }}

\ No newline at end of file diff --git a/src/app/components/activity/activity.component.scss b/src/app/components/activity/activity.component.scss index 022214e48..c058c55de 100644 --- a/src/app/components/activity/activity.component.scss +++ b/src/app/components/activity/activity.component.scss @@ -43,9 +43,28 @@ .amount { text-align: right; } + .smallText { font-size: 80%; } + +.btn-balance { + color: #6c757d; + padding-right: 0rem; // original 0.5rem; + padding-left: 0rem; // original 0.5rem; +} + +.last-btn-column > td { + background-color: white; + padding-top: 0.25rem; // default at 0.75rem + padding-bottom: 0.25rem; // default at 0.75rem +} + +.show-more { + font-size: 0.9rem; + width: 73px; +} + @media(min-width:768px) { #page-wrapper { position: inherit; diff --git a/src/app/components/activity/activity.component.ts b/src/app/components/activity/activity.component.ts index c016de234..8ae1ae86b 100644 --- a/src/app/components/activity/activity.component.ts +++ b/src/app/components/activity/activity.component.ts @@ -1,6 +1,10 @@ import { Component, Input, OnInit, AfterViewInit, SimpleChange } from '@angular/core'; import { WalletService } from '../../services/wallet.service'; +import { TzscanService } from '../../services/tzscan.service'; + import { Constants } from '../../constants'; +import { TimeAgoPipe } from '../../pipes/time-ago.pipe'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-activity', @@ -10,16 +14,19 @@ import { Constants } from '../../constants'; export class ActivityComponent implements OnInit { accounts = null; CONSTANTS = new Constants(); + @Input() activePkh: string; constructor( - private walletService: WalletService + private walletService: WalletService, + private tzscanService: TzscanService, ) {} ngOnInit() { if (this.walletService.wallet) { this.init(); } } init() { this.accounts = this.walletService.wallet.accounts; - console.log('transaction', this.accounts[0].activities); + console.log('activePkh: ', this.activePkh); } + getStatus(transaction: any): string { if (transaction.failed) { return 'Failed'; @@ -32,7 +39,15 @@ export class ActivityComponent implements OnInit { getType(transaction: any): string { if (transaction.type !== 'transaction') { - return transaction.type; + if (transaction.type === 'delegation') { + if (transaction.destination) { + return 'delegate'; + } else { + return 'undelegate'; + } + } else { + return transaction.type; + } } else { let operationType = ''; if (transaction.amount > 0) { @@ -45,12 +60,16 @@ export class ActivityComponent implements OnInit { } getCounterparty(transaction: any): string { - console.log('transaction - getCounterparty', transaction); + // console.log('transaction - getCounterparty', transaction); let counterparty = ''; // Checks for delegation as destination is stored in transaction.destination.tz if (transaction.type === 'delegation') { - return transaction.destination.tz; + if (transaction.destination) { + return transaction.destination.tz; + } else { + return ''; // User has undelegate + } } if (this.activePkh === transaction.source) { diff --git a/src/app/components/backup/backup.component.html b/src/app/components/backup/backup.component.html index e83aeb7ba..b9878995f 100644 --- a/src/app/components/backup/backup.component.html +++ b/src/app/components/backup/backup.component.html @@ -2,7 +2,7 @@
-

Backup Your Wallet

+

{{ 'BACKUPCOMPONENT.TITLE' | translate }}

@@ -10,10 +10,8 @@

Backup Your Wallet

-

A wallet backup protects your tez against computer or software failure. If you lose the backup and can't - access your wallet for some reasons, your tez are permanently lost!

-

It is recommended that you store backups of both forms of your key (the Keystore file version and paper wallet - version) in physically separate, offline environments.

+

{{ 'BACKUPCOMPONENT.HEADING1' | translate }}

+

{{ 'BACKUPCOMPONENT.HEADING2' | translate }}

@@ -22,30 +20,30 @@

-

1. Export your Full Wallet to File

-

1. Export your View-only Wallet to File

-

1. Export your Observer Wallet to File

-

This wallet file will contain your private seed encrypted with your password.

-

This wallet file will contain your public key.

-

This wallet file will contain your public key hash.

+

{{ 'BACKUPCOMPONENT.EXPORTFULLWALLET' | translate }}

+

{{ 'BACKUPCOMPONENT.EXPORTVIEWONLYWALLET' | translate }}

+

{{ 'BACKUPCOMPONENT.EXPORTOBSERVERWALLET' | translate }}

+

{{ 'BACKUPCOMPONENT.INFOFULLWALLET' | translate }}

+

{{ 'BACKUPCOMPONENT.INFOVIEWONLYWALLET' | translate }}

+

{{ 'BACKUPCOMPONENT.INFOOBSERVERWALLET' | translate }}

- +

-

2. Export View-only Wallet to file

-

This wallet file will contain your public key (Needed to create unsigned operations).

+

{{ 'BACKUPCOMPONENT.EXPORTVIEWONLYWALLET2' | translate }}

+

{{ 'BACKUPCOMPONENT.INFOVIEWONLYWALLET2' | translate }}

- + - + {{ pk }} @@ -58,13 +56,18 @@

2. Export View-only Wallet to file

+ +

+ {{ 'BACKUPCOMPONENT.EMPTY' | translate }} +

\ No newline at end of file diff --git a/src/app/components/bakery/bakery.component.html b/src/app/components/bakery/bakery.component.html index 461408257..346a1cb0c 100644 --- a/src/app/components/bakery/bakery.component.html +++ b/src/app/components/bakery/bakery.component.html @@ -2,7 +2,7 @@
-

Bakery

+

{{ 'BAKERYCOMPONENT.TITLE' | translate }}

@@ -10,8 +10,8 @@

Bakery

-

In the bakery, you can easily set different delegates for your accounts.

-

Please note that you can't delegate with your identity. You need to create new accounts.

+

{{ 'BAKERYCOMPONENT.HEADING' | translate }}

+

{{ 'BAKERYCOMPONENT.INFO' | translate }}

@@ -21,13 +21,13 @@

- Accounts + {{ 'BAKERYCOMPONENT.ACCOUNTS' | translate }}
- Balance (ꜩ) + {{ 'BAKERYCOMPONENT.BALANCE' | translate }} (ꜩ)
- Delegated to + {{ 'BAKERYCOMPONENT.DELEGATEDTO' | translate }}
@@ -51,14 +51,19 @@

+ +

+ {{ 'BAKERYCOMPONENT.EMPTY' | translate }} +

\ No newline at end of file diff --git a/src/app/components/delegate/delegate.component.html b/src/app/components/delegate/delegate.component.html index b21128dc9..cecec30da 100644 --- a/src/app/components/delegate/delegate.component.html +++ b/src/app/components/delegate/delegate.component.html @@ -3,7 +3,7 @@