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
Hide 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);
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
send
.
distributions
(
socket
);
socket
.
on
(
'
get-view
'
,
function
(
data
)
{
socket
.
get
(
'
view
'
,
function
(
err
,
view
)
{
if
(
!
view
||
view
!=
data
)
{
socket
.
get
(
'
watchers
'
,
function
(
err
,
watchers
)
{
if
(
watchers
)
watchers
.
forEach
(
function
(
w
){
w
.
close
()
});
watchers
=
[]
socket
.
set
(
'
view
'
,
data
,
function
()
{
packages_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
// watch on incoming packages
try
{
watchIncomingPackages
=
fs
.
watch
(
packages_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
send
.
view
(
socket
,
data
);
});
watchers
.
push
(
watchIncomingPackages
);
}
catch
(
err
)
{}
// if user is viewing a package, watch package dir
if
(
data
.
package
&&
data
.
package
.
name
&&
data
.
package
.
version
)
{
pack_path
=
path
.
join
(
packages_path
,
data
.
package
.
name
+
'
_
'
+
data
.
package
.
version
);
try
{
watchPackageFiles
=
fs
.
watch
(
pack_path
,
{
persistent
:
true
},
function
(
event
,
filename
)
{
if
(
event
==
'
rename
'
)
send
.
view
(
socket
,
data
);
});
watchers
.
push
(
watchPackageFiles
)
}
catch
(
err
)
{}
}
socket
.
set
(
'
watchers
'
,
watchers
);
});
// send distribution packages
socket
.
on
(
'
get_distribution_packages
'
,
function
(
data
)
{
if
(
!
data
)
return
socket
.
get
(
"
watcher-distribution-packages
"
,
function
(
err
,
watcher
){
if
(
watcher
)
watcher
.
close
()
if
(
!
data
.
distribution
||
!
data
.
distribution
.
name
)
return
packages_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
// watch for incoming packages
try
{
watcher
=
fs
.
watch
(
packages_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
send
.
distribution_packages
(
socket
,
data
);
});
send
.
view
(
socket
,
data
);
};
});
});
socket
.
set
(
'
watcher-distribution-packages
'
,
watcher
);
}
catch
(
err
)
{}
})
send
.
distribution_packages
(
socket
,
data
);
})
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
{
watcher
=
fs
.
watch
(
package_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
send
.
package_file_list
(
socket
,
data
);
});
socket
.
set
(
'
watcher-package-files-list
'
,
watcher
);
}
catch
(
err
)
{}
})
send
.
package_file_list
(
socket
,
data
);
})
});
io
.
sockets
.
on
(
'
disconnect
'
,
function
(
socket
){
socket
.
get
(
'
watchers
'
,
function
(
err
,
watchers
)
{
if
(
watchers
)
watchers
.
forEach
(
function
(
w
){
...
...
debomatic-webui/send.js
View file @
fa1dac59
...
...
@@ -4,7 +4,7 @@ var fs = require('fs')
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
){
result
=
[];
if
(
err
)
{
...
...
@@ -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
=
{}
get_files_list
(
package_path
,
false
,
function
(
files
)
{
__
get_files_list
(
package_path
,
false
,
function
(
files
)
{
package_info
.
files
=
[]
package_info
.
debs
=
[]
package_info
.
archives
=
[]
files
.
forEach
(
function
(
f
)
{
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
.
name
=
f
.
split
(
'
_
'
)[
0
]
file
.
label
=
f
.
replace
(
file
.
name
+
'
_
'
,
''
)
...
...
@@ -55,44 +55,56 @@ function get_files_list_from_pacakge(package_path, callback) {
});
}
function
__send_package_files_list
(
socket
,
data
)
{
if
(
!
data
.
package
||
!
data
.
distribution
)
return
distro_path
=
path
.
join
(
BASE_DIR
,
data
.
distribution
.
name
,
'
pool
'
);
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
)
});
}
function
__send_distribution_packages
(
socket
,
data
)
{
if
(
!
data
.
distribution
||
!
data
.
distribution
.
name
)
return
;
distro_path
=
path
.
join
(
BASE_DIR
,
data
.
distribution
.
name
,
'
pool
'
);
__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
)
});
}
debomatic_sender
=
{
distributions
:
function
(
socket
)
{
get_files_list
(
BASE_DIR
,
true
,
function
(
distros
){
__
get_files_list
(
BASE_DIR
,
true
,
function
(
distros
){
socket
.
emit
(
'
distributions
'
,
distros
);
});
},
view
:
function
(
socket
,
data
)
{
distro_path
=
path
.
join
(
BASE_DIR
,
data
.
distribution
.
name
,
'
pool
'
);
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
)
});
if
(
data
.
package
)
{
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
)
}
});
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 @@
if
(
info
.
length
>=
1
)
{
data
.
distribution
=
{}
data
.
distribution
.
name
=
info
[
0
];
socket
.
emit
(
"
get_distribution_packages
"
,
data
)
}
if
(
info
.
length
>=
3
){
data
.
package
=
{}
data
.
package
.
name
=
info
[
1
];
data
.
package
.
version
=
info
[
2
];
socket
.
emit
(
"
get_package_file_list
"
,
data
)
}
if
(
info
.
length
=
=
4
)
{
if
(
info
.
length
>
=
4
)
{
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
'
);
socket
.
on
(
'
distributions
'
,
function
(
distributions
)
{
...
...
@@ -54,10 +35,20 @@
});
});
socket
.
on
(
'
view
'
,
function
(
data
){
console
.
log
(
data
)
set_up_view
(
data
)
});
socket
.
on
(
'
distribution_packages
'
,
function
(
data
){
$
(
'
#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>
'
)
})
})
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
)
});
...
...
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