mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Add dashboard (initial)
This commit is contained in:
parent
116ef1d31f
commit
c795880535
7 changed files with 575 additions and 0 deletions
183
public/lib/stats-vcloud-numbers.js
Normal file
183
public/lib/stats-vcloud-numbers.js
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
var numbers_url = '/dashboard/stats/vcloud/numbers';
|
||||
var numbers_width = 130;
|
||||
var numbers_height = 45;
|
||||
|
||||
var stats_vcloud_numbers__data = {};
|
||||
var stats_vcloud_numbers__svg = {};
|
||||
|
||||
d3.json( numbers_url,
|
||||
|
||||
function( stats_vcloud_numbers__data ) {
|
||||
|
||||
( function tick() {
|
||||
setTimeout( function() {
|
||||
var stats_vcloud_numbers__data__live = ( function() {
|
||||
var stats_vcloud_numbers__data__live = null;
|
||||
|
||||
$.ajax( {
|
||||
'url': numbers_url,
|
||||
'async': false,
|
||||
'global': false,
|
||||
'dataType': 'json',
|
||||
'success': function( data ) {
|
||||
stats_vcloud_numbers__data__live = data;
|
||||
}
|
||||
} );
|
||||
|
||||
return stats_vcloud_numbers__data__live;
|
||||
} )();
|
||||
|
||||
$( '#stats-vcloud-numbers' ).empty();
|
||||
|
||||
stats_vcloud_numbers__svg[ 'ready' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10 25 0 0' )
|
||||
.style( 'padding', '0 0 20 0' )
|
||||
.attr( 'width', numbers_width )
|
||||
.attr( 'height', numbers_height );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'ready' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( 'ready and waiting' )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
'y': numbers_height + 6,
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-size': '12px',
|
||||
'font-weight': 'bold',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'ready' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( stats_vcloud_numbers__data__live[ 'ready' ] )
|
||||
)
|
||||
.attr( {
|
||||
'x': '0',
|
||||
'y': '36',
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-weight': 'bold',
|
||||
'font-size': '50px',
|
||||
'letter-spacing': '-0.05em',
|
||||
'fill': '#444'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'pending' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10 25 0 0' )
|
||||
.style( 'padding', '0 0 20 0' )
|
||||
.attr( 'width', numbers_width )
|
||||
.attr( 'height', numbers_height );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'pending' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( 'being built' )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
'y': numbers_height + 6,
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-size': '12px',
|
||||
'font-weight': 'bold',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'pending' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( stats_vcloud_numbers__data__live[ 'pending' ] )
|
||||
)
|
||||
.attr( {
|
||||
'x': '0',
|
||||
'y': '36',
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-weight': 'bold',
|
||||
'font-size': '50px',
|
||||
'letter-spacing': '-0.05em',
|
||||
'fill': '#444'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'running' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10 25 0 0' )
|
||||
.style( 'padding', '0 0 20 0' )
|
||||
.attr( 'width', numbers_width )
|
||||
.attr( 'height', numbers_height );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'running' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( 'running tests' )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
'y': numbers_height + 6,
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-size': '12px',
|
||||
'font-weight': 'bold',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'running' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( stats_vcloud_numbers__data__live[ 'running' ] )
|
||||
)
|
||||
.attr( {
|
||||
'x': '0',
|
||||
'y': '36',
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-weight': 'bold',
|
||||
'font-size': '50px',
|
||||
'letter-spacing': '-0.05em',
|
||||
'fill': '#444'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'completed' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10 25 0 0' )
|
||||
.style( 'padding', '0 0 20 0' )
|
||||
.attr( 'width', numbers_width )
|
||||
.attr( 'height', numbers_height );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'completed' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( 'waiting to die' )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
'y': numbers_height + 6,
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-size': '12px',
|
||||
'font-weight': 'bold',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'completed' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( stats_vcloud_numbers__data__live[ 'completed' ] )
|
||||
)
|
||||
.attr( {
|
||||
'x': '0',
|
||||
'y': '36',
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-weight': 'bold',
|
||||
'font-size': '50px',
|
||||
'letter-spacing': '-0.05em',
|
||||
'fill': '#444'
|
||||
} );
|
||||
|
||||
tick();
|
||||
}, 5000 );
|
||||
} )();
|
||||
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
166
public/lib/stats-vcloud-pool.js
Normal file
166
public/lib/stats-vcloud-pool.js
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
var pool_url = '/dashboard/stats/vcloud/pool';
|
||||
var pool_width = 130;
|
||||
var pool_height = 70;
|
||||
|
||||
var stats_vcloud_pool__data = {};
|
||||
var stats_vcloud_pool__svg = {};
|
||||
|
||||
d3.json( pool_url+'?history=1',
|
||||
|
||||
function( stats_vcloud_pool__data ) {
|
||||
|
||||
var stats_vcloud_pool__data__keys = [];
|
||||
|
||||
for ( var key in stats_vcloud_pool__data ) {
|
||||
stats_vcloud_pool__data__keys.push( key );
|
||||
}
|
||||
|
||||
stats_vcloud_pool__data__keys.sort().map(
|
||||
function( pool ) {
|
||||
stats_vcloud_pool__data[ pool ][ 'r' ] = stats_vcloud_pool__data[ pool ][ 'history' ];
|
||||
}
|
||||
);
|
||||
|
||||
( function tick() {
|
||||
setTimeout( function() {
|
||||
var stats_vcloud_pool__data__live = ( function() {
|
||||
var stats_vcloud_pool__data__live = null;
|
||||
|
||||
$.ajax( {
|
||||
'url': pool_url,
|
||||
'async': false,
|
||||
'global': false,
|
||||
'dataType': 'json',
|
||||
'success': function( data ) {
|
||||
stats_vcloud_pool__data__live = data;
|
||||
}
|
||||
} );
|
||||
|
||||
return stats_vcloud_pool__data__live;
|
||||
} )();
|
||||
|
||||
$( '#stats-vcloud-pool' ).empty();
|
||||
|
||||
stats_vcloud_pool__data__keys.sort().map(
|
||||
function( pool ) {
|
||||
var x = d3.scale.linear().domain( [ 0, 500 ] ).range( [ 0, pool_width ] );
|
||||
var y = d3.scale.linear().domain( [ parseInt( stats_vcloud_pool__data__live[ pool ][ 'size' ] ), 0 ] ).range( [ 0, pool_height ] );
|
||||
|
||||
var area = d3.svg.area()
|
||||
.interpolate( 'basis' )
|
||||
.x( function( d, i ) { return x( i ); } )
|
||||
.y0( pool_height )
|
||||
.y1( function( d ) { return y( d ); } );
|
||||
|
||||
var path = d3.svg.line()
|
||||
.interpolate( 'basis' )
|
||||
.x( function( d, i ) { return x( i ); } )
|
||||
.y( function( d ) { return y( d ); } );
|
||||
|
||||
stats_vcloud_pool__data[ pool ][ 'r' ].push( parseInt( stats_vcloud_pool__data__live[ pool ][ 'ready' ] ) );
|
||||
|
||||
var pool_current = stats_vcloud_pool__data[ pool ][ 'r' ].slice( -1 )[ 0 ];
|
||||
var pool_size = stats_vcloud_pool__data[ pool ][ 'size' ]
|
||||
var pool_pct = Math.floor( ( pool_current / pool_size ) * 100 );
|
||||
|
||||
var statuscolor = '#78a830';
|
||||
if ( pool_pct < 50 ) { statuscolor = '#f0a800'; }
|
||||
if ( pool_pct < 25 ) { statuscolor = '#d84830'; }
|
||||
|
||||
stats_vcloud_pool__svg[ pool ] = d3.select( '#stats-vcloud-pool' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '15 25 0 0' )
|
||||
.style( 'padding', '0 0 20 0' )
|
||||
.attr( 'width', pool_width )
|
||||
.attr( 'height', pool_height );
|
||||
|
||||
stats_vcloud_pool__svg[ pool ]
|
||||
.append( 'g' )
|
||||
.attr( 'class', 'x tick' )
|
||||
.attr( 'transform', 'translate( 0,' + pool_height + ')' )
|
||||
.call(
|
||||
d3.svg.axis()
|
||||
.scale( x )
|
||||
.ticks( 4 )
|
||||
.tickSize( -pool_height )
|
||||
.outerTickSize( 0 )
|
||||
.tickFormat( '' )
|
||||
.tickSubdivide( true )
|
||||
.orient( 'bottom' )
|
||||
);
|
||||
|
||||
stats_vcloud_pool__svg[ pool ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( pool )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
'y': pool_height + 15,
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-weight': 'bold',
|
||||
'font-size': '12px',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_pool__svg[ pool ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( pool_pct + '%' )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
'y': pool_height - 5,
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-weight': 'bold',
|
||||
'font-size': '12px',
|
||||
'letter-spacing': '-0.05em',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_pool__svg[ pool ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( '( ' ) +
|
||||
( pool_current ) +
|
||||
( '/' ) +
|
||||
( pool_size ) +
|
||||
( ' )' )
|
||||
)
|
||||
.attr( {
|
||||
'x': 40,
|
||||
'y': pool_height - 5,
|
||||
'font-face': 'PT Sans sans-serif',
|
||||
'font-size': '12px',
|
||||
'letter-spacing': '-0.05em',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_pool__svg[ pool ]
|
||||
.append( 'path' )
|
||||
.attr( 'class', 'area' )
|
||||
.attr( 'fill', statuscolor )
|
||||
.attr( 'opacity', '0.25' )
|
||||
.attr( 'd', area( stats_vcloud_pool__data[ pool ][ 'r' ] ) );
|
||||
|
||||
stats_vcloud_pool__svg[ pool ]
|
||||
.append( 'path' )
|
||||
.attr( 'class', 'line' )
|
||||
.attr( 'stroke', statuscolor )
|
||||
.attr( 'stroke-width', '1' )
|
||||
.attr( 'd', path( stats_vcloud_pool__data[ pool ][ 'r' ] ) );
|
||||
|
||||
if ( stats_vcloud_pool__data[ pool ][ 'r' ].length > 500 ) {
|
||||
stats_vcloud_pool__data[ pool ][ 'r' ].shift();
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
tick();
|
||||
}, 5000 );
|
||||
} )();
|
||||
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue