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
28a72f8b
Commit
28a72f8b
authored
Mar 08, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added utils.js - moved there some common functions
parent
97f1ef29
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
22 deletions
+80
-22
debomatic-webui/app.js
debomatic-webui/app.js
+13
-14
debomatic-webui/send.js
debomatic-webui/send.js
+18
-8
debomatic-webui/utils.js
debomatic-webui/utils.js
+49
-0
No files found.
debomatic-webui/app.js
View file @
28a72f8b
...
...
@@ -9,6 +9,7 @@ var express = require('express')
,
send
=
require
(
'
./send.js
'
)
,
fs
=
require
(
'
fs
'
)
,
path
=
require
(
'
path
'
)
,
utils
=
require
(
'
./utils.js
'
)
var
app
=
module
.
exports
=
express
.
createServer
();
...
...
@@ -38,7 +39,7 @@ var io = require('socket.io').listen(app);
// Routes
app
.
get
(
'
/
'
,
routes
.
index
);
function
watch
er_on_socket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
function
watch
_dir
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
name
=
"
watcher-
"
+
event_name
socket
.
get
(
name
,
function
(
err
,
watcher
)
{
if
(
watcher
)
...
...
@@ -53,34 +54,32 @@ function watcher_on_socket(event_name, socket, data, watch_path, updater) {
})
}
function
check_data_distribution
(
data
)
{
return
data
&&
data
.
distribution
&&
data
.
distribution
.
name
}
function
check_data_package
(
data
)
{
return
check_data_distribution
(
data
)
&&
data
.
package
&&
data
.
package
.
name
&&
data
.
package
.
version
}
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
send
.
distributions
(
socket
);
// send distribution packages
socket
.
on
(
'
get_distribution_packages
'
,
function
(
data
)
{
if
(
!
check_data_distribution
(
data
))
if
(
!
utils
.
check_data_distribution
(
data
))
return
distribution_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
watch
er_on_socket
(
'
get_distribution_packages
'
,
socket
,
data
,
distribution_path
,
send
.
distribution_packages
)
watch
_dir
(
'
get_distribution_packages
'
,
socket
,
data
,
distribution_path
,
send
.
distribution_packages
)
send
.
distribution_packages
(
socket
,
data
);
})
socket
.
on
(
'
get_package_file_list
'
,
function
(
data
)
{
if
(
!
check_data_package
(
data
))
if
(
!
utils
.
check_data_package
(
data
))
return
package_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
,
data
.
package
.
name
+
"
_
"
+
data
.
package
.
version
)
watch
er_on_socket
(
'
get_package_file_list
'
,
socket
,
data
,
package_path
,
send
.
package_file_list
)
package_path
=
utils
.
get_package_path
(
data
)
watch
_dir
(
'
get_package_file_list
'
,
socket
,
data
,
package_path
,
send
.
package_file_list
)
send
.
package_file_list
(
socket
,
data
)
})
socket
.
on
(
'
get_file
'
,
function
(
data
){
if
(
!
utils
.
check_data_file
(
data
))
return
send
.
file
(
socket
,
data
)
})
});
...
...
debomatic-webui/send.js
View file @
28a72f8b
var
fs
=
require
(
'
fs
'
)
,
path
=
require
(
'
path
'
)
,
config
=
require
(
'
./config.js
'
)
var
BASE_DIR
=
config
.
debomatic_path
;
,
utils
=
require
(
'
./utils.js
'
)
function
__get_files_list
(
dir
,
onlyDirectories
,
callback
)
{
fs
.
readdir
(
dir
,
function
(
err
,
files
){
...
...
@@ -56,9 +55,7 @@ function __get_files_list_from_package(package_path, callback) {
}
function
__send_package_files_list
(
socket
,
data
)
{
distro_path
=
path
.
join
(
BASE_DIR
,
data
.
distribution
.
name
,
'
pool
'
);
p
=
data
.
package
.
name
+
"
_
"
+
data
.
package
.
version
package_path
=
path
.
join
(
distro_path
,
p
)
package_path
=
utils
.
get_package_path
(
data
)
__get_files_list_from_package
(
package_path
,
function
(
package_files
){
data
.
package
.
files
=
package_files
.
files
data
.
package
.
debs
=
package_files
.
debs
...
...
@@ -68,7 +65,7 @@ function __send_package_files_list (socket, data) {
}
function
__send_distribution_packages
(
socket
,
data
)
{
distro_path
=
path
.
join
(
BASE_DIR
,
data
.
distribution
.
name
,
'
pool
'
);
distro_path
=
utils
.
get_distribution_pool_path
(
data
)
__get_files_list
(
distro_path
,
true
,
function
(
packages
)
{
data
.
distribution
.
packages
=
[]
packages
.
forEach
(
function
(
p
)
{
...
...
@@ -76,7 +73,7 @@ function __send_distribution_packages (socket, data) {
info
=
p
.
split
(
'
_
'
)
pack
.
name
=
info
[
0
]
pack
.
version
=
info
[
1
]
if
(
data
.
package
&&
if
(
data
.
package
&&
pack
.
name
==
data
.
package
.
name
&&
pack
.
version
==
data
.
package
.
version
)
{
pack
.
selected
=
true
;
...
...
@@ -87,10 +84,19 @@ function __send_distribution_packages (socket, data) {
});
}
function
__send_file
(
socket
,
data
)
{
file_path
=
utils
.
get_file_path
(
data
)
fs
.
readFile
(
file_path
,
'
utf8
'
,
function
(
err
,
content
)
{
if
(
err
)
return
;
data
.
file
.
content
=
content
socket
.
emit
(
'
file
'
,
data
)
});
}
debomatic_sender
=
{
distributions
:
function
(
socket
)
{
__get_files_list
(
BASE_DIR
,
true
,
function
(
distros
){
__get_files_list
(
config
.
debomatic_path
,
true
,
function
(
distros
){
socket
.
emit
(
'
distributions
'
,
distros
);
});
},
...
...
@@ -101,6 +107,10 @@ debomatic_sender = {
distribution_packages
:
function
(
socket
,
data
)
{
__send_distribution_packages
(
socket
,
data
)
},
file
:
function
(
socket
,
data
)
{
__send_file
(
socket
,
data
)
}
}
...
...
debomatic-webui/utils.js
0 → 100644
View file @
28a72f8b
var
path
=
require
(
'
path
'
)
,
config
=
require
(
'
./config.js
'
)
function
__check_data_distribution
(
data
)
{
return
data
&&
data
.
distribution
&&
data
.
distribution
.
name
}
function
__check_data_package
(
data
)
{
return
__check_data_distribution
(
data
)
&&
data
.
package
&&
data
.
package
.
name
&&
data
.
package
.
version
}
function
__check_data_file
(
data
)
{
return
__check_data_package
(
data
)
&&
data
.
file
.
name
}
function
__get_distribution_pool_path
(
data
)
{
return
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
}
function
__get_package_path
(
data
)
{
return
path
.
join
(
__get_distribution_pool_path
(
data
),
data
.
package
.
name
+
'
_
'
+
data
.
package
.
version
)
}
function
__get_file_path
(
data
)
{
return
path
.
join
(
__get_package_path
(
data
),
data
.
file
.
name
)
}
utils
=
{
check_data_distribution
:
function
(
data
)
{
return
__check_data_distribution
(
data
)
},
check_data_package
:
function
(
data
)
{
return
__check_data_package
(
data
)
},
check_data_file
:
function
(
data
)
{
return
__check_data_file
(
data
)
},
get_distribution_pool_path
:
function
(
data
)
{
return
__get_distribution_pool_path
(
data
)
},
get_package_path
:
function
(
data
)
{
return
__get_package_path
(
data
)
},
get_file_path
:
function
(
data
)
{
return
__get_file_path
(
data
)
},
}
module
.
exports
=
utils
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