diff options
Diffstat (limited to 'modules-available/locations/templates/locations.html')
-rw-r--r-- | modules-available/locations/templates/locations.html | 83 |
1 files changed, 65 insertions, 18 deletions
diff --git a/modules-available/locations/templates/locations.html b/modules-available/locations/templates/locations.html index c2dc610e..fb09a45e 100644 --- a/modules-available/locations/templates/locations.html +++ b/modules-available/locations/templates/locations.html @@ -1,6 +1,7 @@ <div> - <div class="pull-right"> - <a href="?do=Locations&action=showsubnets">{{lang_thisListBySubnet}}</a> + <div class="btn-group pull-right"> + <a href="?do=Locations&action=showlocations" class="btn btn-default active"><span class="glyphicon glyphicon-home"></span> {{lang_thisListByLocation}}</a> + <a href="?do=Locations&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"> @@ -23,9 +24,10 @@ <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> + <a href="#" class="{{linkClass}}" onclick="slxOpenLocation(this, {{locationid}}); return false">{{locationname}}{{^linkClass}} <b class="caret"></b>{{/linkClass}}</a> </td> <td class="text-nowrap" align="right"> + {{^linkClass}} {{#havestatistics}} {{clientCount}} <span class="text-muted"> @@ -34,13 +36,17 @@ </span> <a class="btn btn-default btn-xs" href="?do=Statistics&show=list&filters=location={{locationid}}"><span class="glyphicon glyphicon-eye-open"></span></a> {{/havestatistics}} + {{/linkClass}} </td> <td class="text-nowrap" align="right"> + {{^linkClass}} {{#havestatistics}} {{clientLoad}} {{/havestatistics}} + {{/linkClass}} </td> <td class="text-nowrap"> + {{^linkClass}} {{#havebaseconfig}} <div class="pull-right" style="z-index:-1"> <a class="btn btn-default btn-xs" href="?do=baseconfig&module=locations&locationid={{locationid}}"><span class="glyphicon glyphicon-edit"></span></a> @@ -49,8 +55,10 @@ {{lang_overrideCount}}: {{overriddenVars}}   {{/overriddenVars}} {{/havebaseconfig}} + {{/linkClass}} </td> <td class="text-nowrap"> + {{^linkClass}} {{#havesysconfig}} <div class="pull-right"> <a class="btn btn-default btn-xs" href="?do=sysconfig&locationid={{locationid}}"><span class="glyphicon glyphicon-edit"></span></a> @@ -59,6 +67,7 @@ {{configName}}   </span> {{/havesysconfig}} + {{/linkClass}} </td> </tr> {{/list}} @@ -84,14 +93,14 @@ <input type="hidden" name="action" value="addlocations"> <table class="table table-condensed table-hover"> <tr id="lasttr"> - <td> - <button class="btn btn-success btn-sm" type="button" onclick="slxAddLocationRow()"> - <span class="glyphicon glyphicon-plus-sign"></span> {{lang_location}} + <td width="60%"> </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 {{^addAllowed}}disabled{{/addAllowed}} class="btn btn-success" type="button" onclick="slxAddLocationRow()"> + <span class="glyphicon glyphicon-plus"></span> {{lang_location}} </button> - </td> - <td width="80%"> </td> - <td width="20%" align="right"> - <button type="submit" class="btn btn-primary">{{lang_save}}</button> </td> </tr> </table> @@ -111,17 +120,28 @@ var slxAddCounter = 0; var slxLastLocation = false; +var newRowCounter = 0; + function slxAddLocationRow() { + $("#saveLocationRows").show(); var tr = $('#lasttr'); - tr.before('<tr>\ - <td>#</td>\ + 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}}\ + {{#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) { @@ -134,9 +154,10 @@ function slxOpenLocation(e, lid) { if (existing.is(slxLastLocation)) { slxLastLocation = false; } else { - existing.show()[0].scrollIntoView(); + existing.show(); $(e).closest('tr').addClass('active slx-bold'); slxLastLocation = existing; + scollIntoView(existing); } return; } @@ -146,25 +167,51 @@ function slxOpenLocation(e, lid) { $(e).closest('tr').addClass('active slx-bold').after(tr); td.load('?do=Locations&action=showlocation&locationid=' + lid, function() { slxAttachCidr(); - $('#location-details-' + lid)[0].scrollIntoView(); + 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 class="cidrmagic">\ + 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></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}}'); } + +function deleteSubnetWarning(locid) { + var form = $("#locationForm"+locid); + if (form.find("input[type=checkbox]:checked").length > 0) { + $("#saveWarningModal"+locid).modal(); + } else { + form.submit(); + } +} // --> </script> |