Form
You can easily create dedicated web forms.
sudo /usr/local/small-shell/adm/gen -app
Type of App (1.BASE | 2.FORM | 3.CUSTOM): 2
# Dialog will be started, You can define keys which will be inserted to the form in the dialog.
Scenario
Here is an example of creating survey form and analyzing result.
- Create Databox for survey
- Create survey form for end user
- Analyze survey result with graph
Required
Please set up Base App beforehand, referring to the Quick start guide.
Create a Databox
For the first step, need to create survey databox to push data through form.
sudo /usr/local/small-shell/adm/gen -databox
Databox Name: survey.box
Note
For using form, primary key of the databox must be "hashid". Please set hashid in the dialog as following.
>> primary_key(col1): hashid
Result of dialog
Databox Name:survey.box
#primary_key
name="hashid"
label="#ID"
type="text"
option="required"
#key(col2)
name="impression"
label="Impression of this product"
type="radio"
params="Good,Average,Bad"
option="required"
#key(col3)
name="comment"
label="Comment"
type="textarea"
option=""
Generate a Form
Then let's create a survey form for end users.
sudo /usr/local/small-shell/adm/gen -app
Type of App (1.BASE | 2.FORM | 3.CUSTOM): 2
Form Name: survey
Result of dialog.
In this example, some keys of survey.box are excluded.
The Form will be generated in the following order, please check it.
-----------------------------------------------------------------
App Type: 2.FORM
Form Name: survey
Target Databox: survey.box
Description: This is an internal survey of product A
Included keys: impression,comment
Access URL: https://${your_server_FQDN}/survey
-----------------------------------------------------------------
Access to the Form
As you already checked, access URL is shown in the gen dialog. The URL must be ${your_server_FQDN}/${your_Form_name}
e.g.) https://ec2-XX-XX-XX-XX.compute.XXXX.com/survey

Check databox via Base App
Data will be pushed to the databox through the survey form. Admin can check survey results through Base App. Then you can analyze result on table view or console box.
Make snapshot graph
You can visualize survey results by generating graph. Please setup pyshell beforehand. Following is an example of making graph.
Make November 28th 2022 as snapshot.
sudo -u small-shell /usr/local/small-shell/util/scripts/countup.sh databox:survey.box \
key:impression filters:Good,Average,Bad type:pie title:2022-11-28_survey_result frequency:snapshot
please input #stats to console box on Base App.
Base App > Console [#stats]


Change View
You can modify html def of the form directly.
sudo vi /var/www/def/${your_Form_name}_get_new.html.def
e.g.) sudo vi /var/www/def/survey_get_new.html.def
--code--
<html>
<head>
<meta charset="UTF-8" />
<title>survey.new</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link rel="stylesheet" href="./survey_css">
</head>
<body>
<div class="container">
<div class="form-box">
<div class="description">
<h1>#survey</h1>
<p>This is a an internal survey of product A</p>
<hr>
<br>
</div>
<form method="post" action="./survey?req=set&id=%%id" onclick="document.charset='utf-8';">
<ul>
%%dataset
</ul>
<button class="button" type="submit">SUBMIT</button>
</form>
</div>
</div>
</body>
</html>
-------
Change row size for textarea
You can change row size by inserting code to ${your_Form_name}_new.html.def.
e.g)
sudo vi /var/www/def/survey_new.html.def
--code--
<script>
document.getElementById("txtara").rows="10"
</script>
--------