upgraded dashboard to be more streamlined for CLI
This commit is contained in:
parent
beeaa626a9
commit
a6963ed84f
@ -9,58 +9,47 @@ modpol.interactions = {}
|
|||||||
-- DASHBOARDS
|
-- DASHBOARDS
|
||||||
-- ==========
|
-- ==========
|
||||||
|
|
||||||
function modpol.interactions.login()
|
|
||||||
print("Log in as which user?")
|
|
||||||
local username = io.read()
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local org = modpol.interactions.dashboard(username)
|
|
||||||
if org then
|
|
||||||
modpol.interactions.org_dashboard(username, org)
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Function: modpol.interactions.dashboard(user)
|
-- Function: modpol.interactions.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?
|
||||||
-- Output: Displays a menu of commands to the user
|
-- Output: Displays a menu of commands to the user
|
||||||
-- TKTK currently just prints all of modpol---needs major improvement
|
-- TKTK currently just prints all of modpol---needs major improvement
|
||||||
function modpol.interactions.dashboard(user)
|
function modpol.interactions.dashboard(user)
|
||||||
print()
|
-- adds user to root org if not already in it
|
||||||
local org_list = modpol.orgs.list_all()
|
if not modpol.instance:has_member(user) then
|
||||||
|
modpol.instance:add_member(user)
|
||||||
print('Select an org')
|
|
||||||
for i, org_name in ipairs(org_list) do
|
|
||||||
local org = modpol.orgs.get_org(org_name)
|
|
||||||
local indicator = ""
|
|
||||||
if org:has_pending_actions(user) then
|
|
||||||
indicator = "*"
|
|
||||||
end
|
|
||||||
print('['..i..']'..' '..org_name..indicator)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local all_users = modpol.list_users()
|
||||||
|
|
||||||
|
print('All orgs: (user orgs indicated by *)')
|
||||||
|
for id, org in ipairs(modpol.orgs.array) do
|
||||||
|
if type(org) == "table" then
|
||||||
|
local indicator = ""
|
||||||
|
if org:has_member(user) then indicator = "*" end
|
||||||
|
print('['..id..'] '..indicator..org.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
print()
|
||||||
|
print('Users: ' .. table.concat(all_users, ', '))
|
||||||
|
print()
|
||||||
|
|
||||||
|
print('Access which org?')
|
||||||
|
|
||||||
local sel = io.read()
|
local sel = io.read()
|
||||||
local sel_org = org_list[tonumber(sel)]
|
local sel_org = modpol.orgs.array[tonumber(sel)]
|
||||||
|
|
||||||
if not sel_org then return end
|
if not sel_org then return end
|
||||||
|
|
||||||
modpol.interactions.org_dashboard(user, sel_org)
|
modpol.interactions.org_dashboard(user, sel_org)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Function: modpol.interactions.org_dashboard
|
-- Function: modpol.interactions.org_dashboard
|
||||||
-- Params: user (string), org_name (string)
|
-- Params: user (string), org_name (string)
|
||||||
-- Output: Displays a menu of org-specific commands to the user
|
-- Output: Displays a menu of org-specific commands to the user
|
||||||
function modpol.interactions.org_dashboard(user, org_name)
|
function modpol.interactions.org_dashboard(user, org)
|
||||||
print()
|
|
||||||
local org = modpol.orgs.get_org(org_name)
|
|
||||||
if not org then return nil end
|
|
||||||
|
|
||||||
|
|
||||||
local children = {}
|
local children = {}
|
||||||
for k,v in ipairs(org.children) do
|
for k,v in ipairs(org.children) do
|
||||||
local this_child = modpol.orgs.get_org(v)
|
local this_child = modpol.orgs.get_org(v)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user