{% extends 'ui/base.html' %} {% block title %}Protocol | BioQueue{% endblock %} {% block content %}
{% for protocol in protocol_list %} {% endfor %}
ID Protocol Operation
{{ protocol.id }} {{ protocol.name }}
{% endblock %} {% block script %} var before_software = ""; $("#edit-job").addClass("active"); var csrftoken = $.cookie('csrftoken'); $.ajaxSetup({ beforeSend: function(xhr, settings){ xhr.setRequestHeader("X-CSRFToken", csrftoken); } }); var oTextbox = new AutoSuggestControl("parameter"); $("form").submit(function(){ var self = $(this); $.post(self.attr("action"), self.serialize(), success, "json"); return false; function success(data){ if(data.status){ Messenger().post({ message: data.info, showCloseButton: true }); self[0].reset(); if (self.attr('id') == 'new-step-form'){ showSteps($("#step-parent").val()); $('#newStep').modal('hide'); } } else { Messenger().post({ message: data.info, type: 'error', showCloseButton: true }); } } }); function delProtocol(obj){ var self = $(obj); $.get("{% url 'ui:delete_protocol' %}", {id: self.attr("data-pid")}, function(data){ if(data.status){ self.parent().parent().parent().hide("slow"); }; }); } function edit(obj){ var new_id = "parameter" + Math.random(); var self = $(obj); var txt = $.trim(self.text()); var input = $(""); input.attr("value", txt); self.html(input); var oTextbox = new AutoSuggestControl(new_id); input.click(function(){return false;}); input.trigger("focus"); input.blur(function(){ var newTxt = input.val(); if (newTxt != txt){ self.html(newTxt); $.get("{% url 'ui:update_parameter' %}", {parent:self.attr("data-pid"), id:self.attr("data-sid"), parameter:encodeURI(newTxt)}, function(data){ if (data.status){ Messenger().post({ message: data.info, showCloseButton: true }); }else{ Messenger().post({ message: data.info, type: 'error', showCloseButton: true }); } }); }else{ self.html(newTxt); } }); }; function showML(obj){ var self = $(obj); if (self.text() == 'CPU'){ $.get('{% url 'ui:get_learning_result' %}', {stephash: self.attr('data-hash'), type: 3}, function(data){ $('#ml .modal-body').html(data.info); $('#ml').modal(); }); }else if(self.text() == 'Memory'){ $.get('{% url 'ui:get_learning_result' %}', {stephash: self.attr('data-hash'), type: 2}, function(data){ $('#ml .modal-body').html(data.info); $('#ml').modal(); }); }else if(self.text() == 'Disk'){ $.get('{% url 'ui:get_learning_result' %}', {stephash: self.attr('data-hash'), type: 1}, function(data){ $('#ml .modal-body').html(data.info); $('#ml').modal(); }); } } function showNewStep(recId){ $('#newStep #step-parent').val(recId); $('#newStep .modal-body').html(); $('#newStep').modal(); } function showShare(proId){ $('#share #pro').val(proId); $('#upload-protocol-link').attr("data-pid", proId); $('#export-protocol-link').attr("href", "/ui/export-protocol?id="+proId); $('#share').modal(); } function uploadProtocol(obj){ var self = $(obj); $.get('{% url 'ui:upload_protocol' %}', {id: self.attr('data-pid')}, function(data){ if (data.status){ Messenger().post({ message: data.info, showCloseButton: true }); }else{ Messenger().post({ message: data.info, type: 'error', showCloseButton: true }); } }); } function showSteps(recId){ $('#stepsContainer').html(''); $.post("{% url 'ui:show_step' %}", {parent: recId}, function(data){ if(data.status){ if ($('#stepsContainer').css("display") != 'none'){ $('#stepsContainer').hide("fast"); } $('#stepsContainer').html(data.info); $('#stepsContainer').show("slow"); $("html,body").animate({scrollTop:$("#stepsContainer").offset().top},1000) }else{ Messenger().post({ message: data.info, type: 'error', showCloseButton: true }); }; }); } function fetchKB(obj){ var self = $(obj); var this_software = self.parent().parent().children("#software").val(); //self.parent().parent().parent().parent() var hint_panel = $("#new-step-form").children(".hints"); if (before_software != this_software){ before_software = this_software; self.attr("disabled", true); var api_bus = "{% url 'ui:query_usage' %}"; $.post(api_bus, {software: this_software}, function(data){ if (data.status){ hint_panel.children('.hints-container').html(data.content); hint_panel.show(); } self.attr("disabled", false); }, 'json').error(function(){ self.attr("disabled", false); }); }else{ hint_panel.show(); } } {% endblock %}