ticket_overviews_controller.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. overview = Overview.lookup(id: index[:overview][:id])
  12. meta = {
  13. name: overview.name,
  14. prio: overview.prio,
  15. link: overview.link,
  16. count: index[:count],
  17. }
  18. indexes.push meta
  19. end
  20. render json: indexes
  21. return
  22. end
  23. index_and_lists = Ticket::Overviews.index(current_user)
  24. assets = {}
  25. result = {}
  26. index_and_lists.each do |index|
  27. next if index[:overview][:view] != params[:view]
  28. overview = Overview.lookup(id: index[:overview][:id])
  29. assets = overview.assets(assets)
  30. index[:tickets].each do |ticket_meta|
  31. ticket = Ticket.lookup(id: ticket_meta[:id])
  32. assets = ticket.assets(assets)
  33. end
  34. result = index
  35. end
  36. render json: {
  37. assets: assets,
  38. index: result,
  39. }
  40. end
  41. end