From fad3229cca5d31670f1c1d99542f3d563e226d99 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 23 Sep 2011 10:34:34 +0200 Subject: endpoint selection for create model form --- application.rb | 4 ++-- helper.rb | 33 ++++++++++++++++++++++++++++++--- views/create.haml | 30 +++++++++++++++++++++++++++++- views/model_echa.haml | 4 ++-- views/style.sass | 40 ++++++++++++++++++++++++++++++++++++---- 5 files changed, 99 insertions(+), 12 deletions(-) diff --git a/application.rb b/application.rb index 12784f0..3ed2af6 100644 --- a/application.rb +++ b/application.rb @@ -232,8 +232,8 @@ end post '/models' do # create a new model - unless (params[:dataset] and params[:prediction_feature]) or (params[:file] and params[:file][:tempfile]) #params[:endpoint] and - flash[:notice] = "Please upload a Excel or CSV file or select an AMBIT dataset." + unless (params[:dataset] and params[:prediction_feature]) or (params[:endpoint] and params[:file] and params[:file][:tempfile]) #params[:endpoint] and + flash[:notice] = "Please upload a Excel or CSV file and select an endpoint or select an AMBIT dataset." redirect url_for('/create') end diff --git a/helper.rb b/helper.rb index 9b47142..234d612 100644 --- a/helper.rb +++ b/helper.rb @@ -108,12 +108,39 @@ helpers do File.unlink(tmpfile) end end - result = OpenTox::Ontology::Echa.endpoint_option_list() + result = endpoint_selection() if result.lines.count > 3 f = File.new(tmpfile,"w") f.print result f.close end - return result + result end -end + + def endpoint_level(endpoint="Endpoints", level=1) + results = OpenTox::Ontology::Echa.echa_endpoints(endpoint) rescue results = [] + out = "" + out += "\n" if results.size > 0 + return out + end + + def endpoint_selection() + out = " \n +
\n" + out += "Please select:\n" + out += endpoint_level + js = "" + out += "
\n" + return out + end + +end \ No newline at end of file diff --git a/views/create.haml b/views/create.haml index da85382..acfa098 100644 --- a/views/create.haml +++ b/views/create.haml @@ -1,3 +1,30 @@ +:javascript + $(document).ready(function() { + $(".endpoint_list").click(function() { + elem = this.id; + title = $("label#label_" + elem).html(); + if($("ul#list_" + elem)) { + if ($("ul#list_" + elem).is(":hidden")) { + $("ul#list_" + elem).slideDown("slow"); + } else { + $("ul#list_" + elem).slideUp("slow"); + } + } + $("span#endpoint_label").html(title); + }); + $("#endpoint_list_button").click(function() { + if ($("div#div_endpoint").is(":hidden")) { + $("div#div_endpoint").slideDown("slow"); + $("input#endpoint_list_button").val("OK"); + $("input#endpoint_list_button").toggleClass("ok_button", true); + } else { + $("div#div_endpoint").slideUp("slow"); + $("input#endpoint_list_button").val("select endpoint"); + $("input#endpoint_list_button").toggleClass("ok_button", false); + } + }); + }); + .input %p @@ -25,7 +52,8 @@ format: %input{:type => 'file', :name => 'file', :id => 'file', :size => '41'} %br - -# = haml :model_echa, :layout => false + = haml :model_echa, :layout => false + %br %input{ :type => "submit", :value => "Create model"} =# link_to "Cancel", '/create' diff --git a/views/model_echa.haml b/views/model_echa.haml index 257a28a..4815c35 100644 --- a/views/model_echa.haml +++ b/views/model_echa.haml @@ -1,2 +1,2 @@ -Select an endpoint: -= endpoint_option_list \ No newline at end of file +For endpoint: += endpoint_option_list() \ No newline at end of file diff --git a/views/style.sass b/views/style.sass index c2a74cb..0c1f48c 100644 --- a/views/style.sass +++ b/views/style.sass @@ -5,6 +5,7 @@ $ot_purple: #5d308a $body_color: white $text_color: black $notice_border: red +$mouseover: #FFFF69 body min-width: 30em @@ -288,12 +289,43 @@ dl .thin font-weight: 100 +ul.endpoint + list-style-type: none + margin-left: 0px + padding-left: 0px + +ul.level_2 + display: none +ul.level_3 + display: none +ul.level_4 + display: none + .level_1 - padding-left: 10px + margin-left: 0px font-weight: bold .level_2 - padding-left: 20px + margin-left: 20px + font-weight: normal .level_3 - padding-left: 30px + margin-left: 40px + font-weight: normal .level_4 - padding-left: 40px + margin-left: 60px + font-weight: normal + +#endpoint_label + font-weight: bold + margin: 0 10px + +ul.endpoint + label:hover, label:active + background-color: $mouseover + border-bottom: solid #999 1px + border-top: solid #999 1px + +#div_endpoint + display: none + +.ok_button + background-color: $mouseover -- cgit v1.2.3 From d1a61ff236cf95a7f3cba4a60e85c14e877c730d Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 23 Sep 2011 15:58:03 +0200 Subject: remove unused js --- views/models_navigation.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/models_navigation.haml b/views/models_navigation.haml index b491cb5..0dc1f63 100644 --- a/views/models_navigation.haml +++ b/views/models_navigation.haml @@ -42,7 +42,7 @@ %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ - js = "" - - ["id","created_at","name","type"].each do |s| + - ["created_at","name","type"].each do |s| - idname = s == "created_at" ? "date" : s - js += "$('##{idname}').click(function() \{ \n " - js += " $('#sort_by').val('#{s}');\n " -- cgit v1.2.3 From c1e82f2705d1e7c0e7eb464e940ae43920856d7a Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 4 Oct 2011 11:35:27 +0200 Subject: require oprntoxruby ~> 3 --- application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.rb b/application.rb index 3ed2af6..3b2fa74 100644 --- a/application.rb +++ b/application.rb @@ -1,7 +1,7 @@ ['rubygems', "haml", "sass", "rack-flash"].each do |lib| require lib end -gem "opentox-ruby", "~> 2" +gem "opentox-ruby", "~> 3" require 'opentox-ruby' gem 'sinatra-static-assets' require 'sinatra/static_assets' -- cgit v1.2.3 From 99a50ecb6c6cbff678048c2f60eafcfe476c1b64 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 10 Oct 2011 12:47:52 +0200 Subject: add endpoint to features --- application.rb | 4 ++-- helper.rb | 2 +- views/create.haml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/application.rb b/application.rb index 3ed2af6..a75c6c0 100644 --- a/application.rb +++ b/application.rb @@ -1,7 +1,7 @@ ['rubygems', "haml", "sass", "rack-flash"].each do |lib| require lib end -gem "opentox-ruby", "~> 2" +gem "opentox-ruby", "~> 3" require 'opentox-ruby' gem 'sinatra-static-assets' require 'sinatra/static_assets' @@ -280,6 +280,7 @@ post '/models' do # create a new model else raise "#{params[:file][:filename]} has an unsupported file type." end + @dataset.features[@dataset.features.keys.first][OWL.sameAs] = params[:endpoint].split(',').first if params[:endpoint] @dataset.save(@subjectid) rescue => e error "Dataset creation failed '#{e.message}'",e @@ -290,7 +291,6 @@ post '/models' do # create a new model @prediction_feature = OpenTox::Feature.find(@dataset.features.keys.first,@subjectid) end end - task.progress(10) if @dataset.compounds.size < 10 error "Too few compounds to create a prediction model. Did you provide compounds in SMILES format and classification activities as described in the #{link_to "instructions", "/help"}? As a rule of thumb you will need at least 100 training compounds for nongeneric datasets. A lower number could be sufficient for congeneric datasets." diff --git a/helper.rb b/helper.rb index 234d612..0bcde74 100644 --- a/helper.rb +++ b/helper.rb @@ -134,7 +134,7 @@ helpers do end def endpoint_selection() - out = " \n + out = " \n
\n" out += "Please select:\n" out += endpoint_level diff --git a/views/create.haml b/views/create.haml index acfa098..a26ae05 100644 --- a/views/create.haml +++ b/views/create.haml @@ -15,11 +15,11 @@ $("#endpoint_list_button").click(function() { if ($("div#div_endpoint").is(":hidden")) { $("div#div_endpoint").slideDown("slow"); - $("input#endpoint_list_button").val("OK"); + $("input#endpoint_list_button").val("Hide"); $("input#endpoint_list_button").toggleClass("ok_button", true); } else { $("div#div_endpoint").slideUp("slow"); - $("input#endpoint_list_button").val("select endpoint"); + $("input#endpoint_list_button").val("Select endpoint"); $("input#endpoint_list_button").toggleClass("ok_button", false); } }); -- cgit v1.2.3 From 680b552ce6d135a1730f83eb23da44ae244c2aa8 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 11 Oct 2011 12:37:14 +0200 Subject: endpoint for external dataset --- application.rb | 6 ++++++ helper.rb | 4 ++-- model.rb | 2 ++ views/model.haml | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/application.rb b/application.rb index a75c6c0..50aee72 100644 --- a/application.rb +++ b/application.rb @@ -281,6 +281,7 @@ post '/models' do # create a new model raise "#{params[:file][:filename]} has an unsupported file type." end @dataset.features[@dataset.features.keys.first][OWL.sameAs] = params[:endpoint].split(',').first if params[:endpoint] + @model.update :endpoint_uri => params[:endpoint].split(',').first, :endpoint => params[:endpoint].split(',')[1..99].to_s.gsub(/^"(.*?)"$/,'\1') if params[:endpoint] @dataset.save(@subjectid) rescue => e error "Dataset creation failed '#{e.message}'",e @@ -290,6 +291,11 @@ post '/models' do # create a new model else @prediction_feature = OpenTox::Feature.find(@dataset.features.keys.first,@subjectid) end + #else + # test when external dataset is enabled: + #if @dataset.features[@dataset.features.keys.first][OWL.sameAs] + # @model.update :endpoint_uri => @dataset.features[@dataset.features.keys.first][OWL.sameAs], :endpoint => OpenTox::Ontology::Echa.get_endpoint_name(@dataset.features[@dataset.features.keys.first][OWL.sameAs]) + #end end task.progress(10) if @dataset.compounds.size < 10 diff --git a/helper.rb b/helper.rb index 0bcde74..f45e349 100644 --- a/helper.rb +++ b/helper.rb @@ -98,7 +98,7 @@ helpers do def endpoint_option_list(max_time=3600) out = "" - tmpfile = File.join(TMP_DIR, "endpoint_option_list") + tmpfile = File.join(TMP_DIR, 'endpoint_option_list') if File.exists? tmpfile if Time.now-File.mtime(tmpfile) <= max_time f = File.open(tmpfile, 'r+') @@ -110,7 +110,7 @@ helpers do end result = endpoint_selection() if result.lines.count > 3 - f = File.new(tmpfile,"w") + f = File.new(tmpfile,'w') f.print result f.close end diff --git a/model.rb b/model.rb index bab5bde..05075f8 100644 --- a/model.rb +++ b/model.rb @@ -19,6 +19,8 @@ class ToxCreateModel < Ohm::Model attribute :training_dataset attribute :feature_dataset + attribute :endpoint_uri + attribute :endpoint #attributey :validation_task_uri attribute :validation_uri diff --git a/views/model.haml b/views/model.haml index 356ec65..fb264ca 100644 --- a/views/model.haml +++ b/views/model.haml @@ -40,6 +40,9 @@ - if model.nr_compounds %dt Training compounds: %dd= model.nr_compounds + - if model.endpoint + %dt Endpoint: + %dd= model.endpoint - if model.error_messages %dt Errors: %dd= model.error_messages -- cgit v1.2.3 From 5147b37a3285a231d8c938c3baf2f216a3b7f197 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 17 Oct 2011 10:04:44 +0200 Subject: model sorting for endpoints| pager for models --- application.rb | 21 ++++++++++++++--- helper.rb | 5 ++++ views/models.haml | 1 + views/models_navigation.haml | 36 ++++++++++++++++++---------- views/models_navigation_bottom.haml | 47 +++++++++++++++++++++++++++++++++++++ views/predict.haml | 5 ++++ views/style.sass | 24 ++++++++++++------- 7 files changed, 115 insertions(+), 24 deletions(-) create mode 100644 views/models_navigation_bottom.haml diff --git a/application.rb b/application.rb index c41f072..019592c 100644 --- a/application.rb +++ b/application.rb @@ -96,8 +96,22 @@ get '/models/?' do sort_by = params["sort_by"] if sort_by case sort_by - when "name", "created_at", "type" - @models = ToxCreateModel.all.sort_by(sort_by.to_sym, :order => "#{order} ALPHA") + when "created_at" + @models = ToxCreateModel.all.sort(:order => "#{order}") + when "name" + @models = ToxCreateModel.all.sort + if order == "ASC" + @models = @models.sort_by{|x| x.name.downcase} + else + @models = @models.sort{|x, y| y.name.downcase <=> x.name.downcase} + end + when "type", "endpoint" + @models = ToxCreateModel.all.sort + if order == "ASC" + @models = @models.sort_by{|x| [x.send(sort_by.to_sym),x.name.downcase]} + else + @models = @models.sort{|x,y|[y.send(sort_by.to_sym),x.name.downcase] <=> [x.send(sort_by.to_sym), y.name.downcase]} + end when "id" @models = ToxCreateModel.all.sort(:order => "#{order}") end @@ -186,8 +200,9 @@ get '/model/:id/:view/?' do end get '/predict/?' do - @models = ToxCreateModel.all.sort(:order => "DESC") + @models = ToxCreateModel.all.sort @models = @models.collect{|m| m if m.status == 'Completed'}.compact + @models = @models.sort_by{|x| [x.endpoint,x.name.downcase] } haml :predict end diff --git a/helper.rb b/helper.rb index f45e349..11f99f7 100644 --- a/helper.rb +++ b/helper.rb @@ -96,6 +96,11 @@ helpers do haml :models_navigation, :layout => false end + def models_navigation_bottom + @page = 0 unless @page + haml :models_navigation_bottom, :layout => false + end + def endpoint_option_list(max_time=3600) out = "" tmpfile = File.join(TMP_DIR, 'endpoint_option_list') diff --git a/views/models.haml b/views/models.haml index 1419e37..af11a32 100644 --- a/views/models.haml +++ b/views/models.haml @@ -26,3 +26,4 @@ = haml :model, :locals=>{:model=>model}, :layout => false -if @models.size == 0 .notice There are currently no models. You have to create a model first. += models_navigation_bottom if @models.size > 1 \ No newline at end of file diff --git a/views/models_navigation.haml b/views/models_navigation.haml index 0dc1f63..6bf05bd 100644 --- a/views/models_navigation.haml +++ b/views/models_navigation.haml @@ -1,12 +1,12 @@ .models_navigation - + - js = "" %form{:name => "nav", :action => url_for('/models'), :method => "get", :id => "nav"} %input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]} %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]} %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]} Sort by: - - ["created_at","name","type"].each do |s| + - ["created_at","name","type","endpoint"].each do |s| - idname = s == "created_at" ? "date" : s - if params[:sort_by] == s %div{:id => idname, :class => "active"} @@ -22,27 +22,37 @@ - if @models.size > 5 | Models: - = "#{@models.size}" - - unless @page.to_i == 0 - #prev - %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ - -else - %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ - - if @models.size < 5*@page+5 - last = @models.size - else - last = 5*@page+5 - = "(#{5*@page+1}-#{last}/#{@models.size})" + = "#{5*@page+1}-#{last} / #{@models.size}" + + | Page: + - unless @page.to_i == 0 + #prev{:class => "link"} + %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ + -else + %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ + + - (0..(@models.size/5).to_f.ceil-1).each do |p| + -if p != @page.to_f + %a{:href => '#', :id => "page_link_#{p}", :class => "page page_link"} #{p+1} + - js += "$('#page_link_#{p}').click(function() \{ \n " + - js += " $('#page').val('#{p}');\n " + - js += " $('#nav').submit();\n " + - js += "});\n " + -else + %span{:class => "page page_active"} #{p+1} + - unless 5*@page.to_i+5 >= @models.size - #next + #next{:class => "link"} %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/ -else %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ - - js = "" - - ["created_at","name","type"].each do |s| + - ["created_at","name","type","endpoint"].each do |s| - idname = s == "created_at" ? "date" : s - js += "$('##{idname}').click(function() \{ \n " - js += " $('#sort_by').val('#{s}');\n " diff --git a/views/models_navigation_bottom.haml b/views/models_navigation_bottom.haml new file mode 100644 index 0000000..abea2d4 --- /dev/null +++ b/views/models_navigation_bottom.haml @@ -0,0 +1,47 @@ +.models_navigation + - js = "" + %form{:name => "nav_bottom", :action => url_for('/models'), :method => "get", :id => "nav"} + %input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]} + %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]} + %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]} + + - if @models.size > 5 + Models: + - if @models.size < 5*@page+5 + - last = @models.size + - else + - last = 5*@page+5 + = "#{5*@page+1}-#{last} / #{@models.size}" + | Page: + - unless @page.to_i == 0 + #prevbot{:class => "link"} + %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ + -else + %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ + + - (0..(@models.size/5).to_f.ceil-1).each do |p| + -if p != @page.to_f + %a{:href => '#', :id => "page_linkbot_#{p}", :class => "page page_link"} #{p+1} + - js += "$('#page_linkbot_#{p}').click(function() \{ \n" + - js += " $('#page').val('#{p}');\n" + - js += " $('#nav').submit();\n" + - js += "});\n" + -else + %span{:class => "page page_active"} #{p+1} + + - unless 5*@page.to_i+5 >= @models.size + #nextbot{:class => "link"} + %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/ + -else + %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ + + :javascript + $("#prevbot").click(function() { + $("#page").val(#{@page-1}); + $("#nav").submit(); + }); + $("#nextbot").click(function() { + $("#page").val(#{@page+1}); + $("#nav").submit(); + }); + #{js} \ No newline at end of file diff --git a/views/predict.haml b/views/predict.haml index 670ca44..c6097ac 100644 --- a/views/predict.haml +++ b/views/predict.haml @@ -30,7 +30,12 @@ %legend Choose one or more prediction models %br + - endpoint = '' - @models.each do |model| + -if model.endpoint != endpoint + -endpoint = model.endpoint + %b #{endpoint}: + %br %input{:type => 'checkbox', :name => "selection[#{model.id}]", :value => true, :id => "model#{model.id}", :disabled => false} %label{:for => "model#{model.id}"} = model.name diff --git a/views/style.sass b/views/style.sass index 0c1f48c..c14f164 100644 --- a/views/style.sass +++ b/views/style.sass @@ -270,14 +270,7 @@ dl float: left .models_navigation - #prev - @extend a - display: inline - cursor: pointer - #next - @extend a - display: inline - cursor: pointer + margin-top: 4px .link @extend a display: inline @@ -288,6 +281,21 @@ dl font-weight: bold .thin font-weight: 100 + .page + border: solid 1px #999 + background-color: #FFF + padding: 0px 3px + font-size: 94% + foont-weight: normal + .page_link:hover + border-color: #000 + color: #000 + .page_active + background-color: #ccd2dc + color: #000 + font-weight: bold + border-right-color: #000 + border-bottom-color: #000 ul.endpoint list-style-type: none -- cgit v1.2.3 From 3740f8be9d43a874f87a1757857f55d3662f60ff Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 17 Oct 2011 12:30:21 +0200 Subject: change external links to js _blank | remove spaces --- public/javascripts/toxcreate.js | 50 +++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/public/javascripts/toxcreate.js b/public/javascripts/toxcreate.js index 0e82040..ef2a953 100755 --- a/public/javascripts/toxcreate.js +++ b/public/javascripts/toxcreate.js @@ -25,12 +25,12 @@ $(function() { $.each(stati, function(){ checkProgress(this); if(checkStatus(this) > 0) newstati.push(this); - }); + }); if (newstati.length > 0) var statusCheck = setTimeout('checkStati("' + newstati.join(", ") + '")',10000); }; - + checkStatus = function(id) { - if(id == "") return -1; + if(id == "") return -1; var opts = {method: 'get', action: 'model/' + id + '/status', id: id}; var status_changed = $.ajax({ type: opts.method, @@ -43,15 +43,15 @@ $(function() { success: function(data) { var status_before = ""; if ($("span#model_" + id + "_status") != null) status_before = $("span#model_" + id + "_status").html().trim(); - if (status_before == "Deleting") return -1; + if (status_before == "Deleting") return -1; var status_after = data.trim(); $("span#model_" + id + "_status").animate({"opacity": "0.2"},1000); $("span#model_" + id + "_status").animate({"opacity": "1"},1000); if( status_before != status_after) { - $("span#model_" + id + "_status").html(data); + $("span#model_" + id + "_status").html(data); loadModel(id, 'model'); if (status_after == "Completed" || status_after == "Error") id = -1; - } + } }, error: function(data) { //alert("status check error"); @@ -60,8 +60,8 @@ $(function() { }); return id; }; - - + + checkProgress = function(id) { var task = $("input#model_" + id + "_task").attr('value'); var opts = {action: task + "/percentageCompleted" , id: id}; @@ -74,9 +74,8 @@ $(function() { }, success: function(data) { var progress = data.trim(); - if (progress == "100") return -1; - - $("div#model_" + id + "_progress").progressbar("value", parseInt(progress)); + if (progress == "100") return -1; + $("div#model_" + id + "_progress").progressbar("value", parseInt(progress)); $("div#model_" + id + "_progress").attr({title: parseInt(progress) + "%"}); }, error: function(data) { @@ -84,10 +83,10 @@ $(function() { } }); return id; - }; + }; loadModel = function(id, view) { - if(id == "") return -1; + if(id == "") return -1; var opts = {method: 'get', action: 'model/' + id + '/' + view, view: view }; var out = id; $.ajax({ @@ -118,7 +117,7 @@ jQuery.fn.editModel = function(options) { trigger_on: 'click' }; var opts = $.extend(defaults, options); - this.bind(opts.trigger_on, function() { + this.bind(opts.trigger_on, function() { $.ajax({ type: opts.method, url: opts.action, @@ -126,7 +125,7 @@ jQuery.fn.editModel = function(options) { data: { '_method': 'get' }, - success: function(data) { + success: function(data) { $("div#model_" + opts.id + "_name").html(data); $("input#model_" + opts.id + "_name").focus(); }, @@ -145,8 +144,8 @@ jQuery.fn.cancelEdit = function(options) { trigger_on: 'click' }; var opts = $.extend(defaults, options); - - this.bind(opts.trigger_on, function() { + + this.bind(opts.trigger_on, function() { $.ajax({ type: opts.method, url: opts.action, @@ -154,7 +153,7 @@ jQuery.fn.cancelEdit = function(options) { data: { '_method': 'get' }, - success: function(data) { + success: function(data) { $("div#model_" + opts.id + "_name").html(data); }, error: function(data) { @@ -172,9 +171,9 @@ jQuery.fn.saveModel = function(options) { trigger_on: 'click' }; var opts = $.extend(defaults, options); - - this.bind(opts.trigger_on, function() { - var name = $("input#model_" + opts.id + "_name").val(); + + this.bind(opts.trigger_on, function() { + var name = $("input#model_" + opts.id + "_name").val(); $.ajax({ type: opts.method, url: opts.action, @@ -183,7 +182,7 @@ jQuery.fn.saveModel = function(options) { '_method': 'put', 'name': name }, - success: function(data) { + success: function(data) { $("div#model_" + opts.id + "_name").html(data); }, error: function(data) { @@ -215,7 +214,7 @@ jQuery.fn.deleteModel = function(type, options) { data: { '_method': 'delete' }, - success: function(data) { + success: function(data) { $("div#model_" + opts.id).fadeTo("slow",0).slideUp("slow").remove(); }, error: function(data) { @@ -236,9 +235,6 @@ addExternalLinks = function() { $('A[rel="external"]').each(function() { $(this).attr('alt', 'Link opens in new window.'); $(this).attr('title', 'Link opens in new window.'); - }); - $('A[rel="external"]').click(function() { - window.open($(this).attr('href')); - return false; + $(this).attr('target', '_blank'); }); }; -- cgit v1.2.3 From f60f559c98343b36ed50cfba1a365f2738f59a68 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 17 Oct 2011 12:32:27 +0200 Subject: clean code for navigation --- application.rb | 2 +- views/models_navigation.haml | 18 ++++----- views/models_navigation_bottom.haml | 77 +++++++++++++++++-------------------- views/style.sass | 2 +- 4 files changed, 47 insertions(+), 52 deletions(-) diff --git a/application.rb b/application.rb index 019592c..6cdfcfb 100644 --- a/application.rb +++ b/application.rb @@ -202,7 +202,7 @@ end get '/predict/?' do @models = ToxCreateModel.all.sort @models = @models.collect{|m| m if m.status == 'Completed'}.compact - @models = @models.sort_by{|x| [x.endpoint,x.name.downcase] } + @models = @models.sort_by{|x| [x.endpoint ? x.endpoint : "",x.name.downcase]} haml :predict end diff --git a/views/models_navigation.haml b/views/models_navigation.haml index 6bf05bd..c5eda97 100644 --- a/views/models_navigation.haml +++ b/views/models_navigation.haml @@ -26,7 +26,7 @@ - last = @models.size - else - last = 5*@page+5 - + = "#{5*@page+1}-#{last} / #{@models.size}" | Page: @@ -39,10 +39,10 @@ - (0..(@models.size/5).to_f.ceil-1).each do |p| -if p != @page.to_f %a{:href => '#', :id => "page_link_#{p}", :class => "page page_link"} #{p+1} - - js += "$('#page_link_#{p}').click(function() \{ \n " - - js += " $('#page').val('#{p}');\n " - - js += " $('#nav').submit();\n " - - js += "});\n " + - js += "$('#page_link_#{p}').click(function() \{ \n" + - js += " $('#page').val('#{p}');\n" + - js += " $('#nav').submit();\n" + - js += "});\n" -else %span{:class => "page page_active"} #{p+1} @@ -54,10 +54,10 @@ - ["created_at","name","type","endpoint"].each do |s| - idname = s == "created_at" ? "date" : s - - js += "$('##{idname}').click(function() \{ \n " - - js += " $('#sort_by').val('#{s}');\n " - - js += " $('#nav').submit();\n " - - js += "});\n " + - js += "$('##{idname}').click(function() \{ \n" + - js += " $('#sort_by').val('#{s}');\n" + - js += " $('#nav').submit();\n" + - js += "});\n" :javascript $("#prev").click(function() { diff --git a/views/models_navigation_bottom.haml b/views/models_navigation_bottom.haml index abea2d4..b2425fa 100644 --- a/views/models_navigation_bottom.haml +++ b/views/models_navigation_bottom.haml @@ -1,47 +1,42 @@ .models_navigation - js = "" - %form{:name => "nav_bottom", :action => url_for('/models'), :method => "get", :id => "nav"} - %input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]} - %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]} - %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]} + - if @models.size > 5 + Models: + - if @models.size < 5*@page+5 + - last = @models.size + - else + - last = 5*@page+5 + = "#{5*@page+1}-#{last} / #{@models.size}" + | Page: + - unless @page.to_i == 0 + #prevbot{:class => "link"} + %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ + -else + %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ - - if @models.size > 5 - Models: - - if @models.size < 5*@page+5 - - last = @models.size - - else - - last = 5*@page+5 - = "#{5*@page+1}-#{last} / #{@models.size}" - | Page: - - unless @page.to_i == 0 - #prevbot{:class => "link"} - %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/ + - (0..(@models.size/5).to_f.ceil-1).each do |p| + -if p != @page.to_f + %a{:href => '#', :id => "page_linkbot_#{p}", :class => "page page_link"} #{p+1} + - js += "$('#page_linkbot_#{p}').click(function() \{ \n" + - js += " $('#page').val('#{p}');\n" + - js += " $('#nav').submit();\n" + - js += "});\n" -else - %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/ + %span{:class => "page page_active"} #{p+1} - - (0..(@models.size/5).to_f.ceil-1).each do |p| - -if p != @page.to_f - %a{:href => '#', :id => "page_linkbot_#{p}", :class => "page page_link"} #{p+1} - - js += "$('#page_linkbot_#{p}').click(function() \{ \n" - - js += " $('#page').val('#{p}');\n" - - js += " $('#nav').submit();\n" - - js += "});\n" - -else - %span{:class => "page page_active"} #{p+1} + - unless 5*@page.to_i+5 >= @models.size + #nextbot{:class => "link"} + %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/ + -else + %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ - - unless 5*@page.to_i+5 >= @models.size - #nextbot{:class => "link"} - %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/ - -else - %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/ - - :javascript - $("#prevbot").click(function() { - $("#page").val(#{@page-1}); - $("#nav").submit(); - }); - $("#nextbot").click(function() { - $("#page").val(#{@page+1}); - $("#nav").submit(); - }); - #{js} \ No newline at end of file + :javascript + $("#prevbot").click(function() { + $("#page").val(#{@page-1}); + $("#nav").submit(); + }); + $("#nextbot").click(function() { + $("#page").val(#{@page+1}); + $("#nav").submit(); + }); + #{js} \ No newline at end of file diff --git a/views/style.sass b/views/style.sass index c14f164..f7fb7ac 100644 --- a/views/style.sass +++ b/views/style.sass @@ -286,7 +286,7 @@ dl background-color: #FFF padding: 0px 3px font-size: 94% - foont-weight: normal + font-weight: normal .page_link:hover border-color: #000 color: #000 -- cgit v1.2.3 From 922794101d336756313b90720a0c68ffdac7d53d Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 17 Oct 2011 12:37:04 +0200 Subject: pager style --- views/style.sass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/style.sass b/views/style.sass index f7fb7ac..230c13c 100644 --- a/views/style.sass +++ b/views/style.sass @@ -286,7 +286,7 @@ dl background-color: #FFF padding: 0px 3px font-size: 94% - font-weight: normal + font-weight: bold .page_link:hover border-color: #000 color: #000 -- cgit v1.2.3 From fc6d98de8462f8c7e3db3f15cd0ed85b70f51c5f Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 17 Oct 2011 15:36:07 +0200 Subject: rename endpoint subview --- views/create.haml | 2 +- views/create_echa.haml | 2 ++ views/model_echa.haml | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 views/create_echa.haml delete mode 100644 views/model_echa.haml diff --git a/views/create.haml b/views/create.haml index a26ae05..9b0ca09 100644 --- a/views/create.haml +++ b/views/create.haml @@ -52,7 +52,7 @@ format: %input{:type => 'file', :name => 'file', :id => 'file', :size => '41'} %br - = haml :model_echa, :layout => false + = haml :create_echa, :layout => false %br %input{ :type => "submit", :value => "Create model"} =# link_to "Cancel", '/create' diff --git a/views/create_echa.haml b/views/create_echa.haml new file mode 100644 index 0000000..4815c35 --- /dev/null +++ b/views/create_echa.haml @@ -0,0 +1,2 @@ +For endpoint: += endpoint_option_list() \ No newline at end of file diff --git a/views/model_echa.haml b/views/model_echa.haml deleted file mode 100644 index 4815c35..0000000 --- a/views/model_echa.haml +++ /dev/null @@ -1,2 +0,0 @@ -For endpoint: -= endpoint_option_list() \ No newline at end of file -- cgit v1.2.3 From bb75fafc60b6725b9dc80d974f9aba2dd6b521df Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 18 Oct 2011 11:22:58 +0200 Subject: fix measured actifity --- views/neighbors.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/neighbors.haml b/views/neighbors.haml index e2d65fa..49b72b7 100644 --- a/views/neighbors.haml +++ b/views/neighbors.haml @@ -14,7 +14,7 @@ - compound = OpenTox::Compound.new(neighbor[OT.compound]) %tr %td.image= compound_image(compound,@prediction.descriptors(compound),@value_map) - %td= activity_markup(neighbor[OT.measuredActivity], @value_map) + %td= activity_markup(neighbor[OT.measuredActivity].to_s, @value_map) %td= sprintf('%.03g', neighbor[OT.similarity]) %td %ul -- cgit v1.2.3 From f53928a35754c29f7ee912ed5f405731d451f49e Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 19 Oct 2011 12:11:28 +0200 Subject: add ChangeLog --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 ChangeLog diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..51762ea --- /dev/null +++ b/ChangeLog @@ -0,0 +1,6 @@ +v3.0.1 2011-10-19 + * assign a model to an endpoints on creating a new model, + endpoint-list from ontology service, + endpoint uri in "Training dataset" + * fix missing "measured activity" predicting a classification model + -- cgit v1.2.3