ticket_overviews_controller.rb 1.2 KB

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