Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/components/projects/ml')
-rw-r--r--app/components/projects/ml/models_index_component.rb25
-rw-r--r--app/components/projects/ml/show_ml_model_component.html.haml1
-rw-r--r--app/components/projects/ml/show_ml_model_component.rb27
3 files changed, 48 insertions, 5 deletions
diff --git a/app/components/projects/ml/models_index_component.rb b/app/components/projects/ml/models_index_component.rb
index c5c20565195..57900165ad1 100644
--- a/app/components/projects/ml/models_index_component.rb
+++ b/app/components/projects/ml/models_index_component.rb
@@ -3,27 +3,42 @@
module Projects
module Ml
class ModelsIndexComponent < ViewComponent::Base
- attr_reader :models
+ attr_reader :paginator
- def initialize(models:)
- @models = models
+ def initialize(paginator:)
+ @paginator = paginator
end
private
def view_model
- Gitlab::Json.generate({ models: models_view_model })
+ vm = {
+ models: models_view_model,
+ page_info: page_info_view_model
+ }
+
+ Gitlab::Json.generate(vm.deep_transform_keys { |k| k.to_s.camelize(:lower) })
end
def models_view_model
- models.map(&:present).map do |m|
+ paginator.records.map(&:present).map do |m|
{
name: m.name,
version: m.latest_version_name,
+ version_count: m.version_count,
path: m.latest_package_path
}
end
end
+
+ def page_info_view_model
+ {
+ has_next_page: paginator.has_next_page?,
+ has_previous_page: paginator.has_previous_page?,
+ start_cursor: paginator.cursor_for_previous_page,
+ end_cursor: paginator.cursor_for_next_page
+ }
+ end
end
end
end
diff --git a/app/components/projects/ml/show_ml_model_component.html.haml b/app/components/projects/ml/show_ml_model_component.html.haml
new file mode 100644
index 00000000000..20e52246e6d
--- /dev/null
+++ b/app/components/projects/ml/show_ml_model_component.html.haml
@@ -0,0 +1 @@
+#js-mount-show-ml-model{ data: { view_model: view_model } }
diff --git a/app/components/projects/ml/show_ml_model_component.rb b/app/components/projects/ml/show_ml_model_component.rb
new file mode 100644
index 00000000000..2fe2c7e7e9d
--- /dev/null
+++ b/app/components/projects/ml/show_ml_model_component.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Projects
+ module Ml
+ class ShowMlModelComponent < ViewComponent::Base
+ attr_reader :model
+
+ def initialize(model:)
+ @model = model.present
+ end
+
+ private
+
+ def view_model
+ vm = {
+ model: {
+ id: model.id,
+ name: model.name,
+ path: model.path
+ }
+ }
+
+ Gitlab::Json.generate(vm)
+ end
+ end
+ end
+end