ticket_overviews_controller.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. current_user: current_user,
  10. )
  11. render json: attributes_to_change
  12. end
  13. # GET /api/v1/ticket_overviews
  14. def show
  15. # get navbar overview data
  16. if !params[:view]
  17. index_and_lists = Ticket::Overviews.index(current_user)
  18. indexes = []
  19. index_and_lists.each do |index|
  20. overview = Overview.lookup(id: index[:overview][:id])
  21. meta = {
  22. name: overview.name,
  23. prio: overview.prio,
  24. link: overview.link,
  25. count: index[:count],
  26. }
  27. indexes.push meta
  28. end
  29. render json: indexes
  30. return
  31. end
  32. index_and_lists = Ticket::Overviews.index(current_user)
  33. assets = {}
  34. result = {}
  35. index_and_lists.each do |index|
  36. next if index[:overview][:view] != params[:view]
  37. overview = Overview.lookup(id: index[:overview][:id])
  38. assets = overview.assets(assets)
  39. index[:tickets].each do |ticket_meta|
  40. ticket = Ticket.lookup(id: ticket_meta[:id])
  41. assets = ticket.assets(assets)
  42. end
  43. result = index
  44. end
  45. render json: {
  46. assets: assets,
  47. index: result,
  48. }
  49. end
  50. end