13
Tools for Designing Web Based Interfaces for Erlang/OTP Martin Gustafsson

Tools for Designing Web Based Interfaces for Erlang/OTP

Embed Size (px)

DESCRIPTION

Tools for Designing Web Based Interfaces for Erlang/OTP. Martin Gustafsson. Program. Why Web Based User Interfaces. httpd the Webserver in Erlang/OTP. How to use and develop with WebTool. Best Desing of Web Based Tools, with Erlang/OTP. Why Web Based User Interfaces. Easy for the user. - PowerPoint PPT Presentation

Citation preview

Page 1: Tools for Designing Web Based Interfaces for Erlang/OTP

Tools for Designing Web Based Interfaces for Erlang/OTP

Martin Gustafsson

Page 2: Tools for Designing Web Based Interfaces for Erlang/OTP

Program

Why Web Based User Interfaces. httpd the Webserver in Erlang/OTP. How to use and develop with WebTool. Best Desing of Web Based Tools, with

Erlang/OTP.

Page 3: Tools for Designing Web Based Interfaces for Erlang/OTP

Why Web Based User Interfaces

Easy for the user. Fast development,

– Easy to Learn.– Fast Development.

The tool can be used from the network. Easy to generate printable reports.

Page 4: Tools for Designing Web Based Interfaces for Erlang/OTP

Problems with Web based User Interfaces

Takes little more time to start than command-line tools.

Interaction with the files system. Browser incompabilities. Security is problem,

– Functionality that can stop the Erlang node.– Data transfer between server and client is not

secure.

Page 5: Tools for Designing Web Based Interfaces for Erlang/OTP

httpd -The Webserver in Erlang/OTP

Support for Basic User Authentication. Support for SSL. Support for creation of Dynamic Web Pages. httpd is a Apache styled Webserver.

Page 6: Tools for Designing Web Based Interfaces for Erlang/OTP

The functionality of httpd

httpd

s

mod_xxx

HTTP-request

{response{statuscode,Body}}

HTTP-Response

Page 7: Tools for Designing Web Based Interfaces for Erlang/OTP

Creation of dynamic Web Pages

CGI Eval Scheme

– Ex: http://server:port/EvalSchemAlias/mod:func(AnyArg)

Erl SchemeEx: http://server:port/ErlSchemeAlias/mod/func

The Webserver will return the result of calling

mod:func(Env,Input).

Page 8: Tools for Designing Web Based Interfaces for Erlang/OTP

Example index(Env,Input) ->

[“\r\n\r\n”,html_head(),htmlbody(),

createMenu(Env),”</HTML>”].

createMenu(Env)->

Ag=httpd_util:key1search(

Env, http_user_agent,other), case

mod_browser:getBrowser(Ag) of

{{msie,_},_} ->

menu(ie);

{{netscape,_},_} ->

menu(nav)

end.

menu(nav) ->

“<LAYER NAME=\”popup\”

VISIBILITY=\”hidden\”>

<TABLE>

<TR><TD>

<A HREF=./start>

Start tool

</A>

</TD></TR>

….

</TABLE>

</LAYER>”;

Page 9: Tools for Designing Web Based Interfaces for Erlang/OTP
Page 10: Tools for Designing Web Based Interfaces for Erlang/OTP

Starting WebTool

Create a *.tool file for each tool and save it in the directory MyTool-vsn/priv/FileName.tool– Ex: {version,1.2},

[{config_func,{webappmon,configData,[]}}] Start WebTool.

– Ex: webtool:start().webtool:start(Path,Port).

Point a browser to http://HostName:Port/

Page 11: Tools for Designing Web Based Interfaces for Erlang/OTP

Callback function for WebTool

WebTool use the callback function to receive configuration data for the tool.

Configuration data is needed for:– Creating links from WebTool to the tool.– Configuration of the Webserver.– Data about how to start and stop the tool.

Page 12: Tools for Designing Web Based Interfaces for Erlang/OTP

Developing tools to be used via WebTool

The tools must export a callback function that returns the configuration data needed by WebTool.– Example:configData()-> Application=my_app RealPath=code:priv_dir(Application), {mytool,[{web_data,{“URL”,”Linktext”}},

{alias,{erl_alias,”VPath”,[“Module”]}}, {alias,{“VirtualPath2”,RealPath}},

{start{{Mod,Func,Arg},{Mod,Func,Arg}}}]}.

Page 13: Tools for Designing Web Based Interfaces for Erlang/OTP

Design principles for Web based Tools

A N-layered solution has many advantages– Easier to update the code– If well designed the logic module might be

possible to use as a command-line version.

logic ModuleModule that generates the

User Interface

HTTP-Request

WebPage