Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
fadf0818
Commit
fadf0818
authored
Jul 20, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactory on client
parent
159e0294
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
142 deletions
+86
-142
debomatic-webui/lib/broadcaster.coffee
debomatic-webui/lib/broadcaster.coffee
+5
-5
debomatic-webui/lib/client.coffee
debomatic-webui/lib/client.coffee
+79
-128
debomatic-webui/lib/utils.coffee
debomatic-webui/lib/utils.coffee
+2
-9
No files found.
debomatic-webui/lib/broadcaster.coffee
View file @
fadf0818
config
=
require
(
"./config"
)
fs
=
require
(
"fs"
)
utils
=
require
(
"./utils"
)
Tail
=
require
(
"./tail"
)
__watch_status_check_same_obj
=
(
obj1
,
obj2
)
->
if
obj1
.
status
is
obj2
.
status
if
obj1
.
distribution
is
obj2
.
distribution
...
...
@@ -84,9 +89,4 @@ Broadcaster = (sockets, status) ->
__watch_distributions
(
sockets
)
__watch_pidfile
(
sockets
)
"use strict"
config
=
require
(
"./config"
)
fs
=
require
(
"fs"
)
utils
=
require
(
"./utils"
)
Tail
=
require
(
"./tail"
)
module
.
exports
=
Broadcaster
debomatic-webui/lib/client.coffee
View file @
fadf0818
__get_files_list_from_package
=
(
data
,
callback
)
->
fs
=
require
(
"fs"
)
path
=
require
(
"path"
)
config
=
require
(
"./config"
)
utils
=
require
(
"./utils"
)
e
=
config
.
events
.
client
get_files_list_from_package
=
(
data
,
callback
)
->
package_path
=
utils
.
get_package_path
(
data
)
utils
.
get_files_list
package_path
,
false
,
(
files
)
->
data
.
package
.
files
=
[]
...
...
@@ -28,165 +34,110 @@ __get_files_list_from_package = (data, callback) ->
callback
(
data
)
__send_package_files_list
=
(
event_name
,
socket
,
data
)
->
__get_files_list_from_package
data
,
(
new_data
)
->
socket
.
emit
event_name
,
new_data
return
return
__read_package_status
=
(
data
,
cb
)
->
read_package_status
=
(
data
,
cb
)
->
package_path
=
utils
.
get_package_path
(
data
)
package_json
=
path
.
join
(
package_path
,
data
.
package
.
orig_name
+
".json"
)
fs
.
readFile
package_json
,
{
encoding
:
"utf8"
},
(
err
,
content
)
->
if
err
utils
.
errors_handler
"Client:
__
read_package_status:"
,
err
utils
.
errors_handler
"Client:read_package_status:"
,
err
return
try
content
=
JSON
.
parse
(
content
)
catch
parse
_
err
catch
parseerr
utils
.
errors_handler
(
"Client:"
+
"
__read_package_status:parse_
err:"
,
parse
_
err
)
"
read_package_status:parse
err:"
,
parseerr
)
return
cb
content
return
return
__send_package_info
=
(
socket
,
data
)
->
__read_package_status
data
,
(
content
)
->
socket
.
emit
_e
.
package_info
,
content
return
class
Client
return
__send_package_status
=
(
socket
,
data
)
->
__read_package_status
data
,
(
content
)
->
socket
.
emit
_e
.
distribution_packages_status
,
content
return
constructor
:
(
@
socket
)
->
return
__send_distribution_packages
=
(
event_name
,
socket
,
data
)
->
send_package_files_list
:
(
data
)
->
get_files_list_from_package
data
,
(
new_data
)
=>
@
socket
.
emit
e
.
package_files_list
,
new_data
send_distribution_packages
:
(
data
)
->
distro_path
=
utils
.
get_distribution_pool_path
(
data
)
utils
.
get_files_list
distro_path
,
true
,
(
packages
)
-
>
utils
.
get_files_list
distro_path
,
true
,
(
packages
)
=
>
data
.
distribution
.
packages
=
[]
packages
.
forEach
(
p
)
->
for
p
in
packages
pack
=
{}
info
=
p
.
split
(
"_"
)
pack
.
name
=
info
[
0
]
pack
.
version
=
info
[
1
]
pack
.
orig_name
=
p
__send_package_status
socket
,
distribution
:
data
.
distribution
package
:
pack
read_package_status
{
distribution
:
data
.
distribution
,
package
:
pack
},
(
content
)
=>
@
socket
.
emit
e
.
distribution_packages_status
,
content
data
.
distribution
.
packages
.
push
pack
return
socket
.
emit
event_name
,
data
return
@
socket
.
emit
e
.
distribution_packages
,
data
return
__send_file
=
(
event_name
,
socket
,
data
,
last_lines
)
->
send_file
:
(
data
)
->
file_path
=
utils
.
get_file_path
(
data
)
fs
.
readFile
file_path
,
"utf8"
,
(
err
,
content
)
->
get_preview
=
data
.
file
.
name
in
config
.
web
.
file
.
preview
and
not
data
.
file
.
force
fs
.
readFile
file_path
,
"utf8"
,
(
err
,
content
)
=>
if
err
utils
.
errors_handler
(
"client:__send_file"
,
err
,
socket
)
utils
.
errors_handler
(
"client:send_file"
,
err
,
@
socket
)
return
data
.
file
.
orig_name
=
file_path
.
split
(
"/"
).
pop
()
if
last_lines
>
0
if
get_preview
and
config
.
web
.
file
.
num_lines
>
0
last_lines
=
config
.
web
.
file
.
num_lines
data
.
file
.
content
=
content
.
split
(
"
\n
"
)[
-
last_lines
..].
join
(
"
\n
"
)
else
data
.
file
.
content
=
content
data
.
file
.
path
=
file_path
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
socket
.
emit
event_name
,
data
return
return
__handler_get_file
=
(
socket
,
data
)
->
file_path
=
utils
.
get_file_path
(
data
)
send
=
(
event_name
,
socket
,
data
)
->
data
.
file
.
content
=
null
socket
.
emit
(
event_name
,
data
)
utils
.
watch_path_onsocket
(
_e
.
file_newcontent
,
socket
,
data
,
file_path
,
send
)
@
socket
.
emit
e
.
file
,
data
if
data
.
file
.
name
in
config
.
web
.
file
.
preview
and
not
data
.
file
.
force
__send_file
(
_e
.
file
,
socket
,
data
,
config
.
web
.
file
.
num_lines
)
else
__send_file
(
_e
.
file
,
socket
,
data
)
return
send_status
:
(
status
)
->
@
socket
.
emit
e
.
status
,
status
send_status_debomatic
:
->
fs
.
exists
config
.
debomatic
.
pidfile
,
(
exists
)
=>
@
socket
.
emit
config
.
events
.
broadcast
.
status_debomatic
,
running
:
exists
Client
=
(
socket
)
->
@
start
=
->
start
:
->
# init send distributions
utils
.
send_distributions
socket
utils
.
send_distributions
@
socket
# init events
socket
.
on
_e
.
distribution_packages
,
(
data
)
-
>
@
socket
.
on
e
.
distribution_packages
,
(
data
)
=
>
return
unless
utils
.
check_data_distribution
(
data
)
distribution_path
=
utils
.
get_distribution_pool_path
(
data
)
utils
.
generic_handler_watcher
(
_e
.
distribution_packages
,
socket
,
data
,
distribution_path
,
__send_distribution_packages
)
data
=
null
return
@
send_distribution_packages
(
data
)
utils
.
watch_path_onsocket
e
.
distribution_packages
,
@
socket
,
data
,
distribution_path
,
(
new_data
)
=>
@
send_distribution_packages
(
new_data
)
socket
.
on
_e
.
package_files_list
,
(
data
)
-
>
@
socket
.
on
e
.
package_files_list
,
(
data
)
=
>
return
unless
utils
.
check_data_package
(
data
)
package_path
=
utils
.
get_package_path
(
data
)
utils
.
generic_handler_watcher
(
_e
.
package_files_list
,
socket
,
data
,
package_path
,
__send_package_files_list
)
data
=
null
return
@
send_package_files_list
(
data
)
utils
.
watch_path_onsocket
e
.
package_files_list
,
@
socket
,
data
,
package_path
,
(
new_data
)
=>
@
send_package_files_list
(
new_data
)
socket
.
on
_e
.
file
,
(
data
)
-
>
@
socket
.
on
e
.
file
,
(
data
)
=
>
return
unless
utils
.
check_data_file
(
data
)
__handler_get_file
socket
,
data
data
=
null
return
file_path
=
utils
.
get_file_path
(
data
)
data
.
file
.
content
=
null
@
send_file
(
data
)
utils
.
watch_path_onsocket
e
.
file_newcontent
,
@
socket
,
data
,
file_path
,
(
new_data
)
=>
@
socket
.
emit
(
e
.
file_newcontent
,
new_data
)
socket
.
on
_e
.
package_info
,
(
data
)
-
>
@
socket
.
on
e
.
package_info
,
(
data
)
=
>
return
unless
utils
.
check_data_package
(
data
)
__send_package_info
socket
,
data
data
=
null
return
read_package_status
data
,
(
content
)
=>
@
socket
.
emit
e
.
package_info
,
content
# on client disconnection close all watchers
socket
.
on
"disconnect"
,
-
>
socket_watchers
=
socket
.
watchers
@
socket
.
on
"disconnect"
,
=
>
socket_watchers
=
@
socket
.
watchers
return
unless
socket_watchers
for
key
of
socket_watchers
try
socket_watchers
[
key
].
close
()
catch
error_watch
utils
.
errors_handler
"client:disconnect"
,
error_watch
return
return
@
send_status
=
(
status
)
->
socket
.
emit
_e
.
status
,
status
return
@
send_status_debomatic
=
->
fs
.
exists
config
.
debomatic
.
pidfile
,
(
exists
)
->
socket
.
emit
config
.
events
.
broadcast
.
status_debomatic
,
running
:
exists
return
return
return
"use strict"
fs
=
require
(
"fs"
)
path
=
require
(
"path"
)
config
=
require
(
"./config"
)
utils
=
require
(
"./utils"
)
_e
=
config
.
events
.
client
module
.
exports
=
Client
debomatic-webui/lib/utils.coffee
View file @
fadf0818
...
...
@@ -75,13 +75,13 @@ watch_path_onsocket = (event_name, socket, data, watch_path, callback) ->
persistent
:
true
,
(
event
,
fileName
)
->
if
event
is
"rename"
callback
(
event_name
,
socket
,
data
))
callback
(
data
))
else
if
stats
.
isFile
()
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
"line"
,
(
new_content
,
tailInfo
)
->
data
.
file
.
new_content
=
new_content
+
"
\n
"
callback
(
event_name
,
socket
,
data
)
callback
(
data
)
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
...
...
@@ -95,12 +95,6 @@ watch_path_onsocket = (event_name, socket, data, watch_path, callback) ->
err
,
socket
)
return
generic_handler_watcher
=
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
callback
event_name
,
socket
,
data
watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
callback
send_distributions
=
(
socket
)
->
get_files_list
config
.
debomatic
.
path
,
true
,
(
directories
)
->
distributions
=
[]
...
...
@@ -128,6 +122,5 @@ module.exports.get_package_path = get_package_path
module
.
exports
.
get_file_path
=
get_file_path
module
.
exports
.
get_files_list
=
get_files_list
module
.
exports
.
watch_path_onsocket
=
watch_path_onsocket
module
.
exports
.
generic_handler_watcher
=
generic_handler_watcher
module
.
exports
.
send_distributions
=
send_distributions
module
.
exports
.
errors_handler
=
errors_handler
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment