Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
Fixes to sync with heroku/add_recorders
Browse files Browse the repository at this point in the history
  • Loading branch information
shakeelanjum committed Oct 14, 2014
1 parent 3990c45 commit 9cfae0f
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 166 deletions.
Binary file added app/assets/images/icons/recorder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/javascripts/application.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $ ->

$(".features span").on 'click', ->
feature_id = $(this).attr("id").replace('_icon', '')
$("##{feature_id}").trigger "click"
$("#{feature_id}").trigger "click"
$(this).toggleClass "selected"

$(".features input[type=checkbox]").each ->
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/pages_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module PagesHelper
def link_to_model_url(name = model.model, model)
link_to(name, "/#{model.vendor.vendor_slug}/#{model.model_slug}")
link_to(name, "/#{model.vendor.vendor_slug}/models/#{model.model_slug}")
end
end
1 change: 1 addition & 0 deletions app/models/vendor.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Vendor < ActiveRecord::Base
has_one :image, as: :owner
has_many :recorders
has_many :models
before_create :make_slug
has_paper_trail
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<% if user_signed_in? %>
<%= render 'shared/add_model_modal' %>
<%= render 'shared/add_vendor_modal' %>
<%= render 'shared/add_recorder_modal' %>
<% else %>
<%= render 'shared/signin_modal' %>
<% end %>
Expand Down
136 changes: 8 additions & 128 deletions app/views/models/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<% content_for :title do %>
<%= "#{@model.vendor.name} #{@model.model}" %>
<%= "#{@model.vendor.name} #{@model.model}" %>
<% end %>

<div class="camera-heading clearfix">
<h1><%= "#{@model.vendor.name} #{@model.model}" %></h1>
<% if @model.prev %>
<%= link_to "prev", vendor_model_path(@model.prev.vendor.vendor_slug, @model.prev.model_slug), class: 'align-left' %>
<%= link_to "prev", "/#{model.prev.vendor.name.downcase}/models/#{model.prev.model_slug}", class: 'align-left' %>
<% end %>
<% if @model.next %>
<%= link_to "next", vendor_model_path(@model.next.vendor.vendor_slug, @model.next.model_slug), class: 'align-left' %>
<%= link_to "next", "/#{model.next.vendor.name.downcase}/models/#{model.next.model_slug}", class: 'align-left' %>
<% end %>
<%= link_to "json", "/api/v1/models/#{@model.model_slug}", class: 'align-right' %>
<%= link_to "url", '', class: 'align-right' %>
Expand Down Expand Up @@ -56,11 +56,13 @@
<% end %>
<div class="module module-table module-manufacturer">
<div class="module-header">
<h4 class="">Manufacturer Information</h4>
<h4 class="">Vendor Information</h4>
</div>
<div class="module-body">
<% if @camera.manufacturer.image %>
<%= link_to(image_tag(@camera.manufacturer.image.file.url(:medium)), "/#{@camera.manufacturer.manufacturer_slug}", :class => '') %>
<% if @model.vendor.image %>
<%= link_to(image_tag(@model.vendor.image.file.url(:medium)), "/#{@model.vendor.vendor_slug}", :class => '') %>
<% else %>
<%= link_to('Add Logo', '', :class => 'add-new-image add-logo') %>
<% end %>
<div class="table-responsive">
<table class="table table-striped">
Expand Down Expand Up @@ -104,122 +106,6 @@
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<<<<<<< .mine
<tr class="clickable">
<td class="col-sm-3">Manufacturer</td>
<td class="col-sm-9 manufacturer-website">
<% #= editable @camera, :manufacturer_id, source: Manufacturer.all.map{ |manufacturer| {value: manufacturer.id, text: manufacturer.name}}, type: :select, tag: :a, href: "/#{@camera.manufacturer.manufacturer_slug}" %>
<%= link_to @camera.manufacturer.name, "/#{@camera.manufacturer.manufacturer_slug}" %>
<%= link_to('Website', @camera.manufacturer.url, target: "_blank", class: 'icon-link') %>
</td>
</tr>
<tr>
<td>Model</td>
<td><%= @camera.model || 'Unknown' %></td>
</tr>
<tr>
<td>Resolution</td>
<td><%= @camera.resolution || 'Unknown' %></td>
</tr>
<tr class="shapes">
<td>Shape</td>
<td><%= @camera.shape || 'Unknown' %></td>
</tr>
<tr>
<td>JPEG URL</td>
<td><%= @camera.jpeg_url || 'Unknown' %></td>
</tr>
<tr>
<td>H264 URL</td>
<td>
<% if @camera.h264_url=="<blank>"%>
None
<% else %>
<%= @camera.h264_url || 'Unknown' %>
<% end %>
</td>
</tr>
<tr>
<td>MJPEG URL</td>
<td><%= @camera.mjpeg_url || 'Unknown' %></td>
</tr>
<tr>
<td>Default Username</td>
<td><%= @camera.default_username || 'Unknown' %></td>
</tr>
<tr>
<td>Default Password</td>
<td><%= @camera.default_password || 'Unknown' %></td>
</tr>
<tr>
<td>Official Page</td>
<td>
<% if @camera.official_url %>
<%= link_to @camera.official_url, @camera.official_url, target: '_blank' %>
<% else %>
Unknown
<% end %>
</td>
</tr>
=======
<% if user_signed_in? %>
<tr class="clickable">
<td class="col-sm-3">Vendor</td>
Expand Down Expand Up @@ -334,7 +220,6 @@
<td></td>
</tr>
<% end %>
>>>>>>> .theirs
</tbody>
</table>
</div>
Expand Down Expand Up @@ -384,13 +269,8 @@
<tbody>
<tr>
<td class="col-sm-3">ONVIF</td>
<<<<<<< .mine
<%= editable @camera, :onvif, tag: :td, class: "col-sm-9" %>
=======
<%= editable @model, :onvif, tag: :td %>
<td></td>
>>>>>>> .theirs
</tr>
<tr>
<td>PSIA</td>
Expand Down
14 changes: 14 additions & 0 deletions app/views/pages/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
</div>
</div>
<% end %>
<% elsif image.owner_type == "Recorder" %>
<% if image.position == 1 %>
<div class="tile tile-big col-sm-4">
<div class="tile-content">
<%= link_to(image_tag(@images[index].file.url, :title => "#{owner.recorder}"), "/#{owner.vendor.vendor_slug}/#{owner.recorder_slug}") %>
</div>
</div>
<% else %>
<div class="tile tile-small col-sm-2">
<div class="tile-content">
<%= link_to(image_tag(@images[index].file.url, :title => "#{owner.recorder}"), "/#{owner.vendor.vendor_slug}/#{owner.recorder_slug}") %>
</div>
</div>
<% end %>
<% else %>
<div class="tile tile-big col-sm-4">
<div class="tile-content">
Expand Down
3 changes: 1 addition & 2 deletions app/views/shared/_filters.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
<div>
<span>
<label>
<!-- Uncomment this line and fix the issue -->
<% #= f.check_box combine_features, :id => 'any', checked: true %>
<%= f.check_box combine_features, :id => 'any', checked: true %>
Any
</label>
</span>
Expand Down
30 changes: 7 additions & 23 deletions app/views/shared/_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
<div class="front-header navbar navbar-top">
<div class="container">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<h1>Cambase</h1>
</a>
<ul class="nav navbar-nav navbar-left">
<li><%= link_to('Models', models_path) %></li>
<li><%= link_to('Vendors', vendors_path) %></li>
<li><%= link_to('API', api_docs_path) %></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<% if user_signed_in? %>
<li class="dropdown">
<a href="#" class="dropdown-toggle username" data-toggle="dropdown">
<%= image_tag(avatar_url(current_user)) %>
<%= current_user.username %>
<b class="caret"></b>
<div class="navbar">
<div class="navbar-inner">
<a class="navbar-brand" href="/">
<%= image_tag(asset_url('logo.jpg')) %>
</a>

<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
Expand All @@ -32,8 +15,9 @@

<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-left">
<li><%= link_to('Cameras', cameras_path) %></li>
<li><%= link_to('Manufacturers', manufacturers_path) %></li>
<li><%= link_to('Models', models_path) %></li>
<li><%= link_to('Vendors', vendors_path) %></li>
<li><%= link_to('Recorders', recorders_path) %></li>
<li><%= link_to('API', api_docs_path) %></li>
</ul>
<ul class="nav navbar-nav navbar-right">
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_models.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Model Listing
<td>
<%= link_to_model_url(model.model, model) %>
</td>
<td class="manufacturer-name"><%= link_to model.vendor.name, "/#{model.vendor.vendor_slug}" %></td>
<td class="manufacturer-name"><%= link_to model.vendor.name, "/#{model.vendor.vendor_slug}/models" %></td>
<td><%= model.resolution %></td>
<td>
<% if Model::SHAPES.include? model.shape.downcase %>
Expand Down
7 changes: 5 additions & 2 deletions app/views/shared/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
<p>We encourage individuals and vendors to contribute more information to Cambase.io as a resource for future developers.</p>
<p>This data is licensed under creative commons and is freely available for both private and commercial use.</p>
<p class="sidebar-stats icon-cameras">
<%= pluralize(Model.all.length, 'Model') %>
<%= link_to pluralize(Model.all.length, 'Model'), models_path %>
</p>
<p class="sidebar-stats icon-recorders">
<%= link_to pluralize(Recorder.all.length, 'Recorder'), recorders_path %>
</p>
<p class="sidebar-stats icon-manufacturers">
<%= pluralize(Vendor.all.length, 'Vendor') %>
<%= link_to pluralize(Vendor.all.length, 'Vendor'), vendors_path %>
</p>
<p class="sidebar-stats icon-images">
<%= pluralize(Image.where(owner_type: "Model").length, 'Image') %>
Expand Down
8 changes: 5 additions & 3 deletions app/views/vendors/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
<tr>
<th>Vendor</th>
<th>Logo</th>
<th>#</th>
<th>Models</th>
<th>Recorders</th>
</tr>
</thead>

<tbody>
<% @vendors.each do |vendor| %>
<tr>
<td><%= link_to vendor.name, "/#{vendor.vendor_slug}" %></td>
<td><%= vendor.name %></td>
<td><%= image_tag(vendor.image.file.url(:small)) if vendor.image %></td>
<td><%= vendor.models.size %></td>
<td><%= link_to vendor.models.size, "#{vendor.vendor_slug.downcase}/models" %></td>
<td><%= link_to vendor.recorders.size, "#{vendor.vendor_slug.downcase}/recorders" %></td>
</tr>
<% end %>
</tbody>
Expand Down
16 changes: 12 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@
end
end

resources :vendors, :only => [:index, :update, :create]

resources :vendors, :except => [:new], :path => '' do
resources :models, :path => '', :except => [:index, :new]
resources :recorders, :only => [:index, :update] do
collection do
match 'search' => 'recorders#search', via: [:get, :post], as: :search
end
end

resources :vendors, :only => [:index, :update, :create]
resources :recorders, :path => ':vendor_slug/recorders/'
resources :models, :path => ':vendor_slug/models/'

#resources :vendors, :except => [:new], :path => '' do
# resources :models, :path => ':vendor_id/models/', :except => [:index, :new]
#end

end
5 changes: 5 additions & 0 deletions db/migrate/20140929150902_rename_recoder_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RenameRecoderType < ActiveRecord::Migration
def self.up
rename_column :recorders, :type, :recorder_type
end
end
Loading

0 comments on commit 9cfae0f

Please sign in to comment.