Skip to content

Commit a4ede2c

Browse files
committed
WebApp Installer: Added app wizzard form page. Supports input types: text,password,dropdown
Generate dynamic forms for options configured in app definition class
1 parent cadc568 commit a4ede2c

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

web/js/pages/setup_webapp.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function randomString(target) {
2+
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
3+
var string_length = 16;
4+
var randomstring = '';
5+
for (var i = 0; i < string_length; i++) {
6+
var rnum = Math.floor(Math.random() * chars.length);
7+
randomstring += chars.substr(rnum, 1);
8+
}
9+
document.getElementById(target).value = randomstring;
10+
}
11+
12+
$(document).ready(function() {
13+
14+
});
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<div class="l-center edit">
2+
<div class="l-sort clearfix">
3+
<div class="l-unit-toolbar__buttonstrip">
4+
<a class="ui-button cancel" id="btn-back" href="/add/webapp/?domain=<?=$v_domain?>"><i class="fas fa-arrow-left status-icon blue"></i> <?=__('Back')?></a>
5+
</div>
6+
<div class="l-unit-toolbar__buttonstrip float-right">
7+
<?php
8+
if (!empty($_SESSION['error_msg'])) {
9+
echo "<span class=\"vst-error\"> → ".htmlentities($_SESSION['error_msg'])."</span>";
10+
} else {
11+
if (!empty($_SESSION['ok_msg'])) {
12+
echo "<span class=\"vst-ok\"> → ".$_SESSION['ok_msg']."</span>";
13+
}
14+
}
15+
?>
16+
<a href="#" class="ui-button" title="<?=__('Install')?>" data-action="submit" data-id="vstobjects"><i class="fas fa-save status-icon purple"></i> <?=__('Install')?></a>
17+
</div>
18+
</div>
19+
</div>
20+
21+
<div class="l-separator"></div>
22+
<!-- /.l-separator -->
23+
24+
<div class="l-center animated fadeIn" style="padding-top:240px;">
25+
<?php
26+
$back = $_SESSION['back'];
27+
if (empty($back)) {
28+
$back = "location.href='/list/web/'";
29+
} else {
30+
$back = "location.href='".$back."'";
31+
}
32+
?>
33+
34+
<?php if( !empty($WebappInstaller->getOptions())): ?>
35+
36+
<form id="vstobjects" method="POST" name="v_setup_webapp" style="padding-top:0px;" >
37+
<input type="hidden" name="token" value="<?=$_SESSION['token']?>" />
38+
<input type="hidden" name="ok" value="true" />
39+
<div class="app-form" >
40+
<?php foreach ($WebappInstaller->getOptions() as $form_name => $form_control):?>
41+
<?php
42+
$f_name = $WebappInstaller->formNs() . '_' . $form_name;
43+
$f_type = $form_control;
44+
$f_value = '';
45+
$f_label = ucwords(str_replace('.', ' ', $form_name));
46+
if (is_array($form_control)) {
47+
$f_type = (!empty($form_control['type']))?$form_control['type']:'text';
48+
$f_value = (!empty($form_control['value']))?$form_control['value']:'';
49+
}
50+
51+
$f_value = htmlentities($f_value);
52+
$f_label = htmlentities($f_label);
53+
?>
54+
<div class="form-control">
55+
<label for="<?=$f_name?>"><?=$f_label?>
56+
<?php if ($f_type === 'password'):?>
57+
/ <a href="javascript:randomString('<?=$f_name?>');" class="generate" ><?php print __('generate')?></a>
58+
<?php endif?>
59+
</label>
60+
<p>
61+
<?php if (in_array($f_type, ['select']) && count($form_control['options']) ):?>
62+
<select class="vst-list" name="<?=$f_name?>">
63+
<?foreach ($form_control['options'] as $option):?>
64+
<?php $selected = (!empty($form_control['value']) && $option === $form_control['value'])?'selected':''?>
65+
<option value="<?=$option?>" <?=$selected?> ><?=htmlentities($option)?></option>
66+
<?endforeach?>
67+
</select>
68+
<?php else:?>
69+
<input type="text" size="20" class="vst-input" name="<?=$f_name?>" id="<?=$f_name?>" value="<?=$f_value?>">
70+
<?php endif?>
71+
72+
</p>
73+
</div>
74+
<?php endforeach; ?>
75+
76+
</div>
77+
</form>
78+
79+
<?php endif ?>
80+
</div>

0 commit comments

Comments
 (0)