Changeset 180

Show
Ignore:
Timestamp:
02-04-12 18:28:00 (2 years ago)
Author:
kostas.karasavvas@…
Message:

use rack config (config.ru) for port and timeout, impr. tooltips, app inherits from Sinatra::Base

Location:
t2-web/trunk
Files:
1 added
8 modified

Legend:

Unmodified
Added
Removed
  • t2-web/trunk/bin/t2_webapp.rb

    r179 r180  
    22 
    33require 'rubygems' if RUBY_VERSION < '1.9' 
    4 require 'sinatra' 
     4require 'sinatra/base' 
    55require 'haml' 
    66require 'open-uri' 
     
    1919  # TODO: const for TMP_UPLOAD_PATH ? - need to read from config file? 
    2020 
    21   set :port, 9494 
     21  #set :port, 9494     set from: rackup -p 9494 
    2222  set :views, File.dirname(__FILE__) + '/../views' 
    2323  set :public_folder, File.dirname(__FILE__) + '/../public' 
     
    7373 
    7474     
    75     # Generates the contents of the header frame 
     75    # Generates the contents of the header frame table 
    7676    def generate_header_table(my_exp_wkf, my_exp_usr) 
    7777      <<END 
     
    102102 
    103103 
    104     # Generates tooltip html text for descriptions 
    105     def generate_label_tooltip(input) 
    106       "Description: " << CGI::unescapeHTML(input.descriptions[0]) 
    107     end 
    108  
     104    # Generates tooltip html text with type prefix 
     105    def generate_tooltip(type, input) 
     106      if type =~ /description/i 
     107        type << CGI::unescapeHTML(input.descriptions[0]) 
     108      else 
     109        type << CGI::unescapeHTML(input.examples[0]) 
     110      end 
     111    end 
     112 
     113    # TODO: remove 02/04/2012 
    109114    # Generates tooltip html text for textarea example 
    110     def generate_textarea_tooltip(input) 
    111       "Example: " << CGI::unescapeHTML(input.examples[0]) 
    112     end 
     115    #def generate_textarea_tooltip(input) 
     116    #  "Example: " << CGI::unescapeHTML(input.examples[0]) 
     117    #end 
    113118 
    114119 
     
    147152      #p list 
    148153      if list.instance_of? Array 
    149         data = list.flatten.join("\n") 
     154        # flatten (sub-)list and remove nils and if present, newlines 
     155        # then join list as a multi-line string 
     156        data = list.flatten.compact.map {|e| e.chomp}.join("\n") 
    150157      else 
    151         data = list 
     158        data = list.chomp 
    152159      end 
    153160 
     
    160167    # TODO: make proper rdoc 
    161168    def copy_to_tmp(subdir, filename, out) 
    162  
    163       FileUtils.mkdir("/tmp/#{WEB_APP_NAME}") unless File.exist?("/tmp/#{WEB_APP_NAME}") 
    164       FileUtils.mkdir("/tmp/#{WEB_APP_NAME}/#{subdir}") unless File.exist?("/tmp/#{WEB_APP_NAME}/#{subdir}") 
     169      FileUtils.mkdir_p("/tmp/#{WEB_APP_NAME}/#{subdir}") unless File.exist?("/tmp/#{WEB_APP_NAME}/#{subdir}") 
    165170      tmp_file = File.open("/tmp/#{WEB_APP_NAME}/#{subdir}/#{filename}", "w") 
    166171      FileUtils.copy_stream(out, tmp_file) 
     
    285290        data_lists = run.get_output("#{t2_output}.error", false) 
    286291      end 
     292 
     293      # flatten the results  
    287294      data_stream = flatten_list_results(data_lists) 
    288295 
     296      # copy results to tmp 
    289297      copy_to_tmp("outputs/#{@run_uuid}", t2_output, data_stream) 
    290298    end 
     
    321329  end 
    322330 
     331  # start the server if ruby file executed directly 
     332  run! if app_file == $0 
    323333end 
    324334 
    325335 
    326336# Start Web App 
    327 WebT2App.run! 
     337# $ rackup -p 9494 
  • t2-web/trunk/CHANGES

    r179 r180  
    33== Version 0.1.0 
    44* Results are downloaded directly and stored in tmp files - progress cycle works once 
     5* Added rackup configuration file: config.ru 
     6* webapp is run using rackup now to enable configuration of web server timeout 
     7* Increased tooltip size and anchored them to the 'west' 
     8* Port is set via: rackup -p 9494 
    59 
    610== Version 0.0.9 
  • t2-web/trunk/public/css/form.css

    r177 r180  
    2020  border-bottom: 4px solid #909090; 
    2121  border-top: 4px solid #909090; 
     22  text-align: center; 
    2223} 
    2324 
  • t2-web/trunk/public/css/tipsy.css

    r177 r180  
    11.tipsy { padding: 5px; font-size: 13px; opacity: 0.8; filter: alpha(opacity=80); background-repeat: no-repeat;  background-image: url(../images/tipsy.gif); } 
    2   .tipsy-inner { padding: 5px 8px 4px 8px; background-color: #161616; color: white; max-width: 240px; text-align: left; } 
     2  .tipsy-inner { padding: 5px 8px 4px 8px; background-color: #161616; color: white; max-width: 300px; text-align: left; } 
    33  .tipsy-inner { -moz-border-radius:3px; -webkit-border-radius:3px; } 
    44  .tipsy-north { background-position: top center; } 
  • t2-web/trunk/public/scripts/form.js

    r178 r180  
    4242  $('#workflow-form').append("<input name='" + input + "-file' type='hidden' value='" + filename +"' />"); 
    4343 
    44  
    45   //var file = files[0]; 
    46  
    47   // create form to send to server-side upload handler 
    48   //var formdata = new FormData(); 
    49  
    50   // include file to form 
    51   //formdata.append("file", file); 
    52  
    53  
    5444  // get the form from the document (jQuery selector wasn't working inside function!) 
    5545  var formdata = new FormData(document.getElementById(input + '-upload-form')); 
    56  
    57   //$.ajax({ 
    58   //  type: "POST", 
    59   //  url: "http://" + document.location.host + "/t2web/upload", 
    6046 
    6147  var xhr = new XMLHttpRequest(); 
     
    6652  }, false); 
    6753  if ( xhr.upload ) { 
    68       console.log("AAAAAAAAAAAAAAAA"); 
    6954      xhr.upload.onprogress = function(e) { 
    7055          var done = e.position || e.loaded, total = e.totalSize || e.total; 
     
    8065  xhr.open('post', "http://" + document.location.host + "/t2web/upload", false); 
    8166  xhr.send(formdata); 
    82    
    83  
    84  
    85   // submit the form to upload the file 
    86   // we would like to do that via XHR to include client-side progress bar! 
    87   //$('#' + input + '-upload-form').submit(); 
    88  
    8967} 
    9068 
    9169// initilises certain html elements to employ tipsy for their tooltips 
    9270function initialiseTipsys() { 
    93   $('[name$="-input"]').tipsy({gravity: 'e', fade: true, html: true, fallback: "No available example"}); 
    94   $('[for$="-label"]').tipsy({gravity: 'e', fade: true, html: true, fallback: "No available description"}); 
    95   //$('[name$="-input"]').tooltip(); 
    96  
     71  $('[name$="-input"]').tipsy({gravity: 'w', fade: true, html: true, fallback: "No available example"}); 
     72  $('[for$="-label"]').tipsy({gravity: 'w', fade: true, html: true, fallback: "No available description"}); 
    9773} 
    9874 
  • t2-web/trunk/public/scripts/results.js

    r179 r180  
    3030 
    3131  // ajax request to confirm finished execution 
    32   $.get(httpcall, function (result) { 
    33     if (result == 'Finished') { 
     32  //$.get(httpcall, function (result) { 
     33  //  if (result == 'Finished') { 
    3434 
    35       //console.log("yeah??"); 
    36       // prepare get outputs call (to local ruby, cross-domain ajax call) 
     35      // TODO: that probably causes the browser status to show that it's still working!! 
     36  //    clearInterval(runStatusIntervalId); 
     37 
     38  //    getOutputs(t2_server, uuid); 
     39      //getOutputs("http://test.mybiobank.org/taverna-server", "f3dca934-a6d7-44e3-acc3-f8c1f30e0973"); 
     40  //  } 
     41  //}); 
     42 
     43  $.ajax({ 
     44            type: "GET", 
     45            url: httpcall, 
     46            success: function (result) { 
     47              if (result == 'Finished') { 
     48                clearInterval(runStatusIntervalId); 
     49                getOutputs(t2_server, uuid); 
     50              } 
     51            } 
     52          }); 
     53} 
     54 
     55function getOutputs(t2_server, uuid) { 
     56     // prepare get outputs call (to local ruby, cross-domain ajax call) 
    3757      var httpoutputs = "http://" + document.location.host + "/t2web/run/" + uuid + "/outputs" + 
    3858                        "?server=" + t2_server; 
     59      console.log("in new function!!!!"); 
    3960 
    4061      // ajax request to get outputs 
    41       $.get(httpoutputs, function (reply) { 
    42         if (reply == 'Successful download!') { 
    43           window.frames['data-navigation'].document.documentElement.innerHTML = results_navigation; 
    44         } 
    45       }); 
     62      //$.get(httpoutputs, function (reply) { 
     63      //  if (reply == 'Successful download!') { 
     64      //    window.frames['data-navigation'].document.documentElement.innerHTML = results_navigation; 
     65      //  } 
     66      //}); 
    4667 
    47       // TODO: that probably causes the browser status to show that it's still working!! 
    48       clearInterval(runStatusIntervalId); 
    49     } 
    50   }); 
     68      $.ajax({ 
     69                type: "GET", 
     70                url: httpoutputs, 
     71                success: function(reply) { 
     72                  if (reply == 'Successful download!') { 
     73                    window.frames['data-navigation'].document.documentElement.innerHTML = results_navigation; 
     74                  } 
     75                }//, 
     76                //error: function(reply) { 
     77                //    window.frames['data-navigation'].document.documentElement.innerHTML = results_navigation; 
     78                //} 
     79              }); 
    5180 
    5281} 
    53  
  • t2-web/trunk/views/form.haml

    r178 r180  
    3939      - if @my_exp_wkf.inputs.size >=1 
    4040        - @my_exp_wkf.inputs.each do |input| 
    41           -# TODO: make helper create_input_tooltip(input) to return proper tooltip html string!!! 
    4241          - if input.descriptions.size >=1 
    43             - input_label_tooltip = generate_label_tooltip(input) 
     42            - input_label_tooltip = generate_tooltip("Description: ", input) 
    4443          - input_textarea_tooltip = "" 
    4544          - if input.examples.size >=1 
    46             - input_textarea_tooltip = generate_textarea_tooltip(input) 
     45            - input_textarea_tooltip = generate_tooltip("Example: ", input) 
    4746          %div{:id => "#{input.name}-upload-form-div"} 
    4847            -#%form{:id => "#{input.name}-upload-form", :enctype => "multipart/form-data", :target => "hidden-iframe", :action => "/t2web/upload", :method => "post"} 
     
    121120          %td.inputs 
    122121            For more information on this workflow please visit the 
    123             %a{ :href => "http://www.myExperiment.org/workflows/#{@wid}" } myExperiment website 
     122            %a{ :href => "http://www.myExperiment.org/workflows/#{@wid}", :target => "_blank" } myExperiment website 
    124123        -# if #{@my_exp_wkf.user.email} 
    125124          %tr 
  • t2-web/trunk/views/results.haml

    r177 r180  
    1515          window.frames['data-navigation'].document.write("#{generate_data_navigation_frame(@my_exp_wkf, @run_uuid, @wid, @wkf_version, @t2_server, false)}"); 
    1616          runStatusIntervalId = window.setInterval( "checkRunStatus('#{@t2_server}', '#{@run_uuid}')", 5000); 
     17          //checkRunStatus("#{@t2_server}", "#{@run_uuid}"); 
    1718        }); 
    1819    %script{:type => "text/javascript", :src => "/scripts/results.js"}