Commit 873a33b3 authored by Leo Iannacone's avatar Leo Iannacone

all events used are now in config

parent e3912e86
...@@ -77,30 +77,32 @@ function __send_file (event_name, socket, data) { ...@@ -77,30 +77,32 @@ function __send_file (event_name, socket, data) {
function __handler_get_file (socket, data) { function __handler_get_file (socket, data) {
file_path = utils.get_file_path(data) file_path = utils.get_file_path(data)
utils.watch_path_onsocket('file_newcontent', socket, data, file_path, function(event_name, socket, data) { utils.watch_path_onsocket(events.file_newcontent, socket, data, file_path, function(event_name, socket, data) {
data.file.content = null data.file.content = null
socket.emit(event_name, data) socket.emit(event_name, data)
}) })
__send_file('file', socket, data) __send_file(events.file.set, socket, data)
} }
Client = function (socket) { Client = function (socket) {
socket.on('get_distribution_packages', function (data) { events = config.events.client
socket.on(events.distribution_packages.get, function (data) {
if (! utils.check_data_distribution(data)) if (! utils.check_data_distribution(data))
return return
distribution_path = path.join(config.debomatic.path, data.distribution.name, 'pool') distribution_path = path.join(config.debomatic.path, data.distribution.name, 'pool')
utils.generic_handler_watcher('distribution_packages', socket, data, distribution_path, __send_distribution_packages) utils.generic_handler_watcher(events.distribution_packages.set, socket, data, distribution_path, __send_distribution_packages)
}) })
socket.on('get_package_files_list', function(data) { socket.on(events.package_files_list.get, function(data) {
if (! utils.check_data_package(data)) if (! utils.check_data_package(data))
return return
package_path = utils.get_package_path(data) package_path = utils.get_package_path(data)
utils.generic_handler_watcher('package_files_list', socket, data, package_path, __send_package_files_list) utils.generic_handler_watcher(events.package_files_list.set, socket, data, package_path, __send_package_files_list)
}) })
socket.on('get_file', function (data){ socket.on(events.file.get, function (data){
if (! utils.check_data_file(data)) if (! utils.check_data_file(data))
return return
__handler_get_file(socket, data) __handler_get_file(socket, data)
......
...@@ -24,6 +24,20 @@ config.events.broadcast = {} ...@@ -24,6 +24,20 @@ config.events.broadcast = {}
config.events.broadcast.distributions = 'distributions' config.events.broadcast.distributions = 'distributions'
config.events.broadcast.status_update = 'status_update' config.events.broadcast.status_update = 'status_update'
function __build_get_set(event_name) {
return {
set: event_name,
get: 'get_' + event_name
}
}
config.events.client = {}
config.events.client.distribution_packages = __build_get_set('distribution_packages')
config.events.client.package_files_list = __build_get_set('package_files_list')
config.events.client.file = __build_get_set('file')
config.events.client.file_newcontent = 'file_newcontent'
config.web.paths = config.routes config.web.paths = config.routes
config.web.events = config.events config.web.events = config.events
config.web.hostname = config.host + ((config.port == 80) ? null : ':' + config.port) config.web.hostname = config.host + ((config.port == 80) ? null : ':' + config.port)
......
function Page_Distrubion() function Page_Distrubion()
{ {
var socket var socket
var events = config.events.client
var data = Utils.from_hash_to_data() var data = Utils.from_hash_to_data()
function __check_hash_makes_sense() { function __check_hash_makes_sense() {
...@@ -53,7 +54,7 @@ function Page_Distrubion() ...@@ -53,7 +54,7 @@ function Page_Distrubion()
if (Utils.check_data_distribution(data)) { if (Utils.check_data_distribution(data)) {
var new_data = {} var new_data = {}
new_data.distribution = data.distribution new_data.distribution = data.distribution
socket.emit("get_distribution_packages", new_data) socket.emit(events.distribution_packages.get, new_data)
} }
}, },
select: function() { select: function() {
...@@ -114,7 +115,7 @@ function Page_Distrubion() ...@@ -114,7 +115,7 @@ function Page_Distrubion()
var new_data = {} var new_data = {}
new_data.distribution = data.distribution new_data.distribution = data.distribution
new_data.package = data.package new_data.package = data.package
socket.emit("get_package_files_list", new_data) socket.emit(events.package_files_list.get, new_data)
} }
}, },
select: function() { select: function() {
...@@ -152,7 +153,7 @@ function Page_Distrubion() ...@@ -152,7 +153,7 @@ function Page_Distrubion()
new_data.package = data.package new_data.package = data.package
new_data.file = data.file new_data.file = data.file
new_data.file.content = null new_data.file.content = null
socket.emit("get_file", new_data) socket.emit(events.file.get, new_data)
} }
} }
} }
...@@ -269,19 +270,19 @@ function Page_Distrubion() ...@@ -269,19 +270,19 @@ function Page_Distrubion()
socket = mysocket socket = mysocket
socket.on('distribution_packages', function(socket_data){ socket.on(events.distribution_packages.set, function(socket_data){
packages.set(socket_data) packages.set(socket_data)
}) })
socket.on('package_files_list', function(socket_data){ socket.on(events.package_files_list.set, function(socket_data){
files.set(socket_data) files.set(socket_data)
}) })
socket.on('file', function (socket_data) { socket.on(events.file.set, function (socket_data) {
file.set(socket_data) file.set(socket_data)
}) })
socket.on('file_newcontent', function(socket_data) { socket.on(events.file_newcontent, function(socket_data) {
file.append(socket_data) file.append(socket_data)
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment