Changeset 1613

Show
Ignore:
Timestamp:
06/10/08 11:42:56 (7 months ago)
Author:
mbriggs
Message:

Notification of job results from interface requests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hive/trunk/data_webapp/app/controllers/hc_database_controller.rb

    r1608 r1613  
    4343    # Create a JobSource 
    4444    job_source = new_or_existing(JobSource,obj_hash.delete(:source).symbolize_keys) 
    45     job_source.save! 
    4645 
    4746    # Extract the set of URLs 
     
    5251    job = DroneJob.new(obj_hash.symbolize_keys) 
    5352    job.job_source = job_source 
    54     job.save! 
    5553 
    5654    # Create the QueueUrl objects 
     
    5856      insert_pending_url(:url => url, :priority => priority, :job => job) 
    5957    end 
    60  
    61     return job.id  
     58=begin 
     59    if job.pending_urls_count > 0 or job.completed_urls_count > 0 
     60      job_source.save! 
     61      job.save! 
     62    end 
     63=end 
     64    return job.id.nil? ? 0 : job.id 
    6265  end 
    6366 
    6467  def insert_pending_url(args) 
     68    return if args[:url].to_s.empty? 
    6569    PendingUrl.transaction do 
     70         
     71      url_obj = nil 
    6672      # There's a small chance that another process instance may have simultaneously inserted  
    6773      # the same URL into our queue.  In that case, we simply retry the insert operation until it succeeds. 
    68       url_obj = nil 
    6974      while true 
    7075        begin 
  • hive/trunk/data_webapp/app/controllers/queue_urls_controller.rb

    r1609 r1613  
    4848        :name => 'drone_interface', 
    4949      }, 
    50       :notify_source => (params[:notify])
     50      :notify_source => params[:notify]
    5151      :queue_urls => { 
    5252        params[:queue_url][:url] => params[:queue_url][:priority] 
     
    6262    job_id = c.insert_drone_job(job_hash) 
    6363    # Get the inserted job 
    64     job = DroneJob.find(job_id) 
     64    job = job_id > 0 ? DroneJob.find(job_id) : nil 
     65 
    6566    @queue_url = []  
    6667    if not job.nil? 
     
    7475        format.xml  { render :xml => @queue_url, :status => :created, :location => @queue_url } 
    7576      else 
    76         flash[:notice] = 'Failed to create QueueUrl .
     77        flash[:notice] = 'Failed to create a job for your request.<br>Perhaps an invalid url?
    7778        format.html { redirect_to :action => "new" } 
    7879        format.xml  { render :xml => @queue_url.errors, :status => :unprocessable_entity } 
  • hive/trunk/data_webapp/app/views/queue_urls/new.html.erb

    r1501 r1613  
    55          <%= f.text_field :url %> 
    66          <%= f.select "priority",{"high" => 500, "medium" => 100, "low" => 1}.sort{|a,b| a[1] <=> b[1]} %> 
    7           <%= f.submit "Create" %> 
     7          <%= f.submit "Create" %><br> 
     8          Notify? : <%= check_box_tag 'notify','false',false,{:onchange => "toggleEnabledById('address'); this.value = (this.value == 'true' ? 'false' : 'true')"} %> 
     9          Email Address : <%= text_field_tag 'address','',:disabled => true %> 
    810        <% end %> 
    911        <p/> 
  • hive/trunk/data_webapp/public/javascripts/application.js

    r1501 r1613  
    6969  } 
    7070} 
     71 
     72function toggleEnabledById(elt_id) { 
     73  if(elt = document.getElementById(elt_id)) { 
     74    if(elt.disabled == true) { 
     75      elt.disabled = false; 
     76    } 
     77    else { 
     78      elt.disabled = true; 
     79    } 
     80  } 
     81}