job.coffee 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. class Job extends App.ControllerSubContent
  2. @requiredPermission: 'admin.scheduler'
  3. header: __('Scheduler')
  4. constructor: ->
  5. super
  6. @fetchTimezones()
  7. @genericController = new Index(
  8. el: @el
  9. id: @id
  10. genericObject: 'Job'
  11. defaultSortBy: 'name'
  12. searchBar: true
  13. searchQuery: @search_query
  14. pageData:
  15. home: 'Jobs'
  16. object: __('Scheduler')
  17. objects: __('Schedulers')
  18. pagerAjax: true
  19. pagerBaseUrl: '#manage/job/'
  20. pagerSelected: ( @page || 1 )
  21. pagerPerPage: 50
  22. navupdate: '#Jobs'
  23. buttons: [
  24. { name: __('New Scheduler'), 'data-type': 'new', class: 'btn--success' }
  25. ]
  26. container: @el.closest('.content')
  27. veryLarge: true
  28. handlers: [
  29. App.FormHandlerAdminJobObjectName.run
  30. ]
  31. )
  32. show: (params) =>
  33. for key, value of params
  34. if key isnt 'el' && key isnt 'shown' && key isnt 'match'
  35. @[key] = value
  36. @genericController.paginate(@page || 1, params)
  37. fetchTimezones: =>
  38. @ajax(
  39. id: 'calendar_timezones'
  40. type: 'GET'
  41. url: "#{@apiPath}/calendars/timezones"
  42. success: (data) ->
  43. App.Config.set('timezones', data.timezones)
  44. )
  45. class Index extends App.ControllerGenericIndex
  46. newControllerClass: -> New
  47. editControllerClass: -> Edit
  48. ModalContentFormModelMixin =
  49. events:
  50. 'change input[name="execution_localization"]': 'executionLocalizationChanged'
  51. contentFormModel: ->
  52. params = @contentFormParams() or {}
  53. attrs = _.clone(App[ @genericObject ].configure_attributes)
  54. attrs = @prepareExecutionLocalizationAttributes(params, attrs)
  55. { configure_attributes: attrs }
  56. class Edit extends App.ControllerGenericEdit
  57. @include App.ExecutionLocalizationMixin
  58. @include ModalContentFormModelMixin
  59. class New extends App.ControllerGenericNew
  60. @include App.ExecutionLocalizationMixin
  61. @include ModalContentFormModelMixin
  62. App.Config.set('Job', { prio: 3400, name: __('Scheduler'), parent: '#manage', target: '#manage/job', controller: Job, permission: ['admin.scheduler'] }, 'NavBarAdmin')