summaryrefslogblamecommitdiffstats
path: root/modules-available/statistics/templates/clientlist.html
blob: fcb98774931c1b594521ae50ee5aebd0687b7fd6 (plain) (tree)
1
2
3
4
5
6
7
8





                                                
 
                                           



                                                                                
 
                                                           

                                                           
 
                                                                                
               
                               






                                                                               








                                                                                                                      



                         
                                    
                                                                               
                                                              
                                                                                                                      

                                               
                                                 
                                     


                                                                                                                                    
                                     





                                                                                                                                                            
                                          
                                                                                                         

                                          
                                                                                                               

                                           
                                                                                                                   



                                                                                                           


                                                                                  
                                                                            


                                                 
                                                                             
                                     
                                                                              


                                                                                                                                        







                                                                                             





                                                      
                             
                                                           
                                                                                                                                             


                                                                              


                                                                               
                                                                                                               
                                                                  

                                                                                                                 
                                                    

                                                                                                                                          
                                                      
                                                            
                                                  
                                                                                         






                                                                                             
                             
                                                                            

                                                        
                                                                                                                                       
                                                                                      


                         
        

                                                             
                                                                         

                                      
                                              

                                                                                                                           




















                                                                                                         




                                                                                                                     
                             
                      
                                  
                                              




                                                                                                                           
                                 



























                                                                                                                                              


                                                                                                                                         
                                                                         

                                                         


                                      

                                  
                                              




                                                                                                                         














                                                                                                                                            
                              
              




                                                                                                        

                      
       
 














                                                                                                                      














                                                                                                         
                                          
 

                     
                                                           
                                                




                                                                                       








                                                   
                                                        






                                                                                                                          



                                                                                                    
                                                                                           




                              




                                                               
                                         
                                                           


                                                 








                                                                                                           


                                                                              

                                                    

                                                    

                    
                                                                   

                                  




                                                
                                                      




                                                                                                                                                                















                                                                                            

   
                                
 
                       


                                      











                                                                                                     
              
<div class="slx-right">
	{{{roomsvg}}}
	{{#sidebar}}
		<div class="infobox">{{.}}</div>
	{{/sidebar}}
</div>

<h2>{{lang_clientList}} ({{rowCount}})</h2>
<button class="btn btn-default" type="button" data-toggle="modal"
		  data-target="#column-selector">{{lang_selectColumns}}</button>

<div class="clearfix"></div>

<form method="post" action="?do=statistics" id="list-form">
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="redirect" value="?{{redirect}}">

<table id="client-list" class="stupidtable table table-condensed table-striped">
	<thead>
		<tr id="thead">
			<th data-sort="string">
				<div class="checkbox checkbox-inline">
					<input type="checkbox" id="toggle-all">
					<label></label>
				</div>
				{{lang_machine}}
			</th>
			<th data-sort="ipv4" data-column="clientip">{{lang_address}}</th>
			<th data-sort="int" data-column="nicspeed" class="text-right">{{lang_nicSpeed}}</th>
			<th data-sort="int" data-column="lastseen" class="text-right">{{lang_lastSeen}}</th>
			<th data-sort="string" data-column="kvmstate">{{lang_kvmSupport}}</th>
			<th data-sort="int" data-column="gbram" class="text-right">{{lang_gbRam}}</th>
			<th data-sort="int" data-column="hddgb" class="text-right">{{lang_tmpGb}}</th>
			<th data-sort="int" data-column="persistentgb" class="text-right">{{lang_persistentPart}}</th>
			<th data-sort="int" data-column="realcores">{{lang_cpuModel}}</th>
			<th data-sort="string" data-column="location">{{lang_location}}</th>
		</tr>
	</thead>
	<tbody>
		{{#rows}}
		<tr class="machine">
			<td data-sort-value="{{hostname}}" class="text-nowrap">
			<div class="checkbox checkbox-inline">
				<input type="checkbox" name="uuid[]" value="{{machineuuid}}" class="machine-checkbox">
				<label></label>
			</div>
			<span class="pull-right">
			{{#hasnotes}}
				<a href="?do=Statistics&amp;uuid={{machineuuid}}#usernotes" class="badge" title="{{lang_hasNotes}}">
					<span class="glyphicon glyphicon-tags"></span>
				</a>
			{{/hasnotes}}
			{{#confvars}}
				<a href="?do=baseconfig&amp;module=statistics&amp;machineuuid={{machineuuid}}" class="badge" title="{{lang_numConfigVars}}">
					<span class="glyphicon glyphicon-pencil"></span>{{confvars}}
				</a>
			{{/confvars}}
			</span>
			{{#state_OFFLINE}}
				<span class="glyphicon glyphicon-off" title="{{lang_machineOff}}"></span>
			{{/state_OFFLINE}}
			{{#state_IDLE}}
				<span class="glyphicon glyphicon-ok green" title="{{lang_machineIdle}}"></span>
			{{/state_IDLE}}
			{{#state_OCCUPIED}}
				<span class="glyphicon glyphicon-user red" title="{{lang_machineOccupied}}"></span>
			{{/state_OCCUPIED}}
			{{#state_STANDBY}}
			<span class="glyphicon glyphicon-off green" title="{{lang_machineStandby}}"></span>
			{{/state_STANDBY}}
				{{#link_details}}
				<a href="?do=Statistics&amp;uuid={{machineuuid}}">
				{{/link_details}}
					<b class="hostname">{{hostname}}</b>
				{{#link_details}}
				</a>
				{{/link_details}}
				<div class="small uuid">{{machineuuid}}</div>
			{{#rmmodule}}
				<div class="small">{{lang_configuredRunMode}}:
					<a class="slx-bold" href="?do=runmode&amp;module={{rmmodule}}">{{moduleName}}</a> / {{modeName}}
				</div>
			{{/rmmodule}}
			{{#wrongRunMode}}
				<div class="small text-danger">
					{{lang_clientInDifferentRunmode}}: {{currentrunmode}}
					{{^currentrunmode}}
					{{lang_bootedWithoutAnyRunmode}}
					{{/currentrunmode}}
				</div>
			{{/wrongRunMode}}
			{{#currentuser}}
			<div class="small">
				{{lang_user}}:
				<b>{{currentuser}}</b>
			</div>
			{{/currentuser}}
			</td>
			<td data-sort-value="{{clientip}}">
				<b><a href="?do=statistics&amp;show=list&amp;filters=clientip={{subnet}}/24">{{subnet}}.</a>{{lastoctet}}</b>
				<div class="mac text-nowrap">{{macaddr}}</div>
				<div class="hidden ip">{{clientip}}</div>
			</td>
			<td data-sort-value="{{nic-speed}}" class="text-right">
				{{nic-speed_s}}&thinsp;MBit/s
			</td>
			<td data-sort-value="{{lastseen_int}}" class="text-right text-nowrap">{{lastseen}}</td>
			<td class="{{kvmclass}}">{{kvmstate}}</td>
			<td data-sort-value="{{mbram}}" class="text-right {{ramclass}}">{{gbram}}&thinsp;GiB</td>
			<td data-sort-value="{{id44mb}}" class="text-right {{hddclass}}">
				{{gbtmp}}&thinsp;GiB
				{{#badsectors}}<div><span data-toggle="tooltip" title="{{lang_reallocatedSectors}}" data-placement="left">
					<span class="glyphicon glyphicon-exclamation-sign"></span>
					{{badsectors}}
				</span></div>{{/badsectors}}
				{{^hddcount}}<div>
					<span class="glyphicon glyphicon-hdd red"></span>
				</div>{{/hddcount}}
				{{#hddcount}}<div>
					<span class="badge">
						<span class="glyphicon glyphicon-hdd"></span>
						{{hddcount}}
					</span>
				</div>{{/hddcount}}
			</td>
			<td data-sort-value="{{id45mb}}" class="text-right">
				{{gbpersist}}&thinsp;GiB
			</td>
			<td data-sort-value="{{realcores}}">{{lang_realCores}}: {{realcores}}<div class="small">{{cpumodel}}</div></td>
			<td data-sort-value="{{location.sort}}">{{location.name}}</td>
		</tr>
		{{/rows}}
	</tbody>
</table>
	<div class="text-right buttonbar">
		<button type="reset" class="btn btn-default">
			<span class="glyphicon glyphicon-refresh"></span>
			{{lang_reset}}
		</button>
		<div class="btn-group dropup">
			<button class="btn btn-default dropdown-toggle btn-machine-action" type="button" id="dropdownMenu1"
					  data-toggle="dropdown" aria-haspopup="true">
				<span class="glyphicon glyphicon-list"></span>
				{{lang_listDropdown}}
				<span class="caret"></span>
			</button>
			<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
				<li><a href="#" class="list-btn" data-what="hostname" data-toggle="modal"
						 data-target="#mac-list">
					{{lang_hostname}}
				</a></li>
				<li><a href="#" class="list-btn" data-what="ip" data-toggle="modal"
								data-target="#mac-list">
					{{lang_ip}}
				</a></li>
				<li><a href="#" class="list-btn" data-what="mac" data-toggle="modal"
						 data-target="#mac-list">
					{{lang_macAddr}}
				</a></li>
				<li><a href="#" class="list-btn" data-what="uuid" data-toggle="modal"
						 data-target="#mac-list">
					{{lang_uuid}}
				</a></li>
				<hr style="margin: 0px">
				<li><a href="#" class="list-btn" data-what="hostname ip mac uuid" data-toggle="modal"
						 data-target="#mac-list">
					{{lang_fullInfo}}
				</a></li>
			</ul>
		</div>
		{{#rebootcontrol}}
		<div class="btn-group dropup">
			<button class="btn btn-default dropdown-toggle btn-machine-action" type="button" id="dropdownMenu2"
					  data-toggle="dropdown" aria-haspopup="true">
				<span class="glyphicon glyphicon-list"></span>
				{{lang_remoteActions}}
				<span class="caret"></span>
			</button>
			<div class="dropdown-menu" style="padding:0" aria-labelledby="dropdownMenu2">
				<div class="btn-group-vertical">
					{{#canShutdown}}
					<button type="submit" name="action" value="shutdownmachines" class="btn btn-danger btn-machine-action"
							  data-confirm="{{lang_shutdownConfirm}}" data-title="{{lang_shutdown}}">
						<span class="glyphicon glyphicon-off"></span>
						{{lang_shutdown}}
					</button>
					{{/canShutdown}}
					{{#canReboot}}
					<button type="submit" name="action" value="rebootmachines" class="btn btn-warning btn-machine-action"
							  data-confirm="#confirm-reboot">
						<span class="glyphicon glyphicon-repeat"></span>
						{{lang_reboot}}
					</button>
					{{/canReboot}}
					{{#canWol}}
					<button type="submit" name="action" value="wol" class="btn btn-primary btn-machine-action">
						<span class="glyphicon glyphicon-bell"></span>
						{{lang_wakeOnLan}}
					</button>
					{{/canWol}}
					{{#canExec}}
					<button type="submit" name="action" value="prepare-exec" class="btn btn-primary btn-machine-action">
						<span class="glyphicon glyphicon-play"></span>
						{{lang_remoteExec}}
					</button>
					{{/canExec}}
					{{#canBenchmark}}
					<button type="submit" name="action" value="benchmark" class="btn btn-primary btn-machine-action">
						<span class="glyphicon glyphicon-dashboard"></span>
						{{lang_remoteSpeedcheck}}
					</button>
					{{/canBenchmark}}
				</div>
			</div>
		</div>
		{{/rebootcontrol}}
		{{#canDelete}}
		<div class="btn-group dropup">
			<button type="submit" name="action" value="delmachines" class="btn btn-danger btn-machine-action"
					  data-confirm="{{lang_sureDeletePermanent}}">
				<span class="glyphicon glyphicon-trash"></span>
				{{lang_delete}}
			</button>
			<button type="button" class="btn btn-danger btn-machine-action dropdown-toggle"
					  data-toggle="dropdown" aria-haspopup="true">
				<span class="caret"></span>
				<span class="sr-only">Toggle Dropdown</span>
			</button>
			<div class="dropdown-menu" style="padding:0">
				<div class="btn-group-vertical">
					<button type="submit" name="action" value="clear-machines" class="btn btn-danger btn-machine-action"
							  data-confirm="{{lang_sureClearIp}}">
						<span class="glyphicon glyphicon-refresh"></span>
						{{lang_resetClearIp}}
					</button>
				</div>
			</div>
		</div>
		{{/canDelete}}
	</div>
	<div class="hidden" id="confirm-reboot">
		<p>{{lang_rebootConfirm}}</p>
		<div class="checkbox">
			<input type="checkbox" name="kexec" value="1" id="kexec-input" form="list-form">
			<label for="kexec-input">{{lang_rebootKexecCheck}}</label>
		</div>
	</div>
</form>

<div class="modal" id="mac-list" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">&times;</button>
			</div>
			<div class="modal-body"><textarea class="form-control" id="mac-list-content"></textarea></div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default"
						  data-dismiss="modal">{{lang_close}}</button>
			</div>
		</div>
	</div>
</div>

<div class="modal" id="column-selector" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">&times;</button>
			</div>
			<div class="modal-body"></div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default"
						  data-dismiss="modal">{{lang_close}}</button>
			</div>
		</div>
	</div>
</div>

<script type="application/javascript"><!--

var lookupTable = {};

document.addEventListener("DOMContentLoaded", function () {
	var $buttons = $('.btn-machine-action');
	var $fn = function () {
		$buttons.prop("disabled", $('.machine-checkbox:checked').length === 0);
	};
	var $boxes = $('.machine-checkbox');
	$boxes.change($fn);

	// Shift click selection for the checkboxes
	var lastChecked = null;
	$boxes.click(function(e) {
		if (!lastChecked) {
			lastChecked = this;
			return;
		}
		if (e.shiftKey) {
			$boxes = $('.machine-checkbox');
			const start = $boxes.index(this);
			const end = $boxes.index(lastChecked);
			$boxes.slice(Math.min(start, end), Math.max(start, end) + 1).prop('checked', lastChecked.checked);
		}
		lastChecked = this;
	});

	$("button[type=reset]").click(function() { setTimeout($fn, 1); });
	if (window && window.opera && window.opera.version && Number(window.opera.version()) < 13) {
		$(document).ready(function () {
			setTimeout(function () {
				$('div.checkbox > input.machine-checkbox').click().click();
			}, 1);
		});
	} else {
		$fn();
	}
	$('#toggle-all').click(function(e) {
		e.stopPropagation();
		$boxes.prop('checked', $(this).is(':checked'));
		$fn();
	});
	$('.list-btn').click(function() {
		var what = $(this).data('what').split(" ");
		var $el = $('#mac-list-content');
		$el.empty();
		var result = '';
		var num = $('.machine').has('input[type=checkbox]:checked').each(function(index, element) {
			what.forEach(function (w) {
				$(element).find('.' + w).each(function() {
					var text = this.innerText;
					if (w === 'mac') text = text.replace(/-/g, ':');
					result += text + "\t";
				});
			});
			result += "\n";
		}).length;
		$el.text(result).prop('rows', Math.min(24, Math.max(5, num)));
	});
	// Generate list for column selection
	var $cs = $('#column-selector .modal-body');
	var $filters = $('<tr>');
	$('#client-list > thead').prepend($filters);
	var idx = 0;
	$cs.empty();
	$('#client-list > thead > tr#thead > th').each(function() {
		idx++;
		var $th = $(this);
		var $td = $('<td>');
		$filters.append($td);
		var column = $th.data('column');
		if (!column)
			return;
		$cs.append($('<div class="checkbox">')
				.append($('<input id="shc-' + column + '" type="checkbox" onclick="toggleColumn(this, \'' + column + '\')" checked="checked">'))
				.append($('<label for="shc-' + column + '">').text($th.text())));
		$td.append($('<button type="button" class="btn btn-default btn-xs" onclick="popupFilter(\'' + column + '\')">'
				+ '<span class="glyphicon glyphicon-filter"></span></button>'));
		lookupTable[column] = idx;
	});
	// Load previous visibility settings
	var colConf;
	if (window.localStorage && (colConf = window.localStorage.getItem('cl-col-conf'))) {
		colConf = JSON.parse(colConf);
		if (colConf) {
			for (var k in colConf) {
				if (k.substring(0, 4) === 'shc-' && colConf[k]) {
					var $cb = $('#' + k);
					if ($cb.prop('checked')) {
						$cb.click();
					}
				}
			}
		}
	}
});

function toggleColumn(e, column)
{
	var $el = $(e);
	if (!(column in lookupTable))
		return;
	var idx = lookupTable[column];
	$('#client-list tr > td:nth-child(' + idx + '), #client-list tr > th:nth-child(' + idx + ')')
			.css('display', $el.is(':checked') ? '' : 'none');
	var data = {};
	$('#column-selector .modal-body .checkbox input').each(function() {
		var $el = $(this);
		if (!$el.is(':checked')) {
			data[$el[0].id] = 1;
		}
	});
	window.localStorage.setItem('cl-col-conf', JSON.stringify(data));
}

//--></script>