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
9f520661
Commit
9f520661
authored
Mar 08, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use 2 blank space instead of 4
parent
e46c0e75
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
166 additions
and
167 deletions
+166
-167
debomatic-webui/app.js
debomatic-webui/app.js
+56
-57
debomatic-webui/send.js
debomatic-webui/send.js
+86
-86
debomatic-webui/utils.js
debomatic-webui/utils.js
+24
-24
No files found.
debomatic-webui/app.js
View file @
9f520661
...
...
@@ -41,75 +41,74 @@ var io = require('socket.io').listen(app);
app
.
get
(
'
/
'
,
routes
.
index
);
function
watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
name
=
"
watcher-
"
+
event_name
socket
.
get
(
name
,
function
(
err
,
watcher
)
{
if
(
watcher
)
{
try
{
watcher
.
unwatch
()
}
catch
(
errorWatchingDirectory
)
{
watcher
.
close
()
}
name
=
"
watcher-
"
+
event_name
socket
.
get
(
name
,
function
(
err
,
watcher
)
{
if
(
watcher
)
{
try
{
watcher
.
unwatch
()
}
catch
(
errorWatchingDirectory
)
{
watcher
.
close
()
}
}
try
{
fs
.
stat
(
watch_path
,
function
(
err
,
stats
)
{
if
(
err
)
return
if
(
stats
.
isDirectory
())
{
watcher
=
fs
.
watch
(
watch_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
updater
(
socket
,
data
)
})
}
try
{
fs
.
stat
(
watch_path
,
function
(
err
,
stats
)
{
if
(
err
)
return
if
(
stats
.
isDirectory
())
{
watcher
=
fs
.
watch
(
watch_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
updater
(
socket
,
data
)
})
}
else
{
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
data
.
file
.
new_content
=
new_content
+
'
\n
'
updater
(
socket
,
data
)
})
}
socket
.
set
(
name
,
watcher
)
})
}
catch
(
err_watch
)
{}
})
else
{
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
data
.
file
.
new_content
=
new_content
+
'
\n
'
updater
(
socket
,
data
)
})
}
socket
.
set
(
name
,
watcher
)
})
}
catch
(
err_watch
)
{}
})
}
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
send
.
distributions
(
socket
);
// send distribution packages
socket
.
on
(
'
get_distribution_packages
'
,
function
(
data
)
{
if
(
!
utils
.
check_data_distribution
(
data
))
return
distribution_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
watch_path_onsocket
(
'
get_distribution_packages
'
,
socket
,
data
,
distribution_path
,
send
.
distribution_packages
)
send
.
distribution_packages
(
socket
,
data
);
})
send
.
distributions
(
socket
);
// send distribution packages
socket
.
on
(
'
get_distribution_packages
'
,
function
(
data
)
{
if
(
!
utils
.
check_data_distribution
(
data
))
return
distribution_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
watch_path_onsocket
(
'
get_distribution_packages
'
,
socket
,
data
,
distribution_path
,
send
.
distribution_packages
)
send
.
distribution_packages
(
socket
,
data
);
})
socket
.
on
(
'
get_package_file_list
'
,
function
(
data
)
{
if
(
!
utils
.
check_data_package
(
data
))
return
package_path
=
utils
.
get_package_path
(
data
)
watch_path_onsocket
(
'
get_package_file_list
'
,
socket
,
data
,
package_path
,
send
.
package_file_list
)
send
.
package_file_list
(
socket
,
data
)
socket
.
on
(
'
get_package_file_list
'
,
function
(
data
)
{
if
(
!
utils
.
check_data_package
(
data
))
return
package_path
=
utils
.
get_package_path
(
data
)
watch_path_onsocket
(
'
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
file_path
=
utils
.
get_file_path
(
data
)
watch_path_onsocket
(
'
get_file
'
,
socket
,
data
,
file_path
,
send
.
file_newcontent
)
send
.
file
(
socket
,
data
)
})
})
socket
.
on
(
'
get_file
'
,
function
(
data
){
if
(
!
utils
.
check_data_file
(
data
))
return
file_path
=
utils
.
get_file_path
(
data
)
watch_path_onsocket
(
'
get_file
'
,
socket
,
data
,
file_path
,
send
.
file_newcontent
)
send
.
file
(
socket
,
data
)
})
});
io
.
sockets
.
on
(
'
disconnect
'
,
function
(
socket
){
});
fs
.
watch
(
config
.
debomatic_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
send
.
distributions
(
io
.
sockets
);
send
.
distributions
(
io
.
sockets
);
});
var
server
=
app
.
listen
(
config
.
port
,
function
(){
...
...
debomatic-webui/send.js
View file @
9f520661
...
...
@@ -4,114 +4,114 @@ var fs = require('fs')
,
utils
=
require
(
'
./utils.js
'
)
function
__get_files_list
(
dir
,
onlyDirectories
,
callback
)
{
fs
.
readdir
(
dir
,
function
(
err
,
files
){
result
=
[];
if
(
err
)
{
console
.
error
(
err
);
return
;
fs
.
readdir
(
dir
,
function
(
err
,
files
){
result
=
[];
if
(
err
)
{
console
.
error
(
err
);
return
;
}
files
.
forEach
(
function
(
f
)
{
complete_path
=
path
.
join
(
dir
,
f
);
if
(
onlyDirectories
)
{
if
(
fs
.
statSync
(
complete_path
).
isDirectory
())
{
result
.
push
(
f
);
}
}
else
{
if
(
fs
.
statSync
(
complete_path
).
isFile
())
{
result
.
push
(
f
);
}
files
.
forEach
(
function
(
f
)
{
complete_path
=
path
.
join
(
dir
,
f
);
if
(
onlyDirectories
)
{
if
(
fs
.
statSync
(
complete_path
).
isDirectory
())
{
result
.
push
(
f
);
}
}
else
{
if
(
fs
.
statSync
(
complete_path
).
isFile
())
{
result
.
push
(
f
);
}
}
});
callback
(
result
);
}
});
callback
(
result
);
});
}
function
__get_files_list_from_package
(
data
,
callback
)
{
package_path
=
utils
.
get_package_path
(
data
)
__get_files_list
(
package_path
,
false
,
function
(
files
)
{
data
.
package
.
files
=
[]
data
.
package
.
debs
=
[]
data
.
package
.
archives
=
[]
files
.
forEach
(
function
(
f
)
{
file
=
{}
file
.
path
=
path
.
join
(
package_path
,
f
).
replace
(
config
.
debomatic_path
,
config
.
debomatic_webpath
)
file
.
orig_name
=
f
file
.
name
=
f
.
split
(
'
_
'
)[
0
]
file
.
label
=
f
.
replace
(
file
.
name
+
'
_
'
,
''
)
file
.
extension
=
f
.
split
(
'
.
'
).
pop
();
if
(
file
.
extension
==
"
deb
"
||
file
.
extension
==
"
ddeb
"
)
data
.
package
.
debs
.
push
(
file
);
else
if
(
f
.
indexOf
(
'
.tar
'
)
>=
0
||
file
.
extension
==
"
changes
"
||
file
.
extension
==
"
dsc
"
)
{
data
.
package
.
archives
.
push
(
file
)
}
else
{
file
.
name
=
file
.
extension
data
.
package
.
files
.
push
(
file
)
}
});
callback
(
data
);
package_path
=
utils
.
get_package_path
(
data
)
__get_files_list
(
package_path
,
false
,
function
(
files
)
{
data
.
package
.
files
=
[]
data
.
package
.
debs
=
[]
data
.
package
.
archives
=
[]
files
.
forEach
(
function
(
f
)
{
file
=
{}
file
.
path
=
path
.
join
(
package_path
,
f
).
replace
(
config
.
debomatic_path
,
config
.
debomatic_webpath
)
file
.
orig_name
=
f
file
.
name
=
f
.
split
(
'
_
'
)[
0
]
file
.
label
=
f
.
replace
(
file
.
name
+
'
_
'
,
''
)
file
.
extension
=
f
.
split
(
'
.
'
).
pop
();
if
(
file
.
extension
==
"
deb
"
||
file
.
extension
==
"
ddeb
"
)
data
.
package
.
debs
.
push
(
file
);
else
if
(
f
.
indexOf
(
'
.tar
'
)
>=
0
||
file
.
extension
==
"
changes
"
||
file
.
extension
==
"
dsc
"
)
{
data
.
package
.
archives
.
push
(
file
)
}
else
{
file
.
name
=
file
.
extension
data
.
package
.
files
.
push
(
file
)
}
});
callback
(
data
);
});
}
function
__send_package_files_list
(
socket
,
data
)
{
__get_files_list_from_package
(
data
,
function
(
new_data
){
socket
.
emit
(
'
package_file_list
'
,
new_data
)
});
__get_files_list_from_package
(
data
,
function
(
new_data
){
socket
.
emit
(
'
package_file_list
'
,
new_data
)
});
}
function
__send_distribution_packages
(
socket
,
data
)
{
distro_path
=
utils
.
get_distribution_pool_path
(
data
)
__get_files_list
(
distro_path
,
true
,
function
(
packages
)
{
data
.
distribution
.
packages
=
[]
packages
.
forEach
(
function
(
p
)
{
pack
=
{}
info
=
p
.
split
(
'
_
'
)
pack
.
name
=
info
[
0
]
pack
.
version
=
info
[
1
]
if
(
data
.
package
&&
pack
.
name
==
data
.
package
.
name
&&
pack
.
version
==
data
.
package
.
version
)
{
pack
.
selected
=
true
;
}
data
.
distribution
.
packages
.
push
(
pack
)
});
socket
.
emit
(
"
distribution_packages
"
,
data
)
distro_path
=
utils
.
get_distribution_pool_path
(
data
)
__get_files_list
(
distro_path
,
true
,
function
(
packages
)
{
data
.
distribution
.
packages
=
[]
packages
.
forEach
(
function
(
p
)
{
pack
=
{}
info
=
p
.
split
(
'
_
'
)
pack
.
name
=
info
[
0
]
pack
.
version
=
info
[
1
]
if
(
data
.
package
&&
pack
.
name
==
data
.
package
.
name
&&
pack
.
version
==
data
.
package
.
version
)
{
pack
.
selected
=
true
;
}
data
.
distribution
.
packages
.
push
(
pack
)
});
socket
.
emit
(
"
distribution_packages
"
,
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
)
});
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
(
config
.
debomatic_path
,
true
,
function
(
distros
){
socket
.
emit
(
'
distributions
'
,
distros
);
});
},
distributions
:
function
(
socket
)
{
__get_files_list
(
config
.
debomatic_path
,
true
,
function
(
distros
){
socket
.
emit
(
'
distributions
'
,
distros
);
});
},
package_file_list
:
function
(
socket
,
data
)
{
__send_package_files_list
(
socket
,
data
)
},
package_file_list
:
function
(
socket
,
data
)
{
__send_package_files_list
(
socket
,
data
)
},
distribution_packages
:
function
(
socket
,
data
)
{
__send_distribution_packages
(
socket
,
data
)
},
file
:
function
(
socket
,
data
)
{
__send_file
(
socket
,
data
)
},
file_newcontent
:
function
(
socket
,
data
)
{
socket
.
emit
(
'
file_newcontent
'
,
data
);
}
distribution_packages
:
function
(
socket
,
data
)
{
__send_distribution_packages
(
socket
,
data
)
},
file
:
function
(
socket
,
data
)
{
__send_file
(
socket
,
data
)
},
file_newcontent
:
function
(
socket
,
data
)
{
socket
.
emit
(
'
file_newcontent
'
,
data
);
}
}
module
.
exports
=
debomatic_sender
debomatic-webui/utils.js
View file @
9f520661
...
...
@@ -2,48 +2,48 @@ var path = require('path')
,
config
=
require
(
'
./config.js
'
)
function
__check_data_distribution
(
data
)
{
return
data
&&
data
.
distribution
&&
data
.
distribution
.
name
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
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
return
__check_data_package
(
data
)
&&
data
.
file
.
name
}
function
__get_distribution_pool_path
(
data
)
{
return
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
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
)
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
.
package
.
name
+
'
_
'
+
data
.
package
.
version
+
'
.
'
+
data
.
file
.
name
)
return
path
.
join
(
__get_package_path
(
data
),
data
.
package
.
name
+
'
_
'
+
data
.
package
.
version
+
'
.
'
+
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
)
},
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