Jump to content

Eugeniusz Rink

uniGUI Subscriber
  • Posts

    44
  • Joined

  • Last visited

Everything posted by Eugeniusz Rink

  1. Problem solved. Below I show how I did it. This is a way to silently print PDF documents. I used the project: https://github.com/imTigger/webapp-hardware-bridge You install the Windows client: https://github.com/imTigger/webapp-hardware-bridge/releases/tag/0.14.0 In the Delphi code: function LoadJavaScriptFromFile(const FileName: string): string; var FileStream: TFileStream; StreamSize: Int64; Buffer: AnsiString; begin Result := ''; FileStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone); try StreamSize := FileStream.Size; SetLength(Buffer, StreamSize); FileStream.Read(Buffer[1], StreamSize); Result := String(Buffer); finally FileStream.Free; end; end; [...] var JavaScriptCode: String; [...] JavaScriptCode := LoadJavaScriptFromFile(UniServerModule.StartPath+'files\res\js\websocket-printer.js'); JavaScriptCode := StringReplace(JavaScriptCode, '$url$', '"ws://127.0.0.1:12213/printer"', [rfReplaceAll]); JavaScriptCode := StringReplace(JavaScriptCode, '$typ$', ''''+UniApplication.Parameters.Values['gabinet']+'''', [rfReplaceAll]); JavaScriptCode := StringReplace(JavaScriptCode, '$pdfbase64$', ''''+pdf_base64+'''', [rfReplaceAll]); UniSession.AddJS(JavaScriptCode); Of course, adapt the variables to your needs. The PDF file must be converted to Base64 without line-ending enters. websocket-printer.js
  2. If I add a script definition in UniServerModule: CustomFiles:='files/rs/js/websocket-printer.js' run the function: UniSession.AddJS('printPDFBase64("'+UniApplication.Parameters.Values['office']+'","'+pdf_base64+'")'); It works properly and without errors... But this does not solve the problem, because I have to change the server port for each logging user. I need to change this entry in the JS script: url: "ws://127.0.0.1:12212/printer".
  3. Hi. I have a problem running JS. script1:= ' function WebSocketPrinter(options) { '+ ' var defaults = { '+ ' url: "ws://127.0.0.1:12212/printer", '+ ' onConnect: function () { '+ ' }, '+ ' onDisconnect: function () { '+ ' }, '+ ' onUpdate: function () { '+ ' }, '+ ' }; '+ ' var settings = Object.assign({}, defaults, options); '+ ' var websocket; '+ ' var connected = false; '+ ' var onMessage = function (evt) { '+ ' settings.onUpdate(evt.data); '+ ' }; '+ ' var onConnect = function () { '+ ' connected = true; '+ ' settings.onConnect(); '+ ' }; '+ ' var onDisconnect = function () { '+ ' connected = false; '+ ' settings.onDisconnect(); '+ ' reconnect(); '+ ' }; '+ ' var connect = function () { '+ ' websocket = new WebSocket(settings.url); '+ ' websocket.onopen = onConnect; '+ ' websocket.onclose = onDisconnect; '+ ' websocket.onmessage = onMessage; '+ ' }; '+ ' var reconnect = function () { '+ ' connect(); '+ ' }; '+ ' this.submit = function (data) { '+ ' if (Array.isArray(data)) { '+ ' data.forEach(function (element) { '+ ' websocket.send(JSON.stringify(element)); '+ ' }); '+ ' } else { '+ ' websocket.send(JSON.stringify(data)); '+ ' } '+ ' }; '+ ' this.isConnected = function () { '+ ' return connected; '+ ' }; '+ ' connect(); '+ '} ' + ' var printService = new WebSocketPrinter(); '+ ' function printPDFBase64(typ,pdfbase64) { '+ ' printService.submit({ '+ ' ''type'': typ, '+ ' ''url'': ''tuxmed.pdf'', '+ ' ''file_content'': pdfbase64 '+ ' }); '+ ' } '; UniSession.AddJS(script1); I trigger a function with parameters: UniSession.AddJS('printPDFBase64("'+UniApplication.Parameters.Values['gabinet']+'","'+pdf_base64+'")'); I get this error:
  4. That's it, thanks a lot 🙂
  5. OK, maybe we will start over. So for example I have form and 4 uniDBEdits. 3 of them must be validated (no empty) so I make this in form create: UniDBEdit1.JSInterface.JSConfig('allowBlank', [False]); UniDBEdit2.JSInterface.JSConfig('allowBlank', [False]); UniDBEdit3.JSInterface.JSConfig('allowBlank', [False]); UniDBEdit4.JSInterface.JSConfig('allowBlank', [True]); UniButton4.JSInterface.JSAddListener('click', 'function(){return '+ Self.WebForm.JSForm.JSName +'.isValid()}'); Now I wants to expand validation for new feature - showmessage and setfocus. So I want to write procedure that will check in loop if all UniDBEdits in that form has allowblank set to false and UniDBEdit text is empty if that 2 condition is fulfilled then procudure will show message and set focus current UniDBEdit in that loop. So my question is how to check if component have set allowblank true or false?
  6. The elements are visible. They are not hidden, they are located in the tabs tab. I would like to switch the tab programmatically and set SetFocus to UniDBEdit if it is not populated. Therefore, I need a list of UniDBEdit elements that have satatus 'allowBlank', [False] and have not been populated by the user.
  7. Hi. I set UniDBEdit on the form and define the requirement for completion using: UniDBEdit1.JSInterface.JSConfig('allowBlank', [False]); UniButton4.JSInterface.JSAddListener('click', 'function(){return '+ Self.WebForm.JSForm.JSName +'.isValid()}'); Everything works great, but I have a problem when TUniDBEdit is on one of the tabs, e.g. UniPageControl. I wanted to program the SetFocus event but I have no idea how to download UniDBEdit that has not been filled in and is not currently visible to the user?
  8. I want to show the mask before executing the actual SQL. For simplicity's sake, it shows showmessage. The HTML code in the DataModule shows records in html format in UniDGGrid in TFrameRecepty.
  9. Hi. The following code is used in the data module: [...] '<img align="right" title="Kopiuj leki z recepty." src="files/grafika/Forward Button.svg" style="cursor: pointer" width="24" vspace="0" hspace="0" height="24"'+ 'onclick="FramRecepty.FramePanel.showMask(''Szukam leku...''),javascript:ajaxRequest(FramRecepty.FramePanel,''_KopiujRecepte'',[''_KopiujRecepte_id_recepty='+IntToStr(ZQReceptyPanelrecepty_id.AsInteger)+'''],false)"> '+ [...] Code in FrameRecepty procedure TFramRecepty.UniFrameAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if (EventName = '_KopiujRecepte') then begin showmessage('Kopiuj receptÄ™ '+Params.Values['_KopiujRecepte_id_recepty']); UniSession.Synchronize(); end; end; I wanted to activate the mask, but this code does not work. The mask does not show.
  10. I have uniGUI Complete 1.90.0.1560. It always happens. There is space at the bottom of the table, however, RowEditor shows the buttons at the top and with two records they are invisible. I use UniMemoEdit as an editor in two fields. After unpinning UniMemoEdit, the buttons are visible...
  11. Hi. In UniDBGrid I use RowEditor. When entering the 3rd record into the table, the Save and Cancel buttons hide at the top, although there is a lot of space at the bottom. How to force buttons to appear at the bottom?
  12. Hi MVakili. Why do you only provide .pas files in your published project? Easier to post a custom sample project.
  13. Thanks for the hint. I searched the forum, but in English. The thread is in Russian 😉
  14. Hi. Is it possible to move the ToolButtons in UniPanel to the left side?
  15. We open various documents on the server. PDF, HTML. You give the path and open it. Please specify what problems you are having specifically?
  16. Create a separate virtual field for html presentation. And for editing, use physical fields.
  17. Hi. It uses UniDBLookupComboBox in the project. For better readability, I bold one of the fields in the list using the html code. In the list it shows fine, but after selecting the item from the list in the field it shows html codes. How to get around it?
  18. Of course. It is used as a frame. See the example I gave you.
  19. Hi. If you are talking about the master-detail layout as shown in the screenshot, you can take a look at the demo: C:\Program Files (x86)\FMSoft\Framework\uniGUI\Demos\Desktop\Grid - RowWidget Or at: http://prime.fmsoft.net/demo/desktop/mdemo.dll e section Grids->Row Widget. However, this is an inefficient presentation to the user. The best solution is the Tree format. But that's my opinion.
  20. I use UniDBTreeGrid. It shows the master-detail relationship nicely, but it has a problem with sorting and I stopped with the project.
  21. The data is in the test.csv file. Correct the date format to the appropriate one because in the csv file it is in the form of a string. It's about incorrect sorting by date. Test_DBTreeGrid.zip
  22. Doesn't anyone have such a problem with sorting in UniDBTreeGrid?
  23. Hi. The topic is old but have you solved the problem with sorting in UniDBTreeGrid? I have the same problem.
×
×
  • Create New...