{% extends "layout.html" %}
{% block title %}Instance inspection{% endblock %}
{% block head %}
  {{ super() }}
  <link href="{{ url_for('static', filename='css/jqueryTabs.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
  <script src="{{ url_for('static', filename='js/jquery/jqueryTabs.js') }}" type="text/javascript" charset="utf-8"></script>
  <script src="{{ url_for('static', filename='js/ace/ace.js') }}" type="text/javascript" charset="utf-8"></script>
  <script src="{{ url_for('static', filename='js/ace/theme-crimson_editor.js') }}" type="text/javascript" charset="utf-8"></script>
  <link href="{{ url_for('static', filename='css/colorbox.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
  <script src="{{ url_for('static', filename='js/jquery/jquery.colorbox-min.js') }}" type="text/javascript" charset="utf-8"></script>
  <script src="{{ url_for('static', filename='js/scripts/inspectInstance.js') }}" type="text/javascript" charset="utf-8"></script>
  <link href="{{ url_for('static', filename='css/gsFileManager.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
  <script src="{{ url_for('static', filename='js/jquery/gsFileManager.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
<input type='hidden' name='root' id='root' value='{%if file_path != "" %}{{file_path}}{%endif%}' />
<input type="hidden" name="partition_amount" id="partitionAmount" value="{{ partition_amount }}" />
<h2>Instance inspection</h2><br/>
<div id="tabContaier">
    <ul>
      <li><a href="#tab1" class="active">Slapgrid Supervisor</a></li>
      <li><a href="#tab2">SLAP Response</a></li>
      <li><a href="#tab3" id="parameterTab">SLAP Parameters</a></li>
      <li><a href="#tab4" id="instancetabfiles">Partitions Content</a></li>
    </ul><!-- //Tab buttons -->
    <div class="tabDetails">
      <div id="tab1" class="tabContents">
      <p>This tab show all process generated by slapgrid for your application. You can click on the process name to display log.</p>
      {% if supervisor %}
      <table cellpadding="0" cellspacing="0" width="100%" id="supervisordcontent">
        <tr>
          <th>Partition and Process name</th><th>Status</th><th>Process PID </th><th> UpTime</th><th></th>
        </tr>
      {% for item in supervisor %}
        <tr>
          <td  class='first'><b><a href="{{ url_for('tailProcess', process=item[0]) }}">{{ item[0]}}</a></b></td>
          <td align="center"><a href="{{ url_for('startStopProccess', process=item[0], action=item[1]) }}">{{ item[1]}}</a></td>
          <td align="center">{{ item[3]}}</td><td>{{ item[5]}}</td>
          <td align="center"><a href="{{ url_for('startStopProccess', process=item[0], action='RESTART') }}">Restart</a></td>
        </tr>
      {% endfor %}
      </table><br/>
      <a href="#" id="refresh" class="lshare simple no-right-border" style="float:left">Refresh Status</a>
      <a href="{{ url_for('stopAllPartition') }}" class="lshare simple" style="float:left">Stop all process</a>
      <img class="waitting" id="imgwaitting" src="{{ url_for('static', filename='images/waiting.gif') }}" alt="" />
      <div class="clear"></div><br/>
      {% else %}
      <h2>No process to display, please run your instance</h2>
      {%endif%}
        </div><!-- end tab1 -->
      <div id="tab2" class="tabContents">
      {% if slap_status %}
      <p>Uses parameters below to run your application</p>
      <div class="menu-box-right">
      <div style="background:#fff; padding:10px;">
        {% for item in slap_status %}
        <div id="box{{item[0]}}" style="display:none;">
        {% if item[1] %}
          <h2><span style="float:left; margin-left:10px;" id="{{item[0]}}title">Slap Response for {{item[0]}}</span>
            <a href="#" id="{{item[0]}}Parameter" rel="{{item[0]}}" class="lshare simple" style="float:right" title='Restart all partition process'>Restart</a>
            <a href="#" id="{{item[0]}}Files" rel="{{item[0]}}" class="lshare simple no-right-border" style="float:right">Files</a>
          </h2>
          <div class="clear"></div><br/>
          <div id="bcontent{{item[0]}}">
            <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
               <th>Parameter Name</th><th>Parameter Value</th>
            </tr>
            {% for k in item[1] %}
            <tr>
               <td class="propertie first">{{k}}</td><td align='left'><span class="slapvalues">{{item[1][k]}}</span></td>
            </tr>
            {% endfor %}
            </table>
          </div>
        {% else %}
          <h2>Empty Partition</h2></br>
          <center><img alt="" src="{{ url_for('static', filename='images/empty.png') }}" /></center>
          <br/><h2>Partition {{item[0]}} is still empty</h2>
        {%endif%}
        </div>
        {% endfor %}
      </div>
      </div>
      <div class="menu-box-left">
        <ul id="slappart">
          {% for item in slap_status %}
            <li><input type="radio" name="slapresponse" id="{{item[0]}}" value="{{item[0]}}" />
              <label for="{{item[0]}}" {% if item[1] %}style="font-weight:bold"{%endif%}>{{item[0]}}</label></li>
          {% endfor %}
        </ul>
      </div>
      <div class="clear"></div><br/>
      {% else %}
        <h2>No response. Please run Software Instance!</h2>
      {%endif%}
        </div><!-- end tab2 -->
      <div id="tab3" class="tabContents">
      <div id="softwareType">
        <h2 class='title'>Software Type of main instance</h2>
        <input style="margin-top:5px;" type="text" name="software_type" id="software_type" size="35" value="Software Type here..." />
      </div>
      <br/>
      <div id="parameterkw">
        <h2 class='hight'>Partitions Parameter</h2>
        <div class="slidebox">
          <table class="small" cellpadding="0" cellspacing="0" width="100%" id="partitionParameter">
            <tr id="row_1">
              <th width="150">Parameter Name</th><th>Parameter Value</th><th width="49">
                <a href="#" class="link" id="add_attribute">[new]</a>
              </th>
            </tr>
          </table>
        </div>
      </div>
      <br/>
      <div>
        <a id="updateParameters" class="lshare simple no-right-border" style="float:left">Update Values</a>
        <a href="#" id="xmlview" class="lshare simple"  style="float:left">Load XML</a>
      </div>
      <div class="clear"></div>
        </div><!-- end tab3 -->
      <div id="tab4" class="tabContents">
      <!--<h2>File content for all your partitions</h2>
      <div id="fileTree" class="file_tree_tabs" title="Double click to open file"></div>-->
      {%if file_path != "" %}
        <div id="fileNavigator"></div>
        <br/>
        <a href="#" id="reloadfiles" class="lshare simple">Reload Files</a>
      {%else%}
        <h2>Your partitions content is empty yet!
          <br/>please run your software instance
          and look for file result here.
        </h2>
      {%endif%}
        </div><!-- end tab4 -->
    </div>
</div>
<!-- This contains the hidden content for inline calls -->
<a id='inlineInstance' style='display:none' href="#inline_instance">Inline HTML</a>
<div style='display:none'>
<div id='inline_instance' style='padding:10px; background:#fff;'>

</div>
</div>
{% endblock %}

