mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-31 00:19:20 +08:00
added file upload popup modal, rails routes and controller functions, deleted old standalone model and controller
This commit is contained in:
parent
706031dacb
commit
b7432b336a
11 changed files with 97 additions and 30 deletions
2
app/assets/javascripts/temp_jsons.js
Normal file
2
app/assets/javascripts/temp_jsons.js
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
||||||
3
app/assets/stylesheets/temp_jsons.scss
Normal file
3
app/assets/stylesheets/temp_jsons.scss
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
// Place all the styles related to the temp_jsons controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||||
|
|
@ -337,7 +337,18 @@ a {
|
||||||
border-color: darken($color-theme-secondary, 10%);
|
border-color: darken($color-theme-secondary, 10%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.btn-link-alt {
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-right: 5px;
|
||||||
|
padding: 3px;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
.btn-invis-file{
|
||||||
|
opacity: 0;
|
||||||
|
position: absolute;
|
||||||
|
z-index: -1;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
.btn-open-file {
|
.btn-open-file {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
@ -1803,6 +1814,7 @@ textarea.textarea-sm {
|
||||||
-webkit-padding-before: 0;
|
-webkit-padding-before: 0;
|
||||||
-webkit-padding-after: 0;
|
-webkit-padding-after: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2008,12 +2020,7 @@ th.custom-field .modal-tooltiptext {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
}
|
}
|
||||||
.btn-link {
|
|
||||||
border-radius: 4px;
|
|
||||||
margin-right: 5px;
|
|
||||||
padding: 3px;
|
|
||||||
cursor:pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:last-child {
|
.btn:last-child {
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
|
|
|
||||||
|
|
@ -599,7 +599,23 @@ class ProtocolsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
#
|
||||||
|
#tule
|
||||||
|
def protocolsio_import_new
|
||||||
|
#@temp_json=JsonTemp.new
|
||||||
|
end
|
||||||
|
def protocolsio_import_create
|
||||||
|
|
||||||
|
|
||||||
|
json_file_contents=File.read(params[:json_file].path)
|
||||||
|
json_object=JSON.parse(json_file_contents)
|
||||||
|
byebug
|
||||||
|
end
|
||||||
|
|
||||||
|
def protocolsio_temp_params
|
||||||
|
params.require(:json_file)
|
||||||
|
end
|
||||||
|
#
|
||||||
def export
|
def export
|
||||||
# Make a zip output stream and send it to the client
|
# Make a zip output stream and send it to the client
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
||||||
2
app/helpers/temp_jsons_helper.rb
Normal file
2
app/helpers/temp_jsons_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
module TempJsonsHelper
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<div class="modal fade" id="modal-import-json-protocol" tabindex="-1" role="dialog" aria-labelledby="modal-import-json-protocol-label">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="modal-title"><%= t('protocols.index.modal_import_json_title') %></h4>
|
||||||
|
<%= t("protocols.index.modal_import_json_notice") %>
|
||||||
|
</div>
|
||||||
|
<%= form_tag({ action: "protocolsio_import_create"}, format: "json", multipart: true,remote: true,:method => "post", html: {'data-type' => 'json'}) do %>
|
||||||
|
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<%= file_field_tag 'json_file', accept: '.txt' %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal"><%= t('general.cancel')%></button>
|
||||||
|
<%= submit_tag t("protocols.index.modal_import_json_submit"), class: "btn btn-default" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
<%= render partial: "protocols/import_export/import_json_protocol_modal" %>
|
||||||
<% provide(:head_title, t("protocols.index.head_title")) %>
|
<% provide(:head_title, t("protocols.index.head_title")) %>
|
||||||
|
|
||||||
<% if current_team %>
|
<% if current_team %>
|
||||||
|
|
@ -48,9 +49,8 @@
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="import-export-protocols" class="btn-group" role="group">
|
||||||
<div id="import-export-protocols" class="btn-group" role="group">
|
<a class="btn btn-default btn-open-file" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"><span class="glyphicon glyphicon-import"></span><span class="hidden-xs"> <%= "Import protocol" %></span></a>
|
||||||
<a class="btn btn-default btn-open-file" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"><span class="glyphicon glyphicon-import"></span><span class="hidden-xs"> <%= "Import protocol" %></span></a>
|
|
||||||
|
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
|
|
@ -68,15 +68,14 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a class="btn-link btn-default-link btn-open-file" <%= can_import_protocols(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
|
|
||||||
<span class="glyphicon glyphicon-file"></span>
|
|
||||||
<span class="hidden-xs"><%= t("protocols.index.import_json") %></span>
|
|
||||||
<input type="file" value="" accept=".txt" data-role="import-json-file-input"
|
|
||||||
data-team-id="<%= @current_team.id %>"
|
|
||||||
data-type="<%= @type %>" data-import-url="<%= import_protocols_path %>"
|
|
||||||
<%= 'disabled="disabled"' unless can_import_protocols(@current_team) %>>
|
|
||||||
|
|
||||||
</a>
|
|
||||||
|
<%= link_to "#modal-import-json-protocol", "data-toggle" => "modal" do %>
|
||||||
|
<span class="glyphicon glyphicon-file"></span>
|
||||||
|
<span class="hidden-xs"><%= t("protocols.index.import_json") %></span>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -84,11 +83,7 @@
|
||||||
<span class="glyphicon glyphicon-export"></span>
|
<span class="glyphicon glyphicon-export"></span>
|
||||||
<span class="hidden-xs"> <%= t("protocols.index.export") %></span>
|
<span class="hidden-xs"> <%= t("protocols.index.export") %></span>
|
||||||
</a>
|
</a>
|
||||||
<!-- </div> -->
|
</div>
|
||||||
|
|
||||||
<!--<div class="btn-group"> -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<a class="btn btn-default" data-action="archive" data-url="<%= archive_protocols_path %>">
|
<a class="btn btn-default" data-action="archive" data-url="<%= archive_protocols_path %>">
|
||||||
|
|
|
||||||
|
|
@ -1445,6 +1445,9 @@ en:
|
||||||
import: "Import"
|
import: "Import"
|
||||||
import_alt: "from SciNote protocol file(.eln)"
|
import_alt: "from SciNote protocol file(.eln)"
|
||||||
import_json: "from protocols.io file(.txt)"
|
import_json: "from protocols.io file(.txt)"
|
||||||
|
modal_import_json_title: "Import protocols.io file"
|
||||||
|
modal_import_json_notice: "Upload your protocols.io .txt json protocol file"
|
||||||
|
modal_import_json_submit: "Upload file"
|
||||||
export: "Export"
|
export: "Export"
|
||||||
make_private: "Make private"
|
make_private: "Make private"
|
||||||
publish: "Publish"
|
publish: "Publish"
|
||||||
|
|
|
||||||
|
|
@ -398,6 +398,10 @@ Rails.application.routes.draw do
|
||||||
to: 'protocols#load_from_repository_modal'
|
to: 'protocols#load_from_repository_modal'
|
||||||
post 'load_from_repository', to: 'protocols#load_from_repository'
|
post 'load_from_repository', to: 'protocols#load_from_repository'
|
||||||
post 'load_from_file', to: 'protocols#load_from_file'
|
post 'load_from_file', to: 'protocols#load_from_file'
|
||||||
|
##
|
||||||
|
##-tule gre tvoje json_import match 'admin_login' => 'user#admin_login',
|
||||||
|
post 'protocolsio_import_create', to: 'protocols#protocolsio_import_create'
|
||||||
|
##
|
||||||
get 'copy_to_repository_modal', to: 'protocols#copy_to_repository_modal'
|
get 'copy_to_repository_modal', to: 'protocols#copy_to_repository_modal'
|
||||||
post 'copy_to_repository', to: 'protocols#copy_to_repository'
|
post 'copy_to_repository', to: 'protocols#copy_to_repository'
|
||||||
get 'protocol_status_bar', to: 'protocols#protocol_status_bar'
|
get 'protocol_status_bar', to: 'protocols#protocol_status_bar'
|
||||||
|
|
@ -406,6 +410,7 @@ Rails.application.routes.draw do
|
||||||
get 'edit_keywords_modal', to: 'protocols#edit_keywords_modal'
|
get 'edit_keywords_modal', to: 'protocols#edit_keywords_modal'
|
||||||
get 'edit_authors_modal', to: 'protocols#edit_authors_modal'
|
get 'edit_authors_modal', to: 'protocols#edit_authors_modal'
|
||||||
get 'edit_description_modal', to: 'protocols#edit_description_modal'
|
get 'edit_description_modal', to: 'protocols#edit_description_modal'
|
||||||
|
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get 'create_new_modal', to: 'protocols#create_new_modal'
|
get 'create_new_modal', to: 'protocols#create_new_modal'
|
||||||
|
|
@ -415,6 +420,10 @@ Rails.application.routes.draw do
|
||||||
post 'archive', to: 'protocols#archive'
|
post 'archive', to: 'protocols#archive'
|
||||||
post 'restore', to: 'protocols#restore'
|
post 'restore', to: 'protocols#restore'
|
||||||
post 'import', to: 'protocols#import'
|
post 'import', to: 'protocols#import'
|
||||||
|
##
|
||||||
|
##-tule gre tvoje json_import match 'admin_login' => 'user#admin_login',
|
||||||
|
post 'protocolsio_import_create', to: 'protocols#protocolsio_import_create'
|
||||||
|
##
|
||||||
get 'export', to: 'protocols#export'
|
get 'export', to: 'protocols#export'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -481,4 +490,5 @@ Rails.application.routes.draw do
|
||||||
get 'wopi/files/:id', to: 'wopi#file_get_endpoint', as: 'wopi_rest_endpoint'
|
get 'wopi/files/:id', to: 'wopi#file_get_endpoint', as: 'wopi_rest_endpoint'
|
||||||
post 'wopi/files/:id', to: 'wopi#post_file_endpoint'
|
post 'wopi/files/:id', to: 'wopi#post_file_endpoint'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
13
db/schema.rb
13
db/schema.rb
|
|
@ -11,7 +11,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: 20170515141252) do
|
ActiveRecord::Schema.define(version: 20170619125051) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
@ -413,7 +413,6 @@ ActiveRecord::Schema.define(version: 20170515141252) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "repository_rows", ["name"], name: "index_repository_rows_on_name", using: :btree
|
|
||||||
add_index "repository_rows", ["repository_id"], name: "index_repository_rows_on_repository_id", using: :btree
|
add_index "repository_rows", ["repository_id"], name: "index_repository_rows_on_repository_id", using: :btree
|
||||||
|
|
||||||
create_table "repository_table_states", force: :cascade do |t|
|
create_table "repository_table_states", force: :cascade do |t|
|
||||||
|
|
@ -544,11 +543,11 @@ ActiveRecord::Schema.define(version: 20170515141252) do
|
||||||
add_index "samples", ["user_id"], name: "index_samples_on_user_id", using: :btree
|
add_index "samples", ["user_id"], name: "index_samples_on_user_id", using: :btree
|
||||||
|
|
||||||
create_table "samples_tables", force: :cascade do |t|
|
create_table "samples_tables", force: :cascade do |t|
|
||||||
t.jsonb "status", default: {"time"=>0, "order"=>[[2, "desc"]], "start"=>0, "length"=>10, "search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "columns"=>[{"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}], "ColReorder"=>[0, 1, 2, 3, 4, 5, 6]}, null: false
|
t.jsonb "status", default: {"time"=>0, "order"=>[[2, "desc"]], "start"=>0, "length"=>10, "search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "columns"=>[{"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}, {"search"=>{"regex"=>false, "smart"=>true, "search"=>"", "caseInsensitive"=>true}, "visible"=>true}], "assigned"=>"all", "ColReorder"=>[0, 1, 2, 3, 4, 5, 6]}, null: false
|
||||||
t.integer "user_id", null: false
|
t.integer "user_id", null: false
|
||||||
t.integer "team_id", null: false
|
t.integer "team_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "samples_tables", ["team_id"], name: "index_samples_tables_on_team_id", using: :btree
|
add_index "samples_tables", ["team_id"], name: "index_samples_tables_on_team_id", using: :btree
|
||||||
|
|
|
||||||
7
test/controllers/temp_jsons_controller_test.rb
Normal file
7
test/controllers/temp_jsons_controller_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class TempJsonsControllerTest < ActionController::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
Loading…
Add table
Reference in a new issue