Skip to content

Commit

Permalink
Don't show db_type for imported resources
Browse files Browse the repository at this point in the history
- Hopefully workaround const_missing error with Models, need to revisit
- Decrease Scheduler job time
  • Loading branch information
Jeremy Stephens committed May 24, 2011
1 parent 92ff452 commit ee0baaa
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 581 deletions.
4 changes: 4 additions & 0 deletions lib/coupler/base.rb
Expand Up @@ -50,6 +50,10 @@ class Base < Sinatra::Base
})
enable :sessions

configure do
Models.load_all
end

use Rack::Flash
register Extensions::Connections
register Extensions::Projects
Expand Down
8 changes: 8 additions & 0 deletions lib/coupler/helpers.rb
Expand Up @@ -117,5 +117,13 @@ def local_ip
def cycle(even, odd)
(@_cycle = !@_cycle) ? even : odd
end

def field_type(resource, field)
result = field.final_type
if !resource.import_id
result += " (#{field.final_db_type})"
end
result
end
end
end
8 changes: 8 additions & 0 deletions lib/coupler/models.rb
Expand Up @@ -12,6 +12,14 @@ module Models
:Transformation, :Scenario, :Matcher, :Job, :Result, :Comparison,
:Import
]

def self.load_all
Database.instance
NAMES.each do |name|
require File.dirname(__FILE__) + "/models/#{name.to_s.downcase}"
end
end

def self.const_missing(name)
name = name.to_sym
if NAMES.include?(name)
Expand Down
2 changes: 1 addition & 1 deletion lib/coupler/runner.rb
Expand Up @@ -51,7 +51,7 @@ def initialize(argv = ARGV, options = {}, &block)

if success
Coupler::Base.set(:running, true)
say "Web server is up and running on http://#{settings.bind}:#{settings.port}"
puts "Web server is up and running on http://#{settings.bind}:#{settings.port}"
if !options.has_key?(:trap) || options[:trap]
trap("INT") do
shutdown
Expand Down
2 changes: 1 addition & 1 deletion lib/coupler/scheduler.rb
Expand Up @@ -37,7 +37,7 @@ def start
if !is_started?
@loop = Thread.new do
loop do
sleep 30
sleep 10
run_jobs
end
end
Expand Down
704 changes: 130 additions & 574 deletions webroot/public/js/jquery.dataTables.min.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions webroot/views/resources/list.erb
Expand Up @@ -6,14 +6,13 @@
<tr>
<th>Name</th>
<% unless @hide_connection %><th>Connection</th><% end %>
<th>Database</th>
<th>Table</th>
</tr>
</thead>
<tbody>
<% @resources.each_with_index do |resource, i| %>
<tr<%= ' class="alt"' if i % 2 == 1 %>>
<td><a href="/projects/<%= @project.id %>/resources/<%= resource.id %>"><%= resource.name %></a></td>
<td><a href="/projects/<%= resource.project_id %>/resources/<%= resource.id %>"><%= resource.name %></a></td>
<%- if resource.import_id -%>
<td colspan="3" class='centered'>(imported)</td>
<%- else -%>
Expand Down
7 changes: 5 additions & 2 deletions webroot/views/resources/show.erb
Expand Up @@ -13,7 +13,7 @@
<%- @fields.each do |field| -%>
<tr>
<td<%= ' class="altered-field"' if field.is_generated %>><%= field.name %></td>
<td<%= ' class="altered-field"' if field.local_db_type %>><%= field.final_db_type %></td>
<td<%= ' class="altered-field"' if field.local_type %>><%= field_type(@resource, field) %></td>
</tr>
<%- end -%>
</tbody>
Expand Down Expand Up @@ -66,7 +66,10 @@
<script type="text/javascript">
var intervalId;
$(function() {
$('#fields').dataTable({bJQueryUI: true, aaSorting: [], aoColumns: [null, null] });
$('#fields').dataTable({
bJQueryUI: true, aaSorting: [],
bAutoWidth: false, aoColumns: [{sWidth: "50%"}, {sWidth: "50%"}]
});
<%- if @job && @job.status == 'running' -%>
$('#progressbar').progressbar({value: <%= @job.percent_completed %>});
setInterval(function() {
Expand Down
2 changes: 1 addition & 1 deletion webroot/views/transformations/new.erb
Expand Up @@ -27,7 +27,7 @@
</tr>
<tr id="field-info" class="hidden">
<td class="col1">Current Type:</td>
<td><span id='field-type'></span> (<span id='field-db-type'></span>)</td>
<td><span id='field-type'></span><%= " (<span id='field-db-type'></span>)" if !@resource.import_id %></td>
</tr>
</table>
</div>
Expand Down

0 comments on commit ee0baaa

Please sign in to comment.