Skip to content

Commit

Permalink
Merge pull request #74 from pentium10/master
Browse files Browse the repository at this point in the history
enhanced memory/cpu usage
  • Loading branch information
pentium10 committed Sep 17, 2014
2 parents de0529d + 28f40bb commit 68d1ad6
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 159 deletions.
13 changes: 12 additions & 1 deletion lib/tpl/main.php
Expand Up @@ -169,7 +169,18 @@
<?php if (isset($_tplPage)): ?>
<?php include(dirname(__FILE__) . '/' . $_tplPage . '.php') ?>
<?php elseif (!$server): ?>
<?php include(dirname(__FILE__) . '/serversList.php') ?>
<div id="idServers">
<?php
include(dirname(__FILE__) . '/serversList.php');
?>
</div>
<div id="idServersCopy" style="display:none"></div>
<?php
if ($tplVars['_tplMain'] != 'ajax') {
require_once '../lib/tpl/modalAddServer.php';
require_once '../lib/tpl/modalFilterServer.php';
}
?>
<?php elseif (!$tube):
?>
<div id="idAllTubes">
Expand Down
37 changes: 37 additions & 0 deletions lib/tpl/modalAddServer.php
@@ -0,0 +1,37 @@
<div id="servers-add" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="servers-add-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="servers-add-labal">Add Server</h4>

</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="host">Host</label>

<div class="col-sm-10">
<input type="text" id="host" value="localhost" class="form-control">
</div>
</div>

<div class="form-group">
<label class="control-label col-sm-2" for="port">Port</label>

<div class="col-sm-10">
<input type="text" id="port" value="<?php echo Pheanstalk::DEFAULT_PORT ?>" class="form-control">
</div>
</div>


</form>
</div>
<div class="modal-footer">
<button class="btn btn-info">Add server</button>
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
</div>
</div>

</div>
49 changes: 49 additions & 0 deletions lib/tpl/modalFilterServer.php
@@ -0,0 +1,49 @@
<div id="filterServer" data-cookie="filter" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="servers-add-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="filter-label" class="text-info">Filter columns</h3>
</div>
<div class="modal-body">
<form class="form-group">
<div class="tabbable">
<ul class="nav nav-tabs">
<?php
$i = 0;
foreach ($console->getServerStatsGroups() as $groupName => $fields): $i++;
?>
<li <?php if ($i == 1) echo 'class="active"' ?>><a href="#<?php echo $groupName ?>" data-toggle="tab"><?php echo $groupName ?></a></li>
<?php endforeach ?>
</ul>
<div class="tab-content">
<?php
$i = 0;
foreach ($console->getServerStatsGroups() as $groupName => $fields): $i++;
?>
<div class="tab-pane <?php if ($i == 1) echo 'active' ?>" id="<?php echo $groupName ?>">
<?php foreach ($fields as $key => $description): ?>
<div class="control-group">
<div class="controls">
<div class="checkbox">
<label>
<input type="checkbox" name="<?php echo $key ?>" <?php if (in_array($key, $visible)) echo 'checked="checked"' ?>>
<b><?php echo $key ?></b>
<br/><?php echo $description ?>
</label>
</div>
</div>
</div>
<?php endforeach ?>
</div>
<?php endforeach ?>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
</div>
</div>
223 changes: 65 additions & 158 deletions lib/tpl/serversList.php
Expand Up @@ -16,83 +16,79 @@
);
}
?>
<div id="idServers">
<?php if (!empty($servers)): ?>
<div class="row">
<div class="col-sm-12">
<table class="table table-striped table-hover" id="servers-index">
<thead>
<?php if (!empty($servers)): ?>
<div class="row">
<div class="col-sm-12">
<table class="table table-striped table-hover" id="servers-index">
<thead>
<tr>
<th>name</th>
<?php foreach ($console->getServerStats(reset($servers)) as $key => $item): ?>
<th class="<?php if (!in_array($key, $visible)) echo 'hide' ?>" name="<?php echo $key ?>"
title="<?php echo $item['description'] ?>"><?php echo $key ?></th>
<?php endforeach ?>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
foreach (array_unique($servers) as $server):
$stats = $console->getServerStats($server);
?>
<tr>
<th>name</th>
<?php foreach ($console->getServerStats(reset($servers)) as $key => $item): ?>
<th class="<?php if (!in_array($key, $visible)) echo 'hide' ?>" name="<?php echo $key ?>"
title="<?php echo $item['description'] ?>"><?php echo $key ?></th>
<?php if (empty($stats)): ?>
<td><?php echo $server ?></td>
<?php else: ?>
<td><a href="?server=<?php echo $server ?>"><?php echo $server ?></a></td>
<?php endif ?>
<?php foreach ($stats as $key => $item): ?>
<td class="<?php if (!in_array($key, $visible)) echo 'hide' ?>"
name="<?php echo $key ?>"><?php echo htmlspecialchars($item['value']) ?></td>
<?php endforeach ?>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
foreach (array_unique($servers) as $server):
$stats = $console->getServerStats($server);
?>
<tr>
<?php if (empty($stats)): ?>
<td><?php echo $server ?></td>
<?php else: ?>
<td><a href="?server=<?php echo $server ?>"><?php echo $server ?></a></td>
<?php endif ?>
<?php foreach ($stats as $key => $item): ?>
<td class="<?php if (!in_array($key, $visible)) echo 'hide' ?>"
name="<?php echo $key ?>"><?php echo htmlspecialchars($item['value']) ?></td>
<?php endforeach ?>
<?php if (empty($stats)): ?>
<td colspan="<?php echo count($visible) ?>" class="row-full">&nbsp;</td>
<?php endif ?>
<td><?php if (array_intersect(array($server), $cookieServers)): ?>
<a class="btn btn-xs btn-danger" title="Remove from list" href="?action=serversRemove&removeServer=<?php echo $server ?>"><span
class="glyphicon glyphicon-minus"></span></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<a href="#servers-add" role="button" class="btn btn-info" id="addServer">Add server</a>
</div>
<td colspan="<?php echo count($visible) ?>" class="row-full">&nbsp;</td>
<?php endif ?>
<td><?php if (array_intersect(array($server), $cookieServers)): ?>
<a class="btn btn-xs btn-danger" title="Remove from list" href="?action=serversRemove&removeServer=<?php echo $server ?>"><span
class="glyphicon glyphicon-minus"></span></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<a href="#servers-add" role="button" class="btn btn-info" id="addServer">Add server</a>
</div>
<?php else: ?>
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="col-sm-8 col-sm-push-2 text-center">
<h1>Hello!</h1>

<p class="lead">
This is Beanstalk console,<br/>web-interface for
<a href="http://kr.github.io/beanstalkd/" target="_blank">simple and fast work queue</a>
</p>

<p>
Your servers' list is empty. You could fix it in two ways:
<ol class="inside">
<li>Click the button below to add server just for you and save it in cookies</li>
<li>Edit <b>config.php</b> file and add server for everybody</li>
</ol>
</p>
<p>
<br/><a href="#servers-add" role="button" class="btn btn-lg btn-success" data-toggle="modal">Add server</a>
</p>
</div>
</div>
<?php else: ?>
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="col-sm-8 col-sm-push-2 text-center">
<h1>Hello!</h1>

<p class="lead">
This is Beanstalk console,<br/>web-interface for
<a href="http://kr.github.io/beanstalkd/" target="_blank">simple and fast work queue</a>
</p>

<p>
Your servers' list is empty. You could fix it in two ways:
<ol class="inside">
<li>Click the button below to add server just for you and save it in cookies</li>
<li>Edit <b>config.php</b> file and add server for everybody</li>
</ol>
</p>
<p>
<br/><a href="#servers-add" role="button" class="btn btn-lg btn-success" data-toggle="modal">Add server</a>
</p>
</div>
</div>
</div>



<?php endif ?>
</div>
<div id="idServersCopy" style="display:none"></div>

<?php
endif;
if ($tplVars['_tplMain'] != 'ajax') {
$url = 'https://api.github.com/repos/ptrofimov/beanstalk_console/tags';
$ctx = stream_context_create(
Expand Down Expand Up @@ -120,94 +116,5 @@ class="glyphicon glyphicon-minus"></span></a>
<?php
}
}
?>


<div id="servers-add" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="servers-add-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="servers-add-labal">Add Server</h4>

</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="host">Host</label>

<div class="col-sm-10">
<input type="text" id="host" value="localhost" class="form-control">
</div>
</div>

<div class="form-group">
<label class="control-label col-sm-2" for="port">Port</label>

<div class="col-sm-10">
<input type="text" id="port" value="<?php echo Pheanstalk::DEFAULT_PORT ?>" class="form-control">
</div>
</div>


</form>
</div>
<div class="modal-footer">
<button class="btn btn-info">Add server</button>
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
</div>
</div>

</div>

<div id="filterServer" data-cookie="filter" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="servers-add-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="filter-label" class="text-info">Filter columns</h3>
</div>
<div class="modal-body">
<form class="form-group">
<div class="tabbable">
<ul class="nav nav-tabs">
<?php
$i = 0;
foreach ($console->getServerStatsGroups() as $groupName => $fields): $i++;
?>
<li <?php if ($i == 1) echo 'class="active"' ?>><a href="#<?php echo $groupName ?>" data-toggle="tab"><?php echo $groupName ?></a></li>
<?php endforeach ?>
</ul>
<div class="tab-content">
<?php
$i = 0;
foreach ($console->getServerStatsGroups() as $groupName => $fields): $i++;
?>
<div class="tab-pane <?php if ($i == 1) echo 'active' ?>" id="<?php echo $groupName ?>">
<?php foreach ($fields as $key => $description): ?>
<div class="control-group">
<div class="controls">
<div class="checkbox">
<label>
<input type="checkbox" name="<?php echo $key ?>" <?php if (in_array($key, $visible)) echo 'checked="checked"' ?>>
<b><?php echo $key ?></b>
<br/><?php echo $description ?>
</label>
</div>
</div>
</div>
<?php endforeach ?>
</div>
<?php endforeach ?>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
</div>
</div>
<?php } ?>
}
?>

0 comments on commit 68d1ad6

Please sign in to comment.