Moving a desktop application to the web lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Luc · 2019-03-03 17:16 Hi, I am looking for a way or another to move an existing windows app to the web. I think we will all agree that Lazarus+FPC is really a great solution to build desktop applications, no doubt, but not so easy to use when it comes to mobile or web development. I am currently using windows server in TS mode when I need multi-user access to my desktop application. To avoid having to rewrite a large part of the application, I have been looking to cloud virtualization solutions: https://cameyo.com/ A nice service using windows servers but rather slow and too expensive for my needs https://www.rollapp.com/ Another great service. I think they run your app on linux in a Wine container if needed. I am waiting for further information https://www.cybelesoft.com/thinfinity/virtualui/ Seems to work great with Lazarus but you need a windows server + CAL so this is also too expensive for my needs https://guacamole.apache.org/ Was not able to have it running properly... https://developer.gnome.org/gtk3/stable/gtk-broadway.html As I was not fully satisfied with what I had found, I started to have a look at other solutions (the main goal is to keep as much as possible of the pascal code used by the application and libraries): http://www.unigui.com/ Seems great but for Delphi and IIS only ? https://www.elevatesoft.com https://smartmobilestudio.com https://www.tmssoftware.com Officially, despite the use of Pas2JS, it is Delphi only for the moment After having a look at what is ready at the moment, I don't think I would be able to use one of them and get the same functionalities I can achieve in a few clicks with Lazarus beacause they offer: Only limited or very basic reporting capabilities (I use Fast Report Master/Detail, drill-down events in preview, custom components...etc), Only Basic charting that doesn't match what you can do on desktop (complex layers and drill-down), Only Basic grids or components, etc... I hope not to be the only one beeing an old school desktop programmer in need to move to the web, and whishing to keep the simplicity of app development he knows and appreciates... I know there are a lot of efforts done with Pas2JS (it is moving really fast and looks very promising). Just for the ones who don't already know it, you can find some demos on the wiki and in the Pas2JS mailing list: https://www.freepascal.org/~michael/pas2js/chartjs/index.html Pas2JS clearly could be the winner but it needs to be connected to a backend service or app. I wish I could be able to find a good tutorial, a real use case example with all the basic code one needs to implement a first application, including: Best tool/editor to design the client UI. Does anybody could recommend a good UI editor we could use until the Lazarus one is ready?Easiest way to deploy the app on the server (embedded, cgi, fast cgi) pro and cons?Easiest way to debug the appHow to handle user session and securityHow to exchange data from UI to/from backendRecommanded backend frameworks : Mormot, Brook, fpWebHow to secure the code if most of the application code is avaliable in the browser via JSSome help on how to wrap an UI library To summarize, some complete tutorials and examples to help building a first app with Pas2JS with an embeded or cgi backend would I know there are top noch experts here who could create all this in a couple of hours, but I am not... so I can help testing and writing docs under the experts reviews...  This is just my feeling for now. Some will say I am mixing things up and I surely do, this is why some help will be welcome. Believe me, I would really hope to find a good solution to develop web apps with Lazarus. ---------------------------------------------------------------------- Leledumbo · 2019-03-03 19:03 I believe someday it would be possible to have a widgetset for the web, using whatever available JS toolkit and of course Pas2JS. But indeed for now, your choice is very limited. Quote from: Luc on March 03, 2019, 06:16:23 pmBest tool/editor to design the client UI. Does anybody could recommend a good UI editor we could use until the Lazarus one is ready? All of my web apps are handcoded, including the UI (even this one is not my specialty, we have a frontend team for this matter). Quote from: Luc on March 03, 2019, 06:16:23 pmEasiest way to deploy the app on the server (embedded, cgi, fast cgi) pro and cons? Deploying is as easy as copying the binary then restart the app (there are 0 downtime deployment techniques, but they're out of the scope of my answer), provided you have everything else set up (e.g. a dedicated webserver for reverse proxy if you use embedded server). Quote from: Luc on March 03, 2019, 06:16:23 pmEasiest way to debug the app Use embedded server, it's no different that usual executable. Quote from: Luc on March 03, 2019, 06:16:23 pmHow to handle user session and security This is left out to framework of choice, for fpWeb, read my tutorial. Quote from: Luc on March 03, 2019, 06:16:23 pmHow to exchange data from UI to/from backend Read and understand how HTTP works. Quote from: Luc on March 03, 2019, 06:16:23 pmRecommanded backend frameworks : Mormot, Brook, fpWeb For now, I stick to fpWeb. But it's a choice, you make your own after trying each. Quote from: Luc on March 03, 2019, 06:16:23 pmHow to secure the code if most of the application code is avaliable in the browser via JS Something is wrong at design level if that's what happened. Most (business logic) code should be in backend (with Pas2JS or fpWeb, it's the same), frontend should only serves as UI and bridge, even if it has its own logic but it's still frontend logic, not business one. Quote from: Luc on March 03, 2019, 06:16:23 pmSome help on how to wrap an UI library I believe somebody has just wrapped a JS library for Pas2JS. I haven't, so I can't really comment on this. ---------------------------------------------------------------------- tatamata · 2019-03-03 19:10 Feeling the same troubles, searching for same. To add some cloud options to your list: https://www.apponfly.com/en/ https://fra.me/ ---------------------------------------------------------------------- Luc · 2019-03-04 07:55 @Leledumbo As always, you provide detailled and useful information. I have read your fpWeb tutorial last week. Nicely written. I will give a try for embedded server and will study the reverse proxy need for this kind of application. (Currently, I use lazarus exe on client side, synapse, threads and apache + php on server side, yes I know not the perfect stack for a fpc user...) http://wiki.freepascal.org/pas2js_widgetsets I didn't find any "one click demo" here: could it be possible for the widgetsets developpers/fpc team to put some online demo? For example, but not related to fpc: http://banano.tuebben.de/kendoui/demo/ I wish I could find an overall picture of what can be done with FPC/Lazarus for the web and the best pratice. Not that I think for myself here, but this will surely boost Lazarus/fpc attractivity: You have 30sec? We are going to show you that Lazarus rocks to write web apps! Click here! I guess I will have to do my homework first and discover by myself. ---------------------------------------------------------------------- Luc · 2019-03-04 08:03 @Tatamata, Thanks, I didn't know about them. Their prices are quite high too and you need high speed connection to really use this kind of services, but with the 5G coming sooner or later, this could be the futur for client/server apps, don't you think ? ---------------------------------------------------------------------- nouzi · 2019-03-05 08:25 Quote from: Luc on March 04, 2019, 08:55:05 am... http://wiki.freepascal.org/pas2js_widgetsets I didn't find any "one click demo" here: could it be possible for the widgetsets developpers/fpc team to put some online demo? ... look at this https://www.youtube.com/watch?v=Hxb-An_61D8 and this https://www.youtube.com/watch?v=YE0ExvxVGTw https://www.lazarus-components.org/Components-with-sources/Web- XML/Web/ExtPascal/ and https://www.lazarus-components.org/Components-with-sources/Web- XML/Web/ ---------------------------------------------------------------------- Luc · 2019-03-06 09:30 Thanks Nouzi, I will have a look. ExtJS is quite old and I am not sure about the Sencha License... ---------------------------------------------------------------------- dinmil · 2019-03-06 10:21 Maybe this solution http://zebkit.org/ Normal GUI Components in HTML5 Canvas. ---------------------------------------------------------------------- ps · 2019-03-06 10:44 Quote from: Luc on March 03, 2019, 06:16:23 pmOnly limited or very basic reporting capabilities (I use Fast Report Master/Detail, drill- down events in preview, custom components...etc), Only Basic charting that doesn't match what you can do on desktop (complex layers and drill-down), Only Basic grids or components, etc... I hope not to be the only one beeing an old school desktop programmer in need to move to the web, and whishing to keep the simplicity of app development he knows and appreciates... Why not move your app to "cloud" instead of web? First you need server API and in next step you can think about UI (web or/and native or/and mobile).  Many modern services have native desktop client in present days (mainly build with Electron). ---------------------------------------------------------------------- tatamata · 2019-03-06 21:10 Does anybody know whether TMS Web Core (https://www.tmssoftware.com/site/products.asp?t=web) is supported for Lazarus and CodeTyphon? In the TMS Web Core docs (http://www.tmssoftware.biz/download/manuals/TMSWEBCoreDevGuide.pdf) there is no mention of the Lazarus. Is there anybody on this forum to share his experience with the TMS Web Core commercial package? ---------------------------------------------------------------------- berocoder · 2021-01-25 10:18 I believe Quartex Pascal https://jonlennartaasenden.wordpress.com/category/quartex-pascal/ is the best solution to webify your Delphi applications. The author Jon Aasanden is an old democoder. it means that he is passionate about performance. No compromises. It is fast! If you have good separation in you app between GUI and logic you should be able to move logic as is and just rewrite GUI for the web. It is the cleanest solution. Unfortunately Quartex Pascal is not ready for release yet but Jon publish updates every day in the closed facebookgroup. It should be ready soon. It is free for opensource and hobby projects. For commercial applications the price is $300. A long presentation about the project from Jon. https://youtu.be/sBoPScUDt30 ---------------------------------------------------------------------- Leledumbo · 2021-01-25 11:38 Quote from: tatamata on March 06, 2019, 10:10:57 pmDoes anybody know whether TMS Web Core (https://www.tmssoftware.com/site/products.asp?t=web) is supported for Lazarus and CodeTyphon? In the TMS Web Core docs (http://www.tmssoftware.biz/download/manuals/TMSWEBCoreDevGuide.pdf) there is no mention of the Lazarus. Is there anybody on this forum to share his experience with the TMS Web Core commercial package? Enjoy: https://www.tmssoftware.com/site/blog.asp?post=489https://www.tmssoftw are.com/site/videos.asp?v=97 ---------------------------------------------------------------------- Blade · 2021-04-04 05:50 I think the FreePascal/Lazarus answer for most people would be pas2js (https://wiki.lazarus.freepascal.org/pas2js) and then Lazarus Widgetset (to have the LCL on the web), which is also something more in line with open-source.  Appears to me that most would want to port over an app or create HTML client apps, where they can utilize their existing Object Pascal code or skill, and shortcut bypass CSS, HTML, and JavaScript as much as possible (or just sprinkle some in when needed).  Also, HTML client apps can be a lightweight shortcut around getting deep into Android and iOS development. Sadly progress seems quite slow.  Looks like maybe a call has go out to those with that skill to be volunteer developers or some type of bounty. ---------------------------------------------------------------------- valdir.marcos · 2021-04-04 20:43 You may try RDW (REST Dataware Component Suite): REST Dataware and you, get to the clouds effortlessly and with peace of mind https://forum.lazarus.freepascal.org/index.php?topic=47141.0 REST Dataware Componentes https://sourceforge.net/p/rest-dataware- componentes/activity/?page=0&limit=100#606653b88cdbb33f113e6e42 Projeto Rest Dataware https://www.restdw.com.br/ https://cursos.projetorestdataware.com.br/ ---------------------------------------------------------------------- trev · 2021-04-04 23:05 Many years ago I wrote and maintained a series of tax calculators in Delphi 1 for a legal publishing company to replace 100s of pages of tax tables. In 1994 we were moving from print products (typeset pages stuck down on boards with wax) to CD-ROM products (encrypted SGML content rendered by DynaText). Later in 1999 we were expanding to the web (encrypted SGML content rendered by DynaWeb) and I used the new Delphi 5 WebBroker to turn my desktop programs into ISAPI DLLs for a Windows IIS server (the actual web products ran under Dynaweb on a Sun Solaris UNIX server with links to IIS for the calculators). The conversion was a fairly trivial exercise, as I recall, simply replacing the GUI with generated HTML. ---------------------------------------------------------------------- egsuh · 2021-04-05 01:30 As trev told, I don't think moving to web is a daunting task. I myself haven't done a large project but first I built a small program with Delphi2, later moved it to client/server program, then web-service + windows application with Delph5, and now web server application + windows application accessing the web server + accesses of the web server from web browsers (HTML/CSS/JS) in Lazarus. The core parts - what they say business logic - have not changed much and are portable. I had to redefine some functions/procedures so that key or ID variable is included as parameters of the functions/procedures as web connection is, as you know, stateless. But if your application has many UI forms made with Delphi or Lazarus, I cannot say anything on changing them to HTML/CSS/Javascript. I thought VirtualUI would do that, which I tested successfully (but not using right now). I have written about 2,000 line javascript script, which relieved much of pascal work. As I'm doing this myself, I welcome any newbies? to Lazarus/FPC web development world. So based on my short humble (and basically based on trial and error) experience, I suggest following step    1) separate server-side work and client-side work first. Or separate purely logical modules and those which need form or visual control elements. Try to use interfaces to access procedure/functions, even though you can directly access procedures/functions in another module.   2) Define the communication rules between server and client, considering HTML server.    3) Separate two programs - server and client, and try to connect from client to server using THTMLclient. You may use synapse, etc.   4) Think of moving client-side forms to HTML/CSS/Javascript.