Initial admin/jobs index
This commit is contained in:
7
app/controllers/admin/jobs_controller.rb
Normal file
7
app/controllers/admin/jobs_controller.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Admin::JobsController < ApplicationController
|
||||
before_action :authorize!
|
||||
def index
|
||||
@jobs = Job.all
|
||||
@pagy, @records = pagy(@jobs, limit: 10)
|
||||
end
|
||||
end
|
||||
2
app/helpers/admin/jobs_helper.rb
Normal file
2
app/helpers/admin/jobs_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Admin::JobsHelper
|
||||
end
|
||||
@@ -30,7 +30,7 @@
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<h2>Aktueller Monat</h2>
|
||||
<%= link_to admin_users_path() do %>
|
||||
<%= link_to admin_jobs_path() do %>
|
||||
<div class="shadow p-4 bg-gray-50">
|
||||
<h2 class="text-xl">aktuelle Druckaufträge:</h2>
|
||||
<p class="size-28"><%= @jobs.count %></p>
|
||||
|
||||
63
app/views/admin/jobs/_job_tr.html.erb
Normal file
63
app/views/admin/jobs/_job_tr.html.erb
Normal file
@@ -0,0 +1,63 @@
|
||||
<tr id="<%= dom_id job %>" class="bg-status-<%= job.status %>-light odd:bg-opacity-25 even:bg-opacity-10 text-hsrm-gray whitespace-nowrap hover:bg-opacity-30" data-stream-enter-class="animate-flash-increase">
|
||||
<td class="p-2 py-3 text-center">
|
||||
<%= link_to operator_job_path(job), target: "_top" do %>
|
||||
<span class="badge badge-xl text-status-<%= job.status %> bg-status-<%= job.status %>-light">
|
||||
<%= job.id %>
|
||||
</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="p-2 py-3 text-center">
|
||||
<% if job.pdf.attached? && job.pdf.previewable? %>
|
||||
<%= link_to job.pdf, target: "_blank", target: "_top" do %>
|
||||
<span class="badge badge-hover">
|
||||
<%= icon("eye", class:"icon") %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="p-2 py-3">
|
||||
<%= link_to job.costumer_fullname, admin_user_path(job.costumer), target: "_top" %>
|
||||
</td>
|
||||
<td class="p-2 py-3">
|
||||
<% 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 %>
|
||||
<span class="badge badge-hover">
|
||||
<%= icon("document-arrow-down", class: "text-hsrm-gray size-6 inline", title: "Download") %>
|
||||
<%=number_to_human_size job.pdf.blob.byte_size%>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% Job::AVAILABLE_PAGE_FORMATS.each do |din| %>
|
||||
<td class="p-1 py-3">
|
||||
<span class="badge">
|
||||
<%= job.public_send("number_of_plans_#{din}") if job.respond_to? "number_of_plans_#{din}" %>
|
||||
</span>
|
||||
</td>
|
||||
<% end %>
|
||||
<td class="p-2 py-3 text-right">
|
||||
<% if job.printing? %>
|
||||
<%= link_to edit_operator_job_path(job), target: "_top" do %>
|
||||
<span class="badge badge-hover">
|
||||
<%= job.costum_qm_plan.round(2) %> m²
|
||||
</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="badge">
|
||||
<%= job.costum_qm_plan.round(2) %> m²
|
||||
</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="w-24 p-2 py-3 text-right">
|
||||
<span class="badge">
|
||||
<%= job.cost.round(2) %> €
|
||||
</span>
|
||||
</td>
|
||||
<td class="p-2 py-3">
|
||||
<span class="badge badge-status text-status-<%= job.status.to_sym %> bg-status-<%= job.status %>-light">
|
||||
<%= job.status %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
28
app/views/admin/jobs/index.html.erb
Normal file
28
app/views/admin/jobs/index.html.erb
Normal file
@@ -0,0 +1,28 @@
|
||||
<%= turbo_frame_tag "admin_jobs" do %>
|
||||
<div>
|
||||
<h1 class="font-bold text-4xl py-4 text-hsrm-gray">Alle Druckaufträge</h1>
|
||||
<div class="min-w-full overflow-auto shadow-lg">
|
||||
<table class="w-full py-8 table-auto">
|
||||
<thead class="font-semibold tracking-wide bg-gray-200 border-b-2 border-gray-300 text text-hsrm-gray">
|
||||
<tr>
|
||||
<th class="w-1 p-2 py-3 text-center"> ID </th>
|
||||
<th class="w-1 p-2 py-3 text-center"> Vorschau </th>
|
||||
<th class="w-1 p-2 py-3 text-left"> Auftraggeber </th>
|
||||
<th class="p-2 py-3 text-left"> PDF </th>
|
||||
<th class="w-1 p-1 py-3 text-left"> A0 </th>
|
||||
<th class="w-1 p-1 py-3 text-left"> A1 </th>
|
||||
<th class="w-1 p-1 py-3 text-left"> A2 </th>
|
||||
<th class="w-1 p-1 py-3 text-left"> A3 </th>
|
||||
<th class="w-1 p-2 py-3 text-center text-nowrap"> no DIN </th>
|
||||
<th class="w-1 p-2 py-3 text-center"> Kosten </th>
|
||||
<th class="w-1 p-2 py-3 text-center"> Status </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id='jobs' class="divide-y divivde-gray-300">
|
||||
<%= render partial: "job_tr", collection: @records, as: :job, locals: { no_actions: true } %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<%== pagy_nav(@pagy) %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,4 +1,4 @@
|
||||
<%= turbo_frame_tag "admin_user" do %>
|
||||
<%= turbo_frame_tag "admin_users" do %>
|
||||
<div class="w-full">
|
||||
<% content_for :title, "Current Print Jobs" %>
|
||||
<div class="flex items-center justify-between py-4">
|
||||
|
||||
@@ -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 ]
|
||||
|
||||
8
test/controllers/admin/jobs_controller_test.rb
Normal file
8
test/controllers/admin/jobs_controller_test.rb
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user