Browse Source

Added ticket job feature.

Martin Edenhofer 9 years ago
parent
commit
1950f82322

+ 3 - 3
app/assets/javascripts/app/controllers/_ui_element/active.coffee

@@ -17,13 +17,13 @@ class App.UiElement.active extends App.UiElement.ApplicationUiElement
       attribute.name = '{boolean}' + attribute.name
 
     # build options list based on config
-    @getConfigOptionList( attribute, params )
+    @getConfigOptionList(attribute, params)
 
     # sort attribute.options
-    @sortOptions( attribute, params )
+    @sortOptions(attribute, params)
 
     # finde selected/checked item of list
-    @selectedOptions( attribute, params )
+    @selectedOptions(attribute, params)
 
     # return item
     $( App.view('generic/select')( attribute: attribute ) )

+ 4 - 4
app/assets/javascripts/app/controllers/_ui_element/boolean.coffee

@@ -14,13 +14,13 @@ class App.UiElement.boolean extends App.UiElement.ApplicationUiElement
       attribute.name = '{boolean}' + attribute.name
 
     # build options list based on config
-    @getConfigOptionList( attribute, params )
+    @getConfigOptionList(attribute, params)
 
     # sort attribute.options
-    @sortOptions( attribute, params )
+    @sortOptions(attribute, params)
 
     # finde selected/checked item of list
-    @selectedOptions( attribute, params )
+    @selectedOptions(attribute, params)
 
     # return item
-    $( App.view('generic/select')( attribute: attribute ) )
+    $(App.view('generic/select')(attribute: attribute))

+ 7 - 7
app/assets/javascripts/app/controllers/_ui_element/radio.coffee

@@ -3,24 +3,24 @@ class App.UiElement.radio extends App.UiElement.ApplicationUiElement
   @render: (attribute, params) ->
 
     # build options list based on config
-    @getConfigOptionList( attribute, params )
+    @getConfigOptionList(attribute, params)
 
     # build options list based on relation
-    @getRelationOptionList( attribute, params )
+    @getRelationOptionList(attribute, params)
 
     # add null selection if needed
-    @addNullOption( attribute, params )
+    @addNullOption(attribute, params)
 
     # sort attribute.options
-    @sortOptions( attribute, params )
+    @sortOptions(attribute, params)
 
     # finde selected/checked item of list
-    @selectedOptions( attribute, params )
+    @selectedOptions(attribute, params)
 
     # disable item of list
-    @disabledOptions( attribute, params )
+    @disabledOptions(attribute, params)
 
     # filter attributes
-    @filterOption( attribute, params )
+    @filterOption(attribute, params)
 
     $( App.view('generic/radio')( attribute: attribute ) )

+ 7 - 7
app/assets/javascripts/app/controllers/_ui_element/select.coffee

@@ -9,25 +9,25 @@ class App.UiElement.select extends App.UiElement.ApplicationUiElement
       attribute.multiple = ''
 
     # build options list based on config
-    @getConfigOptionList( attribute, params )
+    @getConfigOptionList(attribute, params)
 
     # build options list based on relation
-    @getRelationOptionList( attribute, params )
+    @getRelationOptionList(attribute, params)
 
     # add null selection if needed
-    @addNullOption( attribute, params )
+    @addNullOption(attribute, params)
 
     # sort attribute.options
-    @sortOptions( attribute, params )
+    @sortOptions(attribute, params)
 
     # finde selected/checked item of list
-    @selectedOptions( attribute, params )
+    @selectedOptions(attribute, params)
 
     # disable item of list
-    @disabledOptions( attribute, params )
+    @disabledOptions(attribute, params)
 
     # filter attributes
-    @filterOption( attribute, params )
+    @filterOption(attribute, params)
 
     # return item
     $( App.view('generic/select')( attribute: attribute ) )

+ 1 - 1
app/assets/javascripts/app/controllers/_ui_element/tag.coffee

@@ -5,5 +5,5 @@ class App.UiElement.tag
     a = ->
       $('#' + attribute.id ).tokenfield()
       $('#' + attribute.id ).parent().css('height', 'auto')
-    App.Delay.set( a, 120, undefined, 'tags' )
+    App.Delay.set(a, 120, undefined, 'tags')
     item

+ 2 - 2
app/assets/javascripts/app/controllers/_ui_element/textarea.coffee

@@ -13,7 +13,7 @@ class App.UiElement.textarea
         if visible && !$( item[0] ).expanding('active')
           $( item[0] ).expanding().focus()
       )
-    App.Delay.set( a, 80 )
+    App.Delay.set(a, 80)
 
     if attribute.upload
 
@@ -39,5 +39,5 @@ class App.UiElement.textarea
               fail:    ''
             debug: false
           )
-      App.Delay.set( u, 100, undefined, 'form_upload' )
+      App.Delay.set(u, 100, undefined, 'form_upload')
     item

+ 3 - 3
app/assets/javascripts/app/controllers/_ui_element/timezone.coffee

@@ -15,13 +15,13 @@ class App.UiElement.timezone extends App.UiElement.ApplicationUiElement
       attribute.options.push item
 
     # add null selection if needed
-    @addNullOption( attribute, params )
+    @addNullOption(attribute, params)
 
     # sort attribute.options
-    @sortOptions( attribute, params )
+    @sortOptions(attribute, params)
 
     # finde selected/checked item of list
-    @selectedOptions( attribute, params )
+    @selectedOptions(attribute, params)
 
     attribute.tag =        'searchable_select'
     attribute.placeholder = App.i18n.translateInline('Enter timzone...')

+ 29 - 0
app/assets/javascripts/app/controllers/job.coffee

@@ -0,0 +1,29 @@
+class Index extends App.ControllerContent
+  constructor: ->
+    super
+
+    # check authentication
+    return if !@authenticate(false, 'Admin')
+
+    new App.ControllerGenericIndex(
+      el: @el
+      id: @id
+      genericObject: 'Job'
+      defaultSortBy: 'name'
+      pageData:
+        title: 'Scheduler'
+        home: 'Jobs'
+        object: 'Scheduler'
+        objects: 'Schedulers'
+        navupdate: '#Jobs'
+        notes: [
+          'Scheduler are ...'
+        ]
+        buttons: [
+          { name: 'New Scheduler', 'data-type': 'new', class: 'btn--success' }
+        ]
+      container: @el.closest('.content')
+      #large: true
+    )
+
+App.Config.set('Job', { prio: 3400, name: 'Scheduler', parent: '#manage', target: '#manage/job', controller: Index, role: ['Admin'] }, 'NavBarAdmin')

+ 23 - 81
app/assets/javascripts/app/controllers/trigger.coffee

@@ -1,88 +1,30 @@
-class Index extends App.ControllerTabs
-  header: 'Trigger'
+class Index extends App.ControllerContent
   constructor: ->
     super
 
-    @title 'Trigger', true
+    # check authentication
+    return if !@authenticate(false, 'Admin')
 
-    @tabs = [
-      {
-        name:       'Time Based',
-        target:     'c-time-based',
-        controller: App.TriggerTime,
-      },
-      {
-        name:       'Event Based',
-        target:     'c-event-based',
-        controller: App.SettingsArea,
-        params:     { area: 'Email::Base' },
-      },
-      {
-        name:       'Notifications',
-        target:     'c-notification',
-        controller: App.SettingsArea,
-        params:     { area: 'Email::Base' },
-      },
-      {
-        name:       'Web Hooks',
-        target:     'c-web-hook',
-        controller: App.SettingsArea,
-        params:     { area: 'Email::Base' },
-      },
-    ]
-
-    @render()
-
-App.Config.set( 'Trigger', { prio: 3000, name: 'Trigger', parent: '#manage', target: '#manage/triggers', controller: Index, role: ['Admin'] }, 'NavBarAdmin' )
-
-class App.TriggerTime extends App.Controller
-  events:
-    'click .js-new': 'new'
-    #'click .js-edit': 'edit'
-    'click .js-delete': 'delete'
-
-  constructor: ->
-    super
-    @interval(@load, 30000)
-    #@load()
-
-  load: =>
-    @startLoading()
-    @ajax(
-      id:   'trigger_time_index'
-      type: 'GET'
-      url:  @apiPath + '/jobs'
-      processData: true
-      success: (data, status, xhr) =>
-        #App.Collection.loadAssets(data.assets)
-        @stopLoading()
-        @render(data)
-    )
-
-  render: (data = {}) =>
-
-    @html App.view('trigger/time/index')(
-      triggers: []
-    )
-
-
-  delete: (e) =>
-    e.preventDefault()
-    id   = $(e.target).closest('.action').data('id')
-    item = App.Channel.find(id)
-    new App.ControllerGenericDestroyConfirm(
-      item:      item
-      container: @el.closest('.content')
-      callback:  @load
-    )
-
-  new: (e) =>
-    e.preventDefault()
-    channel_id = $(e.target).closest('.action').data('id')
-    new App.ControllerGenericNew(
+    new App.ControllerGenericIndex(
+      el: @el
+      id: @id
+      genericObject: 'Trigger'
+      defaultSortBy: 'name'
+      #groupBy: 'role'
       pageData:
-        object: 'Jobs'
-      genericObject: 'Job'
+        title: 'Triggers'
+        home: 'triggers'
+        object: 'Trigger'
+        objects: 'Triggers'
+        navupdate: '#triggers'
+        notes: [
+          'Triggers are ...'
+        ]
+        buttons: [
+          { name: 'New Trigger', 'data-type': 'new', class: 'btn--success' }
+        ]
       container: @el.closest('.content')
-      callback: @load
+      #large: true
     )
+
+App.Config.set('Trigger', { prio: 3300, name: 'Trigger', parent: '#manage', target: '#manage/trigger', controller: Index, role: ['Admin'] }, 'NavBarAdmin')

+ 5 - 4
app/assets/javascripts/app/models/job.coffee

@@ -1,12 +1,13 @@
 class App.Job extends App.Model
-  @configure 'Job', 'name', 'timeplan', 'condition', 'execute', 'note', 'active'
+  @configure 'Job', 'name', 'timeplan', 'condition', 'perform', 'disable_notiifcation', 'note', 'active'
   @extend Spine.Model.Ajax
   @url: @apiPath + '/jobs'
   @configure_attributes = [
     { name: 'name',           display: 'Name',        tag: 'input',    type: 'text', limit: 100, null: false },
-#    { name: 'timeplan',       display: 'The times where the job should run.', tag: 'timeplan', null: true },
-    { name: 'condition',      display: 'Conditions for matching objects.', tag: 'ticket_selector', null: true },
-    { name: 'execute',        display: 'Execute changes on objects.', tag: 'ticket_perform_action', null: true },
+    { name: 'timeplan',       display: 'When should the job run?', tag: 'timer', null: true },
+    { name: 'condition',      display: 'Conditions for effected objects', tag: 'ticket_selector', null: true },
+    { name: 'perform',        display: 'Execute changes on objects', tag: 'ticket_perform_action', null: true },
+    { name: 'disable_notiifcation', display: 'Disable Notifications', tag: 'boolean', default: true },
     { name: 'note',           display: 'Note',        tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
     { name: 'active',         display: 'Active',      tag: 'active', default: true },
     { name: 'matching',       display: 'Matching',    readonly: 1 },

Some files were not shown because too many files changed in this diff