Skip to content

Commit 0241f6c

Browse files
web: web-based job submission changes
General goal: provide volunteers with more information about apps, in particular BUDA science apps. Terminology: 'remote apps' are those for which jobs are submitted via web RPCs, or web forms, or both. We use user-level permissions for these apps. - If a project has remote apps, it must create a PHP file html/project/remote_apps.inc that creates a data structure $remote_apps describing these apps. In the case of non-BUDA apps, these include long name, description text, URL, and science keywords. (This replaces $web_apps, which was in project.inc) - BUDA apps now have a JSON description file containing - short and long names - description - science keywords - URL of a page describing the app - user ID of creator - create time - Added web interface for creating/editing the above - A new page 'show_apps.php' shows remote apps and BUDA apps, including the above details. TODO in a later PR: get info for job submitters, including location keywords and what apps they can submit to
1 parent 0c6f8c1 commit 0241f6c

File tree

6 files changed

+362
-104
lines changed

6 files changed

+362
-104
lines changed

html/inc/bootstrap.inc

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,7 @@ function sample_navbar(
194194
$x[] = ["File sandbox", "sandbox.php"];
195195
$x[] = ["Submit jobs", $url_prefix."submit.php"];
196196
$x[] = ["Job status", $url_prefix."submit.php?action=status"];
197-
$is_admin = $user_submit->manage_all;
198-
if (!$is_admin) {
199-
$usas = BoincUserSubmitApp::enum("user_id=$user->id");
200-
foreach ($usas as $usa) {
201-
if ($usa->manage) {
202-
$is_admin = true;
203-
break;
204-
}
205-
}
206-
}
207-
if ($is_admin) {
197+
if ($user_submit->manage_all) {
208198
$x[] = ["Administer", $url_prefix."submit.php?action=admin"];
209199
}
210200
navbar_menu(tra("Job submission"), $x);
@@ -387,7 +377,8 @@ function form_input_textarea($label, $name, $value='', $nrows=4) {
387377
);
388378
}
389379

390-
// $items is either a string of <option> elements, or an array
380+
// $items is either a string of <option> elements,
381+
// or an array of [value, name] pairs
391382
//
392383
function form_select($label, $name, $items, $selected=null) {
393384
echo sprintf('
@@ -542,7 +533,7 @@ function form_checkbox($label, $name, $checked=false) {
542533
);
543534
}
544535

545-
// 'select2' is replacement for select boxed:
536+
// 'select2' is replacement for multiple select with a nicer UI:
546537
// https://github.com/select2/select2
547538
//
548539
// To use it you must use this version of page_head():
@@ -562,7 +553,7 @@ function page_head_select2($title) {
562553
}
563554

564555
// show a multi-select using select2.
565-
// $items is a list of [val, label] pairs;
556+
// $items is a list of [value, name] pairs;
566557
// $selected is the list of selected values.
567558
// $extra is e.g. id=foo
568559
//

html/inc/buda.inc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
$buda_root = "../../buda_apps";
4+
5+
function get_buda_apps() {
6+
global $buda_root;
7+
$apps = [];
8+
$x = scandir($buda_root);
9+
foreach ($x as $app) {
10+
if ($app[0] == '.') continue;
11+
if (!is_dir("$buda_root/$app")) continue;
12+
$apps[] = $app;
13+
}
14+
return $apps;
15+
}
16+
17+
function get_buda_variants($app_name) {
18+
global $buda_root;
19+
$x = [];
20+
$pcs = scandir("$buda_root/$app_name");
21+
foreach ($pcs as $pc) {
22+
if ($pc[0] == '.') continue;
23+
if ($pc == 'desc.json') continue;
24+
$x[] = $pc;
25+
}
26+
return $x;
27+
}
28+
29+
function get_buda_desc($app) {
30+
global $buda_root;
31+
$path = "$buda_root/$app/desc.json";
32+
return json_decode(file_get_contents($path));
33+
}
34+
35+
?>

html/inc/keywords.inc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,54 @@ keyword('KW_AMERICAS', KW_CATEGORY_LOC, 0, 0,
303303
keyword('KW_UND', KW_CATEGORY_LOC, 2, KW_US,
304304
'University of North Dakota'
305305
);
306+
307+
// return a list of [value, name] pairs for the given category
308+
//
309+
function keyword_select_options($category) {
310+
global $job_keywords;
311+
$opts = [];
312+
kw_children();
313+
foreach ($job_keywords as $id=>$k) {
314+
if ($k->category != $category) continue;
315+
if ($k->parent) continue;
316+
$opts = array_merge($opts, kw_options($id));
317+
}
318+
return $opts;
319+
}
320+
321+
function kw_children() {
322+
global $job_keywords;
323+
foreach ($job_keywords as $id=>$k) {
324+
$job_keywords[$id]->children = array();
325+
$job_keywords[$id]->expand = 0;
326+
}
327+
foreach ($job_keywords as $id=>$k) {
328+
if (!$k->parent) continue;
329+
$job_keywords[$k->parent]->children[] = $id;
330+
}
331+
}
332+
333+
function kw_options($id, $indent='') {
334+
global $job_keywords;
335+
$kw = $job_keywords[$id];
336+
$opts = [[$id, "$indent$kw->name"]];
337+
$indent .= '&nbsp;&nbsp;&nbsp;&nbsp;';
338+
foreach ($kw->children as $k) {
339+
$opts = array_merge($opts, kw_options($k, $indent));
340+
}
341+
return $opts;
342+
}
343+
344+
function kw_id_to_name($id) {
345+
global $job_keywords;
346+
$kw = $job_keywords[$id];
347+
return $kw->name;
348+
}
349+
350+
function kw_array_to_str($kws) {
351+
$x = array_map('strval', $kws);
352+
$x = array_map('kw_id_to_name', $x);
353+
return implode('<br>', $x);
354+
}
355+
306356
?>

0 commit comments

Comments
 (0)