Commit 0abad2f6 authored by Leo Iannacone's avatar Leo Iannacone

update status on socket event

parent 0607b59a
function Page_Generic() function Page_Generic()
{ {
var socket; var socket;
var c = config.status.classes
var i = config.status.icons function __get_status_icon_and_class(status_package) {
var e = config.events var _c = config.status.classes
var _i = config.status.icons
var button_class = null
var icon = null
var s = status_package
if (s.status == 'building') {
button_class = _c.building
icon = _i.building
}
else if (s.status == 'build-failed') {
button_class = _c.failed
icon = _i.failed
}
else {
button_class = _c.successed
icon = _i.successed
}
return {
button_class: button_class,
icon: icon
}
}
function __get_status_html(status_package) { function __get_status_html(status_package) {
var s = status_package var s = status_package
...@@ -14,24 +35,10 @@ function Page_Generic() ...@@ -14,24 +35,10 @@ function Page_Generic()
button.addClass(s.status) button.addClass(s.status)
button.attr('title', s.status + ': ' + s.distribution + ' > ' + s.package) button.attr('title', s.status + ': ' + s.distribution + ' > ' + s.package)
button.attr('href', config.paths.distribution + '#' + s.distribution + '/' + s.package.replace('_', '/') + '/datestamp') button.attr('href', config.paths.distribution + '#' + s.distribution + '/' + s.package.replace('_', '/') + '/datestamp')
// button.html(s.package)
button.html(s.package.split('_')[0]) button.html(s.package.split('_')[0])
var button_class = null var info = __get_status_icon_and_class(s)
var icon = null button.addClass('btn-' + info.button_class)
if (s.status == 'building') { button.html(button.html() + ' <span class="icon glyphicon glyphicon-' + info.icon + '"></span>')
button_class = c.building
icon = i.building
}
else if (s.status == 'build-failed') {
button_class = c.failed
icon = i.failed
}
else {
button_class = c.successed
icon = i.successed
}
button.addClass('btn-' + button_class)
button.html(button.html() + ' <span class="icon glyphicon glyphicon-' + icon + '"></span>')
li.html(button) li.html(button)
var result = $('<div></div>') var result = $('<div></div>')
result.html(li) result.html(li)
...@@ -51,8 +58,30 @@ function Page_Generic() ...@@ -51,8 +58,30 @@ function Page_Generic()
} }
} }
}, },
status: function(new_package) {
status: function(status_package) {
var delay = {}
delay.remove = 10000 // 10 seconds
delay.fadeOut = 2500
var li = $("#status li[id='status-" + status_package.distribution + "-" + status_package.package + "']")
if (li.length > 0
&& status_package.status != 'building')
{
li.html($(__get_status_html(status_package)).children())
// chain fadeOut and delete
setTimeout(function() {
li.children().fadeOut(config.status.delay.fadeOut)
setTimeout(function() {
li.animate({width: 'toggle'})
li.attr('id', '')
}, config.status.delay.fadeOut)
}, config.status.delay.remove)
}
else if (status_package.status == 'building') {
status.append(status_package)
}
} }
} }
...@@ -62,34 +91,33 @@ function Page_Generic() ...@@ -62,34 +91,33 @@ function Page_Generic()
if (data_status.packages.length > 0) { if (data_status.packages.length > 0) {
$('#status .idle').hide() $('#status .idle').hide()
data_status.packages.forEach(function(p){ data_status.packages.forEach(function(p){
$("#status ul").html($("#status ul").html() + " " + __get_status_html(p)) status.append(p)
}) })
} }
},
append: function(status_package) {
$("#status ul").html($("#status ul").html() + " " + __get_status_html(status_package))
} }
} }
this.init = function(mysocket) { this.init = function(mysocket) {
var _e = config.events
socket = mysocket socket = mysocket
// update distributions // update distributions
socket.on(e.broadcast.distributions, function(distributions) { socket.on(_e.broadcast.distributions, function(distributions) {
update.distributions(distributions) update.distributions(distributions)
}); });
socket.on('error', function(data) { console.error(data) }); socket.on('error', function(data) { consol_e.error(data) });
socket.on(e.client.status, function(data_status) { socket.on(_e.client.status, function(packages) {
status.set(data_status) status.set(packages)
}) })
socket.on(e.broadcast.status_update, function(data) { socket.on(_e.broadcast.status_update, function(package_status) {
// this is how to fadeout and remove update.status(package_status)
// setTimeout(function() {$('#id-status').remove();}, 3500);
// $($("li[id='id-status']")[0]).delay(3200).fadeOut(300)
console.log('status_update')
console.log(data)
}) })
} }
} }
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