-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/versioning enhanced #1253
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f5f91ec
dont execute initializers on db create
VadimKeller 38114e2
Refactor ReactionDetails and SampleDetails
mschneider85 c63f1de
Add a change history /w logidze
mschneider85 971ce24
Add svg formatter and json
be07bbb
Enhance versioning + revert function
mschneider85 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,98 @@ | ||
require 'open-uri' | ||
|
||
module Chemotion | ||
class VersionAPI < Grape::API | ||
include Grape::Kaminari | ||
helpers ParamsHelpers | ||
|
||
namespace :versions do | ||
resource :samples do | ||
desc 'Return versions of the given sample' | ||
|
||
params do | ||
requires :id, type: Integer, desc: 'Sample id' | ||
end | ||
|
||
paginate per_page: 10, offset: 0, max_per_page: 100 | ||
|
||
route_param :id do | ||
get do | ||
sample = Sample.with_log_data.find(params[:id]) | ||
versions = Versioning::Fetcher.call(sample) | ||
|
||
{ versions: paginate(Kaminari.paginate_array(versions)) } | ||
end | ||
end | ||
end | ||
|
||
resource :reactions do | ||
desc 'Return versions of the given reaction' | ||
|
||
params do | ||
requires :id, type: Integer, desc: 'Reaction id' | ||
end | ||
|
||
paginate per_page: 10, offset: 0, max_per_page: 100 | ||
|
||
route_param :id do | ||
get do | ||
reaction = Reaction.with_log_data.find(params[:id]) | ||
versions = Versioning::Fetcher.call(reaction) | ||
|
||
{ versions: paginate(Kaminari.paginate_array(versions)) } | ||
end | ||
end | ||
end | ||
|
||
resource :research_plans do | ||
desc 'Return versions of the given research plan' | ||
|
||
params do | ||
requires :id, type: Integer, desc: 'Research plan id' | ||
end | ||
|
||
paginate per_page: 10, offset: 0, max_per_page: 100 | ||
|
||
route_param :id do | ||
get do | ||
research_plan = ResearchPlan.with_log_data.find(params[:id]) | ||
versions = Versioning::Fetcher.call(research_plan) | ||
|
||
{ versions: paginate(Kaminari.paginate_array(versions)) } | ||
end | ||
end | ||
end | ||
|
||
resource :screens do | ||
desc 'Return versions of the given screen' | ||
|
||
params do | ||
requires :id, type: Integer, desc: 'Screen id' | ||
end | ||
|
||
paginate per_page: 10, offset: 0, max_per_page: 100 | ||
|
||
route_param :id do | ||
get do | ||
screen = Screen.with_log_data.find(params[:id]) | ||
versions = Versioning::Fetcher.call(screen) | ||
|
||
{ versions: paginate(Kaminari.paginate_array(versions)) } | ||
end | ||
end | ||
end | ||
|
||
resource :revert do | ||
desc 'Revert selected changes' | ||
|
||
params do | ||
requires :changes, type: JSON, desc: 'Changes hash' | ||
end | ||
|
||
post do | ||
Versioning::Reverter.call(params[:changes]) | ||
end | ||
end | ||
end | ||
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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
# A helper to help logidize track current_user | ||
module LogidzeModule | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before do | ||
if current_user.present? && request.request_method.in?(%w[PATCH POST PUT DELETE]) | ||
@logidze_meta_set ||= begin | ||
Logidze.with_responsible!(current_user.id) | ||
true | ||
end | ||
end | ||
end | ||
|
||
after do | ||
Logidze.clear_responsible! if @logidze_meta_set.present? | ||
end | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/TrailingEmptyLines: Final newline missing. |
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,3 @@ | ||
.image-with-full-width { | ||
width: 100%; | ||
} |
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,126 @@ | ||
.history-legend { | ||
display: flex; | ||
justify-content: flex-end; | ||
list-style: none; | ||
padding: 0; | ||
margin: 2px 2px 10px 0; | ||
|
||
&__item { | ||
font-size: 10px; | ||
padding-left: .5em; | ||
|
||
&::before { | ||
content: "\f0c8"; | ||
font-family: FontAwesome; | ||
display: inline-block; | ||
padding: 0 0.2em; | ||
} | ||
|
||
&--old { | ||
&::before { | ||
color: #f2dede; | ||
} | ||
} | ||
|
||
&--new { | ||
&::before { | ||
color: #dff0d8; | ||
} | ||
} | ||
|
||
&--current { | ||
&::before { | ||
color: #f5f5f5; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.history-modal .modal-dialog { | ||
top: 0; | ||
transform: translate(-50%, 0) !important; | ||
} | ||
|
||
.history-alert { | ||
margin-bottom: 0; | ||
margin-top: 20px; | ||
} | ||
|
||
.history-checkbox-label { | ||
margin-bottom: 0; | ||
display: flex; | ||
gap: 5px; | ||
cursor: pointer; | ||
|
||
input { | ||
margin-top: 0 !important; | ||
} | ||
} | ||
|
||
.history-table { | ||
&__caret { | ||
transition: transform .1s ease-out; | ||
} | ||
|
||
&__row { | ||
cursor: pointer; | ||
|
||
&.active { | ||
.history-table__caret { | ||
transform: rotate(90deg); | ||
} | ||
} | ||
} | ||
|
||
&-breadcrumb { | ||
font-size: 13px; | ||
padding: 8px 15px; | ||
margin: 0; | ||
list-style: none; | ||
background-color: #f5f5f5; | ||
border-radius: 4px; | ||
|
||
&:not(:first-child) { | ||
margin-top: 10px; | ||
} | ||
|
||
&__element { | ||
display: inline-block; | ||
} | ||
|
||
&__element + &__element:before { | ||
padding: 0 5px; | ||
color: #ccc; | ||
content: "/ "; | ||
} | ||
} | ||
|
||
.bg-current { | ||
background-color: #f5f5f5; | ||
} | ||
|
||
.row-change { | ||
display: flex; | ||
flex-wrap: wrap; | ||
font-size: 10px; | ||
margin: 10px 0 0; | ||
word-break: break-all; | ||
|
||
& > [class*="col-"] { | ||
padding: 6px; | ||
} | ||
|
||
.ql-container { | ||
font-size: 10px; | ||
} | ||
|
||
.ql-editor { | ||
padding: 0; | ||
} | ||
|
||
.ql-tooltip.ql-hidden { | ||
height: 0; | ||
padding-top: 10px; | ||
} | ||
} | ||
} |
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
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 @@ | ||
class ContainerHierarchy < ApplicationRecord | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/FrozenStringLiteralComment: Missing frozen string literal comment. |
||
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 |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
# | ||
|
||
class ElementalComposition < ApplicationRecord | ||
has_logidze | ||
|
||
belongs_to :sample | ||
|
||
TYPES = { | ||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/FrozenStringLiteralComment: Missing frozen string literal comment.