Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix/rigs-adding-pools

priority now changes based on what inputted
  • Loading branch information...
Stoyvo committed Jan 27, 2015
1 parent 5d3c53a commit 5df7941f73d3837c20e8f32546aa449e2124c252
Showing with 82 additions and 48 deletions.
  1. +5 −0 css/cryptoglance-base.css
  2. +36 −38 includes/classes/miners/cgminer.php
  3. +9 −6 includes/classes/update.php
  4. +29 −4 js/rig/script.js
  5. +3 −0 rig.php
@@ -579,6 +579,11 @@ input.form-control, select.form-control, textarea.form-control, .modal-body inpu
margin: 13px 0px 10px;
}

.table-pools td a.poolGrip,
.table-pools td a.poolGrip span,
.table-pools td a.poolGrip span i {
cursor: move;
}
.table-pools td a {
cursor: pointer;
}
@@ -194,7 +194,7 @@ public function devices() {
public function pools() {
$pools = array();
foreach ($this->_pools as $pool) {
$pools[] = array(
$pools[$pool['Priority']] = array(
'id' => $pool['POOL'],
'status' => ($pool['Status'] == 'Alive') ? 1 : 0,
'active' => ($pool['POOL'] == $this->_activePool['id']) ? 1 : 0,
@@ -204,6 +204,8 @@ public function pools() {
);
}
ksort($pools);
return $pools;
}
@@ -228,57 +230,48 @@ public function removePool($poolId) {
}
public function addPool($values) {
if (count($values) > 3) {
array_splice($values, 3);
}
$poolPriority = end($values);
array_pop($values);
$this->cmd('{"command":"addpool","parameter":"'. implode(',', $values) .'"}');
// Now prioritize
$this->fetchPools();
$pools = $this->_pools;
$currentPool = end($pools);
$poolId = $currentPool['POOL'];
return $this->cmd('{"command":"addpool","parameter":"'. implode(',', $values) .'"}');
$this->prioritizePools($poolPriority, $poolId);
return;
}
public function editPool($poolId, $values) {
$poolPriority = end($values);
array_pop($values);
$this->removePool($poolId);
$this->addPool($values);
$this->fetchPools(); // Update our collection of pools
$this->prioritizePools($poolPriority, null);
return;
}
public function prioritizePools($poolPriority, $poolId = null) {
$this->fetchPools();
if (!is_null($poolId)) {
foreach ($this->_pools as $pKey => $pool) {
if ($pool['POOL'] == $poolId) {
$poolIndex = $pKey;
break;
}
public function prioritizePools($poolPriority, $poolId) {
foreach ($this->_pools as $key => $pool) {
if ($pool['POOL'] == $poolId) {
$this->_pools[$poolId]['Priority'] = $poolPriority;
break;
}
} else {
$pools = $this->_pools;
end($pools);
$poolIndex = key($pools);
}
$newPools = array();
$poolIdCollection = array();
foreach ($this->_pools as $pKey => $pool) {
if ($pKey == $poolIndex) {
continue;
} else {
if ($pKey == $poolPriority) {
$newPools[] = $this->_pools[$poolIndex];
$poolIdCollection[] = $this->_pools[$poolIndex]['POOL'];
}
$newPools[] = $pool;
$poolIdCollection[] = $pool['POOL'];
}
usort($this->_pools, array('Miners_Cgminer','prioritySort'));
$priorityList = array();
foreach ($this->_pools as $key => $pool) {
$priorityList[] = $pool['POOL'];
}
$this->_pools = $newPools;
$this->getActivePool();
$this->cmd('{"command":"poolpriority","parameter":"'. implode(',', $priorityList) .'"}');
$this->fetchPools();
return $this->cmd('{"command":"poolpriority","parameter":"'. implode(',', $poolIdCollection) .'"}');
return;
}
@@ -614,7 +607,7 @@ private function fetchPools() {
/* Private functions for independant product types. EG: Bitmain */
public function _checkBitmain() {
private function _checkBitmain() {
if (!empty($this->_eStats)) {
foreach ($this->_eStats as $eStats) {
// if a bitmain asic has an 'x' in it's data, that means an asic chip has failed
@@ -627,4 +620,9 @@ public function _checkBitmain() {
}
}
}
/* Private functions for things such as sorting */
private function prioritySort($a,$b) {
return ($a['Priority'] < $b['Priority']) ? -1 : 1;
}
}
@@ -1,5 +1,7 @@
<?php
// Is this used anymore?
/*
* @author Stoyvo
*/
@@ -11,22 +13,23 @@ public function all() {
echo json_encode($data);
}
public function pool() {
$data['pools'] = $this->getPools(intval($_GET['attr']));
echo json_encode($data);
}
public function addConfig() {
if (isset($_POST['type'])) {
$action = 'add' . ucwords(strtolower($_POST['type']));
require_once(dirname(__FILE__).'/../cryptoglance.php');
$cryptoglance = new CryptoGlance();
$cryptoglance->$action();
}
}
public function editConfig() {
if (isset($_POST['type'])) {
$action = 'edit' . ucwords(strtolower($_POST['type']));
@@ -35,7 +38,7 @@ public function editConfig() {
$cryptoglance->$action();
}
}
public function removeConfig() {
if (isset($_POST['type'])) {
$action = 'remove' . ucwords(strtolower($_POST['type']));
@@ -49,7 +52,7 @@ public function removeConfig() {
private function getPools($poolId = null) {
$pools = new Pools();
$data = $pools->update($poolId);
return $data;
}
@@ -105,7 +105,7 @@
evt.preventDefault()

var $tr = $(this).parents('tr');
var $td = $tr.children().slice(1, 5);
var $td = $tr.children().slice(2, 6);

$td.each(function(){
var elmText = $('span', this);
@@ -131,7 +131,7 @@
var $_self = $(this);

var $tr = $(this).parents('tr');
var $inputs = $tr.children().slice(1, 5).find('input');
var $inputs = $tr.children().slice(2, 6).find('input');
var values = {};
var ridId = $('#rig-wrap').attr('data-rigId');
var poolId = $tr.attr('data-id');
@@ -175,7 +175,7 @@
evt.preventDefault();

var $tr = $(this).parents('tr');
var $inputs = $tr.children().slice(1, 5).find('input');
var $inputs = $tr.children().slice(2, 6).find('input');
var values = {};
var ridId = $('#rig-wrap').attr('data-rigId');

@@ -205,7 +205,7 @@
evt.preventDefault()

var $tr = $(this).parents('tr');
var $td = $tr.children().slice(1, 5);
var $td = $tr.children().slice(2, 6);

// Turn inputs into hidden, set input value from span value
$td.each(function(){
@@ -230,6 +230,7 @@
evt.preventDefault()

var $tr = $(this).parents('tr');
var $table = $tr.parent();
var ridId = $('#rig-wrap').attr('data-rigId');
var poolId = $tr.attr('data-id');

@@ -246,6 +247,13 @@
})
.done(function (data) {
$tr.remove();
$('tr', $table).each(function(k, v) {
if ($(this).attr('data-id') > poolId) {
$(this).find('td[data-type="priority"] span').text(k);
$(this).attr('data-id', ($(this).attr('data-id')-1));
}
$(this).find('td[data-type="priority"] input').val(k);
});
});
})

@@ -269,6 +277,23 @@
});
});

$( "#rigDetails .table-pools tbody" ).sortable({
items: 'tr:not(:last)',
placeholder: "placeholder",
opacity: 0.75,
scrollSpeed: 70,
handle: '.poolGrip',
containment: 'parent',
forcePlaceholderSize: true,
scroll: true,
scrollSensitivity: 100,
update: function(event, ui) {
// var cooked = [];
// $("#dashboard-wrap:not(.login-container)").each(function(index, domEle){ cooked[index]= $(domEle).sortable('toArray');});
// $.cookie('cookie_dashboard_layout', 'x'+cooked.join('|'), { expires: 365, path: '/'});
}
}).disableSelection();

/*----- End of Pools ------*/

/*=============================================
@@ -285,6 +285,7 @@
<table class="table table-hover table-striped table-pools">
<thead>
<tr>
<th></th>
<th>Active</th>
<th>Pool URL</th>
<th>Worker</th>
@@ -298,6 +299,7 @@
foreach ($rigPools as $pool) {
?>
<tr data-id="<?php echo $pool['id']; ?>">
<td><a class="poolGrip"><span class="grey"><i class="icon icon-braillespace"></i></span></a></td>
<td><input type="checkbox" class="form-control poolActive" <?php echo ($pool['status'] == 1) ? 'checked' : ''; ?> /></td>
<td data-type="url">
<span><?php echo $pool['url']; ?></span>
@@ -322,6 +324,7 @@
</tr>
<?php } ?>
<tr>
<td></td>
<td></td>
<td data-type="url">
<input type="text" placeholder="Pool URL" name="pools[new][url]" class="form-control" />

0 comments on commit 5df7941

Please sign in to comment.
You can’t perform that action at this time.