Verified Commit 0b54a9a9 authored by Štěpán Henek's avatar Štěpán Henek 🌩

menu indicator that updater is running added

parent 5183e2cb
# Foris - web administration interface for OpenWrt based on NETCONF
# Copyright (C) 2013 CZ.NIC, z.s.p.o. <http://www.nic.cz>
# coding=utf-8
# Foris
# Copyright (C) 2018 CZ.NIC, z.s.p.o. <http://www.nic.cz>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -377,6 +379,14 @@ class UpdaterConfigPage(ConfigPageMixin, updater.UpdaterHandler):
messages.warning(_("There were some errors in your input."))
return result
@staticmethod
def menu_tag():
return {
"show": current_state.updater_is_running,
"hint": _("Updater is running"),
"text": u"↺",
}
class DataCollectionConfigPage(ConfigPageMixin, collect.UcollectHandler):
menu_order = 20
......
......@@ -56,4 +56,7 @@ class BackendData(object):
# update notification count
current_state.update_notification_count(data["notification_count"])
# update updater running indicator
current_state.set_updater_is_running(data["updater_running"])
return self.app(environ, start_response)
......@@ -63,5 +63,13 @@ class ForisState(object):
def repr(self):
return "%s (%s)" % (self.__class__, str(vars(self)))
def set_updater_is_running(self, running):
""" Sets whenter updater is running
:param running: True if updater is running False otherwise
:type required: boolean
"""
logger.debug("setting updater_is_running=%s" % running)
self.updater_is_running = running
current_state = ForisState()
......@@ -189,6 +189,11 @@ Foris.WS = {
if (msg.action == "create" || msg.action == "mark_as_displayed") {
Foris.handleNotificationsCountUpdate(msg.data.new_count);
}
},
updater: function(msg) {
if (msg.action == "run") {
Foris.handleUpdaterRun(msg.data.status != "exit" && msg.data.status != "failed");
}
}
};
......@@ -843,6 +848,23 @@ Foris.handleNotificationsCountUpdate = function(new_count) {
}
};
Foris.handleUpdaterRun = function(running) {
if (running) {
if (!$("#updater_menu_tag").is(":visible")) {
$("#updater_menu_tag").css('opacity', '0');
$("#updater_menu_tag").show();
$("#updater_menu_tag").animate({opacity:1}, 200);
}
} else {
if ($("#updater_menu_tag").is(":visible")) {
$("#updater_menu_tag").animate({opacity:0},200,"linear",function(){
$(this).hide();
$(this).css('opacity', '1');
});
}
}
};
$(document).ready(function () {
Foris.initialize();
......
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