| @@ -19,3 +19,5 @@ | |||||
| # Ignore Byebug command history file. | # Ignore Byebug command history file. | ||||
| .byebug_history | .byebug_history | ||||
| /public/system/* | |||||
| @@ -13,3 +13,22 @@ | |||||
| *= require_tree . | *= require_tree . | ||||
| *= require_self | *= require_self | ||||
| */ | */ | ||||
| #columns { | |||||
| display: flex; | |||||
| #main { | |||||
| padding: 1em; | |||||
| flex: 1; | |||||
| } | |||||
| #side { | |||||
| padding: 1em 2em; | |||||
| } | |||||
| } | |||||
| @media all and (max-width: 800px) { | |||||
| #columns { | |||||
| flex-direction: column-reverse; | |||||
| } | |||||
| } | |||||
| @@ -26,6 +26,11 @@ class DocumentsController < ApplicationController | |||||
| def create | def create | ||||
| @document = Document.new(document_params) | @document = Document.new(document_params) | ||||
| @document.name = @document.doc_file_name | |||||
| if Document.exists?(doc_fingerprint: @document.doc_fingerprint) | |||||
| end | |||||
| respond_to do |format| | respond_to do |format| | ||||
| if @document.save | if @document.save | ||||
| format.html { redirect_to @document, notice: 'Document was successfully created.' } | format.html { redirect_to @document, notice: 'Document was successfully created.' } | ||||
| @@ -69,6 +74,6 @@ class DocumentsController < ApplicationController | |||||
| # Never trust parameters from the scary internet, only allow the white list through. | # Never trust parameters from the scary internet, only allow the white list through. | ||||
| def document_params | def document_params | ||||
| params.require(:document).permit(:name, :doc) | |||||
| params.require(:document).permit(:doc) | |||||
| end | end | ||||
| end | end | ||||
| @@ -1,4 +1,4 @@ | |||||
| class Document < ApplicationRecord | class Document < ApplicationRecord | ||||
| has_attached_file :doc | |||||
| has_attached_file :doc, adapter_options: { hash_digest: Digest::SHA256 } | |||||
| validates_attachment_content_type :doc, content_type: 'application/pdf' | validates_attachment_content_type :doc, content_type: 'application/pdf' | ||||
| end | end | ||||
| @@ -12,11 +12,6 @@ | |||||
| <% end %> | <% end %> | ||||
| <div class="field"> | <div class="field"> | ||||
| <%= f.label :name %> | |||||
| <%= f.text_field :name %> | |||||
| </div> | |||||
| <div class="field"> | |||||
| <%= f.label :doc %> | <%= f.label :doc %> | ||||
| <%= f.file_field :doc %> | <%= f.file_field :doc %> | ||||
| </div> | </div> | ||||
| @@ -8,8 +8,8 @@ | |||||
| <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> | ||||
| </head> | </head> | ||||
| <body> | |||||
| <div id="columsn"> | |||||
| <body class="<%= controller.controller_name %>"> | |||||
| <div id="columns"> | |||||
| <div id="side"> | <div id="side"> | ||||
| <% if session[:user_id] %> | <% if session[:user_id] %> | ||||
| <%= button_to 'Logout', logout_path, method: :delete %> | <%= button_to 'Logout', logout_path, method: :delete %> | ||||
| @@ -0,0 +1,6 @@ | |||||
| class AddFingerprintToDocumentDoc < ActiveRecord::Migration[5.0] | |||||
| def change | |||||
| add_column :documents, :doc_fingerprint, :string | |||||
| add_index :documents, :doc_fingerprint | |||||
| end | |||||
| end | |||||
| @@ -10,7 +10,7 @@ | |||||
| # | # | ||||
| # It's strongly recommended that you check this file into your version control system. | # It's strongly recommended that you check this file into your version control system. | ||||
| ActiveRecord::Schema.define(version: 20161124131141) do | |||||
| ActiveRecord::Schema.define(version: 20161124142626) do | |||||
| create_table "documents", force: :cascade do |t| | create_table "documents", force: :cascade do |t| | ||||
| t.string "name" | t.string "name" | ||||
| @@ -20,6 +20,8 @@ ActiveRecord::Schema.define(version: 20161124131141) do | |||||
| t.string "doc_content_type" | t.string "doc_content_type" | ||||
| t.integer "doc_file_size" | t.integer "doc_file_size" | ||||
| t.datetime "doc_updated_at" | t.datetime "doc_updated_at" | ||||
| t.string "doc_fingerprint" | |||||
| t.index ["doc_fingerprint"], name: "index_documents_on_doc_fingerprint" | |||||
| end | end | ||||
| create_table "users", force: :cascade do |t| | create_table "users", force: :cascade do |t| | ||||
| @@ -1,57 +0,0 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <p1:MDIBContainer xmlns:p1="http://domain-model-uri/15/04" xmlns:p2="http://extension-point-uri/15/03" xmlns:m="http://message-model-uri/15/04" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" p1:MDIBVersion="1"> | |||||
| <p1:MDDescription> | |||||
| <p1:MDS xsi:type="p1:HydraMDSDescriptor" Handle="my_med_device_handle"> | |||||
| <p1:Type> | |||||
| <p1:CodeId>CODE_ID</p1:CodeId> | |||||
| <p1:ConceptDescription>My device description text.</p1:ConceptDescription> | |||||
| </p1:Type> | |||||
| <p1:MetaData> | |||||
| <p1:UDI>uuid-123</p1:UDI> | |||||
| <p1:Manufacturer>MyManufacturer</p1:Manufacturer> | |||||
| <p1:ModelName>MyModelname</p1:ModelName> | |||||
| <p1:ModelNumber>MyModelnumber123</p1:ModelNumber> | |||||
| <p1:SerialNumber>MySN123</p1:SerialNumber> | |||||
| </p1:MetaData> | |||||
| <p1:Context Handle="context"/> | |||||
| <p1:SCO Handle="sco"> | |||||
| <p1:Operation xsi:type="p1:SetStringOperationDescriptor" Handle="my_set_method_name" OperationTarget="my_metric_handle"> | |||||
| <p1:Type> | |||||
| <p1:CodeId>CODE_ID_SETM</p1:CodeId> | |||||
| <p1:ConceptDescription>My set method.</p1:ConceptDescription> | |||||
| </p1:Type> | |||||
| </p1:Operation> | |||||
| </p1:SCO> | |||||
| <p1:VMD Handle="my_vmd_handle"> | |||||
| <p1:Type> | |||||
| <p1:CodeId>CODE_ID_VMD</p1:CodeId> | |||||
| <p1:ConceptDescription>My vmd descrtiption.</p1:ConceptDescription> | |||||
| </p1:Type> | |||||
| <p1:Channel Handle="my_channel_handle"> | |||||
| <p1:Type> | |||||
| <p1:CodeId>CODE_ID_CHAN</p1:CodeId> | |||||
| <p1:ConceptDescription>My channel description.</p1:ConceptDescription> | |||||
| </p1:Type> | |||||
| <p1:Metric xsi:type="p1:StringMetricDescriptor" Handle="my_metric_handle"> | |||||
| <p2:Extension> | |||||
| <m:Retrievability> | |||||
| <m:By>Get</m:By> | |||||
| </m:Retrievability> | |||||
| </p2:Extension> | |||||
| <p1:Type> | |||||
| <p1:CodeId>CODE_ID_METRIC</p1:CodeId> | |||||
| <p1:ConceptDescription>My metric description.</p1:ConceptDescription> | |||||
| </p1:Type> | |||||
| <p1:Unit> | |||||
| <p1:CodeId>MDC_DIM_DIMLESS</p1:CodeId> | |||||
| <p1:ConceptDescription>No description for this unit code id.</p1:ConceptDescription> | |||||
| </p1:Unit> | |||||
| <p1:MetricCategory>Unspec</p1:MetricCategory> | |||||
| <p1:Availability>Intr</p1:Availability> | |||||
| </p1:Metric> | |||||
| </p1:Channel> | |||||
| </p1:VMD> | |||||
| </p1:MDS> | |||||
| </p1:MDDescription> | |||||
| <p1:MDState/> | |||||
| </p1:MDIBContainer> | |||||