Skip to content

Instantly share code, notes, and snippets.

@hussfelt
Last active September 28, 2024 14:51
Show Gist options
  • Save hussfelt/a6fe71ebd7cce327df29 to your computer and use it in GitHub Desktop.
Save hussfelt/a6fe71ebd7cce327df29 to your computer and use it in GitHub Desktop.
Dashing widget to display an iframe with specified src

dashing-iframe

IFrame plugin for dashing

Description

Dashing widget to display an iframe with specified src

Installation

Create the folder iframe in the /widgets/ directory. Put the files iframe.coffee, iframe.html and iframe.scss in that folder.

This can also be done by using the gist: https://gist.github.com/hussfelt/a6fe71ebd7cce327df29

dashing install a6fe71ebd7cce327df29

Dashboard configuration

Put the following in your dashboard.erb file to show the iframe:

    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
      <div data-id="iframeId1" data-view="Iframe"></div>
    </li>

Updating the src

Curl

curl -d '{
	"auth_token": "YOUR_AUTH_TOKEN",
	"src": "http://example.com/"
}' http://0.0.0.0:3030/widgets/iframeId1

Inline

    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
      <div data-id="iframeId1" data-view="Iframe" data-src="http://example.com/"></div>
    </li>

License

Distributed under the MIT license

class Dashing.Iframe extends Dashing.Widget
ready: ->
$(@node).find(".iframe").attr('src', @get('src'))
onData: (data) ->
$(@node).find(".iframe").attr('src', data.src)
<iframe class="iframe" data-bind-src="src" scrolling="no"></iframe>
// ----------------------------------------------------------------------------
// Sass declarations
// ----------------------------------------------------------------------------
$background-color: #FFF;
$title-color: #333;
$moreinfo-color: #333;
$iframe-background: darken($background-color, 25%);
// ----------------------------------------------------------------------------
// Widget-iframe styles
// ----------------------------------------------------------------------------
.widget-iframe {
background-color: $background-color;
padding: 0 !important;
margin: 0 !important;
iframe {
width: 100%;
height: 100%;
border: 0;
padding: 0;
margin: 0;
overflow: hidden;
}
}
@manikandanselva
Copy link

manikandanselva commented May 20, 2019

which file or which place add curl code?

curl -d '{
"auth_token": "YOUR_AUTH_TOKEN",
"src": "http://example.com/"
}' http://0.0.0.0:3030/widgets/iframeId1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment