-
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
feat: data versioning #2068
Open
PiTrem
wants to merge
22
commits into
main
Choose a base branch
from
versioning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,556
−187
Open
feat: data versioning #2068
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0fa81fc
Add a change history /w logidze
mschneider85 1741ea7
Add svg formatter and json
59c3820
Enhance versioning + revert function
mschneider85 e176e2a
refactor: various files
109768a
refactored Form and removed css
78db23e
feat: Added Version Table to Sample as All Versions Tab
b447648
added author to all_versions
369f0f5
feat: versions tab syncs with properties - reloads on click
e199277
feat: added fields to sample serializer
cab0fc9
feat: added versioning to reactions
df6106e
feat: added versions to research_plan
4440258
feat: added versions to screen
1c3d0a6
fix: mistakes from rebase
48541ad
feat: added setState after revert to screens and research_plans
b83d32f
feat: added wellplate to versioning
f2d7bf2
feat: added wells to versioning
13f2dd2
review findings: reverted some refactorings & specified alert text
67f153a
reverted refactoring in sample.rb
e7b55dd
refactor: changed BootstrapTable to AgGridReact
ac70bcb
fix: rebase on bootstrap update
161d0f4
sample detail rebase fix
ab6c437
added tests for version_api
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# frozen_string_literal: true | ||
|
||
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 :wellplates do | ||
desc 'Return versions of the given wellplate' | ||
|
||
params do | ||
requires :id, type: Integer, desc: 'Wellplate id' | ||
end | ||
|
||
paginate per_page: 10, offset: 0, max_per_page: 100 | ||
|
||
route_param :id do | ||
get do | ||
wellplate = Wellplate.with_log_data.find(params[:id]) | ||
versions = Versioning::Fetcher.call(wellplate) | ||
{ 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 |
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
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. Why do we need this stub? |
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
Oops, something went wrong.
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.