summaryrefslogblamecommitdiffstats
path: root/modules-available/locations/templates/locations.html
blob: 7bdf3038f6a7bf1f137e881e82287ea4bbfadead (plain) (tree)
1
2
3
4
5
6
7
8
9
10
     
                                          







                                                                                                                       

                                              











                                                                                            
                                                                               
                    
                                                                   


                                                                                           


                                                                                          
                                                

                                                                                                  
                                                
                                                                                      
                             


                                                                           


                            
                                                        
                                                                                                  








                                                                                                                          
                                     
                                                                      
                                                           




                                                                                                                                                          
                                               
                                                           
                                     




                                                                      
                                                                            
                                                           



                                                                                                                                                                                                             
                                                                                              
                                                           
                                                           
                                     
                                                        
                                                          



                                                                                                                                                                                       
                                                                  
                                               

                                                          









                                                                                                                                                                                                                         

                             

                                    
                                                            
                                                              

                                                                                              
                                    
                                                                                    
                             
                                                              
                                                  
                             

                                                  

                                    



                                                                        
                                                     
                                        
                                                           
                                                                   
                                                                                                                                                    
                                                                                                                
                                                 


                                                                                                                     
                                     



                             
 



                                   

                      
                              
                                      
                              
                                                      

                                                                                                                                                                  
                                                                                                                                            
                               
                                                                                                                                                                                                                  

                        








                                              











                                                                         
                                        

                                                                       
                                                


                       
                                                                               


                                                                 

                                                                                   
                                  
           


                             












                                                               

                                      
                                                                        
                           

                                                                                                                                                                        
                                                                                                                                                                                                                

                        
                        

 



                                







                                                                   

              
<div>
	<div class="btn-group pull-right">
		<a href="?do=Locations&amp;action=showlocations" class="btn btn-default active">
			<span class="glyphicon glyphicon-home"></span>
			{{lang_thisListByLocation}}
		</a>
		<a href="?do=Locations&amp;action=showsubnets" class="btn btn-default {{perms.subnets.edit.disabled}}">
			<span class="glyphicon glyphicon-list-alt"></span>
			{{lang_thisListBySubnet}}
		</a>
	</div>
	<h1>{{lang_locationsMainHeading}}</h1>

	{{#overlapSelf}}
		<div class="alert alert-warning">
			{{lang_locationSelfOverlap}}: <b>{{locationname}}</b>
		</div>
	{{/overlapSelf}}
	{{#overlapOther}}
		<div class="alert alert-danger">
			{{lang_locationOtherOverlap}}: <b>{{name1}}</b><b>{{name2}}</b>
		</div>
	{{/overlapOther}}

	<table class="table table-condensed locations" style="margin-bottom:0">
		<tr>
			<th width="100%">{{lang_locationName}}</th>
			<th>
				{{#havestatistics}}{{lang_machineCount}}{{/havestatistics}}
			</th>
			<th>
				{{#havestatistics}}{{lang_machineLoad}}{{/havestatistics}}
			</th>
			<th class="text-nowrap">
				{{#havebaseconfig}}{{lang_editConfigVariables}}{{/havebaseconfig}}
			</th>
			<th class="text-nowrap">
				{{#havesysconfig}}{{lang_sysConfig}}{{/havesysconfig}}
			</th>
			<th class="text-nowrap">
				{{#haveipxe}}{{lang_bootMenu}}{{/haveipxe}}
			</th>
		</tr>
		{{#list}}
			<tr>
				<td class="text-nowrap">
					<div style="display:inline-block;width:{{depth}}em"></div>
					{{#show-only}}
						<span>{{locationname}}</span>
					{{/show-only}}
					{{^show-only}}
						<a href="#" onclick="slxOpenLocation(this, {{locationid}}); return false">
							{{locationname}}
							<b class="caret"></b>
						</a>
					{{/show-only}}
				</td>
				<td class="text-nowrap" align="right">
					{{#havestatistics}}
						<a href="?do=Statistics&amp;show=list&amp;filters=location={{locationid}}">&nbsp;{{clientCount}}&nbsp;</a>
					<span style="display:inline-block;width:5ex">
					{{#hasChild}}
					(<a href="?do=Statistics&amp;show=list&amp;filters=location~{{locationid}}">&downarrow;{{clientCountSum}}</a>)
					{{/hasChild}}
					</span>
					{{/havestatistics}}
				</td>
				<td class="text-nowrap" align="right">
					{{#havestatistics}}
					{{clientLoad}}
					{{/havestatistics}}
				</td>
				<td class="text-nowrap {{overriddenClass}}">
					{{#havebaseconfig}}
					<div class="pull-right" style="z-index:-1">
						<a class="btn btn-default btn-xs" href="?do=baseconfig&amp;module=locations&amp;locationid={{locationid}}"><span class="glyphicon glyphicon-edit"></span></a>
					</div>
					{{#overriddenVars}}
					{{lang_overrideCount}}: {{overriddenVars}}&emsp;&emsp;
					{{/overriddenVars}}
					{{/havebaseconfig}}
				</td>
				<td class="text-nowrap">
					{{#havesysconfig}}
					<div class="pull-right">
						<a class="btn btn-default btn-xs" href="?do=sysconfig&amp;locationid={{locationid}}"><span class="glyphicon glyphicon-edit"></span></a>
					</div>
					<span class="{{configClass}}">
					{{configName}}&emsp;&emsp;
					</span>
					{{/havesysconfig}}
				</td>
				<td class="text-nowrap">
					{{#haveipxe}}
						<div class="pull-right">
							<a class="btn btn-default btn-xs" href="?do=serversetup&amp;show=assignlocation&amp;locationid={{locationid}}"><span class="glyphicon glyphicon-edit"></span></a>
						</div>
						<span class="{{customMenuClass}}">
					{{customMenu}}&emsp;&emsp;
					</span>
					{{/haveipxe}}
				</td>
			</tr>
		{{/list}}
		{{#unassignedCount}}
		<tr>
			<td>{{lang_unassignedMachines}}</td>
			<td class="text-nowrap" align="right">
				<a href="?do=Statistics&amp;show=list&amp;filters=location=0">
					&nbsp;{{unassignedCount}}&nbsp;
				</a>
				<span style="display:inline-block;width:5ex"></span>
			</td>
			<td class="text-nowrap" align="right">
				{{unassignedLoad}}
			</td>
			<td></td>
			<td>{{defaultConfig}}</td>
		</tr>
		{{/unassignedCount}}
	</table>
	<form method="post" action="?do=Locations">
		<input type="hidden" name="token" value="{{token}}">
		<input type="hidden" name="action" value="addlocations">
		<table class="table table-condensed">
			<tr id="lasttr">
				<td width="60%">&emsp;</td>
				<td class="text-right" colspan="2">
					<button {{perms.location.add.disabled}} class="btn btn-success" type="button" onclick="slxAddLocationRow()">
						<span class="glyphicon glyphicon-plus"></span> {{lang_location}}
					</button>
					<button id="saveLocationRows" type="submit" class="btn btn-primary collapse">
						<span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}
					</button>
				</td>
			</tr>
		</table>
	</form>
</div>

<script type="text/javascript"><!--
var slxAddCounter = 0;
var slxLastLocation = false;

var newRowCounter = 0;

function slxAddLocationRow() {
	$("#saveLocationRows").show();
	var tr = $('#lasttr');
	tr.before('<tr id="row' + slxAddCounter + '">\
		<td><input class="form-control" type="text" name="newlocation[' + slxAddCounter + ']" placeholder="{{lang_locationName}}" pattern=".*\\S.*"></td>\
		<td><select class="form-control" name="newparent[' + slxAddCounter + ']">\
		{{#addAllowedList}}<option {{disabled}} value="{{locationid}}">{{locationpad}} {{locationname}}</option>{{/addAllowedList}}\
		</select></td>\
		<td class="text-center"><button class="btn btn-default btn-sm" type="button" onclick="removeNewLocationRow(' + slxAddCounter + ')"><span class="glyphicon glyphicon-remove"></span></button></td>\
	</tr>');
	slxAddCounter++;
	newRowCounter++;
}

function removeNewLocationRow(r) {
	$("#row"+r).remove();
	newRowCounter--;
	if (newRowCounter === 0) {
		$("#saveLocationRows").hide();
	}
}

function slxOpenLocation(e, lid) {
	if (slxLastLocation !== false) {
		slxLastLocation.hide();
		$(slxLastLocation).prev().removeClass('active slx-bold');
	}
	var existing = $('#location-details-' + lid);
	if (existing.length > 0) {
		if (existing.is(slxLastLocation)) {
			slxLastLocation = false;
		} else {
			existing.show();
			$(e).closest('tr').addClass('active slx-bold');
			slxLastLocation = existing;
			scollIntoView(existing);
		}
		return;
	}
	var td = $('<td>').attr('colspan', '6').css('padding', '0px 0px 12px');
	var tr = $('<tr>').attr('id', 'location-details-' + lid);
	tr.append(td);
	$(e).closest('tr').addClass('active slx-bold').after(tr);
	td.load('?do=Locations&action=showlocation&locationid=' + lid, function() {
		slxAttachCidr();
		scollIntoView(tr);
	});
	slxLastLocation = tr;
}

function scollIntoView(el) {
	var offset = $(el).offset();
	var win = $(window);
	var h = $(el).height();
	if (offset.top +  h > win.scrollTop() + win.height()) {
		offset.top -= win.height();
		offset.top += h;
		$('html, body').animate({
			scrollTop: offset.top
		});
	}
}

function slxAddSubnetRow(e, lid) {
	var tr = $('#loc-sub-' + lid);
	tr.before('<tr id="row' + slxAddCounter + '" class="cidrmagic">\
		<td>#</td>\
		<td><input class="form-control cidrstart" type="text" name="newstartaddr[' + slxAddCounter + ']" pattern="\\d{1,3}\.\\d{1,3}\.\\d{1,3}\.\\d{1,3}"></td>\
		<td><input class="form-control cidrend" type="text" name="newendaddr[' + slxAddCounter + ']" pattern="\\d{1,3}\.\\d{1,3}\.\\d{1,3}\.\\d{1,3}"></td>\
		<td class="text-center"><button class="btn btn-default btn-sm" type="button" onclick="removeNewSubnetRow(' + slxAddCounter + ')"><span class="glyphicon glyphicon-remove"></span></button></td>\
	</tr>');
	slxAddCounter++;
	slxAttachCidr();
}

function removeNewSubnetRow(r) {
	$("#row"+r).remove();
}

function deleteSubnetWarning(locid) {
	var form = $("#locationForm"+locid);
	if (form.find("input[type=checkbox]:checked").length > 0) {
		$("#saveWarningModal"+locid).modal();
	} else {
		form.submit();
	}
}
	// -->
</script>