summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/templates/locations.html
blob: 451d8addfacc3f056c0549553a8c3022e97bc0e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<div>
	<div class="btn-group pull-right">
		<a href="?do=Locations&amp;action=showlocations" class="btn btn-primary"><span class="glyphicon glyphicon-home"></span> {{lang_thisListByLocation}}</a>
		<a href="?do=Locations&amp;action=showsubnets" class="btn btn-default"><span class="glyphicon glyphicon-list-alt"></span> {{lang_thisListBySubnet}}</a>
	</div>
	<h1>{{lang_locationsMainHeading}}</h1>
	<table class="table table-condensed locations" style="margin-bottom:0px">
		<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>
		</tr>
		{{#list}}
			<tr>
				<td>
					<div style="display:inline-block;width:{{depth}}em"></div>
					<a href="#" onclick="slxOpenLocation(this, {{locationid}}); return false">{{locationname}} <b class="caret"></b></a>
				</td>
				<td class="text-nowrap" align="right">
					{{#havestatistics}}
					{{clientCount}}
					<span class="text-muted">
						/
						<span style="display:inline-block;width:3ex">{{clientCountSum}}</span>
					</span>
					<a class="btn btn-default btn-xs" href="?do=Statistics&amp;show=list&amp;filters=location={{locationid}}"><span class="glyphicon glyphicon-eye-open"></span></a>
					{{/havestatistics}}
				</td>
				<td class="text-nowrap" align="right">
					{{#havestatistics}}
					{{clientLoad}}
					{{/havestatistics}}
				</td>
				<td class="text-nowrap">
					{{#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>
			</tr>
		{{/list}}
		{{#unassignedCount}}
		<tr>
			<td>{{lang_unassignedMachines}}</td>
			<td class="text-nowrap" align="right">
				{{unassignedCount}}
				<a class="btn btn-default btn-xs" href="?do=Statistics&amp;show=list&amp;filters=location=0">
					<span class="glyphicon glyphicon-eye-open"></span>
				</a>
			</td>
			<td class="text-nowrap" align="right">
				{{clientLoad}}
			</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 table-hover">
			<tr id="lasttr">
				<td width="50%">&emsp;</td>
				<td class="text-right" colspan="2">
					<button id="saveLocationRows" type="submit" class="btn btn-primary" style="display: none">
						<span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}
					</button>
					<button class="btn btn-success" type="button" onclick="slxAddLocationRow()">
						<span class="glyphicon glyphicon-plus"></span> {{lang_location}}
					</button>

				</td>

			</tr>
		</table>
	</form>
</div>
{{#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}}
<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 + ']">\
		<option value="0">{{lang_noParent}}</option>\
		{{#list}}<option value="{{locationid}}">{{locationpad}} {{locationname}}</option>{{/list}}\
		</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;
		}
		return;
	}
	var td = $('<td>').attr('colspan', '5').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();
	});
	slxLastLocation = tr;
}

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 slxConfirm() {
	return confirm('{{lang_areYouSureNoUndo}}');
}
	// -->
</script>