Browse Source

earnPer

earnPer
master
yuriy0803 2 years ago
parent
commit
701d2f7ed5
  1. 311
      www/app/controllers/account/index.js
  2. 30
      www/app/templates/account/index.hbs

311
www/app/controllers/account/index.js

@ -1,13 +1,13 @@
import Ember from 'ember'; import Ember from 'ember';
export default Ember.Controller.extend({ export default Ember.Controller.extend({
applicationController: Ember.inject.controller('application'), applicationController: Ember.inject.controller('application'),
netstats: Ember.computed.reads('applicationController'), netstats: Ember.computed.reads('applicationController'),
stats: Ember.computed.reads('applicationController.model.stats'), stats: Ember.computed.reads('applicationController.model.stats'),
config: Ember.computed.reads('applicationController.config'), config: Ember.computed.reads('applicationController.config'),
hashrate: Ember.computed.reads('applicationController.hashrate'), hashrate: Ember.computed.reads('applicationController.hashrate'),
chartOptions: Ember.computed("model.hashrate", { chartOptions: Ember.computed("model.hashrate", {
get() { get() {
var e = this, var e = this,
t = e.getWithDefault("model.minerCharts"), t = e.getWithDefault("model.minerCharts"),
@ -18,9 +18,9 @@ export default Ember.Controller.extend({
marginRight: 10, marginRight: 10,
height: 290, height: 290,
events: { events: {
load: function() { load: function () {
var series = this.series[0]; var series = this.series[0];
setInterval(function() { setInterval(function () {
var x = (new Date()).getTime(), var x = (new Date()).getTime(),
y = e.getWithDefault("model.currentHashrate") / 1000000; y = e.getWithDefault("model.currentHashrate") / 1000000;
series.addPoint([x, y], true, true); series.addPoint([x, y], true, true);
@ -31,60 +31,60 @@ export default Ember.Controller.extend({
title: { title: {
text: "" text: ""
}, },
////// //////
rangeSelector : { rangeSelector: {
enabled: true, enabled: true,
selected: 4, selected: 4,
allButtonsEnabled: true, allButtonsEnabled: true,
inputDateFormat: '%Y/%m/%d %H:%M', inputDateFormat: '%Y/%m/%d %H:%M',
inputEditDateFormat: '%Y/%m/%d %H:%M', inputEditDateFormat: '%Y/%m/%d %H:%M',
inputEnabled: false, inputEnabled: false,
buttons: [{ buttons: [{
type: 'hour', type: 'hour',
count: 1, count: 1,
text: '1h' text: '1h'
}, },
{ {
type: 'hour', type: 'hour',
count: 2, count: 2,
text: '2h' text: '2h'
}, },
{ {
type: 'hour', type: 'hour',
count: 4, count: 4,
text: '4h' text: '4h'
}, },
{ {
type: 'hour', type: 'hour',
count: 6, count: 6,
text: '6h' text: '6h'
}, },
{ {
type: 'hour', type: 'hour',
count: 12, count: 12,
text: '12h' text: '12h'
}, },
{ {
type: 'all', type: 'all',
text: 'All' text: 'All'
} }
], ],
}, },
navigator: { navigator: {
enabled: true enabled: true
}, },
credits: { credits: {
enabled: false, enabled: false,
position: { position: {
align: 'right', align: 'right',
x: -10, x: -10,
verticalAlign: 'bottom', verticalAlign: 'bottom',
y: -5 y: -5
}, },
href: "https://highcharts.com", href: "https://highcharts.com",
text: "Highcharts" text: "Highcharts"
}, },
/////// ///////
xAxis: { xAxis: {
ordinal: false, ordinal: false,
labels: { labels: {
@ -127,12 +127,12 @@ export default Ember.Controller.extend({
legend: { legend: {
enabled: true, enabled: true,
itemStyle: itemStyle:
{ {
color: "#000" color: "#000"
}, },
}, },
tooltip: { tooltip: {
formatter: function() { formatter: function () {
return this.y > 1000000000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000000000).toFixed(2) + "&nbsp;TH/s</b>" : this.y > 1000000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000000).toFixed(2) + "&nbsp;GH/s</b>" : this.y > 1000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000).toFixed(2) + "&nbsp;MH/s</b>" : "<b>" + this.point.d + "<b><br>Hashrate&nbsp;<b>" + this.y.toFixed(2) + "&nbsp;H/s</b>"; return this.y > 1000000000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000000000).toFixed(2) + "&nbsp;TH/s</b>" : this.y > 1000000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000000).toFixed(2) + "&nbsp;GH/s</b>" : this.y > 1000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000).toFixed(2) + "&nbsp;MH/s</b>" : "<b>" + this.point.d + "<b><br>Hashrate&nbsp;<b>" + this.y.toFixed(2) + "&nbsp;H/s</b>";
}, },
@ -145,7 +145,7 @@ export default Ember.Controller.extend({
series: [{ series: [{
color: "#15BD27", color: "#15BD27",
name: "3 hours average hashrate", name: "3 hours average hashrate",
data: function() { data: function () {
var e, a = []; var e, a = [];
if (null != t) { if (null != t) {
for (e = 0; e <= t.length - 1; e += 1) { for (e = 0; e <= t.length - 1; e += 1) {
@ -163,9 +163,9 @@ export default Ember.Controller.extend({
} }
} else { } else {
a.push({ a.push({
x: 0, x: 0,
d: 0, d: 0,
y: 0 y: 0
}); });
} }
return a; return a;
@ -173,7 +173,7 @@ export default Ember.Controller.extend({
}, { }, {
name: "30 minutes average hashrate", name: "30 minutes average hashrate",
color: "#E99002", color: "#E99002",
data: function() { data: function () {
var e, a = []; var e, a = [];
if (null != t) { if (null != t) {
for (e = 0; e <= t.length - 1; e += 1) { for (e = 0; e <= t.length - 1; e += 1) {
@ -205,7 +205,7 @@ export default Ember.Controller.extend({
} }
}), }),
shareChart: Ember.computed("model.hashrate", { shareChart: Ember.computed("model.hashrate", {
get() { get() {
var e = this, var e = this,
t = e.getWithDefault("model.shareCharts"), t = e.getWithDefault("model.shareCharts"),
@ -215,21 +215,21 @@ export default Ember.Controller.extend({
type: "column", type: "column",
marginRight: 10, marginRight: 10,
height: 180 height: 180
// events: { // events: {
/* load: function() { /* load: function() {
var series = this.series[0]; var series = this.series[0];
setInterval(function() { setInterval(function() {
var x = (new Date()).getTime(), var x = (new Date()).getTime(),
y = e.getWithDefault("model.workersOnline") / 1000000; y = e.getWithDefault("model.workersOnline") / 1000000;
series.addPoint([x, y], true, true); series.addPoint([x, y], true, true);
}, 1090000000); }, 1090000000);
} */ } */
// } // }
}, },
title: { title: {
text: "" text: ""
}, },
xAxis: { xAxis: {
ordinal: false, ordinal: false,
labels: { labels: {
style: { style: {
@ -248,9 +248,9 @@ export default Ember.Controller.extend({
year: "%Y" year: "%Y"
} }
}, },
//rangeSelector: { //rangeSelector: {
// selected: 1, // selected: 1,
// }, // },
yAxis: { yAxis: {
title: { title: {
text: "Shares", text: "Shares",
@ -267,20 +267,20 @@ export default Ember.Controller.extend({
//softMax: e.getWithDefault("model.currentHashrate") / 1000000, //softMax: e.getWithDefault("model.currentHashrate") / 1000000,
}, },
plotOptions: { plotOptions: {
series: { series: {
marginleft: 0, marginleft: 0,
pointWidth: 10 pointWidth: 10
// marker: { // marker: {
// enabled: false // enabled: false
// } // }
}, },
column: { column: {
stacking: 'normal', stacking: 'normal',
grouping: false grouping: false
//shadow: false //shadow: false
//borderWidth: 0 //borderWidth: 0
} }
}, },
plotLines: [{ plotLines: [{
value: 0, value: 0,
width: 1, width: 1,
@ -289,25 +289,25 @@ export default Ember.Controller.extend({
legend: { legend: {
enabled: true, enabled: true,
itemStyle: itemStyle:
{ {
color: "#000" color: "#000"
}, },
}, },
tooltip: { tooltip: {
formatter: function() { formatter: function () {
return this.y > 1000000000000 ? "<b>" + this.point.d + "<b><br>Shares&nbsp;" + (this.y / 1000000000000) + "</b>" : this.y > 1000000000 ? "<b>" + this.point.d + "<b><br>Shares&nbsp;" + (this.y / 1000000000) + "</b>" : this.y > 1000000 ? "<b>" + this.point.d + "<b><br>Shares&nbsp;" + (this.y / 1000000) + "</b>" : "<b>" + this.point.d + "<b><br>Shares&nbsp;<b>" + this.y + "</b>"; return this.y > 1000000000000 ? "<b>" + this.point.d + "<b><br>Shares&nbsp;" + (this.y / 1000000000000) + "</b>" : this.y > 1000000000 ? "<b>" + this.point.d + "<b><br>Shares&nbsp;" + (this.y / 1000000000) + "</b>" : this.y > 1000000 ? "<b>" + this.point.d + "<b><br>Shares&nbsp;" + (this.y / 1000000) + "</b>" : "<b>" + this.point.d + "<b><br>Shares&nbsp;<b>" + this.y + "</b>";
}, },
useHTML: true useHTML: true
}, },
exporting: { exporting: {
enabled: false enabled: false
}, },
series: [{ series: [{
color: "#15BD27", color: "#15BD27",
name: "Valid share", name: "Valid share",
data: function() { data: function () {
var e, a = []; var e, a = [];
if (null != t) { if (null != t) {
for (e = 0; e <= t.length - 1; e += 1) { for (e = 0; e <= t.length - 1; e += 1) {
@ -325,9 +325,9 @@ export default Ember.Controller.extend({
} }
} else { } else {
a.push({ a.push({
x: 0, x: 0,
d: 0, d: 0,
y: 0 y: 0
}); });
} }
return a; return a;
@ -337,7 +337,7 @@ export default Ember.Controller.extend({
name: "Stale share", name: "Stale share",
color: "#E99002", color: "#E99002",
data: function() { data: function () {
var e, a = []; var e, a = [];
if (null != t) { if (null != t) {
for (e = 0; e <= t.length - 1; e += 1) { for (e = 0; e <= t.length - 1; e += 1) {
@ -363,44 +363,75 @@ export default Ember.Controller.extend({
return a; return a;
}() }()
/* }, { /* }, {
name: "Workers", name: "Workers",
color: "#FF0000", color: "#FF0000",
type: 'spline', type: 'spline',
plotLines: [{ plotLines: [{
// value: 0, // value: 0,
width: 1, width: 1,
color: "#aaaaaa" color: "#aaaaaa"
}], }],
data: function() { data: function() {
var e, a = []; var e, a = [];
if (null != t) { if (null != t) {
for (e = 0; e <= t.length - 1; e += 1) { for (e = 0; e <= t.length - 1; e += 1) {
var n = 0, var n = 0,
r = 0, r = 0,
l = 0; l = 0;
r = new Date(1e3 * t[e].x); r = new Date(1e3 * t[e].x);
l = r.toLocaleString(); l = r.toLocaleString();
n = t[e].workerOnline; n = t[e].workerOnline;
a.push({ a.push({
x: r, x: r,
d: l, d: l,
y: n y: n
}); });
} }
} else { } else {
a.push({ a.push({
x: 0, x: 0,
d: 0, d: 0,
y: 0 y: 0
}); });
} }
return a; return a;
}() */ }() */
}] }]
}; };
return a; return a;
} }
}) }),
earnPerHour: Ember.computed('model', {
get() {
return 1 * 60 * 60 / this.get('config').BlockTime * this.get('config').BlockReward *
this.getWithDefault('model.hashrate') / this.get('hashrate');
}
}),
earnPerHour12: Ember.computed('model', {
get() {
return 12 * 60 * 60 / this.get('config').BlockTime * this.get('config').BlockReward *
this.getWithDefault('model.hashrate') / this.get('hashrate');
}
}),
earnPerDay: Ember.computed('model', {
get() {
return 24 * 60 * 60 / this.get('config').BlockTime * this.get('config').BlockReward *
this.getWithDefault('model.hashrate') / this.get('hashrate');
}
}),
earnPerWeek: Ember.computed('model', {
get() {
return 168 * 60 * 60 / this.get('config').BlockTime * this.get('config').BlockReward *
this.getWithDefault('model.hashrate') / this.get('hashrate');
}
}),
earnPerMonth: Ember.computed('model', {
get() {
return 672 * 60 * 60 / this.get('config').BlockTime * this.get('config').BlockReward *
this.getWithDefault('model.hashrate') / this.get('hashrate');
}
}),
}); });

30
www/app/templates/account/index.hbs

@ -1,6 +1,36 @@
<div class="container"> <div class="container">
{{high-charts mode=chartMode chartOptions=chartOptions content=chartData}} {{high-charts mode=chartMode chartOptions=chartOptions content=chartData}}
{{high-charts mode=chartMode chartOptions=shareChart content=chartData}} {{high-charts mode=chartMode chartOptions=shareChart content=chartData}}
<table class="table table-condensed table-striped">
<thead>
<tr class="active">
<th>Time</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td><span>Last 60 minutes</span></td>
<td><span>{{format-number earnPerHour maximumFractionDigits='8'}}</span></td>
</tr>
<tr>
<td><span>Last 12 hours</span></td>
<td><span>{{format-number earnPerHour12 maximumFractionDigits='8'}}</span></td>
</tr>
<tr>
<td><span>Last 24 hours</span></td>
<td>{{format-number earnPerDay maximumFractionDigits='8'}}</td>
</tr>
<tr>
<td><span>Last 7 days</span></td>
<td>{{format-number earnPerWeek maximumFractionDigits='8'}}</td>
</tr>
<tr>
<td><span>Last 30 days</span></td>
<td>{{format-number earnPerMonth maximumFractionDigits='8'}}</td>
</tr>
</tbody>
</table>
{{#if model.workers}} {{#if model.workers}}
<h4>Your Workers</h4> <h4>Your Workers</h4>
<div class="table-responsive"> <div class="table-responsive">

Loading…
Cancel
Save