summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-07-13 16:26:49 -0400
committerEudyptula <eitan@mosenkis.net>2009-07-13 16:26:49 -0400
commit2f63d9014665451e87d669ee14a8be9308e91856 (patch)
tree016c06c4683086e94602a4480b97ae730c232eec
parentAdded data verification to config wizard API (diff)
downloadingenue-2f63d9014665451e87d669ee14a8be9308e91856.tar.gz
ingenue-2f63d9014665451e87d669ee14a8be9308e91856.tar.bz2
ingenue-2f63d9014665451e87d669ee14a8be9308e91856.zip
Added 'Show checked' link for package adder, fixed package selector verification, added basic verification frontend
-rw-r--r--frontend/classes/wizard_api.php10
-rw-r--r--frontend/js/wlca.js26
-rw-r--r--frontend/pages/configurations/manager.php6
-rw-r--r--frontend/pages/configurations/verifier.php39
-rw-r--r--frontend/pages/configurations/wizard.php4
-rw-r--r--frontend/routing.csv1
6 files changed, 73 insertions, 13 deletions
diff --git a/frontend/classes/wizard_api.php b/frontend/classes/wizard_api.php
index c0d91b0..48fe637 100644
--- a/frontend/classes/wizard_api.php
+++ b/frontend/classes/wizard_api.php
@@ -259,7 +259,9 @@ class wizard_layered_checkbox_array extends wizard_checkbox_array {
public function verify() {
if (($vals=self::get_opt($this->optname)) === null) return false;
$vals=explode($this->delim, $vals);
- return count($this->r_verify($vals, $this->array)) == 0;
+ $r=$this->r_verify($vals, $this->array);
+ debug('wlca', 'got results: '.implode(' ',$r));
+ return count($r) == 0;
}
private function r_output(&$array, $depth=0, $path=null, $name=null) {
static $uid=0, $ucid=0;
@@ -279,7 +281,7 @@ class wizard_layered_checkbox_array extends wizard_checkbox_array {
if (!isset($conf['id'])) {
$conf['id']=self::b36($uid++);
}
- echo 'Search: <input id="'.$conf['id'].'-q" onkeyup="wlca_search(this.value, document.getElementById(\''.$conf['id'].'\'), 0, '.$this->depth.')" /> <a href="javascript:q=document.getElementById(\''.$conf['id'].'-q\'); q.value=\'\'; q.onkeyup()">Clear</a><br/>'."\n";
+ echo 'Search: <input id="'.$conf['id'].'-q" onkeyup="wlca_search(this.value, document.getElementById(\''.$conf['id'].'\'), 0, '.$this->depth.')" /> <a href="javascript:q=document.getElementById(\''.$conf['id'].'-q\'); q.value=\'\'; q.onkeyup()">Clear</a> <a href="javascript:wlca_show_checked(document.getElementById(\''.$conf['id'].'\'), 0, '.$this->depth.'); undefined">Show checked</a><br/>'."\n";
}
echo '<div class="wlca'.(isset($conf['autosize'])?' autosize" style="font-size: '.pow(1.15, $autosize)*100.0.'%':'').'" id="'.$conf['id'].'">'."\n";
foreach ($array as $name => &$val) {
@@ -287,7 +289,7 @@ class wizard_layered_checkbox_array extends wizard_checkbox_array {
$uid++;
}
echo '</div>';
- echo "<script type=\"text/javascript\">\n<!--\nwlca_search(document.getElementById('{$conf['id']}-q').value, document.getElementById('{$conf['id']}'), 0, $this->depth);\n-->\n</script>\n";
+ echo "<script type=\"text/javascript\">\n<!--\nif (wlca_show_checked(document.getElementById('{$conf['id']}'), 0, $this->depth) == 0) wlca_search(document.getElementById('{$conf['id']}-q').value, document.getElementById('{$conf['id']}'), 0, $this->depth);\n-->\n</script>\n";
} else {
$meta=$this->metadata[$depth];
if (isset($meta['tag'])) {
@@ -346,7 +348,7 @@ class wizard_layered_checkbox_array extends wizard_checkbox_array {
$meta=$this->metadata[$depth];
if (isset($meta['checkbox'])) {
$label=$this->format_label($array, $meta['checkbox'], $path, $name);
- if ($i=array_search($label, $vals) !== false) {
+ if (($i=array_search($label, $vals)) !== false) {
unset($vals[$i]);
}
}
diff --git a/frontend/js/wlca.js b/frontend/js/wlca.js
index 942300c..d62994b 100644
--- a/frontend/js/wlca.js
+++ b/frontend/js/wlca.js
@@ -4,7 +4,7 @@ var wlca_found_last;
function wlcat(id, set) { // Short for 'toggle'
tag=document.getElementById(id);
for (var i=1; i<tag.childNodes.length; i++) {
- if (tag.childNodes[i].className && tag.childNodes[i].className.match(/wlcae/)) {
+ if (tag.childNodes[i].className && tag.childNodes[i].className.indexOf('wlcae') != -1) {
if (typeof(set) == 'undefined') {
set=tag.childNodes[i].style.display=="none"?"":"none";
}
@@ -35,21 +35,39 @@ function wlca_search(q, el, depth, maxdepth, t) {
}
var found=0;
for (var i=0; i<el.childNodes.length; i++) {
- if (el.childNodes[i].nodeName == "LABEL" || (el.childNodes[i].className && el.childNodes[i].className.match(/wlcal/))) {
+ if (el.childNodes[i].nodeName == "LABEL" || (el.childNodes[i].className && el.childNodes[i].className.indexOf('wlcal') != -1)) {
found+=(el.childNodes[i].innerHTML.indexOf(q) == -1?0:1);
break;
}
}
if (depth < maxdepth) {
for (var i=0; i<el.childNodes.length; i++) {
- if (!(el.childNodes[i].className && el.childNodes[i].className.match(/wlcae/))) continue;
+ if (!(el.childNodes[i].className && el.childNodes[i].className.indexOf('wlcae') != -1)) continue;
var lfound=wlca_search(q, el.childNodes[i], depth+1, maxdepth, true);
found+=lfound;
el.childNodes[i].style.display=(q.length == 0 || lfound > 0?"":"none");
}
- if (q.length == 0 && el.className.match(/wlcac/)) {
+ if (q.length == 0 && el.className.indexOf('wlcac') != -1) {
wlca_collapse(el.id);
}
}
return found;
}
+function wlca_show_checked(el, depth, maxdepth) {
+ if (depth == 0) {
+ wlca_last_search=undefined;
+ }
+ var found=0;
+ for (var i=0; i<el.childNodes.length; i++) {
+ if (el.childNodes[i].nodeName == "INPUT" && el.childNodes[i].type == "checkbox" && el.childNodes[i].checked) {
+ found++;
+ }
+ if (depth < maxdepth) {
+ if (!(el.childNodes[i].className && el.childNodes[i].className.indexOf('wlcae') != -1)) continue;
+ var lfound=wlca_show_checked(el.childNodes[i], depth+1, maxdepth);
+ found+=lfound;
+ el.childNodes[i].style.display=(lfound > 0?"":"none");
+ }
+ }
+ return found;
+}
diff --git a/frontend/pages/configurations/manager.php b/frontend/pages/configurations/manager.php
index aef03d1..15ab529 100644
--- a/frontend/pages/configurations/manager.php
+++ b/frontend/pages/configurations/manager.php
@@ -23,7 +23,7 @@ function body_configurations_manager() {
echo print_success('Submitted for build - <a href="'.url('logs/'.$build->id).'">Logs</a>');
}
}
- echo '<form action="'.url('configurations').'" method="post"><table><tr><th>ID</th><th>Name</th>'.(count(explode(' ', $conf['modules'])) > 1?'<th>Module</th>':'').'<th>Status</th><th>Options</th><th>Builds</th></tr>'."\n";
+ echo '<form action="'.url('configurations').'" method="post"><table><tr><th>ID</th><th>Name</th>'.(count($conf['modules']) > 1?'<th>Module</th>':'').'<th>Status</th><th>Options</th><th>Builds</th></tr>'."\n";
$ready=0;
while($c=$r->fetch(PDO::FETCH_ASSOC)) {
$c=new sql_configuration($c);
@@ -35,13 +35,13 @@ function body_configurations_manager() {
echo $c->id;
}
echo '</td><td>'.(isset($c->name) && strlen($c->name)?htmlentities($c->name):'<i>Unnamed</i>').'</td><td>';
- if (count(explode(' ', $conf['modules'])) > 1) {
+ if (count($conf['modules']) > 1) {
echo "$c->module</td><td>";
}
if ($c->status > 0) {
echo '<a href="'.url("config/$c->id")."\">Step $c->status</a>'";
} elseif ($c->status == 0) {
- echo '<b>Ready</b>';
+ echo '<b>Ready</b> (<a href="'.url('verify/'.$c->id).'">verify</a>)';
} else {
echo $c->status;
}
diff --git a/frontend/pages/configurations/verifier.php b/frontend/pages/configurations/verifier.php
new file mode 100644
index 0000000..ae27c3c
--- /dev/null
+++ b/frontend/pages/configurations/verifier.php
@@ -0,0 +1,39 @@
+<?php
+function init_configurations_verifier() {
+ global $S, $request;
+ if (!isset($S['user'])) {
+ return 'login';
+ }
+ if (!(isset($request['configuration']) && strlen($request['configuration']) == 6 && ctype_alnum($request['configuration']))) {
+ return '404';
+ }
+ $r=$S['pdo']->query('SELECT * FROM `configurations` WHERE `id`=\''.$request['configuration'].'\'');
+ if ($r->rowCount() == 0) {
+ return '404';
+ }
+ $S['verifier']['configuration']=new sql_configuration($r->fetch(PDO::FETCH_ASSOC));
+ if ($S['verifier']['configuration']->owner != $S['user']->id) {
+ return '404';
+ }
+ return array('title' => 'Verify');
+}
+function body_configurations_verifier() {
+ global $S;
+ $c=&$S['verifier']['configuration'];
+ wizard::set_configuration($c);
+ $module=new module($c->module);
+ $status=true;
+ echo '<ol>';
+ for ($i=1; $i<=$module->steps; $i++) {
+ echo '<li>';
+ if ($status) {
+ $step=new wizard_step($c->module, $i);
+ $status=$status && ($r=$step->verify());
+ echo $r?'Valid':'INVALID';
+ } else {
+ echo 'Unavailable';
+ }
+ echo '</li>';
+ }
+}
+?>
diff --git a/frontend/pages/configurations/wizard.php b/frontend/pages/configurations/wizard.php
index 9a2b5d4..571f803 100644
--- a/frontend/pages/configurations/wizard.php
+++ b/frontend/pages/configurations/wizard.php
@@ -6,11 +6,11 @@ function init_configurations_wizard() {
}
if (isset($request['configuration']) && strlen($request['configuration']) == 6 && ctype_alnum($request['configuration'])) {
$S['wizard']['configuration']=new sql_configuration($request['configuration']);
- wizard::set_configuration($S['wizard']['configuration']);
$configuration=&$S['wizard']['configuration'];
if ($configuration->owner != $S['user']->id) {
return '404';
}
+ wizard::set_configuration($S['wizard']['configuration']);
if (isset($request['wizard_submit'])) {
$steps=array_keys($request['wizard_submit']);
$step=$steps[0];
@@ -35,7 +35,7 @@ function init_configurations_wizard() {
}
} elseif (isset($request['init'])) {
$S['wizard']['configuration']=new sql_configuration();
- wizard::set_configuration($S['wizard']['configuration']);
+ wizard::set_configuration($S['wizard']['configuration']);
$configuration=&$S['wizard']['configuration'];
$configuration->name=$request['name'];
$mod=isset($request['mod']) && isset($conf['modules'][$request['mod']])?$conf['modules'][$request['mod']]:$conf['modules'][0];
diff --git a/frontend/routing.csv b/frontend/routing.csv
index 1455cf7..492e59e 100644
--- a/frontend/routing.csv
+++ b/frontend/routing.csv
@@ -22,6 +22,7 @@
^config/([a-zA-Z0-9]{6})$ configurations/wizard configuration
^config/([a-zA-Z0-9]{6})/([0-9]+)$ configurations/wizard configuration step
^configurations$ configurations/manager
+^verify/([a-zA-Z0-9]{6})$ configurations/verifier configuration
# Download finished image
^download/([a-zA-Z0-9]{6})$ downloadimage build
# Session