From f78ea0ab19152fce5908119396fdbdbb81f63215 Mon Sep 17 00:00:00 2001 From: Patrick Rigney Date: Thu, 6 May 2021 17:16:38 -0400 Subject: [PATCH] Updates for openLuup --- J_ReactorSensor_UI7.js | 3 + J_Reactor_UI7.js | 193 +++++++++++++++++++++++++---------------- 2 files changed, 119 insertions(+), 77 deletions(-) diff --git a/J_ReactorSensor_UI7.js b/J_ReactorSensor_UI7.js index 70c435e..cf6a3ae 100644 --- a/J_ReactorSensor_UI7.js +++ b/J_ReactorSensor_UI7.js @@ -385,6 +385,9 @@ div.reactortab .form-inline { display: -ms-flexbox; display: flex; -ms-flex-flow } function checkUpdate() { + if ( isOpenLuup ) { + return Promise.resolve( false ); + } return new Promise( function( resolve, reject ) { $.ajax({ url: api.getDataRequestURL(), diff --git a/J_Reactor_UI7.js b/J_Reactor_UI7.js index a74ea65..075c38c 100644 --- a/J_Reactor_UI7.js +++ b/J_Reactor_UI7.js @@ -32,7 +32,7 @@ var Reactor = (function(api, $) { var dateFormat = "%F"; /* ISO8601 default */ var timeFormat = "%T"; - // unused: var isOpenLuup = false; + var isOpenLuup = false; var isALTUI = false; var backupInfo = false; @@ -143,8 +143,16 @@ var Reactor = (function(api, $) { /* Go */ isALTUI = "undefined" !== typeof(MultiBox) && null !== document.location.href.match( /id=lr_ALTUI/i ); - console.log("isALTUI=",isALTUI); - // isOpenLuup = ; + isOpenLuup = false; + var dl = api.getListOfDevices(); + var n = dl.length; + for ( var k=0; k

Backup and Restore

'; html += '
You may back up your Reactor configuration here, or restore a previously backed-up configuration.
'; - html += '

Most Recent Backup

' + - '
' + - '
'; - html += '

Back Up Current Configuration

Press this button to back up your current Reactor configuration:
'; - html += '

Restore from Backup

Tip: Read the online documentation.

To restore from the current backup (info above), select the item to restore (or ALL to restore everything), and then press the "Begin Restore" button. WARNING: Restoring will overwrite the configuration of any current ReactorSensor having the same name(s). If you want to restore from another backup file (e.g. one you downloaded previously from this or another system), please read the linked documentation above before proceeding.

'; + html += '
\ +
\ +

Most Recent Backup

\ +
\ +
\ +
'; + html += '
\ +
\ +

Back Up Current Configuration

\ + Press this button to back up your current Reactor configuration: \ +
\ +
'; + html += '
\ +
\ +

Restore from Backup

\ +

Tip: Read the online documentation.

\ +

To restore from the current backup (info above), select the item to restore (or ALL to restore everything), and then press the \ + "Begin Restore" button. WARNING: Restoring will overwrite the configuration of any current ReactorSensor having the same \ + name(s). If you want to restore from another backup file (e.g. one you downloaded previously from this or another system), please \ + read the linked documentation above before proceeding.

\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
\ +
'; - html += '\ -
\ + html += '
\
\

Bulk Create New ReactorSensors

\
To create multiple ReactorSensors at once, select the number of sensors and click "Create ReactorSensors". This operation causes a Luup reload, and you will need to hard-refresh your browser. \ @@ -516,74 +552,77 @@ The Reactor Plugin for Vera is a community-supported project. If you find Reacto making a donation via PayPal or crypto here. \ ' ) .appendTo( $body ); - $( '
' ).appendTo( $body ); - var $list = $( '
  • Loading release information...
' ) - .appendTo( $body ); - $.ajax({ - url: api.getDataRequestURL(), - data: { - id: "lr_Reactor", - action: "updateplugin", - r: Math.random() - }, - dataType: "json", - cache: false, - timeout: 15000 - }).done( function( data ) { - $list.empty(); - if ( data.status ) { - data.data.forEach( function( rel ) { - var pubtime = Date.parse( rel.published_at ); - if ( pubtime < 1600616760000 ) { // v3.8 2020-09-20T15:46:00Z - return; - } - var $el = $( '
  • ' ).attr( 'id', 're-rel-' + rel.id ).appendTo( $list ); - $( '' ).appendTo( $el ); - $( 'name' ).text( rel.name ).appendTo( $el ); - $( '').appendTo( $el ); - $( '
    ' ).text( rel.body ).appendTo( $el );
    -					});
    -					$( 'button.re-rel-install', $list ).on( 'click.reactor', function( event ) {
    -						var $el = $( event.currentTarget ).closest( 'li' );
    -						var rel = $el.attr( 'id' ).replace( /^re-rel-/, "" );
    -						$( 'button', $el ).prop( 'disabled', true );
    -						$( 'li', $list ).not( 'li#' + $el.attr( 'id' ) ).remove();
    -						$( '.re-rel-status', $el ).text( 'Installing... please wait...' );
    -						$.ajax({
    -							url: api.getDataRequestURL(),
    -							data: {
    -								id: "lr_Reactor",
    -								action: "updateplugin",
    -								release: rel,
    -								r: Math.random()
    -							},
    -							dataType: 'json',
    -							cache: false,
    -							timeout: 32000
    -						}).done( function( res ) {
    -							if ( res.status ) {
    -								$( '.re-rel-status', $el ).text( "" );
    -								$( 'pre', $el ).remove();
    -								$( '

    Install Finalizing!

    The installation is finalizing \ -in the background with a Luup reload. You must now \ -hard-refresh \ -your browser to make sure that the correct UI implementation files load to match the installed Reactor core. Please do it now.

    \ -
    ' ) - .appendTo( $el ); - } else { - $( 'span.re-rel-status', $el ).css( 'color', 'red' ).text( 'Update failed; ' + res.message ); + + if ( false === isOpenLuup ) { + $( '
    ' ).appendTo( $body ); + var $list = $( '
    • Loading release information...
    ' ) + .appendTo( $body ); + $.ajax({ + url: api.getDataRequestURL(), + data: { + id: "lr_Reactor", + action: "updateplugin", + r: Math.random() + }, + dataType: "json", + cache: false, + timeout: 15000 + }).done( function( data ) { + $list.empty(); + if ( data.status ) { + data.data.forEach( function( rel ) { + var pubtime = Date.parse( rel.published_at ); + if ( pubtime < 1600616760000 ) { // v3.8 2020-09-20T15:46:00Z + return; } - }).fail( function( jqXHR, textStatus, textM ) { - console.log( jqXHR, textStatus, textM ); - $( 'span.re-rel-status', $el ).css( 'color', 'red' ).text( 'Update failed; try again later.' ); + var $el = $( '
  • ' ).attr( 'id', 're-rel-' + rel.id ).appendTo( $list ); + $( '' ).appendTo( $el ); + $( 'name' ).text( rel.name ).appendTo( $el ); + $( '').appendTo( $el ); + $( '
    ' ).text( rel.body ).appendTo( $el );
     						});
    -					});
    -				} else {
    -					$list.text( 'Release information is not available right now; try again later. ' + data.message );
    -				}
    -			}).fail( function( /* jqXHR, textStatus, errorThrown */ ) {
    -				$list.empty().text( "Can't load release information. " );
    -			});
    +						$( 'button.re-rel-install', $list ).on( 'click.reactor', function( event ) {
    +							var $el = $( event.currentTarget ).closest( 'li' );
    +							var rel = $el.attr( 'id' ).replace( /^re-rel-/, "" );
    +							$( 'button', $el ).prop( 'disabled', true );
    +							$( 'li', $list ).not( 'li#' + $el.attr( 'id' ) ).remove();
    +							$( '.re-rel-status', $el ).text( 'Installing... please wait...' );
    +							$.ajax({
    +								url: api.getDataRequestURL(),
    +								data: {
    +									id: "lr_Reactor",
    +									action: "updateplugin",
    +									release: rel,
    +									r: Math.random()
    +								},
    +								dataType: 'json',
    +								cache: false,
    +								timeout: 32000
    +							}).done( function( res ) {
    +								if ( res.status ) {
    +									$( '.re-rel-status', $el ).text( "" );
    +									$( 'pre', $el ).remove();
    +									$( '

    Install Finalizing!

    The installation is finalizing \ + in the background with a Luup reload. You must now \ + hard-refresh \ + your browser to make sure that the correct UI implementation files load to match the installed Reactor core. Please do it now.

    \ +
    ' ) + .appendTo( $el ); + } else { + $( 'span.re-rel-status', $el ).css( 'color', 'red' ).text( 'Update failed; ' + res.message ); + } + }).fail( function( jqXHR, textStatus, textM ) { + console.log( jqXHR, textStatus, textM ); + $( 'span.re-rel-status', $el ).css( 'color', 'red' ).text( 'Update failed; try again later.' ); + }); + }); + } else { + $list.text( 'Release information is not available right now; try again later. ' + data.message ); + } + }).fail( function( /* jqXHR, textStatus, errorThrown */ ) { + $list.empty().text( "Can't load release information. " ); + }); + } } catch( err ) { console.error( err ); }