From 448421b511b9630dadb0ebca5de29731d3c56ebf Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Tue, 8 Apr 2008 11:49:10 +0000 Subject: Cleaning up the code even more. Moving view-function from the view-files into a library instead. git-svn-id: svn://svn.alpinelinux.org/acf/quagga/trunk@953 ab2d0c66-481e-0410-8bed-d214d4d58bed --- quagga-controller.lua | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'quagga-controller.lua') diff --git a/quagga-controller.lua b/quagga-controller.lua index cb63668..fdaf6ad 100644 --- a/quagga-controller.lua +++ b/quagga-controller.lua @@ -15,13 +15,14 @@ local function list_redir(self) error (self.conf) end -local function displaycmdmanagement(disablestart,disablestop,disablerestart) +local function displaycmdmanagement(pidofstatus) -- Add a management buttons local management = {} management.start = cfe({ name="cmdmanagement", label="Program control-panel", value="Start", type="submit", + descr="When starting or restarting BGP, the web-page will freeze for some reason!", }) management.stop = cfe({ name="cmdmanagement", label="Program control-panel", @@ -33,11 +34,20 @@ local function displaycmdmanagement(disablestart,disablestop,disablerestart) value="Restart", type="submit", }) + -- next CFE can be used to present the result of the previous action + management.actionresult = cfe({ name="actionresult", + label="Previous action result", + descr="", --Content of this variable is displayed as
 ... 
in BLACK text + errtxt="", --Content of this variable is displayed as
 ... 
in RED text + }) -- Disable management buttons based on if the process is running or not - if (disablestart) then management.start.disabled = "yes" end - if (disablestop) then management.stop.disabled = "yes" end - if (disablerestart) then management.restart.disabled = "yes" end + if (pidofstatus) then + management.start.disabled = "yes" + else + management.stop.disabled = "yes" + management.restart.disabled = "yes" + end return management end @@ -63,7 +73,7 @@ function expert(self) local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller -- Start/Stop/Restart process - local cmdmanagement + local cmdmanagement, actionresult if ( self.clientdata.cmdmanagement) then cmdmanagement = cfe({ name="cmdmanagement", @@ -73,7 +83,7 @@ function expert(self) value=string.lower(self.clientdata.cmdmanagement), -- This row contains start/stop/restart (one of these commands) }), }) - local actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action ) + actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action ) end local status=self.model.getstatus() @@ -90,24 +100,20 @@ function expert(self) file.cmdsave.descr="* Changes has been saved!" end - - -- Management buttons - local disablestart,disablestop,disablerestart - -- Disable management buttons based on if the process is running or not - if (string.lower(status.status.value) == "enabled" ) then - disablestart = "yes" - else - disablestop = "yes" + -- Management buttons (Hide/show buttons + local pidofstatus + if (string.lower(status.status.value) == "enabled" ) then pidofstatus = true end + management = displaycmdmanagement(pidofstatus) + if (actionresult) then + management.actionresult.descr=cmdmanagement.descr + management.actionresult.errtxt=cmdmanagement.errtxt end - -- Display management buttons - management = displaycmdmanagement(disablestart,disablestop,disablerestart) return ( { status = status, file = file, modifications = modifications, management = management, - cmdmanagement = cmdmanagement, url = url, } ) end -- cgit v1.2.3