ticket_overviews_controller.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright (C) 2012-2022 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. name: overview.name,
  24. prio: overview.prio,
  25. link: overview.link,
  26. count: index[:count],
  27. }
  28. indexes.push meta
  29. end
  30. render json: indexes
  31. return
  32. end
  33. index_and_lists = Ticket::Overviews.index(current_user)
  34. assets = {}
  35. result = {}
  36. index_and_lists.each do |index|
  37. next if index[:overview][:view] != params[:view]
  38. overview = Overview.lookup(id: index[:overview][:id])
  39. assets = overview.assets(assets)
  40. index[:tickets].each do |ticket_meta|
  41. ticket = Ticket.lookup(id: ticket_meta[:id])
  42. assets = ticket.assets(assets)
  43. end
  44. result = index
  45. end
  46. render json: {
  47. assets: assets,
  48. index: result,
  49. }
  50. end
  51. end