This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Recorder fixes" (Resolved all conflicts manually)
This reverts commit afef9bb82597a276a90575cfcdea2b49226bbadb. Conflicts: .env app/assets/javascripts/application.coffee app/assets/stylesheets/application.css.scss app/assets/stylesheets/base.css.scss.erb app/assets/stylesheets/camera_index.css.scss app/assets/stylesheets/camera_show.css.scss.erb app/assets/stylesheets/header.css.scss app/assets/stylesheets/model_index.css.scss app/controllers/api/v1/models_controller.rb app/controllers/api/v1/recorders_controller.rb app/controllers/models_controller.rb app/controllers/recorders_controller.rb app/helpers/application_helper.rb app/helpers/pages_helper.rb app/helpers/recorders_helper.rb app/models/recorder.rb app/models/vendor.rb app/views/api/v1/recorders/_recorder.json.jbuilder app/views/api/v1/recorders/index.json.jbuilder app/views/api/v1/recorders/show.json.jbuilder app/views/layouts/application.html.erb app/views/models/show.html.erb app/views/pages/index.html.erb app/views/recorders/_form.html.erb app/views/recorders/edit.html.erb app/views/recorders/index.html.erb app/views/recorders/new.html.erb app/views/recorders/search.html.erb app/views/recorders/show.html.erb app/views/shared/_add_recorder_modal.erb app/views/shared/_filters.html.erb app/views/shared/_header.html.erb app/views/shared/_models.html.erb app/views/shared/_recorders.html.erb app/views/shared/_sidebar.html.erb app/views/vendors/index.html.erb config/routes.rb db/migrate/20140924124928_create_recorder.rb lib/assets/javascripts/swagger/lib/backbone-min.js lib/assets/javascripts/swagger/lib/handlebars-1.0.0.js lib/assets/javascripts/swagger/lib/highlight.7.3.pack.js lib/assets/javascripts/swagger/lib/jquery.ba-bbq.min.js lib/assets/javascripts/swagger/lib/jquery.slideto.min.js lib/assets/javascripts/swagger/lib/jquery.wiggle.min.js lib/assets/javascripts/swagger/lib/shred.bundle.js lib/assets/javascripts/swagger/lib/shred/content.js lib/assets/javascripts/swagger/lib/swagger-oauth.js lib/assets/javascripts/swagger/lib/swagger-ui.js lib/assets/javascripts/swagger/lib/swagger.js lib/assets/javascripts/swagger/lib/underscore-min.js lib/assets/javascripts/swagger/swagger-ui.js lib/tasks/alter_data.rake
- Loading branch information
1 parent
c158063
commit 3990c45
Showing
33 changed files
with
17,897 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ | |
|
||
# IDE | ||
.idea | ||
/*.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
.table-list{ | ||
border: 4px solid $grayborder; | ||
margin-bottom: 0; | ||
border-collapse: inherit; | ||
thead, tbody{ | ||
tr{ | ||
min-width: 100%; | ||
max-width: 100%; | ||
th, td{ | ||
border-right: 4px solid $grayborder; | ||
background-color: #fff; | ||
&:last-child{ | ||
border-right: none; | ||
} | ||
} | ||
th{ | ||
border-top: 4px solid $grayborder; | ||
border-bottom: 4px solid $grayborder; | ||
a{ | ||
font-size: 14px; | ||
color: $darkgreen; | ||
} | ||
} | ||
th.shape{ | ||
text-align: center; | ||
} | ||
th.rotate { | ||
height: 95px; | ||
width: 31px; | ||
white-space: nowrap; | ||
font-style: normal; | ||
border-left: none; | ||
border-right: none; | ||
} | ||
|
||
th.rotate > div { | ||
transform: translate(-7px, 13px) rotate(-45deg); | ||
width: 0px; | ||
} | ||
th.rotate > div > span { | ||
padding: 5px 9px; | ||
} | ||
td{ | ||
border-top: none; | ||
border-bottom: none; | ||
vertical-align: middle; | ||
&.feature{ | ||
text-align: center; | ||
border-width: 1px; | ||
padding: 0; | ||
.dot{ | ||
display: inline-block; | ||
background: $mediumgreen; | ||
width: 10px; | ||
height: 10px; | ||
border-radius: 15px; | ||
} | ||
} | ||
&:first-child{ | ||
a{ | ||
display: block; | ||
line-height: 3.5; | ||
} | ||
} | ||
img{ | ||
max-height: 50px; | ||
} | ||
} | ||
} | ||
} | ||
&.table-models{ | ||
tr td:nth-child(4){ | ||
text-align: center; | ||
width: 80px; | ||
} | ||
} | ||
&.table-vendors{ | ||
td{ | ||
height: 50px; | ||
} | ||
tr td:nth-child(3), | ||
tr th:nth-child(3){ | ||
text-align: center; | ||
width: 42px; | ||
} | ||
} | ||
} | ||
|
||
.pagination{ | ||
margin-top: 0; | ||
padding: 8px; | ||
width: 100%; | ||
border: 4px solid $grayborder; | ||
border-top: none; | ||
background: #fff; | ||
span{ | ||
&.current{ | ||
font-weight: bold; | ||
} | ||
padding: 4px; | ||
background: $offwhite; | ||
&:first-child{ | ||
padding-left: 8px; | ||
} | ||
&:last-child{ | ||
padding-right: 8px; | ||
} | ||
a{ | ||
color: $darkgreen; | ||
} | ||
} | ||
} | ||
|
||
.fullsize-image{ | ||
position: absolute; | ||
z-index: 10; | ||
border: 4px solid #eaeaea; | ||
&.hidden { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
class Api::V1::RecordersController < ApplicationController | ||
skip_before_filter :verify_authenticity_token | ||
|
||
swagger_controller :recorders, "Recorders Management" | ||
|
||
swagger_api :index do | ||
summary "Fetches all Recorders" | ||
param :query, :page, :integer, :optional, "Page number" | ||
param_list :query, :order, :string, :optional, "Sort order", ['created_at DESC', 'created_at ASC', 'updated_at DESC', 'updated_at ASC'] | ||
response :unauthorized | ||
response :not_acceptable, "The request you made is not acceptable" | ||
response :requested_range_not_satisfiable | ||
end | ||
|
||
swagger_api :show do | ||
summary "Fetches a single Recorder" | ||
param :path, :id, :integer, :required, "Recorder ID" | ||
response :unauthorized | ||
response :not_acceptable | ||
response :not_found | ||
end | ||
|
||
swagger_api :create do | ||
summary "Creates a new Recorder" | ||
param :form, :vendor_id, :string, :required, "Vendor ID" | ||
param :form, 'recorder[model]', :string, :required, "Recorder" | ||
param_list :form, 'recorder[shape]', :string, :optional, "Shape", Recorder.uniq.pluck(:resolution).compact.sort | ||
param_list :form, 'recorder[resolution]', :string, :optional, "Resolution", Recorder.uniq.pluck(:resolution).compact.sort | ||
param_list :form, 'recorder[onvif]', :string, :optional, "ONVIF", [true, false] | ||
param_list :form, 'recorder[psia]', :string, :optional, "PSIA", [true, false] | ||
param_list :form, 'recorder[ptz]', :string, :optional, "PTZ", [true, false] | ||
param_list :form, 'recorder[infrared]', :string, :optional, "Infrared", [true, false] | ||
param_list :form, 'recorder[varifocal]', :string, :optional, "Varifocal", [true, false] | ||
param_list :form, 'recorder[sd_card]', :string, :optional, "SD Card", [true, false] | ||
param_list :form, 'recorder[upnp]', :string, :optional, "UPnP", [true, false] | ||
param_list :form, 'recorder[audio_in]', :string, :optional, "UPnP", [true, false] | ||
param_list :form, 'recorder[audio_out]', :string, :optional, "UPnP", [true, false] | ||
param :form, 'recorder[default_username]', :string, :optional, "Default Username" | ||
param :form, 'recorder[default_password]', :string, :optional, "Default Password" | ||
param :form, 'recorder[jpeg_url]', :string, :optional, "JPEG URL" | ||
param :form, 'recorder[h264_url]', :string, :optional, "H264 URL" | ||
param :form, 'recorder[mjpeg_url]', :string, :optional, "MJPEG URL" | ||
response :unauthorized | ||
response :not_acceptable | ||
end | ||
|
||
swagger_api :update do | ||
summary "Updates an existing Recorder" | ||
param :path, :id, :string, :required, "Recorder ID" | ||
param :form, :vendor_id, :string, :required, "Vendor ID" | ||
param :form, 'recorder[name]', :string, :optional, "Recorder" | ||
param_list :form, 'recorder[shape]', :string, :optional, "Shape", Recorder.uniq.pluck(:resolution).compact.sort | ||
param_list :form, 'recorder[resolution]', :string, :optional, "Resolution", Recorder.uniq.pluck(:resolution).compact.sort | ||
param_list :form, 'recorder[onvif]', :string, :optional, "ONVIF", [true, false] | ||
param_list :form, 'recorder[psia]', :string, :optional, "PSIA", [true, false] | ||
param_list :form, 'recorder[ptz]', :string, :optional, "PTZ", [true, false] | ||
param_list :form, 'recorder[infrared]', :string, :optional, "Infrared", [true, false] | ||
param_list :form, 'recorder[varifocal]', :string, :optional, "Varifocal", [true, false] | ||
param_list :form, 'recorder[sd_card]', :string, :optional, "SD Card", [true, false] | ||
param_list :form, 'recorder[upnp]', :string, :optional, "UPnP", [true, false] | ||
param_list :form, 'recorder[audio_in]', :string, :optional, "Audio In", [true, false] | ||
param_list :form, 'recorder[audio_out]', :string, :optional, "Audio Out", [true, false] | ||
param :form, 'recorder[default_username]', :string, :optional, "Default Username" | ||
param :form, 'recorder[default_password]', :string, :optional, "Default Password" | ||
param :form, 'recorder[jpeg_url]', :string, :optional, "JPEG URL" | ||
param :form, 'recorder[h264_url]', :string, :optional, "H264 URL" | ||
param :form, 'recorder[mjpeg_url]', :string, :optional, "MJPEG URL" | ||
response :unauthorized | ||
response :not_found | ||
response :not_acceptable | ||
end | ||
|
||
swagger_api :search do | ||
summary "Searches all Recorders" | ||
param :query, :page, :integer, :optional, "Page number" | ||
param :query, 'q[recorder_cont]', :string, :optional, "Recorder" | ||
param :query, 'q[vendor_name_cont]', :string, :optional, "Vendor" | ||
param_list :query, 'q[shape_eq]', :string, :optional, "Shape", Recorder.uniq.pluck(:resolution).compact.sort | ||
param_list :query, 'q[resolution_eq]', :string, :optional, "Resolution", Recorder.uniq.pluck(:resolution).compact.sort | ||
param_list :query, 'q[onvif_true]', :string, :optional, "ONVIF", [true, false] | ||
param_list :query, 'q[psia_true]', :string, :optional, "PSIA", [true, false] | ||
param_list :query, 'q[ptz_true]', :string, :optional, "PTZ", [true, false] | ||
param_list :query, 'q[infrared_true]', :string, :optional, "Infrared", [true, false] | ||
param_list :query, 'q[varifocal_true]', :string, :optional, "Varifocal", [true, false] | ||
param_list :query, 'q[sd_card_true]', :string, :optional, "SD Card", [true, false] | ||
param_list :query, 'q[upnp_true]', :string, :optional, "UPnP", [true, false] | ||
param_list :query, 'q[audio_in_true]', :string, :optional, "Audio In", [true, false] | ||
param_list :query, 'q[audio_out_true]', :string, :optional, "Audio Out", [true, false] | ||
response :unauthorized | ||
response :not_acceptable, "The request you made is not acceptable" | ||
response :requested_range_not_satisfiable | ||
end | ||
|
||
def index | ||
valid_sort = ['created_at DESC', 'created_at ASC', 'updated_at DESC', 'updated_at ASC'] | ||
order = valid_sort.include?(params[:order]) ? params[:order] : 'created_at DESC' | ||
@recorders = Recorder.order(order).page params[:page] | ||
end | ||
|
||
def show | ||
@recorder = Recorder.find_by_recorder_slug(params[:id]) | ||
end | ||
|
||
def search | ||
@search = Recorder.search(params[:q]) | ||
@recorders = @search.result.page params[:page] | ||
render :index | ||
end | ||
|
||
def create | ||
params[:recorder][:vendor_id] = Vendor.find_by_vendor_slug(params[:vendor_id].to_url).id | ||
@recorder = Recorder.new(recorder_params) | ||
if @recorder.save | ||
render :show, status: :created | ||
else | ||
render json: @recorder.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def update | ||
params[:vendor_id] = Vendor.find_by_vendor_slug(params[:vendor_id].to_url).id | ||
@recorder = Recorder.find_by_recorder_slug(params[:id]) | ||
if @recorder.update(recorder_params) | ||
render :show, status: :created | ||
else | ||
render json: @recorder.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def recorder_params | ||
params.require(:recorder).permit! | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
class RecordersController < ApplicationController | ||
before_action :set_recorder, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /recorders | ||
# GET /recorders.json | ||
def index | ||
if params[:q].blank? | ||
@search = Recorder.search() | ||
@recorders = Recorder.page params[:page] | ||
|
||
unless params[:vendor_slug].blank? | ||
@vendor = Vendor.find_by_vendor_slug(params[:vendor_slug]) | ||
@recorders = @recorders.where(:vendor_id => @vendor.id) | ||
end | ||
else | ||
@search = Recorder.search(params[:q]) | ||
@recorders = @search.result.page params[:page] | ||
end | ||
|
||
respond_to do |format| | ||
format.html | ||
format.json { render :json => @recorders, :except => [:created_at, :updated_at] } | ||
end | ||
end | ||
|
||
def search | ||
index | ||
# render :index | ||
end | ||
|
||
# GET /recorders/1 | ||
# GET /recorders/1.json | ||
def show | ||
unless params[:vendor_slug].blank? | ||
@vendor = Vendor.find_by_vendor_slug(params[:vendor_slug]) | ||
@recorder = Recorder.where(:recorder_slug => params[:id]).where(:vendor_id => @vendor.id).first | ||
end | ||
respond_to do |format| | ||
format.html | ||
format.json { | ||
render :json => | ||
@recorder | ||
} | ||
end | ||
end | ||
|
||
# GET /recorders/new | ||
def new | ||
@recorder = Recorder.new | ||
end | ||
|
||
# GET /recorders/1/edit | ||
def edit | ||
end | ||
|
||
# POST /recorders | ||
# POST /recorders.json | ||
def create | ||
@recorder = Recorder.new(recorder_params) | ||
respond_to do |format| | ||
if @recorder.save | ||
format.html { | ||
redirect_to vendor_recorder_path(@recorder.vendor.vendor_slug, @recorder.recorder_slug), | ||
notice: 'Recorder was successfully created.' | ||
} | ||
format.json { render :show, status: :created, location: @recorder } | ||
else | ||
format.html { redirect_to recorders_path, notice: @recorder.errors.full_messages.to_sentence } | ||
format.json { render json: @recorder.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /recorders/1 | ||
# PATCH/PUT /recorders/1.json | ||
def update | ||
@recorder = Recorder.find(params[:id]) | ||
if params[:model][:images_attributes] | ||
@recorder.images.build(:file => params['model']['images_attributes']['0'][:file]).save | ||
params['model']['images_attributes'] = nil | ||
end | ||
respond_to do |format| | ||
if @recorder.update(recorder_params) | ||
format.html { | ||
redirect_to vendor_recorder_path(@recorder.vendor.vendor_slug, @recorder.recorder_slug), | ||
notice: 'Recorder was successfully updated.' | ||
} | ||
format.json { render json: @recorder } | ||
else | ||
format.html { redirect_to recorders_path, notice: @recorder.errors.full_messages.to_sentence } | ||
format.json { render json: @recorder.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /recorders/1 | ||
# DELETE /recorders/1.json | ||
def destroy | ||
@recorder.destroy | ||
respond_to do |format| | ||
format.html { redirect_to recorders_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_recorder | ||
@recorder = Recorder.find_by_recorder_slug(params[:id]) | ||
end | ||
|
||
def rollback_to_previous_version | ||
@recorder.versions.last.reify.save! | ||
flash[:notice] = "Your changes will be reflected once an admin has reviewed them" | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def recorder_params | ||
params.require(:recorder).permit!.except(:id, :created_at, :updated_at) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module RecordersHelper | ||
end |
Oops, something went wrong.