Skip to content

Commit

Permalink
Merge branch 'frontend'
Browse files Browse the repository at this point in the history
  • Loading branch information
wildkif committed Apr 22, 2019
2 parents f408f93 + 7082b6d commit f79e993
Show file tree
Hide file tree
Showing 27 changed files with 818 additions and 296 deletions.
8 changes: 8 additions & 0 deletions src/gui/qt-daemon/html/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"SETUP_CONFIRM_PASS": "Confirm the password",
"MASTER_PASS": "Master password",
"BUTTON_NEXT": "Next",
"BUTTON_SKIP": "Skip",
"INCORRECT_PASSWORD": "Invalid password",
"FORM_ERRORS": {
"PASS_REQUIRED": "Password is required.",
Expand Down Expand Up @@ -83,6 +84,13 @@
"NAME_REQUIRED": "Name is required.",
"NAME_DUPLICATE": "Name is duplicate.",
"MAX_LENGTH": "Maximum name length reached."
},
"MODAL": {
"TITLE": "Type wallet password",
"LABEL": "Password to this wallet",
"OPEN": "Open wallet",
"SKIP": "Skip",
"NOT_FOUND": "Not found"
}
},
"RESTORE_WALLET": {
Expand Down
11 changes: 11 additions & 0 deletions src/gui/qt-daemon/html/assets/scss/base/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -780,3 +780,14 @@ app-progress-container {
}
}
}

app-open-wallet-modal {

.modal {

@include themify($themes) {
background: themed(modalBackground);
color: themed(mainTextColor);
}
}
}
550 changes: 386 additions & 164 deletions src/gui/qt-daemon/html/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/gui/qt-daemon/html/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/gui/qt-daemon/html/styles.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/gui/qt-daemon/html/styles.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,27 @@ export class BackendService {
backendObject: any;
backendLoaded = false;

constructor(private translate: TranslateService, private variablesService: VariablesService, private modalService: ModalService, private moneyToIntPipe: MoneyToIntPipe) {}
constructor(
private translate: TranslateService,
private variablesService: VariablesService,
private modalService: ModalService,
private moneyToIntPipe: MoneyToIntPipe
) {
}

private Debug(type, message) {
static bigNumberParser(key, val) {
if (val.constructor.name === 'BigNumber' && ['balance', 'unlocked_balance', 'amount', 'fee', 'b_fee', 'to_pay', 'a_pledge', 'b_pledge', 'coast', 'a'].indexOf(key) === -1) {
return val.toNumber();
}
if (key === 'rcv' || key === 'spn') {
for (let i = 0; i < val.length; i++) {
val[i] = new BigNumber(val[i]);
}
}
return val;
}

static Debug(type, message) {
switch (type) {
case 0:
console.error(message);
Expand Down Expand Up @@ -112,13 +130,14 @@ export class BackendService {
}
}
break;
case 'NOT_FOUND': if (command !== 'open_wallet' && command !== 'get_alias_info_by_name' && command !== 'get_alias_info_by_address') {
error_translate = this.translate.instant('ERRORS.FILE_NOT_FOUND');
params = JSON.parse(params);
if (params.path) {
error_translate += ': ' + params.path;
case 'NOT_FOUND':
if (command !== 'open_wallet' && command !== 'get_alias_info_by_name' && command !== 'get_alias_info_by_address') {
error_translate = this.translate.instant('ERRORS.FILE_NOT_FOUND');
params = JSON.parse(params);
if (params.path) {
error_translate += ': ' + params.path;
}
}
}
break;
case 'CANCELED':
case '':
Expand All @@ -142,44 +161,29 @@ export class BackendService {
}
}

private bigNumberParser(key, val) {
if (val.constructor.name === 'BigNumber' && ['balance', 'unlocked_balance', 'amount', 'fee', 'b_fee', 'to_pay', 'a_pledge', 'b_pledge', 'coast', 'a'].indexOf(key) === -1) {
return val.toNumber();
}
if (key === 'rcv' || key === 'spn') {
for (let i = 0; i < val.length; i++) {
val[i] = new BigNumber(val[i]);
}
}
return val;
}

private commandDebug(command, params, result) {
this.Debug(2, '----------------- ' + command + ' -----------------');
BackendService.Debug(2, '----------------- ' + command + ' -----------------');
const debug = {
_send_params: params,
_result: result
};
this.Debug(2, debug);
BackendService.Debug(2, debug);
try {
this.Debug(2, JSONBigNumber.parse(result, this.bigNumberParser));
BackendService.Debug(2, JSONBigNumber.parse(result, BackendService.bigNumberParser));
} catch (e) {
this.Debug(2, {response_data: result, error_code: 'OK'});
BackendService.Debug(2, {response_data: result, error_code: 'OK'});
}
}

private asVal(data) {
return {v: data};
}

private backendCallback(resultStr, params, callback, command) {
let Result = resultStr;
if (command !== 'get_clipboard') {
if (!resultStr || resultStr === '') {
Result = {};
} else {
try {
Result = JSONBigNumber.parse(resultStr, this.bigNumberParser);
Result = JSONBigNumber.parse(resultStr, BackendService.bigNumberParser);
} catch (e) {
Result = {response_data: resultStr, error_code: 'OK'};
}
Expand All @@ -194,7 +198,7 @@ export class BackendService {
const Status = (Result.error_code === 'OK' || Result.error_code === 'TRUE');

if (!Status && Status !== undefined && Result.error_code !== undefined) {
this.Debug(1, 'API error for command: "' + command + '". Error code: ' + Result.error_code);
BackendService.Debug(1, 'API error for command: "' + command + '". Error code: ' + Result.error_code);
}
const data = ((typeof Result === 'object') && 'response_data' in Result) ? Result.response_data : Result;

Expand All @@ -220,7 +224,7 @@ export class BackendService {
if (this.backendObject) {
const Action = this.backendObject[command];
if (!Action) {
this.Debug(0, 'Run Command Error! Command "' + command + '" don\'t found in backendObject');
BackendService.Debug(0, 'Run Command Error! Command "' + command + '" don\'t found in backendObject');
} else {
const that = this;
params = (typeof params === 'string') ? params : JSONBigNumber.stringify(params);
Expand All @@ -245,7 +249,7 @@ export class BackendService {
this.backendObject[command].connect(callback);
} else {
this.backendObject[command].connect((str) => {
callback(JSONBigNumber.parse(str, this.bigNumberParser));
callback(JSONBigNumber.parse(str, BackendService.bigNumberParser));
});
}
}
Expand Down Expand Up @@ -285,17 +289,20 @@ export class BackendService {
}

storeAppData(callback?) {
if (this.variablesService.wallets.length) {
this.variablesService.settings.wallets = [];
this.variablesService.wallets.forEach((wallet) => {
this.variablesService.settings.wallets.push({name: wallet.name, path: wallet.path});
});
}
this.runCommand('store_app_data', this.variablesService.settings, callback);
}

getSecureAppData(pass, callback) {
this.runCommand('get_secure_app_data', pass, callback);
}

storeSecureAppData(callback) {
if (this.variablesService.appPass === '') {
return callback(false);
}
storeSecureAppData(callback?) {
const wallets = [];
this.variablesService.wallets.forEach((wallet) => {
wallets.push({name: wallet.name, pass: wallet.pass, path: wallet.path});
Expand All @@ -305,6 +312,12 @@ export class BackendService {
});
}

dropSecureAppData(callback?) {
this.backendObject['drop_secure_app_data']((dataStore) => {
this.backendCallback(dataStore, {}, callback, 'drop_secure_app_data');
});
}

haveSecureAppData(callback) {
this.runCommand('have_secure_app_data', {}, callback);
}
Expand Down Expand Up @@ -346,15 +359,15 @@ export class BackendService {
this.runCommand('open_wallet', params, callback);
}

closeWallet(wallet_id, callback) {
closeWallet(wallet_id, callback?) {
this.runCommand('close_wallet', {wallet_id: +wallet_id}, callback);
}

getSmartWalletInfo(wallet_id, callback) {
this.runCommand('get_smart_wallet_info', {wallet_id: +wallet_id}, callback);
}

runWallet(wallet_id, callback) {
runWallet(wallet_id, callback?) {
this.runCommand('run_wallet', {wallet_id: +wallet_id}, callback);
}

Expand Down Expand Up @@ -418,15 +431,15 @@ export class BackendService {
fee: this.variablesService.default_fee_big,
b_fee: this.variablesService.default_fee_big
};
this.Debug(1, params);
BackendService.Debug(1, params);
this.runCommand('create_proposal', params, callback);
}

getContracts(wallet_id, callback) {
const params = {
wallet_id: parseInt(wallet_id, 10)
};
this.Debug(1, params);
BackendService.Debug(1, params);
this.runCommand('get_contracts', params, callback);
}

Expand All @@ -435,7 +448,7 @@ export class BackendService {
wallet_id: parseInt(wallet_id, 10),
contract_id: contract_id
};
this.Debug(1, params);
BackendService.Debug(1, params);
this.runCommand('accept_proposal', params, callback);
}

Expand All @@ -445,7 +458,7 @@ export class BackendService {
contract_id: contract_id,
release_type: release_type // "normal" or "burn"
};
this.Debug(1, params);
BackendService.Debug(1, params);
this.runCommand('release_contract', params, callback);
}

Expand All @@ -456,7 +469,7 @@ export class BackendService {
fee: this.variablesService.default_fee_big,
expiration_period: parseInt(time, 10) * 60 * 60
};
this.Debug(1, params);
BackendService.Debug(1, params);
this.runCommand('request_cancel_contract', params, callback);
}

Expand All @@ -465,7 +478,7 @@ export class BackendService {
wallet_id: parseInt(wallet_id, 10),
contract_id: contract_id
};
this.Debug(1, params);
BackendService.Debug(1, params);
this.runCommand('accept_cancel_contract', params, callback);
}

Expand Down Expand Up @@ -506,7 +519,7 @@ export class BackendService {
this.runCommand('set_localization_strings', params, callback);
}

registerAlias (wallet_id, alias, address, fee, comment, reward, callback) {
registerAlias(wallet_id, alias, address, fee, comment, reward, callback) {
const params = {
wallet_id: wallet_id,
alias: {
Expand All @@ -521,7 +534,7 @@ export class BackendService {
this.runCommand('request_alias_registration', params, callback);
}

updateAlias (wallet_id, alias, fee, callback) {
updateAlias(wallet_id, alias, fee, callback) {
const params = {
wallet_id: wallet_id,
alias: {
Expand All @@ -535,24 +548,24 @@ export class BackendService {
this.runCommand('request_alias_update', params, callback);
}

getAllAliases (callback) {
getAllAliases(callback) {
this.runCommand('get_all_aliases', {}, callback);
}

getAliasByName (value, callback) {
getAliasByName(value, callback) {
return this.runCommand('get_alias_info_by_name', value, callback);
}

getAliasByAddress (value, callback) {
getAliasByAddress(value, callback) {
return this.runCommand('get_alias_info_by_address', value, callback);
}

getAliasCoast (alias, callback) {
getAliasCoast(alias, callback) {
this.runCommand('get_alias_coast', {v: alias}, callback);
}

getWalletAlias(address) {
if (address != null && this.variablesService.daemon_state === 2) {
if (address !== null && this.variablesService.daemon_state === 2) {
if (this.variablesService.aliasesChecked[address] == null) {
this.variablesService.aliasesChecked[address] = {};
if (this.variablesService.aliases.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class VariablesService {

public digits = 12;
public appPass = '';
public appLogin = false;
public moneyEquivalent = 0;
public defaultTheme = 'dark';
public defaultCurrency = 'ZAN';
Expand All @@ -35,7 +36,8 @@ export class VariablesService {
language: 'en',
default_path: '/',
viewedContracts: [],
notViewedContracts: []
notViewedContracts: [],
wallets: []
};

public wallets: Array<Wallet> = [];
Expand All @@ -56,6 +58,7 @@ export class VariablesService {
this.ngZone.run(() => {
this.idle.stop();
this.appPass = '';
this.appLogin = false;
this.router.navigate(['/login'], {queryParams: {type: 'auth'}});
});
});
Expand Down
5 changes: 4 additions & 1 deletion src/gui/qt-daemon/html_source/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-sidebar *ngIf="variablesService.appPass"></app-sidebar>
<app-sidebar *ngIf="variablesService.appLogin"></app-sidebar>

<div class="app-content scrolled-content">
<router-outlet *ngIf="[0, 1, 2].indexOf(variablesService.daemon_state) !== -1"></router-outlet>
Expand All @@ -24,3 +24,6 @@
<ng-template contextMenuItem (execute)="contextMenuPaste($event.item)">{{ 'CONTEXT_MENU.PASTE' | translate }}</ng-template>
<ng-template contextMenuItem (execute)="contextMenuSelect($event.item)">{{ 'CONTEXT_MENU.SELECT' | translate }}</ng-template>
</context-menu>


<app-open-wallet-modal *ngIf="needOpenWallets.length" [wallets]="needOpenWallets"></app-open-wallet-modal>
Loading

0 comments on commit f79e993

Please sign in to comment.