Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: openDir frontCall in GBC  (Read 9516 times)
Huy H.
Posts: 45


« on: April 30, 2018, 08:53:03 pm »

In our existing applications, we have places were we are making use of the "openDir" front call to allow the user to select a directory.  Moving to GBC, we just realized that the openDir is not supported.  Is there a workaround or alternative function that will allow us to support similar functionality? 

CALL ui.Interface.frontCall("standard","opendir",[pc_dir,title],[selected_dir])
Leo S.
Four Js
Posts: 129


« Reply #1 on: May 01, 2018, 01:25:02 am »

Hi Huy, "openDir" is a very desktop centric frontcall.
You are not able to use it if GBC runs in a standard web browser without any plugins due to the security restrictions of modern web browsers.
(see ramblings at https://stackoverflow.com/questions/2809688/directory-chooser-in-html-page)

It may be possible in the future to use it in GBC if GBC runs as standalone installable version but I won't go into detail here.
May I ask what you want to do with the directory name queried in the front call ?


Regards, Leo
Huy H.
Posts: 45


« Reply #2 on: May 01, 2018, 05:05:25 pm »

There's two common scenario where we use openDir:
Case 1: We ask the user to select a directory so that we can extract a set of tables (about 30 files) so that the user can take those files and use it in another application. (We think we can get around this by bundling up the entire list as a single zip file before sending it to the user desktop)
Case 2: We ask the user to select a directory where a certain set of configuration files exist so that we can load it into our system.  In this scenario, we are looking about about 6 files.  We might need to work around this by forcing the user to select the file one by one.
Leo S.
Four Js
Posts: 129


« Reply #3 on: May 01, 2018, 06:01:11 pm »

Right, anyway fgl_putfile() in GBC can't make use of the destination directory (due to the security restrictions), so you can't actually make use of the opendir call.
Calling on my Mac

CALL fgl_putfile("image1.jpg","/tmp/ximage1.jpg")
CALL fgl_putfile("image1.jpg","/tmp/yimage1.jpg")

puts image1.jpg and image1 (1).jpg in my /Users/leo/Downloads folder (If I have the popup blocker disabled on both Safari and Chrome). That is a bit surprising, I would have expected at least ximage1.jpg and yimage1.jpg (May be its a bug)

The documentation seems to need a bit updated for the GBC case at least for the ignored destination directory.
It might be useful to mention too the different behaviour in browsers if the popup blocker is on.
(My Safari doesn't inform me at all that there was an attempt, so the file gets lost in hyperspace then)

For uploading files from the end users desk the following works for me

        CALL ui.Interface.frontCall("standard", "openFiles", [".","xx","*.jpg","Caption"], [result])
        MESSAGE "result:",result
        CALL util.JSON.parse( result, files )

        FOR i=1 TO files.getLength()
            DISPLAY SFMT("File %1: %2 ", i, files)
            CALL fgl_getfile(files,files)
        END FOR

HTH and Regards, Leo
Huy H.
Posts: 45


« Reply #4 on: May 01, 2018, 06:16:17 pm »

Thanks Leo for the insight.  We'll give your suggestions a try.
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines