Advertisement
Guest User

config_server.tmpl

a guest
Mar 24th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 19.44 KB | None | 0 0
  1. <!--#set global $pane="Servers"#-->
  2. <!--#set global $help_uri="configure-servers-1-0"#-->
  3. <!--#include $webdir + "/_inc_header_uc.tmpl"#-->
  4.  
  5. <div class="colmask">
  6.     <form action="addServer" method="post" autocomplete="off" novalidate>
  7.     <input type="hidden" name="session" value="$session" />
  8.     <div id="addServer">
  9.         <div class="padding alt">
  10.             <button type="button" class="btn btn-default"  id="addServerButton"><span class="glyphicon glyphicon-plus"></span> $T('button-addServer')</button>
  11.         </div>
  12.     </div>
  13.     <div class="section" id="addServerContent" style="display: none;">
  14.         <div class="col2">
  15.             <h3>$T('addServer') <a href="$helpuri$help_uri" target="_blank"><span class="glyphicon glyphicon-question-sign"></span></a></h3>
  16.         </div><!-- /col2 -->
  17.         <div class="col1">
  18.             <fieldset>
  19.                 <div class="field-pair">
  20.                     <label class="config" for="enable">$T('srv-enable')</label>
  21.                     <input type="checkbox" name="enable" id="enable" value="1" checked="checked" />
  22.                     <span class="desc">$T('srv-enable')</span>
  23.                 </div>
  24.                 <div class="field-pair">
  25.                     <label class="config" for="host">$T('srv-host')</label>
  26.                     <input type="text" name="host" id="host" />
  27.                 </div>
  28.                 <div class="field-pair">
  29.                     <label class="config" for="port">$T('srv-port')</label>
  30.                     <input type="number" name="port" id="port" size="8" />
  31.                 </div>
  32.                 <div class="field-pair">
  33.                     <label class="config" for="username">$T('srv-username')</label>
  34.                     <input type="text" name="username" id="username" />
  35.                 </div>
  36.                 <div class="field-pair">
  37.                     <label class="config" for="password">$T('srv-password')</label>
  38.                     <input type="text" name="password" id="password" />
  39.                 </div>
  40.                 <div class="field-pair">
  41.                     <label class="config" for="connections">$T('srv-connections')</label>
  42.                     <input type="number" name="connections" id="connections" min="0" max="100" />
  43.                 </div>
  44.                 <div class="field-pair">
  45.                     <label class="config" for="priority">$T('srv-priority')</label>
  46.                     <input type="number" name="priority" id="priority" min="0" max="100" /> <i>$T('explain-svrprio')</i>
  47.                 </div>
  48.                 <div class="field-pair">
  49.                     <label class="config" for="retention">$T('srv-retention')</label>
  50.                     <input type="number" name="retention" id="retention" min="0" /> <i>$T('days')</i>
  51.                 </div>
  52.                 <div class="field-pair">
  53.                     <label class="config" for="timeout">$T('srv-timeout')</label>
  54.                     <input type="number" name="timeout" id="timeout" min="30" /> <i>$T('seconds')</i>
  55.                 </div>
  56.                 <div class="field-pair <!--#if int($have_ssl) == 0 then "disabled" else ""#-->">
  57.                     <label class="config" for="ssl">$T('srv-ssl')</label>
  58.                     <input type="checkbox" name="ssl" id="ssl" value="1" <!--#if int($have_ssl) == 0 then "disabled=\"disabled\"" else ""#--> />
  59.                     <span class="desc">$T('srv-ssl')</span>
  60.                 </div>
  61.                 <div class="field-pair <!--#if int($have_ssl) == 0 then "disabled" else ""#-->">
  62.                     <label class="config" for="ssl_type">$T('srv-ssl_type')</label>
  63.                     <!--#if int($have_ssl) == 1#-->
  64.                         <select name="ssl_type" id="ssl_type">
  65.                                 <option value="">$T('Default')</option>
  66.                             <!--#if 't12' in $ssl_protocols#-->
  67.                                 <option value="t12">TLS v1.2</option>
  68.                             <!--#end if#-->
  69.                             <!--#if 't11' in $ssl_protocols#-->
  70.                                 <option value="t11">TLS v1.1</option>
  71.                             <!--#end if#-->
  72.                             <!--#if 't1' in $ssl_protocols#-->
  73.                                 <option value="t1">TLS v1</option>
  74.                             <!--#end if#-->
  75.                             <!--#if 'v3' in $ssl_protocols#-->
  76.                                 <option value="v3">SSL v3</option>
  77.                             <!--#end if#-->
  78.                             <!--#if 'v2' in $ssl_protocols#-->
  79.                                 <option value="v2">SSL v2</option>
  80.                             <!--#end if#-->
  81.                         </select>
  82.                     <!--#end if#-->
  83.                     <span class="desc">$T('srv-explain-ssl_type')</span>
  84.                 </div>
  85.                 <div class="field-pair">
  86.                     <label class="config" for="send_group">$T('srv-send_group')</label>
  87.                     <input type="checkbox" name="send_group" id="send_group" value="1" />
  88.                     <span class="desc">$T('srv-explain-send_group')</span>
  89.                 </div>
  90.                 <div class="field-pair">
  91.                     <label class="config" for="optional">$T('srv-optional')</label>
  92.                     <input type="checkbox" name="optional" id="optional" value="1" />
  93.                     <span class="desc">$T('srv-optional')</span>
  94.                 </div>
  95.                 <div class="field-pair">
  96.                     <label class="config" for="categories">$T('srv-categories')</label>
  97.                     <select name="categories" id="categories" multiple>
  98.                     <!--#for $cat in $cats#-->
  99.                         <option value="$cat" <!--#if $cat == "Default"#-->selected<!--#end if#-->>
  100.                             <!--#if $cat == "Default" then $T('Default') else $cat#-->
  101.                         </option>
  102.                     <!--#end for#-->
  103.                     </select>
  104.                     <span class="desc">$T('srv-explain-categories')</span>
  105.                 </div>
  106.                 <div class="field-pair">
  107.                     <label class="config" for="displayname">$T('srv-displayname')</label>
  108.                     <input type="text" name="displayname" id="displayname" />
  109.                 </div>
  110.                 <div class="field-pair">
  111.                     <label class="config" for="notes">$T('srv-notes')</label>
  112.                     <textarea name="notes" id="notes" rows="3" cols="50"></textarea>
  113.                 </div>
  114.                 <div class="field-pair">
  115.                     <button class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> $T('button-addServer')</button>
  116.                     <button class="btn btn-default testServer" type="button"><span class="glyphicon glyphicon-sort"></span> $T('button-testServer')</button>
  117.                 </div>
  118.             </fieldset>
  119.         </div><!-- /col1 -->
  120.     </div><!-- /section -->
  121. </form>
  122.  
  123. <!--#set $cur = 0#-->
  124. <!--#for $server in $servers#-->
  125.     <!--#set $cur = $cur + 1#-->
  126.  
  127.     <form action="saveServer" method="post" class="fullform" autocomplete="off" novalidate>
  128.     <input type="hidden" name="session" value="$session" />
  129.     <input type="hidden" name="server" value="$server['name']" />
  130.  
  131.     <div class="section <!--#if int($server['enable']) == 0 then 'server-disabled' else ""#-->">
  132.         <div class="col2 <!--#if int($server['enable']) == 0 then 'server-disabled' else ""#-->">
  133.             <h3>$server['displayname'] <a href="$helpuri$help_uri" target="_blank"><span class="glyphicon glyphicon-question-sign"></span></a></h3>
  134.             <!--#if int($server['enable']) != 0#-->
  135.             <span class="label label-primary" data-priority="$server['priority']#-->">$server['priority']</span>
  136.             <span class="label label-primary" data-priority="$server['priority']#-->">$T('srv-priority'):</span>
  137.             <!--#end if#-->
  138.             <table><tr>
  139.               <td><input type="checkbox" class="toggleServerCheckbox" id="enable_$cur" name="$server['name']" value="1" <!--#if int($server['enable']) != 0 then 'checked="checked"' else ""#--> /></td>
  140.               <td><label for="enable_$cur">$T('enabled')</label></td>
  141.             </tr></table>
  142.  
  143.             <button type="button" class="btn btn-default showserver"><span class="glyphicon glyphicon-pencil"></span> $T('showDetails')</button>
  144.         </div><!-- /col2 -->
  145.         <div class="col1"  style="display:none;">
  146.             <input type="hidden" name="enable" id="enable$cur" value="$int($server['enable'])" />
  147.             <fieldset>
  148.                 <div class="field-pair">
  149.                     <label class="config" for="host$cur">$T('srv-host')</label>
  150.                     <input type="text" name="host" id="host$cur" value="$server['host']" />
  151.                 </div>
  152.                 <div class="field-pair">
  153.                     <label class="config" for="port$cur">$T('srv-port')</label>
  154.                     <input type="number" name="port" id="port$cur" value="$server['port']" size="8" />
  155.                 </div>
  156.                 <div class="field-pair">
  157.                     <label class="config" for="username$cur">$T('srv-username')</label>
  158.                     <input type="text" name="username" id="username$cur" value="$server['username']" />
  159.                 </div>
  160.                 <div class="field-pair">
  161.                     <label class="config" for="password$cur">$T('srv-password')</label>
  162.                     <input type="text" name="password" id="password$cur" value="$server['password']" />
  163.                 </div>
  164.                 <div class="field-pair">
  165.                     <label class="config" for="connections$cur">$T('srv-connections')</label>
  166.                     <input type="number" name="connections" id="connections$cur" value="$server['connections']" min="0" max="100" />
  167.                 </div>
  168.                 <div class="field-pair">
  169.                     <label class="config" for="priority$cur">$T('srv-priority')</label>
  170.                     <input type="number" name="priority" id="priority$cur" value="$server['priority']" min="0" max="100" /> <i>$T('explain-svrprio')</i>
  171.                 </div>
  172.                 <div class="field-pair">
  173.                     <label class="config" for="retention$cur">$T('srv-retention')</label>
  174.                     <input type="number" name="retention" id="retention$cur" value="$server['retention']" min="0" /> <i>$T('days')</i>
  175.                 </div>
  176.                 <div class="field-pair">
  177.                     <label class="config" for="timeout$cur">$T('srv-timeout')</label>
  178.                     <input type="number" name="timeout" id="timeout$cur" value="$server['timeout']" min="30" /> <i>$T('seconds')</i>
  179.                 </div>
  180.                 <div class="field-pair <!--#if int($have_ssl) == 0 then "disabled" else ""#-->">
  181.                     <label class="config" for="ssl$cur">$T('srv-ssl')</label>
  182.                     <input type="checkbox" name="ssl" id="ssl$cur" value="1" <!--#if int($server['ssl']) != 0 and int($have_ssl) == 1 then 'checked="checked"' else ""#--> <!--#if int($have_ssl) == 0 then "disabled=\"disabled\"" else ""#--> />
  183.                     <span class="desc">$T('srv-ssl')</span>
  184.                 </div>
  185.                 <div class="field-pair <!--#if int($have_ssl) == 0 then "disabled" else ""#-->">
  186.                     <label class="config" for="ssl_type$cur">$T('srv-ssl_type')</label>
  187.                     <!--#if int($have_ssl) == 1#-->
  188.                         <select name="ssl_type" id="ssl_type$cur">
  189.                                 <option value=""  <!--#if $server['ssl_type'] == ""  then 'selected="selected"' else ""#--> >$T('Default')</option>
  190.                             <!--#if 't12' in $ssl_protocols#-->
  191.                                 <option value="t12"  <!--#if $server['ssl_type'] == "t12"  then 'selected="selected"' else ""#--> >TLS v1.2</option>
  192.                             <!--#end if#-->
  193.                             <!--#if 't11' in $ssl_protocols#-->
  194.                                 <option value="t11"  <!--#if $server['ssl_type'] == "t11"  then 'selected="selected"' else ""#--> >TLS v1.1</option>
  195.                             <!--#end if#-->
  196.                             <!--#if 't1' in $ssl_protocols#-->
  197.                                 <option value="t1"  <!--#if $server['ssl_type'] == "t1"  then 'selected="selected"' else ""#--> >TLS v1</option>
  198.                             <!--#end if#-->
  199.                             <!--#if 'v3' in $ssl_protocols#-->
  200.                                 <option value="v3"  <!--#if $server['ssl_type'] == "v3"  then 'selected="selected"' else ""#--> >SSL v3</option>
  201.                             <!--#end if#-->
  202.                             <!--#if 'v2' in $ssl_protocols#-->
  203.                                 <option value="v2"  <!--#if $server['ssl_type'] == "v2"  then 'selected="selected"' else ""#--> >SSL v2</option>
  204.                             <!--#end if#-->
  205.                         </select>
  206.                     <!--#end if#-->
  207.                     <span class="desc">$T('srv-explain-ssl_type')</span>
  208.                 </div>
  209.                 <div class="field-pair">
  210.                     <label class="config" for="optional$cur">$T('srv-optional')</label>
  211.                     <input type="checkbox" name="optional" id="optional$cur" value="1" <!--#if int($server['optional']) != 0 then 'checked="checked"' else ""#--> />
  212.                     <span class="desc">$T('srv-optional')</span>
  213.                 </div>
  214.                 <div class="field-pair">
  215.                     <label class="config" for="send_group$cur">$T('srv-send_group')</label>
  216.                     <input type="checkbox" name="send_group" id="send_group$cur" value="1" <!--#if int($server['send_group']) != 0 then 'checked="checked"' else ""#--> />
  217.                     <span class="desc">$T('srv-explain-send_group')</span>
  218.                 </div>
  219.                 <div class="field-pair">
  220.                     <label class="config" for="categories$cur">$T('srv-categories')</label>
  221.                     <select name="categories" id="categories$cur" multiple>
  222.                     <!--#for $cat in $cats#-->
  223.                         <option value="$cat" <!--#if $cat in $server['categories'] then 'selected' else ""#-->>
  224.                             <!--#if $cat == "Default" then $T('Default') else $cat#-->
  225.                         </option>
  226.                     <!--#end for#-->
  227.                     </select>
  228.                     <span class="desc">$T('srv-explain-categories')</span>
  229.                 </div>
  230.                 <div class="field-pair">
  231.                     <label class="config" for="displayname$cur">$T('srv-displayname')</label>
  232.                     <input type="text" name="displayname" id="displayname$cur" value="$server['displayname']" />
  233.                 </div>
  234.                 <div class="field-pair">
  235.                     <label class="config" for="notes$cur">$T('srv-notes')</label>
  236.                     <textarea name="notes" id="notes$cur" rows="3" cols="50">$server['notes']</textarea>
  237.                 </div>
  238.                 <div class="field-pair">
  239.                     <button class="btn btn-default saveButton"><span class="glyphicon glyphicon-ok"></span> $T('button-saveChanges')</button>
  240.                     <button class="btn btn-default testServer" type="button"><span class="glyphicon glyphicon-sort"></span> $T('button-testServer')</button>
  241.                     <button class="btn btn-default clrServer" type="button"><span class="glyphicon glyphicon-remove"></span> $T('button-clrServer')</button>
  242.                     <button class="btn btn-default delServer"><span class="glyphicon glyphicon-trash"></span> $T('button-delServer')</button>
  243.                 </div>
  244.             </fieldset>
  245.         </div><!-- /col1 -->
  246.         <div class="col2"  style="display:block;">
  247.         <!--#if 'amounts' in $server#-->
  248.             <b>$T('srv-bandwidth'):</b><br/>
  249.             $T('total'): $(server['amounts'][0])B<br/>
  250.             $T('today'): $(server['amounts'][3])B<br/>
  251.             $T('thisWeek'): $(server['amounts'][2])B<br/>
  252.             $T('thisMonth'): $(server['amounts'][1])B
  253.         <!--#end if#-->
  254.         </div>
  255.     </div><!-- /section -->
  256.     </form>
  257. <!--#end for#-->
  258.  
  259. </div><!-- /colmask -->
  260.  
  261. <script type="text/javascript">
  262. \$(document).ready(function(){
  263.     // Exception when change of priority, reload
  264.     \$('input[name="priority"], input[name="displayname"]').on('change', function() {
  265.         \$('.fullform').submit(function() {
  266.             // Skip the fancy stuff, just submit
  267.             this.submit()
  268.         })
  269.     })
  270.    
  271.     /**
  272.         Color the priority labels
  273.     **/
  274.     // They are already sorted
  275.     var colorList = ["#cc3333", "#cc33a6", "#7f33cc", "#3366cc",  "#59cc33"];
  276.     var lastColor = colorList[0];
  277.     var lastPrio = '-1';
  278.     var theColor = '';
  279.     \$('[data-priority]').each(function() {
  280.         // New one?
  281.         if(\$(this).data('priority') != lastPrio) {
  282.             // Update
  283.             theColor = colorList.pop() || lastColor;
  284.             lastPrio = \$(this).data('priority');
  285.         }
  286.         \$(this).css('background-color', theColor)
  287.     })
  288.    
  289.     /**
  290.         Click events
  291.     **/
  292.     \$('.showserver').click(function () {
  293.         if(\$(this).parent().hasClass('server-disabled')) {
  294.             \$(this).parent().parent().toggleClass('server-disabled')
  295.         }
  296.         \$(this).parent().next().toggle();
  297.         \$(this).parent().next().next().toggle();
  298.         if (\$(this).attr("value") == "$T('showDetails')") {
  299.             \$(this).attr("value", "$T('hideDetails')");
  300.         } else {
  301.             \$(this).attr("value", "$T('showDetails')");
  302.         }
  303.     });
  304.     \$('#addServerButton').click(function(){
  305.         \$('#addServer').hide();
  306.         \$('#addServerContent').show();
  307.     });
  308.     \$('.testServer').click(function(event){
  309.         \$(this).attr("disabled", "disabled")
  310.         \$.ajax({
  311.             type: "POST",
  312.             url: "../../tapi",
  313.             data: "mode=config&amp;name=test_server&amp;" + \$(this).parents('form:first').serialize(),
  314.             success: function(msg){
  315.                 alert(msg);
  316.                 \$(event.target).removeAttr("disabled")
  317.             }
  318.         });
  319.     });
  320.     \$('.delServer').click(function(){
  321.         if( confirm("$T('Plush-confirm')") ) {
  322.             \$(this).parents('form:first').attr('action','delServer').submit();
  323.             // Let us leave!
  324.             formWasSubmitted = true;
  325.             formHasChanged = false;
  326.             setTimeout(function() { location.reload(); }, 100)
  327.         }
  328.         return false;
  329.     });
  330.     \$('.clrServer').click(function(){
  331.         if( confirm("$T('Plush-confirm')") ) {
  332.             \$(this).parents('form:first').attr('action','clrServer').submit();
  333.             // Let us leave!
  334.             formWasSubmitted = true;
  335.             formHasChanged = false;
  336.             setTimeout(function() { location.reload(); }, 100)
  337.         }
  338.         return false;
  339.     });
  340.     \$('.toggleServerCheckbox').click(function(){
  341.         var whichServer = \$(this).attr("name");
  342.         \$.ajax({
  343.             type: "POST",
  344.             url: "toggleServer",
  345.             data: {server: whichServer, session: "$session" }
  346.         }).done(function() {
  347.             // Let us leave!
  348.             formWasSubmitted = true;
  349.             formHasChanged = false;
  350.             setTimeout(function() { location.reload(); }, 100)
  351.         });
  352.     });
  353. });
  354. </script>
  355.  
  356. <!--#include $webdir + "/_inc_footer_uc.tmpl"#-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement