Added org_dashboard to CLI interactions
This commit is contained in:
parent
48b5b3070b
commit
2432633d55
@ -5,7 +5,10 @@
|
|||||||
|
|
||||||
modpol.interactions = {}
|
modpol.interactions = {}
|
||||||
|
|
||||||
-- ===================================================================
|
|
||||||
|
-- DASHBOARDS
|
||||||
|
-- ==========
|
||||||
|
|
||||||
-- Function: modpol.dashboard(user)
|
-- Function: modpol.dashboard(user)
|
||||||
-- Params: user (string)
|
-- Params: user (string)
|
||||||
-- Q: Should this return a menu of commands relevant to the specific user?
|
-- Q: Should this return a menu of commands relevant to the specific user?
|
||||||
@ -17,7 +20,7 @@ function modpol.dashboard(user)
|
|||||||
output = output .. "Orgs:\n" ..
|
output = output .. "Orgs:\n" ..
|
||||||
table.concat(modpol.orgs.list_all(),"\n")
|
table.concat(modpol.orgs.list_all(),"\n")
|
||||||
-- Process status (ongoing processes)
|
-- Process status (ongoing processes)
|
||||||
output = output .. "\nProcesses:\n" .. table.concat(modpol.processes)
|
output = output .. "\nProcesses:\n" .. table.concat(modpol.list_processes(),"\n")
|
||||||
-- Command list (should be redone to be org-specific)
|
-- Command list (should be redone to be org-specific)
|
||||||
output = output .. "\nCommand list:\n"
|
output = output .. "\nCommand list:\n"
|
||||||
for key,value in pairs(modpol) do
|
for key,value in pairs(modpol) do
|
||||||
@ -27,6 +30,43 @@ function modpol.dashboard(user)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Function: modpol.interactions.org_dashboard
|
||||||
|
-- Params: user (string), org_name (string)
|
||||||
|
-- Output: Displays a menu of org-specific commands to the user
|
||||||
|
function modpol.interactions.org_dashboard(user, org_name)
|
||||||
|
local org = modpol.orgs.get_org(org_name)
|
||||||
|
if not org then return nil end
|
||||||
|
local is_member = org:has_member(user)
|
||||||
|
local membership_toggle = function()
|
||||||
|
local toggle_code = ""
|
||||||
|
if is_member then
|
||||||
|
toggle_code = "[Leave]"
|
||||||
|
else
|
||||||
|
toggle_code = "[Join]"
|
||||||
|
end
|
||||||
|
return toggle_code
|
||||||
|
end
|
||||||
|
local children = {}
|
||||||
|
for k,v in ipairs(org.children) do
|
||||||
|
local this_child = modpol.orgs.get_org(v)
|
||||||
|
table.insert(children, this_child.name)
|
||||||
|
end
|
||||||
|
-- set up output
|
||||||
|
local dashboard_table = {
|
||||||
|
"Org: " .. org_name,
|
||||||
|
membership_toggle(),
|
||||||
|
"Members: " .. table.concat(org.members, ", "),
|
||||||
|
"Children: " .. table.concat(children, ", "),
|
||||||
|
"Policies: " .. table.concat(org.policies, ", "),
|
||||||
|
"Processes: " .. table.concat(org.processes, ", "),
|
||||||
|
"[Add child]",
|
||||||
|
"[Remove org]",
|
||||||
|
"[Dashboard: modpol.dashboard()]"
|
||||||
|
}
|
||||||
|
-- present to player
|
||||||
|
print(table.concat(dashboard_table, "\n"))
|
||||||
|
end
|
||||||
|
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- Function: modpol.interactions.message
|
-- Function: modpol.interactions.message
|
||||||
-- input: user (string), message (string)
|
-- input: user (string), message (string)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user