summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-06-20 17:52:19 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-06-20 17:52:19 +0200
commit6335f8c9bc97c0e0316d3ac528ed3d878d982cf0 (patch)
treee3df2bd79b477f5b83511edfb3420917b0f3e68a
parent7671311f029531ad8bbb5a10a21ba9a22cd18687 (diff)
downloadbiruda-6335f8c9bc97c0e0316d3ac528ed3d878d982cf0.tar.gz
biruda-6335f8c9bc97c0e0316d3ac528ed3d878d982cf0.tar.bz2
dynamic worker tabs on button click in web ui
-rw-r--r--src/index.html54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/index.html b/src/index.html
index d7dddb1..846c00f 100644
--- a/src/index.html
+++ b/src/index.html
@@ -1,5 +1,7 @@
-<html>
+<!doctype html>
+<html lang="en">
<head>
+ <meta charset="utf-8"/>
<title>biruda</title>
<link rel="stylesheet" href="/web/jquery-ui.css"/>
@@ -37,7 +39,7 @@
if( data == '' ) {
html = "<p>Loading..</p>";
} else {
- html = "<table><tr><th>worker</th><th>status</th></tr>\n";
+ html = "<table><tr><th>worker</th><th>status</th><th>action</th></tr>\n";
var lines = data.split( '\n' );
$.each( lines, function( ) {
var fields = this.split( ' ' );
@@ -45,7 +47,19 @@
var name = fields[1];
var status = fields[2];
if( type == "worker" ) {
- html += "<tr><td>" + name + "</td><td>" + status + "</td></tr>\n";
+ 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';
+ }
+ if( status == "stopped" ) {
+ html += '<script>$( "#stop_' + name + '" ).button( "option", "disabled", true );<\/script>\n';
+ }
+
+ html += '<script>$( "#details_' + name + '" ).click( function( ) { showWorkerTab( "' + name + '" ); } );<\/script>\n';
}
});
html += "</table>\n";
@@ -57,11 +71,36 @@
}
+ var tabTemplate = "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' role='presentation'>Remove Tab</span></li>";
+
+ function showWorkerTab( worker ) {
+ var label = worker;
+ var id = "tab-worker-" + worker;
+
+ var tabs = $( "#tabs" ).tabs( );
+ if( $( "#" + id ).length ) {
+ tabs.tabs( "option", "active", $( "#" + id ).index( ) - 1 );
+ return;
+ }
+
+ var li = $( tabTemplate.replace( /#\{href\}/g, "#" + id ).replace( /#\{label\}/g, label ) );
+ var tabContentHtml = "worker details of worker '" + worker + "'";
+
+ tabs.find( ".ui-tabs-nav" ).append( li );
+ tabs.append( "<div id='" + id + "'><p>" + tabContentHtml + "</p></div>" );
+ tabs.tabs( "refresh" );
+ tabs.tabs( "option", "active", $( "#" + id ).index( ) - 1 );
+ }
+
var refreshId = setInterval( refresh_status, 5000 );
</script>
<style>
+ body {
+ font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";
+ font-size: 62.5%;
+ }
#tabs li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; }
</style>
@@ -71,19 +110,10 @@
<div id="tabs">
<ul>
<li><a href="#tabs-1">Status</a></li>
- <li><a href="#tabs-2">Worker 1</a><span class='ui-icon ui-icon-close' role='presentation'>Close</span></li>
- <li><a href="#tabs-3">Worker 2</a><span class='ui-icon ui-icon-close' role='presentation'>Close</span></li>
</ul>
<div id="tabs-1">
<p>.. loading status ..</p>
</div>
- <div id="tabs-2">
- <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
- </div>
- <div id="tabs-3">
- <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
- <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
- </div>
</div>
</body>
</html>