Commit bfcd9086 authored by Leo Iannacone's avatar Leo Iannacone

Merge branch 'develop' into portable

parents b608c3e7 eda15528
var config = require('./config.js') var config = require('./config.js')
, fs = require('fs') , fs = require('fs')
, tail = require('tailfd').tail , Tail = require('./tail.js')
// watcher on build_status // watcher on build_status
function __watch_build_status (socket, status) { function __watch_build_status (socket, status) {
tail(config.debomatic.jsonfile, function(new_content) { var watcher = new Tail(config.debomatic.jsonfile)
watcher.on('line', function(new_content) {
var data = null var data = null
try { try {
data = JSON.parse(new_content) data = JSON.parse(new_content)
...@@ -45,6 +46,9 @@ function __watch_build_status (socket, status) { ...@@ -45,6 +46,9 @@ function __watch_build_status (socket, status) {
socket.emit(config.events.broadcast.status_update, 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
......
var fs =require('fs')
, Tail = require('tail').Tail
Tail.prototype.watchEvent = function(e) {
var _this = this;
if (e === 'change') {
return fs.stat(this.filename, function(err, stats) {
if (err) {
_this.emit('error', err);
}
if (stats.size < _this.pos) {
_this.pos = 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");
}
}
});
} else if (e === 'rename') {
this.unwatch();
_this.emit('error', "File " + this.filename + " deleted.");
}
};
Tail.prototype.close = function() {
this.unwatch()
}
module.exports = Tail
\ No newline at end of file
var path = require('path') var path = require('path')
, fs = require('fs') , fs = require('fs')
, tail = require('tailfd').tail
, config = require('./config.js') , config = require('./config.js')
, Tail = require('./tail.js')
function __errors_handler(from, err, socket) { function __errors_handler(from, err, socket) {
if (! socket) if (! socket)
...@@ -93,11 +93,15 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) { ...@@ -93,11 +93,15 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) {
updater(event_name, socket, data) updater(event_name, socket, data)
}) })
} }
else { else if(stats.isFile()) {
watcher = tail(watch_path,function(new_content, tailInfo) { watcher = new Tail(watch_path)
watcher.on('line', function(new_content, tailInfo) {
data.file.new_content = new_content + '\n' data.file.new_content = new_content + '\n'
updater(event_name, socket, data) updater(event_name, socket, data)
}); });
watcher.on('error', function(msg) {
socket.emit(config.events.error, msg);
});
} }
socket_watchers[event_name] = watcher socket_watchers[event_name] = watcher
socket.set("watchers", socket_watchers) socket.set("watchers", socket_watchers)
...@@ -110,8 +114,8 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) { ...@@ -110,8 +114,8 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) {
} }
function __generic_handler_watcher(event_name, socket, data, watch_path, callback) { function __generic_handler_watcher(event_name, socket, data, watch_path, callback) {
__watch_path_onsocket(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)
} }
function __send_distributions(socket) { function __send_distributions(socket) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"express": "3.4.8" "express": "3.4.8"
, "ejs": ">= 0.0.1" , "ejs": ">= 0.0.1"
, "socket.io": "*" , "socket.io": "*"
, "tailfd": "*" , "tail": "*"
} }
, "scripts": { , "scripts": {
"install": "bash scripts/install.sh" "install": "bash scripts/install.sh"
......
...@@ -257,7 +257,8 @@ function Page_Distrubion(socket) ...@@ -257,7 +257,8 @@ function Page_Distrubion(socket)
var file_height = $("#fileOffset").offset().top var file_height = $("#fileOffset").offset().top
var footerOffset = $("footer").offset().top var footerOffset = $("footer").offset().top
if (file_height > footerOffset) { if (file_height > footerOffset) {
$('html').animate({ scrollTop: file_height }, 0); debug(2, 'scoll down on new content')
$('html,body').animate({ scrollTop: file_height }, 0);
} }
} }
}, },
...@@ -268,6 +269,9 @@ function Page_Distrubion(socket) ...@@ -268,6 +269,9 @@ function Page_Distrubion(socket)
query_data.package = view.package query_data.package = view.package
query_data.file = view.file query_data.file = view.file
query_data.file.content = null 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) debug_socket("emit", _e.file.get, query_data)
socket.emit(_e.file.get, query_data) socket.emit(_e.file.get, query_data)
} }
...@@ -559,7 +563,7 @@ function Page_Distrubion(socket) ...@@ -559,7 +563,7 @@ function Page_Distrubion(socket)
view.package.status = view.packages[view.package.orig_name].status view.package.status = view.packages[view.package.orig_name].status
view.file = Utils.clone(new_view.file) view.file = Utils.clone(new_view.file)
update.page(old_view) update.page(old_view)
$('html').animate({scrollTop: 0}, 0); $('html,body').animate({scrollTop: 0}, 0);
debug(1, "changing view", "old:", old_view, "new:", new_view) debug(1, "changing view", "old:", old_view, "new:", new_view)
}); });
...@@ -569,7 +573,7 @@ function Page_Distrubion(socket) ...@@ -569,7 +573,7 @@ function Page_Distrubion(socket)
// Init sticky-package back_on_top on click // Init sticky-package back_on_top on click
$("#sticky-package").on("click", function(){ $("#sticky-package").on("click", function(){
$('html').animate({scrollTop: 0}, 100); $('html,body').animate({scrollTop: 0}, 100);
}) })
// WORKAROUND: // WORKAROUND:
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
</div> </div>
</div> </div>
</section> </section>
</div>
</aside> </aside>
<section id="main" class="col-md-9"> <section id="main" class="col-md-9">
......
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