Commit 46ec5ad3 authored by Eriksson Monteiro's avatar Eriksson Monteiro

update millix bar ui and integration with millix node v1.10.8

parent 0a970000
This source diff could not be displayed because it is too large. You can view the blob instead.
html, body {
height: 40px;
height: 50px;
margin: 0px;
overflow: hidden;
}
......@@ -13,7 +13,7 @@ a {
}
.hidden-element {
display: none;
display: none!important;
width: 0;
border-width: 0;
height: 0;
......@@ -46,10 +46,18 @@ a {
height: 40px;
}
.h-50 {
height: 50px;
}
.h-35 {
height: 35px;
}
.h-37 {
height: 37px;
}
.m-0 {
margin: 0!important;
}
......@@ -82,10 +90,22 @@ a {
margin-top: 1px!important;
}
.mt-0 {
margin-top: 0px!important;
}
.mb-4 {
margin-bottom: 4px!important;
}
.pl-6 {
padding-left: 6px!important;
}
.pt-7 {
padding-top: 7px!important;
}
.move-left {
float: left;
}
......@@ -117,7 +137,7 @@ a {
.container {
display: flex;
width: 100%;
height: 40px;
height: 50px;
margin-left: auto;
margin-right: auto;
}
......@@ -196,7 +216,7 @@ a {
}
.hidden-sm, .hidden {
display: none;
display: none!important;
}
/*@media only screen and (min-width: 45em) {
......@@ -255,8 +275,7 @@ a {
}
.btn {
font-size: 10px;
padding: 1px;
padding: 2px 1px 2px 1px;
margin-bottom: 0;
border-radius: 2px;
min-width: 45px;
......@@ -276,6 +295,10 @@ a {
border: 1px solid transparent;
}
.btn.expandable-view {
padding: 3px 1px 3px 1px;
}
.btn:focus, .btn:active:focus {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
......@@ -290,8 +313,8 @@ a {
.btn:active {
background-image: none;
outline: 0;
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .07);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .07);
}
/* default
......@@ -311,14 +334,33 @@ a {
.btn-default:hover {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
background-color: rgba(210,210,210,0.1);
border-color: #eee;
}
.dark .btn-default:hover {
background-color: transparent;
border-color: #555;
}
.btn-default:active {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
background-color: rgb(230 230 230 / 10%);
}
.dark .btn-default:active {
background-color: transparent;
border-color: #666;
}
.btn-unlock-text {
font-size: 14px;
line-height: 27px;
color: #656565;
}
.dark .btn-unlock-text {
color: #d5d5d5;
}
/**
......@@ -332,7 +374,7 @@ dark mode
.dark .btn {
color: rgba(241, 243, 244, 1);
background-color: rgba(241, 243, 244, 0.1)
background-color: transparent;
}
.dark a {
......@@ -381,6 +423,19 @@ input:focus {
animation: spin 1s linear infinite;
}
.dark .btn-unlock, .btn-unlock {
line-height: 30px;
color: #b5b5b5;
font-size: 13px;
margin-left: 0px!important;
width: 111px;
padding-left: 6px;
padding-right: 6px;
margin-top: 8px;
max-height: 26px;
}
/* Safari */
@-webkit-keyframes spin {
......@@ -410,14 +465,14 @@ input:focus {
float: right;
z-index: 10;
width: 20px;
height: 40px;
height: 50px;
border-radius: 4px;
}
.left-bar {
position: absolute;
background-color: transparent;
top: 21px;
top: 27px;
left: 7px;
width: 10px;
height: 2px;
......@@ -442,7 +497,7 @@ input:focus {
.right-bar {
position: absolute;
background-color: transparent;
top: 14px;
top: 20px;
left: 7px;
width: 10px;
height: 2px;
......@@ -478,6 +533,10 @@ input:focus {
width: 16px!important;
}
.w21 {
width: 21px!important;
}
.w30 {
width: 30px!important;
}
......@@ -490,6 +549,10 @@ input:focus {
width: 54px!important;
}
.w90 {
width: 90px!important;
}
#wallet_holder {
/*border-right: #5c5c5c solid 1px;*/
position: relative;
......
$(document).ready(() => {
$(".arrow-icon").click(function () {
const $this = $(this);
$this.toggleClass("open");
const $adsHolder = $('#ads_holder');
const $walletHolder = $('#wallet_holder');
const $expandableViews = $(".expandable-view");
if ($this.hasClass("open")) {
$adsHolder.hide();
$walletHolder.css("width", "");
$walletHolder[0].classList.replace("col-4", "col-12");
$("body").css("min-width", "");
$expandableViews.removeClass("hidden");
} else {
$expandableViews.addClass("hidden");
$walletHolder[0].classList.replace("col-12", "col-4");
$walletHolder.css("width", "255px");
$("body").css("min-width", "700px");
$adsHolder.show();
}
});
});
/* for test
class _cr{
define(n, f) {
globalThis[n] = f();
}
}
let cr = new _cr();*/
cr.define('millix_bar', function () {
'use strict';
......@@ -69,23 +54,15 @@ cr.define('millix_bar', function () {
chrome.send('showMillixWallet', ['refresh']);
}
function unlockWallet() {
unlockFromBar = true;
const password = document.getElementById('input_pwd').value;
millixAPIFrame && millixAPIFrame.contentWindow.postMessage({
type: 'new_session',
password
}, 'chrome-untrusted://millix-ws/');
}
function activateWallet() {
if (!walletLocked) {
return;
}
$('#wallet_unlock').addClass('hidden');
$('#wallet').removeClass('hidden');
$('#btn_expand').removeClass('hidden');
walletLocked = false;
updateNodeStat(null);
......@@ -104,6 +81,10 @@ cr.define('millix_bar', function () {
updateNodeStat(null);
walletLocked = true;
console.log("[deactivateWallet]");
$('#wallet').addClass('hidden');
$('#btn_expand').addClass('hidden');
$('#wallet_unlock').removeClass('hidden');
expandView(false);
millixAPIFrame.contentWindow.postMessage({
type: 'read_stat_stop'
......@@ -157,7 +138,12 @@ cr.define('millix_bar', function () {
document.body.classList.add('dark');
}
$('#millix_logo').click(() => showMillixWallet());
$('#wallet').click(() => showMillixWallet());
$('#wallet_unlock').click(() => showMillixWallet());
$('#wallet_network').click(() => showMillixWallet());
$('#wallet_log').click(() => showMillixWallet());
$('#wallet_backlog').click(() => showMillixWallet());
$('#wallet_transaction').click(() => chrome.send('showMillixWallet', ['history']));
cr.addWebUIListener("onThemeChanged", refreshThemeStyles.bind(this));
}
......@@ -192,6 +178,29 @@ cr.define('millix_bar', function () {
audioDeposit.play();
}
function expandView(expanded) {
const $arrow = $(".arrow-icon");
const $adsHolder = $('#ads_holder');
const $walletHolder = $('#wallet_holder');
const $expandableViews = $(".expandable-view");
if (expanded) {
$arrow.addClass("open");
$adsHolder.hide();
$walletHolder.css("width", "");
$walletHolder[0].classList.replace("col-4", "col-12");
$("body").css("min-width", "");
$expandableViews.removeClass("hidden");
} else {
$arrow.removeClass("open");
$expandableViews.addClass("hidden");
$walletHolder[0].classList.replace("col-12", "col-4");
$walletHolder.css("width", "255px");
$("body").css("min-width", "700px");
$adsHolder.show();
}
}
// Return an object with all of the exports.
return {
initialize,
......@@ -202,6 +211,7 @@ cr.define('millix_bar', function () {
updateNodeStat,
onApiFrameReady,
onLastTransactionUpdate,
expandView,
onTransaction
};
});
......@@ -234,4 +244,15 @@ window.addEventListener('message', ({ data }) => {
});
document.addEventListener('DOMContentLoaded', millix_bar.initialize);
\ No newline at end of file
document.addEventListener('DOMContentLoaded', millix_bar.initialize);
$(document).ready(() => {
$(".arrow-icon").click(function () {
const $this = $(this);
if ($this.hasClass("open")) {
millix_bar.expandView(false);
} else {
millix_bar.expandView(true);
}
});
});
\ No newline at end of file
......@@ -10,7 +10,7 @@ namespace views {
MillixBarView::MillixBarView(BrowserView* browser_view) : browser_view_(browser_view) {
contents_webview_ = AddChildView(std::make_unique<ContentsWebView>(browser_view->GetProfile()));
contents_webview_->set_is_primary_web_contents_for_window(true);
this->SetPreferredSize(gfx::Size(0, 40));
this->SetPreferredSize(gfx::Size(0, 50));
}
MillixBarView::~MillixBarView() {
......
......@@ -55,13 +55,7 @@ void MillixBarUI::MillixBarMessageHandler::UpdateMillixWallet(
auto* profile = Profile::FromWebUI(web_ui());
Browser* browser = chrome::FindTabbedBrowser(profile, false);
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
const std::string* action_type = message.FindStringPath("action.type");
if (*action_type == "UNLOCK_WALLET") {
browser_view->GetMillixBarView()->SetVisible(true);
} else if (*action_type == "LOCK_WALLET") {
browser_view->GetMillixBarView()->SetVisible(false);
}
browser_view->GetMillixBarView()->SetVisible(true);
}
if (message.FindStringPath("from_bar")) {
......
......@@ -28,7 +28,7 @@ class _rKclyiLtHx0dx55M extends Endpoint {
}).then(balances => _.sum(balances)).then(stable => database.applyShards((shardID) => {
const transactionRepository = database.getRepository('transaction', shardID);
return transactionRepository.getWalletBalance(wallet.defaultKeyIdentifier, false);
}).then(balances => _.sum(balances)).then(unstable => wallet.getAllTransactions().then(transactions => res.send({
}).then(balances => _.sum(balances)).then(unstable => wallet.getTransactionCount().then(transactionCount => res.send({
balance : {
stable,
unstable
......@@ -42,7 +42,7 @@ class _rKclyiLtHx0dx55M extends Endpoint {
backlog_count: logManager.backLogSize
},
transaction: {
transaction_count: transactions.length
transaction_count: transactionCount
}
})))).catch(e => res.send({
api_status : 'fail',
......
......@@ -774,8 +774,8 @@ export const NETWORK_SHORT_TIME_WAIT_MAX = 1500;
export const DATABASE_ENGINE = 'sqlite';
export const DATABASE_CONNECTION = {};
export const MILLIX_CIRCULATION = 9e15;
export const NODE_MILLIX_BUILD_DATE = 1622057458;
export const NODE_MILLIX_VERSION = '1.10.7-tangled';
export const NODE_MILLIX_BUILD_DATE = 1622201109;
export const NODE_MILLIX_VERSION = '1.10.8-tangled';
export const DATA_BASE_DIR_MAIN_NETWORK = './millix-tangled';
export const DATA_BASE_DIR_TEST_NETWORK = './millix-tangled';
let DATA_BASE_DIR = MODE_TEST_NETWORK ? DATA_BASE_DIR_TEST_NETWORK : DATA_BASE_DIR_MAIN_NETWORK;
......
......@@ -457,6 +457,15 @@ class Wallet {
});
}
getTransactionCount() {
return database.applyShards((shardID) => {
return database.getRepository('transaction', shardID)
.getTransactionCountByAddressKeyIdentifier(this.defaultKeyIdentifier);
}).then(transactionCountList => {
return _.sum(transactionCountList);
});
}
isProcessingTransaction(transactionID) {
return this._transactionReceivedFromNetwork[transactionID] === true;
}
......
......@@ -268,6 +268,31 @@ export default class Transaction {
});
}
getTransactionCountByAddressKeyIdentifier(keyIdentifier) {
return new Promise((resolve, reject) => {
this.database.get(
'SELECT COUNT(distinct transaction_id) as transaction_count FROM (SELECT `transaction`.transaction_id FROM `transaction` \
LEFT JOIN transaction_output on transaction_output.transaction_id = `transaction`.transaction_id \
LEFT JOIN transaction_input on transaction_input.transaction_id = `transaction`.transaction_id \
WHERE transaction_output.address_key_identifier = ? \
UNION SELECT `transaction`.transaction_id FROM `transaction` \
LEFT JOIN transaction_input on transaction_input.transaction_id = `transaction`.transaction_id \
LEFT JOIN transaction_output on transaction_output.transaction_id = `transaction`.transaction_id \
WHERE transaction_input.address_key_identifier = ?)',
[
keyIdentifier,
keyIdentifier
],
(err, row) => {
if (err) {
return reject(err);
}
resolve(row.transaction_count);
}
);
});
}
addTransactionOutputAttribute(transactionID, shardID, attributeTypeID, attributeValue) {
return new Promise((resolve, reject) => {
this.database.run('INSERT INTO transaction_output_attribute (transaction_id, shard_id, attribute_type_id, value) VALUES (?,?,?,?)',
......
......@@ -109,4 +109,4 @@ db.initialize()
}
})
.then(() => setTimeout(() => wallet.syncAddresses(), 2000));
//millix v1.10.7-tangled
//millix v1.10.8-tangled
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment