Facility Control

 View Only
Expand all | Collapse all

Image in DashBoard from online URL

  • 1.  Image in DashBoard from online URL

    Posted 06-04-2018 20:58

    So... I'm just looking into making an easier Instagram integration through DashBoard, and not the entire rundown thingy etc you have with Xpression sosial etc...
    And getting a JSON feed from Instagram based on a #hashtag is fairly simple.

    Now, getting the URL from Instagram works just fine, and applying it to an Xpression material works just fine (this kinda surprised me to be honest)!
    That was the easy part really...

    Now.. I wonder, is there a way to grab an online URL for an image and use this as the background for a canvas in DashBoard?
    I was sure I did this before, but when trying with different image URLs now I just cant seem to get it to work.

    Made this little DashBoard where I'm trying to take the ROSS logo from the forum header here and insert that into a parameter, on push of the button should set the background of the grey canvas. However, it wont... Hints? Tips? Clues? Is it possible? (It does update the DataLinq and it works in XPression. The material image updates with the parameter... I just need to be able to see it in DashBoard in order to "approve" each picture. (No way in hell I'm letting everything through...)

    function setImgBg (url) {
       ogscript.setStyle('img_bg', 'bg-u:'+url);
    }
    
    var imgUrl = params.getValue('img_URL', 0);
    ogscript.asyncExec(setImgBg(imgUrl));

    Getting no error message in debugger or anywhere else for that matter.

    DashBoard version: 8.4.0 | 2018-05-31 T11:49



  • 2.  RE: Image in DashBoard from online URL

    Posted 06-05-2018 14:15

    Your code is mostly correct. Your call to asyncExec is not necessary here and, because you're calling your function instead of passing it, you'd have the same problem we discussed in your post about passing variables to callbacks.

    <abs contexttype="opengear">
       <meta>
          <params>
             <param access="1" maxlength="0" name="img_URL" oid="img_URL" type="STRING" value="https://farm5.staticflickr.com/4672/38699277640_e48a74e34b_z_d.jpg" widget="text"/>
          </params>
          <api>function setBackground(url)
    {
       ogscript.setStyle('img_bg', 'bg-u:' + url);
    }
    </api>
       </meta>
       <label height="273" id="img_bg" left="13" style="bdr#000000;bg#dark;bg-fill:crop;" top="11" width="467"/>
       <param expand="true" height="36" left="11" oid="img_URL" runtasksonload="true" top="295" width="471">
          <task tasktype="ogscript">setBackground(params.getValue('img_URL', 0));
    </task>
       </param>
    </abs>

    #DashBoard


  • 3.  RE: Image in DashBoard from online URL

    Posted 06-05-2018 18:44
    But what the?!
    I tried this among other ideas and sollutions, even just setting the background in the style tab for the canvas, still didnt work?
    I mean, just grabbing the URL and setting that in the style tab should give some results right?
    #DashBoard


  • 4.  RE: Image in DashBoard from online URL

    Posted 06-05-2018 19:15
    If you try to pull-up the URL directly in a web browser, does it work? Some servers attempt to prevent loading images unless they're embedded in their own web pages.
    #DashBoard


  • 5.  RE: Image in DashBoard from online URL

    Posted 06-05-2018 21:03
    Yes, of course. Here's what I did. I basically used your logo at the top of this site as a test:

    - Right click and copy link.
    - Paste link into browser URL - Works
    - Paste link into DashBoard background image URL in the style tab of a canvas - Did not work.
    - Use script like yours above and other methods to set background - Did not work.
    - Paste the URL into a parameter that then was sent to a Xpression material through DataLinq - That works in Xpression...

    I dunno why, but it seems my DashBoard is unresponsive to changing the background of an element.
    (And yes, tripple checked the ID)
    #DashBoard


  • 6.  RE: Image in DashBoard from online URL

    Posted 06-05-2018 21:27
    There appears to be an issue with the Cache-Control HTTP header when multiple directives are used. In the case of the logo at the top of the page, the cache control specifies both a max-age and a public/private field. In this case, DashBoard is not expecting anything after the max-age directive and is discarding the remainder of the HTTP response as invalid.

    I'm not sure we can get this addressed in DashBoard 8.4 at this point but it will certainly be in the following release.

    James
    #DashBoard


  • 7.  RE: Image in DashBoard from online URL

    Posted 06-05-2018 21:34
    I assume this will be the case with any URL from an instagram feed then as well.
    As it seems I have the same issue with URLs pointing to a specific URL here as well.

    Example URL fro my own instagram feed:
    https://scontent.cdninstagram.com/vp/ec13c8cba8b768bc405647cd17170056/5BB12C28/t51.2885-15/e35/19623640_1252477638210980_8959994536206008320_n.jpg

    I can view the image in a browser, I can even send it to Xpression, but I cannot use it in DashBoard (yet anyways).
    So yeah, if that is the case as you describe above, a "fix" on that would be GREATLY appreciated. Would make it possible to create a simple Instagram application that I even think should pass their certification demands for the public_access to hashtags even.
    #DashBoard


  • 8.  RE: Image in DashBoard from online URL

    Posted 06-07-2018 18:00

    Could you use the "browser" element in Dashboard and change the URL of that browser programmatically to show your image?

    <browser height="300" id="browserTest" url="current_image_url" width="300"/>
    
    ogscript.getComponentsById('browserTest')[0].setUrl('new_image_url');

    #DashBoard


  • 9.  RE: Image in DashBoard from online URL

    Posted 06-08-2018 08:06
    Could you use the "browser" element in Dashboard and change the URL of that browser programmatically to show your image?




    ogscript.getComponentsById('browserTest')[0].setUrl('new_image_url');




    @josephadams I wasnt clear enough in my previous post, as I ment that I had tested it in a browser element in DashBoard, and that worked :)
    But it's not a bad idea, and it "works".
    I do however run into two challenges with this sollution. [LIST=1]

    • While it works, it's not possible (as I know) to scale the content in a browser tab? Meaning that when the picture is 400x400 pixels, in order to see the entire picture I would have to have a 416x416 (including the white border in a "browser" element) to view the entire content without vertical and horizontal scrollbars. A canvas a background can be positioned center and scale to fit. Wich would be better when you're running out of space in your DashBoard.
    • For some reason it seems the browser element is way slower at loading images and updating than what a simple background URL is when changing it.

    Now I havent been able to test this towards URLs from Instagram yet, as these arent working on updating backgrounds yet, but yeah, testing other images that seems to be the case.
    The canvas bit also seems to be cached when an image has first been loaded. This does not seem to be the case with a browser element (and I wouldnt expect it to either).
    Example panel here - just pick an entry in the table, and the images will update in the two squares. Left one is browser element, right one in canvas with a background:

    <abs contexttype="opengear" dblinqport="2222" gridsize="20" id="_top">
       <meta>
          <params>
             <param access="1" maxlength="0" name="url" oid="url" type="STRING" value="" widget="text"/>
             <param access="1" maxlength="0" name="insta_user" oid="0x2" precision="0" type="STRING_ARRAY" widget="default">
                <value>Img 1</value>
                <value>Img 2</value>
                <value>Img 3</value>
                <value>Img 4</value>
                <value>Img 5</value>
             </param>
             <param access="1" maxlength="0" name="insta_text" oid="0x3" precision="0" type="STRING_ARRAY" widget="default">
                <value>0</value>
             </param>
             <param access="1" maxlength="0" name="insta_id" oid="0x4" precision="0" type="STRING_ARRAY" widget="default">
                <value>0</value>
             </param>
             <param access="1" maxlength="0" name="insta_url" oid="0x5" precision="0" type="STRING_ARRAY" widget="default">
                <value>https://i.imgur.com/v924YOF.jpg</value>
                <value>https://i.imgur.com/mwoHidb.png</value>
                <value>https://i.imgur.com/wmQWKtF.png</value>
                <value>https://i.imgur.com/9nWJZdy.jpg</value>
                <value>https://i.imgur.com/EJsdiET.jpg</value>
             </param>
             <param access="1" constrainttype="INT_CHOICE" name="insta_table" oid="0x6" precision="0" type="INT16" value="0" widget="default">
                <constraint key="2">User</constraint>
                <constraint key="5">URL</constraint>
             </param>
             <param access="1" maxlength="0" name="User" oid="User" type="STRING" value="Img 1" widget="text"/>
             <param access="1" maxlength="0" name="Text" oid="Text" type="STRING" value="0" widget="text"/>
             <param access="1" maxlength="0" name="img_URL" oid="img_URL" type="STRING" value="https://i.imgur.com/v924YOF.jpg" widget="text"/>
             <param access="1" maxlength="0" name="insta_url150x150" oid="0x7" precision="0" type="STRING_ARRAY" widget="default">
                <value>0</value>
             </param>
          </params>
       </meta>
       <button buttontype="push" height="100" left="20" name="Call JSON" top="80" width="500">
          <task tasktype="ogscript">function handleData(resultData)
    {
       if (resultData == null)
       {
           ogscript.debug("NO DATA");
       }
       else
       {
             ogscript.debug('SUCCESS!');
             //ogscript.debug(resultData);
             var obj = JSON.parse(resultData);
             //ogscript.debug(obj);
             for (i in obj.data) {
                ogscript.debug('ID: ' + obj.data[i].id);
                ogscript.debug('User: ' + obj.data[i].user.username);
                ogscript.debug('Img URL: ' + obj.data[i].images.standard_resolution.url);
                ogscript.debug('Img 150x150: ' + obj.data[i].images.thumbnail.url);
                ogscript.debug('Caption: ' + obj.data[i].caption.text);
                ogscript.debug('Likes: ' + obj.data[i].likes.count);
    
                params.setValue(0x4, i, obj.data[i].id);
                params.setValue(0x2, i, obj.data[i].user.username);
                params.setValue(0x3, i, obj.data[i].caption.text);
                params.setValue(0x5, i, obj.data[i].images.standard_resolution.url);
                params.setValue(0x7, i, obj.data[i].images.thumbnail.url);
             }
       }
    }
    
    var url = params.getValue('url', 0);
    ogscript.asyncPost(url, null, handleData);
    ogscript.debug('Trying to get JSON response..');</task>
       </button>
       <param expand="true" height="40" left="20" oid="url" top="20" width="500"/>
       <param expand="true" height="300" left="20" oid="0x6" showlabel="false" top="200" widget="table" width="1220">
          <config key="w.reorder">true</config>
          <config key="w.cellediting">false</config>
          <config key="w.rowheight">50</config>
          <task tasktype="ogscript">var i = params.getValue(0x6, 0);
    params.setValue('User', 0, params.getValue(0x2, i));
    params.setValue('Text', 0, params.getValue(0x3, i));
    params.setValue('img_URL', 0, params.getValue(0x5, i));
    
    var img = params.getValue(0x5, i);
    var img2 = params.getValue(0x5, i);
    ogscript.getComponentsById('insta_preview')[0].setUrl(img);
    ogscript.setStyle('canvas_img', 'bg-u:' + img2);</task>
       </param>
       <param expand="true" height="40" left="20" oid="User" top="520" width="480"/>
       <param expand="true" height="40" left="20" oid="Text" top="580" width="480"/>
       <param expand="true" height="40" left="20" oid="img_URL" top="640" width="480"/>
    
      
    <browser height="280" id="insta_preview" left="520" name="insta_preview" style="txt-align:center;" top="520" url="https://discussions.rossvideo.com/images/quarto/asphalt_light/misc/vbulletin5_logo.png" width="300"/>
       <abs height="280" id="canvas_img" left="840" name="canvas_img" style="bg-align:center;bg#FFFFFF;bg-fill:fit;" top="520" width="300"/>
    </abs>

    #DashBoard


  • 10.  RE: Image in DashBoard from online URL

    Posted 06-08-2018 11:53
    Could you create a wrapper local HTML file thst runs in the browser element and accepts a querystring to load an image, and then styles the image to scale it to the width of the browser window?
    #DashBoard


  • 11.  RE: Image in DashBoard from online URL

    Posted 06-08-2018 12:31
    I guess I could, but that still would not eliminate the excessive load time of the browser element. Wich is actually more of an issue than the actual size.
    (Instagram API gives access to three versions: 150x150, 320x320 and 640x640)
    #DashBoard


  • 12.  RE: Image in DashBoard from online URL

    Posted 07-03-2018 13:54
    Update: This problem was solved in DashBoard version 8.4.1 - June 27 - 2018.

    ROSS with amazing updates and support as allways! :D
    #DashBoard