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
f7a4f04a
Commit
f7a4f04a
authored
Jun 06, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into portable
parents
04380791
43903d3a
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1431 additions
and
1435 deletions
+1431
-1435
debomatic-webui/debomatic-webui
debomatic-webui/debomatic-webui
+5
-0
debomatic-webui/lib/broadcaster.js
debomatic-webui/lib/broadcaster.js
+59
-59
debomatic-webui/lib/client.js
debomatic-webui/lib/client.js
+158
-161
debomatic-webui/lib/config.js
debomatic-webui/lib/config.js
+94
-97
debomatic-webui/lib/parser.js
debomatic-webui/lib/parser.js
+30
-29
debomatic-webui/lib/tail.js
debomatic-webui/lib/tail.js
+32
-30
debomatic-webui/lib/utils.js
debomatic-webui/lib/utils.js
+135
-131
debomatic-webui/public/javascripts/debug.js
debomatic-webui/public/javascripts/debug.js
+21
-20
debomatic-webui/public/javascripts/main.js
debomatic-webui/public/javascripts/main.js
+20
-19
debomatic-webui/public/javascripts/page_distribution.js
debomatic-webui/public/javascripts/page_distribution.js
+563
-577
debomatic-webui/public/javascripts/page_generic.js
debomatic-webui/public/javascripts/page_generic.js
+168
-171
debomatic-webui/public/javascripts/preferences.js
debomatic-webui/public/javascripts/preferences.js
+52
-50
debomatic-webui/public/javascripts/utils.js
debomatic-webui/public/javascripts/utils.js
+88
-89
debomatic-webui/views/distribution.ejs
debomatic-webui/views/distribution.ejs
+6
-2
No files found.
debomatic-webui/debomatic-webui
View file @
f7a4f04a
...
@@ -19,6 +19,11 @@ var express = require('express'),
...
@@ -19,6 +19,11 @@ var express = require('express'),
Broadcaster = require('./lib/broadcaster.js');
Broadcaster = require('./lib/broadcaster.js');
// serve dsc files as octet-stream
serve_static.mime.define({
'application/octet-stream': ['dsc']
});
app.set('views', __dirname + '/views');
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.set('view engine', 'ejs');
app.use(serve_static(__dirname + '/public'));
app.use(serve_static(__dirname + '/public'));
...
...
debomatic-webui/lib/broadcaster.js
View file @
f7a4f04a
var
config
=
require
(
'
./config.js
'
)
'
use strict
'
;
,
fs
=
require
(
'
fs
'
)
,
Tail
=
require
(
'
./tail.js
'
)
function
__watch_status_check_same_obj
(
obj1
,
obj2
)
{
var
config
=
require
(
'
./config.js
'
),
if
(
obj1
.
status
==
obj2
.
status
)
{
fs
=
require
(
'
fs
'
),
if
(
obj1
.
distribution
==
obj2
.
distribution
)
{
utils
=
require
(
'
./utils.js
'
),
if
(
obj1
.
hasOwnProperty
(
'
package
'
)
&&
Tail
=
require
(
'
./tail.js
'
);
obj2
.
hasOwnProperty
(
'
package
'
))
{
function
__watch_status_check_same_obj
(
obj1
,
obj2
)
{
if
(
obj1
.
package
==
obj2
.
package
)
if
(
obj1
.
status
==
obj2
.
status
)
{
return
true
;
if
(
obj1
.
distribution
==
obj2
.
distribution
)
{
return
false
if
(
obj1
.
hasOwnProperty
(
'
package
'
)
&&
}
obj2
.
hasOwnProperty
(
'
package
'
))
{
return
true
if
(
obj1
.
package
==
obj2
.
package
)
return
true
;
return
false
;
}
return
true
;
}
}
}
}
return
false
;
return
false
}
}
// watcher on build_status
// watcher on build_status
function
__watch_status
(
socket
,
status
)
{
function
__watch_status
(
socket
,
status
)
{
var
watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
)
var
watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
);
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
var
data
=
null
var
data
=
null
;
try
{
try
{
data
=
JSON
.
parse
(
new_content
)
data
=
JSON
.
parse
(
new_content
);
}
catch
(
err
)
{
}
catch
(
err
)
{
utils
.
errors_handler
(
'
Broadcaster:__watch_status:JSON.parse(new_content) -
'
,
err
,
socket
)
utils
.
errors_handler
(
'
Broadcaster:__watch_status:JSON.parse(new_content) -
'
,
err
,
socket
);
return
return
;
}
// looking for same status already in statuses lists
if
(
data
.
hasOwnProperty
(
'
success
'
))
{
for
(
i
=
0
;
i
<
status
.
length
;
i
++
)
{
if
(
__watch_status_check_same_obj
(
data
,
status
[
i
]))
{
status
.
splice
(
i
,
1
)
break
;
}
}
else
// looking for same status already in statuses lists
continue
;
if
(
data
.
hasOwnProperty
(
'
success
'
))
{
}
for
(
var
i
=
0
;
i
<
status
.
length
;
i
++
)
{
}
if
(
__watch_status_check_same_obj
(
data
,
status
[
i
]))
{
else
{
status
.
splice
(
i
,
1
);
status
.
push
(
data
)
break
;
}
}
else
socket
.
emit
(
config
.
events
.
broadcast
.
status_update
,
data
)
continue
;
})
}
watcher
.
on
(
'
error
'
,
function
(
msg
)
{
}
else
{
socket
.
emit
(
config
.
events
.
error
,
msg
)
status
.
push
(
data
);
})
}
socket
.
emit
(
config
.
events
.
broadcast
.
status_update
,
data
);
});
watcher
.
on
(
'
error
'
,
function
(
msg
)
{
socket
.
emit
(
config
.
events
.
error
,
msg
);
});
}
}
// watcher on new distributions
// watcher on new distributions
function
__watch_distributions
(
socket
)
{
function
__watch_distributions
(
socket
)
{
fs
.
watch
(
config
.
debomatic
.
path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
fs
.
watch
(
config
.
debomatic
.
path
,
{
// wait half a second to get pool subdir created
persistent
:
true
setTimeout
(
function
()
{
},
function
(
event
,
fileName
)
{
utils
.
send_distributions
(
socket
)
// wait half a second to get pool subdir created
},
500
)
setTimeout
(
function
()
{
})
utils
.
send_distributions
(
socket
);
},
500
);
});
}
}
function
Broadcaster
(
sockets
,
status
)
{
function
Broadcaster
(
sockets
,
status
)
{
var
sockets
=
sockets
__watch_status
(
sockets
,
status
)
__watch_status
(
sockets
,
status
);
__watch_distributions
(
sockets
)
__watch_distributions
(
sockets
);
return
{
return
{
}
};
}
}
module
.
exports
=
Broadcaster
module
.
exports
=
Broadcaster
;
debomatic-webui/lib/client.js
View file @
f7a4f04a
var
fs
=
require
(
'
fs
'
)
'
use strict
'
;
,
path
=
require
(
'
path
'
)
var
fs
=
require
(
'
fs
'
),
,
config
=
require
(
'
./config.js
'
)
path
=
require
(
'
path
'
),
,
utils
=
require
(
'
./utils.js
'
)
config
=
require
(
'
./config.js
'
),
utils
=
require
(
'
./utils.js
'
);
var
_e
=
config
.
events
.
client
var
_e
=
config
.
events
.
client
;
function
__get_files_list_from_package
(
data
,
callback
)
{
function
__get_files_list_from_package
(
data
,
callback
)
{
package_path
=
utils
.
get_package_path
(
data
)
var
package_path
=
utils
.
get_package_path
(
data
);
utils
.
get_files_list
(
package_path
,
false
,
function
(
files
)
{
utils
.
get_files_list
(
package_path
,
false
,
function
(
files
)
{
data
.
package
.
files
=
[]
data
.
package
.
files
=
[];
data
.
package
.
debs
=
[]
data
.
package
.
debs
=
[];
data
.
package
.
sources
=
[]
data
.
package
.
sources
=
[];
files
.
forEach
(
function
(
f
)
{
files
.
forEach
(
function
(
f
)
{
file
=
{}
var
file
=
{};
file
.
path
=
path
.
join
(
package_path
,
f
).
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
file
.
path
=
path
.
join
(
package_path
,
f
).
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
);
file
.
orig_name
=
f
file
.
orig_name
=
f
;
file
.
name
=
f
.
split
(
'
_
'
)[
0
]
file
.
name
=
f
.
split
(
'
_
'
)[
0
];
file
.
extension
=
f
.
split
(
'
.
'
).
pop
();
file
.
extension
=
f
.
split
(
'
.
'
).
pop
();
if
(
file
.
extension
==
"
deb
"
||
file
.
extension
==
"
ddeb
"
)
{
if
(
file
.
extension
==
'
deb
'
||
file
.
extension
==
'
ddeb
'
)
{
data
.
package
.
debs
.
push
(
file
);
data
.
package
.
debs
.
push
(
file
);
}
}
else
if
(
f
.
indexOf
(
'
.tar
'
)
>=
0
||
file
.
extension
==
'
changes
'
||
file
.
extension
==
'
dsc
'
)
{
else
if
(
f
.
indexOf
(
'
.tar
'
)
>=
0
||
file
.
extension
==
"
changes
"
||
file
.
extension
==
"
dsc
"
)
{
file
.
name
=
f
.
replace
(
data
.
package
.
name
+
'
_
'
+
data
.
package
.
version
+
'
.
'
,
''
);
file
.
name
=
f
.
replace
(
data
.
package
.
name
+
'
_
'
+
data
.
package
.
version
+
'
.
'
,
'
'
)
if
(
file
.
extension
==
'
changes
'
)
if
(
file
.
extension
==
'
changes
'
)
file
.
name
=
file
.
extension
;
file
.
name
=
file
.
extension
else
if
(
f
.
indexOf
(
'
.tar
'
)
>=
0
&&
f
.
indexOf
(
'
.orig.
'
)
>
0
)
else
if
(
f
.
indexOf
(
'
.tar
'
)
>=
0
&&
f
.
indexOf
(
'
.orig.
'
)
>
0
)
file
.
name
=
'
orig.
'
+
f
.
split
(
'
.orig.
'
).
pop
();
file
.
name
=
'
orig.
'
+
f
.
split
(
'
.orig.
'
).
pop
()
data
.
package
.
sources
.
push
(
file
);
data
.
package
.
sources
.
push
(
file
)
}
else
{
}
file
.
name
=
file
.
extension
;
else
{
data
.
package
.
files
.
push
(
file
);
file
.
name
=
file
.
extension
}
data
.
package
.
files
.
push
(
file
)
});
}
callback
(
data
);
});
});
callback
(
data
);
});
}
}
function
__send_package_files_list
(
event_name
,
socket
,
data
)
{
function
__send_package_files_list
(
event_name
,
socket
,
data
)
{
__get_files_list_from_package
(
data
,
function
(
new_data
)
{
__get_files_list_from_package
(
data
,
function
(
new_data
)
{
socket
.
emit
(
event_name
,
new_data
)
socket
.
emit
(
event_name
,
new_data
);
});
});
}
}
function
__send_package_status
(
socket
,
data
,
package_data
)
{
function
__send_package_status
(
socket
,
data
,
package_data
)
{
var
event_name
=
config
.
events
.
client
.
distribution_packages
.
status
var
event_name
=
config
.
events
.
client
.
distribution_packages
.
status
;
var
new_data
=
{}
var
new_data
=
{};
new_data
.
distribution
=
data
.
distribution
new_data
.
distribution
=
data
.
distribution
;
new_data
.
package
=
package_data
new_data
.
package
=
package_data
;
var
status_data
=
{}
var
status_data
=
{};
status_data
.
status
=
config
.
status
.
build
status_data
.
status
=
config
.
status
.
build
;
status_data
.
distribution
=
data
.
distribution
.
name
status_data
.
distribution
=
data
.
distribution
.
name
;
status_data
.
package
=
package_data
.
orig_name
status_data
.
package
=
package_data
.
orig_name
;
var
package_path
=
utils
.
get_package_path
(
new_data
)
var
package_path
=
utils
.
get_package_path
(
new_data
);
// status policy:
// status policy:
// + successed: exists .dsc
// + successed: exists .dsc
// + building: wc -l .datestamp == 1 (FIX_ME)
// + building: wc -l .datestamp == 1 (FIX_ME)
// + failed: else
// + failed: else
var
base_path
=
path
.
join
(
package_path
,
package_data
.
orig_name
)
var
base_path
=
path
.
join
(
package_path
,
package_data
.
orig_name
);
fs
.
exists
(
base_path
+
'
.dsc
'
,
function
(
dsc_exists
){
fs
.
exists
(
base_path
+
'
.dsc
'
,
function
(
dsc_exists
)
{
if
(
dsc_exists
)
{
if
(
dsc_exists
)
{
status_data
.
success
=
config
.
status
.
success
status_data
.
success
=
config
.
status
.
success
;
socket
.
emit
(
event_name
,
status_data
)
socket
.
emit
(
event_name
,
status_data
);
}
}
else
{
else
{
// emulate wc -l .datestamp in nodejs
// emulate wc -l .datestamp in nodejs
var
count
=
0
;
var
count
=
0
var
datestamp
=
base_path
+
'
.datestamp
'
;
var
datestamp
=
base_path
+
'
.datestamp
'
fs
.
exists
(
datestamp
,
function
(
datestamp_exists
)
{
fs
.
exists
(
datestamp
,
function
(
datestamp_exists
){
if
(
datestamp_exists
)
{
if
(
datestamp_exists
)
{
// count lines
// count lines
fs
.
createReadStream
(
datestamp
)
fs
.
createReadStream
(
datestamp
)
.
on
(
'
data
'
,
function
(
chunk
)
{
.
on
(
'
data
'
,
function
(
chunk
)
{
for
(
var
i
=
0
;
i
<
chunk
.
length
;
++
i
)
for
(
var
i
=
0
;
i
<
chunk
.
length
;
++
i
)
if
(
chunk
[
i
]
==
10
)
count
++
;
if
(
chunk
[
i
]
==
10
)
count
++
;
})
})
.
on
(
'
end
'
,
function
()
{
.
on
(
'
end
'
,
function
()
{
if
(
count
>
1
)
if
(
count
>
1
)
status_data
.
success
=
config
.
status
.
fail
;
status_data
.
success
=
config
.
status
.
fail
socket
.
emit
(
event_name
,
status_data
);
socket
.
emit
(
event_name
,
status_data
)
});
});
}
});
}
}
})
}
})
}
function
__send_distribution_packages
(
event_name
,
socket
,
data
)
{
distro_path
=
utils
.
get_distribution_pool_path
(
data
)
utils
.
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
]
pack
.
orig_name
=
p
data
.
distribution
.
packages
.
push
(
pack
)
__send_package_status
(
socket
,
data
,
pack
)
});
});
socket
.
emit
(
event_name
,
data
)
});
}
function
__send_file
(
event_name
,
socket
,
data
)
{
var
file_path
=
utils
.
get_file_path
(
data
)
fs
.
readFile
(
file_path
,
'
utf8
'
,
function
(
err
,
content
)
{
if
(
err
)
{
utils
.
errors_handler
(
'
client:__send_file
'
,
err
,
socket
)
return
}
data
.
file
.
orig_name
=
file_path
.
split
(
'
/
'
).
pop
()
data
.
file
.
content
=
content
data
.
file
.
path
=
file_path
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
socket
.
emit
(
event_name
,
data
)
});
}
}
function
__handler_get_file
(
socket
,
data
)
{
function
__send_distribution_packages
(
event_name
,
socket
,
data
)
{
var
file_path
=
utils
.
get_file_path
(
data
)
var
distro_path
=
utils
.
get_distribution_pool_path
(
data
);
utils
.
watch_path_onsocket
(
_e
.
file_newcontent
,
socket
,
data
,
file_path
,
function
(
event_name
,
socket
,
data
)
{
utils
.
get_files_list
(
distro_path
,
true
,
function
(
packages
)
{
data
.
file
.
content
=
null
data
.
distribution
.
packages
=
[];
socket
.
emit
(
event_name
,
data
)
packages
.
forEach
(
function
(
p
)
{
})
var
pack
=
{};
__send_file
(
_e
.
file
.
set
,
socket
,
data
)
var
info
=
p
.
split
(
'
_
'
);
pack
.
name
=
info
[
0
];
pack
.
version
=
info
[
1
];
pack
.
orig_name
=
p
;
data
.
distribution
.
packages
.
push
(
pack
);
__send_package_status
(
socket
,
data
,
pack
);
});
socket
.
emit
(
event_name
,
data
);
});
}
}
function
Client
(
socket
)
{
function
__send_file
(
event_name
,
socket
,
data
)
{
var
file_path
=
utils
.
get_file_path
(
data
);
var
socket
=
socket
fs
.
readFile
(
file_path
,
'
utf8
'
,
function
(
err
,
content
)
{
if
(
err
)
{
this
.
start
=
function
()
{
utils
.
errors_handler
(
'
client:__send_file
'
,
err
,
socket
);
// init send distributions
return
;
utils
.
send_distributions
(
socket
)
// init events
socket
.
on
(
_e
.
distribution_packages
.
get
,
function
(
data
)
{
if
(
!
utils
.
check_data_distribution
(
data
))
return
distribution_path
=
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
'
pool
'
)
utils
.
generic_handler_watcher
(
_e
.
distribution_packages
.
set
,
socket
,
data
,
distribution_path
,
__send_distribution_packages
)
})
socket
.
on
(
_e
.
package_files_list
.
get
,
function
(
data
)
{
if
(
!
utils
.
check_data_package
(
data
))
return
package_path
=
utils
.
get_package_path
(
data
)
utils
.
generic_handler_watcher
(
_e
.
package_files_list
.
set
,
socket
,
data
,
package_path
,
__send_package_files_list
)
})
socket
.
on
(
_e
.
file
.
get
,
function
(
data
){
if
(
!
utils
.
check_data_file
(
data
))
return
__handler_get_file
(
socket
,
data
)
})
// on client disconnection close all watchers
socket
.
on
(
'
disconnect
'
,
function
()
{
socket
.
get
(
"
watchers
"
,
function
(
err
,
socket_watchers
){
if
(
!
socket_watchers
)
return
;
for
(
key
in
socket_watchers
)
{
try
{
socket_watchers
[
key
].
close
()
}
catch
(
err
)
{}
}
}
})
data
.
file
.
orig_name
=
file_path
.
split
(
'
/
'
).
pop
();
data
.
file
.
content
=
content
;
data
.
file
.
path
=
file_path
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
);
socket
.
emit
(
event_name
,
data
);
});
});
}
}
function
__handler_get_file
(
socket
,
data
)
{
var
file_path
=
utils
.
get_file_path
(
data
);
utils
.
watch_path_onsocket
(
_e
.
file_newcontent
,
socket
,
data
,
file_path
,
function
(
event_name
,
socket
,
data
)
{
data
.
file
.
content
=
null
;
socket
.
emit
(
event_name
,
data
);
});
__send_file
(
_e
.
file
.
set
,
socket
,
data
);
}
this
.
send_status
=
function
(
status
)
{
function
Client
(
socket
)
{
socket
.
emit
(
_e
.
status
,
status
)
}
this
.
start
=
function
()
{
// init send distributions
utils
.
send_distributions
(
socket
);
// init events
socket
.
on
(
_e
.
distribution_packages
.
get
,
function
(
data
)
{
if
(
!
utils
.
check_data_distribution
(
data
))
return
;
var
distribution_path
=
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
'
pool
'
);
utils
.
generic_handler_watcher
(
_e
.
distribution_packages
.
set
,
socket
,
data
,
distribution_path
,
__send_distribution_packages
);
});
socket
.
on
(
_e
.
package_files_list
.
get
,
function
(
data
)
{
if
(
!
utils
.
check_data_package
(
data
))
return
;
var
package_path
=
utils
.
get_package_path
(
data
);
utils
.
generic_handler_watcher
(
_e
.
package_files_list
.
set
,
socket
,
data
,
package_path
,
__send_package_files_list
);
});
socket
.
on
(
_e
.
file
.
get
,
function
(
data
)
{
if
(
!
utils
.
check_data_file
(
data
))
return
;
__handler_get_file
(
socket
,
data
);
});
// on client disconnection close all watchers
socket
.
on
(
'
disconnect
'
,
function
()
{
socket
.
get
(
'
watchers
'
,
function
(
err
,
socket_watchers
)
{
if
(
!
socket_watchers
)
return
;
for
(
var
key
in
socket_watchers
)
{
try
{
socket_watchers
[
key
].
close
();
}
catch
(
err
)
{}
}
});
});
};
this
.
send_status
=
function
(
status
)
{
socket
.
emit
(
_e
.
status
,
status
);
};
}
}
module
.
exports
=
Client
module
.
exports
=
Client
;
debomatic-webui/lib/config.js
View file @
f7a4f04a
'
use strict
'
;
/*
/*
* Please DO NOT edit this file.
* Please DO NOT edit this file.
*
*
* Edit auto-generated
"user.config.js"
file instead.
* Edit auto-generated
'user.config.js'
file instead.
*
*
*/
*/
// #start config-auto-export
// #start config-auto-export
var
config
=
{}
var
config
=
{}
;
/*
/*
* Configure host and port.
* Configure host and port.
* Please for ports < 1000 use authbind. DO NOT RUN nodejs as root.
* Please for ports < 1000 use authbind. DO NOT RUN nodejs as root.
* $ authbind nodejs index.js
* $ authbind nodejs index.js
*/
*/
config
.
host
=
'
localhost
'
config
.
host
=
'
localhost
'
;
config
.
port
=
3000
config
.
port
=
3000
;
config
.
socket
=
{}
config
.
socket
=
{}
;
config
.
socket
.
log
=
false
config
.
socket
.
log
=
false
;
config
.
debomatic
=
{}
config
.
debomatic
=
{}
;
config
.
debomatic
.
path
=
'
/srv/debomatic-amd64
'
config
.
debomatic
.
path
=
'
/srv/debomatic-amd64
'
;
config
.
debomatic
.
jsonfile
=
'
/var/log/debomatic-json.log
'
config
.
debomatic
.
jsonfile
=
'
/var/log/debomatic-json.log
'
;
config
.
routes
=
{}
config
.
routes
=
{}
;
config
.
routes
.
debomatic
=
'
/debomatic
'
config
.
routes
.
debomatic
=
'
/debomatic
'
;
config
.
routes
.
distribution
=
'
/distribution
'
config
.
routes
.
distribution
=
'
/distribution
'
;
config
.
routes
.
preferences
=
'
/preferences
'
config
.
routes
.
preferences
=
'
/preferences
'
;
config
.
web
=
{}
config
.
web
=
{}
;
config
.
web
.
title
=
"
Deb-o-Matic web.ui
"
config
.
web
.
title
=
'
Deb-o-Matic web.ui
'
;
config
.
web
.
description
=
"
This is a web interface for debomatic
"
config
.
web
.
description
=
'
This is a web interface for debomatic
'
;
// debomatic configuration exportable for web
// debomatic configuration exportable for web
config
.
web
.
debomatic
=
{}
config
.
web
.
debomatic
=
{}
;
config
.
web
.
debomatic
.
admin
=
{}
config
.
web
.
debomatic
.
admin
=
{}
;
config
.
web
.
debomatic
.
admin
.
name
=
"
Your Name
"
config
.
web
.
debomatic
.
admin
.
name
=
'
Your Name
'
;
config
.
web
.
debomatic
.
admin
.
email
=
"
you AT debian DOT org
"
// please use this SPAMFREE form - it will be converted client side by javascript
config
.
web
.
debomatic
.
admin
.
email
=
'
you AT debian DOT org
'
;
// please use this SPAMFREE form - it will be converted client side by javascript
config
.
web
.
debomatic
.
architecture
=
'
amd64
'
config
.
web
.
debomatic
.
architecture
=
'
amd64
'
;
config
.
web
.
debomatic
.
dput
=
{}
config
.
web
.
debomatic
.
dput
=
{}
;
config
.
web
.
debomatic
.
dput
.
incoming
=
config
.
debomatic
.
path
config
.
web
.
debomatic
.
dput
.
incoming
=
config
.
debomatic
.
path
;
config
.
web
.
debomatic
.
dput
.
host
=
config
.
host
config
.
web
.
debomatic
.
dput
.
host
=
config
.
host
;
config
.
web
.
debomatic
.
dput
.
login
=
"
debomatic
"
config
.
web
.
debomatic
.
dput
.
login
=
'
debomatic
'
;
config
.
web
.
debomatic
.
dput
.
method
=
"
scp
"
config
.
web
.
debomatic
.
dput
.
method
=
'
scp
'
;
config
.
web
.
debomatic
.
dput
.
unsigned_uploads
=
false
config
.
web
.
debomatic
.
dput
.
unsigned_uploads
=
false
;
// default ui settings
// default ui settings
config
.
web
.
preferences
=
{}
config
.
web
.
preferences
=
{}
;
config
.
web
.
preferences
.
autoscroll
=
true
config
.
web
.
preferences
.
autoscroll
=
true
;
config
.
web
.
preferences
.
header
=
true
config
.
web
.
preferences
.
header
=
true
;
config
.
web
.
preferences
.
sidebar
=
true
config
.
web
.
preferences
.
sidebar
=
true
;
config
.
web
.
preferences
.
glossy_theme
=
true
config
.
web
.
preferences
.
glossy_theme
=
true
;
config
.
web
.
preferences
.
file_background
=
true
config
.
web
.
preferences
.
file_background
=
true
;
config
.
web
.
preferences
.
file_fontsize
=
13
// valid values are [13..16]
config
.
web
.
preferences
.
file_fontsize
=
13
;
// valid values are [13..16]
config
.
web
.
preferences
.
debug
=
0
// debug level - 0 means disabled
config
.
web
.
preferences
.
debug
=
0
;
// debug level - 0 means disabled
// #end config-auto-export
// #end config-auto-export
// DO NOT TOUCH these ones
// DO NOT TOUCH these ones
config
.
version
=
'
0.2.
2
'
config
.
version
=
'
0.2.
3
'
;
// A simple function to quickly have
// A simple function to quickly have
// get and set strings for client events
// get and set strings for client events
function
_event_get_set
(
event_name
)
{
function
_event_get_set
(
event_name
)
{
return
{
return
{
set
:
event_name
,
set
:
event_name
,
get
:
'
get_
'
+
event_name
get
:
'
get_
'
+
event_name
}
};
}
}
config
.
events
=
{}
config
.
events
=
{}
;
config
.
events
.
error
=
'
error
'
config
.
events
.
error
=
'
error
'
;
config
.
events
.
broadcast
=
{}
config
.
events
.
broadcast
=
{}
;
config
.
events
.
broadcast
.
distributions
=
'
distributions
'
config
.
events
.
broadcast
.
distributions
=
'
distributions
'
;
config
.
events
.
broadcast
.
status_update
=
'
status_update
'
config
.
events
.
broadcast
.
status_update
=
'
status_update
'
;
config
.
events
.
client
=
{}
config
.
events
.
client
=
{}
;
config
.
events
.
client
.
distribution_packages
=
_event_get_set
(
'
distribution_packages
'
)
config
.
events
.
client
.
distribution_packages
=
_event_get_set
(
'
distribution_packages
'
)
;
config
.
events
.
client
.
distribution_packages
.
status
=
'
package_status
'
config
.
events
.
client
.
distribution_packages
.
status
=
'
package_status
'
;
config
.
events
.
client
.
package_files_list
=
_event_get_set
(
'
package_files_list
'
)
config
.
events
.
client
.
package_files_list
=
_event_get_set
(
'
package_files_list
'
)
;
config
.
events
.
client
.
file
=
_event_get_set
(
'
file
'
)
config
.
events
.
client
.
file
=
_event_get_set
(
'
file
'
)
;
config
.
events
.
client
.
file_newcontent
=
'
file_newcontent
'
config
.
events
.
client
.
file_newcontent
=
'
file_newcontent
'
;
config
.
events
.
client
.
status
=
'
status
'
config
.
events
.
client
.
status
=
'
status
'
;
// debomatic status according with JSONLogger.py module
// debomatic status according with JSONLogger.py module
config
.
status
=
{}
config
.
status
=
{}
;
config
.
status
.
build
=
'
build
'
config
.
status
.
build
=
'
build
'
;
config
.
status
.
create
=
'
create
'
config
.
status
.
create
=
'
create
'
;
config
.
status
.
update
=
'
update
'
config
.
status
.
update
=
'
update
'
;
config
.
status
.
success
=
true
config
.
status
.
success
=
true
;
config
.
status
.
fail
=
false
config
.
status
.
fail
=
false
;
// read user configuration and merge it
// read user configuration and merge it
/*
/*
* update object1 with object2 values
* update object1 with object2 values
*/
*/
function
_merge
(
object1
,
object2
)
{
function
_merge
(
object1
,
object2
)
{
var
result
=
{}
var
result
=
{};
for
(
p
in
object1
)
{
for
(
var
p
in
object1
)
{
if
(
object2
.
hasOwnProperty
(
p
))
{
if
(
object2
.
hasOwnProperty
(
p
))
{
if
(
typeof
object1
[
p
]
===
'
object
'
&&
typeof
object2
[
p
]
===
'
object
'
)
{
if
(
typeof
object1
[
p
]
===
'
object
'
&&
typeof
object2
[
p
]
===
'
object
'
)
{
result
[
p
]
=
_merge
(
object1
[
p
],
object2
[
p
])
result
[
p
]
=
_merge
(
object1
[
p
],
object2
[
p
]);
}
}
else
{
else
{
result
[
p
]
=
object2
[
p
];
result
[
p
]
=
object2
[
p
]
}
}
}
else
{
result
[
p
]
=
object1
[
p
];
}
}
}
else
{
return
result
;
result
[
p
]
=
object1
[
p
]
}
}
return
result
}
}
try
{
try
{
var
Parser
=
require
(
'
./parser.js
'
)
var
Parser
=
require
(
'
./parser.js
'
);
var
parser
=
new
Parser
()
var
parser
=
new
Parser
();
var
user_config
=
parser
.
getUserConfig
()
var
user_config
=
parser
.
getUserConfig
();
if
(
user_config
)
{
if
(
user_config
)
{
console
.
log
(
"
Reading user configutation ...
"
)
console
.
log
(
'
Reading user configutation ...
'
);
config
=
_merge
(
config
,
require
(
user_config
))
config
=
_merge
(
config
,
require
(
user_config
));
}
}
else
{
else
{
console
.
log
(
'
No user config specified. Using global settings.
'
);
console
.
log
(
"
No user config specified. Using global settings.
"
)
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
if
(
err
.
code
==
'
MODULE_NOT_FOUND
'
)
{
if
(
err
.
code
==
'
MODULE_NOT_FOUND
'
)
{
console
.
log
(
"
File %s not found.
"
,
user_config
)
console
.
log
(
'
File %s not found.
'
,
user_config
);
process
.
exit
(
1
)
process
.
exit
(
1
);
}
}
else
{
else
{
console
.
error
(
'
Error reading user configutation
'
,
err
);
console
.
error
(
"
Error reading user configutation
"
,
err
);
process
.
exit
(
1
);
process
.
exit
(
1
)
}
}
}
finally
{
}
finally
{
// export some variable
// export some variable
config
.
web
.
paths
=
config
.
routes
config
.
web
.
paths
=
config
.
routes
;
config
.
web
.
events
=
config
.
events
config
.
web
.
events
=
config
.
events
;
config
.
web
.
status
=
config
.
status
config
.
web
.
status
=
config
.
status
;
config
.
web
.
host
=
config
.
host
config
.
web
.
host
=
config
.
host
;
module
.
exports
=
config
module
.
exports
=
config
;
}
}
debomatic-webui/lib/parser.js
View file @
f7a4f04a
function
Parser
()
'
use strict
'
;
{
var
args
=
process
.
argv
.
slice
(
2
);
function
Parser
()
{
var
help
=
function
()
{
var
args
=
process
.
argv
.
slice
(
2
);
console
.
log
(
"
\
var
help
=
function
()
{
console
.
log
(
'
\
Usage: %s [-c config]
\n\
Usage: %s [-c config]
\n\
-h print this help
\n\
-h print this help
\n\
-c set user configuration file
"
,
-c set user configuration file
'
,
process
.
argv
[
1
].
split
(
'
/
'
).
pop
());
process
.
argv
[
1
].
split
(
'
/
'
).
pop
());
process
.
exit
(
0
);
}
this
.
getUserConfig
=
function
()
{
process
.
exit
(
0
);
var
configFile
=
null
;
};
args
.
forEach
(
function
(
val
,
index
)
{
if
(
val
==
'
-c
'
)
{
configFile
=
args
[
index
+
1
]
return
}
})
if
(
configFile
)
return
process
.
cwd
()
+
'
/
'
+
configFile
;
else
return
null
}
args
.
forEach
(
function
(
val
,
index
)
{
this
.
getUserConfig
=
function
()
{
if
(
val
==
'
-h
'
)
{
var
configFile
=
null
;
help
()
args
.
forEach
(
function
(
val
,
index
)
{
}
if
(
val
==
'
-c
'
)
{
})
configFile
=
args
[
index
+
1
];
return
;
}
});
if
(
configFile
)
return
process
.
cwd
()
+
'
/
'
+
configFile
;
else
return
null
;
};
args
.
forEach
(
function
(
val
,
index
)
{
if
(
val
==
'
-h
'
)
{
help
();
}
});
}
}
module
.
exports
=
Parser
module
.
exports
=
Parser
\ No newline at end of file
debomatic-webui/lib/tail.js
View file @
f7a4f04a
var
fs
=
require
(
'
fs
'
)
'
use strict
'
;
,
Tail
=
require
(
'
tail
'
).
Tail
Tail
.
prototype
.
watchEvent
=
function
(
e
)
{
var
fs
=
require
(
'
fs
'
),
var
_this
=
this
;
Tail
=
require
(
'
tail
'
).
Tail
;
if
(
e
===
'
change
'
)
{
Tail
.
prototype
.
watchEvent
=
function
(
e
)
{
return
fs
.
stat
(
this
.
filename
,
function
(
err
,
stats
)
{
var
_this
=
this
;
if
(
err
)
{
_this
.
emit
(
'
error
'
,
err
);
if
(
e
===
'
change
'
)
{
}
return
fs
.
stat
(
this
.
filename
,
function
(
err
,
stats
)
{
if
(
stats
.
size
<
_this
.
pos
)
{
if
(
err
)
{
_this
.
pos
=
stats
.
size
;
_this
.
emit
(
'
error
'
,
err
);
}
}
if
(
stats
.
size
>
_this
.
pos
)
{
if
(
stats
.
size
<
_this
.
pos
)
{
_this
.
queue
.
push
({
_this
.
pos
=
stats
.
size
;
start
:
_this
.
pos
,
}
end
:
stats
.
size
if
(
stats
.
size
>
_this
.
pos
)
{
_this
.
queue
.
push
({
start
:
_this
.
pos
,
end
:
stats
.
size
});
_this
.
pos
=
stats
.
size
;
if
(
_this
.
queue
.
length
===
1
)
{
return
_this
.
internalDispatcher
.
emit
(
'
next
'
);
}
}
});
});
_this
.
pos
=
stats
.
size
;
}
else
if
(
e
===
'
rename
'
)
{
if
(
_this
.
queue
.
length
===
1
)
{
this
.
unwatch
();
return
_this
.
internalDispatcher
.
emit
(
"
next
"
);
_this
.
emit
(
'
error
'
,
'
File
'
+
this
.
filename
+
'
deleted.
'
);
}
}
}
});
}
else
if
(
e
===
'
rename
'
)
{
this
.
unwatch
();
_this
.
emit
(
'
error
'
,
"
File
"
+
this
.
filename
+
"
deleted.
"
);
}
};
};
Tail
.
prototype
.
close
=
function
()
{
Tail
.
prototype
.
close
=
function
()
{
this
.
unwatch
()
this
.
unwatch
();
}
}
;
module
.
exports
=
Tail
module
.
exports
=
Tail
;
\ No newline at end of file
debomatic-webui/lib/utils.js
View file @
f7a4f04a
var
path
=
require
(
'
path
'
)
'
use strict
'
;
,
fs
=
require
(
'
fs
'
)
,
config
=
require
(
'
./config.js
'
)
var
path
=
require
(
'
path
'
),
,
Tail
=
require
(
'
./tail.js
'
)
fs
=
require
(
'
fs
'
),
config
=
require
(
'
./config.js
'
),
Tail
=
require
(
'
./tail.js
'
);
function
__errors_handler
(
from
,
err
,
socket
)
{
function
__errors_handler
(
from
,
err
,
socket
)
{
if
(
!
socket
)
if
(
!
socket
)
from
=
"
NO SOCKET:
"
+
from
from
=
'
NO SOCKET:
'
+
from
;
console
.
error
(
from
,
err
)
console
.
error
(
from
,
err
);
if
(
socket
)
if
(
socket
)
socket
.
emit
(
config
.
events
.
error
,
err
.
message
)
socket
.
emit
(
config
.
events
.
error
,
err
.
message
);
}
}
function
__check_no_backward
(
backward_path
)
{
function
__check_no_backward
(
backward_path
)
{
try
{
try
{
return
backward_path
.
indexOf
(
'
..
'
)
<
0
return
backward_path
.
indexOf
(
'
..
'
)
<
0
;
}
catch
(
err
)
{
return
true
}
}
catch
(
err
)
{
return
true
;
}
}
}
function
__check_data_distribution
(
data
)
{
function
__check_data_distribution
(
data
)
{
return
__check_no_backward
(
data
)
&&
__check_no_backward
(
data
.
distribution
)
&&
__check_no_backward
(
data
.
distribution
.
name
)
return
__check_no_backward
(
data
)
&&
__check_no_backward
(
data
.
distribution
)
&&
__check_no_backward
(
data
.
distribution
.
name
);
}
}
function
__check_data_package
(
data
)
{
function
__check_data_package
(
data
)
{
return
__check_data_distribution
(
data
)
&&
__check_no_backward
(
data
.
package
)
&&
__check_no_backward
(
data
.
package
.
name
)
&&
__check_no_backward
(
data
.
package
.
version
)
return
__check_data_distribution
(
data
)
&&
__check_no_backward
(
data
.
package
)
&&
__check_no_backward
(
data
.
package
.
name
)
&&
__check_no_backward
(
data
.
package
.
version
);
}
}
function
__check_data_file
(
data
)
{
function
__check_data_file
(
data
)
{
return
__check_data_package
(
data
)
&&
__check_no_backward
(
data
.
file
)
&&
__check_no_backward
(
data
.
file
.
name
)
return
__check_data_package
(
data
)
&&
__check_no_backward
(
data
.
file
)
&&
__check_no_backward
(
data
.
file
.
name
);
}
}
function
__get_distribution_pool_path
(
data
)
{
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
)
{
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
)
{
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
);
}
}
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
=
[];
var
result
=
[];
if
(
err
)
{
if
(
err
)
{
__errors_handler
(
"
__get_files_list
"
,
err
)
__errors_handler
(
'
__get_files_list
'
,
err
);
return
;
return
;
}
files
.
forEach
(
function
(
f
)
{
try
{
complete_path
=
path
.
join
(
dir
,
f
);
stat
=
fs
.
statSync
(
complete_path
)
if
(
onlyDirectories
)
{
if
(
stat
.
isDirectory
())
{
result
.
push
(
f
);
}
}
else
{
if
(
stat
.
isFile
())
{
result
.
push
(
f
);
}
}
}
}
catch
(
fs_error
)
{
files
.
forEach
(
function
(
f
)
{
__errors_handler
(
"
__get_files_list:forEach
"
,
fs_error
)
try
{
return
var
complete_path
=
path
.
join
(
dir
,
f
);
}
var
stat
=
fs
.
statSync
(
complete_path
);
if
(
onlyDirectories
)
{
if
(
stat
.
isDirectory
())
{
result
.
push
(
f
);
}
}
else
{
if
(
stat
.
isFile
())
{
result
.
push
(
f
);
}
}
}
catch
(
fs_error
)
{
__errors_handler
(
'
__get_files_list:forEach
'
,
fs_error
);
return
;
}
});
callback
(
result
);
});
});
callback
(
result
);
});
}
}
function
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
function
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
socket
.
get
(
"
watchers
"
,
function
(
err
,
socket_watchers
){
socket
.
get
(
'
watchers
'
,
function
(
err
,
socket_watchers
)
{
if
(
!
socket_watchers
)
{
if
(
!
socket_watchers
)
{
// init socket watchers
// init socket watchers
socket_watchers
=
{}
socket_watchers
=
{};
}
try
{
var
watcher
=
socket_watchers
[
event_name
]
if
(
watcher
)
watcher
.
close
()
fs
.
stat
(
watch_path
,
function
(
err
,
stats
)
{
if
(
err
)
{
__errors_handler
(
"
__watch_path_onsocket:fs.stat
"
,
err
,
socket
)
return
}
if
(
stats
.
isDirectory
())
{
watcher
=
fs
.
watch
(
watch_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
updater
(
event_name
,
socket
,
data
)
})
}
}
else
if
(
stats
.
isFile
())
{
try
{
watcher
=
new
Tail
(
watch_path
)
var
watcher
=
socket_watchers
[
event_name
];
watcher
.
on
(
'
line
'
,
function
(
new_content
,
tailInfo
)
{
if
(
watcher
)
data
.
file
.
new_content
=
new_content
+
'
\n
'
watcher
.
close
();
updater
(
event_name
,
socket
,
data
)
});
fs
.
stat
(
watch_path
,
function
(
err
,
stats
)
{
watcher
.
on
(
'
error
'
,
function
(
msg
)
{
if
(
err
)
{
socket
.
emit
(
config
.
events
.
error
,
msg
);
__errors_handler
(
'
__watch_path_onsocket:fs.stat
'
,
err
,
socket
);
});
return
;
}
if
(
stats
.
isDirectory
())
{
watcher
=
fs
.
watch
(
watch_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
updater
(
event_name
,
socket
,
data
);
});
}
else
if
(
stats
.
isFile
())
{
watcher
=
new
Tail
(
watch_path
);
watcher
.
on
(
'
line
'
,
function
(
new_content
,
tailInfo
)
{
data
.
file
.
new_content
=
new_content
+
'
\n
'
;
updater
(
event_name
,
socket
,
data
);
});
watcher
.
on
(
'
error
'
,
function
(
msg
)
{
socket
.
emit
(
config
.
events
.
error
,
msg
);
});
}
socket_watchers
[
event_name
]
=
watcher
;
socket
.
set
(
'
watchers
'
,
socket_watchers
);
});
}
catch
(
err
)
{
__errors_handler
(
'
__watch_path_onsocket <-
'
+
arguments
.
callee
.
caller
.
name
,
err
,
socket
);
return
;
}
}
socket_watchers
[
event_name
]
=
watcher
});
socket
.
set
(
"
watchers
"
,
socket_watchers
)
})
}
catch
(
err
)
{
__errors_handler
(
"
__watch_path_onsocket <-
"
+
arguments
.
callee
.
caller
.
name
,
err
,
socket
)
return
}
})
}
}
function
__generic_handler_watcher
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
function
__generic_handler_watcher
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
callback
(
event_name
,
socket
,
data
)
callback
(
event_name
,
socket
,
data
);
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
callback
);
}
}
function
__send_distributions
(
socket
)
{
function
__send_distributions
(
socket
)
{
__get_files_list
(
config
.
debomatic
.
path
,
true
,
function
(
directories
)
{
__get_files_list
(
config
.
debomatic
.
path
,
true
,
function
(
directories
)
{
var
distributions
=
[]
var
distributions
=
[];
directories
.
forEach
(
function
(
dir
)
{
directories
.
forEach
(
function
(
dir
)
{
var
data
=
{}
var
data
=
{};
data
.
distribution
=
{}
data
.
distribution
=
{};
data
.
distribution
.
name
=
dir
data
.
distribution
.
name
=
dir
;
var
pool_path
=
__get_distribution_pool_path
(
data
)
var
pool_path
=
__get_distribution_pool_path
(
data
);
if
(
fs
.
existsSync
(
pool_path
))
{
if
(
fs
.
existsSync
(
pool_path
))
{
distributions
.
push
(
dir
)
distributions
.
push
(
dir
);
}
}
})
});
socket
.
emit
(
config
.
events
.
broadcast
.
distributions
,
distributions
);
socket
.
emit
(
config
.
events
.
broadcast
.
distributions
,
distributions
);
})
});
}
}
utils
=
{
var
utils
=
{
check_data_distribution
:
function
(
data
)
{
check_data_distribution
:
function
(
data
)
{
return
__check_data_distribution
(
data
)
return
__check_data_distribution
(
data
);
},
},
check_data_package
:
function
(
data
)
{
check_data_package
:
function
(
data
)
{
return
__check_data_package
(
data
)
return
__check_data_package
(
data
);
},
},
check_data_file
:
function
(
data
)
{
check_data_file
:
function
(
data
)
{
return
__check_data_file
(
data
)
return
__check_data_file
(
data
);
},
},
get_distribution_pool_path
:
function
(
data
)
{
get_distribution_pool_path
:
function
(
data
)
{
return
__get_distribution_pool_path
(
data
)
return
__get_distribution_pool_path
(
data
);
},
},
get_package_path
:
function
(
data
)
{
get_package_path
:
function
(
data
)
{
return
__get_package_path
(
data
)
return
__get_package_path
(
data
);
},
},
get_file_path
:
function
(
data
)
{
get_file_path
:
function
(
data
)
{
return
__get_file_path
(
data
)
return
__get_file_path
(
data
);
},
},
get_files_list
:
function
(
dir
,
onlyDirectories
,
callback
)
{
get_files_list
:
function
(
dir
,
onlyDirectories
,
callback
)
{
return
__get_files_list
(
dir
,
onlyDirectories
,
callback
)
return
__get_files_list
(
dir
,
onlyDirectories
,
callback
);
},
},
watch_path_onsocket
:
function
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
watch_path_onsocket
:
function
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
return
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
return
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
);
},
},
generic_handler_watcher
:
function
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
generic_handler_watcher
:
function
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
return
__generic_handler_watcher
(
event_name
,
socket
,
data
,
watch_path
,
callback
);
return
__generic_handler_watcher
(
event_name
,
socket
,
data
,
watch_path
,
callback
);
},
},
send_distributions
:
function
(
socket
)
{
send_distributions
:
function
(
socket
)
{
return
__send_distributions
(
socket
)
return
__send_distributions
(
socket
);
},
},
errors_handler
:
function
(
from
,
error
,
socket
)
{
errors_handler
:
function
(
from
,
error
,
socket
)
{
return
__errors_handler
(
from
,
error
,
socket
)
return
__errors_handler
(
from
,
error
,
socket
);
}
}
}
}
;
module
.
exports
=
utils
module
.
exports
=
utils
;
debomatic-webui/public/javascripts/debug.js
View file @
f7a4f04a
"
use strict
"
;
/*
/*
General information about debugging:
General information about debugging:
...
@@ -10,18 +11,18 @@
...
@@ -10,18 +11,18 @@
3 - socket emit data
3 - socket emit data
4 - socket received data
4 - socket received data
*/
*/
var
debug
=
function
()
{
var
debug
=
function
()
{
if
(
arguments
.
length
<
2
)
{
if
(
arguments
.
length
<
2
)
{
return
return
;
}
}
var
level
=
arguments
[
0
]
var
level
=
arguments
[
0
];
arguments
[
0
]
=
"
debug [
"
+
level
+
"
]:
"
arguments
[
0
]
=
"
debug [
"
+
level
+
"
]:
"
;
if
(
level
<=
config
.
preferences
.
debug
)
{
if
(
level
<=
config
.
preferences
.
debug
)
{
if
(
console
.
debug
)
if
(
console
.
debug
)
console
.
debug
.
apply
(
console
,
arguments
)
console
.
debug
.
apply
(
console
,
arguments
);
else
else
console
.
log
.
apply
(
console
,
arguments
)
console
.
log
.
apply
(
console
,
arguments
);
}
}
}
}
/*
/*
...
@@ -30,11 +31,11 @@ var debug = function() {
...
@@ -30,11 +31,11 @@ var debug = function() {
usage: debug_socket("emit"|"received", event_name, data)
usage: debug_socket("emit"|"received", event_name, data)
*/
*/
var
debug_socket
=
function
()
{
var
debug_socket
=
function
()
{
if
(
arguments
.
length
!=
3
)
if
(
arguments
.
length
!=
3
)
return
return
;
var
level
=
3
;
var
level
=
3
;
if
(
arguments
[
0
]
==
"
received
"
)
if
(
arguments
[
0
]
==
"
received
"
)
level
=
4
level
=
4
;
debug
(
level
,
"
socket
"
,
arguments
[
0
],
"
event:
"
,
arguments
[
1
],
"
data:
"
,
arguments
[
2
])
debug
(
level
,
"
socket
"
,
arguments
[
0
],
"
event:
"
,
arguments
[
1
],
"
data:
"
,
arguments
[
2
]);
}
}
\ No newline at end of file
debomatic-webui/public/javascripts/main.js
View file @
f7a4f04a
// main client javascript
// main client javascript
'
use strict
'
;
var
preferences
=
new
Preferences
()
var
preferences
=
new
Preferences
()
;
var
page_generic
=
new
Page_Generic
()
var
page_generic
=
new
Page_Generic
()
;
if
(
window
.
location
.
pathname
==
config
.
paths
.
preferences
)
{
if
(
window
.
location
.
pathname
==
config
.
paths
.
preferences
)
{
preferences
.
initPage
()
preferences
.
initPage
();
}
}
if
(
window
.
location
.
pathname
==
'
/
'
)
{
if
(
window
.
location
.
pathname
==
'
/
'
)
{
// convert email addresses in the right format
// convert email addresses in the right format
var
emails
=
$
(
"
.email
"
)
var
emails
=
$
(
'
.email
'
);
$
.
each
(
emails
,
function
()
{
$
.
each
(
emails
,
function
()
{
var
subject
=
''
var
subject
=
''
;
if
(
$
(
this
).
attr
(
'
subject
'
))
{
if
(
$
(
this
).
attr
(
'
subject
'
))
{
subject
=
'
?subject=
'
+
$
(
this
).
attr
(
'
subject
'
)
subject
=
'
?subject=
'
+
$
(
this
).
attr
(
'
subject
'
);
}
}
var
real_email
=
$
(
this
).
attr
(
'
address
'
).
replace
(
'
AT
'
,
'
@
'
).
replace
(
'
DOT
'
,
'
.
'
).
replace
(
/ /g
,
''
)
var
real_email
=
$
(
this
).
attr
(
'
address
'
).
replace
(
'
AT
'
,
'
@
'
).
replace
(
'
DOT
'
,
'
.
'
).
replace
(
/ /g
,
''
);
var
label
=
real_email
var
label
=
real_email
;
if
(
config
.
debomatic
.
admin
.
name
&&
config
.
debomatic
.
admin
.
name
!=
'
Your Name
'
)
if
(
config
.
debomatic
.
admin
.
name
&&
config
.
debomatic
.
admin
.
name
!=
'
Your Name
'
);
label
=
config
.
debomatic
.
admin
.
name
label
=
config
.
debomatic
.
admin
.
name
;
real_email
=
'
<a href="mailto:
'
+
real_email
+
subject
+
'
">
'
+
label
+
'
</a>
'
real_email
=
'
<a href="mailto:
'
+
real_email
+
subject
+
'
">
'
+
label
+
'
</a>
'
;
$
(
this
).
html
(
real_email
)
$
(
this
).
html
(
real_email
);
})
})
}
}
var
socket
=
io
.
connect
(
'
/
'
);
var
socket
=
io
.
connect
(
'
/
'
);
page_generic
.
start
(
socket
)
page_generic
.
start
(
socket
)
;
if
(
window
.
location
.
pathname
==
config
.
paths
.
distribution
)
{
if
(
window
.
location
.
pathname
==
config
.
paths
.
distribution
)
{
new
Page_Distrubion
(
socket
).
start
()
new
Page_Distrubion
(
socket
).
start
();
}
}
debomatic-webui/public/javascripts/page_distribution.js
View file @
f7a4f04a
'
use strict
'
;
// function to get all files in on click
// function to get all files in on click
// event comes from HTML
// event comes from HTML
function
download_all
(
div_id
)
{
function
download_all
(
div_id
)
{
frame_id
=
'
downloadAllFrame
'
var
frame_id
=
'
downloadAllFrame
'
;
if
(
$
(
"
#
"
+
frame_id
).
length
>
0
)
var
frame
=
null
;
frame
=
$
(
$
(
"
#
"
+
frame_id
)[
0
])
if
(
$
(
'
#
'
+
frame_id
).
length
>
0
)
else
{
frame
=
$
(
$
(
'
#
'
+
frame_id
)[
0
]);
frame
=
$
(
'
<iframe></iframe>
'
)
else
{
frame
.
hide
()
frame
=
$
(
'
<iframe></iframe>
'
);
frame
.
attr
(
'
id
'
,
frame_id
)
frame
.
hide
();
$
(
'
body
'
).
append
(
frame
)
frame
.
attr
(
'
id
'
,
frame_id
);
}
$
(
'
body
'
).
append
(
frame
);
files
=
$
(
div_id
).
find
(
'
ul li a
'
)
}
$
.
each
(
files
,
function
(
index
,
item
)
{
var
files
=
$
(
div_id
).
find
(
'
ul li a
'
);
setTimeout
(
function
()
{
$
.
each
(
files
,
function
(
index
,
item
)
{
frame
.
attr
(
'
src
'
,
item
.
href
)
setTimeout
(
function
()
{
},
index
*
1000
)
frame
.
attr
(
'
src
'
,
item
.
href
);
})
},
index
*
1000
);
});
}
}
function
Page_Distrubion
(
socket
)
function
Page_Distrubion
(
socket
)
{
{
/*
/*
...
@@ -60,570 +62,554 @@ function Page_Distrubion(socket)
...
@@ -60,570 +62,554 @@ function Page_Distrubion(socket)
*/
*/
var
socket
=
socket
var
_e
=
config
.
events
.
client
;
var
_e
=
config
.
events
.
client
var
view
=
Utils
.
from_hash_to_view
();
var
view
=
Utils
.
from_hash_to_view
()
var
sidebarOffset
=
0
;
var
sidebarOffset
=
0
var
new_lines
=
[];
var
new_lines
=
[]
function
__check_hash_makes_sense
()
{
function
__check_hash_makes_sense
()
{
if
(
window
.
location
.
hash
.
indexOf
(
'
..
'
)
>=
0
)
{
if
(
window
.
location
.
hash
.
indexOf
(
'
..
'
)
>=
0
)
{
error
.
set
(
"
Detected '..' God Is Watching You !
"
)
error
.
set
(
'
Detected ".." God Is Watching You !
'
);
return
false
return
false
;
}
if
(
!
window
.
location
.
hash
)
{
welcome
.
show
()
return
false
}
var
info
=
window
.
location
.
hash
.
split
(
'
/
'
)
if
(
info
.
length
==
2
)
window
.
location
.
hash
=
info
[
0
]
return
true
}
var
title
=
{
set
:
function
(
label
)
{
if
(
label
)
{
$
(
'
#title
'
).
html
(
label
)
page_generic
.
set_window_title
(
label
)
return
}
var
label
=
''
var
window_title
=
null
if
(
Utils
.
check_view_file
(
view
))
{
var
complete_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
window_title
=
complete_name
if
(
!
view
.
file
.
path
)
view
.
file
.
path
=
config
.
paths
.
debomatic
+
'
/
'
+
view
.
distribution
.
name
+
'
/pool/
'
+
view
.
package
.
orig_name
+
'
/
'
+
complete_name
label
=
complete_name
+
'
\
<a class="btn btn-link btn-lg" title="Download" href="
'
+
view
.
file
.
path
+
'
">
\
<span class="glyphicon glyphicon-download-alt"></span>
\
</a>
'
}
else
if
(
Utils
.
check_view_package
(
view
))
label
=
view
.
package
.
orig_name
else
if
(
Utils
.
check_view_distribution
(
view
))
label
=
view
.
distribution
.
name
$
(
'
#title
'
).
html
(
label
)
if
(
window_title
)
label
=
window_title
page_generic
.
set_window_title
(
label
)
},
clean
:
function
()
{
$
(
'
#title
'
).
html
(
''
)
page_generic
.
set_window_title
()
}
}
var
packages
=
{
set
:
function
(
socket_data
)
{
packages
.
clean
()
var
tmp
=
Utils
.
clone
(
socket_data
)
tmp
.
file
=
null
view
.
packages
=
{}
if
(
socket_data
.
distribution
.
packages
&&
socket_data
.
distribution
.
packages
.
length
>
0
)
{
socket_data
.
distribution
.
packages
.
forEach
(
function
(
p
){
tmp
.
package
=
p
// get datestamp if package is clicked
$
(
'
#packages ul
'
).
append
(
'
<li id="package-
'
+
p
.
orig_name
+
'
"><a href="
'
+
Utils
.
from_view_to_hash
(
tmp
)
+
'
/datestamp">
'
+
p
.
name
+
'
<span>
'
+
p
.
version
+
'
</span></a></li>
'
)
view
.
packages
[
p
.
orig_name
]
=
Utils
.
clone
(
p
)
})
packages
.
select
()
}
else
{
$
(
'
#packages ul
'
).
append
(
'
<li class="text-muted">No packages yet</li>
'
)
}
packages
.
show
()
sticky
.
updateOffset
()
},
clean
:
function
()
{
$
(
'
#packages ul
'
).
html
(
''
)
},
get
:
function
()
{
if
(
Utils
.
check_view_distribution
(
view
))
{
var
query_data
=
{}
query_data
.
distribution
=
view
.
distribution
debug_socket
(
"
emit
"
,
_e
.
distribution_packages
.
get
,
query_data
)
socket
.
emit
(
_e
.
distribution_packages
.
get
,
query_data
)
}
},
select
:
function
()
{
packages
.
unselect
()
if
(
Utils
.
check_view_package
(
view
))
{
$
(
"
#packages li[id='package-
"
+
view
.
package
.
orig_name
+
"
']
"
).
addClass
(
'
active
'
)
}
},
unselect
:
function
()
{
$
(
'
#packages li
'
).
removeClass
(
'
active
'
)
},
set_status
:
function
(
status_data
)
{
// set status in view
if
(
view
.
distribution
.
name
==
status_data
.
distribution
&&
view
.
packages
[
status_data
.
package
]
)
{
view
.
packages
[
status_data
.
package
].
status
=
status_data
.
status
if
(
status_data
.
hasOwnProperty
(
'
success
'
))
view
.
packages
[
status_data
.
package
].
success
=
status_data
.
success
else
delete
(
view
.
packages
[
status_data
.
package
].
success
)
}
// and in html
var
p_html
=
$
(
"
#packages li[id='package-
"
+
status_data
.
package
+
"
'] a
"
)
p_html
.
find
(
'
span.icon
'
).
remove
()
p_html
.
append
(
Utils
.
get_status_icon_html
(
status_data
))
if
(
Utils
.
check_view_package
(
view
)
&&
view
.
package
.
orig_name
==
status_data
.
package
&&
view
.
distribution
.
name
==
status_data
.
distribution
)
{
// in case user is watching this package, update also view.package
view
.
package
=
Utils
.
clone
(
view
.
packages
[
status_data
.
package
])
}
},
show
:
function
()
{
$
(
"
#packages
"
).
show
()
},
hide
:
function
()
{
$
(
"
#packages
"
).
hide
()
}
}
var
files
=
{
set
:
function
(
socket_data
)
{
files
.
clean
()
var
tmp
=
Utils
.
clone
(
socket_data
)
if
(
socket_data
.
package
.
files
&&
socket_data
.
package
.
files
.
length
>
0
)
{
// update view
view
.
package
.
files
=
Utils
.
clone
(
socket_data
.
package
.
files
)
// update html
socket_data
.
package
.
files
.
forEach
(
function
(
f
){
tmp
.
file
=
f
var
html_file
=
$
(
'
<li id="file-
'
+
f
.
orig_name
+
'
"><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
Utils
.
from_view_to_hash
(
tmp
)
+
'
">
'
+
f
.
name
+
'
</a></li>
'
)
html_file
.
on
(
"
click
"
,
function
(){
files
.
select
(
this
)
})
$
(
'
#logs ul
'
).
append
(
html_file
)
})
$
(
'
#logs
'
).
show
()
files
.
select
()
}
if
(
socket_data
.
package
.
debs
&&
socket_data
.
package
.
debs
.
length
>
0
)
{
// update view
view
.
package
.
debs
=
Utils
.
clone
(
socket_data
.
package
.
debs
)
// update.html
socket_data
.
package
.
debs
.
forEach
(
function
(
f
){
$
(
'
#debs ul
'
).
append
(
'
<li><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
f
.
path
+
'
">
'
+
f
.
name
+
'
</a> <span>.
'
+
f
.
extension
+
'
</span></li>
'
)
})
$
(
'
#debs
'
).
show
()
}
if
(
socket_data
.
package
.
sources
&&
socket_data
.
package
.
sources
.
length
>
0
)
{
// update view
view
.
package
.
sources
=
Utils
.
clone
(
socket_data
.
package
.
sources
)
// update html
socket_data
.
package
.
sources
.
forEach
(
function
(
f
){
$
(
'
#sources ul
'
).
append
(
'
<li><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
f
.
path
+
'
">
'
+
f
.
name
+
'
</a></li>
'
)
})
$
(
'
#sources
'
).
show
()
}
files
.
show
()
sticky
.
updateOffset
()
},
clean
:
function
()
{
$
(
'
#logs ul
'
).
html
(
''
);
$
(
'
#logs
'
).
hide
()
$
(
'
#debs ul
'
).
html
(
''
);
$
(
'
#debs
'
).
hide
();
$
(
'
#sources ul
'
).
html
(
''
)
$
(
'
#sources
'
).
hide
()
files
.
hide
()
},
get
:
function
()
{
if
(
Utils
.
check_view_package
(
view
))
{
var
query_data
=
{}
query_data
.
distribution
=
view
.
distribution
query_data
.
package
=
view
.
package
debug_socket
(
"
emit
"
,
_e
.
package_files_list
.
get
,
query_data
)
socket
.
emit
(
_e
.
package_files_list
.
get
,
query_data
)
}
},
select
:
function
()
{
files
.
show
()
files
.
unselect
()
if
(
Utils
.
check_view_file
(
view
))
{
$
(
"
#logs li[id='file-
"
+
view
.
file
.
orig_name
+
"
']
"
).
addClass
(
'
active
'
)
}
},
unselect
:
function
()
{
$
(
'
#logs li
'
).
removeClass
(
'
active
'
);
},
hide
:
function
()
{
$
(
'
#files
'
).
hide
()
},
show
:
function
()
{
$
(
'
#files
'
).
show
()
},
}
var
file
=
{
set
:
function
(
socket_data
)
{
view
.
file
=
Utils
.
clone
(
socket_data
.
file
)
$
(
"
#file pre
"
).
html
(
socket_data
.
file
.
content
)
$
(
"
#file
"
).
show
()
},
clean
:
function
()
{
$
(
'
#file pre
'
).
html
(
''
)
$
(
'
#file
'
).
hide
()
},
append
:
function
(
new_content
)
{
var
content
=
$
(
"
#file pre
"
)
content
.
append
(
new_content
)
if
(
config
.
preferences
.
autoscroll
)
{
// scroll down if file is covering footer
var
file_height
=
$
(
"
#fileOffset
"
).
offset
().
top
var
footerOffset
=
$
(
"
footer
"
).
offset
().
top
if
(
file_height
>
footerOffset
)
{
debug
(
2
,
'
scoll down on new content
'
)
$
(
'
html,body
'
).
animate
({
scrollTop
:
file_height
},
0
);
}
}
}
if
(
!
window
.
location
.
hash
)
{
},
welcome
.
show
();
get
:
function
()
{
return
false
;
if
(
Utils
.
check_view_file
(
view
))
{
}
var
query_data
=
{}
var
info
=
window
.
location
.
hash
.
split
(
'
/
'
);
query_data
.
distribution
=
view
.
distribution
if
(
info
.
length
==
2
)
query_data
.
package
=
view
.
package
window
.
location
.
hash
=
info
[
0
];
query_data
.
file
=
view
.
file
return
true
;
query_data
.
file
.
content
=
null
// get a feedback to user while downloading file
$
(
"
#file pre
"
).
html
(
"
Downloading file, please wait a while ...
"
)
$
(
"
#file
"
).
show
()
debug_socket
(
"
emit
"
,
_e
.
file
.
get
,
query_data
)
socket
.
emit
(
_e
.
file
.
get
,
query_data
)
}
}
}
var
breadcrumb
=
{
update
:
function
(
label
)
{
if
(
label
)
{
$
(
'
.breadcrumb
'
).
html
(
'
<li class="active">
'
+
label
+
'
</li>
'
)
return
}
hash
=
window
.
location
.
hash
.
replace
(
'
#
'
,
''
)
var
new_html
=
''
var
new_hash
=
'
#
'
var
info
=
hash
.
split
(
'
/
'
)
for
(
var
i
=
0
;
i
<
info
.
length
;
i
++
)
{
new_hash
+=
info
[
i
]
if
(
i
==
(
info
.
length
-
1
))
new_html
+=
'
<li class="active">
'
+
info
[
i
]
+
'
</li>
'
else
new_html
+=
'
<li><a href="
'
+
new_hash
+
'
">
'
+
info
[
i
]
+
'
</a>
'
new_hash
+=
'
/
'
}
$
(
'
.breadcrumb
'
).
html
(
new_html
)
}
}
// sticky sidebar
var
sticky
=
{
init
:
function
()
{
if
(
sidebarOffset
==
0
)
return
if
(
$
(
window
).
scrollTop
()
>
sidebarOffset
)
{
sticky
.
show
()
}
else
{
sticky
.
hide
()
sticky
.
updateOffset
()
}
},
start
:
function
()
{
$
(
window
).
scroll
(
sticky
.
init
)
},
stop
:
function
()
{
$
(
window
).
off
(
"
scroll
"
)
},
reset
:
function
()
{
sticky
.
stop
()
sticky
.
update
()
sticky
.
init
()
sticky
.
start
()
},
show
:
function
()
{
if
(
config
.
preferences
.
sidebar
)
{
$
(
"
#sticky
"
).
addClass
(
'
fixed
'
)
}
debug
(
2
,
"
showing sticky
"
)
$
(
"
#sticky-package
"
).
fadeIn
()
},
hide
:
function
()
{
$
(
"
#sticky
"
).
removeClass
(
'
fixed
'
)
$
(
"
#sticky-package
"
).
fadeOut
(
150
)
},
update
:
function
()
{
sticky
.
updateOffset
()
if
(
Utils
.
check_view_distribution
(
view
))
$
(
"
#sticky-package .distribution
"
).
html
(
view
.
distribution
.
name
)
if
(
Utils
.
check_view_package
(
view
))
{
$
(
"
#sticky-package .name
"
).
html
(
view
.
package
.
name
)
$
(
"
#sticky-package .version
"
).
html
(
view
.
package
.
version
)
sticky
.
set_status
()
}
},
updateOffset
:
function
()
{
var
sidebar
=
$
(
"
#files
"
)
sidebarOffset
=
sidebar
.
offset
().
top
},
set_status
:
function
(
status_data
)
{
if
(
!
status_data
)
{
status_data
=
{}
status_data
.
distribution
=
view
.
distribution
.
name
status_data
.
package
=
view
.
package
.
orig_name
status_data
.
status
=
view
.
package
.
status
if
(
view
.
package
.
hasOwnProperty
(
'
success
'
))
status_data
.
success
=
view
.
package
.
success
}
if
(
Utils
.
check_view_package
(
view
)
&&
status_data
.
distribution
==
view
.
distribution
.
name
&&
status_data
.
package
==
view
.
package
.
orig_name
)
{
// update html
var
info
=
Utils
.
get_status_icon_and_class
(
status_data
)
var
panel
=
$
(
"
#sticky-package-content
"
)
panel
.
removeClass
()
panel
.
addClass
(
'
panel panel-
'
+
info
.
className
)
var
div
=
$
(
"
#sticky-package .status
"
)
div
.
find
(
'
span.icon
'
).
remove
()
div
.
append
(
Utils
.
get_status_icon_html
(
status_data
))
}
}
}
}
var
title
=
{
var
error
=
{
set
:
function
(
label
)
{
set
:
function
(
socket_error
)
{
if
(
label
)
{
$
(
"
#error span
"
).
html
(
socket_error
)
$
(
'
#title
'
).
html
(
label
);
error
.
view
()
page_generic
.
set_window_title
(
label
);
},
return
;
clean
:
function
()
{
}
$
(
"
#error
"
).
hide
()
label
=
''
;
$
(
"
#error span
"
).
html
(
''
)
var
window_title
=
null
;
},
if
(
Utils
.
check_view_file
(
view
))
{
view
:
function
()
{
var
complete_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
;
$
(
"
#error
"
).
fadeIn
(
100
)
window_title
=
complete_name
;
title
.
set
(
"
Something is wrong ...
"
)
if
(
!
view
.
file
.
path
);
breadcrumb
.
update
(
'
Something is wrong ...
'
)
view
.
file
.
path
=
config
.
paths
.
debomatic
+
'
/
'
+
view
.
distribution
.
name
+
'
/pool/
'
+
view
.
package
.
orig_name
+
'
/
'
+
complete_name
;
file
.
clean
()
label
=
complete_name
+
'
<a class="btn btn-link btn-lg" title="Download" href="
'
+
view
.
file
.
path
+
'
">
'
+
files
.
hide
()
'
<span class="glyphicon glyphicon-download-alt"></span></a>
'
;
unselect
()
}
else
if
(
Utils
.
check_view_package
(
view
))
},
label
=
view
.
package
.
orig_name
;
}
else
if
(
Utils
.
check_view_distribution
(
view
))
label
=
view
.
distribution
.
name
;
var
welcome
=
{
$
(
'
#title
'
).
html
(
label
);
set
:
function
(
distributions
)
{
if
(
window_title
)
welcome
.
clean
()
label
=
window_title
;
if
(
distributions
.
length
<
1
)
{
page_generic
.
set_window_title
(
label
);
$
(
'
#welcome
'
).
append
(
'
<p class="lead text-muted">There is no distribution at the moment</p>
'
)
},
}
clean
:
function
()
{
else
{
$
(
'
#title
'
).
html
(
''
);
distributions
.
forEach
(
function
(
name
){
page_generic
.
set_window_title
();
$
(
'
#welcome
'
).
append
(
'
<a class="btn btn-lg btn-primary" href="
'
+
config
.
paths
.
distribution
+
'
#
'
+
name
+
'
">
'
+
name
+
'
</a>
'
);
}
};
var
packages
=
{
set
:
function
(
socket_data
)
{
packages
.
clean
();
var
tmp
=
Utils
.
clone
(
socket_data
);
tmp
.
file
=
null
;
view
.
packages
=
{};
if
(
socket_data
.
distribution
.
packages
&&
socket_data
.
distribution
.
packages
.
length
>
0
)
{
socket_data
.
distribution
.
packages
.
forEach
(
function
(
p
)
{
tmp
.
package
=
p
;
// get datestamp if package is clicked
$
(
'
#packages ul
'
).
append
(
'
<li id="package-
'
+
p
.
orig_name
+
'
"><a href="
'
+
Utils
.
from_view_to_hash
(
tmp
)
+
'
/datestamp">
'
+
p
.
name
+
'
<span>
'
+
p
.
version
+
'
</span></a></li>
'
);
view
.
packages
[
p
.
orig_name
]
=
Utils
.
clone
(
p
);
});
packages
.
select
();
}
else
{
$
(
'
#packages ul
'
).
append
(
'
<li class="text-muted">No packages yet</li>
'
);
}
packages
.
show
();
sticky
.
updateOffset
();
},
clean
:
function
()
{
$
(
'
#packages ul
'
).
html
(
''
);
},
get
:
function
()
{
if
(
Utils
.
check_view_distribution
(
view
))
{
var
query_data
=
{};
query_data
.
distribution
=
view
.
distribution
;
debug_socket
(
'
emit
'
,
_e
.
distribution_packages
.
get
,
query_data
);
socket
.
emit
(
_e
.
distribution_packages
.
get
,
query_data
);
}
},
select
:
function
()
{
packages
.
unselect
();
if
(
Utils
.
check_view_package
(
view
))
{
$
(
'
#packages li[id="package-
'
+
view
.
package
.
orig_name
+
'
"]
'
).
addClass
(
'
active
'
);
}
},
unselect
:
function
()
{
$
(
'
#packages li
'
).
removeClass
(
'
active
'
);
},
set_status
:
function
(
status_data
)
{
// set status in view
if
(
view
.
distribution
.
name
==
status_data
.
distribution
&&
view
.
packages
[
status_data
.
package
])
{
view
.
packages
[
status_data
.
package
].
status
=
status_data
.
status
;
if
(
status_data
.
hasOwnProperty
(
'
success
'
))
view
.
packages
[
status_data
.
package
].
success
=
status_data
.
success
;
else
delete
(
view
.
packages
[
status_data
.
package
].
success
);
}
// and in html
var
p_html
=
$
(
'
#packages li[id="package-
'
+
status_data
.
package
+
'
"] a
'
);
p_html
.
find
(
'
span.icon
'
).
remove
();
p_html
.
append
(
Utils
.
get_status_icon_html
(
status_data
));
if
(
Utils
.
check_view_package
(
view
)
&&
view
.
package
.
orig_name
==
status_data
.
package
&&
view
.
distribution
.
name
==
status_data
.
distribution
)
{
// in case user is watching this package, update also view.package
view
.
package
=
Utils
.
clone
(
view
.
packages
[
status_data
.
package
]);
}
},
show
:
function
()
{
$
(
'
#packages
'
).
show
();
},
hide
:
function
()
{
$
(
'
#packages
'
).
hide
();
}
};
var
files
=
{
set
:
function
(
socket_data
)
{
files
.
clean
();
var
tmp
=
Utils
.
clone
(
socket_data
);
if
(
socket_data
.
package
.
files
&&
socket_data
.
package
.
files
.
length
>
0
)
{
// update view
view
.
package
.
files
=
Utils
.
clone
(
socket_data
.
package
.
files
);
// update html
socket_data
.
package
.
files
.
forEach
(
function
(
f
)
{
tmp
.
file
=
f
;
var
html_file
=
$
(
'
<li id="file-
'
+
f
.
orig_name
+
'
"><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
Utils
.
from_view_to_hash
(
tmp
)
+
'
">
'
+
f
.
name
+
'
</a></li>
'
);
html_file
.
on
(
'
click
'
,
function
()
{
files
.
select
(
this
);
});
$
(
'
#logs ul
'
).
append
(
html_file
);
});
$
(
'
#logs
'
).
show
();
files
.
select
();
}
if
(
socket_data
.
package
.
debs
&&
socket_data
.
package
.
debs
.
length
>
0
)
{
// update view
view
.
package
.
debs
=
Utils
.
clone
(
socket_data
.
package
.
debs
);
// update.html
socket_data
.
package
.
debs
.
forEach
(
function
(
f
)
{
$
(
'
#debs ul
'
).
append
(
'
<li><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
f
.
path
+
'
">
'
+
f
.
name
+
'
</a> <span>.
'
+
f
.
extension
+
'
</span></li>
'
);
});
$
(
'
#debs
'
).
show
();
}
if
(
socket_data
.
package
.
sources
&&
socket_data
.
package
.
sources
.
length
>
0
)
{
// update view
view
.
package
.
sources
=
Utils
.
clone
(
socket_data
.
package
.
sources
);
// update html
socket_data
.
package
.
sources
.
forEach
(
function
(
f
)
{
$
(
'
#sources ul
'
).
append
(
'
<li><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
f
.
path
+
'
">
'
+
f
.
name
+
'
</a></li>
'
);
})
$
(
'
#sources
'
).
show
();
}
files
.
show
();
sticky
.
updateOffset
();
},
clean
:
function
()
{
$
(
'
#logs ul
'
).
html
(
''
);
$
(
'
#logs
'
).
hide
();
$
(
'
#debs ul
'
).
html
(
''
);
$
(
'
#debs
'
).
hide
();
$
(
'
#sources ul
'
).
html
(
''
);
$
(
'
#sources
'
).
hide
();
files
.
hide
();
},
get
:
function
()
{
if
(
Utils
.
check_view_package
(
view
))
{
var
query_data
=
{};
query_data
.
distribution
=
view
.
distribution
;
query_data
.
package
=
view
.
package
;
debug_socket
(
'
emit
'
,
_e
.
package_files_list
.
get
,
query_data
);
socket
.
emit
(
_e
.
package_files_list
.
get
,
query_data
);
}
},
select
:
function
()
{
files
.
show
();
files
.
unselect
();
if
(
Utils
.
check_view_file
(
view
))
{
$
(
'
#logs li[id="file-
'
+
view
.
file
.
orig_name
+
'
"]
'
).
addClass
(
'
active
'
);
}
},
unselect
:
function
()
{
$
(
'
#logs li
'
).
removeClass
(
'
active
'
);
},
hide
:
function
()
{
$
(
'
#files
'
).
hide
();
},
show
:
function
()
{
$
(
'
#files
'
).
show
();
},
};
var
file
=
{
set
:
function
(
socket_data
)
{
view
.
file
=
Utils
.
clone
(
socket_data
.
file
);
$
(
'
#file pre
'
).
html
(
socket_data
.
file
.
content
);
$
(
'
#file
'
).
show
();
},
clean
:
function
()
{
$
(
'
#file pre
'
).
html
(
''
);
$
(
'
#file
'
).
hide
();
},
append
:
function
(
new_content
)
{
var
content
=
$
(
'
#file pre
'
);
content
.
append
(
new_content
);
if
(
config
.
preferences
.
autoscroll
)
{
// scroll down if file is covering footer
var
file_height
=
$
(
'
#fileOffset
'
).
offset
().
top
;
var
footerOffset
=
$
(
'
footer
'
).
offset
().
top
;
if
(
file_height
>
footerOffset
)
{
debug
(
2
,
'
scoll down on new content
'
);
$
(
'
html,body
'
).
animate
({
scrollTop
:
file_height
},
0
);
}
}
},
get
:
function
()
{
if
(
Utils
.
check_view_file
(
view
))
{
var
query_data
=
{};
query_data
.
distribution
=
view
.
distribution
;
query_data
.
package
=
view
.
package
;
query_data
.
file
=
view
.
file
;
query_data
.
file
.
content
=
null
;
// get a feedback to user while downloading file
$
(
'
#file pre
'
).
html
(
'
Downloading file, please wait a while ...
'
);
$
(
'
#file
'
).
show
();
debug_socket
(
'
emit
'
,
_e
.
file
.
get
,
query_data
);
socket
.
emit
(
_e
.
file
.
get
,
query_data
);
}
}
};
var
breadcrumb
=
{
update
:
function
(
label
)
{
if
(
label
)
{
$
(
'
.breadcrumb
'
).
html
(
'
<li class="active">
'
+
label
+
'
</li>
'
);
return
;
}
var
hash
=
window
.
location
.
hash
.
replace
(
'
#
'
,
''
);
var
new_html
=
''
;
var
new_hash
=
'
#
'
;
var
info
=
hash
.
split
(
'
/
'
);
for
(
var
i
=
0
;
i
<
info
.
length
;
i
++
)
{
new_hash
+=
info
[
i
];
if
(
i
==
(
info
.
length
-
1
))
new_html
+=
'
<li class="active">
'
+
info
[
i
]
+
'
</li>
'
;
else
new_html
+=
'
<li><a href="
'
+
new_hash
+
'
">
'
+
info
[
i
]
+
'
</a>
'
;
new_hash
+=
'
/
'
;
}
$
(
'
.breadcrumb
'
).
html
(
new_html
);
}
};
// sticky sidebar
var
sticky
=
{
init
:
function
()
{
if
(
sidebarOffset
===
0
)
return
;
if
(
$
(
window
).
scrollTop
()
>
sidebarOffset
)
{
sticky
.
show
();
}
else
{
sticky
.
hide
();
sticky
.
updateOffset
();
}
},
start
:
function
()
{
$
(
window
).
scroll
(
sticky
.
init
);
},
stop
:
function
()
{
$
(
window
).
off
(
'
scroll
'
);
},
reset
:
function
()
{
sticky
.
stop
();
sticky
.
update
();
sticky
.
init
();
sticky
.
start
();
},
show
:
function
()
{
if
(
config
.
preferences
.
sidebar
)
{
$
(
'
#sticky
'
).
addClass
(
'
fixed
'
);
}
debug
(
2
,
'
showing sticky
'
);
$
(
'
#sticky-package
'
).
fadeIn
();
},
hide
:
function
()
{
$
(
'
#sticky
'
).
removeClass
(
'
fixed
'
);
$
(
'
#sticky-package
'
).
fadeOut
(
150
);
},
update
:
function
()
{
sticky
.
updateOffset
();
if
(
Utils
.
check_view_distribution
(
view
))
$
(
'
#sticky-package .distribution
'
).
html
(
view
.
distribution
.
name
);
if
(
Utils
.
check_view_package
(
view
))
{
$
(
'
#sticky-package .name
'
).
html
(
view
.
package
.
name
);
$
(
'
#sticky-package .version
'
).
html
(
view
.
package
.
version
);
sticky
.
set_status
();
}
},
updateOffset
:
function
()
{
var
sidebar
=
$
(
'
#files
'
);
sidebarOffset
=
sidebar
.
offset
().
top
;
},
set_status
:
function
(
status_data
)
{
if
(
!
status_data
)
{
status_data
=
{};
status_data
.
distribution
=
view
.
distribution
.
name
;
status_data
.
package
=
view
.
package
.
orig_name
;
status_data
.
status
=
view
.
package
.
status
;
if
(
view
.
package
.
hasOwnProperty
(
'
success
'
))
status_data
.
success
=
view
.
package
.
success
;
}
if
(
Utils
.
check_view_package
(
view
)
&&
status_data
.
distribution
==
view
.
distribution
.
name
&&
status_data
.
package
==
view
.
package
.
orig_name
)
{
// update html
var
info
=
Utils
.
get_status_icon_and_class
(
status_data
);
var
panel
=
$
(
'
#sticky-package-content
'
);
panel
.
removeClass
();
panel
.
addClass
(
'
panel panel-
'
+
info
.
className
);
var
div
=
$
(
'
#sticky-package .status
'
);
div
.
find
(
'
span.icon
'
).
remove
();
div
.
append
(
Utils
.
get_status_icon_html
(
status_data
));
}
}
};
var
error
=
{
set
:
function
(
socket_error
)
{
$
(
'
#error span
'
).
html
(
socket_error
);
error
.
view
();
},
clean
:
function
()
{
$
(
'
#error
'
).
hide
();
$
(
'
#error span
'
).
html
(
''
);
},
view
:
function
()
{
$
(
'
#error
'
).
fadeIn
(
100
);
title
.
set
(
'
Something is wrong ...
'
);
breadcrumb
.
update
(
'
Something is wrong ...
'
);
file
.
clean
();
files
.
hide
();
unselect
();
},
};
var
welcome
=
{
set
:
function
(
distributions
)
{
welcome
.
clean
();
if
(
distributions
.
length
<
1
)
{
$
(
'
#welcome
'
).
append
(
'
<p class="lead text-muted">There is no distribution at the moment</p>
'
);
}
else
{
distributions
.
forEach
(
function
(
name
)
{
$
(
'
#welcome
'
).
append
(
'
<a class="btn btn-lg btn-primary" href="
'
+
config
.
paths
.
distribution
+
'
#
'
+
name
+
'
">
'
+
name
+
'
</a>
'
);
});
}
},
show
:
function
()
{
title
.
set
(
'
Please select a distribution
'
);
breadcrumb
.
update
(
'
Select a distribution
'
);
packages
.
hide
();
file
.
clean
();
files
.
hide
();
unselect
();
$
(
'
#welcome
'
).
show
();
},
clean
:
function
()
{
$
(
'
#welcome
'
).
html
(
''
);
},
hide
:
function
()
{
$
(
'
#welcome
'
).
hide
();
}
};
var
preferences
=
function
()
{
if
(
!
config
.
preferences
.
sidebar
)
{
debug
(
2
,
'
no sidebar - updating html
'
);
$
(
'
#sidebar
'
).
removeClass
();
$
(
'
#sidebar
'
).
addClass
(
'
col-md-12 row
'
);
$
(
'
#packages
'
).
addClass
(
'
col-md-4
'
);
$
(
'
#logs
'
).
addClass
(
'
col-md-4
'
);
$
(
'
#files .others
'
).
addClass
(
'
col-md-4
'
);
$
(
'
#main
'
).
removeClass
().
addClass
(
'
col-md-12
'
);
$
(
'
#sticky-package
'
).
addClass
(
'
on-top
'
);
}
if
(
!
config
.
preferences
.
file_background
)
{
$
(
'
#file pre
'
).
addClass
(
'
no-background
'
);
}
$
(
'
#file pre
'
).
css
(
'
font-size
'
,
config
.
preferences
.
file_fontsize
);
};
var
select
=
function
()
{
unselect
();
if
(
Utils
.
check_view_distribution
(
view
))
{
$
(
'
#distributions li[id="distribution-
'
+
view
.
distribution
.
name
+
'
"]
'
).
addClass
(
'
active
'
);
}
packages
.
select
();
files
.
select
();
};
var
unselect
=
function
()
{
$
(
'
#distributions li
'
).
removeClass
(
'
active
'
);
files
.
unselect
();
packages
.
unselect
();
};
var
clean
=
function
()
{
welcome
.
hide
();
title
.
clean
();
packages
.
clean
();
files
.
clean
();
file
.
clean
();
unselect
();
breadcrumb
.
update
();
error
.
clean
();
};
var
update
=
{
page
:
function
(
old_view
)
{
if
(
!
old_view
||
!
Utils
.
check_view_distribution
(
old_view
)
||
!
Utils
.
check_view_distribution
(
view
)
||
view
.
distribution
.
name
!=
old_view
.
distribution
.
name
||
!
view
.
package
.
orig_name
)
{
// new distribution view
populate
();
return
;
}
else
if
(
!
Utils
.
check_view_package
(
old_view
)
||
!
Utils
.
check_view_package
(
view
)
||
view
.
package
.
orig_name
!=
old_view
.
package
.
orig_name
)
{
// new package view
files
.
get
();
file
.
get
();
}
else
if
(
!
Utils
.
check_view_file
(
old_view
)
||
!
Utils
.
check_view_file
(
view
)
||
view
.
file
.
name
!=
old_view
.
file
.
name
)
{
// new file view
file
.
get
();
}
update
.
view
(
view
);
},
view
:
function
()
{
error
.
clean
();
title
.
set
();
breadcrumb
.
update
();
select
();
sticky
.
reset
();
}
};
var
populate
=
function
()
{
clean
();
packages
.
get
();
files
.
get
();
file
.
get
();
update
.
view
();
};
this
.
start
=
function
()
{
socket
.
on
(
config
.
events
.
error
,
function
(
socket_error
)
{
debug_socket
(
'
received
'
,
config
.
events
.
error
,
socket_error
);
error
.
set
(
socket_error
);
});
});
}
},
show
:
function
()
{
title
.
set
(
"
Please select a distribution
"
)
breadcrumb
.
update
(
"
Select a distribution
"
)
packages
.
hide
()
file
.
clean
()
files
.
hide
()
unselect
()
$
(
"
#welcome
"
).
show
()
},
clean
:
function
()
{
$
(
"
#welcome
"
).
html
(
''
)
},
hide
:
function
()
{
$
(
"
#welcome
"
).
hide
()
}
}
var
preferences
=
function
()
{
if
(
!
config
.
preferences
.
sidebar
)
{
debug
(
2
,
"
no sidebar - updating html
"
)
$
(
"
#sidebar
"
).
removeClass
()
$
(
"
#sidebar
"
).
addClass
(
"
col-md-12 row
"
)
$
(
"
#packages
"
).
addClass
(
"
col-md-4
"
)
$
(
"
#logs
"
).
addClass
(
"
col-md-4
"
)
$
(
"
#files .others
"
).
addClass
(
"
col-md-4
"
)
$
(
"
#main
"
).
removeClass
().
addClass
(
"
col-md-12
"
)
$
(
"
#sticky-package
"
).
addClass
(
"
on-top
"
)
}
if
(
!
config
.
preferences
.
file_background
)
{
$
(
"
#file pre
"
).
addClass
(
"
no-background
"
)
}
$
(
"
#file pre
"
).
css
(
'
font-size
'
,
config
.
preferences
.
file_fontsize
)
}
var
select
=
function
()
{
unselect
()
if
(
Utils
.
check_view_distribution
(
view
))
{
$
(
"
#distributions li[id='distribution-
"
+
view
.
distribution
.
name
+
"
']
"
).
addClass
(
'
active
'
)
}
packages
.
select
()
files
.
select
()
}
var
unselect
=
function
()
{
$
(
'
#distributions li
'
).
removeClass
(
'
active
'
)
files
.
unselect
()
packages
.
unselect
()
}
var
clean
=
function
()
{
welcome
.
hide
()
title
.
clean
()
packages
.
clean
()
files
.
clean
()
file
.
clean
()
unselect
()
breadcrumb
.
update
()
error
.
clean
()
}
var
update
=
{
page
:
function
(
old_view
)
{
if
(
!
old_view
||
!
Utils
.
check_view_distribution
(
old_view
)
||
!
Utils
.
check_view_distribution
(
view
)
||
view
.
distribution
.
name
!=
old_view
.
distribution
.
name
||
!
view
.
package
.
orig_name
)
{
// new distribution view
populate
()
return
}
else
if
(
!
Utils
.
check_view_package
(
old_view
)
||
!
Utils
.
check_view_package
(
view
)
||
view
.
package
.
orig_name
!=
old_view
.
package
.
orig_name
)
{
// new package view
files
.
get
()
file
.
get
()
}
else
if
(
!
Utils
.
check_view_file
(
old_view
)
||
!
Utils
.
check_view_file
(
view
)
||
view
.
file
.
name
!=
old_view
.
file
.
name
)
{
// new file view
file
.
get
()
}
update
.
view
(
view
)
},
view
:
function
()
{
error
.
clean
()
title
.
set
()
breadcrumb
.
update
()
select
()
sticky
.
reset
()
}
}
var
populate
=
function
()
{
clean
()
packages
.
get
()
files
.
get
()
file
.
get
()
update
.
view
()
}
this
.
start
=
function
()
{
socket
.
on
(
config
.
events
.
error
,
function
(
socket_error
)
{
debug_socket
(
"
received
"
,
config
.
events
.
error
,
socket_error
)
error
.
set
(
socket_error
)
})
socket
.
on
(
config
.
events
.
broadcast
.
distributions
,
function
(
socket_data
)
{
debug_socket
(
"
received
"
,
config
.
events
.
broadcast
.
distributions
,
socket_data
)
welcome
.
set
(
socket_data
)
})
socket
.
on
(
_e
.
distribution_packages
.
set
,
function
(
socket_data
){
debug_socket
(
"
received
"
,
_e
.
distribution_packages
.
set
,
socket_data
)
packages
.
set
(
socket_data
)
})
socket
.
on
(
_e
.
distribution_packages
.
status
,
function
(
socket_data
){
debug_socket
(
"
received
"
,
_e
.
distribution_packages
.
set
,
socket_data
)
packages
.
set_status
(
socket_data
)
sticky
.
set_status
(
socket_data
)
})
socket
.
on
(
config
.
events
.
broadcast
.
status_update
,
function
(
socket_data
){
packages
.
set_status
(
socket_data
)
sticky
.
set_status
(
socket_data
)
})
socket
.
on
(
_e
.
package_files_list
.
set
,
function
(
socket_data
){
debug_socket
(
"
received
"
,
_e
.
package_files_list
.
set
,
socket_data
)
files
.
set
(
socket_data
)
})
socket
.
on
(
_e
.
file
.
set
,
function
(
socket_data
)
{
debug_socket
(
"
received
"
,
_e
.
file
.
set
,
socket_data
)
file
.
set
(
socket_data
)
})
socket
.
on
(
_e
.
file_newcontent
,
function
(
socket_data
)
{
debug_socket
(
"
received
"
,
_e
.
file_newcontent
,
socket_data
)
new_lines
.
push
(
socket_data
.
file
.
new_content
)
})
$
(
window
).
on
(
'
hashchange
'
,
function
()
{
if
(
!
__check_hash_makes_sense
())
return
var
old_view
=
Utils
.
clone
(
view
)
var
new_view
=
Utils
.
from_hash_to_view
()
// reset current view
view
.
distribution
=
Utils
.
clone
(
new_view
.
distribution
)
view
.
package
=
Utils
.
clone
(
new_view
.
package
)
if
(
view
.
packages
[
new_view
.
package
.
orig_name
])
view
.
package
=
Utils
.
clone
(
view
.
packages
[
new_view
.
package
.
orig_name
])
view
.
file
=
Utils
.
clone
(
new_view
.
file
)
update
.
page
(
old_view
)
$
(
'
html,body
'
).
animate
({
scrollTop
:
0
},
0
);
debug
(
1
,
"
changing view
"
,
"
old:
"
,
old_view
,
"
new:
"
,
view
)
});
if
(
!
__check_hash_makes_sense
())
socket
.
on
(
config
.
events
.
broadcast
.
distributions
,
function
(
socket_data
)
{
return
debug_socket
(
'
received
'
,
config
.
events
.
broadcast
.
distributions
,
socket_data
);
populate
()
welcome
.
set
(
socket_data
);
});
// Init sticky-package back_on_top on click
$
(
"
#sticky-package
"
).
on
(
"
click
"
,
function
(){
socket
.
on
(
_e
.
distribution_packages
.
set
,
function
(
socket_data
)
{
$
(
'
html,body
'
).
animate
({
scrollTop
:
0
},
100
);
debug_socket
(
'
received
'
,
_e
.
distribution_packages
.
set
,
socket_data
);
})
packages
.
set
(
socket_data
);
});
// WORKAROUND:
// when page is loaded sidebar has offset().top
socket
.
on
(
_e
.
distribution_packages
.
status
,
function
(
socket_data
)
{
// equals 0. This is because html is loaded on socket
debug_socket
(
'
received
'
,
_e
.
distribution_packages
.
set
,
socket_data
);
// events. Sleep a while and call stiky.reset()
packages
.
set_status
(
socket_data
);
setTimeout
(
sticky
.
reset
,
500
);
sticky
.
set_status
(
socket_data
);
});
// WORKAROUND:
// On incoming hundred of lines browser goes crazy.
socket
.
on
(
config
.
events
.
broadcast
.
status_update
,
function
(
socket_data
)
{
// Append lines every 200 mills.
packages
.
set_status
(
socket_data
);
function
watch_for_new_lines
()
{
sticky
.
set_status
(
socket_data
);
if
(
new_lines
.
length
>
0
)
{
});
file
.
append
(
new_lines
.
join
(
''
))
new_lines
=
[]
socket
.
on
(
_e
.
package_files_list
.
set
,
function
(
socket_data
)
{
}
debug_socket
(
'
received
'
,
_e
.
package_files_list
.
set
,
socket_data
);
setTimeout
(
watch_for_new_lines
,
200
);
files
.
set
(
socket_data
);
}
});
watch_for_new_lines
()
socket
.
on
(
_e
.
file
.
set
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
file
.
set
,
socket_data
);
file
.
set
(
socket_data
);
});
socket
.
on
(
_e
.
file_newcontent
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
file_newcontent
,
socket_data
);
new_lines
.
push
(
socket_data
.
file
.
new_content
);
});
$
(
window
).
on
(
'
hashchange
'
,
function
()
{
if
(
!
__check_hash_makes_sense
())
return
;
var
old_view
=
Utils
.
clone
(
view
);
var
new_view
=
Utils
.
from_hash_to_view
();
// reset current view
view
.
distribution
=
Utils
.
clone
(
new_view
.
distribution
);
view
.
package
=
Utils
.
clone
(
new_view
.
package
);
if
(
view
.
packages
[
new_view
.
package
.
orig_name
])
view
.
package
=
Utils
.
clone
(
view
.
packages
[
new_view
.
package
.
orig_name
]);
view
.
file
=
Utils
.
clone
(
new_view
.
file
);
update
.
page
(
old_view
);
$
(
'
html,body
'
).
animate
({
scrollTop
:
0
},
0
);
debug
(
1
,
'
changing view
'
,
'
old:
'
,
old_view
,
'
new:
'
,
view
);
});
if
(
!
__check_hash_makes_sense
())
return
;
populate
();
// Init sticky-package back_on_top on click
$
(
'
#sticky-package
'
).
on
(
'
click
'
,
function
()
{
$
(
'
html,body
'
).
animate
({
scrollTop
:
0
},
100
);
});
// WORKAROUND:
// when page is loaded sidebar has offset().top
// equals 0. This is because html is loaded on socket
// events. Sleep a while and call stiky.reset()
setTimeout
(
sticky
.
reset
,
500
);
// WORKAROUND:
// On incoming hundred of lines browser goes crazy.
// Append lines every 200 mills.
function
watch_for_new_lines
()
{
if
(
new_lines
.
length
>
0
)
{
file
.
append
(
new_lines
.
join
(
''
));
new_lines
=
[];
}
setTimeout
(
watch_for_new_lines
,
200
);
}
watch_for_new_lines
();
// Update html according with preferences
// Update html according with preferences
preferences
()
preferences
();
}
};
}
}
debomatic-webui/public/javascripts/page_generic.js
View file @
f7a4f04a
function
Page_Generic
()
'
use strict
'
;
{
var
_e
=
config
.
events
function
Page_Generic
()
{
var
_e
=
config
.
events
;
function
__get_status_html_id
(
status_data
)
{
var
result
=
'
status-
'
+
status_data
.
status
+
'
-
'
+
status_data
.
distribution
function
__get_status_html_id
(
status_data
)
{
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
var
result
=
'
status-
'
+
status_data
.
status
+
'
-
'
+
status_data
.
distribution
;
result
+=
'
-
'
+
status_data
.
package
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
return
result
result
+=
'
-
'
+
status_data
.
package
;
}
return
result
;
}
function
__get_status_html_href
(
status_data
)
{
result
=
config
.
paths
.
distribution
+
'
#
'
+
status_data
.
distribution
function
__get_status_html_href
(
status_data
)
{
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
=
config
.
paths
.
distribution
+
'
#
'
+
status_data
.
distribution
;
result
+=
'
/
'
+
status_data
.
package
.
replace
(
'
_
'
,
'
/
'
)
+
'
/datestamp
'
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
return
result
result
+=
'
/
'
+
status_data
.
package
.
replace
(
'
_
'
,
'
/
'
)
+
'
/datestamp
'
;
}
return
result
;
function
__get_status_html_title
(
status_data
)
{
result
=
status_data
.
status
+
'
:
'
+
status_data
.
distribution
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
+=
'
>
'
+
status_data
.
package
if
(
status_data
.
hasOwnProperty
(
'
uploader
'
)
&&
status_data
.
uploader
.
length
>
0
)
result
+=
'
by
'
+
status_data
.
uploader
return
result
}
function
__get_status_html_inner
(
status_data
)
{
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
return
status_data
.
package
;
return
status_data
.
distribution
}
function
__get_status_html
(
status_data
)
{
var
_s
=
status_data
var
li
=
$
(
'
<li></li>
'
)
li
.
attr
(
'
id
'
,
__get_status_html_id
(
status_data
))
var
button
=
$
(
'
<a></a>
'
)
button
.
addClass
(
'
btn btn-xs
'
)
button
.
addClass
(
_s
.
status
)
button
.
attr
(
'
title
'
,
__get_status_html_title
(
_s
))
button
.
attr
(
'
href
'
,
__get_status_html_href
(
_s
))
button
.
html
(
__get_status_html_inner
(
_s
))
var
info
=
Utils
.
get_status_icon_and_class
(
_s
)
button
.
addClass
(
'
btn-
'
+
info
.
className
)
// add icon
button
.
html
(
button
.
html
()
+
'
'
+
Utils
.
get_status_icon_html
(
_s
))
li
.
html
(
button
)
var
result
=
$
(
'
<div></div>
'
)
result
.
html
(
li
)
return
result
.
html
()
}
var
distributions
=
{
set
:
function
(
distributions
)
{
$
(
'
#distributions ul
'
).
html
(
''
);
if
(
distributions
.
length
<
1
)
{
$
(
'
#distributions ul
'
).
append
(
'
<li><a title="There is no distribution at the moment" onclick="return false">None</li>
'
)
}
else
{
distributions
.
forEach
(
function
(
name
){
$
(
'
#distributions ul
'
).
append
(
'
<li id="distribution-
'
+
name
+
'
"><a href="
'
+
config
.
paths
.
distribution
+
'
#
'
+
name
+
'
">
'
+
name
+
'
</a></li>
'
);
});
if
(
window
.
location
.
pathname
==
config
.
paths
.
distribution
)
{
var
data
=
Utils
.
from_hash_to_view
()
if
(
Utils
.
check_view_distribution
(
data
))
{
$
(
"
#distributions li[id='distribution-
"
+
data
.
distribution
.
name
+
"
']
"
).
addClass
(
'
active
'
)
}
}
}
},
}
var
status
=
{
set
:
function
(
data_status
)
{
$
(
"
#status ul
"
).
html
(
''
)
if
(
data_status
.
length
>
0
)
{
data_status
.
forEach
(
function
(
s
){
status
.
append
(
s
)
})
}
},
append
:
function
(
status_data
)
{
$
(
'
#status .idle
'
).
hide
()
$
(
"
#status ul
"
).
append
(
__get_status_html
(
status_data
))
},
update
:
function
(
status_data
)
{
var
li
=
$
(
"
#status li[id='
"
+
__get_status_html_id
(
status_data
)
+
"
']
"
)
if
(
li
.
length
>
0
&&
status_data
.
hasOwnProperty
(
'
success
'
))
{
// Update color and icon
li
=
$
(
li
[
0
])
li
.
html
(
$
(
__get_status_html
(
status_data
)).
children
())
li
.
attr
(
'
id
'
,
''
)
// This is a chain to have a fadeOut and correctly
// delete status li from list.
// The first timemout fades out the status element.
setTimeout
(
function
()
{
li
.
children
().
fadeOut
(
config
.
status
.
delay
.
fadeOut
)
// Then resize list.
setTimeout
(
function
()
{
li
.
animate
({
width
:
'
toggle
'
})
},
config
.
status
.
delay
.
fadeOut
)
// Finally remove status html
// and show idle label if necessary.
setTimeout
(
function
()
{
li
.
remove
()
if
(
$
(
'
#status li
'
).
length
==
0
)
$
(
'
#status .idle
'
).
show
()
},
config
.
status
.
delay
.
remove
+
2000
)
// more delay on remove html
},
config
.
status
.
delay
.
remove
)
}
else
if
(
!
status_data
.
hasOwnProperty
(
'
success
'
))
{
status
.
append
(
status_data
)
}
},
}
this
.
preferences
=
function
()
{
if
(
config
.
preferences
.
header
)
{
$
(
"
#pageheader
"
).
show
()
$
(
"
.navbar .home-link
"
).
hide
()
}
}
else
{
$
(
"
#pageheader
"
).
hide
()
function
__get_status_html_title
(
status_data
)
{
$
(
"
.navbar .home-link
"
).
show
()
result
=
status_data
.
status
+
'
:
'
+
status_data
.
distribution
;
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
+=
'
>
'
+
status_data
.
package
;
if
(
status_data
.
hasOwnProperty
(
'
uploader
'
)
&&
status_data
.
uploader
.
length
>
0
)
result
+=
'
by
'
+
status_data
.
uploader
;
return
result
;
}
function
__get_status_html_inner
(
status_data
)
{
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
return
status_data
.
package
;
return
status_data
.
distribution
;
}
}
if
(
config
.
preferences
.
glossy_theme
)
{
function
__get_status_html
(
status_data
)
{
if
(
$
(
"
head
"
).
find
(
"
link[href='/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css']
"
).
length
==
0
)
var
_s
=
status_data
;
$
(
"
head
"
).
append
(
'
<link rel="stylesheet" href="/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css">
'
)
var
li
=
$
(
'
<li></li>
'
);
li
.
attr
(
'
id
'
,
__get_status_html_id
(
status_data
));
var
button
=
$
(
'
<a></a>
'
);
button
.
addClass
(
'
btn btn-xs
'
);
button
.
addClass
(
_s
.
status
);
button
.
attr
(
'
title
'
,
__get_status_html_title
(
_s
));
button
.
attr
(
'
href
'
,
__get_status_html_href
(
_s
));
button
.
html
(
__get_status_html_inner
(
_s
));
var
info
=
Utils
.
get_status_icon_and_class
(
_s
);
button
.
addClass
(
'
btn-
'
+
info
.
className
);
// add icon
button
.
html
(
button
.
html
()
+
'
'
+
Utils
.
get_status_icon_html
(
_s
));
li
.
html
(
button
);
var
result
=
$
(
'
<div></div>
'
);
result
.
html
(
li
);
return
result
.
html
();
}
}
else
{
$
(
"
head
"
).
find
(
"
link[href='/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css']
"
).
remove
()
var
distributions
=
{
set
:
function
(
distributions
)
{
$
(
'
#distributions ul
'
).
html
(
''
);
if
(
distributions
.
length
<
1
)
{
$
(
'
#distributions ul
'
).
append
(
'
<li><a title="There is no distribution at the moment" onclick="return false">None</li>
'
);
}
else
{
distributions
.
forEach
(
function
(
name
)
{
$
(
'
#distributions ul
'
).
append
(
'
<li id="distribution-
'
+
name
+
'
"><a href="
'
+
config
.
paths
.
distribution
+
'
#
'
+
name
+
'
">
'
+
name
+
'
</a></li>
'
);
});
if
(
window
.
location
.
pathname
==
config
.
paths
.
distribution
)
{
var
data
=
Utils
.
from_hash_to_view
();
if
(
Utils
.
check_view_distribution
(
data
))
{
$
(
'
#distributions li[id="distribution-
'
+
data
.
distribution
.
name
+
'
"]
'
).
addClass
(
'
active
'
);
}
}
}
},
}
var
status
=
{
set
:
function
(
data_status
)
{
$
(
"
#status ul
"
).
html
(
''
);
if
(
data_status
.
length
>
0
)
{
data_status
.
forEach
(
function
(
s
)
{
status
.
append
(
s
);
})
}
},
append
:
function
(
status_data
)
{
$
(
'
#status .idle
'
).
hide
();
$
(
"
#status ul
"
).
append
(
__get_status_html
(
status_data
));
},
update
:
function
(
status_data
)
{
var
li
=
$
(
'
#status li[id="
'
+
__get_status_html_id
(
status_data
)
+
'
"]
'
);
if
(
li
.
length
>
0
&&
status_data
.
hasOwnProperty
(
'
success
'
))
{
// Update color and icon
li
=
$
(
li
[
0
]);
li
.
html
(
$
(
__get_status_html
(
status_data
)).
children
());
li
.
attr
(
'
id
'
,
''
);
// This is a chain to have a fadeOut and correctly
// delete status li from list.
// The first timemout fades out the status element.
setTimeout
(
function
()
{
li
.
children
().
fadeOut
(
config
.
status
.
delay
.
fadeOut
);
// Then resize list.
setTimeout
(
function
()
{
li
.
animate
({
width
:
'
toggle
'
});
},
config
.
status
.
delay
.
fadeOut
);
// Finally remove status html
// and show idle label if necessary.
setTimeout
(
function
()
{
li
.
remove
();
if
(
$
(
'
#status li
'
).
length
===
0
);
$
(
'
#status .idle
'
).
show
();
},
config
.
status
.
delay
.
remove
+
2000
);
// more delay on remove html
},
config
.
status
.
delay
.
remove
);
}
else
if
(
!
status_data
.
hasOwnProperty
(
'
success
'
))
{
status
.
append
(
status_data
);
}
},
};
this
.
preferences
=
function
()
{
if
(
config
.
preferences
.
header
)
{
$
(
'
#pageheader
'
).
show
();
$
(
'
.navbar .home-link
'
).
hide
();
}
else
{
$
(
'
#pageheader
'
).
hide
();
$
(
'
.navbar .home-link
'
).
show
();
}
if
(
config
.
preferences
.
glossy_theme
)
{
if
(
$
(
'
head
'
).
find
(
'
link[href="/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css"]
'
).
length
===
0
)
$
(
'
head
'
).
append
(
'
<link rel="stylesheet" href="/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css">
'
);
}
else
{
$
(
'
head
'
).
find
(
'
link[href="/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css"]
'
).
remove
();
}
};
this
.
set_window_title
=
function
(
label
)
{
var
window_title_separator
=
'
\
u00ab
'
;
if
(
label
)
window
.
document
.
title
=
label
+
window_title_separator
+
config
.
title
;
else
window
.
document
.
title
=
config
.
title
;
};
this
.
start
=
function
(
socket
)
{
// update distributions
socket
.
on
(
_e
.
broadcast
.
distributions
,
function
(
socket_distributions
)
{
debug_socket
(
'
received
'
,
_e
.
broadcast
.
distributions
,
socket_distributions
);
distributions
.
set
(
socket_distributions
);
});
socket
.
on
(
_e
.
client
.
status
,
function
(
socket_status
)
{
debug_socket
(
'
received
'
,
_e
.
client
.
status
,
socket_status
);
status
.
set
(
socket_status
);
});
socket
.
on
(
_e
.
broadcast
.
status_update
,
function
(
package_status
)
{
debug_socket
(
'
received
'
,
_e
.
broadcast
.
status_update
,
package_status
);
status
.
update
(
package_status
);
});
socket
.
on
(
_e
.
error
,
function
(
error
)
{
console
.
error
(
'
socket >
'
+
error
);
});
};
// select current page in navbar
if
(
window
.
location
.
pathname
!=
config
.
paths
.
distribution
)
{
$
(
'
.navbar li a[href="
'
+
window
.
location
.
pathname
+
'
"]
'
).
parent
().
addClass
(
'
active
'
);
}
}
}
// update html according with preferences
this
.
set_window_title
=
function
(
label
)
{
this
.
preferences
();
var
window_title_separator
=
'
\
u00ab
'
if
(
label
)
window
.
document
.
title
=
label
+
window_title_separator
+
config
.
title
else
window
.
document
.
title
=
config
.
title
}
this
.
start
=
function
(
socket
)
{
// update distributions
socket
.
on
(
_e
.
broadcast
.
distributions
,
function
(
socket_distributions
)
{
debug_socket
(
"
received
"
,
_e
.
broadcast
.
distributions
,
socket_distributions
)
distributions
.
set
(
socket_distributions
)
});
socket
.
on
(
_e
.
client
.
status
,
function
(
socket_status
)
{
debug_socket
(
"
received
"
,
_e
.
client
.
status
,
socket_status
)
status
.
set
(
socket_status
)
})
socket
.
on
(
_e
.
broadcast
.
status_update
,
function
(
package_status
)
{
debug_socket
(
"
received
"
,
_e
.
broadcast
.
status_update
,
package_status
)
status
.
update
(
package_status
)
})
socket
.
on
(
_e
.
error
,
function
(
error
)
{
console
.
error
(
"
socket >
"
+
error
)
})
}
// select current page in navbar
if
(
window
.
location
.
pathname
!=
config
.
paths
.
distribution
)
{
$
(
"
.navbar li a[href='
"
+
window
.
location
.
pathname
+
"
']
"
).
parent
().
addClass
(
"
active
"
)
}
// update html according with preferences
this
.
preferences
()
}
}
debomatic-webui/public/javascripts/preferences.js
View file @
f7a4f04a
'
use strict
'
;
function
Preferences
()
{
function
Preferences
()
{
// update config.preferences according with user choices
// update config.preferences according with user choices
var
load
=
function
()
{
var
load
=
function
()
{
for
(
key
in
config
.
preferences
)
{
for
(
var
key
in
config
.
preferences
)
{
if
((
value
=
localStorage
.
getItem
(
key
)))
{
var
value
=
localStorage
.
getItem
(
key
);
debug
(
2
,
'
loading preference
'
,
key
,
value
)
if
(
value
)
{
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
)
debug
(
2
,
'
loading preference
'
,
key
,
value
);
}
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
);
}
}
}
}
};
// set prefence
var
set
=
function
(
key
,
value
)
{
// set prefence
if
(
config
.
preferences
.
hasOwnProperty
(
key
))
{
var
set
=
function
(
key
,
value
)
{
debug
(
1
,
'
setting preference
'
,
key
,
value
)
if
(
config
.
preferences
.
hasOwnProperty
(
key
))
{
localStorage
.
setItem
(
key
,
value
)
debug
(
1
,
'
setting preference
'
,
key
,
value
);
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
)
localStorage
.
setItem
(
key
,
value
);
}
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
);
}
}
};
// init prefence page
this
.
initPage
=
function
()
{
// init prefence page
this
.
initPage
=
function
()
{
page_generic
.
set_window_title
(
"
Preferences
"
)
page_generic
.
set_window_title
(
'
Preferences
'
);
// set view according with config.preferences
for
(
key
in
config
.
preferences
)
{
// set view according with config.preferences
var
element
=
$
(
"
#preferences #
"
+
key
)
for
(
var
key
in
config
.
preferences
)
{
if
(
element
.
attr
(
'
type
'
)
==
"
checkbox
"
)
{
var
element
=
$
(
'
#preferences #
'
+
key
);
element
.
prop
(
'
checked
'
,
config
.
preferences
[
key
])
if
(
element
.
attr
(
'
type
'
)
==
'
checkbox
'
)
{
}
element
.
prop
(
'
checked
'
,
config
.
preferences
[
key
]);
else
{
}
else
{
element
.
val
(
config
.
preferences
[
key
])
element
.
val
(
config
.
preferences
[
key
]);
}
}
}
}
// on input change, set prefence
// on input change, set prefence
$
(
"
#preferences input, #preferences select
"
).
change
(
function
()
{
$
(
'
#preferences input, #preferences select
'
).
change
(
function
()
{
var
key
=
$
(
this
).
attr
(
'
id
'
)
var
key
=
$
(
this
).
attr
(
'
id
'
);
var
value
=
$
(
this
).
val
()
var
value
=
$
(
this
).
val
();
if
(
$
(
this
).
attr
(
'
type
'
)
==
'
checkbox
'
)
if
(
$
(
this
).
attr
(
'
type
'
)
==
'
checkbox
'
)
value
=
$
(
this
).
is
(
'
:checked
'
)
value
=
$
(
this
).
is
(
'
:checked
'
);
set
(
key
,
value
)
set
(
key
,
value
);
// give to user an immediate feedback changing preferences
// give to user an immediate feedback changing preferences
page_generic
.
preferences
()
page_generic
.
preferences
();
})
});
}
};
load
()
load
();
}
}
\ No newline at end of file
debomatic-webui/public/javascripts/utils.js
View file @
f7a4f04a
'
use strict
'
;
var
Utils
=
{
var
Utils
=
{
from_hash_to_view
:
function
(
hash
)
{
from_hash_to_view
:
function
(
hash
)
{
if
(
!
hash
)
if
(
!
hash
)
hash
=
window
.
location
.
hash
hash
=
window
.
location
.
hash
;
hash
=
hash
.
replace
(
'
#
'
,
''
)
hash
=
hash
.
replace
(
'
#
'
,
''
);
info
=
hash
.
split
(
'
/
'
);
var
info
=
hash
.
split
(
'
/
'
);
var
view
=
{}
var
view
=
{};
view
.
distribution
=
{}
view
.
distribution
=
{};
view
.
packages
=
{}
view
.
packages
=
{};
view
.
package
=
{}
view
.
package
=
{};
view
.
file
=
{}
view
.
file
=
{};
if
(
info
.
length
>=
1
)
{
if
(
info
.
length
>=
1
)
{
view
.
distribution
.
name
=
info
[
0
];
view
.
distribution
.
name
=
info
[
0
];
}
}
if
(
info
.
length
>=
3
){
if
(
info
.
length
>=
3
)
{
view
.
package
.
name
=
info
[
1
];
view
.
package
.
name
=
info
[
1
];
view
.
package
.
version
=
info
[
2
];
view
.
package
.
version
=
info
[
2
];
view
.
package
.
orig_name
=
view
.
package
.
name
+
'
_
'
+
view
.
package
.
version
view
.
package
.
orig_name
=
view
.
package
.
name
+
'
_
'
+
view
.
package
.
version
;
}
}
if
(
info
.
length
>=
4
)
{
if
(
info
.
length
>=
4
)
{
view
.
file
.
name
=
info
[
3
]
view
.
file
.
name
=
info
[
3
];
view
.
file
.
orig_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
view
.
file
.
orig_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
;
}
}
return
view
return
view
;
},
},
from_view_to_hash
:
function
(
view
)
{
hash
=
"
#
"
if
(
Utils
.
check_view_distribution
(
view
))
{
hash
=
hash
+
view
.
distribution
.
name
if
(
Utils
.
check_view_package
(
view
))
{
hash
=
hash
+
'
/
'
+
view
.
package
.
name
+
"
/
"
+
view
.
package
.
version
if
(
Utils
.
check_view_file
(
view
))
hash
=
hash
+
'
/
'
+
view
.
file
.
name
}
}
return
hash
},
check_view_distribution
:
function
(
view
)
{
return
view
&&
view
.
distribution
&&
view
.
distribution
.
name
},
check_view_package
:
function
(
view
)
{
return
Utils
.
check_view_distribution
(
view
)
&&
view
.
package
&&
view
.
package
.
name
&&
view
.
package
.
version
&&
view
.
package
.
orig_name
},
check_view_file
:
function
(
view
)
{
return
Utils
.
check_view_package
(
view
)
&&
view
.
file
&&
view
.
file
.
name
},
get_status_icon_and_class
:
function
(
status_data
)
{
from_view_to_hash
:
function
(
view
)
{
var
_c
=
config
.
status
.
className
var
hash
=
'
#
'
;
var
_i
=
config
.
status
.
icons
if
(
Utils
.
check_view_distribution
(
view
))
{
var
_s
=
status_data
hash
=
hash
+
view
.
distribution
.
name
;
var
className
=
null
if
(
Utils
.
check_view_package
(
view
))
{
var
icon
=
null
hash
=
hash
+
'
/
'
+
view
.
package
.
name
+
'
/
'
+
view
.
package
.
version
;
if
(
_s
.
hasOwnProperty
(
'
success
'
))
{
if
(
Utils
.
check_view_file
(
view
))
if
(
_s
.
success
==
true
)
{
hash
=
hash
+
'
/
'
+
view
.
file
.
name
;
className
=
_c
.
success
}
icon
=
_i
.
success
}
}
return
hash
;
else
{
},
className
=
_c
.
fail
icon
=
_i
.
fail
}
}
else
{
className
=
_c
[
_s
.
status
]
icon
=
_i
[
_s
.
status
]
}
// do not change color if update or create and successed
check_view_distribution
:
function
(
view
)
{
if
(
_s
.
success
==
true
&&
return
view
&&
view
.
distribution
&&
view
.
distribution
.
name
;
_s
.
status
!=
config
.
status
.
build
)
},
{
className
=
_c
[
_s
.
status
]
}
return
{
check_view_package
:
function
(
view
)
{
className
:
className
,
return
Utils
.
check_view_distribution
(
view
)
&&
view
.
package
&&
view
.
package
.
name
&&
view
.
package
.
version
&&
view
.
package
.
orig_name
;
icon
:
icon
},
}
},
check_view_file
:
function
(
view
)
{
return
Utils
.
check_view_package
(
view
)
&&
view
.
file
&&
view
.
file
.
name
;
},
get_status_icon_and_class
:
function
(
status_data
)
{
var
_c
=
config
.
status
.
className
;
var
_i
=
config
.
status
.
icons
;
var
_s
=
status_data
;
var
className
=
null
;
var
icon
=
null
;
if
(
_s
.
hasOwnProperty
(
'
success
'
))
{
if
(
_s
.
success
===
true
)
{
className
=
_c
.
success
;
icon
=
_i
.
success
;
}
else
{
className
=
_c
.
fail
;
icon
=
_i
.
fail
;
}
}
else
{
className
=
_c
[
_s
.
status
];
icon
=
_i
[
_s
.
status
];
}
get_status_icon_html
:
function
(
status_data
)
{
// do not change color if update or create and successed
info
=
Utils
.
get_status_icon_and_class
(
status_data
)
if
(
_s
.
success
===
true
&&
return
'
<span class="icon glyphicon glyphicon-
'
+
info
.
icon
+
'
"></span>
'
_s
.
status
!=
config
.
status
.
build
)
{
},
className
=
_c
[
_s
.
status
];
}
// clone an object via JSON
return
{
clone
:
function
(
object
)
{
className
:
className
,
return
JSON
.
parse
(
JSON
.
stringify
(
object
));
icon
:
icon
}
};
}
},
get_status_icon_html
:
function
(
status_data
)
{
var
info
=
Utils
.
get_status_icon_and_class
(
status_data
);
return
'
<span class="icon glyphicon glyphicon-
'
+
info
.
icon
+
'
"></span>
'
;
},
// clone an object via JSON
clone
:
function
(
object
)
{
return
JSON
.
parse
(
JSON
.
stringify
(
object
));
}
};
debomatic-webui/views/distribution.ejs
View file @
f7a4f04a
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<h2>Packages</h2>
<h2>Packages</h2>
<ul class="nav nav-pills nav-stacked"></ul>
<ul class="nav nav-pills nav-stacked"></ul>
</nav>
</nav>
<div id="sticky" >
<div id="sticky" >
<section id="files">
<section id="files">
<nav id="logs">
<nav id="logs">
...
@@ -24,7 +24,11 @@
...
@@ -24,7 +24,11 @@
</nav>
</nav>
<div class="others">
<div class="others">
<nav id="sources">
<nav id="sources">
<h4>Sources</h4>
<h4>Sources
<a class="btn btn-link" title="Get all sources in one click" onclick="download_all('#sources')">
<span class="glyphicon glyphicon-download-alt"></span>
</a>
</h4>
<ul></ul>
<ul></ul>
</nav>
</nav>
<nav id="debs">
<nav id="debs">
...
...
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