• This repository has been archived on 21/Nov/2020
  • Stars
    star
    625
  • Rank 71,862 (Top 2 %)
  • Language
    JavaScript
  • Created almost 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create your own forms and surveys, get your data back.

Formbuilder

Build Status

If you want to try it out, have a look at the demo page

Or deploy it on Scalingo in a single click on this button:

Deploy to Scalingo

Scalingo offer a 1 month free trial then 7.20€ / month.

Installation

To run the formbuilder locally, you can issue the following commands:

$ git clone https://github.com/Kinto/formbuilder.git  
$ cd formbuilder  
$ npm install
$ npm run start  

You also need to have a Kinto server greater than 4.3.1 in order to store your data and less than 11.0.0 for an out-of-the-box experience (when basicauth was removed by default). The latest version of Kinto at the time was 9.2.3. If you don't already have Kinto, follow the installation instructions. Also, see the changelog.

Configuration

It's possible to configure a few things, using environment variables:

  • PROJECT_NAME is the name of the project. Defaults to "formbuilder".
  • SERVER_URL is the URL of the kinto server. It's default value depends on the environment that's being used (development, production, etc.)

How can I get my data back?

All the data generated by the formbuilder is stored in a Kinto instance. As such, you can request the data stored in there.

When you generate a form, you're actually generating two tokens:

  • the adminToken, that you need to keep secret, giving you access to all the submitted data;
  • the userToken, that's used by users to find back the proper form.

One interesting property of the userToken is that it is actually half of the admin token !

With that in mind, let's say we've generated a form with an adminToken of 152e3b0af1e14cb186894980ecac95de. The userToken is then 152e3b0af1e14cb1.

So if we want to have access to the data on the server, using curl, we need to authenticate as the admin (using BasicAuth with form:{adminToken}):

$ SERVER_URL="http://localhost:8888/v1"
$ ADMIN_TOKEN="152e3b0af1e14cb186894980ecac95de"
$ FORM_ID="152e3b0af1e14cb1"
$ curl $SERVER_URL/buckets/formbuilder/collections/$FORM_ID/records \
   -u form:$ADMIN_TOKEN | python -m json.tool
{
    "data": [
        {
            "how_are_you_feeling_today": "I don't know",
            "id": "7785a0bb-cf75-4da4-a757-faefb30e47ae",
            "last_modified": 1464788211487,
            "name": "Clark Kent"
        },
        {
            "how_are_you_feeling_today": "Quite bad",
            "id": "23b00a31-6acc-4ad2-894c-e208fb9d38bc",
            "last_modified": 1464788201181,
            "name": "Garfield"
        },
        {
            "how_are_you_feeling_today": "Happy",
            "id": "aedfb695-b22c-433d-a104-60a0cee8cb55",
            "last_modified": 1464788192427,
            "name": "Lucky Luke"
        }
    ]
}

Architecture of the project

The formbuilder is based on top of React and the react-jsonschema-form (rjsf) library.

It is also using redux to handle the state and dispatch actions. If you're not familiar with it, don't worry, here is an explanation of how it works.

A quick theory tour

With react and redux, components are rendering themselves depending of some state. The state is passed to a component and becomes a set of props.

States aren't all stored at the same place and are grouped in so called stores (which are containers for the different states).

Now, if one needs to update the props of a component, it will be done via an action.

An action will eventually trigger some changes to the state, by the way of reducers: they are simple functions which take a original state, an action and return a new version of the state.

Then, the state will be given to the components which will re-render with the new values. As all components don't want to have access to all stores, the mapping is defined in a "container".

Yeah, I know, it's a bunch of concepts to understand. Here is a short recap:

state : The state of the application. It's stored in different stores.

actions : triggered from the components, they usually do something and then are relayed to reducers in order to update the state.

reducers : Make the state of a store evolve depending a specified action

containers : Containers define which stores and actions should be available from a react component.

How are components organised ?

At the very root, there is an "App" component, which either:

  • renders a "mainComponent"
  • renders a sidebar (customisable), the notifications and a content (customisable)

It is useful to have such a root component for the styling of the application: header is always in place and the menu always remains at the same location as well, if there is a need for such a menu.

There are multiple "screens" that the user navigates into, which are summarized here.

This might not be completely up to date, but is here so you can grasp easily how things are put together in the project.

Welcome screen

There is a Welcome component which is rendered as a mainComponent.

<App>
  <Welcome />
</App>

Form edition

This is the "builder" part of the formbuilder.

On the left side, you have a FieldList component and on the right side you have the components. It's possible to dragndrop from the fieldlist to the form.

Each time a field is added to the form, the insertfield action is called.

<App>
  <Header />
  <NotificationList />
  <FieldList>
    <Draggable />
    <Draggable />
    ...
  </FieldList />
  <Form>
    <EditableField>
      <FieldPropertiesEditor /> or <SchemaField />
    </EditableField>
    <Droppable />
  <Form />
</App>

The form is actually rendered by the rjsf library using a custom SchemaField, defined in components/builder/EditableField.js.

Form created confirmation

Once the form is created, the user is shown the FormCreated view, with a checkbox on the left side. This has two links to the AdminView and the UserForm views.

<App>
  <Header />
  <NotificationContainer />
  <Check />
  <FormCreated />
</App>

Form administration

The form admin is where the answers to the forms can be viewed. It should be viewable only by the people with the administration link.

<App>
  <AdminView>
    <CSVDownloader />
  </AdminView>
</App>

Form user

The UserForm is what the people that will fill the form will see.

<App>
  <UserForm>
</App>

More Repositories

1

kinto

A generic JSON document store with sharing and synchronisation capabilities.
Python
4,324
star
2

kinto.js

An Offline-First JavaScript Client for Kinto.
TypeScript
318
star
3

kinto-admin

Kinto Web Administration Console
TypeScript
185
star
4

kinto-react-boilerplate

An UNMAINTAINED Kinto.js+React project boilerplate.
JavaScript
67
star
5

kinto-http.js

A JavaScript HTTP client for the Kinto API.
TypeScript
66
star
6

kinto-http.py

A Python HTTP client for the Kinto API.
Python
52
star
7

kinto-attachment

Attach files to Kinto records
Python
43
star
8

elm-kinto

An Elm client for the Kinto API
Elm
28
star
9

kinto-webpush

Use WebPush to notify clients on collection change.
Python
18
star
10

kinto-emailer

Plugin to manage email notifications on records modification in a collection.
Python
12
star
11

kinto-signer

Digital signatures to guarantee integrity and authenticity of collections of records.
Python
12
star
12

kinto-heroku

Deploy Kinto on Heroku via a one-click button
Python
11
star
13

kinto-fxa

Firefox Accounts authentication support in Kinto
Python
10
star
14

kinto-elasticsearch

Index and query Kinto records via ElasticSearch
Python
10
star
15

kinto-wizard

Save/Load Kinto server content to/from a YAML file
Python
10
star
16

kinto-pusher

Plug Kinto notifications with Pusher.com
Python
8
star
17

kinto-changes

Gather timestamps of several collections into one to optimize server polling
Python
8
star
18

kinto-portier

Kinto authentication backend for Portier
Python
6
star
19

storage-sync

Prototype to wrap Chrome Sync API around Kinto.js
JavaScript
5
star
20

kinto-redis

Kinto Redis storage/cache/permission backends
Python
4
star
21

kinto-slides

Slides about Kinto
HTML
4
star
22

kinto-alwaysdata

Deploy a Kinto on AlwaysData automatically.
Shell
4
star
23

kinto-ldap

A LDAP Basic Auth authentication layer that validate the user/password against a LDAP server.
Python
4
star
24

kinto-http.rs

Kinto Rust Client
Rust
3
star
25

kinto-loadtests

Kinto loadtest based on molotov
Makefile
3
star
26

kinto-node-test-server

A nodejs test server for Kinto.
TypeScript
2
star
27

kinto-website

Website for the kinto ecosystem
HTML
2
star
28

kinto-discovery-lib

JavaScript
1
star
29

kinto-hawk

Hawk authentication support for Kinto
Python
1
star
30

kinto-webextension

Configure your default Kinto server
JavaScript
1
star
31

ESP8266Kinto

Kinto library for ESP8266 Arduino
C++
1
star
32

parse2kinto

Little utility to migrate Parse objects into a Kinto collection.
Python
1
star