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
fa1dac59
Commit
fa1dac59
authored
Mar 08, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split single event get view in three different ones
parent
6baf925a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
97 deletions
+109
-97
debomatic-webui/app.js
debomatic-webui/app.js
+44
-35
debomatic-webui/send.js
debomatic-webui/send.js
+47
-35
debomatic-webui/views/layout.ejs
debomatic-webui/views/layout.ejs
+18
-27
No files found.
debomatic-webui/app.js
View file @
fa1dac59
...
@@ -40,44 +40,53 @@ app.get('/', routes.index);
...
@@ -40,44 +40,53 @@ app.get('/', routes.index);
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
send
.
distributions
(
socket
);
send
.
distributions
(
socket
);
socket
.
on
(
'
get-view
'
,
function
(
data
)
{
socket
.
get
(
'
view
'
,
function
(
err
,
view
)
{
// send distribution packages
if
(
!
view
||
view
!=
data
)
{
socket
.
on
(
'
get_distribution_packages
'
,
function
(
data
)
{
socket
.
get
(
'
watchers
'
,
function
(
err
,
watchers
)
{
if
(
!
data
)
if
(
watchers
)
watchers
.
forEach
(
function
(
w
){
return
w
.
close
()
socket
.
get
(
"
watcher-distribution-packages
"
,
function
(
err
,
watcher
){
});
if
(
watcher
)
watchers
=
[]
watcher
.
close
()
socket
.
set
(
'
view
'
,
data
,
function
()
{
if
(
!
data
.
distribution
||
!
data
.
distribution
.
name
)
return
packages_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
packages_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
// watch on
incoming packages
// watch for
incoming packages
try
{
try
{
watchIncomingPackages
=
fs
.
watch
(
packages_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
watcher
=
fs
.
watch
(
packages_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
if
(
event
==
'
rename
'
)
send
.
view
(
socket
,
data
);
send
.
distribution_packages
(
socket
,
data
);
});
});
watchers
.
push
(
watchIncomingPackages
);
socket
.
set
(
'
watcher-distribution-packages
'
,
watcher
);
}
catch
(
err
)
{}
}
catch
(
err
)
{}
// if user is viewing a package, watch package dir
})
if
(
data
.
package
&&
data
.
package
.
name
&&
data
.
package
.
version
)
{
send
.
distribution_packages
(
socket
,
data
);
pack_path
=
path
.
join
(
packages_path
,
data
.
package
.
name
+
'
_
'
+
data
.
package
.
version
);
})
socket
.
on
(
'
get_package_file_list
'
,
function
(
data
)
{
if
(
!
data
)
return
socket
.
get
(
'
wather-package-files-list
'
,
function
(
err
,
watcher
)
{
if
(
watcher
)
watcher
.
close
()
if
(
!
data
.
distribution
||
!
data
.
distribution
.
name
||
!
data
.
package
||
!
data
.
package
.
name
||
!
data
.
package
.
version
)
return
package_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
,
data
.
package
.
name
+
"
_
"
+
data
.
package
.
version
)
try
{
try
{
watchPackageFiles
=
fs
.
watch
(
pack_path
,
{
persistent
:
true
},
function
(
event
,
filen
ame
)
{
watcher
=
fs
.
watch
(
package_path
,
{
persistent
:
true
},
function
(
event
,
fileN
ame
)
{
if
(
event
==
'
rename
'
)
if
(
event
==
'
rename
'
)
send
.
view
(
socket
,
data
);
send
.
package_file_list
(
socket
,
data
);
});
});
watchers
.
push
(
watchPackageFiles
)
socket
.
set
(
'
watcher-package-files-list
'
,
watcher
);
}
catch
(
err
)
{}
}
catch
(
err
)
{}
}
})
socket
.
set
(
'
watchers
'
,
watchers
);
send
.
package_file_list
(
socket
,
data
);
});
})
});
send
.
view
(
socket
,
data
);
};
});
});
});
});
io
.
sockets
.
on
(
'
disconnect
'
,
function
(
socket
){
io
.
sockets
.
on
(
'
disconnect
'
,
function
(
socket
){
socket
.
get
(
'
watchers
'
,
function
(
err
,
watchers
)
{
socket
.
get
(
'
watchers
'
,
function
(
err
,
watchers
)
{
if
(
watchers
)
watchers
.
forEach
(
function
(
w
){
if
(
watchers
)
watchers
.
forEach
(
function
(
w
){
...
...
debomatic-webui/send.js
View file @
fa1dac59
...
@@ -4,7 +4,7 @@ var fs = require('fs')
...
@@ -4,7 +4,7 @@ var fs = require('fs')
var
BASE_DIR
=
config
.
debomatic_path
;
var
BASE_DIR
=
config
.
debomatic_path
;
function
get_files_list
(
dir
,
onlyDirectories
,
callback
)
{
function
__
get_files_list
(
dir
,
onlyDirectories
,
callback
)
{
fs
.
readdir
(
dir
,
function
(
err
,
files
){
fs
.
readdir
(
dir
,
function
(
err
,
files
){
result
=
[];
result
=
[];
if
(
err
)
{
if
(
err
)
{
...
@@ -28,15 +28,15 @@ function get_files_list(dir, onlyDirectories, callback) {
...
@@ -28,15 +28,15 @@ function get_files_list(dir, onlyDirectories, callback) {
});
});
}
}
function
get_files_list_from_pacakge
(
package_path
,
callback
)
{
function
__
get_files_list_from_pacakge
(
package_path
,
callback
)
{
package_info
=
{}
package_info
=
{}
get_files_list
(
package_path
,
false
,
function
(
files
)
{
__
get_files_list
(
package_path
,
false
,
function
(
files
)
{
package_info
.
files
=
[]
package_info
.
files
=
[]
package_info
.
debs
=
[]
package_info
.
debs
=
[]
package_info
.
archives
=
[]
package_info
.
archives
=
[]
files
.
forEach
(
function
(
f
)
{
files
.
forEach
(
function
(
f
)
{
file
=
{}
file
=
{}
file
.
path
=
path
.
join
(
pack_path
,
f
).
replace
(
config
.
debomatic_path
,
config
.
debomatic_webpath
)
file
.
path
=
path
.
join
(
pack
age
_path
,
f
).
replace
(
config
.
debomatic_path
,
config
.
debomatic_webpath
)
file
.
orig_name
=
f
file
.
orig_name
=
f
file
.
name
=
f
.
split
(
'
_
'
)[
0
]
file
.
name
=
f
.
split
(
'
_
'
)[
0
]
file
.
label
=
f
.
replace
(
file
.
name
+
'
_
'
,
''
)
file
.
label
=
f
.
replace
(
file
.
name
+
'
_
'
,
''
)
...
@@ -55,17 +55,25 @@ function get_files_list_from_pacakge(package_path, callback) {
...
@@ -55,17 +55,25 @@ function get_files_list_from_pacakge(package_path, callback) {
});
});
}
}
debomatic_sender
=
{
function
__send_package_files_list
(
socket
,
data
)
{
if
(
!
data
.
package
||
!
data
.
distribution
)
distributions
:
function
(
socket
)
{
return
get_files_list
(
BASE_DIR
,
true
,
function
(
distros
){
distro_path
=
path
.
join
(
BASE_DIR
,
data
.
distribution
.
name
,
'
pool
'
);
socket
.
emit
(
'
distributions
'
,
distros
);
p
=
data
.
package
.
name
+
"
_
"
+
data
.
package
.
version
package_path
=
path
.
join
(
distro_path
,
p
)
__get_files_list_from_pacakge
(
package_path
,
function
(
package_files
){
data
.
package
.
files
=
package_files
.
files
data
.
package
.
debs
=
package_files
.
debs
data
.
package
.
archives
=
package_files
.
archives
socket
.
emit
(
'
package_file_list
'
,
data
)
});
});
},
}
view
:
function
(
socket
,
data
)
{
function
__send_distribution_packages
(
socket
,
data
)
{
if
(
!
data
.
distribution
||
!
data
.
distribution
.
name
)
return
;
distro_path
=
path
.
join
(
BASE_DIR
,
data
.
distribution
.
name
,
'
pool
'
);
distro_path
=
path
.
join
(
BASE_DIR
,
data
.
distribution
.
name
,
'
pool
'
);
get_files_list
(
distro_path
,
true
,
function
(
packages
)
{
__
get_files_list
(
distro_path
,
true
,
function
(
packages
)
{
data
.
distribution
.
packages
=
[]
data
.
distribution
.
packages
=
[]
packages
.
forEach
(
function
(
p
)
{
packages
.
forEach
(
function
(
p
)
{
pack
=
{}
pack
=
{}
...
@@ -79,20 +87,24 @@ debomatic_sender = {
...
@@ -79,20 +87,24 @@ debomatic_sender = {
}
}
data
.
distribution
.
packages
.
push
(
pack
)
data
.
distribution
.
packages
.
push
(
pack
)
});
});
if
(
data
.
package
)
{
socket
.
emit
(
"
distribution_packages
"
,
data
)
p
=
data
.
package
.
name
+
"
_
"
+
data
.
package
.
version
package_path
=
path
.
join
(
distro_path
,
p
)
get_files_list_from_pacakge
(
package_path
,
function
(
package_files
){
data
.
package
.
files
=
package_files
.
files
data
.
package
.
debs
=
package_files
.
debs
data
.
package
.
archives
=
package_files
.
archives
socket
.
emit
(
'
view
'
,
data
)
});
});
}
}
else
{
socket
.
emit
(
'
view
'
,
data
)
debomatic_sender
=
{
}
distributions
:
function
(
socket
)
{
__get_files_list
(
BASE_DIR
,
true
,
function
(
distros
){
socket
.
emit
(
'
distributions
'
,
distros
);
});
});
},
package_file_list
:
function
(
socket
,
data
)
{
__send_package_files_list
(
socket
,
data
)
},
distribution_packages
:
function
(
socket
,
data
)
{
__send_distribution_packages
(
socket
,
data
)
}
}
}
}
...
...
debomatic-webui/views/layout.ejs
View file @
fa1dac59
...
@@ -12,39 +12,20 @@
...
@@ -12,39 +12,20 @@
if
(
info
.
length
>=
1
)
{
if
(
info
.
length
>=
1
)
{
data
.
distribution
=
{}
data
.
distribution
=
{}
data
.
distribution
.
name
=
info
[
0
];
data
.
distribution
.
name
=
info
[
0
];
socket
.
emit
(
"
get_distribution_packages
"
,
data
)
}
}
if
(
info
.
length
>=
3
){
if
(
info
.
length
>=
3
){
data
.
package
=
{}
data
.
package
=
{}
data
.
package
.
name
=
info
[
1
];
data
.
package
.
name
=
info
[
1
];
data
.
package
.
version
=
info
[
2
];
data
.
package
.
version
=
info
[
2
];
socket
.
emit
(
"
get_package_file_list
"
,
data
)
}
}
if
(
info
.
length
=
=
4
)
{
if
(
info
.
length
>
=
4
)
{
data
.
file
=
info
[
3
]
data
.
file
=
info
[
3
]
socket
.
emit
(
'
get-file
'
,
data
)
socket
.
emit
(
"
get_file
"
,
data
)
}
}
else
socket
.
emit
(
'
get-view
'
,
data
);
}
}
function
set_up_view
(
data
)
{
if
(
data
)
{
if
(
data
.
distribution
)
{
if
(
data
.
distribution
.
name
&&
data
.
distribution
.
packages
)
{
$
(
'
#packages
'
).
html
(
''
)
data
.
distribution
.
packages
.
forEach
(
function
(
p
){
div
=
$
(
'
#packages
'
).
append
(
'
<li><a href="#
'
+
data
.
distribution
.
name
+
'
/
'
+
p
.
name
+
'
/
'
+
p
.
version
+
'
">
'
+
p
.
name
+
'
<span>
'
+
p
.
version
+
'
</span></a></li>
'
)
})
}
if
(
data
.
package
)
{
$
(
'
#files
'
).
html
(
''
);
data
.
package
.
files
.
forEach
(
function
(
f
){
p
=
data
.
package
$
(
'
#files
'
).
append
(
'
<li><a href="#
'
+
data
.
distribution
.
name
+
'
/
'
+
p
.
name
+
'
/
'
+
p
.
version
+
'
/
'
+
f
.
name
+
'
">
'
+
f
.
name
+
'
</a></li>
'
)
})
}
}
}
}
var
socket
=
io
.
connect
(
'
//localhost:3000
'
);
var
socket
=
io
.
connect
(
'
//localhost:3000
'
);
socket
.
on
(
'
distributions
'
,
function
(
distributions
)
{
socket
.
on
(
'
distributions
'
,
function
(
distributions
)
{
...
@@ -54,10 +35,20 @@
...
@@ -54,10 +35,20 @@
});
});
});
});
socket
.
on
(
'
view
'
,
function
(
data
){
socket
.
on
(
'
distribution_packages
'
,
function
(
data
){
console
.
log
(
data
)
$
(
'
#packages
'
).
html
(
''
)
set_up_view
(
data
)
data
.
distribution
.
packages
.
forEach
(
function
(
p
){
});
div
=
$
(
'
#packages
'
).
append
(
'
<li><a href="#
'
+
data
.
distribution
.
name
+
'
/
'
+
p
.
name
+
'
/
'
+
p
.
version
+
'
">
'
+
p
.
name
+
'
<span>
'
+
p
.
version
+
'
</span></a></li>
'
)
})
})
socket
.
on
(
'
package_file_list
'
,
function
(
data
){
$
(
'
#files
'
).
html
(
''
);
data
.
package
.
files
.
forEach
(
function
(
f
){
p
=
data
.
package
$
(
'
#files
'
).
append
(
'
<li><a href="#
'
+
data
.
distribution
.
name
+
'
/
'
+
p
.
name
+
'
/
'
+
p
.
version
+
'
/
'
+
f
.
name
+
'
">
'
+
f
.
name
+
'
</a></li>
'
)
})
})
socket
.
on
(
'
error
'
,
function
()
{
console
.
error
(
arguments
)
});
socket
.
on
(
'
error
'
,
function
()
{
console
.
error
(
arguments
)
});
...
...
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