summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-06-21 10:51:26 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-06-21 10:51:26 +0200
commitfa55b7f146bceed4a85637f7747877a9c9ceebc6 (patch)
treedd80b9d6ae72939e5ec705332d14ccf990fed79a
parent913f275c092d4d6631a0d745f1d382759d3513c0 (diff)
downloadbiruda-fa55b7f146bceed4a85637f7747877a9c9ceebc6.tar.gz
biruda-fa55b7f146bceed4a85637f7747877a9c9ceebc6.tar.bz2
implemented start/stop in the web interface, disabling disabled workers
-rw-r--r--src/index.html35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/index.html b/src/index.html
index ed3d1fd..b25d1db 100644
--- a/src/index.html
+++ b/src/index.html
@@ -52,14 +52,18 @@
$.each( lines, function( ) {
var fields = this.split( ' ' );
var type = fields[0];
- var name = fields[1];
- var status = fields[2];
if( type == "worker" ) {
+ var name = fields[1];
+ var status = fields[2];
+ var workertype = fields[3];
+
var start_button = "<button id=\"start_" + name + "\">Start</button><script>$( \"#start_" + name + "\" ).button( );<\/script>";
var stop_button = "<button id=\"stop_" + name + "\">Stop</button><script>$( \"#stop_" + name + "\" ).button( );<\/script>";
var details_button = "<button id=\"details_" + name + "\">Details</button><script>$( \"#details_" + name + "\" ).button( );<\/script>";
var buttons = start_button + stop_button + details_button;
+
html += "<tr><td>" + name + "</td><td>" + status + "</td><td>" + buttons + "</td></tr>\n";
+
if( status == "running" ) {
html += '<script>$( "#start_' + name + '" ).button( "option", "disabled", true );<\/script>\n';
}
@@ -67,6 +71,14 @@
html += '<script>$( "#stop_' + name + '" ).button( "option", "disabled", true );<\/script>\n';
}
+ if( workertype == "disabled" ) {
+ html += '<script>$( "#start_' + name + '" ).button( "option", "disabled", true );<\/script>\n';
+ html += '<script>$( "#stop_' + name + '" ).button( "option", "disabled", true );<\/script>\n';
+ html += '<script>$( "#details_' + name + '" ).button( "option", "disabled", true );<\/script>\n';
+ }
+
+ html += '<script>$( "#start_' + name + '" ).click( function( ) { startWorker( "' + name + '" ); } );<\/script>\n';
+ html += '<script>$( "#stop_' + name + '" ).click( function( ) { stopWorker( "' + name + '" ); } );<\/script>\n';
html += '<script>$( "#details_' + name + '" ).click( function( ) { showWorkerTab( "' + name + '" ); } );<\/script>\n';
}
});
@@ -74,7 +86,7 @@
}
$( '#tabs-1' ).html( html );
}).fail( function( ) {
- $( '#tabs-1' ).html( "<p>Couldn't load status of biruda. Check if biruda is running and the webserver is enabled.</p>" )
+ $( '#tabs-1' ).html( "<p>Couldn't load status of biruda. Check if biruda is running and the webserver is enabled.</p>" );
});
}
@@ -100,6 +112,23 @@
tabs.tabs( "option", "active", $( "#" + id ).index( ) - 1 );
}
+ function startWorker( worker ) {
+ $.post( "/worker?op=start&name=" + worker, { } )
+ .done( function( data ) {
+ }).fail( function( ) {
+ alert( "Couldn't start worker. Check if biruda is running and the webserver is enabled." );
+ });
+
+ }
+
+ function stopWorker( worker ) {
+ $.post( "/worker?op=stop&name=" + worker, { } )
+ .done( function( data ) {
+ }).fail( function( ) {
+ alert( "Couldn't stop worker. Check if biruda is running and the webserver is enabled." );
+ });
+ }
+
var refreshId = setInterval( refresh_status, 5000 );
</script>