davidizadar Posted September 17, 2018 Share Posted September 17, 2018 (edited) Introduction In typical desktop client/server applications, every reference to files is always local (including shared network locations). These applications use OpenDialog and SaveDialog everywhere and the meaning is always clear. In uniGUI applications, when we use the OpenDialog we could be trying to open a local file or a server file. When we use SaveDialog we could be trying to download the file or to save it to the server. In addition to the distinction between local and server, we also need to know if the file in the server will be temporary, local to the user, or public and accessible to everyone. What is needed? We can not use OpenDialog nor SaveDialog as both components are for the VCL. OpenDialog This dialog allows to select the file we want to open, but the result is just the file name. We still need to load it. We can replace OpenDialog with the UniGUI component TUniFileUpload. The component allows defining the Caption of the dialog and the filter to use when browsing for the local file to be uploaded. The button Upload will request the upload of the file to the server. When the upload is finished, the component will trigger the event OnCompleted passing a parameter of type TFileStream which should be saved to the server. SaveDialog UniGUI does not include a component equivalent to SaveDialog. SaveDialog allows the user to select the location of the file to save while saving it must be done by ourselves. In a web application, hosted in a browser, when we download a file, the browser will ask for the destination or it will default to a predefined location like Downloads (it will depend on the browser's configuration). uniGUI offers several options to start the download: 1. UniSession.SendFile( ServerFile ) 2. UniSession.SendStream( TStream, LocalFile ) 3. TUniMemo.Lines.SaveToFile( ServerFile ) In this new scenario where we have two locations, client and server, the previous methods are not enough. OpenDialog - Server Most of the time, OpenDialog is used for selecting a local file and working with it. It could be a .INI file, .TXT, .DBF, anything. We need to find out what is the correct use case: the file could be used for some specific operation. It will be temporary. For example, when importing a .DBF file as part of some EDI process. In this case, we should save the file to the user area in the server, process it, and delete it once it is not needed anymore. we could be opening a file which should be part of the server storage, just for the user or shared among all users. The uniGUI component cannot be used for this. We will need to implement a component which will receive from the server a TUniTreeView with the file structure for our public/shared folder and the user's folder. This new component will replace the OpenDialog when we know that we need to reference files on the server. This component should expose a similar interface to the current OpenDialog. For a temporary file needed on the server, we could use the temporary location provided by uniGUI (UniServerModule.TempFolderPath). SaveDialog - Server As with OpenDialog, using SaveDialog could have different use cases: Sometimes we need to export some information from the database to a local file we will take with us. Here we could just download the file In other occasions, we could be saving something to use it for some other purpose by our application. For example, export some information from the database to send it by email. This scenario will require creating some component to allow browsing the server folders (public, and the user's folder) to mimic the current SaveDialog. If the file will be temporary, it is also possible to use the temporary folder provided by uniGUI (UniServerModule.TempFolderPath) Conclusions We need to implement two new dialogs to be used as replacements for OpenDialog and SaveDialog, but making reference to public and users folders in the server. Part of the implementation will be to expose our own public path and user's folder in our ServerModule. Our file system structure will look like: Root temp files public users <username1> <username2> ... log Both OpenDialog and SaveDialog should expose the public folder (and any subfolders) and the specific user folder associated with the session. Edited September 17, 2018 by davidizadar Unfinished Quote Link to comment Share on other sites More sharing options...
TI.ME Posted September 18, 2018 Share Posted September 18, 2018 3 hours ago, davidizadar said: Introduction In typical desktop client/server applications, every reference to files is always local (including shared network locations). These applications use OpenDialog and SaveDialog everywhere and the meaning is always clear. In uniGUI applications, when we use the OpenDialog we could be trying to open a local file or a server file. When we use SaveDialog we could be trying to download the file or to save it to the server. In addition to the distinction between local and server, we also need to know if the file in the server will be temporary, local to the user, or public and accessible to everyone. What is needed? We can not use OpenDialog nor SaveDialog as both components are for the VCL. OpenDialog This dialog allows to select the file we want to open, but the result is just the file name. We still need to load it. We can replace OpenDialog with the UniGUI component TUniFileUpload. The component allows defining the Caption of the dialog and the filter to use when browsing for the local file to be uploaded. The button Upload will request the upload of the file to the server. When the upload is finished, the component will trigger the event OnCompleted passing a parameter of type TFileStream which should be saved to the server. SaveDialog UniGUI does not include a component equivalent to SaveDialog. SaveDialog allows the user to select the location of the file to save while saving it must be done by ourselves. In a web application, hosted in a browser, when we download a file, the browser will ask for the destination or it will default to a predefined location like Downloads (it will depend on the browser's configuration). uniGUI offers several options to start the download: 1. UniSession.SendFile( ServerFile ) 2. UniSession.SendStream( TStream, LocalFile ) 3. TUniMemo.Lines.SaveToFile( ServerFile ) In this new scenario where we have two locations, client and server, the previous methods are not enough. OpenDialog - Server Most of the time, OpenDialog is used for selecting a local file and working with it. It could be a .INI file, .TXT, .DBF, anything. We need to find out what is the correct use case: the file could be used for some specific operation. It will be temporary. For example, when importing a .DBF file as part of some EDI process. In this case, we should save the file to the user area in the server, process it, and delete it once it is not needed anymore. we could be opening a file which should be part of the server storage, just for the user or shared among all users. The uniGUI component cannot be used for this. We will need to implement a component which will receive from the server a TUniTreeView with the file structure for our public/shared folder and the user's folder. This new component will replace the OpenDialog when we know that we need to reference files on the server. This component should expose a similar interface to the current OpenDialog. For a temporary file needed on the server, we could use the temporary location provided by uniGUI (UniServerModule.TempFolderPath). SaveDialog - Server As with OpenDialog, using SaveDialog could have different use cases: Sometimes we need to export some information from the database to a local file we will take with us. Here we could just download the file In other occasions, we could be saving something to use it for some other purpose by our application. For example, export some information from the database to send it by email. This scenario will require creating some component to allow browsing the server folders (public, and the user's folder) to mimic the current SaveDialog. If the file will be temporary, it is also possible to use the temporary folder provided by uniGUI (UniServerModule.TempFolderPath) Conclusions We need to implement two new dialogs to be used as replacements for OpenDialog and SaveDialog, but making reference to public and users folders in the server. Part of the implementation will be to expose our own public path and user's folder in our ServerModule. Our file system structure will look like: Root temp files public users <username1> <username2> ... log Both OpenDialog and SaveDialog should expose the public folder (and any subfolders) and the specific user folder associated with the session. Good evening... Your suggestions ... On my system, I need the user to indicate some paths. These paths contain default configuration files for some routines. In the current model, I only get this done from the server. I need the user to see some folders (directory defined by configuration). Quote Link to comment Share on other sites More sharing options...
davidizadar Posted September 18, 2018 Author Share Posted September 18, 2018 The two new components giving access to the virtual server file system should use properties like the uniGUI ServerModule, providing defaults for common locations and allowing for custom locations (like a config folder). Quote Link to comment Share on other sites More sharing options...
55143681 Posted September 18, 2018 Share Posted September 18, 2018 3 minutes ago, davidizadar said: The two new components giving access to the virtual server file system should use properties like the uniGUI ServerModule, providing defaults for common locations and allowing for custom locations (like a config folder). I need OpenDialog and SaveDialog to operate local files too. Quote Link to comment Share on other sites More sharing options...
davidizadar Posted September 18, 2018 Author Share Posted September 18, 2018 Access to local files is limited by the rights of a browser application. When uploading files, the browser allows you to select a file using its own dialog. When downloading files, the browser will allow you to select where to store the file and assign a filename. Any other solution will require an HTML 5 API for local file system access. That kind of API already exists for Google Chrome, but I don't know of a standard version implemented in every browser. Quote Link to comment Share on other sites More sharing options...
TI.ME Posted September 19, 2018 Share Posted September 19, 2018 On 9/18/2018 at 10:14 AM, davidizadar said: The two new components giving access to the virtual server file system should use properties like the uniGUI ServerModule, providing defaults for common locations and allowing for custom locations (like a config folder). but is it already in development? Quote Link to comment Share on other sites More sharing options...
Tokay Posted September 20, 2018 Share Posted September 20, 2018 I have created a server folder (not file) browser. Unfotunatelly it's have a bug on the UniGUI side. I reported it to the Portal. Quote Link to comment Share on other sites More sharing options...
TI.ME Posted September 20, 2018 Share Posted September 20, 2018 2 hours ago, Tokay said: I have created a server folder (not file) browser. Unfotunatelly it's have a bug on the UniGUI side. I reported it to the Portal. Good morning mate!!! I searched the portal and found your post. But the download is not available ... Could you post it again ?? Thank you!!! Quote Link to comment Share on other sites More sharing options...
TI.ME Posted September 20, 2018 Share Posted September 20, 2018 5 hours ago, Tokay said: I have created a server folder (not file) browser. Unfotunatelly it's have a bug on the UniGUI side. I reported it to the Portal. Good morning friends!!! Based on your idea of TreeView, I made a screen and it works perfectly !!! I'm finalizing the layout adjustments (because I did in test mode), and soon I'll post the solution !!! Thank you!!! 1 Quote Link to comment Share on other sites More sharing options...
Tokay Posted September 22, 2018 Share Posted September 22, 2018 Quote But the download is not available ... Could you post it again ?? Thank you!!! I just try to download my project from topic, and it downloaded well. I reupload it here. You can view my sources. Quote Based on your idea of TreeView, I made a screen and it works perfectly !!! It's great! I'll wait for you solution, thank you. Project3.7z Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.