ticket_overviews_controller.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class TicketOverviewsController < ApplicationController
  3. prepend_before_action :authentication_check
  4. # GET /api/v1/ticket_overview
  5. def data
  6. # get attributes to update
  7. attributes_to_change = Ticket::ScreenOptions.attributes_to_change(
  8. view: 'ticket_overview',
  9. screen: 'overview_bulk',
  10. current_user: current_user,
  11. )
  12. render json: attributes_to_change
  13. end
  14. # GET /api/v1/ticket_overviews
  15. def show
  16. # get navbar overview data
  17. if !params[:view]
  18. index_and_lists = Ticket::Overviews.index(current_user)
  19. indexes = []
  20. index_and_lists.each do |index|
  21. overview = Overview.lookup(id: index[:overview][:id])
  22. meta = {
  23. id: overview.id,
  24. name: overview.name,
  25. prio: overview.prio,
  26. link: overview.link,
  27. count: index[:count],
  28. }
  29. indexes.push meta
  30. end
  31. render json: indexes
  32. return
  33. end
  34. index_and_lists = Ticket::Overviews.index(current_user)
  35. assets = {}
  36. result = {}
  37. index_and_lists.each do |index|
  38. next if index[:overview][:view] != params[:view]
  39. overview = Overview.lookup(id: index[:overview][:id])
  40. assets = overview.assets(assets)
  41. index[:tickets].each do |ticket_meta|
  42. ticket = Ticket.lookup(id: ticket_meta[:id])
  43. assets = ticket.assets(assets)
  44. end
  45. result = index
  46. end
  47. render json: {
  48. assets: assets,
  49. index: result,
  50. }
  51. end
  52. end