Improved application log backend. Now all controllers have " @log 'debug|notice|error', 'some ' " available.

This commit is contained in:
Martin Edenhofer 2013-06-20 19:04:09 +02:00
parent 5820f23da5
commit 76cafc60ba
36 changed files with 219 additions and 231 deletions

View file

@ -452,7 +452,7 @@ class App.ControllerModal extends App.Controller
submit: (e) ->
e.preventDefault()
@log 'You need to implement your own "submit" method!'
@log 'error', 'You need to implement your own "submit" method!'
class App.ErrorModal extends App.ControllerModal
constructor: ->

View file

@ -18,7 +18,7 @@ class App.ControllerForm extends App.Controller
@form.html()
formGen: ->
App.Log.log 'ControllerForm', 'debug', 'formGen', @model.configure_attributes
App.Log.debug 'ControllerForm', 'formGen', @model.configure_attributes
fieldset = $('<fieldset>')
@ -176,7 +176,7 @@ class App.ControllerForm extends App.Controller
if attribute.name of @params
attribute.value = @params[attribute.name]
App.Log.log 'ControllerForm', 'debug', 'formGenItem-before', attribute
App.Log.debug 'ControllerForm', 'formGenItem-before', attribute
# build options list based on config
@_getConfigOptionList( attribute )
@ -259,7 +259,6 @@ class App.ControllerForm extends App.Controller
counter = 0
for key of loopData
counter =+ 1
# @log 'kkk', key, loopData[ key ]
# clone to keep it untouched for next loop
select = _.clone( attribute )
@ -432,17 +431,15 @@ class App.ControllerForm extends App.Controller
source: '/users/search',
minLength: 2,
select: ( event, ui ) =>
@log 'selected', event, ui
@log 'notice', 'selected', event, ui
b(event, ui.item.id)
}
)
###
# @log '111111', @local_attribute_full, item
$(@local_attribute_full).autocomplete(
source: 'api/users/search',
minLength: 2,
select: ( event, ui ) =>
# @log 'selected', event, ui
b(event, ui.item.id)
)
@delay( a, 180 )
@ -935,7 +932,6 @@ class App.ControllerForm extends App.Controller
item = $( App.view('generic/input')( attribute: attribute ) )
if attribute.onchange
# @log 'on change', attribute.name
if typeof attribute.onchange is 'function'
attribute.onchange(attribute)
else
@ -943,7 +939,6 @@ class App.ControllerForm extends App.Controller
a = i.split(/__/)
if a[1]
if a[0] is attribute.name
# @log 'aaa', i, a[0], attribute.id
@attribute = attribute
@classname = classname
@attributes_clean = attributes_clean
@ -1114,11 +1109,11 @@ class App.ControllerForm extends App.Controller
list = []
if attribute.filter
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter', attribute.filter
App.Log.debug 'ControllerForm', '_getRelationOptionList:filter', attribute.filter
# function based filter
if typeof attribute.filter is 'function'
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-function'
App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-function'
all = App.Collection.all( type: attribute.relation, sortBy: attribute.sortBy || 'name' )
@ -1128,7 +1123,7 @@ class App.ControllerForm extends App.Controller
else if attribute.filter[ attribute.name ]
filter = attribute.filter[ attribute.name ]
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-data', filter
App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-data', filter
# check all records
for record in App.Collection.all( type: attribute.relation, sortBy: attribute.sortBy || 'name' )
@ -1143,13 +1138,13 @@ class App.ControllerForm extends App.Controller
# no data filter matched
else
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-data no filter matched'
App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-data no filter matched'
list = App.Collection.all( type: attribute.relation, sortBy: attribute.sortBy || 'name' )
else
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList:filter-no filter defined'
App.Log.debug 'ControllerForm', '_getRelationOptionList:filter-no filter defined'
list = App.Collection.all( type: attribute.relation, sortBy: attribute.sortBy || 'name' )
App.Log.log 'ControllerForm', 'debug', '_getRelationOptionList', attribute, list
App.Log.debug 'ControllerForm', '_getRelationOptionList', attribute, list
# build options list
@_buildOptionList( list, attribute )
@ -1180,7 +1175,7 @@ class App.ControllerForm extends App.Controller
return if !attribute.options
return if typeof attribute.filter isnt 'function'
App.Log.log 'ControllerForm', 'debug', '_filterOption:filter-function'
App.Log.debug 'ControllerForm', '_filterOption:filter-function'
attribute.options = attribute.filter( attribute.options, attribute )
@ -1251,7 +1246,7 @@ class App.ControllerForm extends App.Controller
else if form.parents().find('form')[0]
form = form.parents().find('form')
else
App.Log.log 'ControllerForm', 'error', 'no form found!', form
App.Log.error 'ControllerForm', 'no form found!', form
array = form.serializeArray()
@ -1320,7 +1315,7 @@ class App.ControllerForm extends App.Controller
for key of inputSelectObject
param[ key ] = inputSelectObject[ key ]
#App.Log.log 'ControllerForm', 'notice', 'formParam', form, param
#App.Log.notice 'ControllerForm', 'formParam', form, param
return param
@formId: ->
@ -1328,14 +1323,14 @@ class App.ControllerForm extends App.Controller
formId.toString().substr formId.toString().length-9, 9
@disable: (form) ->
App.Log.log 'ControllerForm', 'notice', 'disable...', $(form.target).parent()
App.Log.notice 'ControllerForm', 'disable...', $(form.target).parent()
$(form.target).parent().find('button').attr('disabled', true)
$(form.target).parent().find('[type="submit"]').attr('disabled', true)
$(form.target).parent().find('[type="reset"]').attr('disabled', true)
@enable: (form) ->
App.Log.log 'ControllerForm', 'notice', 'enable...', $(form.target).parent()
App.Log.notice 'ControllerForm', 'enable...', $(form.target).parent()
$(form.target).parent().find('button').attr('disabled', false)
$(form.target).parent().find('[type="submit"]').attr('disabled', false)
$(form.target).parent().find('[type="reset"]').attr('disabled', false)

View file

@ -21,7 +21,6 @@ class App.ControllerGenericNew extends App.ControllerModal
@modalShow()
submit: (e) ->
@log 'submit'
e.preventDefault()
params = @formParam( e.target )
@ -31,7 +30,7 @@ class App.ControllerGenericNew extends App.ControllerModal
# validate
errors = object.validate()
if errors
@log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
return false
@ -81,7 +80,7 @@ class App.ControllerGenericEdit extends App.ControllerModal
# validate
errors = @item.validate()
if errors
@log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
return false
@ -133,9 +132,9 @@ class App.ControllerGenericIndex extends App.ControllerContent
)
App[ @genericObject ].bind 'ajaxError', (rec, msg) =>
@log 'ajax notice', msg.status
@log 'error', 'ajax', msg.status
if msg.status is 401
@log 'ajax error', rec, msg, msg.status
@log 'error', 'ajax', rec, msg, msg.status
# @navigate @pageData.navupdate
# alert('relogin')
@navigate 'login'

View file

@ -110,7 +110,7 @@ class App.ControllerTable extends App.Controller
record = App.Collection.find( attribute.relation, object[rowWithoutId] )
object[row.name] = record.name
@log 'ControllerTable', 'debug', 'table', 'header', header, 'overview', dataTypesForCols, 'objects', data.objects
@log 'debug', 'table', 'header', header, 'overview', dataTypesForCols, 'objects', data.objects
table = App.view('generic/table')(
header: header
overview: dataTypesForCols
@ -133,4 +133,4 @@ class App.ControllerTable extends App.Controller
$(e.target).parents().find('[name="bulk"]').attr( 'checked', false );
)
return table
return table

View file

@ -119,7 +119,7 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal
# show errors in form
if errors
@log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
return false
@ -131,7 +131,6 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal
success: =>
@modalHide()
error: =>
@log 'errors'
@modalHide()
)
@ -211,7 +210,7 @@ class App.ChannelEmailAddressEdit extends App.ControllerModal
# show errors in form
if errors
@log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
return false
@ -223,7 +222,6 @@ class App.ChannelEmailAddressEdit extends App.ControllerModal
success: =>
@modalHide()
error: =>
@log 'errors'
@modalHide()
)
@ -259,7 +257,6 @@ class App.ChannelEmailSignature extends App.Controller
edit: (e) =>
e.preventDefault()
item = $(e.target).item( App.Signature )
@log '123', item, $(e.target)
new App.ChannelEmailSignatureEdit( object: item )
class App.ChannelEmailSignatureEdit extends App.ControllerModal
@ -303,7 +300,7 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal
# show errors in form
if errors
@log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
return false
@ -315,7 +312,6 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal
success: =>
@modalHide()
error: =>
@log 'errors'
@modalHide()
)
@ -430,7 +426,7 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
# show errors in form
if errors
@log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
return false
@ -442,7 +438,6 @@ class App.ChannelEmailInboundEdit extends App.ControllerModal
success: =>
@modalHide()
error: =>
@log 'errors'
@modalHide()
)

View file

@ -80,7 +80,6 @@ class App.DashboardActivityStream extends App.Controller
e.preventDefault()
id = $(e.target).parents('[data-id]').data('id')
subid = $(e.target).parents('[data-subid]').data('subid')
@log 'goto zoom!', id, subid
if subid
@navigate 'ticket/zoom/' + id + '/' + subid
else

View file

@ -4,7 +4,6 @@ class App.DashboardRecentViewed extends App.Controller
constructor: ->
super
# @log 'aaaa', @el
@items = []
@ -54,5 +53,5 @@ class App.DashboardRecentViewed extends App.Controller
zoom: (e) =>
e.preventDefault()
id = $(e.target).parents('[data-id]').data('id')
@log 'goto zoom!'
@navigate 'ticket/zoom/' + id

View file

@ -59,12 +59,12 @@ class App.DashboardTicket extends App.Controller
App.Overview.unbind('local:rerender')
App.Overview.bind 'local:rerender', (record) =>
@log 'rerender...', record
@log 'notice', 'rerender...', record
@render(data)
App.Overview.unbind('local:refetch')
App.Overview.bind 'local:refetch', (record) =>
@log 'refetch...', record
@log 'notice', 'refetch...', record
@fetch()
@render( data )
@ -123,7 +123,6 @@ class App.DashboardTicket extends App.Controller
@Config.set('LastOverviewPosition', position )
@Config.set('LastOverviewTotal', @tickets_count )
@log 'goto zoom!', id, position
@navigate 'ticket/zoom/' + id + '/nav/true'
settings: (e) =>

View file

@ -46,7 +46,7 @@ class App.TicketCreate extends App.Controller
# lisen if view need to be rerendert
App.Event.bind 'ticket_create_rerender', (defaults) =>
@log 'AgentTicketPhone', 'error', defaults
@log 'notice', 'error', defaults
@render(defaults)
# start auto save
@ -90,7 +90,7 @@ class App.TicketCreate extends App.Controller
diff = difference( @autosaveLast, data )
if !@autosaveLast || ( diff && !_.isEmpty( diff ) )
@autosaveLast = data
console.log('form hash changed', diff, data)
@log 'notice', 'form hash changed', diff, data
App.TaskManager.update( @task_key, { 'state': data })
@interval( update, 10000, @id, @auto_save_key )
@ -145,7 +145,6 @@ class App.TicketCreate extends App.Controller
t.customer_id_autocompletion = a.from
t.subject = a.subject || t.title
t.body = a.body
@log '11111', t
@render( options: t )
)
@ -286,7 +285,7 @@ class App.TicketCreate extends App.Controller
# show errors in form
if errors
console.log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
# save ticket, create article
@ -346,7 +345,7 @@ class UserNew extends App.ControllerModal
@modalShow()
submit: (e) ->
@log 'submit'
e.preventDefault()
params = @formParam(e.target)
@ -359,12 +358,12 @@ class UserNew extends App.ControllerModal
# find role_id
role = App.Collection.findByAttribute( 'Role', 'name', 'Customer' )
params.role_ids = role.id
@log 'updateAttributes', params
@log 'notice', 'updateAttributes', params
user.load(params)
errors = user.validate()
if errors
@log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
return
@ -391,7 +390,6 @@ class UserNew extends App.ControllerModal
class TicketCreateRouter extends App.ControllerPermanent
constructor: (params) ->
super
@log 'create router', params
# create new uniq form id
if !params['id']

View file

@ -58,7 +58,7 @@ class App.TicketHistory extends App.ControllerModal
sortorder: (e) ->
e.preventDefault()
isSorted = @el.find('.sorted')
@log 'is sorted?', isSorted
if isSorted.length
@sortstate = 'notsorted'
@html App.view('agent_ticket_history')(

View file

@ -124,7 +124,7 @@ class App.TicketMerge extends App.ControllerModal
@modalHide()
# view ticket
@log 'nav...', App.Collection.find( 'Ticket', data.master_ticket['id'] )
@log 'notice', 'nav...', App.Collection.find( 'Ticket', data.master_ticket['id'] )
@navigate '#ticket/zoom/' + data.master_ticket['id']
# notify UI

View file

@ -12,7 +12,7 @@ class Index extends App.ControllerContent
return if !@authenticate()
@view_mode = localStorage.getItem( "mode:#{@view}" ) || 's'
@log 'view:', @view, @view_mode
@log 'notice', 'view:', @view, @view_mode
# set title
@title ''
@ -78,12 +78,12 @@ class Index extends App.ControllerContent
App.Overview.unbind('local:rerender')
App.Overview.bind 'local:rerender', (record) =>
@log 'rerender...', record
@log 'notice', 'rerender...', record
@render()
App.Overview.unbind('local:refetch')
App.Overview.bind 'local:refetch', (record) =>
@log 'refetch...', record
@log 'notice', 'refetch...', record
@fetch()
# # bind render after a change is done
@ -286,7 +286,7 @@ class Index extends App.ControllerContent
@bulk_count = @el.find('.table-overview').find('[name="bulk"]:checked').length
@bulk_count_index = 0
@el.find('.table-overview').find('[name="bulk"]:checked').each( (index, element) =>
@log '@bulk_count_index', @bulk_count, @bulk_count_index
@log 'notice', '@bulk_count_index', @bulk_count, @bulk_count_index
ticket_id = $(element).val()
ticket = App.Ticket.find(ticket_id)
params = @formParam(e.target)
@ -297,7 +297,7 @@ class Index extends App.ControllerContent
if params[item] != ''
ticket_update[item] = params[item]
# @log 'update', params, ticket_update, ticket
# @log 'notice', 'update', params, ticket_update, ticket
ticket.load(ticket_update)
ticket.save(

View file

@ -114,7 +114,6 @@ class App.ChatWidget extends App.Controller
@el.find('div.well').addClass('alert-success')
@delay( =>
@el.find('div.well').removeClass('alert-success')
@log 'DELAY rm'
App.Event.trigger(
'ws:send'

View file

@ -82,13 +82,13 @@ class Index extends App.ControllerContent
else
@params.role_ids = [0]
@log 'updateAttributes', @params
@log 'notice', 'updateAttributes', @params
user = new App.User
user.load(@params)
errors = user.validate()
if errors
@log 'error new', errors
@log 'error', errors
@formValidate( form: e.target, errors: errors )
return false
@ -134,7 +134,7 @@ class Index extends App.ControllerContent
)
relogin: (data, status, xhr) =>
@log 'login:success', data
@log 'notice', 'relogin:success', data
# login check
App.Auth.loginCheck()

View file

@ -121,7 +121,6 @@ class App.LinkAdd extends App.ControllerModal
submit: (e) =>
e.preventDefault()
params = @formParam(e.target)
@log 'link', params
# get data
App.Com.ajax(
@ -139,4 +138,4 @@ class App.LinkAdd extends App.ControllerModal
success: (data, status, xhr) =>
@modalHide()
@parent.fetch()
)
)

View file

@ -74,7 +74,6 @@ class Index extends App.ControllerContent
)
success: (data, status, xhr) =>
@log 'login:success', data
# rebuild navbar with ticket overview counter
App.WebSocket.send( event: 'navupdate_ticket_overview' )
@ -88,13 +87,13 @@ class Index extends App.ControllerContent
# redirect to #
requested_url = @Config.get( 'requested_url' )
if requested_url && requested_url isnt '#login'
console.log("REDIRECT to '#{requested_url}'")
@log 'notice', "REDIRECT to '#{requested_url}'"
@navigate requested_url
# reset
@Config.set( 'requested_url', '' )
else
console.log("REDIRECT to -#/-")
@log 'notice', "REDIRECT to -#/-"
@navigate '#/'
error: (xhr, statusText, error) =>

View file

@ -19,10 +19,10 @@ class Index extends App.ControllerContent
networks = App.Network.all()
network_categories = App.NetworkCategory.all()
for network in networks
@log 'f', network for network in networks
@log 'notice', network for network in networks
for network_category in network_categories
@log 'fc', network_category
@log 'notice', network_category
@html App.view('network')(
networks: App.Network.all(),

View file

@ -49,7 +49,7 @@ class Index extends App.ControllerContent
@params.login = @params.email
@params.role_ids = [0]
@log 'updateAttributes', @params
@log 'notice', 'updateAttributes', @params
user = new App.User
user.load(@params)
@ -96,4 +96,4 @@ class Index extends App.ControllerContent
msg: 'Wrong Username and Password combination.'
removeAll: true
App.Config.set( 'signup', Index, 'Routes' )
App.Config.set( 'signup', Index, 'Routes' )

View file

@ -18,7 +18,7 @@ class App.TemplateUI extends App.Controller
reload: =>
App.Template.bind 'refresh', =>
@log 'loading....'
@log 'notice', 'loading...'
@render()
App.Template.unbind 'refresh'
App.Collection.fetch( 'Template' )
@ -85,7 +85,7 @@ class App.TemplateUI extends App.Controller
# show errors in form
if errors
@log 'error new', errors
@log 'error', errors
else
ui = @
template.save(
@ -94,5 +94,5 @@ class App.TemplateUI extends App.Controller
ui.render()
error: =>
@log 'save failed!'
@log 'error', 'save failed!'
)

View file

@ -50,7 +50,7 @@ class App.TextModuleUIOld extends App.Controller
reload: =>
App.TextModule.bind 'refresh', =>
@log 'loading....'
@log 'notice', 'loading....'
@render()
App.TextModule.unbind 'refresh'
App.Collection.fetch( 'TextModule' )
@ -262,7 +262,7 @@ class App.TextModuleUIOld extends App.Controller
# show errors in form
if errors
@log 'error new', errors
@log 'error', errors
else
ui = @
text_module.save(

View file

@ -1,7 +1,6 @@
class App.TicketZoom extends App.Controller
constructor: (params) ->
super
# console.log 'zoom', params
# check authentication
return if !@authenticate()
@ -20,7 +19,7 @@ class App.TicketZoom extends App.Controller
@load(cache)
update = =>
@fetch( @ticket_id, false )
@interval( update, 120000, @key, 'ticket_zoom' )
@interval( update, 300000, @key, 'ticket_zoom' )
# fetch new data if triggered
App.Event.bind(
@ -29,7 +28,7 @@ class App.TicketZoom extends App.Controller
update = =>
if data.id.toString() is @ticket_id.toString()
ticket = App.Collection.find( 'Ticket', @ticket_id )
console.log('TRY', data.updated_at, ticket.updated_at)
@log 'notice', 'TRY', data.updated_at, ticket.updated_at
if data.updated_at isnt ticket.updated_at
@fetch( @ticket_id, false )
@delay( update, 2000, 'ticket-zoom-' + @ticket_id )
@ -69,7 +68,7 @@ class App.TicketZoom extends App.Controller
diff = difference( @autosaveLast, data )
if !@autosaveLast || ( diff && !_.isEmpty( diff ) )
@autosaveLast = data
console.log('form hash changed', diff, data)
@log 'notice', 'form hash changed', diff, data
App.TaskManager.update( @task_key, { 'state': data })
@interval( update, 10000, @id, @auto_save_key )
@ -93,7 +92,7 @@ class App.TicketZoom extends App.Controller
# trigger task notify
diff = difference( @dataLastCall.ticket, data.ticket )
console.log('diff', diff)
@log 'diff', diff
# notify if ticket changed not by my self
if !_.isEmpty(diff) && data.ticket.updated_by_id isnt @Session.all().id
@ -425,7 +424,7 @@ class Edit extends App.Controller
ticket = App.Collection.find( 'Ticket', @ticket.id )
@log 'TicketZoom', 'notice', 'update', params, ticket
@log 'notice', 'update', params, ticket
article_type = App.Collection.find( 'TicketArticleType', params['ticket_article_type_id'] )
# update ticket
@ -463,14 +462,14 @@ class Edit extends App.Controller
return if !confirm( App.i18n.translateContent('You use attachment in text but no attachment is attached. Do you want to continue?') )
ticket.load( ticket_update )
@log 'TicketZoom', 'notice', 'update ticket', ticket_update, ticket
@log 'notice', 'update ticket', ticket_update, ticket
# disable form
@formDisable(e)
errors = ticket.validate()
if errors
@log 'TicketZoom', 'error', 'update', errors
@log 'error', 'update', errors
@formEnable(e)
ticket.save(
@ -494,16 +493,16 @@ class Edit extends App.Controller
else
sender = App.Collection.findByAttribute( 'TicketArticleSender', 'name', 'Agent' )
params.ticket_article_sender_id = sender.id
@log 'TicketZoom', 'notice', 'update article', params, sender
@log 'notice', 'update article', params, sender
article.load(params)
errors = article.validate()
if errors
@log 'TicketZoom', 'error', 'update article', errors
@log 'error', 'update article', errors
article.save(
success: (r) =>
@ui.fetch( ticket.id, true )
error: (r) =>
@log 'TicketZoom', 'error', 'update article', r
@log 'error', 'update article', r
)
else
@ui.fetch( ticket.id, true )
@ -634,7 +633,6 @@ class ArticleView extends App.Controller
else if article_type.name is 'email'
@ui.el.find('[name="to"]').val(article.from)
# @log 'reply ', article, @el.find('[name="to"]')
# add quoted text if needed
selectedText = App.ClipBoard.getSelected()
@ -777,7 +775,6 @@ class TicketActionRow extends App.Controller
class TicketZoomRouter extends App.ControllerPermanent
constructor: (params) ->
super
@log 'zoom router', params
# cleanup params
clean_params =

View file

@ -45,7 +45,7 @@ class App.UserInfo extends App.Controller
user = App.Collection.find( 'User', @user_id )
if user.note isnt note
user.updateAttributes( note: note )
@log 'update', e, note, user
@log 'notice', 'update', e, note, user
edit: (e) =>
e.preventDefault()

View file

@ -2,24 +2,24 @@ class App.Config
_instance = undefined
@init: ->
_instance ?= new _Singleton
_instance ?= new _configSingleton
@get: ( key, group ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _configSingleton
_instance.get( key, group )
@set: ( key, value, group ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _configSingleton
_instance.set( key, value, group )
@_all: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _configSingleton
_instance._all()
class _Singleton
class _configSingleton
constructor: ->
@config = {}

View file

@ -1,15 +1,26 @@
class App.Log
_instance = undefined
@log: ( module, level, args... ) ->
@log: ( level, args... ) ->
if _instance == undefined
_instance ?= new _Singleton
module = @constructor.name
_instance.log( module, level, args )
@debug: ( module, level, args... ) ->
@debug: ( module, args... ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance.log( module, level, args )
_instance.log( module, 'debug', args )
@notice: ( module, args... ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance.log( module, 'notice', args )
@error: ( module, args... ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance.log( module, 'error', args )
class _Singleton
constructor: ->

View file

@ -2,25 +2,25 @@ class App.Session
_instance = undefined
@init: ->
_instance ?= new _Singleton
_instance ?= new _sessionSingleton
_instance.clear()
@get: ( key ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _sessionSingleton
_instance.get( key )
@set: ( key, value ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _sessionSingleton
_instance.set( key, value )
@all: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _sessionSingleton
_instance.all()
class _Singleton extends Spine.Module
class _sessionSingleton extends Spine.Module
@include App.Log
constructor: ->
@ -30,11 +30,11 @@ class _Singleton extends Spine.Module
@data = {}
get: ( key ) ->
@log 'Session', 'debug', key, @data[key]
@log 'debug', key, @data[key]
return @data[key]
set: ( key, value ) ->
@log 'Session', 'debug', 'set', key, value
@log 'debug', 'set', key, value
@data[key] = value
all: ->

View file

@ -1,7 +1,7 @@
class App.Auth
@login: (params) ->
App.Log.log 'Auth', 'notice', 'login', params
App.Log.notice 'Auth', 'login', params
App.Com.ajax(
id: 'login',
type: 'POST',
@ -21,7 +21,7 @@ class App.Auth
)
@loginCheck: ->
App.Log.log 'Auth', 'notice', 'loginCheck'
App.Log.notice 'Auth', 'loginCheck'
App.Com.ajax(
id: 'login_check'
async: false
@ -37,7 +37,7 @@ class App.Auth
)
@logout: ->
App.Log.log 'Auth', 'notice', 'logout'
App.Log.notice 'Auth', 'logout'
App.Com.ajax(
id: 'logout'
type: 'DELETE'
@ -52,7 +52,7 @@ class App.Auth
)
@_login: (data) ->
App.Log.log 'Auth', 'notice', '_login:success', data
App.Log.notice 'Auth', '_login:success', data
# if session is not valid
if data.error
@ -102,7 +102,7 @@ class App.Auth
@_logout: (data) ->
App.Log.log 'Auth', 'notice', '_logout'
App.Log.notice 'Auth', '_logout'
# empty session
App.Session.init()
@ -112,7 +112,7 @@ class App.Auth
App.Event.trigger( 'ui:rerender' )
@_loginError: (xhr, statusText, error) ->
App.Log.log 'Auth', 'notice', '_loginError:error'
App.Log.notice 'Auth', '_loginError:error'
# empty session
App.Session.init()

View file

@ -2,69 +2,69 @@ class App.Collection
_instance = undefined
@init: ->
_instance = new _Singleton
_instance = new _collectionSingleton
@load: ( args ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.load( args )
@reset: ( args ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.reset( args )
@find: ( type, id, callback, force ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.find( type, id, callback, force )
@get: ( args ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.get( args )
@all: ( args ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.all( args )
@deleteAll: ( type ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.deleteAll( type )
@findByAttribute: ( type, key, value ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.findByAttribute( type, key, value )
@count: ( type ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.count( type )
@fetch: ( type ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.fetch( type )
@observe: (args) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.observe(args)
@observeUnbindLevel: (level) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance.observeUnbindLevel(level)
@_observeStats: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _collectionSingleton
_instance._observeStats()
class _Singleton extends Spine.Module
class _collectionSingleton extends Spine.Module
@include App.Log
constructor: (@args) ->
@ -76,7 +76,7 @@ class _Singleton extends Spine.Module
if data.collections
for type of data.collections
@log 'Collection', 'debug', 'loadCollection:trigger', type, data.collections[type]
@log 'debug', 'loadCollection:trigger', type, data.collections[type]
@load( localStorage: data.localStorage, type: type, data: data.collections[type] )
# add trigger - bind new events
@ -86,7 +86,7 @@ class _Singleton extends Spine.Module
if data.collections
for type of data.collections
@log 'Collection', 'debug', 'resetCollection:trigger', type, data.collections[type]
@log 'debug', 'resetCollection:trigger', type, data.collections[type]
@reset( localStorage: data.localStorage, type: type, data: data.collections[type] )
# find collections to load
@ -99,14 +99,14 @@ class _Singleton extends Spine.Module
if parts[0] is 'collection'
data = App.Store.get( key )
if data && data.localStorage
@log 'Collection', 'debug', 'load INIT', data
@log 'debug', 'load INIT', data
@load( data )
reset: (params) ->
if !App[ params.type ]
@log 'Collection', 'error', 'reset', 'no such collection', params
@log 'error', 'reset', 'no such collection', params
return
@log 'Collection', 'debug', 'reset', params
@log 'debug', 'reset', params
# empty in-memory
App[ params.type ].refresh( [], { clear: true } )
@ -122,7 +122,7 @@ class _Singleton extends Spine.Module
@load(params)
load: (params) ->
@log 'Collection', 'debug', 'load', params
@log 'debug', 'load', params
return if _.isEmpty( params.data )
@ -160,9 +160,9 @@ class _Singleton extends Spine.Module
return data
else
if force
@log 'Collection', 'debug', 'find forced to load!', type, id
@log 'debug', 'find forced to load!', type, id
else
@log 'Collection', 'debug', 'find not loaded!', type, id
@log 'debug', 'find not loaded!', type, id
if callback
# execute callback if record got loaded
@ -180,7 +180,7 @@ class _Singleton extends Spine.Module
callback( data )
# fetch object
@log 'Collection', 'debug', 'loading..' + type + '..', id
@log 'debug', 'loading..' + type + '..', id
App[type].fetch( id: id )
return true
return false
@ -265,15 +265,15 @@ class _Singleton extends Spine.Module
get: (params) ->
if !App[ params.type ]
@log 'Collection', 'error', 'get', 'no such collection', params
@log 'error', 'get', 'no such collection', params
return
@log 'Collection', 'debug', 'get', params
@log 'debug', 'get', params
App[ params.type ].refresh( object, options: { clear: true } )
all: (params) ->
if !App[ params.type ]
@log 'Collection', 'error', 'all', 'no such collection', params
@log 'error', 'all', 'no such collection', params
return
all = App[ params.type ].all()
@ -301,23 +301,23 @@ class _Singleton extends Spine.Module
findByAttribute: ( type, key, value ) ->
if !App[type]
@log 'Collection', 'error', 'findByAttribute', 'no such collection', type, key, value
@log 'error', 'findByAttribute', 'no such collection', type, key, value
return
item = App[type].findByAttribute( key, value )
if !item
@log 'Collection', 'error', 'findByAttribute', 'no such item in collection', type, key, value
@log 'error', 'findByAttribute', 'no such item in collection', type, key, value
return
item
count: ( type ) ->
if !App[type]
@log 'Collection', 'error', 'count', 'no such collection', type, key, value
@log 'error', 'count', 'no such collection', type, key, value
return
App[type].count()
fetch: ( type ) ->
if !App[type]
@log 'Collection', 'error', 'fetch', 'no such collection', type, key, value
@log 'error', 'fetch', 'no such collection', type, key, value
return
App[type].fetch()
@ -394,4 +394,4 @@ class _Singleton extends Spine.Module
App[ observe.collection ].unbind( event, observe.callback )
_observeStats: ->
@observeCurrent
@observeCurrent

View file

@ -3,30 +3,30 @@ class App.Delay
@set: ( callback, timeout, key, level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _delaySingleton
_instance.set( callback, timeout, key, level )
@clear: ( key, level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _delaySingleton
_instance.clear( key, level )
@clearLevel: ( level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _delaySingleton
_instance.clearLevel( level )
@reset: ( level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _delaySingleton
_instance.reset( level )
@_all: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _delaySingleton
_instance._all()
class _Singleton extends Spine.Module
class _delaySingleton extends Spine.Module
@include App.Log
constructor: ->
@ -47,9 +47,9 @@ class _Singleton extends Spine.Module
key = Math.floor( Math.random() * 99999 )
# setTimeout
@log 'Delay', 'debug', 'set', key, timeout, level, callback
@log 'debug', 'set', key, timeout, level, callback
call = =>
@clear( key )
@clear( key )
callback()
delay_id = setTimeout( call, timeout )
@ -74,7 +74,7 @@ class _Singleton extends Spine.Module
data = @levelStack[ level ][ key.toString() ]
return if !data
@log 'Delay', 'debug', 'clear', data
@log 'debug', 'clear', data
clearTimeout( data['delay_id'] )
clearLevel: (level) ->

View file

@ -2,34 +2,34 @@ class App.Event
_instance = undefined
@init: ->
_instance = new _Singleton
_instance = new _eventSingleton
@bind: ( events, callback, level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _eventSingleton
_instance.bind( events, callback, level )
@unbind: ( events, callback, level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _eventSingleton
_instance.unbind( events, callback, level )
@trigger: ( events, data ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _eventSingleton
_instance.trigger( events, data )
@unbindLevel: (level) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _eventSingleton
_instance.unbindLevel(level)
@_allBindings: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _eventSingleton
_instance._allBindings()
class _Singleton extends Spine.Module
class _eventSingleton extends Spine.Module
@include App.Log
constructor: ->
@ -60,7 +60,7 @@ class _Singleton extends Spine.Module
}
# bind
@log 'Event', 'debug', 'bind', event, callback
@log 'debug', 'bind', event, callback
Spine.bind( event, callback )
unbind: ( events, callback, level ) ->
@ -81,14 +81,14 @@ class _Singleton extends Spine.Module
else
return item if item.event isnt event
)
@log 'Event', 'debug', 'unbind', event, callback
@log 'debug', 'unbind', event, callback
Spine.unbind( event, callback )
trigger: ( events, data ) ->
eventList = events.split(' ')
for event in eventList
@log 'Event', 'debug', 'trigger', event, data
@log 'debug', 'trigger', event, data
Spine.trigger event, data
_allBindings: ->
@eventCurrent
@eventCurrent

View file

@ -2,44 +2,44 @@ class App.i18n
_instance = undefined
@init: ( args ) ->
_instance ?= new _Singleton( args )
_instance ?= new _i18nSingleton( args )
@translateContent: ( string, args... ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _i18nSingleton
_instance.translateContent( string, args )
@translatePlain: ( string, args... ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _i18nSingleton
_instance.translatePlain( string, args )
@translateInline: ( string, args... ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _i18nSingleton
_instance.translateInline( string, args )
@translateTimestamp: ( args ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _i18nSingleton
_instance.timestamp( args )
@get: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _i18nSingleton
_instance.get()
@set: ( args ) ->
if _instance == undefined
_instance ?= new _Singleton( args )
_instance ?= new _i18nSingleton( args )
_instance.set( args )
@escape: ( args ) ->
if _instance == undefined
_instance ?= new _Singleton( args )
_instance ?= new _i18nSingleton( args )
_instance.escape( args )
class _Singleton extends Spine.Module
class _i18nSingleton extends Spine.Module
@include App.Log
constructor: ( locale ) ->
@ -67,7 +67,7 @@ class _Singleton extends Spine.Module
# update translation
return if $this.data('before') is translation_new
@log 'i18n', 'debug', 'translate Update', translation_new, $this.data, 'before'
@log 'debug', 'translate Update', translation_new, $this.data, 'before'
$this.data 'before', translation_new
# update runtime translation map
@ -155,7 +155,7 @@ class _Singleton extends Spine.Module
for arg in args
translated = translated.replace(/%s/, arg)
@log 'i18n', 'debug', 'translate', string, args, translated
@log 'debug', 'translate', string, args, translated
# return translated string
return translated

View file

@ -57,7 +57,7 @@ class App.Content extends App.Controller
do (route, callback) =>
@route(route, (params) ->
@log 'Content', 'notice', 'execute page controller', route, params
@log 'notice', 'execute page controller', route, params
# remove observers for page
App.Collection.observeUnbindLevel('page')

View file

@ -3,30 +3,30 @@ class App.Interval
@set: ( callback, timeout, key, level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _intervalSingleton
_instance.set( callback, timeout, key, level )
@clear: ( key, level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _intervalSingleton
_instance.clear( key, level )
@clearLevel: ( level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _intervalSingleton
_instance.clearLevel( level )
@reset: ( level ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _intervalSingleton
_instance.reset( level )
@_all: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _intervalSingleton
_instance._all()
class _Singleton extends Spine.Module
class _intervalSingleton extends Spine.Module
@include App.Log
constructor: ->
@ -47,7 +47,7 @@ class _Singleton extends Spine.Module
key = Math.floor( Math.random() * 99999 )
# setTimeout
@log 'Interval', 'debug', 'set', key, timeout, level, callback
@log 'debug', 'set', key, timeout, level, callback
callback()
interval_id = setInterval( callback, timeout )
@ -72,7 +72,7 @@ class _Singleton extends Spine.Module
data = @levelStack[ level ][ key.toString() ]
return if !data
@log 'Interval', 'debug', 'clear', data
@log 'debug', 'clear', data
clearInterval( data['interval_id'] )
clearLevel: (level) ->

View file

@ -1,35 +1,35 @@
class App.Store
_instance = undefined # Must be declared here to force the closure on the class
@renew: ->
_instance = new _Singleton
_instance = new _storeSingleton
@write: (key, value) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _storeSingleton
_instance.write(key, value)
@get: (args) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _storeSingleton
_instance.get(args)
@delete: (args) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _storeSingleton
_instance.delete(args)
@clear: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _storeSingleton
_instance.clear()
@list: () ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _storeSingleton
_instance.list()
# The actual Singleton class
class _Singleton
class _storeSingleton
store: {}
constructor: ->
@support = true
@ -51,7 +51,7 @@ class _Singleton
catch e
if e is QUOTA_EXCEEDED_ERR
# do something nice to notify your users
App.Log.log 'App.Store', 'error', 'Local storage quote exceeded, please relogin!'
App.Log.error 'App.Store', 'Local storage quote exceeded, please relogin!'
# get item
get: (key) ->

View file

@ -2,64 +2,64 @@ class App.TaskManager
_instance = undefined
@init: ->
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
@all: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.all()
@add: ( key, callback, params, to_not_show, state ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.add( key, callback, params, to_not_show, state )
@get: ( key ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.get( key )
@update: ( key, params ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.update( key, params )
@remove: ( key ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.remove( key )
@notify: ( key ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.notify( key )
@reorder: ( order ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.reorder( order )
@reset: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.reset()
@worker: ( key ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.worker( key )
@workerAll: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.workerAll()
@TaskbarId: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _taskManagerSingleton
_instance.TaskbarId()
class _Singleton extends App.Controller
class _taskManagerSingleton extends App.Controller
@include App.Log
constructor: ->

View file

@ -2,36 +2,36 @@ class App.WebSocket
_instance = undefined # Must be declared here to force the closure on the class
@connect: (args) -> # Must be a static method
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _webSocketSingleton
_instance
@close: (args) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _webSocketSingleton
_instance.close(args)
@send: (args) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _webSocketSingleton
_instance.send(args)
@auth: (args) ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _webSocketSingleton
_instance.auth(args)
@channel: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _webSocketSingleton
_instance.channel()
@_spool: ->
if _instance == undefined
_instance ?= new _Singleton
_instance ?= new _webSocketSingleton
_instance.spool()
# The actual Singleton class
class _Singleton extends App.Controller
class _webSocketSingleton extends App.Controller
@include App.Log
queue: []
@ -44,6 +44,7 @@ class _Singleton extends App.Controller
tryToConnect: false
backend: 'websocket'
client_id: undefined
error: false
constructor: (@args) ->
super
@ -84,8 +85,6 @@ class _Singleton extends App.Controller
@_ajaxSend(data)
else
# console.log 'ws:send trying', data, @ws, @ws.readyState
# A value of 0 indicates that the connection has not yet been established.
# A value of 1 indicates that the connection is established and communication is possible.
# A value of 2 indicates that the connection is going through the closing handshake.
@ -115,7 +114,7 @@ class _Singleton extends App.Controller
if @lastSpoolMessage
data['timestamp'] = @lastSpoolMessage
@log 'Websocket', 'debug', 'spool', data
@log 'debug', 'spool', data
# reset @sentSpoolFinished if spool:sent will not return
reset = =>
@ -139,20 +138,20 @@ class _Singleton extends App.Controller
ping: =>
return if @backend is 'ajax'
@log 'Websocket', 'debug', 'send websockend ping'
@log 'debug', 'send websockend ping'
@send( { action: 'ping' } )
# check if ping is back within 2 min
@clearDelay('websocket-ping-check', 'ws')
check = =>
@log 'Websocket', 'notice', 'no websockend ping response, reconnect...'
@log 'notice', 'no websockend ping response, reconnect...'
@close()
@delay check, 90000, 'websocket-ping-check', 'ws'
pong: ->
return if @backend is 'ajax'
@log 'Websocket', 'debug', 'received websockend ping'
@log 'debug', 'received websockend ping'
# test again after 1 min
@delay @ping, 60000, 'websocket-pong', 'ws'
@ -162,7 +161,7 @@ class _Singleton extends App.Controller
if !window.WebSocket
@backend = 'ajax'
@log 'WebSocket', 'notice', 'no support of websocket, use ajax long polling'
@log 'notice', 'no support of websocket, use ajax long polling'
@_ajaxInit()
return
@ -174,7 +173,7 @@ class _Singleton extends App.Controller
# Set event handlers.
@ws.onopen = =>
@log 'Websocket', 'notice', 'new websocket connection open'
@log 'notice', 'new websocket connection open'
@connectionEstablished = true
@connectionWasEstablished = true
@ -190,7 +189,7 @@ class _Singleton extends App.Controller
# empty queue
for item in @queue
@log 'Websocket', 'debug', 'empty ws queue', item
@log 'debug', 'empty ws queue', item
@send(item)
@queue = []
@ -199,11 +198,11 @@ class _Singleton extends App.Controller
@ws.onmessage = (e) =>
pipe = JSON.parse( e.data )
@log 'Websocket', 'debug', 'ws:onmessage', pipe
@log 'debug', 'ws:onmessage', pipe
@_receiveMessage(pipe)
@ws.onclose = (e) =>
@log 'Websocket', 'notice', 'close websocket connection'
@log 'notice', 'close websocket connection'
# take connection down and keep it down
return if @connectionKeepDown
@ -222,7 +221,7 @@ class _Singleton extends App.Controller
# use fallback if no connection was possible
if !@connectionWasEstablished
@backend = 'ajax'
@log 'WebSocket', 'notice', 'No connection to websocket, use ajax long polling as fallback'
@log 'notice', 'No connection to websocket, use ajax long polling as fallback'
@_ajaxInit()
return
@ -242,7 +241,7 @@ class _Singleton extends App.Controller
@delay @connect, 4500, 'websocket-try-reconnect-after-x-sec', 'ws'
@ws.onerror = (e) =>
@log 'Websocket', 'debug', "ws:onerror", e
@log 'debug', "ws:onerror", e
_receiveMessage: (data = []) =>
@ -255,17 +254,17 @@ class _Singleton extends App.Controller
# fill collection
if item['collection']
@log 'Websocket', 'debug', "onmessage collection:" + item['collection']
@log 'debug', "onmessage collection:" + item['collection']
App.Store.write( item['collection'], item['data'] )
# fire event
if item['event']
if typeof item['event'] is 'object'
for event in item['event']
@log 'Websocket', 'debug', "onmessage event:" + event
@log 'debug', "onmessage event:" + event
App.Event.trigger( event, item['data'] )
else
@log 'Websocket', 'debug', "onmessage event:" + item['event']
@log 'debug', "onmessage event:" + item['event']
App.Event.trigger( item['event'], item['data'] )
_ajaxInit: (data = {}) =>
@ -285,7 +284,7 @@ class _Singleton extends App.Controller
queue: false
success: (data) =>
if data.client_id
@log 'Websocket', 'notice', 'ajax:new client_id', data.client_id
@log 'notice', 'ajax:new client_id', data.client_id
@client_id = data.client_id
@_ajaxReceive()
@_ajaxSendQueue()
@ -302,7 +301,7 @@ class _Singleton extends App.Controller
)
_ajaxSend: (data) =>
@log 'Websocket', 'debug', 'ajax:sendmessage', data
@log 'debug', 'ajax:sendmessage', data
if !@client_id || @client_id is undefined || !@_ajaxInitDone
@_ajaxInit()
@queue.push data
@ -339,7 +338,7 @@ class _Singleton extends App.Controller
data: JSON.stringify({ client_id: @client_id })
processData: false
success: (data) =>
@log 'Websocket', 'notice', 'ajax:onmessage', data
@log 'notice', 'ajax:onmessage', data
@_receiveMessage(data)
if data && data.error
@client_id = undefined

View file

@ -1,4 +1,4 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
# Copyright (C) 2013-2013 Zammad Foundation, http://zammad-foundation.org/
require 'cache'
require 'user_info'
@ -15,12 +15,12 @@ class ApplicationModel < ActiveRecord::Base
@@import_class_list = ['Ticket', 'Ticket::Article', 'History', 'Ticket::State', 'Ticket::Priority', 'Group', 'User' ]
# for import other objects, remove 'id'
# for import of other objects, remove 'id'
def self.attributes_protected_by_default
if Setting.get('import_mode') && @@import_class_list.include?( self.name.to_s )
['type']
else
['id','type']
['id','type', 'created_at', 'updated_at']
end
end