From c89fa05978217d8e46ef48c4089d6fade59eb16c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 4 Mar 2021 11:45:44 +0300 Subject: get rid of the /timers endpoit, use /status --- app.py | 11 ----------- index.html | 32 ++++++++++---------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/app.py b/app.py index 96ffc1d..a224b0b 100755 --- a/app.py +++ b/app.py @@ -283,29 +283,21 @@ class UserInstanceStatusTaskList(Task): class StatusTask(Task): def __init__(self): self.hostname = hostname() - self.top = TopTask() self.system = SystemInstanceStatusTask() self.user = UserInstanceStatusTaskList() def run(self): - self.top.run() self.system.run() self.user.run() def result(self): return { 'hostname': self.hostname, - 'top': self.top.result(), 'system': self.system.result(), 'user': self.user.result(), } -class TimersTask(StatusTask): - # TODO: I'm going to remove the timers-only endpoint completely. - pass - - User = namedtuple('User', ['uid', 'name']) SystemdUser = namedtuple('SystemdUser', ['uid', 'name', 'runtime_dir']) @@ -396,7 +388,6 @@ def systemd_users(): class Request(Enum): STATUS = 'status' - TIMERS = 'timers' TOP = 'top' REBOOT = 'reboot' POWEROFF = 'poweroff' @@ -413,8 +404,6 @@ class Request(Enum): def process(self): if self is Request.STATUS: return StatusTask().complete() - if self is Request.TIMERS: - return TimersTask().complete() if self is Request.TOP: return TopTask().complete() if self is Request.REBOOT: diff --git a/index.html b/index.html index 7c8f487..3cbf6cc 100644 --- a/index.html +++ b/index.html @@ -45,7 +45,7 @@ h1, .h1 {

           
           
-

systemctl --system list-timers --all refreshed every - seconds

+

systemctl --system list-timers --all refreshed every - seconds


           
@@ -121,7 +121,7 @@ function add_user(name) {

     
     
-

systemctl --user list-timers --all refreshed every ${timers_refresh_interval_seconds} seconds

+

systemctl --user list-timers --all refreshed every ${status_refresh_interval_seconds} seconds


     
@@ -164,38 +164,26 @@ function set_users(data) { function refresh_status() { $.get('status', function(data) { data = JSON.parse(data); - set_top(data['top']); set_hostname(data['hostname']); set_system(data['system']); set_users(data['user']); }); } -function refresh_timers() { - $.get('timers', function(data) { - data = JSON.parse(data); - set_system(data['system']); - set_users(data['user']); - }); -} +var status_refresh_interval_seconds = 30; -var timers_refresh_interval_seconds = 30; - -function loop_timers() { +function loop_status() { setInterval(function() { - refresh_timers(); - }, timers_refresh_interval_seconds * 1000); - $('#timers_system_refresh_interval').text(timers_refresh_interval_seconds); -} - -function loop() { - loop_top(); - loop_timers(); + refresh_status(); + }, status_refresh_interval_seconds * 1000); + $('#status_system_refresh_interval').text(status_refresh_interval_seconds); } function main() { + refresh_top(); refresh_status(); - loop(); + loop_top(); + loop_status(); } $(function() { -- cgit v1.2.3