diff --git a/src/css/style.less b/src/css/style.less index e1496f71..69d051bd 100644 --- a/src/css/style.less +++ b/src/css/style.less @@ -550,6 +550,21 @@ input[type='radio'].nice-radio { } } +.messages .progress { + display:inline-block; + height:0.8em; + margin-bottom: 0; + width: 200px; + border-radius: 5px; +} + +.messages .progress-bar-striped { + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0.5) 75%, transparent 75%, transparent); +} + +.messages .progress-bar.active { + animation-direction: reverse; +} /** custom badges **/ .badge { diff --git a/src/js/yunohost/helpers.js b/src/js/yunohost/helpers.js index 260bde6a..d572807a 100644 --- a/src/js/yunohost/helpers.js +++ b/src/js/yunohost/helpers.js @@ -35,10 +35,31 @@ message = message.split("\n").join("
"); + // If the message starts with a progress bar + progressbar = message.match(/^\[#*\+*\.*\] > /); + if (progressbar) + { + progressbar = progressbar[0]; + // Remove the progress bar from the mesage + message = message.replace(progressbar,""); + // Compute percent + done = (progressbar.match(/#/g)||[]).length; + ongoing = (progressbar.match(/\+/g)||[]).length; + remaining = (progressbar.match(/\./g)||[]).length; + total = done + ongoing + remaining; + done = done * 100 / total; + ongoing = ongoing * 100 / total; + // Actually build the message with the progress bar + message = '

' + message + '

'; + } + else + { + message = '

'+message+'

'; + } + // Add message $('#flashMessage .messages') - .prepend('
'+ - '

'+ message +'

'); + .prepend('
'+message+'
'); // Scroll to top to view new messages $('#flashMessage').scrollTop(0);