Facility Control

 View Only
  • 1.  Dashboard open/save file dialogs?

    Posted 06-08-2023 12:45

    Hi all, 

    Just starting to get into Dashboard and was wondering if there's any way to open up a load or save dialog, or even a folder picker?

    I found the sample .grids from Ben Gatien that included 

    • Reading and Writing Files or Directories: How to read different file formats and how to write back to files.

    but you have to manually type the folder name into a text box.  I also found ogscript.upload() that opens a file dialog box so I know the functionality is technically possible, but I can't find a more general solution.

    Thanks,

    -Rich



    ------------------------------
    rich helvey
    access hollywood, nbc
    ------------------------------


  • 2.  RE: Dashboard open/save file dialogs?

    Posted 08-24-2023 16:41

    Hello Rich,

    sorry for the delay.  Can you expand on the use-case you are trying to execute?  What 'data' do you want to load from/save to file?

    Regards,



    ------------------------------
    Marc-André Parent
    Ross Video
    ------------------------------



  • 3.  RE: Dashboard open/save file dialogs?

    Posted 08-25-2023 12:16

    I did eventually get a file picker working, but it's VERY slow to open – at least on this machine – I still need to try it on some other ones and see if the problem persists.  Turns out it was pretty easy:

    <param expand="true" height="40" left="33" oid="filename" top="28" widget="file-picker" width="606"/>

     

    Set the widget to "file-picker" and we're done.  Well, almost...  I would like to have a function get called when I select a file or folder and close the file picker.  Right now I have a separate button the user has to hit manually to process the file.  I kinda gave up on chasing down if having a callback function was possible since it was just sooooo slow to get the dialog box open, it wasn't going to be usable in a real production environment.  I'm still in the "I don't really know what I'm doing yet" stage though, so I freely admit I could be doing something horribly wrong.  J

     

     

     






  • 4.  RE: Dashboard open/save file dialogs?

    Posted 08-28-2023 09:02

    Hello Rich,

    Using the file picker opens very fast on my computer.  I would suggest trying on a different computer.

    You can create a task on the file picker parameter which will get invoked once the user closes the picker.  I recommend using the Visual Logic editor to create your task.  Here is a simple example of a panel which has a picker and text field to display the first line of the selected file.

    <abs contexttype="opengear" id="_top" keepalive="false" style="">
       <meta>
          <params>
             <param access="1" maxlength="0" name="selectedFile" oid="selectedFile" type="STRING" value="" widget="file-picker"/>
             <param access="1" maxlength="0" name="firstLine" oid="firstLine" type="STRING" value="" widget="default"/>
          </params>
       </meta>
       <param expand="true" height="36" left="21" oid="selectedFile" showlabel="false" top="20" width="408">
          <task tasktype="ogscript">/*! block id=1006,1003,1002,1000 !*/
    params.setValue('firstLine', 0, ogscript.createFileInput(params.getValue('selectedFile', 0)).readLine());
    /*!!
     &lt;block id="1006" type="param__top&amp;amp;firstLine (firstLine)[0]" x="837" y="116" w="243" SET="ID:1003" /&gt;
    &lt;block id="1003" type="file_readLine" x="566" y="118" w="243" FILEID="ID:1002" /&gt;
    &lt;block id="1002" type="ogscript_openfileread" x="342" y="118" w="243" PATH="ID:1000" /&gt;
    &lt;block id="1000" type="param__top&amp;amp;selectedFile (selectedFile)[0]" x="104" y="115" w="243" SET="" /&gt;
    !!*/
    /*!!&lt;checksum&gt;6363f78e8f281b78e70034f5af98d847&lt;/checksum&gt;!!*/</task>
       </param>
       <param expand="true" height="46" left="23" oid="firstLine" top="64" width="1200"/>
    </abs>
    

    Hope this helps,



    ------------------------------
    Marc-André Parent
    Ross Video
    ------------------------------