From 7671311f029531ad8bbb5a10a21ba9a22cd18687 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 19 Jun 2015 16:59:46 +0200 Subject: better handling of connection errors, handling close button in web client --- src/GNUmakefile | 2 +- src/index.html | 51 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/GNUmakefile b/src/GNUmakefile index 1ca09c4..eacc405 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile @@ -136,7 +136,7 @@ run: all @-./biruda --guess-env --human-readable @-./biruda -f -c biruda.conf -test: +test: all @-./biruda -f -c biruda.conf & @sleep 10 @-./biruda -i --no-colors -c biruda.conf -F testscript diff --git a/src/index.html b/src/index.html index 0f4f0a5..d7dddb1 100644 --- a/src/index.html +++ b/src/index.html @@ -11,14 +11,19 @@ $( "#tabs" ).tabs({ cache: false, beforeLoad: function( event, ui ) { - //~ ui.jqXHR.fail( function( ) { - //~ ui.panel.html( - //~ "Couldn't load status of biruda. Check if biruda is running and the webserver is enabled." ); - //~ }); event.preventDefault( ); return false; } }); + + var tabs = $( "#tabs" ).tabs( ); + + tabs.delegate( 'span.ui-icon-close', 'click', function( ) { + var panelId = $( this ).closest( "li" ).remove( ).attr( 'aria-controls' ); + $( '#' + panelId ).remove( ); + tabs.tabs( 'refresh' ); + }); + }); $(document).ready( function( ) { @@ -28,24 +33,32 @@ function refresh_status( ) { $.get( "/status", { } ) .done( function( data ) { - var lines = data.split( '\n' ); - var html = "\n"; - $.each( lines, function( ) { - var fields = this.split( ' ' ); - var type = fields[0]; - var name = fields[1]; - var status = fields[2]; - if( type == "worker" ) { - html += "\n"; - } - }); - html += "
workerstatus
" + name + "" + status + "
\n"; - $('#tabs-1').html( html ); + var html; + if( data == '' ) { + html = "

Loading..

"; + } else { + html = "\n"; + var lines = data.split( '\n' ); + $.each( lines, function( ) { + var fields = this.split( ' ' ); + var type = fields[0]; + var name = fields[1]; + var status = fields[2]; + if( type == "worker" ) { + html += "\n"; + } + }); + html += "
workerstatus
" + name + "" + status + "
\n"; + } + $( '#tabs-1' ).html( html ); + }).fail( function( ) { + $( '#tabs-1' ).html( "

Couldn't load status of biruda. Check if biruda is running and the webserver is enabled.

" ) }); - + } - var refreshId =setInterval( refresh_status, 5000 ); + var refreshId = setInterval( refresh_status, 5000 ); +