Skip to content

Commit

Permalink
Merge branch 'project/ares/admin_console' into project/ares/tm_holder
Browse files Browse the repository at this point in the history
  • Loading branch information
realforest2001 committed Sep 4, 2023
2 parents ec59276 + 2ba9163 commit 6513e74
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 3 deletions.
50 changes: 49 additions & 1 deletion code/game/machinery/ARES/AdminAres.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,27 @@
data["active_ref"] = active_ref
data["conversations"] = logged_convos

var/list/logged_access = list()
for(var/datum/ares_ticket/access/access_ticket as anything in tickets_access)
var/lock_status = TICKET_OPEN
switch(access_ticket.ticket_status)
if(TICKET_REJECTED, TICKET_CANCELLED, TICKET_COMPLETED)
lock_status = TICKET_CLOSED

var/list/current_ticket = list()
current_ticket["id"] = access_ticket.ticket_id
current_ticket["time"] = access_ticket.ticket_time
current_ticket["priority_status"] = access_ticket.ticket_priority
current_ticket["title"] = access_ticket.ticket_name
current_ticket["details"] = access_ticket.ticket_details
current_ticket["status"] = access_ticket.ticket_status
current_ticket["submitter"] = access_ticket.ticket_submitter
current_ticket["assignee"] = access_ticket.ticket_assignee
current_ticket["lock_status"] = lock_status
current_ticket["ref"] = "\ref[access_ticket]"
logged_access += list(current_ticket)
data["access_tickets"] = logged_access

return data


Expand Down Expand Up @@ -285,6 +306,9 @@
if("page_deleted_1to1")
admin_interface.last_menu = admin_interface.current_menu
admin_interface.current_menu = "deleted_talks"
if("page_access_management")
admin_interface.last_menu = admin_interface.current_menu
admin_interface.current_menu = "access_management"

// -- 1:1 Conversation -- //
if("new_conversation")
Expand Down Expand Up @@ -312,7 +336,7 @@
if(message)
interface.response_from_ares(message, params["active_convo"])
var/datum/ares_record/talk_log/conversation = locate(params["active_convo"])
var/admin_log = SPAN_STAFF_IC(SPAN_STAFF_IC("<b>ADMINS/MODS: [SPAN_RED("[key_name(user)] replied to [conversation.user]'s ARES message")] [SPAN_GREEN("via Remote Interface")] with: [SPAN_BLUE(message)] </b>"))
var/admin_log = SPAN_STAFF_IC("<b>ADMINS/MODS: [SPAN_RED("[key_name(user)] replied to [conversation.user]'s ARES message")] [SPAN_GREEN("via Remote Interface")] with: [SPAN_BLUE(message)] </b>")
for(var/client/admin in GLOB.admins)
if((R_ADMIN|R_MOD) & admin.admin_holder.rights)
to_chat(admin, admin_log)
Expand All @@ -322,3 +346,27 @@
admin_interface.deleted_1to1 = conversation.conversation
admin_interface.last_menu = admin_interface.current_menu
admin_interface.current_menu = "read_deleted"

if("auth_access")
var/datum/ares_ticket/access/access_ticket = locate(params["ticket"])
if(!access_ticket)
return FALSE
for(var/obj/item/card/id/identification in waiting_ids)
if(!istype(identification))
continue
if(identification.registered_gid != access_ticket.user_id_num)
continue
identification.handle_ares_access(MAIN_AI_SYSTEM, user)
access_ticket.ticket_status = TICKET_GRANTED
playsound(src, 'sound/machines/chime.ogg', 15, 1)
return TRUE
for(var/obj/item/card/id/identification in active_ids)
if(!istype(identification))
continue
if(identification.registered_gid != access_ticket.user_id_num)
continue
identification.handle_ares_access(MAIN_AI_SYSTEM, user)
access_ticket.ticket_status = TICKET_REVOKED
playsound(src, 'sound/machines/chime.ogg', 15, 1)
return TRUE
return FALSE
172 changes: 170 additions & 2 deletions tgui/packages/tgui/interfaces/AresAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const PAGES = {
'read_deleted': () => ReadingTalks,
'security': () => Security,
'requisitions': () => Requisitions,
'antiair': () => AntiAir,
'emergency': () => Emergency,
'admin_access_log': () => AdminAccessLogs,
'access_management': () => AccessManagement,
};

export const AresAdmin = (props, context) => {
Expand Down Expand Up @@ -343,14 +343,26 @@ const MainMenu = (props, context) => {
<Button
content="Remote Access Log"
tooltip="View which admins have been using ARES."
icon="users"
icon="user-secret"
ml="auto"
px="2rem"
width="25vw"
bold
onClick={() => act('page_admin_list')}
/>
</Stack.Item>
<Stack.Item>
<Button
content="Access Ticket Management"
tooltip="View and update access tickets."
icon="user-tag"
ml="auto"
px="2rem"
width="25vw"
bold
onClick={() => act('page_access_management')}
/>
</Stack.Item>
</Stack>
</Section>
</>
Expand Down Expand Up @@ -1608,3 +1620,159 @@ const AdminAccessLogs = (props, context) => {
</>
);
};

const AccessManagement = (props, context) => {
const { data, act } = useBackend(context);
const { logged_in, access_text, last_page, current_menu, access_tickets } =
data;

return (
<>
<Section>
<Flex align="center">
<Box>
<Button
icon="arrow-left"
px="2rem"
textAlign="center"
tooltip="Go back"
onClick={() => act('go_back')}
disabled={last_page === current_menu}
/>
<Button
icon="house"
ml="auto"
mr="1rem"
tooltip="Navigation Menu"
onClick={() => act('home')}
/>
</Box>

<h3>
{logged_in}, {access_text}
</h3>

<Button.Confirm
content="Logout"
icon="circle-user"
ml="auto"
px="2rem"
bold
onClick={() => act('logout')}
/>
</Flex>
</Section>

<Section>
<h1 align="center">Access Ticket Management</h1>
{!!access_tickets.length && (
<Flex
mt="2rem"
className="candystripe"
p=".75rem"
align="center"
fontSize="1.25rem">
<Flex.Item bold width="5rem" shrink="0" mr="1.5rem">
ID
</Flex.Item>
<Flex.Item bold width="6rem" shrink="0" mr="1rem">
Time
</Flex.Item>
<Flex.Item width="8rem" mr="1rem" bold>
Submitter
</Flex.Item>
<Flex.Item width="8rem" mr="1rem" bold>
For
</Flex.Item>
<Flex.Item width="30rem" bold>
Reason
</Flex.Item>
</Flex>
)}
{access_tickets.map((ticket, i) => {
let can_claim = 'Yes';
if (ticket.assignee === logged_in) {
can_claim = 'No';
} else if (ticket.lock_status === 'CLOSED') {
can_claim = 'No';
}
let can_update = 'Yes';
if (ticket.assignee !== logged_in) {
can_update = 'No';
} else if (ticket.lock_status === 'CLOSED') {
can_update = 'No';
}
let view_status = 'Ticket is pending assignment.';
let view_icon = 'circle-question';
let update_tooltip = 'Update Access';
if (ticket.status === 'assigned') {
view_status = 'Ticket is assigned.';
view_icon = 'circle-plus';
update_tooltip = 'Grant Access';
} else if (ticket.status === 'rejected') {
view_status = 'Ticket has been rejected.';
view_icon = 'circle-xmark';
} else if (ticket.status === 'cancelled') {
view_status = 'Ticket was cancelled by reporter.';
view_icon = 'circle-stop';
} else if (ticket.status === 'granted') {
view_status = 'Access ticket has been granted.';
view_icon = 'circle-check';
update_tooltip = 'Revoke Access';
} else if (ticket.status === 'revoked') {
view_status = 'Access ticket has been revoked.';
view_icon = 'circle-minus';
update_tooltip = 'Access revoked. No further changes possible.';
} else if (ticket.status === 'returned') {
view_status = 'Access ticket has been returned.';
view_icon = 'circle-minus';
update_tooltip =
'Access self-returned. No further changes possible.';
}

return (
<Flex key={i} className="candystripe" p=".75rem" align="center">
{!!ticket.priority_status && (
<Flex.Item width="5rem" shrink="0" mr="1.5rem" bold color="red">
{ticket.id}
</Flex.Item>
)}
{!ticket.priority_status && (
<Flex.Item width="5rem" shrink="0" mr="1.5rem" bold>
{ticket.id}
</Flex.Item>
)}
<Flex.Item italic width="6rem" shrink="0" mr="1rem">
{ticket.time}
</Flex.Item>
<Flex.Item width="8rem" mr="1rem">
{ticket.submitter}
</Flex.Item>
<Flex.Item width="8rem" mr="1rem">
{ticket.title}
</Flex.Item>
<Flex.Item width="30rem" shrink="0" textAlign="left">
{ticket.details}
</Flex.Item>
<Flex.Item ml="1rem">
<Button icon={view_icon} tooltip={view_status} />
<Button.Confirm
icon="user-lock"
tooltip="Claim Ticket"
disabled={can_claim === 'No'}
onClick={() => act('claim_ticket', { ticket: ticket.ref })}
/>
<Button.Confirm
icon="user-gear"
tooltip={update_tooltip}
disabled={can_update === 'No'}
onClick={() => act('auth_access', { ticket: ticket.ref })}
/>
</Flex.Item>
</Flex>
);
})}
</Section>
</>
);
};

0 comments on commit 6513e74

Please sign in to comment.