Add update check and action stub
This commit is contained in:
parent
ebd24befaf
commit
14876bc139
@ -65,6 +65,12 @@ class AppMgr:
|
||||
self.update_app_autostart(app, False)
|
||||
self.pkgmgr.uninstall_app(app)
|
||||
|
||||
def update_app(self, item):
|
||||
# Main update function. Wrapper for download and update script
|
||||
self.stop_app(item)
|
||||
item.data = Pkg()
|
||||
self.pkgmgr.update_app(item.key, item.data)
|
||||
|
||||
def get_services_deps(self):
|
||||
# Fisrt, build a dictionary of {app: [needs]}
|
||||
needs = {}
|
||||
|
@ -7,6 +7,7 @@ import shutil
|
||||
import subprocess
|
||||
|
||||
from enum import Enum
|
||||
from packaging.version import Version
|
||||
from werkzeug.exceptions import BadRequest, NotFound, Unauthorized
|
||||
|
||||
from . import crypto
|
||||
@ -82,6 +83,12 @@ class PkgMgr:
|
||||
self.purge_package(dep)
|
||||
self.unregister_package(dep)
|
||||
|
||||
def update_app(self, app, item):
|
||||
# Main update function.
|
||||
# TODO: Implement actual update
|
||||
uninstall_app(app)
|
||||
install_app(app, item)
|
||||
|
||||
def download_package(self, name, item):
|
||||
# Download tar.xz package and verify its hash. Can raise InvalidSignature
|
||||
pkg_archive = '{}_{}-{}.tar.xz'.format(name, self.online_packages[name]['version'], self.online_packages[name]['release'])
|
||||
@ -164,3 +171,8 @@ class PkgMgr:
|
||||
for d in self.conf['packages'][name]['depends']:
|
||||
deps.setdefault(d, []).append(name)
|
||||
return deps
|
||||
|
||||
def has_update(self, app):
|
||||
if not self.online_packages:
|
||||
return False
|
||||
return Version(self.conf['packages'][app]['version']) < Version(self.online_packages[app]['version'])
|
||||
|
@ -62,6 +62,7 @@ class WSGIApp:
|
||||
Rule('/get-app-status', endpoint='get_app_status_action'),
|
||||
Rule('/clear-app-status', endpoint='clear_app_status_action'),
|
||||
Rule('/uninstall-app', endpoint='uninstall_app_action'),
|
||||
Rule('/update-app', endpoint='update_app_action'),
|
||||
Rule('/update-password', endpoint='update_password_action'),
|
||||
Rule('/shutdown-vm', endpoint='shutdown_vm_action'),
|
||||
Rule('/reboot-vm', endpoint='reboot_vm_action'),
|
||||
@ -247,12 +248,15 @@ class WSGIApp:
|
||||
if not installed:
|
||||
status = lang.status_not_installed()
|
||||
actions = '<a href="#" class="app-install">{}</a>'.format(lang.action_install())
|
||||
elif self.appmgr.is_service_started(app):
|
||||
else:
|
||||
if self.appmgr.is_service_started(app):
|
||||
status = '<span class="info">{}</span>'.format(lang.status_started())
|
||||
actions = '<a href="#" class="app-stop">{}</a>'.format(lang.action_stop())
|
||||
else:
|
||||
status = '<span class="error">{}</span>'.format(lang.status_stopped())
|
||||
actions = '<a href="#" class="app-start">{}</a>, <a href="#" class="app-uninstall">{}</a>'.format(lang.action_start(), lang.action_uninstall())
|
||||
if self.appmgr.pkgmgr.has_update(app):
|
||||
actions = '{}, <a href="#" class="app-update">{}</a>'.format(actions, lang.action_update())
|
||||
app_data[app] = {'title': title, 'visible': visible, 'installed': installed, 'autostarted': autostarted, 'status': status, 'actions': actions}
|
||||
return self.render_template('setup-apps-table.html', request, app_data=app_data)
|
||||
|
||||
@ -385,6 +389,10 @@ class WSGIApp:
|
||||
# Queues application uninstallation
|
||||
return self.enqueue_app_action(request, self.appmgr.uninstall_app)
|
||||
|
||||
def update_app_action(self, request):
|
||||
# Queues application update
|
||||
return self.enqueue_app_action(request, self.appmgr.update_app)
|
||||
|
||||
def get_app_status_action(self, request):
|
||||
# Gets application and queue status
|
||||
return self.render_json({'ok': self.render_setup_apps_table(request)})
|
||||
|
@ -50,6 +50,7 @@ class WSGILang:
|
||||
'action_stop': 'Zastavit',
|
||||
'action_install': 'Instalovat',
|
||||
'action_uninstall': 'Odinstalovat',
|
||||
'action_update': 'Aktualizovat',
|
||||
'ssh_keys_installed': 'SSH klíče byly úspěšně změněny.',
|
||||
'vpn_updated': 'Nastavení VPN bylo úspěšně změněno.',
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ $(function() {
|
||||
.on('click', '.app-stop', stop_app)
|
||||
.on('click', '.app-install', install_app)
|
||||
.on('click', '.app-uninstall', uninstall_app)
|
||||
.on('click', '.app-update', update_app)
|
||||
.on('click', '.app-clear-status', clear_app_status);
|
||||
$('#update-password').on('submit', update_password);
|
||||
$('#reboot-vm').on('click', reboot_vm);
|
||||
@ -165,6 +166,10 @@ function uninstall_app(ev) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function update_app(ev) {
|
||||
return _do_app('/update-app', ev);
|
||||
}
|
||||
|
||||
function clear_app_status(ev) {
|
||||
return _do_app('/clear-app-status', ev);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user