Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rsslog improvements
- allow address elements - use this to notify about data change so that
  the data can be reloded
  • Loading branch information
ChristianMayer authored and peuter committed Jan 17, 2016
1 parent e58516d commit b0c084c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
18 changes: 16 additions & 2 deletions src/config/demo/visu_config_demorss.xml
Expand Up @@ -98,6 +98,10 @@
<urltrigger value="Call me" url="/something/else.php">
<label>Any other local(!) URL/script</label>
</urltrigger>
<trigger value="0">
<label>Trigger RSSLog Reload</label>
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
</trigger>
<line>
<layout colspan="12"/>
</line>
Expand All @@ -106,45 +110,55 @@
</text>
<rsslog src="plugins/rsslog/rsslog.php" refresh="300" limit="6" mode="last">
<layout rowspan="6" colspan="6"/>
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
</rsslog>
<line>
<layout colspan="12"/>
</line>
<text align="center">
<label>rsslog filter: fish - only last (click log!)</label>
</text>
<rsslog src="plugins/rsslog/rsslog.php" filter="fish" mode="last"/>
<rsslog src="plugins/rsslog/rsslog.php" filter="fish" mode="last">
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
</rsslog>
<line>
<layout colspan="12"/>
</line>
<text align="center">
<label>rsslog filter: ventilation - mode: rollover</label>
</text>
<rsslog src="plugins/rsslog/rsslog.php" filter="ventilation" mode="rollover"/>
<rsslog src="plugins/rsslog/rsslog.php" filter="ventilation" mode="rollover">
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
</rsslog>
<line>
<layout colspan="12"/>
</line>
<rsslog src="plugins/rsslog/rsslog.php?state=1" filter="fish" refresh="300" mode="last" timeformat="%d.%m. %H:%M">
<layout rowspan="9" colspan="6"/>
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
<label>Ereignisse state=1 Filter=fish</label>
</rsslog>
<rsslog src="plugins/rsslog/rsslog.php?state=0" filter="fish" refresh="300" mode="last" timeformat="%d.%m. %H:%M">
<layout rowspan="9" colspan="6"/>
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
<label>Ereignisse state=0 Filter=fish</label>
</rsslog>
<line>
<layout colspan="12"/>
</line>
<rsslog src="plugins/rsslog/rsslog.php" refresh="300" limit="5" mode="last" itemack="modify">
<layout rowspan="3" colspan="4"/>
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
<label>itemack: Modify</label>
</rsslog>
<rsslog src="plugins/rsslog/rsslog.php" refresh="300" limit="5" mode="last" itemack="display">
<layout rowspan="3" colspan="4"/>
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
<label>itemack: Display</label>
</rsslog>
<rsslog src="plugins/rsslog/rsslog.php" refresh="300" limit="5" mode="last" itemack="disable">
<layout rowspan="3" colspan="4"/>
<address transform="DPT:1.001" mode="readwrite">12/7/1</address>
<label>itemack: Disable</label>
</rsslog>
<line>
Expand Down
22 changes: 19 additions & 3 deletions src/plugins/rsslog/structure_plugin.js
Expand Up @@ -23,7 +23,8 @@ VisuDesign_Custom.prototype.addCreator("rsslog", {
var
$el = $(element),
classes = templateEngine.design.setWidgetLayout( $el, path ),
label = templateEngine.design.extractLabel( $el.find('label')[0], flavour );
label = templateEngine.design.extractLabel( $el.find('label')[0], flavour ),
address = templateEngine.design.makeAddressList( $el, false, path );

var id = "rss_" + path;
var extsource = false;
Expand All @@ -44,6 +45,7 @@ VisuDesign_Custom.prototype.addCreator("rsslog", {

var data = templateEngine.widgetDataInsert( path, {
id: id,
address: address,
src: $el.attr("src"),
filter: $el.attr("filter"),
refresh: $el.attr("refresh"),
Expand All @@ -67,6 +69,13 @@ VisuDesign_Custom.prototype.addCreator("rsslog", {

return ret_val;
},
update: function( ga, d ) {
var
element = $(this),
path = element.parent().attr('id'),
widgetData = templateEngine.widgetDataGet( path );
refreshRSSlog( widgetData );
},
action: function( path, actor, isCanceled ) {
if( isCanceled ) return;

Expand All @@ -86,8 +95,15 @@ VisuDesign_Custom.prototype.addCreator("rsslog", {
// here).
// But delay it so that any change done to the data has a chance to
// arrive here.
if( $(this).hasClass('popup') )
if( $(this).hasClass('popup') && widgetData.itemack === 'modify' )
{
window.setTimeout( function(){ refreshRSSlog( widgetData ); }, 100 );
for( var addr in widgetData.address )
{
if( !(widgetData.address[addr][1] & 2) ) continue; // skip when write flag not set
templateEngine.visu.write( addr, templateEngine.transformEncode( widgetData.address[addr][0], 0 ) );
}
}
});
popup.find('.main').css("overflow", "auto");
refreshRSSlog( widgetData, true );
Expand Down Expand Up @@ -119,7 +135,7 @@ function refreshRSSlog( data, isBig ) {
datetime: eval(data.datetime),
mode: data.mode,
timeformat: data.timeformat,
itemack: isBig ? data.itemack : ( 'modify' === data.itemack ? 'display' : data.itemack ),
itemack: isBig ? data.itemack : ( 'modify' === data.itemack ? 'display' : data.itemack )
});

if (typeof (refresh) != "undefined" && refresh) {
Expand Down
2 changes: 2 additions & 0 deletions src/visu_config.xsd
Expand Up @@ -1198,6 +1198,7 @@
<xsd:sequence>
<xsd:element name="layout" type="layout" minOccurs="0" maxOccurs="1"/>
<xsd:element name="label" type="label" minOccurs="0" maxOccurs="1"/>
<xsd:element name="address" type="address" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="src" type="xsd:string" use="required" />
<xsd:attribute name="refresh" type="xsd:integer" use="optional" />
Expand All @@ -1206,6 +1207,7 @@
<xsd:attribute name="datetime" type="xsd:boolean" use="optional" />
<xsd:attribute name="timeformat" type="xsd:string" use="optional" />
<xsd:attribute name="filter" type="xsd:string" use="optional" />
<xsd:attribute name="itemack" type="xsd:string" use="optional" />
</xsd:complexType>

<xsd:complexType name="svg">
Expand Down

0 comments on commit b0c084c

Please sign in to comment.