diff --git a/app/controllers/admin/jobs_controller.rb b/app/controllers/admin/jobs_controller.rb new file mode 100644 index 0000000..39d6040 --- /dev/null +++ b/app/controllers/admin/jobs_controller.rb @@ -0,0 +1,7 @@ +class Admin::JobsController < ApplicationController + before_action :authorize! + def index + @jobs = Job.all + @pagy, @records = pagy(@jobs, limit: 10) + end +end diff --git a/app/helpers/admin/jobs_helper.rb b/app/helpers/admin/jobs_helper.rb new file mode 100644 index 0000000..2554ac6 --- /dev/null +++ b/app/helpers/admin/jobs_helper.rb @@ -0,0 +1,2 @@ +module Admin::JobsHelper +end diff --git a/app/views/admin/dashboards/show.html.erb b/app/views/admin/dashboards/show.html.erb index b3d055c..be6bbd5 100644 --- a/app/views/admin/dashboards/show.html.erb +++ b/app/views/admin/dashboards/show.html.erb @@ -30,7 +30,7 @@

Aktueller Monat

- <%= link_to admin_users_path() do %> + <%= link_to admin_jobs_path() do %>

aktuelle Druckaufträge:

<%= @jobs.count %>

diff --git a/app/views/admin/jobs/_job_tr.html.erb b/app/views/admin/jobs/_job_tr.html.erb new file mode 100644 index 0000000..4b2cbbf --- /dev/null +++ b/app/views/admin/jobs/_job_tr.html.erb @@ -0,0 +1,63 @@ + + + <%= link_to operator_job_path(job), target: "_top" do %> + + <%= job.id %> + + <% end %> + + + <% if job.pdf.attached? && job.pdf.previewable? %> + <%= link_to job.pdf, target: "_blank", target: "_top" do %> + + <%= icon("eye", class:"icon") %> + + <% end %> + <% end %> + + + <%= link_to job.costumer_fullname, admin_user_path(job.costumer), target: "_top" %> + + + <% if job.pdf.attached? %> + <%#= link_to job.pdf.filename, rails_blob_path(job.pdf, disposition: "attachment") %> + <%= link_to truncate(job.pdf.filename.to_s, length: 45), job.pdf, download:true, target: "_top" %> + <%= link_to job.pdf, download:true, target: "_top" do %> + + <%= icon("document-arrow-down", class: "text-hsrm-gray size-6 inline", title: "Download") %> + <%=number_to_human_size job.pdf.blob.byte_size%> + + <% end %> + <% end %> + + <% Job::AVAILABLE_PAGE_FORMATS.each do |din| %> + + + <%= job.public_send("number_of_plans_#{din}") if job.respond_to? "number_of_plans_#{din}" %> + + + <% end %> + + <% if job.printing? %> + <%= link_to edit_operator_job_path(job), target: "_top" do %> + + <%= job.costum_qm_plan.round(2) %> m² + + <% end %> + <% else %> + + <%= job.costum_qm_plan.round(2) %> m² + + <% end %> + + + + <%= job.cost.round(2) %> € + + + + + <%= job.status %> + + + diff --git a/app/views/admin/jobs/index.html.erb b/app/views/admin/jobs/index.html.erb new file mode 100644 index 0000000..f9aead9 --- /dev/null +++ b/app/views/admin/jobs/index.html.erb @@ -0,0 +1,28 @@ +<%= turbo_frame_tag "admin_jobs" do %> +
+

Alle Druckaufträge

+
+ + + + + + + + + + + + + + + + + + <%= render partial: "job_tr", collection: @records, as: :job, locals: { no_actions: true } %> + +
ID Vorschau Auftraggeber PDF A0 A1 A2 A3 no DIN Kosten Status
+
+ <%== pagy_nav(@pagy) %> +
+<% end %> diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index d5187b1..5877b0a 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,4 +1,4 @@ -<%= turbo_frame_tag "admin_user" do %> +<%= turbo_frame_tag "admin_users" do %>
<% content_for :title, "Current Print Jobs" %>
diff --git a/config/routes.rb b/config/routes.rb index a0c9492..324b229 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,7 @@ Rails.application.routes.draw do end resource :profile, only: [ :show, :edit, :destroy ] namespace :admin do + resource :jobs, only: [ :index ] resources :users, only: [ :index, :show ] resources :jobs resource :dashboard, only: [ :show ] diff --git a/test/controllers/admin/jobs_controller_test.rb b/test/controllers/admin/jobs_controller_test.rb new file mode 100644 index 0000000..c2b3aac --- /dev/null +++ b/test/controllers/admin/jobs_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class Admin::JobsControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get admin_jobs_index_url + assert_response :success + end +end