From 6a6646f68beeb7afb802f4c3e49e8b6b0ae6d3f4 Mon Sep 17 00:00:00 2001 From: Michael Basmanov Date: Fri, 10 Nov 2023 14:59:56 +0300 Subject: [PATCH] fix: supprot xrd .xy and libs .spec files --- app/models/spectrum.rb | 6 +++++- app/views/samples/edit.html.erb | 2 +- app/views/samples/new.html.erb | 2 +- app/views/spectra/edit.html.erb | 2 +- app/views/spectra/new.html.erb | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/models/spectrum.rb b/app/models/spectrum.rb index 6a756659..c92f0029 100644 --- a/app/models/spectrum.rb +++ b/app/models/spectrum.rb @@ -69,7 +69,7 @@ class Spectrum < RsdbRecord enum range: { not_set: 0, vis: 1, ir: 2, uv: 3, other: 4 }, _default: :not_set - enum format: { not_set: 0, csv: 1, imp: 2, spectable: 3, mon: 4, txt: 5, dat: 6, dpt: 7, other: 99 }, _default: :not_set, _suffix: :format + enum format: { not_set: 0, csv: 1, imp: 2, spectable: 3, mon: 4, txt: 5, dat: 6, dpt: 7, xy: 8, spec: 9, other: 99 }, _default: :not_set, _suffix: :format enum category: { not_set: 0, xrf: 1, xrd: 2, ftir: 3, libs: 4, raman: 5, thz: 6, reflectance: 7, other: 99 }, _default: :not_set, _suffix: :type @@ -139,12 +139,16 @@ def infer_category else other_type! end + when 'spec' + libs_type! when 'mon' if valid_header?(file, :reflectance) reflectance_type! else other_type! end + when 'xy' + xrd_type! when 'txt' if valid_header?(file, :raman) raman_type! diff --git a/app/views/samples/edit.html.erb b/app/views/samples/edit.html.erb index 36339051..3dbf0708 100644 --- a/app/views/samples/edit.html.erb +++ b/app/views/samples/edit.html.erb @@ -96,7 +96,7 @@ controller: "uploads", uploads_target: "div", uploads_filetype_value: "files", - uploads_allowedfiletypes_value: [".dpt", "text/*", ".raw", ".mon", ".csv", ".spectable", ".txt", ".dat"], + uploads_allowedfiletypes_value: [".dpt", "text/*", ".raw", ".mon", ".csv", ".spectable", ".txt", ".dat", ".xy", ".spec"], uploads_allowmultiplefiles_value: true, uploads_generatethumbnails_value: current_user.settings(:uploading).thumbnails } do %> diff --git a/app/views/samples/new.html.erb b/app/views/samples/new.html.erb index f6763aab..c17de33e 100644 --- a/app/views/samples/new.html.erb +++ b/app/views/samples/new.html.erb @@ -99,7 +99,7 @@ controller: "uploads", uploads_target: "div", uploads_filetype_value: "files", - uploads_allowedfiletypes_value: [".dpt", "text/*", ".raw", ".mon", ".csv", ".spectable", ".txt", ".dat"], + uploads_allowedfiletypes_value: [".dpt", "text/*", ".raw", ".mon", ".csv", ".spectable", ".txt", ".dat", ".xy", ".spec"], uploads_allowmultiplefiles_value: true, uploads_generatethumbnails_value: current_user.settings(:uploading).thumbnails } do %> diff --git a/app/views/spectra/edit.html.erb b/app/views/spectra/edit.html.erb index ee27327e..6274a705 100644 --- a/app/views/spectra/edit.html.erb +++ b/app/views/spectra/edit.html.erb @@ -44,7 +44,7 @@ controller: "uploads", uploads_target: "div", uploads_filetype_value: "files", - uploads_allowedfiletypes_value: [".dpt", "text/*", ".raw", ".mon", ".csv", ".spectable", ".txt", ".dat"], + uploads_allowedfiletypes_value: [".dpt", "text/*", ".raw", ".mon", ".csv", ".spectable", ".txt", ".dat", ".xy", ".spec"], uploads_allowmultiplefiles_value: false, uploads_generatethumbnails_value: current_user.settings(:uploading).thumbnails } do %> diff --git a/app/views/spectra/new.html.erb b/app/views/spectra/new.html.erb index 719a6d91..0e79d9a5 100644 --- a/app/views/spectra/new.html.erb +++ b/app/views/spectra/new.html.erb @@ -45,7 +45,7 @@ uploads_target: "div", uploads_filetype_value: "files", uploads_allowmultiplefiles_value: false, - uploads_allowedfiletypes_value: [".dpt", "text/*", ".raw", ".mon", ".csv", ".spectable", ".txt", ".dat"], + uploads_allowedfiletypes_value: [".dpt", "text/*", ".raw", ".mon", ".csv", ".spectable", ".txt", ".dat", ".xy", ".spec"], uploads_generatethumbnails_value: current_user.settings(:uploading).thumbnails } do %> <%= render Forms::LabelComponent.new().with_content("Spectrum file") %>