Commit 19ba1d26 authored by Jason Rhinelander's avatar Jason Rhinelander
Browse files

Added pool warning field

parent baf18569
......@@ -166,7 +166,8 @@ CREATE TABLE public.pools (
api text NOT NULL,
enabled boolean DEFAULT true NOT NULL,
location text,
payment_system text
payment_system text,
warning text
);
......
......@@ -98,7 +98,7 @@ def pool_stats(env, start_response, q):
mean_effort[x[0]] = (eff * 100, count, pval)
cur.execute("""
SELECT id, name, url, blocks_url, location, payment_system,
SELECT id, name, url, blocks_url, location, payment_system, warning,
height, blocks_found, hashrate, effort, miners, miners_paid, payments, fee, threshold, error,
hashrate_1d AS hr1, hashrate_7d AS hr7
FROM pools JOIN pool_stats ON pool = id JOIN pool_agg_stats ON pool_stats.pool = pool_agg_stats.pool
......@@ -245,7 +245,7 @@ def add_pool(env, start_response, q):
if auth_failed:
return auth_failed
for x in ('name', 'url', 'blocks_url', 'api', 'api_url', 'location', 'payment_system'):
for x in ('name', 'url', 'blocks_url', 'api', 'api_url', 'location', 'payment_system', 'warning'):
if x not in q:
return error(start_response, "Required parameter '" + x + "' not specified")
......@@ -268,9 +268,11 @@ def add_pool(env, start_response, q):
pg = pgsql()
cur = pg.cursor()
try:
cur.execute("INSERT INTO pools (name, url, blocks_url, api, api_url, enabled, location, payment_system) "
cur.execute("INSERT INTO pools (name, url, blocks_url, api, api_url, warning, enabled, location, payment_system) "
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
(q['name'], q['url'], q['blocks_url'], q['api'], q['api_url'], bool('enabled' in q and q['enabled']),
(q['name'], q['url'], q['blocks_url'], q['api'], q['api_url'],
q['warning'] if q['warning'] else None,
bool('enabled' in q and q['enabled']),
q['location'], q['payment_system']))
except psycopg2.Error as e:
return error(start_response, "Unable to insert pool: " + str(e))
......@@ -292,6 +294,9 @@ def modify_pool(env, start_response, q):
if x in q:
update.append(x)
params.append(q[x])
if 'warning' in q:
update.append('warning')
params.append(q['warning'] if q['warning'] else None)
if 'enabled' in q:
update.append('enabled')
params.append(bool(q['enabled']))
......
......@@ -25,7 +25,8 @@ body {
.admin-form .field label {
color: #333388;
width: 33%;
margin: 0 0 auto 0;
margin: 7px 0 auto 0;
vertical-align: top;
}
.admin-form .field button#pool-detect-api {
width: 12%;
......@@ -36,7 +37,7 @@ body {
.admin-form .field .input {
width: 66%;
}
.admin-form .field .input input, .admin-form .field .input select {
.admin-form .field .input input, .admin-form .field .input select, .admin-form .field .input textarea {
width: 100%;
}
......
......@@ -145,6 +145,22 @@
</div>
</div>
<div class="pool field">
<label>Warning?</label>
<div class="pool input">
<textarea id="pool-warning"></textarea>
</div>
<div class="description">
<p>
If non-empty, this pool is flagged with a warning indicator that displays the given value when clicked.
</p>
<p>
Contents are HTML.
</p>
</div>
</div>
<div class="pool field">
<label>Enabled?</label>
<div class="pool input">
......
......@@ -113,7 +113,7 @@ function populate_pool_form() {
}
else {
let pool = pools[id];
for (let x of ['name', 'location', 'payment_system', 'url', 'blocks_url', 'api', 'api_url']) {
for (let x of ['name', 'location', 'payment_system', 'url', 'blocks_url', 'api', 'api_url', 'warning']) {
$('#pool-' + x).val(pool[x]);
}
$('#pool-enabled').val(pool.enabled ? '1' : '');
......@@ -139,7 +139,7 @@ function submit_pool() {
auth_code: $('#auth_code').val()
};
if (id) data['id'] = id;
for (let x of ['name', 'url', 'location', 'payment_system', 'blocks_url', 'api', 'api_url', 'enabled'])
for (let x of ['name', 'url', 'location', 'payment_system', 'blocks_url', 'api', 'api_url', 'warning', 'enabled'])
data[x] = $('#pool-' + x).val();
$.ajax({
......@@ -150,7 +150,7 @@ function submit_pool() {
error: submit_fail,
success: function(data) {
if (!data.success) return submit_fail(null, null, data.error);
$('.pool.input input, .pool.input select').val("");
$('.pool.input input, .pool.input select, .pool.input textarea').val("");
$('#pool-enabled').val("1");
var ss = $('.submit-success');
ss.empty().append($('<h3>Success!</h3><div></div>'));
......
......@@ -10,8 +10,8 @@
<title>Graft pool list</title>
<script src="/javascript/jquery/jquery.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="pools.js?6"></script>
<link rel="stylesheet" href="pools.css?6" />
<script src="pools.js?7"></script>
<link rel="stylesheet" href="pools.css?7" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/javascript/jquery-ui/themes/base/jquery-ui.css" />
<script src="/javascript/jquery-ui/jquery-ui.min.js"></script>
......@@ -41,7 +41,7 @@
</div>
</div>
<div id="effort-dialog"></div>
<div id="dialog-msg"></div>
<table id="pool-table">
<thead>
......
......@@ -67,6 +67,17 @@ td.name, td.location {
text-align: left;
}
td.name .warning {
display: inline-block;
width: 1em;
height: 1em;
background-image: url('warning.png');
background-repeat: no-repeat;
background-size: 1em 1em;
cursor: pointer;
}
td.effort, td.fee.high { cursor: help; }
td.effort.significant, td.fee.high { text-decoration: underline; }
td.effort.significant .indicator { font-weight: bold; }
......@@ -198,8 +209,9 @@ body.embedded .hashrate-chart {
display: none;
}
div#effort-dialog {
div#dialog-msg {
display: none;
white-space: pre-line;
}
div.ui-dialog {
box-shadow: 0 0 10px 5px gray;
......
......@@ -100,6 +100,14 @@ function updatePoolCharts() {
}
function dialog_creator(title, text) { return function(e) {
var dialog = $('div#dialog-msg');
dialog.empty().append($('<div>' + text + '</div>'));
dialog.dialog({
title: title,
position: { my: 'left top', at: 'center', of: e } });
}; };
function update_pools(data) {
var to_find = {};
......@@ -194,15 +202,8 @@ function update_pools(data) {
effort_info += '<br /><br />This pool seems impossibly lucky: treat this reported luck value with suspicion.';
}
}
var dialog_creator = function(name, text) { return function(e) {
var dialog = $('div#effort-dialog');
dialog.empty().append($('<div>' + effort_info + '</div>'));
dialog.dialog({
title: name + ' effort statistics',
position: { my: 'center', at: 'center', of: e } });
}; };
tde.on('click', dialog_creator(pool.dispname, effort_info));
tde.on('click', dialog_creator(pool.dispname + ' effort statistics', effort_info));
if (eff.pval < 0.05) {
tde.addClass('significant');
......@@ -222,7 +223,7 @@ function update_pools(data) {
tdfee.text(fee.toFixed(1) + ' *');
tdfee.attr('sortkey', fee);
tdfee.addClass('high').addClass('conf9999');
tdfee.on('click', dialog_creator(pool.dispname, effort_info));
tdfee.on('click', dialog_creator(pool.dispname + ' effort statistics', effort_info));
}
tde.attr("sortkey", eff.mean);
......@@ -242,6 +243,11 @@ function update_pools(data) {
td.attr("title", Math.round(avghr / total_hr * 10000) / 100.0 + '% of ' + d + '-day total pools average');
}
}
if ('warning' in pool && pool['warning']) {
let warning = $('<span class="warning"></span>');
warning.on('click', dialog_creator(pool.dispname + ' reported issues', pool['warning']));
row.find('td.name').append(' ').append(warning);
}
}
if (pool.desync) {
......
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