ticket_overviews_controller.rb 1.2 KB

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