Merge branch 'develop' into feature/ui2

This commit is contained in:
Martin Edenhofer 2013-08-21 21:40:18 +02:00
commit 1dc7545075
42 changed files with 349 additions and 367 deletions

View file

@ -120,6 +120,8 @@ class Taskbar extends App.Controller
tasks = App.TaskManager.all() tasks = App.TaskManager.all()
item_list = [] item_list = []
for task in tasks for task in tasks
# collect meta data of task for task bar item
data = data =
url: '#' url: '#'
id: false id: false
@ -128,8 +130,13 @@ class Taskbar extends App.Controller
worker = App.TaskManager.worker( task.key ) worker = App.TaskManager.worker( task.key )
if worker if worker
meta = worker.meta() meta = worker.meta()
# apply meta data of controller
if meta if meta
data = meta for key, value of meta
data[key] = value
# collect new task bar items
item = {} item = {}
item.task = task item.task = task
item.data = data item.data = data

View file

@ -35,16 +35,16 @@ class App.TicketZoom extends App.Controller
) )
meta: => meta: =>
return if !@ticket
ticket = App.Ticket.retrieve( @ticket.id )
meta = meta =
url: @url() url: @url()
head: ticket.title id: @ticket_id
title: '#' + ticket.number + ' - ' + ticket.title if @ticket
id: ticket.id meta.head = @ticket.title
meta.title = '#' + @ticket.number + ' - ' + @ticket.title
meta
url: => url: =>
'#ticket/zoom/' + @ticket.id '#ticket/zoom/' + @ticket_id
activate: => activate: =>
@navupdate '#' @navupdate '#'
@ -106,9 +106,6 @@ class App.TicketZoom extends App.Controller
load: (data, force) => load: (data, force) =>
# reset old indexes
@ticket = undefined
# remember article ids # remember article ids
@ticket_article_ids = data.ticket_article_ids @ticket_article_ids = data.ticket_article_ids
@ -121,14 +118,14 @@ class App.TicketZoom extends App.Controller
# load collections # load collections
App.Event.trigger 'loadAssets', data.assets App.Event.trigger 'loadAssets', data.assets
# get data
@ticket = App.Ticket.retrieve( @ticket_id )
# render page # render page
@render(force) @render(force)
render: (force) => render: (force) =>
# get data
@ticket = App.Ticket.retrieve( @ticket_id )
# update taskbar with new meta data # update taskbar with new meta data
App.Event.trigger 'task:render' App.Event.trigger 'task:render'
if !@renderDone if !@renderDone

View file

@ -29,10 +29,10 @@ class _trackSingleton
@log( 'start', 'notice', {} ) @log( 'start', 'notice', {} )
# start initial submit 10 sec. later to avoid ie10 cookie issues # start initial submit 30 sec. later to avoid ie10 cookie issues
delay = => delay = =>
App.Interval.set @send, 60000 App.Interval.set @send, 80000
App.Delay.set delay, 10000 App.Delay.set delay, 30000
# log clicks # log clicks
$(document).bind( $(document).bind(
@ -139,9 +139,15 @@ class _trackSingleton
@data @data
` `
(function() {
window.onerrorOld = window.onerror
window.onerror = function(errorMsg, url, lineNumber) { window.onerror = function(errorMsg, url, lineNumber) {
console.error(errorMsg + " - in " + url + ", line " + lineNumber); console.error(errorMsg + " - in " + url + ", line " + lineNumber);
}; if (window.onerrorOld) {
window.onerrorOld(errorMsg, url, lineNumber);
}
}
}).call(this);
(function() { (function() {
var console = window.console var console = window.console

View file

@ -83,6 +83,10 @@ class App.Auth
for key, value of data.session for key, value of data.session
App.Session.set( key, value ) App.Session.set( key, value )
# refresh default collections
for key, value of data.default_collections
App[key].refresh( value, options: { clear: true } )
App.Event.trigger( 'auth', data.session ) App.Event.trigger( 'auth', data.session )
# init of i18n # init of i18n
@ -93,10 +97,6 @@ class App.Auth
locale = window.navigator.userLanguage || window.navigator.language || 'en' locale = window.navigator.userLanguage || window.navigator.language || 'en'
App.i18n.set( locale ) App.i18n.set( locale )
# refresh default collections
for key, value of data.default_collections
App[key].refresh( value, options: { clear: true } )
App.Event.trigger( 'auth:login', data.session ) App.Event.trigger( 'auth:login', data.session )
App.Event.trigger( 'ui:rerender' ) App.Event.trigger( 'ui:rerender' )

View file

@ -375,11 +375,11 @@ class _taskManagerSingleton extends App.Controller
for task in @allTasks for task in @allTasks
task_count += 1 task_count += 1
console.log('START', task) console.log('START', task)
do (task) =>
App.Delay.set( App.Delay.set(
=> =>
task = tasks.shift()
@add(task.key, task.callback, task.params, true) @add(task.key, task.callback, task.params, true)
task_count * 300 task_count * 900
undefined undefined
'task' 'task'
) )

View file

@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base
:mode_show_rendeder, :mode_show_rendeder,
:model_index_render :model_index_render
before_filter :set_user, :session_update before_filter :log_request, :set_user, :session_update
before_filter :cors_preflight_check before_filter :cors_preflight_check
after_filter :set_access_control_headers after_filter :set_access_control_headers
@ -52,6 +52,10 @@ class ApplicationController < ActionController::Base
Observer::Ticket::Notification.transaction Observer::Ticket::Notification.transaction
end end
def log_request
puts Time.now().to_s + ' ' + request.original_fullpath.to_s
end
# Finds the User with the ID stored in the session with the key # Finds the User with the ID stored in the session with the key
# :current_user_id This is a common way to handle user login in # :current_user_id This is a common way to handle user login in
# a Rails application; logging in sets the session value and # a Rails application; logging in sets the session value and

View file

@ -26,7 +26,7 @@ class LongPollingController < ApplicationController
# spool messages for new connects # spool messages for new connects
if params['data']['spool'] if params['data']['spool']
msg = JSON.generate( params['data'] ) msg = JSON.generate( params['data'] )
Session.spool_create(msg) Sessions.spool_create(msg)
end end
# get spool messages and send them to new client connection # get spool messages and send them to new client connection
@ -40,14 +40,14 @@ class LongPollingController < ApplicationController
end end
if current_user if current_user
spool = Session.spool_list( params['data']['timestamp'], current_user.id ) spool = Sessions.spool_list( params['data']['timestamp'], current_user.id )
spool.each { |item| spool.each { |item|
if item[:type] == 'direct' if item[:type] == 'direct'
log 'notice', "send spool to (user_id=#{ current_user.id })", client_id log 'notice', "send spool to (user_id=#{ current_user.id })", client_id
Session.send( client_id, item[:message] ) Sessions.send( client_id, item[:message] )
else else
log 'notice', "send spool", client_id log 'notice', "send spool", client_id
Session.send( client_id, item[:message] ) Sessions.send( client_id, item[:message] )
end end
} }
end end
@ -55,7 +55,7 @@ class LongPollingController < ApplicationController
# send spool:sent event to client # send spool:sent event to client
sleep 0.2 sleep 0.2
log 'notice', "send spool:sent event", client_id log 'notice', "send spool:sent event", client_id
Session.send( client_id, { :event => 'spool:sent', :data => { :timestamp => Time.now.utc.to_i } } ) Sessions.send( client_id, { :event => 'spool:sent', :data => { :timestamp => Time.now.utc.to_i } } )
end end
@ -67,13 +67,13 @@ class LongPollingController < ApplicationController
user = User.user_data_full( user_id ) user = User.user_data_full( user_id )
end end
log 'notice', "send auth login (user_id #{user_id})", client_id log 'notice', "send auth login (user_id #{user_id})", client_id
Session.create( client_id, user, { :type => 'ajax' } ) Sessions.create( client_id, user, { :type => 'ajax' } )
# broadcast # broadcast
elsif params['data']['action'] == 'broadcast' elsif params['data']['action'] == 'broadcast'
# list all current clients # list all current clients
client_list = Session.list client_list = Sessions.list
client_list.each {|local_client_id, local_client| client_list.each {|local_client_id, local_client|
if local_client_id != client_id if local_client_id != client_id
@ -82,13 +82,13 @@ class LongPollingController < ApplicationController
params['data']['recipient']['user_id'].each { |user_id| params['data']['recipient']['user_id'].each { |user_id|
if local_client[:user][:id] == user_id if local_client[:user][:id] == user_id
log 'notice', "send broadcast from (#{client_id.to_s}) to (user_id #{user_id})", local_client_id log 'notice', "send broadcast from (#{client_id.to_s}) to (user_id #{user_id})", local_client_id
Session.send( local_client_id, params['data'] ) Sessions.send( local_client_id, params['data'] )
end end
} }
# broadcast every client # broadcast every client
else else
log 'notice', "send broadcast from (#{client_id.to_s})", local_client_id log 'notice', "send broadcast from (#{client_id.to_s})", local_client_id
Session.send( local_client_id, params['data'] ) Sessions.send( local_client_id, params['data'] )
end end
else else
log 'notice', "do not send broadcast to it self", client_id log 'notice', "do not send broadcast to it self", client_id
@ -119,13 +119,13 @@ class LongPollingController < ApplicationController
# update last ping # update last ping
sleep 1 sleep 1
Session.touch( client_id ) Sessions.touch( client_id )
# set max loop time to 24 sec. because of 30 sec. timeout of mod_proxy # set max loop time to 24 sec. because of 30 sec. timeout of mod_proxy
count = 12 count = 12
while true while true
count = count - 1 count = count - 1
queue = Session.queue( client_id ) queue = Sessions.queue( client_id )
if queue && queue[0] if queue && queue[0]
# puts "send " + queue.inspect + client_id.to_s # puts "send " + queue.inspect + client_id.to_s
render :json => queue render :json => queue
@ -155,7 +155,7 @@ class LongPollingController < ApplicationController
end end
def client_id_verify def client_id_verify
return if !params[:client_id] return if !params[:client_id]
sessions = Session.sessions sessions = Sessions.sessions
return if !sessions.include?( params[:client_id].to_s ) return if !sessions.include?( params[:client_id].to_s )
return true return true
end end

View file

@ -1,5 +1,7 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'ticket/overviews'
class TicketOverviewsController < ApplicationController class TicketOverviewsController < ApplicationController
before_filter :authentication_check before_filter :authentication_check

View file

@ -2,7 +2,7 @@
require 'cache' require 'cache'
require 'user_info' require 'user_info'
require 'session' require 'sessions'
class ApplicationModel < ActiveRecord::Base class ApplicationModel < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
@ -340,7 +340,7 @@ class OwnModel < ApplicationModel
class_name = self.class.name class_name = self.class.name
class_name.gsub!(/::/, '') class_name.gsub!(/::/, '')
Session.broadcast( Sessions.broadcast(
:event => class_name + ':created', :event => class_name + ':created',
:data => { :id => self.id, :updated_at => self.updated_at } :data => { :id => self.id, :updated_at => self.updated_at }
) )
@ -368,7 +368,7 @@ class OwnModel < ApplicationModel
puts "#{self.class.name.downcase} UPDATED " + self.updated_at.to_s puts "#{self.class.name.downcase} UPDATED " + self.updated_at.to_s
class_name = self.class.name class_name = self.class.name
class_name.gsub!(/::/, '') class_name.gsub!(/::/, '')
Session.broadcast( Sessions.broadcast(
:event => class_name + ':updated', :event => class_name + ':updated',
:data => { :id => self.id, :updated_at => self.updated_at } :data => { :id => self.id, :updated_at => self.updated_at }
) )
@ -395,7 +395,7 @@ class OwnModel < ApplicationModel
puts "#{self.class.name.downcase} DESTOY " + self.updated_at.to_s puts "#{self.class.name.downcase} DESTOY " + self.updated_at.to_s
class_name = self.class.name class_name = self.class.name
class_name.gsub!(/::/, '') class_name.gsub!(/::/, '')
Session.broadcast( Sessions.broadcast(
:event => class_name + ':destroy', :event => class_name + ':destroy',
:data => { :id => self.id, :updated_at => self.updated_at } :data => { :id => self.id, :updated_at => self.updated_at }
) )

View file

@ -82,5 +82,8 @@ module Zammad
# Enable threaded mode # Enable threaded mode
config.threadsafe! config.threadsafe!
# catch all router files
config.paths['config/routes'] += Dir[Rails.root.join("config/routes/*.rb")]
end end
end end

View file

@ -8,11 +8,4 @@ Zammad::Application.routes.draw do
# just remember to delete public/index.html. # just remember to delete public/index.html.
root :to => 'init#index', :via => :get root :to => 'init#index', :via => :get
# load routes from external files
dir = File.expand_path('../', __FILE__)
files = Dir.glob( "#{dir}/routes/*.rb" )
for file in files
require file
ExtraRoutes.add(self, Rails.configuration.api_path)
end
end end

View file

@ -1,8 +1,6 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
map.match api_path + '/activity_stream', :to => 'activity#activity_stream', :via => :get match api_path + '/activity_stream', :to => 'activity#activity_stream', :via => :get
end end
module_function :add
end

View file

@ -1,19 +1,18 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# omniauth # omniauth
map.match '/auth/:provider/callback', :to => 'sessions#create_omniauth',:via => [:post, :get, :puts, :delete] match '/auth/:provider/callback', :to => 'sessions#create_omniauth',:via => [:post, :get, :puts, :delete]
# sso # sso
map.match '/auth/sso', :to => 'sessions#create_sso', :via => [:post, :get] match '/auth/sso', :to => 'sessions#create_sso', :via => [:post, :get]
# sessions # sessions
map.match api_path + '/signin', :to => 'sessions#create', :via => :post match api_path + '/signin', :to => 'sessions#create', :via => :post
map.match api_path + '/signshow', :to => 'sessions#show', :via => :get match api_path + '/signshow', :to => 'sessions#show', :via => :get
map.match api_path + '/signout', :to => 'sessions#destroy', :via => [:get, :delete] match api_path + '/signout', :to => 'sessions#destroy', :via => [:get, :delete]
match api_path + '/sessions', :to => 'sessions#list', :via => :get
match api_path + '/sessions/:id', :to => 'sessions#delete', :via => :delete
map.match api_path + '/sessions', :to => 'sessions#list', :via => :get
map.match api_path + '/sessions/:id', :to => 'sessions#delete', :via => :delete
end
module_function :add
end end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# channels # channels
map.match api_path + '/channels', :to => 'channels#index', :via => :get match api_path + '/channels', :to => 'channels#index', :via => :get
map.match api_path + '/channels/:id', :to => 'channels#show', :via => :get match api_path + '/channels/:id', :to => 'channels#show', :via => :get
map.match api_path + '/channels', :to => 'channels#create', :via => :post match api_path + '/channels', :to => 'channels#create', :via => :post
map.match api_path + '/channels/:id', :to => 'channels#update', :via => :put match api_path + '/channels/:id', :to => 'channels#update', :via => :put
map.match api_path + '/channels/:id', :to => 'channels#destroy', :via => :delete match api_path + '/channels/:id', :to => 'channels#destroy', :via => :delete
end end
module_function :add
end

View file

@ -1,12 +1,10 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# groups # groups
map.match api_path + '/email_addresses', :to => 'email_addresses#index', :via => :get match api_path + '/email_addresses', :to => 'email_addresses#index', :via => :get
map.match api_path + '/email_addresses/:id', :to => 'email_addresses#show', :via => :get match api_path + '/email_addresses/:id', :to => 'email_addresses#show', :via => :get
map.match api_path + '/email_addresses', :to => 'email_addresses#create', :via => :post match api_path + '/email_addresses', :to => 'email_addresses#create', :via => :post
map.match api_path + '/email_addresses/:id', :to => 'email_addresses#update', :via => :put match api_path + '/email_addresses/:id', :to => 'email_addresses#update', :via => :put
end end
module_function :add
end

View file

@ -1,9 +1,7 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# getting_started # getting_started
map.match api_path + '/getting_started', :to => 'getting_started#index', :via => :get match api_path + '/getting_started', :to => 'getting_started#index', :via => :get
end end
module_function :add
end

View file

@ -1,12 +1,10 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# groups # groups
map.match api_path + '/groups', :to => 'groups#index', :via => :get match api_path + '/groups', :to => 'groups#index', :via => :get
map.match api_path + '/groups/:id', :to => 'groups#show', :via => :get match api_path + '/groups/:id', :to => 'groups#show', :via => :get
map.match api_path + '/groups', :to => 'groups#create', :via => :post match api_path + '/groups', :to => 'groups#create', :via => :post
map.match api_path + '/groups/:id', :to => 'groups#update', :via => :put match api_path + '/groups/:id', :to => 'groups#update', :via => :put
end end
module_function :add
end

View file

@ -1,11 +1,9 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# links # links
map.match api_path + '/links', :to => 'links#index', :via => :get match api_path + '/links', :to => 'links#index', :via => :get
map.match api_path + '/links/add', :to => 'links#add', :via => :get match api_path + '/links/add', :to => 'links#add', :via => :get
map.match api_path + '/links/remove', :to => 'links#remove', :via => :get match api_path + '/links/remove', :to => 'links#remove', :via => :get
end end
module_function :add
end

View file

@ -1,10 +1,8 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# messages # messages
map.match api_path + '/message_send', :to => 'long_polling#message_send', :via => [ :get, :post ] match api_path + '/message_send', :to => 'long_polling#message_send', :via => [ :get, :post ]
map.match api_path + '/message_receive', :to => 'long_polling#message_receive', :via => [ :get, :post ] match api_path + '/message_receive', :to => 'long_polling#message_receive', :via => [ :get, :post ]
end end
module_function :add
end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# networkss # networkss
map.match api_path + '/networks', :to => 'networks#index', :via => :get match api_path + '/networks', :to => 'networks#index', :via => :get
map.match api_path + '/networks/:id', :to => 'networks#show', :via => :get match api_path + '/networks/:id', :to => 'networks#show', :via => :get
map.match api_path + '/networks', :to => 'networks#create', :via => :post match api_path + '/networks', :to => 'networks#create', :via => :post
map.match api_path + '/networks/:id', :to => 'networks#update', :via => :put match api_path + '/networks/:id', :to => 'networks#update', :via => :put
map.match api_path + '/networks/:id', :to => 'networks#destroy',:via => :delete match api_path + '/networks/:id', :to => 'networks#destroy',:via => :delete
end end
module_function :add
end

View file

@ -1,12 +1,10 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# organizations # organizations
map.match api_path + '/organizations', :to => 'organizations#index', :via => :get match api_path + '/organizations', :to => 'organizations#index', :via => :get
map.match api_path + '/organizations/:id', :to => 'organizations#show', :via => :get match api_path + '/organizations/:id', :to => 'organizations#show', :via => :get
map.match api_path + '/organizations', :to => 'organizations#create', :via => :post match api_path + '/organizations', :to => 'organizations#create', :via => :post
map.match api_path + '/organizations/:id', :to => 'organizations#update', :via => :put match api_path + '/organizations/:id', :to => 'organizations#update', :via => :put
end end
module_function :add
end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# overviews # overviews
map.match api_path + '/overviews', :to => 'overviews#index', :via => :get match api_path + '/overviews', :to => 'overviews#index', :via => :get
map.match api_path + '/overviews/:id', :to => 'overviews#show', :via => :get match api_path + '/overviews/:id', :to => 'overviews#show', :via => :get
map.match api_path + '/overviews', :to => 'overviews#create', :via => :post match api_path + '/overviews', :to => 'overviews#create', :via => :post
map.match api_path + '/overviews/:id', :to => 'overviews#update', :via => :put match api_path + '/overviews/:id', :to => 'overviews#update', :via => :put
map.match api_path + '/overviews/:id', :to => 'overviews#destroy', :via => :delete match api_path + '/overviews/:id', :to => 'overviews#destroy', :via => :delete
end end
module_function :add
end

View file

@ -1,11 +1,9 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# overviews # overviews
map.match api_path + '/packages', :to => 'packages#index', :via => :get match api_path + '/packages', :to => 'packages#index', :via => :get
map.match api_path + '/packages', :to => 'packages#install', :via => :post match api_path + '/packages', :to => 'packages#install', :via => :post
map.match api_path + '/packages', :to => 'packages#uninstall', :via => :delete match api_path + '/packages', :to => 'packages#uninstall', :via => :delete
end end
module_function :add
end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# postmaster_filters # postmaster_filters
map.match api_path + '/postmaster_filters', :to => 'postmaster_filters#index', :via => :get match api_path + '/postmaster_filters', :to => 'postmaster_filters#index', :via => :get
map.match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#show', :via => :get match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#show', :via => :get
map.match api_path + '/postmaster_filters', :to => 'postmaster_filters#create', :via => :post match api_path + '/postmaster_filters', :to => 'postmaster_filters#create', :via => :post
map.match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#update', :via => :put match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#update', :via => :put
map.match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#destroy', :via => :delete match api_path + '/postmaster_filters/:id', :to => 'postmaster_filters#destroy', :via => :delete
end end
module_function :add
end

View file

@ -1,8 +1,5 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
map.match api_path + '/recent_viewed', :to => 'recent_viewed#recent_viewed', :via => :get
end match api_path + '/recent_viewed', :to => 'recent_viewed#recent_viewed', :via => :get
module_function :add
end end

View file

@ -1,12 +1,10 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# roles # roles
map.match api_path + '/roles', :to => 'roles#index', :via => :get match api_path + '/roles', :to => 'roles#index', :via => :get
map.match api_path + '/roles/:id', :to => 'roles#show', :via => :get match api_path + '/roles/:id', :to => 'roles#show', :via => :get
map.match api_path + '/roles', :to => 'roles#create', :via => :post match api_path + '/roles', :to => 'roles#create', :via => :post
map.match api_path + '/roles/:id', :to => 'roles#update', :via => :put match api_path + '/roles/:id', :to => 'roles#update', :via => :put
end end
module_function :add
end

View file

@ -1,9 +1,7 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# rss # rss
map.match api_path + '/rss_fetch', :to => 'rss#fetch', :via => :get match api_path + '/rss_fetch', :to => 'rss#fetch', :via => :get
end end
module_function :add
end

View file

@ -1,9 +1,7 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# search # search
map.match api_path + '/search', :to => 'search#search', :via => [:get, :post] match api_path + '/search', :to => 'search#search', :via => [:get, :post]
end end
module_function :add
end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# base objects # base objects
map.match api_path + '/settings', :to => 'settings#index', :via => :get match api_path + '/settings', :to => 'settings#index', :via => :get
map.match api_path + '/settings/:id', :to => 'settings#show', :via => :get match api_path + '/settings/:id', :to => 'settings#show', :via => :get
map.match api_path + '/settings', :to => 'settings#create', :via => :post match api_path + '/settings', :to => 'settings#create', :via => :post
map.match api_path + '/settings/:id', :to => 'settings#update', :via => :put match api_path + '/settings/:id', :to => 'settings#update', :via => :put
map.match api_path + '/settings/:id', :to => 'settings#destroy', :via => :delete match api_path + '/settings/:id', :to => 'settings#destroy', :via => :delete
end end
module_function :add
end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# signatures # signatures
map.match api_path + '/signatures', :to => 'signatures#index', :via => :get match api_path + '/signatures', :to => 'signatures#index', :via => :get
map.match api_path + '/signatures/:id', :to => 'signatures#show', :via => :get match api_path + '/signatures/:id', :to => 'signatures#show', :via => :get
map.match api_path + '/signatures', :to => 'signatures#create', :via => :post match api_path + '/signatures', :to => 'signatures#create', :via => :post
map.match api_path + '/signatures/:id', :to => 'signatures#update', :via => :put match api_path + '/signatures/:id', :to => 'signatures#update', :via => :put
map.match api_path + '/signatures/:id', :to => 'signatures#destroy', :via => :delete match api_path + '/signatures/:id', :to => 'signatures#destroy', :via => :delete
end end
module_function :add
end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# slas # slas
map.match api_path + '/slas', :to => 'slas#index', :via => :get match api_path + '/slas', :to => 'slas#index', :via => :get
map.match api_path + '/slas/:id', :to => 'slas#show', :via => :get match api_path + '/slas/:id', :to => 'slas#show', :via => :get
map.match api_path + '/slas', :to => 'slas#create', :via => :post match api_path + '/slas', :to => 'slas#create', :via => :post
map.match api_path + '/slas/:id', :to => 'slas#update', :via => :put match api_path + '/slas/:id', :to => 'slas#update', :via => :put
map.match api_path + '/slas/:id', :to => 'slas#destroy', :via => :delete match api_path + '/slas/:id', :to => 'slas#destroy', :via => :delete
end end
module_function :add
end

View file

@ -1,11 +1,9 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# links # links
map.match api_path + '/tags', :to => 'tags#list', :via => :get match api_path + '/tags', :to => 'tags#list', :via => :get
map.match api_path + '/tags/add', :to => 'tags#add', :via => :get match api_path + '/tags/add', :to => 'tags#add', :via => :get
map.match api_path + '/tags/remove', :to => 'tags#remove', :via => :get match api_path + '/tags/remove', :to => 'tags#remove', :via => :get
end end
module_function :add
end

View file

@ -1,10 +1,10 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
map.match api_path + '/taskbar', :to => 'taskbar#index', :via => :get
map.match api_path + '/taskbar/:id', :to => 'taskbar#show', :via => :get match api_path + '/taskbar', :to => 'taskbar#index', :via => :get
map.match api_path + '/taskbar', :to => 'taskbar#create', :via => :post match api_path + '/taskbar/:id', :to => 'taskbar#show', :via => :get
map.match api_path + '/taskbar/:id', :to => 'taskbar#update', :via => :put match api_path + '/taskbar', :to => 'taskbar#create', :via => :post
map.match api_path + '/taskbar/:id', :to => 'taskbar#destroy',:via => :delete match api_path + '/taskbar/:id', :to => 'taskbar#update', :via => :put
end match api_path + '/taskbar/:id', :to => 'taskbar#destroy',:via => :delete
module_function :add
end end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# templates # templates
map.match api_path + '/templates', :to => 'templates#index', :via => :get match api_path + '/templates', :to => 'templates#index', :via => :get
map.match api_path + '/templates/:id', :to => 'templates#show', :via => :get match api_path + '/templates/:id', :to => 'templates#show', :via => :get
map.match api_path + '/templates', :to => 'templates#create', :via => :post match api_path + '/templates', :to => 'templates#create', :via => :post
map.match api_path + '/templates/:id', :to => 'templates#update', :via => :put match api_path + '/templates/:id', :to => 'templates#update', :via => :put
map.match api_path + '/templates/:id', :to => 'templates#destroy', :via => :delete match api_path + '/templates/:id', :to => 'templates#destroy', :via => :delete
end end
module_function :add
end

View file

@ -1,10 +1,7 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path)
map.match '/tests-core', :to => 'tests#core', :via => :get match '/tests-core', :to => 'tests#core', :via => :get
map.match '/tests-form', :to => 'tests#form', :via => :get match '/tests-form', :to => 'tests#form', :via => :get
map.match '/tests/wait/:sec', :to => 'tests#wait', :via => :get match '/tests/wait/:sec', :to => 'tests#wait', :via => :get
end end
module_function :add
end

View file

@ -1,13 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# text_modules # text_modules
map.match api_path + '/text_modules', :to => 'text_modules#index', :via => :get match api_path + '/text_modules', :to => 'text_modules#index', :via => :get
map.match api_path + '/text_modules/:id', :to => 'text_modules#show', :via => :get match api_path + '/text_modules/:id', :to => 'text_modules#show', :via => :get
map.match api_path + '/text_modules', :to => 'text_modules#create', :via => :post match api_path + '/text_modules', :to => 'text_modules#create', :via => :post
map.match api_path + '/text_modules/:id', :to => 'text_modules#update', :via => :put match api_path + '/text_modules/:id', :to => 'text_modules#update', :via => :put
map.match api_path + '/text_modules/:id', :to => 'text_modules#destroy', :via => :delete match api_path + '/text_modules/:id', :to => 'text_modules#destroy', :via => :delete
end end
module_function :add
end

View file

@ -1,43 +1,41 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# tickets # tickets
map.match api_path + '/tickets/search', :to => 'tickets#search', :via => [:get, :post] match api_path + '/tickets/search', :to => 'tickets#search', :via => [:get, :post]
map.match api_path + '/tickets', :to => 'tickets#index', :via => :get match api_path + '/tickets', :to => 'tickets#index', :via => :get
map.match api_path + '/tickets/:id', :to => 'tickets#show', :via => :get match api_path + '/tickets/:id', :to => 'tickets#show', :via => :get
map.match api_path + '/tickets', :to => 'tickets#create', :via => :post match api_path + '/tickets', :to => 'tickets#create', :via => :post
map.match api_path + '/tickets/:id', :to => 'tickets#update', :via => :put match api_path + '/tickets/:id', :to => 'tickets#update', :via => :put
map.match api_path + '/ticket_create', :to => 'tickets#ticket_create', :via => :get match api_path + '/ticket_create', :to => 'tickets#ticket_create', :via => :get
map.match api_path + '/ticket_full/:id', :to => 'tickets#ticket_full', :via => :get match api_path + '/ticket_full/:id', :to => 'tickets#ticket_full', :via => :get
map.match api_path + '/ticket_history/:id', :to => 'tickets#ticket_history', :via => :get match api_path + '/ticket_history/:id', :to => 'tickets#ticket_history', :via => :get
map.match api_path + '/ticket_customer', :to => 'tickets#ticket_customer', :via => :get match api_path + '/ticket_customer', :to => 'tickets#ticket_customer', :via => :get
map.match api_path + '/ticket_merge_list/:ticket_id', :to => 'tickets#ticket_merge_list', :via => :get match api_path + '/ticket_merge_list/:ticket_id', :to => 'tickets#ticket_merge_list', :via => :get
map.match api_path + '/ticket_merge/:slave_ticket_id/:master_ticket_number', :to => 'tickets#ticket_merge', :via => :get match api_path + '/ticket_merge/:slave_ticket_id/:master_ticket_number', :to => 'tickets#ticket_merge', :via => :get
# ticket overviews # ticket overviews
map.match api_path + '/ticket_overviews', :to => 'ticket_overviews#show', :via => :get match api_path + '/ticket_overviews', :to => 'ticket_overviews#show', :via => :get
# ticket priority # ticket priority
map.match api_path + '/ticket_priorities', :to => 'ticket_priorities#index', :via => :get match api_path + '/ticket_priorities', :to => 'ticket_priorities#index', :via => :get
map.match api_path + '/ticket_priorities/:id', :to => 'ticket_priorities#show', :via => :get match api_path + '/ticket_priorities/:id', :to => 'ticket_priorities#show', :via => :get
map.match api_path + '/ticket_priorities', :to => 'ticket_priorities#create', :via => :post match api_path + '/ticket_priorities', :to => 'ticket_priorities#create', :via => :post
map.match api_path + '/ticket_priorities/:id', :to => 'ticket_priorities#update', :via => :put match api_path + '/ticket_priorities/:id', :to => 'ticket_priorities#update', :via => :put
# ticket state # ticket state
map.match api_path + '/ticket_states', :to => 'ticket_states#index', :via => :get match api_path + '/ticket_states', :to => 'ticket_states#index', :via => :get
map.match api_path + '/ticket_states/:id', :to => 'ticket_states#show', :via => :get match api_path + '/ticket_states/:id', :to => 'ticket_states#show', :via => :get
map.match api_path + '/ticket_states', :to => 'ticket_states#create', :via => :post match api_path + '/ticket_states', :to => 'ticket_states#create', :via => :post
map.match api_path + '/ticket_states/:id', :to => 'ticket_states#update', :via => :put match api_path + '/ticket_states/:id', :to => 'ticket_states#update', :via => :put
# ticket articles # ticket articles
map.match api_path + '/ticket_articles', :to => 'ticket_articles#index', :via => :get match api_path + '/ticket_articles', :to => 'ticket_articles#index', :via => :get
map.match api_path + '/ticket_articles/:id', :to => 'ticket_articles#show', :via => :get match api_path + '/ticket_articles/:id', :to => 'ticket_articles#show', :via => :get
map.match api_path + '/ticket_articles', :to => 'ticket_articles#create', :via => :post match api_path + '/ticket_articles', :to => 'ticket_articles#create', :via => :post
map.match api_path + '/ticket_articles/:id', :to => 'ticket_articles#update', :via => :put match api_path + '/ticket_articles/:id', :to => 'ticket_articles#update', :via => :put
map.match api_path + '/ticket_attachment/:ticket_id/:article_id/:id', :to => 'ticket_articles#attachment', :via => :get match api_path + '/ticket_attachment/:ticket_id/:article_id/:id', :to => 'ticket_articles#attachment', :via => :get
map.match api_path + '/ticket_attachment_new', :to => 'ticket_articles#attachment_new', :via => :post match api_path + '/ticket_attachment_new', :to => 'ticket_articles#attachment_new', :via => :post
map.match api_path + '/ticket_article_plain/:id', :to => 'ticket_articles#article_plain', :via => :get match api_path + '/ticket_article_plain/:id', :to => 'ticket_articles#article_plain', :via => :get
end end
module_function :add
end

View file

@ -1,12 +1,11 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
map.match api_path + '/translations', :to => 'translations#index', :via => :get
map.match api_path + '/translations/:id', :to => 'translations#show', :via => :get
map.match api_path + '/translations', :to => 'translations#create', :via => :post
map.match api_path + '/translations/:id', :to => 'translations#update', :via => :put
map.match api_path + '/translations/:id', :to => 'translations#destroy', :via => :delete
map.match api_path + '/translations/lang/:locale', :to => 'translations#load', :via => :get match api_path + '/translations', :to => 'translations#index', :via => :get
end match api_path + '/translations/:id', :to => 'translations#show', :via => :get
module_function :add match api_path + '/translations', :to => 'translations#create', :via => :post
match api_path + '/translations/:id', :to => 'translations#update', :via => :put
match api_path + '/translations/:id', :to => 'translations#destroy', :via => :delete
match api_path + '/translations/lang/:locale', :to => 'translations#load', :via => :get
end end

View file

@ -1,18 +1,16 @@
module ExtraRoutes Zammad::Application.routes.draw do
def add(map, api_path) api_path = Rails.configuration.api_path
# users # users
map.match api_path + '/users/search', :to => 'users#search', :via => [:get, :post] match api_path + '/users/search', :to => 'users#search', :via => [:get, :post]
map.match api_path + '/users/password_reset', :to => 'users#password_reset_send', :via => :post match api_path + '/users/password_reset', :to => 'users#password_reset_send', :via => :post
map.match api_path + '/users/password_reset_verify', :to => 'users#password_reset_verify', :via => :post match api_path + '/users/password_reset_verify', :to => 'users#password_reset_verify', :via => :post
map.match api_path + '/users/password_change', :to => 'users#password_change', :via => :post match api_path + '/users/password_change', :to => 'users#password_change', :via => :post
map.match api_path + '/users/preferences', :to => 'users#preferences', :via => :put match api_path + '/users/preferences', :to => 'users#preferences', :via => :put
map.match api_path + '/users/account', :to => 'users#account_remove', :via => :delete match api_path + '/users/account', :to => 'users#account_remove', :via => :delete
map.match api_path + '/users', :to => 'users#index', :via => :get match api_path + '/users', :to => 'users#index', :via => :get
map.match api_path + '/users/:id', :to => 'users#show', :via => :get match api_path + '/users/:id', :to => 'users#show', :via => :get
map.match api_path + '/users', :to => 'users#create', :via => :post match api_path + '/users', :to => 'users#create', :via => :post
map.match api_path + '/users/:id', :to => 'users#update', :via => :put match api_path + '/users/:id', :to => 'users#update', :via => :put
end end
module_function :add
end

View file

@ -2,7 +2,7 @@ require 'json'
require 'rss' require 'rss'
require 'session_helper' require 'session_helper'
module Session module Sessions
# get application root directory # get application root directory
@root = Dir.pwd.to_s @root = Dir.pwd.to_s
@ -205,7 +205,7 @@ module Session
next if @@client_threads[client_id] next if @@client_threads[client_id]
# get current user # get current user
session_data = Session.get( client_id ) session_data = Sessions.get( client_id )
next if !session_data next if !session_data
next if !session_data[:user] next if !session_data[:user]
next if !session_data[:user][:id] next if !session_data[:user][:id]
@ -272,7 +272,7 @@ module Session
files.sort.each {|entry| files.sort.each {|entry|
filename = path + '/' + entry filename = path + '/' + entry
if /^send/.match( entry ) if /^send/.match( entry )
data.push Session.queue_file( path, entry ) data.push Sessions.queue_file( path, entry )
end end
} }
return data return data
@ -297,7 +297,7 @@ module Session
# list all current clients # list all current clients
client_list = self.list client_list = self.list
client_list.each {|local_client_id, local_client| client_list.each {|local_client_id, local_client|
Session.send( local_client_id, data ) Sessions.send( local_client_id, data )
} }
return true return true
end end
@ -552,7 +552,7 @@ class ClientState
while true while true
# get connection user # get connection user
session_data = Session.get( @client_id ) session_data = Sessions.get( @client_id )
return if !session_data return if !session_data
return if !session_data[:user] return if !session_data[:user]
return if !session_data[:user][:id] return if !session_data[:user][:id]
@ -851,7 +851,7 @@ class ClientState
# send update to browser # send update to browser
def send( data ) def send( data )
Session.send( @client_id, data ) Sessions.send( @client_id, data )
end end
def log( level, data ) def log( level, data )

View file

@ -8,7 +8,7 @@ require 'eventmachine'
require 'em-websocket' require 'em-websocket'
require 'json' require 'json'
require 'fileutils' require 'fileutils'
require 'session' require 'sessions'
require 'optparse' require 'optparse'
require 'daemons' require 'daemons'
@ -91,7 +91,7 @@ EventMachine.run {
ws.onopen { ws.onopen {
client_id = ws.object_id.to_s client_id = ws.object_id.to_s
log 'notice', 'Client connected.', client_id log 'notice', 'Client connected.', client_id
Session.create( client_id, {}, { :type => 'websocket' } ) Sessions.create( client_id, {}, { :type => 'websocket' } )
if !@clients.include? client_id if !@clients.include? client_id
@clients[client_id] = { @clients[client_id] = {
@ -112,7 +112,7 @@ EventMachine.run {
@clients.delete client_id @clients.delete client_id
end end
Session.destory( client_id ) Sessions.destory( client_id )
} }
# manage messages # manage messages
@ -132,7 +132,7 @@ EventMachine.run {
# spool messages for new connects # spool messages for new connects
if data['spool'] if data['spool']
Session.spool_create(msg) Sessions.spool_create(msg)
end end
# get spool messages and send them to new client connection # get spool messages and send them to new client connection
@ -146,7 +146,7 @@ EventMachine.run {
end end
if @clients[client_id] && @clients[client_id][:session] && @clients[client_id][:session]['id'] if @clients[client_id] && @clients[client_id][:session] && @clients[client_id][:session]['id']
spool = Session.spool_list( data['timestamp'], @clients[client_id][:session]['id'] ) spool = Sessions.spool_list( data['timestamp'], @clients[client_id][:session]['id'] )
spool.each { |item| spool.each { |item|
# create new msg to push to client # create new msg to push to client
@ -171,7 +171,7 @@ EventMachine.run {
# get session # get session
if data['action'] == 'login' if data['action'] == 'login'
@clients[client_id][:session] = data['session'] @clients[client_id][:session] = data['session']
Session.create( client_id, data['session'], { :type => 'websocket' } ) Sessions.create( client_id, data['session'], { :type => 'websocket' } )
# remember ping, send pong back # remember ping, send pong back
elsif data['action'] == 'ping' elsif data['action'] == 'ping'
@ -182,7 +182,7 @@ EventMachine.run {
elsif data['action'] == 'broadcast' elsif data['action'] == 'broadcast'
# list all current clients # list all current clients
client_list = Session.list client_list = Sessions.list
client_list.each {|local_client_id, local_client| client_list.each {|local_client_id, local_client|
if local_client_id != client_id if local_client_id != client_id
@ -203,7 +203,7 @@ EventMachine.run {
if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ] if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
@clients[ local_client_id ][:websocket].send( "[#{msg}]" ) @clients[ local_client_id ][:websocket].send( "[#{msg}]" )
else else
Session.send( local_client_id, data ) Sessions.send( local_client_id, data )
end end
end end
} }
@ -217,7 +217,7 @@ EventMachine.run {
if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ] if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
@clients[ local_client_id ][:websocket].send( "[#{msg}]" ) @clients[ local_client_id ][:websocket].send( "[#{msg}]" )
else else
Session.send( local_client_id, data ) Sessions.send( local_client_id, data )
end end
end end
else else
@ -247,7 +247,7 @@ EventMachine.run {
} }
# ajax # ajax
client_list = Session.list client_list = Sessions.list
clients = 0 clients = 0
client_list.each {|client_id, client| client_list.each {|client_id, client|
next if client[:meta][:type] == 'websocket' next if client[:meta][:type] == 'websocket'
@ -268,7 +268,7 @@ EventMachine.run {
next if client[:disconnect] next if client[:disconnect]
log 'debug', 'checking for data...', client_id log 'debug', 'checking for data...', client_id
begin begin
queue = Session.queue( client_id ) queue = Sessions.queue( client_id )
if queue && queue[0] if queue && queue[0]
# log "send " + queue.inspect, client_id # log "send " + queue.inspect, client_id
log 'notice', "send data to client", client_id log 'notice', "send data to client", client_id
@ -312,12 +312,12 @@ EventMachine.run {
} }
# ajax # ajax
clients = Session.list clients = Sessions.list
clients.each { |client_id, client| clients.each { |client_id, client|
next if client[:meta][:type] == 'websocket' next if client[:meta][:type] == 'websocket'
if ( client[:meta][:last_ping].to_i + ( 60 * idle_time_in_min ) ) < Time.now.to_i if ( client[:meta][:last_ping].to_i + ( 60 * idle_time_in_min ) ) < Time.now.to_i
log 'notice', "closing idle ajax connection", client_id log 'notice', "closing idle ajax connection", client_id
Session.destory( client_id ) Sessions.destory( client_id )
end end
} }
end end

View file

@ -52,11 +52,35 @@ class TestCase < Test::Unit::TestCase
end end
end end
local_browser.manage.timeouts.implicit_wait = 3 # seconds local_browser.manage.timeouts.implicit_wait = 3 # seconds
browser_instance_js_on_start(local_browser)
end
def browser_instance_js_on_start(instance)
instance.execute_script('
window.jsErrors = [];
window.onerror = function(errorMessage) {
window.jsErrors.push(errorMessage);
};');
end
def browser_instance_js_on_teardown(instance)
result = instance.execute_script( 'return window.jsErrors;' )
if result
puts 'JS ERRORS: ' + result.inspect
else
puts 'JS ERRORS: -none-'
end
end end
def teardown def teardown
return if !@browsers return if !@browsers
# show js errors
@browsers.each{ |local_browser|
browser_instance_js_on_teardown(local_browser)
}
# only shut down browser type once on local webdriver tests # only shut down browser type once on local webdriver tests
# otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)" # otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)"
if !ENV['REMOTE_URL'] if !ENV['REMOTE_URL']