Skip to content

Instantly share code, notes, and snippets.

@Serpent6877
Created April 3, 2018 21:33
Show Gist options
  • Save Serpent6877/c4393d3bd1779effec7f2a166c9d0907 to your computer and use it in GitHub Desktop.
Save Serpent6877/c4393d3bd1779effec7f2a166c9d0907 to your computer and use it in GitHub Desktop.
ember-highchart-test
import Ember from 'ember';
export default Ember.Controller.extend({
applicationController: Ember.inject.controller('application'),
config: Ember.computed.reads('applicationController.config'),
stats: Ember.computed.reads('applicationController.model.stats'),
chartOptions: Ember.computed("hashrate", {
get() {
var e = this,
t = e.getWithDefault("model.minerCharts"),
a = {
chart: {
backgroundColor: "rgba(6, 6, 6, 0.1)",
type: "spline",
marginRight: 10,
height: 400,
events: {
load: function() {
var series = this.series[0];
setInterval(function() {
var x = (new Date).getTime(),
y = e.getWithDefault("model.currentHashrate") / 1000000;
series.addPoint([x, y], true, true)
}, 109000000)
}
}
},
title: {
text: ""
},
xAxis: {
ordinal: false,
type: "datetime",
dateTimeLabelFormats: {
millisecond: "%H:%M:%S",
second: "%H:%M:%S",
minute: "%H:%M",
hour: "%H:%M",
day: "%e. %b",
week: "%e. %b",
month: "%b '%y",
year: "%Y"
}
},
yAxis: {
title: {
text: "HASHRATE"
},
min: 0
},
plotLines: [{
value: 0,
width: 1,
color: "#808080"
}],
legend: {
enabled: true,
itemStyle: {
fontSize: '14px;',
color: '#898b96'
},
itemHoverStyle: {
color: '#fff'
}
},
tooltip: {
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>"
},
useHTML: true
},
exporting: {
enabled: false
},
series: [{
color: "#E99002",
name: "Average hashrate",
data: function() {
var e, a = [];
if (null != t)
for (e = 0; e <= t.length - 1; e += 1) {
var n = 0,
r = 0,
l = 0;
r = new Date(1e3 * t[e].x), l = r.toLocaleString(), n = t[e].minerLargeHash, a.unshift({
x: r,
d: l,
y: n
})
} else a.unshift({
x: 0,
d: 0,
y: 0
});
return a
}()
}, {
name: "Current hashrate",
data: function() {
var e, a = [];
if (null != t)
for (e = 0; e <= t.length - 1; e += 1) {
var n = 0,
r = 0,
l = 0;
r = new Date(1e3 * t[e].x), l = r.toLocaleString(), n = t[e].minerHash, a.unshift({
x: r,
d: l,
y: n
})
} else a.unshift({
x: 0,
d: 0,
y: 0
});
return a
}()
}]
};
return a
}
}),
roundPercent: Ember.computed('stats', 'model', {
get() {
var percent = this.get('model.roundShares') / this.get('stats.nShares');
if (!percent) {
return 0;
}
return percent;
}
})
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
var url = 'http://pirl.digipools.org/api/accounts/0xfcf9e3e43cd0860605e2b094e2410e238b26d6cc';
return Ember.$.getJSON(url).then(function(data) {
data.login = '0xfcf9e3e43cd0860605e2b094e2410e238b26d6cc';
return Ember.Object.create(data);
});
},
setupController: function(controller, model) {
this._super(controller, model);
Ember.run.later(this, this.refresh, 5000);
},
actions: {
error(error) {
if (error.status === 404) {
return this.transitionTo('not-found');
}
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{high-charts mode=chartMode chartOptions=chartOptions content=chartData}}
<br>
<br>
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.13.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2",
"broccoli-asset-rev": "^2.7.0",
"broccoli-funnel": "^1.0.9",
"ember-ajax": "^2.4.1",
"ember-cli": "2.9.1",
"ember-cli-app-version": "^2.0.0",
"ember-cli-babel": "^5.2.8",
"ember-cli-cookie": "^0.2.0",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-htmlbars": "^1.0.10",
"ember-cli-htmlbars-inline-precompile": "^0.3.3",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-jshint": "^1.0.4",
"ember-cli-qunit": "^3.0.1",
"ember-cli-release": "^0.2.9",
"ember-cli-sri": "^2.1.0",
"ember-cli-test-loader": "^1.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-cli-update": "0.16.0",
"ember-data": "3.1.1",
"ember-export-application-global": "^1.0.5",
"ember-format-currency": "0.0.2",
"ember-highcharts": "0.5.4",
"ember-intl": "2.15.1",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"ember-truth-helpers": "2.0.0",
"ember-welcome-page": "^1.0.3",
"highcharts": "6.0.7",
"loader.js": "^4.0.10"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment