details: http://www.bx.psu.edu/hg/galaxy/rev/83551d2b3144 changeset: 3093:83551d2b3144 user: Enis Afgan <afgane@gmail.com> date: Thu Nov 12 15:26:10 2009 -0500 description: Cleaned up AJAXed UCI state changes on main UI. UCI still does not get automatically removed after from displayed list being deleted by user. diffstat: templates/cloud/configure_cloud.mako | 28 ++++++++++++++++++---------- 1 files changed, 18 insertions(+), 10 deletions(-) diffs (61 lines): diff -r 118dc385752b -r 83551d2b3144 templates/cloud/configure_cloud.mako --- a/templates/cloud/configure_cloud.mako Thu Nov 12 14:24:43 2009 -0500 +++ b/templates/cloud/configure_cloud.mako Thu Nov 12 15:26:10 2009 -0500 @@ -36,24 +36,21 @@ old_state = $(elem + "-state").text(); prev_old_state = trim19( $(elem + "-state-p").text() ); new_state = data[i].state; - console.log( "old_state[%d] = %s", i, old_state ); - console.log( "prev_old_state[%d] = %s", i, prev_old_state ); - console.log( "new_state[%d] = %s", i, new_state ); + //console.log( "old_state[%d] = %s", i, old_state ); + //console.log( "prev_old_state[%d] = %s", i, prev_old_state ); + //console.log( "new_state[%d] = %s", i, new_state ); //console.log( trim19(prev_old_state) ); if ( ( old_state=='pending' && new_state=='running' ) || ( old_state=='shutting-down' && new_state=='available' ) || \ ( old_state=='running' && new_state=='available' ) || ( old_state=='running' && new_state=='error' ) || \ - ( old_state=='pending' && new_state=='error' ) || ( old_state=='pending' && new_state=='available' ) || \ - ( old_state=='submitted' && new_state=='available' ) || ( prev_old_state.match('newUCI') && new_state=='available' ) || \ - ( prev_old_state.match('new') && new_state=='available' ) || ( prev_old_state.match('deletingUCI') && new_state=='deleted' ) || \ - ( prev_old_state.match('deleting') && new_state=='deleted' ) ) { + ( old_state=='pending' && new_state=='available' ) || ( old_state=='submitted' && new_state=='available' ) || \ + ( prev_old_state.match('creating') && new_state=='available' ) ) { var url = "${h.url_for( controller='cloud', action='list')}"; location.replace( url ); } else if ( ( old_state=='running' && new_state=='error' ) || ( old_state=='pending' && new_state=='error' ) || \ ( old_state=='submitted' && new_state=='error' ) || ( old_state=='submittedUCI' && new_state=='error' ) || \ ( old_state=='shutting-down' && new_state=='error' ) || ( prev_old_state.match('newUCI') && new_state=='error' ) || \ - ( prev_old_state.match('new') && new_state=='error' ) || \ - ( prev_old_state.match('deletingUCI') && new_state=='error' ) ) { + ( prev_old_state.match('new') && new_state=='error' ) || ( prev_old_state.match('deletingUCI') && new_state=='error' ) ) { // TODO: Following clause causes constant page refresh for an exception thrown as a result of instance not starting correctly - need alternative method! //( prev_old_state.match('available') && new_state=='error' ) || ( prev_old_state.match('deleting') && new_state=='error' ) \ @@ -61,6 +58,10 @@ location.replace( url ); } + if ( prev_old_state.match('deletingUCI') || prev_old_state.match('deleting') ) { + setTimeout("update_state()", 3000); + } + if ( new_state=='shutting-down' || new_state=='shutting-downUCI' ) { $(elem + "-link").text( "" ); } @@ -89,7 +90,14 @@ // Update 'state' and 'time alive' fields $(elem + "-state").text( data[i].state ); - //$(elem + "-state-p").text( data[i].state ); + if ( ( prev_old_state.match('newUCI') && new_state=='new' ) || \ + ( prev_old_state.match('newUCI') && new_state=='creating' ) || ( prev_old_state.match('new') && new_state=='creating' ) || \ + ( prev_old_state.match('deletingUCI') && new_state=='deleted' ) || ( prev_old_state.match('deleting') && new_state=='deleted' ) || \ + ( prev_old_state.match('available') && new_state=='error' ) || ( prev_old_state.match('deleting') && new_state=='error' ) ) { + // TODO: on state change from available->error and deleting->error page should be refreshed but that causes problems with + // constant refreshings depending on what error message is so at least do it here... + $(elem + "-state-p").text( data[i].state ); + } if (data[i].launch_time) { $(elem + "-launch_time").text( data[i].launch_time.substring(0, 16 ) + " UTC (" + data[i].time_ago + ")" ); }