New pages to control generation queue

This commit is contained in:
Némunaire 2015-01-18 06:51:23 +01:00 committed by Nemunaire
parent 8b3d771fd1
commit 5836a3c3d8
6 changed files with 139 additions and 6 deletions

View File

@ -80,6 +80,27 @@ if ($n && $p[0] == SALT_ADMIN)
$page = require("admin/chrono.php");
break;
case "generation":
case "generation/":
case "generation/clear":
case "generation/clear/":
case "generation/custom":
case "generation/custom/":
case "generation/full":
case "generation/full/":
case "generation/freeze":
case "generation/freeze/":
case "generation/unfreeze":
case "generation/unfreeze/":
case "generation/nginx":
case "generation/nginx/":
case "generation/team":
case "generation/team/":
case "generation/sync":
case "generation/sync/":
$page = require("admin/generation.php");
break;
// Theme
case "themes":
case "themes/":

View File

@ -9,6 +9,7 @@
<var name="prefix_public">challenge-public</var>
<var name="prefix_teams">challenge</var>
<var name="prefix_admin">challenge-admin</var>
<var name="default_time">180</var>
<var name="chrono"><![CDATA[<!--Page générée en: $ secondes.-->]]></var>
</config>
<config match="*">

View File

@ -0,0 +1,51 @@
<?php
if(!defined('ONYX')) exit;
if (count($p) > 2)
{
switch($p[2])
{
case "custom":
if (!empty($_POST["cmds"]))
$ret = pipe_backend_scheduler($_POST["cmds"]);
break;
case "clear":
$ret = pipe_backend_scheduler("clear");
break;
case "full":
$ret = pipe_backend_scheduler("resetr:ERRORS:HOME:all:DS");
break;
case "freeze":
$ret = pipe_backend_scheduler("freeze");
break;
case "unfreeze":
$ret = pipe_backend_scheduler("unfreeze");
break;
case "nginx":
$ret = pipe_backend_scheduler("RTEAMS_NOWNOW");
break;
case "team":
if (!empty($_POST["team"]))
$ret = pipe_backend_scheduler("resetr:TEAM".intval($_POST["team"]).":SYNCS");
break;
case "sync":
$ret = pipe_backend_scheduler("SYNCSYNCSYNCSYNCSYNC");
break;
}
}
if (!empty($ret))
{
$template->assign("return", $ret);
return "admin/generation";
}
header("Location: /".SALT_ADMIN."/");
exit();

View File

@ -2,6 +2,8 @@
if(!defined('ONYX')) exit;
@$template->assign("DEF_TIME", $VAR['default_time']);
if (empty($VAR['misc_dir']))
{
erreur("Please add <var>misc_dir</var> variable into <code>root.xml</code> configuration.");
@ -10,10 +12,7 @@ if (empty($VAR['misc_dir']))
$misc_dir = $VAR['misc_dir'];
if (!is_dir("$misc_dir/shared") || !is_writable("$misc_dir/shared"))
{
erreur("<code>$misc_dir/shared/</code> directory not writable.");
return "admin/home";
}
$template->assign("cert_writable", is_writable("$misc_dir/shared/") && is_writable("$misc_dir/PKI/"));
@ -37,4 +36,10 @@ if (file_exists($srv_file))
openssl_x509_parse(file_get_contents($srv_file)));
}
/* GENERATION */
$queue = explode("\n", pipe_backend_scheduler("show"));
unset($queue[0], $queue[1]);
$template->assign("queue", array_filter($queue, function($var){ return !empty($var); }));
return "admin/home";

View File

@ -0,0 +1,10 @@
{extends file="admin/layout.tpl"}
{block name=content}
<h1>
Génération
</h1>
{if isset($return)}
<h2>Sortie</h2>
<pre>{$return|escape}</pre>
{/if}
{/block}

View File

@ -16,7 +16,7 @@
</ul>
<a href="/{$SALT_ADMIN}/certificate/deleteca" class="btn btn-danger"
onclick="return confirm('Êtes-vous sûr de vouloir supprimer ce certificat ?')">Supprimer</a>
{elseif ! $cert_writable}
{elseif empty($cert_writable)}
<div class="alert alert-danger"><span class="glyphicon glyphicon-warning-sign"></span> Répertoire non accessible en écriture.</div>
<a href="/{$SALT_ADMIN}/certificate/newca" class="btn btn-primary" disabled="disabled">Nouveau</a>
{else}
@ -41,7 +41,7 @@
</ul>
<a href="/{$SALT_ADMIN}/certificate/revokesrv" class="btn btn-danger"
onclick="return confirm('Êtes-vous sûr de vouloir supprimer ce certificat ?')">Supprimer</a>
{elseif ! $cert_writable}
{elseif empty($cert_writable)}
<div class="alert alert-danger"><span class="glyphicon glyphicon-warning-sign"></span> Répertoire non accessible en écriture.</div>
<a href="/{$SALT_ADMIN}/certificate/newsrv" class="btn btn-primary" disabled="disabled">Nouveau</a>
{else}
@ -62,7 +62,7 @@
<div class="form-group">
<label class="sr-only" for="time">Temps :</label>
<div class="input-group">
<input type="input" class="form-control" id="time" name="time" value="240">
<input type="input" class="form-control" id="time" name="time" value="{$DEF_TIME|default:240}">
<span class="input-group-addon">minutes</span>
</div>
</div>
@ -73,4 +73,49 @@
</form>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Génération</h3>
</div>
<div class="panel-body container">
<div class="col-xs-4">
<table class="table table-hover table-striped">
<thead>
<tr>
<th>File d'attente</th>
</tr>
</thead>
<tbody>
{foreach from=$queue item=itm key=k}
<tr>
<td{if $k == 2} class="{if $itm == "empty!"}warning{else}success{/if}"{/if}>
{$itm}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="col-xs-4">
<a href="/{$SALT_ADMIN}/generation/full" class="btn btn-default">Tout regénérer</a>
<a href="/{$SALT_ADMIN}/generation/sync" class="btn btn-default">Synchro légère</a><br>
<a href="/{$SALT_ADMIN}/generation/clear" class="btn btn-danger">Vider la file d'attente</a><br>
<a href="/{$SALT_ADMIN}/generation/freeze" class="btn btn-danger">Freeze</a>
<a href="/{$SALT_ADMIN}/generation/unfreeze" class="btn btn-success">Unfreeze</a>
<form method="post" action="/{$SALT_ADMIN}/generation/team" role="form" class="form-inline">
<div class="form-group">
<input type="input" class="form-control" id="regenteam" name="team" placeholder="Team to regen">
<button type="submit" class="btn btn-primary">Regénérer</button>
</div>
</form>
<form method="post" action="/{$SALT_ADMIN}/generation/custom" role="form" class="form-inline">
<div class="form-group">
<input type="input" class="form-control" id="cmds" name="cmds" placeholder="Custom commands, : separated">
<button type="submit" class="btn btn-warning">Envoyer</button>
</div>
</form>
</div>
</div>
</div>
{/block}