<% the_current_user = current_user %>

<script type="text/javascript" charset="utf-8">
    // for testing
    function wemo_switch_status(elem_id) {
        the_ip = $("#" + elem_id).val();
        var url = '/api/wemo_switch_status?ip=' + the_ip;
        $.get(url, function (data) {
            $("#" + elem_id + "_indicator").show();
            $("#" + elem_id + "_indicator").removeClass("label-success");
            $("#" + elem_id + "_indicator").removeClass("label-default");
            $("#" + elem_id + "_indicator").removeClass("label-failed");

            if (data == "on") {
              if (elem_id == "publisher_wemo_success_ip") {
                $("#" + elem_id + "_indicator").addClass("label-success");
              } else {
                $("#" + elem_id + "_indicator").addClass("label-failed");                
              }
            } else if (data == "off") {
                $("#" + elem_id + "_indicator").addClass("label-default");
            }
        });

    }

    function tplink_smart_plug_status(elem_id) {
        device_name = $("#" + elem_id).val();
        var url = '/api/tplink_smart_plug_status?device_name=' + device_name;
        $.get(url, function (data) {
            // console.log("device status: " + data);
            $("#" + elem_id + "_indicator").show();
            $("#" + elem_id + "_indicator").removeClass("label-success");
            $("#" + elem_id + "_indicator").removeClass("label-default");
            $("#" + elem_id + "_indicator").removeClass("label-failed");
            if (data == "on") {               
              if (elem_id == "publisher_tplink_success_device_name") {
                $("#" + elem_id + "_indicator").addClass("label-success");
              } else {
                $("#" + elem_id + "_indicator").addClass("label-failed");                
              }
            } else if (data == "off") {
                $("#" + elem_id + "_indicator").addClass("label-default");
            }
        });

    }


    function disable_enable_task(checkbox, task_id) {
        if (checkbox.checked) {
            $("#" + task_id + "_task").removeAttr('readonly');
            $("#" + task_id + "_delete").hide();
        } else {
            $("#" + task_id + "_task").attr('readonly', 'readonly');
            $("#" + task_id + "_delete").show();
        }
    }

    function delete_build_step(step_id) {
        $("#step_" + step_id).remove();
        // need to save to take effect
    }

    function getTemplateBuildStepRow(step_name) {
        var x = document.getElementById("templateBuildStepRow").cloneNode(true);
        var step_identifier = step_name.trim().toLowerCase().replace(/\s/g, "_").replace(".", "");
        x.id = "step_" + step_identifier;
        x.style.display = "";
        var innerHtml = x.innerHTML
        innerHtml = innerHtml.replace(/template_step_identifier/g, step_identifier);
        innerHtml = innerHtml.replace(/template_step_name/g, step_name);
        x.innerHTML = innerHtml;
        return x;
    }

	function add_build_step() {
      bootbox.prompt({ 
          size: "medium",
          title: "Step Name:",
          callback: function(value){ 
            if (value) {
			       var t = document.getElementById('build_steps');
					   var r = document.getElementById('last_build_step');
					   r.parentNode.insertBefore(getTemplateBuildStepRow(value), r);			
						 enable_sort_build_steps();		 	              
            }
          }
      });
	}

    function slack_send_test_notification() {
        $.getScript("/projects/<%= @project.id %>/slack_send_test_notification");
    }
    function http_callback_send_test_notification() {
		var webhook = $("#publisher_http_callback_webhook_url").val();
        $.getScript("/projects/<%= @project.id %>/http_callback_send_test_notification?webhook=" + webhook);
    }

    function delete_env_variable(row_id) {
        <% if the_current_user && (the_current_user.is_admin? ||  the_current_user.has_role?(:builder, @project) )%>
        $("#env_row_" + row_id).remove();
        <% end %>
    }


    var env_var_count = <%= @config.environment_variables.size rescue 1 %>;

    function add_env_var_row() {
        <% if the_current_user && (the_current_user.is_admin? || the_current_user.has_role?("builder", @project) ) %>

      $("#env_var_editor").append('<div class="form-group form-group-sm row" id="env_row_' + env_var_count + '" ><div class="col-sm-5"><input type="text" name="env_var_key[' + env_var_count + ']" value="" style="" class="form-control"></div> <div class="col-sm-1" style="text-align: center; margin-left: -1rem; margin-right: -1rem; margin-top: 8px;"> = </div><div class="col-sm-5"> <input type="text" name="env_var_value[' + env_var_count + ']" value="" style="" class="form-control"> </div> <div class="col-sm-1"><a href="javascript:void(0);" onclick="delete_env_variable(' + env_var_count + ');"><i class="fa fa-trash fa-lg orange" style="margin-top: 5px;"></i></a> </div> </div>');

        env_var_count += 1;
        <% end %>
    }


    function enable_sort_build_steps() {
        $('.step-sortable').sortable({
            placeholderClass: 'col-sm-12',
            handle: "span"
        });

        $('.step-sortable').bind('sortupdate', function (e, ui) {
            //ui.item contains the current dragged element.
            //Triggered when the user stopped sorting and the DOM position has changed.
            console.log("reorder steps");
            var count = 0;
            $("#build_steps input.step_order").each(function () {
                count += 1;
                $(this).val(count);
            });

        });
    }

	
	function clear_api_key() {
 	   $("#project_api_key").val("");		
	   return;
	}
	
	function generate_random_api_key() {
	   var length = 20;
	   var result           = '';
	   var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	   var charactersLength = characters.length;
	   for ( var i = 0; i < length; i++ ) {
	      result += characters.charAt(Math.floor(Math.random() * charactersLength));
	   }
	   
	   $("#project_api_key").val(result);
	   return result;
	}


</script>

<div id="project-form">

  <div class="config-section-content">
	  <div class="form-group form-group-sm row">
	      <div class="col-sm-2" style="margin-left: -10px; padding-left: 0px;"><b class="section-heading"><%= I18n.t(:execution_mode) %></b></div>		
				<div class="col-sm-9" style="padding-top: 1px; padding-left: 25px;">
					<div>
	<input type="radio" name="execution_mode" value="sequential" <%unless @config.is_parallel%>checked="checked"<%end%>> <span style="margin-left: 0.3rem;"><b>Sequential</b> Functional</span>
					 <label style="width: 1.5rem;">&nbsp;</label>
	<input type="radio" name="execution_mode" value="parallel" <%if @config.is_parallel && !@config.is_load_testing %>checked="checked"<%end%>> <span style="margin-left: 0.15rem;"><b>Parallel</b> Functional</span>

					 <label style="width: 1.5rem;">&nbsp;</label>
					 <input type="radio" name="execution_mode" value="performance_testing" <%if @config.is_performance_testing%>checked="checked"<%end%>> <span style="margin-left: 0.15rem;">Sequential</span> <b style=""> Performance</b>

					 <label style="width: 1.5rem;">&nbsp;</label>
					 <input type="radio" name="execution_mode" value="load_testing" <%if @config.is_load_testing%>checked="checked"<%end%>> <span style="margin-left: 0.15rem;">Parallel</span> <b style=""> Load</b>
				  </div>
					<div><span class="hint">Sequential (Functional and Performance): runs test scripts one by one on the build server machine;<br/>
	Parallel Functional: distribute tests to BuildWise agents to run them in parallel to save time and increase reliability; <br/>
	Load Testing: distribute tests to BuildWise agents to run them in parallel for load/performance testing purposes.  </div>	
    
<!--
    <span style="margin-left: 0rem; font-style:italic;" class="hint">(actual execution mode set by the UI test task, this toggles configuration options)</span>
-->			
			  </div>
		</div>
  </div>
				
  <p><b class="section-heading">Source Control</b></p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header">Source Control</label>
      <div class="col-sm-2">
        <select name="scm_type" class="form-control">
          <option value="git"
                  <% if @config && @config.scm_type == "git" %> selected
                  <% end %> >Git
          </option>
          <option value="svn"
                  <% if @config && @config.scm_type == "svn" %> selected
                  <% end %> >Subversion
          </option>
        </select>
      </div>
				<div class="col-sm-8" style="padding-top: 7px;">
					<span class="hint">Authentication: Use Git Credential Manager, set up SSH keys or embed user:pass in <code>.git/config</code>.</span>
				</div>
    </div>

    <% if the_current_user %>
        <div class="form-group form-group-sm row">
          <label class="col-sm-2 form-control-label" for="contact_header">Repository URL</label>
          <div class="col-sm-9">
            <% if !the_current_user.is_admin? && @config && @config.scm_url && @config.scm_url.include?(":") %>
                <input type="password" name="scm_url" class="col-span-5 form-control form-control-inline" value="<%= @config.scm_url rescue nil %>"/>
            <% else %>
                <input type="text" name="scm_url" class="col-span-5 form-control" value="<%= @config.scm_url rescue nil %>" readonly="<%= @config.scm_url && @config.scm_url.size > 5 ? 'false' : 'true'%> "/>
            <% end %>
          </div>
        </div>

        <div class="form-group form-group-sm row">
          <label class="col-sm-2 form-control-label" for="contact_header">Branch</label>
          <div class="col-sm-2">
            <input type="text" name="scm_branch" class="form-control" placeholder="branch" value="<%= @config.scm_branch rescue nil %>"/>
          </div>
          <div class="col-sm-7">
            <span class="hint">default to <code>main</code>. A good way to set up a branch build is to duplicate an existing one, commonly requires Git knowledge to make sure the work folder <code>your-project/sources</code> (and checked out project on build agents) are on the same branch.</span>
          </div>
        </div>

    <% end %>

</div>

<div>
  <p><b class="section-heading"><%= I18n.t(:build_steps) %></b>
    <% if the_current_user %>
        <a href="javascript:void(0);" onclick="add_build_step();" class="btn btn-success btn-xs"><i class="fa fa-plus"></i> <%= I18n.t(:new_build_step) %></a>
    <% end %>
    <span class="hint"><%= I18n.t(:build_steps_hint) %></span>
  </p>

  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:build_prepare_command) %></label>
      <div class="col-sm-9">
        <input type="text" name="builder_prepare_command" class="form-control" size="26" value="<%= @config.builder_prepare_command rescue nil %>" class="span9" placeholder="e.g. <% if @config.is_parallel %>start_docker_agent.sh<% else %>kill_chrome_and_driver.sh<% end %>"></input>
      </div>
    </div>

    <div class="form-group form-group-sm row" id="templateBuildStepRow" style="display:none;">
      <label class="col-sm-2 form-control-label">
        <span style="float:left;"><i class="fa fa-arrows gray" aria-hidden="true"></i></span>
        <input type="hidden" name="build_steps[template_step_identifier][name]" value="template_step_name"/>
        <input type="hidden" name="build_steps[template_step_identifier][order]" value=""/>

        <span>template_step_name</span>
        <input style="display: inline" type="checkbox" name="build_steps[template_step_identifier][enabled]"
               value="true" onclick="disable_enable_task(this, 'template_step_identifier');"/>
      </label>
      <div class="col-sm-9">
        <select name="build_steps[template_step_identifier][builder]" style="font-size: 16px">
          <option value="rake" selected>Rake</option>
          <option value="command">Command</option>
        </select>

        <input type="text" id="template_step_identifier_task" name="build_steps[template_step_identifier][task]" class="form-control form-control-inline step_task" value=''></input>
      </div>
    </div>


    <div id="build_steps" class="step-sortable">

      <% @config.build_steps.each do |a_step| %>
          <div class="form-group form-group-sm row" id="step_<%= a_step.identifier %>">

            <label class="col-sm-2 form-control-label" for="contact_header">
              <span class="step-handle"><i class="fa fa-arrows gray" aria-hidden="true"></i></span>

              <input type="hidden" name="build_steps[<%= a_step.identifier %>][name]" value="<%= a_step.name %>"/>
              <input type="hidden" class="step_order" name="build_steps[<%= a_step.identifier %>][order]" value="<%= a_step.order %>"/>
              <%= a_step.name %>
              <input style="display: inline" type="checkbox" name="build_steps[<%= a_step.identifier %>][enabled]"
                     <% if a_step.enabled %> checked="true"
                     <% end %> value="true" onclick="disable_enable_task(this, '<%= a_step.identifier %>');"/>
            </label>
            <div class="col-sm-9">

              <select name="build_steps[<%= a_step.identifier %>][builder]" style="font-size: 16px">
                <option value="rake" selected>Rake</option>
                <option value="command"
                        <% if a_step.builder == "command" %> selected
                        <% end %> >Command
                </option>
	
                <option value="ant"
                        <% if a_step.builder == "ant" %> selected
                        <% end %> >Ant
                </option>
                <option value="command"
                        <% if a_step.builder == "maven" %> selected
                        <% end %> >Maven
                </option>	
              </select>

              <input type="text" id="<%= a_step.identifier %>_task" name="build_steps[<%= a_step.identifier %>][task]" class="form-control form-control-inline step_task"
                     <% unless a_step.enabled %> readonly="true"
                     <% end %>  value='<%= a_step.task rescue nil %>'></input>

              <span
              <% if a_step.enabled %> style="display:none;" <% end %> id="<%= a_step.identifier %>_delete">&nbsp;
									<a href="javascript:void(0);" onclick="delete_build_step('<%= a_step.identifier %>');"><i class="fa fa-trash red"></i></a>
								</span>

              <% if a_step.is_test_execution_step? %>
                  <div style="margin-top: 10px;">

                    <select name="build_steps[<%= a_step.identifier %>][test_syntax_framework]" name="<%= a_step.identifier %>test_framework" style="width: 150px;">
                      <option value="RSpec">RSpec (Ruby)</option>
                      <option value="pytest"
                              <% if a_step.get_attribute("test_syntax_framework") == "pytest" %>selected
                              <% end %>>pytest (Python)
                      </option>
                      <option value="Cucumber"
                              <% if a_step.get_attribute("test_syntax_framework") == "Cucumber" %>selected
                              <% end %>>Cucumber (Ruby)
                      </option>
                      <option value="Mocha"
                              <% if a_step.get_attribute("test_syntax_framework") == "Mocha" %>selected
                              <% end %> >Mocha (JavaScript)
                      </option>
                      <option value="unittest"
                              <% if a_step.get_attribute("test_syntax_framework") == "unittest" %>selected
                              <% end %> >unittest (Python)
                      </option>
                      <option value="playwrighttest"
                              <% if a_step.get_attribute("test_syntax_framework") == "playwrighttest" || a_step.get_attribute("test_syntax_framework") == "PlaywrightTest" %>selected
                              <% end %> >Playwright Test (JS)
                      </option>
					  
                      <option value="VSTest"
                              <% if a_step.get_attribute("test_syntax_framework") == "VSTest" %>selected
                              <% end %> >VSTest (C#)
                      </option>
					  
                     	 <option value="JUnit"
                              <% if a_step.get_attribute("test_syntax_framework") == "JUnit" %>selected
                              <% end %> >JUnit Ant (Java)
                      	</option>
					  
                    </select>

                    &nbsp;

                    <% if a_step.get_attribute("test_syntax_framework") == "RSpec" %>
                        Exclude suite name from test case:
                        <input type="hidden" name="build_steps[<%= a_step.identifier %>][remove_suite_name_from_test_case]" value="false"/>
                        <input type="checkbox" name="build_steps[<%= a_step.identifier %>][remove_suite_name_from_test_case]" value="true"
                               <% if a_step.get_attribute("remove_suite_name_from_test_case") == 'true' %>checked
                               <% end %> />
                    <% end %>

                  </div>
              <% end %>

            </div>
          </div>
      <% end %>

      <div id="last_build_step"></div>

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:build_cleanup_command) %></label>
      <div class="col-sm-9">
        <input type="text" name="builder_cleanup_command" class="form-control" size="26" value="<%= @config.builder_cleanup_command rescue nil %>" class="span9" placeholder="e.g. <% if @config.is_parallel %>delete_docker_agents.sh<% else %>kill_chrome_and_driver.sh<% end %>"></input>
      </div>
    </div>
                        
    </div>

  </div>
</div>

<!-- scheduler does not work -->

<!--
  <div>
    <p><b class="section-heading">Scheduler</b> <span class="hint">(only with MySQL database)</span></p>

    <% polling = @config.scheduler_polling rescue false %>
    <div class="config-section-content">

	  <div  class="form-group form-group-sm row" >
		 <label class="col-sm-2 form-control-label" for="contact_header">Polling for changes</label>
	    <div  class="col-sm-8">
			<input type="radio" name="scheduler_polling"
  <% if polling %> checked
  <% end %> value="true"> Yes  &nbsp;
			<input type="radio" name="scheduler_polling"
  <% if !polling %> checked
  <% end %>  value="false"> No  &nbsp;
	    </div>
	  </div>

    </div>
	</div>
-->


<div>
  <p><b class="section-heading"><%= I18n.t(:ui_tests) %></b> <span class="hint"><%= I18n.t(:ui_tests_hint) %></span></p>

  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:ui_test_folder) %> <% if @config.is_parallel%><span class="mandatory">*</span><% end %> </label>
      <div class="col-sm-9">
        <input type="text" name="ui_tests_dir" class="form-control" value="<%= @config.ui_tests_dir rescue nil %>" placeholder="relative path, e.g. test/acceptance"/>
        <div class="hint hint-below">
          <%= raw I18n.t(:ui_test_folder_hint) %>          
        </div>
      </div>
    </div>

		<% unless @config.is_parallel %>
    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:test_results_folder) %> </label>
      <div class="col-sm-9">
        <input type="text" name="ui_tests_report_dir" class="form-control" value="<%= @config.ui_tests_report_dir rescue nil %>" placeholder="relative path, e.g. spec/reports"/>
        <div class="hint hint-below">
          <%= raw I18n.t(:test_results_folder_hint) %>
        </div>
      </div>
    </div>
    
    <% end %>
  
    <% if settings.testwise_integration || !@config.is_parallel %>
    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:local_ui_test_folder) %></label>
      <div class="col-sm-9">
        <input type="text" name="ui_tests_local_working_dir" class="form-control" value="<%= @config.ui_tests_local_working_dir rescue nil %>" placeholder="absolute path, containing TestWise project file, e.g. c:/work/my_project/test/ui-tests"/>
        <div class="hint hint-below">
          <%= raw I18n.t(:local_ui_test_folder_hint) %>   
          <code><% if RUBY_PLATFORM =~ /mingw/ %>c:/work/projects/foo/spec<% else %>/Users/me/project/spec<% end %></code>.
        </div>
      </div>
    </div>		
		<% end %>
					
  </div>
</div>
	
<div id="sequential-section" <% if @config.is_parallel %>style="display:none;"<% end %> >
  <p><b class="section-heading"><%= I18n.t(:sequential_test_execution) %></b>
    <span class="hint">(<%= raw I18n.t(:run_tests_sequentially_on_buildwise_server) %>)</span>
  </p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
        <% enable_dynamic_ordering = @config.enable_dynamic_ordering rescue false %>
	
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:dynamic_ordering) %></label>
      <div class="col-sm-9" style="">
        <input type="hidden" name="enable_dynamic_ordering" value="false"/>
        <input type="checkbox" name="enable_dynamic_ordering" value="true"
               <% if enable_dynamic_ordering.to_s == "true" %> checked
               <% end %> data-size="small" data-onstyle="primary" data-toggle="toggle"> 
 
        <div class="hint hint-below">
          <%= I18n.t(:dynamic_ordering_hint) %> 
        </div>
      </div>
    </div>
<!-- 	   
    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:dynamic_feedback) %></label>
      <div class="col-sm-1" style="">    
         <% enable_dynamic_feedback = @config.enable_dynamic_feedback rescue false %>	
         <input type="hidden" name="enable_dynamic_feedback" value="false"/>
         <input type="checkbox" name="enable_dynamic_feedback" value="true"
               <% if enable_dynamic_feedback.to_s == "true" %> checked
               <% end %> data-size="small" data-onstyle="primary" data-toggle="toggle"> 
      </div>
      <div class="col-sm-7" style="">
	
			   <input type="text" name="dynamic_feedback_project_identifier" value="<%= @config.dynamic_feedback_project_identifier%>" class="form-control" />
       
			  <div class="hint hint-below">
          <%= I18n.t(:dynamic_feedback_hint) %> 
        </div>
      </div>
    </div>
-->
  	   
    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:browser) %></label>
      <div class="col-sm-9" style="padding-top: 5px;" id="target-browser-div">
  
        <!-- no "ie"  -->
         <% ["chrome", "firefox",  "safari", "edge"].each do |browser_identifier| %>
         <span>
           <input type="radio" name="target_browser" 	<% if  @config.target_browser == browser_identifier %>checked<% end %> value="<%= browser_identifier %>">&nbsp; <i class="fa <% if browser_identifier == "ie"%> fa-internet-explorer <% else %> fa-<%= browser_identifier %> <% end %> fa-lg" aria-hidden="true"></i>
  <span <%if  @config.target_browser == browser_identifier %>class="selected-browser"<% end %> ><%= t(browser_identifier) %></span> </input> &nbsp; &nbsp;  
         </span>
         <% end %>
	
			  <div class="hint hint-below">
         <%= I18n.t(:target_browser_hint) %>
	      </div>
	
			</div>
		</div>
	
  </div>
</div>
	
<div id="parallel-section" <% unless @config.is_parallel %>style="display:none;"<% end %> >
  <p><b class="section-heading"><%= I18n.t(:parallel_test_execution) %></b>
    <span class="hint">(<%= raw I18n.t(:run_tests_via_multiple) %>)</span>
  </p>
  <% retry_on_another = @config.retry_on_another_machine rescue false %>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:build_agents) %></label>
      <div class="col-sm-9">
        <select name="default_agents[]" id="default_agents" class="select2" multiple="true" style="width: 100%;">
          <option value=""
                  <% if @config && @config.default_agents.nil? %>selected
                  <% end %>>All Agents
          </option>
          <% (@project_available_agents || project.available_agents).each do |x| %>
              <option class="default_agents_option"
                      <% if @config.default_agents && @config.default_agents.include?(x) %> selected
                      <% end %> ><%= x %></option>
          <% end %>
        </select>
        <span class="hint"><%= I18n.t(:build_agents_hint) %></span>
      </div>
    </div>

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:retry_failed_tests_on_another_agent) %></label>
      <div class="col-sm-9" style="">
        <input type="checkbox" name="retry_on_another_machine" value="true"
               <% if retry_on_another %> checked
               <% end %> data-size="small" data-onstyle="primary" data-toggle="toggle">
        <div class="hint hint-below">
          <%= I18n.t(:auto_retry_hint) %> 
        </div>

      </div>
    </div>


    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:app_name) %> <% if @config.is_parallel%><span class="mandatory">*</span><% end %></label>
      <div class="col-sm-7">
        <input type="text" name="app_name" value="<%= @config.app_name rescue nil %>" class="form-control"/>
        <div class="hint hint-below"><%= raw I18n.t(:app_name_hint) %></div>
      </div>
    </div>


    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header">Work directory on Agents <% if @config.is_parallel%><span class="mandatory">*</span><% end %></label>
      <div class="col-sm-9">
        <input type="text" id="agent_work_dir" name="agent_work_dir" value="<%= @config.agent_work_dir rescue nil %>" class="form-control"/>
        <div class="hint hint-below"><%= I18n.t(:work_dir_on_buildwise_agents) %>  <code>
          <% if RUBY_PLATFORM =~ /mingw/ %>c:\work\myproject<% else %>/Users/me/myproject<% end %></code>
          <%= raw I18n.t(:hint_work_dirs_multi_platforms) %> 
       </div>
      </div>
    </div>

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:distribution_rules) %>
        <div style="margin-top: 3px;">
          <% if the_current_user && (the_current_user.is_admin? || the_current_user.has_role?("builder", @project)) %>
              <a href="javascript:void(0);" onclick="$('#distribute-rule-modal').modal('show');" class="btn btn-xs btn-success"><i class="fa fa-plus"></i>
                <%= I18n.t(:add_rule) %> </a>
          <% end %>
        </div>
      </label>
      <div class="col-sm-9">
        <div id="project_distribution_rules" style="font-size: 14px;">
          <%= partial(:'projects/distribution_rules', :locals => {:project => @project}) %>
        </div>
      </div>
    </div>


  </div>
</div>



<div id="load-testing-section" <% unless @config.is_parallel && @config.is_load_testing %>style="display:none;"<% end %> >
  <p><b class="section-heading"><%= I18n.t(:load_test_execution) %></b>
    <span class="hint">(<%= raw I18n.t(:run_tests_via_multiple) %>)</span>
  </p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:load_server_url) %></label>
      <div class="col-sm-3">
        <input type="textarea" name="load_server_url" value="<%= @config.load_server_url rescue '' %>"  class="form-control"/>
      </div>
      <div class="col-sm-6">
        <div class="hint"><%= raw I18n.t(:load_server_url_hint) %></div>
  	  </div>
    </div>


    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:max_vu_count) %></label>
      <div class="col-sm-2">
        <input type="number" name="load_max_agent_count"  style="width: 75px; text-align: right;"  value="<%= @config.load_max_agent_count rescue 10 %>"  class="form-control"/>
      </div>
      <div class="col-sm-6" style="margin-left: 0rem;">
        <div class="hint"><%= raw I18n.t(:max_vu_count_hint) %></div>
  	  </div>
    </div>

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:duration) %></label>
      <div class="col-sm-9">
    
        <div class="input-group" style="margin-bottom: 10px;">
          <div class="input-group-prepend">
            <span class="input-group-text" style="width: 160px;"><%= I18n.t(:load_max_iteration_count) %></span>
          </div>						  
          <input type="number" placeholder="e.g. 10" min="1" max="1000" aria-describedby="basic-addon1" name="load_max_iteration_count" style="width: 64px; text-align: right;" value="<%= @config.load_max_iteration_count rescue 10 %>" width="12">  
           <div class="hint" style="margin-left: 0.5rem; margin-top: 0.1rem;"><%= raw I18n.t(:load_max_iteration_count_hint) %></div>  
         </div>
  
  
        <div class="input-group" style="margin-bottom: 10px;">
          <div class="input-group-prepend">
            <span class="input-group-text" style="width: 160px;"><%= I18n.t(:load_max_execution_time) %></span>
          </div>						  
          <input type="number" placeholder="e.g. 10" min="0" max="10000" aria-describedby="basic-addon1" name="load_max_duration" style="width: 64px; text-align: right;" value="<%= @config.load_max_duration rescue 10 %>" width="12">  
          <div class="hint" style="margin-left: 0.5rem; margin-top: 0.1rem;"><%= raw I18n.t(:load_max_duration_hint) %></div>  
		    </div>

        </div>
    </div>
  
  
    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:load_repeat_times_within_test) %></label>
      <div class="col-sm-2">
        <input type="number" name="load_repeat_times_within_test" value="<%= @config.load_repeat_times_within_test rescue 3 %>" style="width: 75px; text-align: right;"  class="form-control"/>
      </div>
      <div class="col-sm-6">
        <div class="hint"><%= raw I18n.t(:load_repeat_times_within_test_hint) %></div>
  	  </div>
    </div>


    <div class="form-group form-group-sm row">
      <div class="col-sm-2"
          <label class="form-control-label" style="text-align:right;"><b>Success Criteria</b></label>
          <div style="margin-top: 3px;">
              <a href="javascript:void(0);" onclick="$('#load-operational-criteria-modal').modal('show');" class="btn btn-xs btn-success"><i class="fa fa-plus"></i>Add Critiera</a>
          </div>
      </div>
      <div class="col-sm-9">
  
        <div class="input-group" style="margin-bottom: 10px;">
          <div class="input-group-prepend">
            <span class="input-group-text" style="width: 160px;"><%= I18n.t(:load_error_rate) %></span>
          </div>						  
          <input type="text" placeholder="e.g. 0.5" aria-describedby="basic-addon1" name="load_criteria_error_rate" style="width: 64px; text-align: right;" value="<%= @config.load_criteria_error_rate rescue 0.1 %>" width="12">  
          <div class="hint" style="margin-left: 0.5rem; margin-top: 0.1rem;"><%= raw I18n.t(:load_error_rate_hint) %></div>  
		    </div>
  
        <div><b>Operation Timings</b></div>
        <div id="load-operation-timings" style="margin-top: 12px;">
          <table  class="table table-striped table-condensed">
            <thead>
              <tr>
                <th width="70%">Operation</th>
                <th>Average (ms)</th>
                <th>Slowest (ms)</th>  
                <th>Active?</th>  
                <th></th>  
              </tr>
            </thead>
            <tbody>
            <% lc_idx = 0  %>
            <% @config.load_operation_criteria.each do |key, val| %>
              <tr id="load-criteria-operation-<%= lc_idx %>">
                <td><input type="text" name="load_criteria_operation_names[]" readonly value='<%= key%>'/></td>
                <td><input type="text" name="load_criteria_operation_average_time[]" readonly value='<%= val[:average_time] %>' style='width:80px; text-align:right;'/></td>
                <td><input type="text"  name="load_criteria_operation_slowest_time[]" readonly value='<%= val[:slowest_time] %>' style='width:80px; text-align:right;'/></td>
                <td style="text-align:center; padding-top: 16px;">  
                  <!-- no space in next two tag -->
                  <input type="hidden"  name="load_criteria_operation_is_active[]" id="operation_check_box_<%= lc_idx %>" value="<% if val[:is_active].to_s == "true" %>1<% else %>0<% end %>" /><input type="checkbox" onclick="this.previousSibling.value=1-this.previousSibling.value"
  					<% if val[:is_active].to_s == "true" %>checked<% end %>
  				  />

                </td>
                <td style="align:right; padding: 5px; padding-top: 10px;">				
                  <a href="javascript:void(0);" class="btn btn-sm" onclick="$('#load-criteria-operation-<%= lc_idx %>').remove();">
      		<i class="fa fa-trash red" aria-hidden="true"></i></a></td>  
              </tr>
              <% lc_idx += 1; %>
            <% end %>
            </tbody>
          </table>
        </div>
          
  	  </div>
    </div>

  
  </div>
</div>


<div>
  <p><b class="section-heading"><%= I18n.t(:environment_variables) %></b>
    <a href="https://agileway.com.au/buildwise/docs"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
    &nbsp;
    <span class="hint"> <%= I18n.t(:environment_variables_heading_hint) %></span></p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:current_environment_variables) %> :
        <div style="margin-top: 6px;">
          <a href="javascript:void(0);" onclick="add_env_var_row()" class="btn btn-xs btn-success"><i class="fa fa-plus"></i>
            <%= I18n.t(:add_environment_variable) %> </a>
        </div>
      </label>
      <div class="col-sm-10">

        <div class="" style="margin-right: 10px;" id="env_var_editor">
          <% if @config && @config.environment_variables %>

              <% env_keys = @config.environment_variables.keys %>
              <% env_keys.sort.each_with_index do |key, idx| %>
                  <div class="form-group form-group-sm row" id="env_row_<%= idx %>">
                    <div class="col-sm-5">
                      <input type="text" name="env_var_key[<%= idx %>]" value="<%= key %>" style="" class="form-control">
                    </div>
                    <div class="col-sm-1" style="text-align: center; margin-left: -1rem; margin-right: -1rem; margin-top: 8px;">
                      =
                    </div>
                    <div class="col-sm-5">
                      <% if the_current_user && (the_current_user.is_admin? || the_current_user.has_role?("builder", @project)) %>

                          <input type="text" name="env_var_value[<%= idx %>]" value="<%= @config.environment_variables[key] %>" style="" class="form-control">

                      <% else %>

                          <input type="password" name="env_var_value[<%= idx %>]" value="secret" disabled="true" style="" class="form-control">

                      <% end %>

                    </div>
                    <div class="col-sm-1" style="margin-top: 4px;">

                      <% if the_current_user && (the_current_user.is_admin? || the_current_user.has_role?("builder", @project)) && ![ "BUILDWISE_MASTER", "DISTRIBUTED_BUILD_CHECK_INTERVAL", "DISTRIBUTED_MAX_BUILD_TIME"].include?(key) %>

                          <a href="javascript:void(0);" onclick="$('#env_row_<%= idx %>').remove();"><i class="fa fa-trash orange fa-lg" style="margin-top: 5px;"></i></a>

                      <% end %>
                    </div>
                  </div>
              <% end %>


          <% end %>
        </div>

        <div class="hint hint-below">
          <%= raw I18n.t(:environment_variables_long_hint) %>
        </div>

      </div>


    </div>

    <!--
      <div class="form-group form-group-sm row">
        <label class="col-sm-2 form-control-label" for="contact_header">Edit Environment Variables <br/>(separate by new
          line)</label>
        <div class="col-sm-9">
          <textarea name="environment_variables_edit" class="form-control" rows="4"><%= @env_vars_string %></textarea>
        </div>
      </div>
-->

  </div>
</div>

<div>
  <p><b class="section-heading"><%= I18n.t(:files_directories_to_archive) %></b>
    <span class="hint"><%= I18n.t(:artifacts_heading_hint) %></span></p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"> &nbsp; </label>
      <div class="col-sm-9">

        <textarea name="files_to_archive" cols="64" class="form-control" rows="2"><%= @config.files_to_archive rescue nil %></textarea>
        <div class="hint hint-below">
          <%= I18n.t(:artifacts_hint)%>
        </div>
      </div>

    </div>
  </div>
</div>



<div>
  <p><b class="section-heading"><%= I18n.t(:user_interface) %></b>
    <span class="hint"><%= I18n.t(:user_interface_heading_hint) %></span></p>
  </p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:show_test_scripts_to_public) %>?</label>
      <div class="col-sm-9">

        <% ui_show_test_scripts_to_public = @config.show_test_scripts_to_public rescue false %>
        <input type="hidden" name="show_test_scripts_to_public" value="false"/>
        <input type="checkbox" name="show_test_scripts_to_public" value="true" <% if ui_show_test_scripts_to_public.to_s =="true" %>checked<% else %>nothing<% end %>
                data-size="small" data-onstyle="primary" data-toggle="toggle">
        <div class="hint hint-below">
        </div>
      </div>
    </div>
          
    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:highlight_test_output) %>?</label>
      <div class="col-sm-9">

        <% ui_highlight_test_output = @config.highlight_test_output rescue false %>
        <input type="hidden" name="highlight_test_output" value="false"/>
        <input type="checkbox" name="highlight_test_output" value="true" <% if ui_highlight_test_output.to_s =="true" %>checked<% else %>nothing<% end %>
                data-size="small" data-onstyle="primary" data-toggle="toggle">
        <div class="hint hint-below">
          <%= raw I18n.t(:highlight_test_output_hint)%>          
        </div>
      </div>
    </div>
          
          
  </div>
</div>


<div>
  <p><b class="section-heading"><%= I18n.t(:requirement_traceability) %></b>
    <span class="hint"><%= I18n.t(:requirement_traceability_hint) %></span></p>
  </p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:user_story_prefix_url) %></label>
      <div class="col-sm-9">      
        <% if the_current_user && the_current_user.is_admin? %>
            <input type="text" name="user_story_prefix_url" class="form-control" value="<%= @config.user_story_prefix_url rescue nil %>" placeholder="http://jira/browse/"/>
        <% else %>
            <input type="password" name="user_story_prefix_url" class="form-control" disabled="true" placeholder="http://jira/browse/"/>
        <% end %>
        <div class="hint hint-below">
            <%= I18n.t(:user_story_prefix_url_hint) %>          
        </div>
          
      </div>

    </div>
  </div>
</div>

<div>
  <p><b class="section-heading"><%= I18n.t(:deployment) %></b>
    <span class="hint"><%= I18n.t(:deployment_hint) %></span></p>
  </p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:rake_task) %></label>
      <div class="col-sm-9">      
        <% if the_current_user && the_current_user.is_admin? %>
            <input type="text" name="deploy_rake_task" class="form-control" value="<%= @config.deploy_rake_task rescue nil %>" placeholder="-f Rakefile deploy:production"/>
        <% else %>
            <input type="password" name="deploy_rake_task" class="form-control" disabled="true" placeholder="-f Rakefile deploy:production"/>
        <% end %>
        <div class="hint hint-below">
            <%= I18n.t(:deploy_rake_task_hint) %>          
        </div>          
      </div>
    </div>
  </div>
</div>


<div>
  <p><b class="section-heading">API</b>
    <span class="hint"><%= I18n.t(:project_api_heading_hint) %></span></p>
  </p>
  <div class="config-section-content">

    <div class="form-group form-group-sm row">
      <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:project_api_key) %>
			<div style="margin-top: 8px;">
			  <button id="generate_api_key" class="btn btn-default btn-sm" onclick="generate_random_api_key(); return false;">Generate</button>			
			  <button id="disable_api" class="btn btn-default btn-sm" onclick="clear_api_key(); return false;">Disable</button>						
			</div>
	  </label>
      <div class="col-sm-9">
        <% if the_current_user && the_current_user.is_admin? %>
            <input type="text" style="width: 300px;" readonly="true" id="project_api_key" name="api_key" class="form-control" value="<%= @config.api_key rescue nil %>" placeholder="secret token" />
        <% else %>
            <input type="password"  style="width: 300px;" readonly="true"  id="project_api_key"  name="api_key" class="form-control" disabled="true" placeholder="secret key"/>
        <% end %>
			
			
        <div class="hint hint-below"><%= raw I18n.t(:api_trigger_bulid_hint, :project_id => @project.identifier) %></div>
      </div>
    </div>
  </div>
</div>


<div>
  <p><b class="section-heading"><%= I18n.t(:notifications) %></b> <span class="hint"><%= I18n.t(:notification_hint) %></span></p>
  <div class="config-section-content">
    <div id="notifications_tabs">
      <ul class="nav nav-tabs" id="notifications-tabs">

        <li class="nav-item"><a class="nav-link active" href="#notification-tab-1" data-toggle="tab" role="tab">Slack
          <% if @config && !@config.publisher_slack_webhook_url.blank? && @config.publisher_slack_active %>
              <i class="fa fa-check text-success" aria-hidden="true"></i>
          <% end %></a></li>

        <li class="nav-item"><a class="nav-link" href="#notification-tab-2" data-toggle="tab" role="tab" aria-selected="false">Wemo (Lamp)
            
          <% if @config && @config.publisher_wemo_active  %>
              <i class="fa fa-check text-success" aria-hidden="true"></i>
          <% end %></a></li>

        <li class="nav-item"><a class="nav-link" href="#notification-tab-4" data-toggle="tab" role="tab">TP-link Smart Plug (Lamp)
          <% if @config && @config.publisher_tplink_active %>
              <i class="fa fa-check text-success" aria-hidden="true"></i>
          <% end %></a></li>

        <li class="nav-item"><a class="nav-link " href="#notification-tab-3" data-toggle="tab" role="tab">E-mail
          <% if @config && @config.publisher_mail_recipients && @config.publisher_mail_active %>
              <i class="fa fa-check text-success" aria-hidden="true"></i>
          <% end %></a></li>

        <li class="nav-item"><a class="nav-link " href="#notification-tab-5" data-toggle="tab" role="tab">HTTP Callback
          <% if @config && @config.publisher_http_callback_active %>
              <i class="fa fa-check text-success" aria-hidden="true"></i>
          <% end %></a></li>

      </ul>


      <div class="tab-content">


        <div id="notification-tab-1" class="tab-pane show active" style="padding-left: 2px;">

          <div style="margin-top: 10px; margin-bottom:10px;"><%= raw I18n.t(:slack_intro) %></div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:is_active) %></label>
            <div class="col-sm-6" style="margin-top: 4px;">
              <input type="radio" name="publisher_slack_active" value="true"
                     <% if @config && @config.publisher_slack_active %>checked
                     <% end %>/> Yes &nbsp;
              <input type="radio" name="publisher_slack_active" value="false"
                     <% unless @config && @config.publisher_slack_active %>checked
                     <% end %> /> No

              <% if @project.id && the_current_user && (the_current_user.is_admin? || the_current_user.has_role?(:builder, @project)) %>
        					<span style="margin-left: 20px;">
        						<a href="javascript:void(0);" onclick="slack_send_test_notification()" class="btn btn-default btn-sm"><%= I18n.t(:send_test_notification) %></a>
        					</span>
              <% end %>

            </div>
          </div>


          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header">Webhook URL</label>
            <div class="col-sm-9">
              <input type="text" name="publisher_slack_webhook_url" class="form-control" value="<%= @config && @config.publisher_slack_webhook_url rescue nil %>" placeholder="e.g. https://hooks.slack.com/services/..."/>
            </div>
          </div>


          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header">Channel</label>
            <div class="col-sm-6">
              <input type="text" name="publisher_slack_channel" class="form-control" value="<%= @config && @config.publisher_slack_channel rescue nil %>" placeholder="e.g. build status"/>
            </div>
          </div>


          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:username) %></label>
            <div class="col-sm-6">
              <input type="text" name="publisher_slack_username" class="form-control" value="<%= @config && @config.publisher_slack_username rescue nil %>" placeholder="e.g. cto"/>
            </div>
          </div>

        </div> <!-- end notification 1 tab -->


        <div id="notification-tab-3" class="tab-pane fade show ">

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:is_active) %></label>
            <div class="col-sm-6" style="margin-top: 4px;">
              <input type="radio" name="publisher_mail_active" value="true"
                     <% if @config && @config.publisher_mail_active %>checked
                     <% end %>/> Yes &nbsp;
              <input type="radio" name="publisher_mail_active" value="false"
                     <% unless @config && @config.publisher_mail_active %>checked
                     <% end %> /> No
            </div>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:recipients) %></label>
            <div class="col-sm-9">
              <input type="text" name="publisher_mail_recipients" class="form-control" value="<%= @config.publisher_mail_recipients rescue nil %>" placeholder="e.g. me@host.com, you@host.com"/>
            </div>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:mail_server_url) %></label>
            <div class="col-sm-6">
              <input type="text" name="publisher_mail_address" class="form-control" value="<%= @config.publisher_mail_address rescue nil %>" placeholder="e.g. smtp.gmail.com"/>
            </div>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:mail_server_port) %></label>
            <div class="col-sm-6">
              <input type="text" name="publisher_mail_port" class="form-control" value="<%= @config.publisher_mail_port rescue nil %>" placeholder="e.g. 587"/>
            </div>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:authentication)%></label>
            <div class="col-sm-6">
              <input type="text" name="publisher_mail_authentication" class="form-control" value="<%= @config.publisher_mail_authentication rescue nil %>" placeholder="e.g. plain"/>
            </div>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:user_name) %></label>
            <div class="col-sm-6">
              <input type="text" name="publisher_mail_user" class="form-control" value="<%= @config.publisher_mail_user rescue nil %>" placeholder="e.g. john"/>
            </div>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:password) %></label>
            <div class="col-sm-6">

              <% if the_current_user && (the_current_user.is_admin? || the_current_user.has_role?("builder", @project)) %>

                  <input type="password" name="publisher_mail_password" class="form-control" value="<%= @config.publisher_mail_password rescue nil %>" placeholder="e.g. secret"/>

              <% else %>

                  <input type="password" name="publisher_mail_password" class="form-control" value="secret" disabled="true" placeholder="e.g. secret"/>


              <% end %>
            </div>
          </div>

        </div>



        <div id="notification-tab-2" class="tab-pane fade">

          <div style="margin-top: 10px; margin-bottom:10px;"><%= raw I18n.t(:wemo_intro) %>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-3 form-control-label" for="contact_header"><%= I18n.t(:is_active) %></label>
            <div class="col-sm-6" style="margin-top: 4px;">
              <input type="radio" name="publisher_wemo_active" value="true"
                     <% if @config && @config.publisher_wemo_active %>checked
                     <% end %>/> Yes &nbsp;
              <input type="radio" name="publisher_wemo_active" value="false"
                     <% unless @config && @config.publisher_wemo_active %>checked
                     <% end %> /> No
            </div>
          </div>

          <div class="form-group form-group-sm row">

            <label class="col-sm-3 form-control-label" for="contact_header">Wemo Location (IP) when failed</label>
            <div class="col-sm-3">
              <input type="text" name="publisher_wemo_failure_ip" id="publisher_wemo_failure_ip" class="form-control" value="<%= @config.publisher_wemo_failure_ip rescue nil %>" placeholder="10.0.0.12"/>
            </div>
            <div class="col-sm-3">
              <a href="javascript:void(0)" class="btn btn-sm btn-default" onclick="wemo_switch_status('publisher_wemo_failure_ip')">Check status</a>
              <span id="publisher_wemo_failure_ip_indicator" class="label label-as-badge" style="display:none;">&nbsp;</span>
            </div>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-3 form-control-label" for="contact_header">Wemo Location (IP) when
              successful</label>
            <div class="col-sm-3">
              <input type="text" name="publisher_wemo_success_ip" id="publisher_wemo_success_ip" class="form-control" value="<%= @config.publisher_wemo_success_ip rescue nil %>" placeholder="10.0.0.11"/>
            </div>
            <div class="col-sm-3">
              <a href="javascript:void(0)" class="btn btn-sm btn-default" onclick="wemo_switch_status('publisher_wemo_success_ip')">Check status</a>
              <span id="publisher_wemo_success_ip_indicator" class="label label-as-badge" style="display:none;">&nbsp;</span>

            </div>
          </div>

        </div> <!-- end notification 2 tab -->


        <div id="notification-tab-4" class="tab-pane fade">

          <div style="margin-top: 10px; margin-bottom:10px;"><%= raw I18n.t(:tplink_smart_plug_intro) %>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-3 form-control-label" for="contact_header"><%= I18n.t(:is_active) %></label>
            <div class="col-sm-6" style="margin-top: 4px;">
              <input type="radio" name="publisher_tplink_active" value="true"
                     <% if @config && @config.publisher_tplink_active %>checked
                     <% end %>/> Yes &nbsp;
              <input type="radio" name="publisher_tplink_active" value="false"
                     <% unless @config && @config.publisher_tplink_active %>checked
                     <% end %> /> No
            </div>
          </div>

          <div class="form-group form-group-sm row">

            <label class="col-sm-3 form-control-label" for="contact_header">Plug device name when failed</label>
            <div class="col-sm-3">
              <input type="text" name="publisher_tplink_failure_device_name" id="publisher_tplink_failure_device_name" class="form-control" value="<%= @config.publisher_tplink_failure_device_name rescue nil %>" placeholder="Build Red Lamp"/>
            </div>
            <div class="col-sm-3">
              <a href="javascript:void(0)" class="btn btn-sm btn-default" onclick="tplink_smart_plug_status('publisher_tplink_failure_device_name')">Check status</a>
              <span id="publisher_tplink_failure_device_name_indicator" class="label label-as-badge" style="display:none;">&nbsp;</span>
            </div>
          </div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-3 form-control-label" for="contact_header">Plug device name when
              successful</label>
            <div class="col-sm-3">
              <input type="text" name="publisher_tplink_success_device_name" id="publisher_tplink_success_device_name" class="form-control" value="<%= @config.publisher_tplink_success_device_name rescue nil %>" placeholder="Build Green Lamp"/>
            </div>
            <div class="col-sm-3">
              <a href="javascript:void(0)" class="btn btn-sm btn-default" onclick="tplink_smart_plug_status('publisher_tplink_success_device_name')">Check status</a>
              <span id="publisher_tplink_success_device_name_indicator" class="label label-as-badge" style="display:none;">&nbsp;</span>

            </div>
          </div>

        </div> <!-- end notification 4 tab -->


        <div id="notification-tab-5" class="tab-pane fade" style="padding-left: 2px;">

          <div style="margin-top: 10px; margin-bottom:10px;"><%= raw I18n.t(:http_callback_intro) %></div>

          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header"><%= I18n.t(:is_active) %></label>
            <div class="col-sm-6" style="margin-top: 4px;">
              <input type="radio" name="publisher_http_callback_active" value="true"
                     <% if @config && @config.publisher_http_callback_active %>checked
                     <% end %>/> Yes &nbsp;
              <input type="radio" name="publisher_http_callback_active" value="false"
                     <% unless @config && @config.publisher_http_callback_active %>checked
                     <% end %> /> No

              <% if @project.id && the_current_user && (the_current_user.is_admin? || the_current_user.has_role?(:builder, @project)) %>
        					<span style="margin-left: 20px;">
        						<a href="javascript:void(0);" onclick="http_callback_send_test_notification()" class="btn btn-default btn-sm"><%= I18n.t(:send_test_notification) %></a>
        					</span>
              <% end %>

            </div>
          </div>


          <div class="form-group form-group-sm row">
            <label class="col-sm-2 form-control-label" for="contact_header">Webhook URL</label>
            <div class="col-sm-9">
              <input type="text" id="publisher_http_callback_webhook_url" name="publisher_http_callback_webhook_url" class="form-control" value="<%= @config && @config.publisher_http_callback_webhook_url rescue nil %>" placeholder="e.g. https://your_ci.server/..."/>
            </div>
          </div>

        </div> <!-- end notification 5 tab -->

      </div>
    </div>
  </div>
</div>


<script type="text/javascript">
    $('select.select2').select2();

    $(function () {

      $('#notifications-tabs a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
       })

        enable_sort_build_steps();
    });

</script>
