Show installation progress in percents

This commit is contained in:
Disassembler 2018-10-26 22:42:34 +02:00
parent 848e99b4af
commit 513c0839a5
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
3 changed files with 6 additions and 6 deletions

View File

@ -295,14 +295,14 @@ class WSGIApp(object):
except:
return self.render_json({'error': request.session.lang.package_manager_error()})
app_title = self.pkgmgr.online_packages[app]['title']
response = self.render_json({'ok': self.render_setup_apps_row(app, app_title, '{:.1f}'.format(total_size / 1048576))})
response = self.render_json({'ok': self.render_setup_apps_row(app, app_title, total_size)})
response.call_on_close(lambda: self.pkgmgr.install_package(app))
return response
def get_install_progress_action(self, request):
# Gets pending installation status
if self.pkgmgr.pending:
return self.render_json({'progress': '{:.1f}'.format(self.pkgmgr.pending / 1048576)})
return self.render_json({'progress': self.pkgmgr.pending})
app = request.form['app']
app_title = self.conf['apps'][app]['title']
return self.render_json({'ok': self.render_setup_apps_row(app, app_title)})
@ -312,7 +312,6 @@ class WSGIApp(object):
try:
app = request.form['app']
app_title = self.conf['apps'][app]['title']
self.vmmgr.stop_app(app)
self.pkgmgr.uninstall_package(app)
except (BadRequest, InvalidValueException):
return self.render_json({'error': request.session.lang.malformed_request()})

View File

@ -178,7 +178,8 @@ function check_progress() {
var tr = progress.closest('tr');
$.post('/get-install-progress', {'app': tr.data('app')}, function(data) {
if (data.progress) {
progress.text(data.progress);
var value = Math.max(0.1, Math.min(data.progress / progress.data('total') * 100, 99.9));
progress.text(parseFloat(value).toFixed(1));
} else {
tr.replaceWith(data.ok);
}

View File

@ -2,6 +2,6 @@
<td>{{ app_title }}</td>
<td class="center"><input type="checkbox" class="app-visible"{% if app not in conf['apps'] %} disabled{% elif conf['apps'][app]['visible'] %} checked{% endif %}></td>
<td class="center"><input type="checkbox" class="app-autostart"{% if app not in conf['apps'] %} disabled{% elif is_service_autostarted(app) %} checked{% endif %}></td>
<td>{% if total_size %}Instalace (<span id="install-progress">0</span> / {{ total_size }} MB){% elif app not in conf['apps'] %} Není nainstalována{% elif is_service_started(app) %}<span class="info">Spuštěna</span>{% else %}<span class="error">Zastavena</span>{% endif %}</td>
<td>{% if total_size %}<div class="loader"></div>{% elif app not in conf['apps'] %}<a href="#" class="app-install">Instalovat</a>{% else %}{% if is_service_started(app) %}<a href="#" class="app-stop">Zastavit</a>{% else %}<a href="#" class="app-start">Spustit</a>{% endif %}, <a href="#" class="app-uninstall">Odinstalovat</a>{% endif %}</td>
<td>{% if total_size %}Instalace (<span id="install-progress" data-total="{{ total_size }}">0.1</span> %){% elif app not in conf['apps'] %} Není nainstalována{% elif is_service_started(app) %}<span class="info">Spuštěna</span>{% else %}<span class="error">Zastavena</span>{% endif %}</td>
<td>{% if total_size %}<div class="loader"></div>{% elif app not in conf['apps'] %}<a href="#" class="app-install">Instalovat</a>{% elif is_service_started(app) %}<a href="#" class="app-stop">Zastavit</a>{% else %}<a href="#" class="app-start">Spustit</a>, <a href="#" class="app-uninstall">Odinstalovat</a>{% endif %}</td>
</tr>