Commit fae96602 authored by Leo Iannacone's avatar Leo Iannacone

Merge branch 'master' into portable

parents 86a14982 accf5a4f
# 0.4.1 (2014-06-13)
* [fix] preview file using a fixed max-height on new content
* [fix] show and hide correctly debomatic status when build packages
* [fix] reduce update delay when get new content (now 150 ms)
# 0.4.0 (2014-06-12) # 0.4.0 (2014-06-12)
* [new] always show only max_lines in preview, also when new_content is recevied * [new] always show only max_lines in preview, also when new_content is recevied
* [new] get debomatic real status by reading pidfile in /var/run directory * [new] get debomatic real status by reading pidfile in /var/run directory
......
...@@ -67,7 +67,7 @@ config.web.preferences.debug = 0; // debug level - 0 means disabled ...@@ -67,7 +67,7 @@ config.web.preferences.debug = 0; // debug level - 0 means disabled
// DO NOT TOUCH these ones // DO NOT TOUCH these ones
config.version = '0.4.0'; config.version = '0.4.1';
// 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
......
...@@ -68,6 +68,7 @@ function Page_Distrubion(socket) { ...@@ -68,6 +68,7 @@ function Page_Distrubion(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 current_file_in_preview = false; var current_file_in_preview = false;
function __check_hash_makes_sense() { function __check_hash_makes_sense() {
...@@ -102,8 +103,7 @@ function Page_Distrubion(socket) { ...@@ -102,8 +103,7 @@ function Page_Distrubion(socket) {
view.file.path = config.paths.debomatic + '/' + view.distribution.name + '/pool/' + view.package.orig_name + '/' + complete_name; view.file.path = config.paths.debomatic + '/' + view.distribution.name + '/pool/' + view.package.orig_name + '/' + complete_name;
label += ' <a class="btn btn-link btn-lg" title="Download" href="' + view.file.path + '"> ' + label += ' <a class="btn btn-link btn-lg" title="Download" href="' + view.file.path + '"> ' +
'<span class="glyphicon glyphicon-download-alt"></span></a>'; '<span class="glyphicon glyphicon-download-alt"></span></a>';
if (config.file.preview.indexOf(view.file.name) >= 0) { if (current_file_in_preview) {
current_file_in_preview = true;
var view_all = $('<a id="get-whole-file" class="btn btn-link btn-lg" title="View the whole file"></a>'); var view_all = $('<a id="get-whole-file" class="btn btn-link btn-lg" title="View the whole file"></a>');
view_all.html('<span class="glyphicon glyphicon-eye-open"></span>'); view_all.html('<span class="glyphicon glyphicon-eye-open"></span>');
label += view_all.get(0).outerHTML; label += view_all.get(0).outerHTML;
...@@ -120,8 +120,9 @@ function Page_Distrubion(socket) { ...@@ -120,8 +120,9 @@ function Page_Distrubion(socket) {
// set onclick get-whole-file // set onclick get-whole-file
$("#get-whole-file").on('click', function () { $("#get-whole-file").on('click', function () {
debug(1, "get the whole file");
file.get(true); file.get(true);
current_file_in_preview = false; $(this).remove();
}); });
}, },
clean: function () { clean: function () {
...@@ -282,6 +283,8 @@ function Page_Distrubion(socket) { ...@@ -282,6 +283,8 @@ function Page_Distrubion(socket) {
view.file = Utils.clone(socket_data.file); view.file = Utils.clone(socket_data.file);
$('#file pre').html(socket_data.file.content); $('#file pre').html(socket_data.file.content);
$('#file').show(); $('#file').show();
if (current_file_in_preview)
$('#file pre').scrollTop($('#file pre')[0].scrollHeight);
}, },
clean: function () { clean: function () {
$('#file pre').html(''); $('#file pre').html('');
...@@ -297,6 +300,7 @@ function Page_Distrubion(socket) { ...@@ -297,6 +300,7 @@ function Page_Distrubion(socket) {
content = content.concat(new_content.replace(/\n$/, '').split('\n')); content = content.concat(new_content.replace(/\n$/, '').split('\n'));
content = content.slice(-config.file.num_lines).join('\n'); content = content.slice(-config.file.num_lines).join('\n');
$('#file pre').html(content); $('#file pre').html(content);
$('#file pre').scrollTop($('#file pre')[0].scrollHeight);
} }
if (config.preferences.autoscroll) { if (config.preferences.autoscroll) {
...@@ -313,6 +317,11 @@ function Page_Distrubion(socket) { ...@@ -313,6 +317,11 @@ function Page_Distrubion(socket) {
}, },
get: function (force) { get: function (force) {
if (Utils.check_view_file(view)) { if (Utils.check_view_file(view)) {
if (force) {
file.set_preview(false);
} else {
file.set_preview();
}
var query_data = {}; var query_data = {};
query_data.distribution = view.distribution; query_data.distribution = view.distribution;
query_data.package = view.package; query_data.package = view.package;
...@@ -325,7 +334,26 @@ function Page_Distrubion(socket) { ...@@ -325,7 +334,26 @@ function Page_Distrubion(socket) {
debug_socket('emit', _e.file.get, query_data); debug_socket('emit', _e.file.get, query_data);
socket.emit(_e.file.get, query_data); socket.emit(_e.file.get, query_data);
} }
},
set_preview: function (preview) {
if (preview === undefined) {
preview = config.file.preview.indexOf(view.file.name) >= 0;
}
debug(2, "file set preview", preview);
current_file_in_preview = preview;
if (preview) {
$('#file pre').addClass('preview');
var height = (config.file.num_lines) *
parseInt($('#file pre').css('line-height').replace(/[^-\d\.]/g, '')) +
parseInt($('#file pre').css('padding-top').replace(/[^-\d\.]/g, '')) +
parseInt($('#file pre').css('padding-bottom').replace(/[^-\d\.]/g, ''));
$('#file pre').css('max-height', height);
} else {
$('#file pre').removeClass('preview');
$('#file pre').css('max-height', 'auto');
}
} }
}; };
var breadcrumb = { var breadcrumb = {
...@@ -584,7 +612,7 @@ function Page_Distrubion(socket) { ...@@ -584,7 +612,7 @@ function Page_Distrubion(socket) {
socket.on(_e.file_newcontent, function (socket_data) { socket.on(_e.file_newcontent, function (socket_data) {
debug_socket('received', _e.file_newcontent, socket_data); debug_socket('received', _e.file_newcontent, socket_data);
file.append(socket_data.file.new_content); new_lines.push(socket_data.file.new_content);
}); });
$(window).on('hashchange', function () { $(window).on('hashchange', function () {
...@@ -622,6 +650,18 @@ function Page_Distrubion(socket) { ...@@ -622,6 +650,18 @@ function Page_Distrubion(socket) {
// events. Sleep a while and call stiky.reset() // events. Sleep a while and call stiky.reset()
setTimeout(sticky.reset, 500); 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, 150);
}
watch_for_new_lines();
// Update html according with preferences // Update html according with preferences
preferences(); preferences();
......
...@@ -75,12 +75,14 @@ function Page_Generic() { ...@@ -75,12 +75,14 @@ function Page_Generic() {
var status = { var status = {
set: function (data_status) { set: function (data_status) {
if (!data_status) { if (!data_status) {
if (status_debomatic.running) { if ($('#status li').length === 0) {
$('#status .idle').show(); if (status_debomatic.running) {
$('#status .norunning').hide(); $('#status .idle').show();
} else { $('#status .norunning').hide();
$('#status .idle').hide(); } else {
$('#status .norunning').show(); $('#status .idle').hide();
$('#status .norunning').show();
}
} }
} else { } else {
$('#status ul').html(''); $('#status ul').html('');
...@@ -92,7 +94,7 @@ function Page_Generic() { ...@@ -92,7 +94,7 @@ function Page_Generic() {
} }
}, },
append: function (status_data) { append: function (status_data) {
$('#status .idle').hide(); $('#status .debomatic').hide();
$('#status ul').append(__get_status_html(status_data)); $('#status ul').append(__get_status_html(status_data));
}, },
update: function (status_data) { update: function (status_data) {
......
...@@ -156,6 +156,10 @@ footer { ...@@ -156,6 +156,10 @@ footer {
color: #101010; color: #101010;
} }
#file pre.preview {
overflow:hidden;
}
#title a.btn { #title a.btn {
padding-right: 0; padding-right: 0;
float: right; float: right;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment