mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
TGUI Request Console (and Fix TGUI verb)
This commit is contained in:
@@ -38,7 +38,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
// 0 = no new message
|
||||
// 1 = normal priority
|
||||
// 2 = high priority
|
||||
var/screen = RCS_MAINMENU
|
||||
var/screen = RCS_VIEWMSGS
|
||||
var/silent = 0 // set to 1 for it not to beep all the time
|
||||
// var/hackState = 0
|
||||
// 0 = not hacked
|
||||
@@ -105,10 +105,16 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
if(..(user))
|
||||
return
|
||||
ui_interact(user)
|
||||
tgui_interact(user)
|
||||
|
||||
/obj/machinery/requests_console/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
var/data[0]
|
||||
/obj/machinery/requests_console/tgui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "RequestConsole", "[department] Request Console")
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/requests_console/tgui_data(mob/user)
|
||||
var/list/data = ..()
|
||||
data["department"] = department
|
||||
data["screen"] = screen
|
||||
data["message_log"] = message_log
|
||||
@@ -122,93 +128,103 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
|
||||
data["message"] = message
|
||||
data["recipient"] = recipient
|
||||
data["priortiy"] = priority
|
||||
data["priority"] = priority
|
||||
data["msgStamped"] = msgStamped
|
||||
data["msgVerified"] = msgVerified
|
||||
data["announceAuth"] = announceAuth
|
||||
return data
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "request_console.tmpl", "[department] Request Console", 520, 410)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/requests_console/Topic(href, href_list)
|
||||
if(..()) return
|
||||
usr.set_machine(src)
|
||||
/obj/machinery/requests_console/tgui_act(action, list/params)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
add_fingerprint(usr)
|
||||
|
||||
switch(action)
|
||||
if("write")
|
||||
if(reject_bad_text(params["write"]))
|
||||
recipient = params["write"] //write contains the string of the receiving department's name
|
||||
|
||||
if(reject_bad_text(href_list["write"]))
|
||||
recipient = href_list["write"] //write contains the string of the receiving department's name
|
||||
var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
|
||||
if(new_message)
|
||||
message = new_message
|
||||
screen = RCS_MESSAUTH
|
||||
switch(params["priority"])
|
||||
if(1)
|
||||
priority = 1
|
||||
if(2)
|
||||
priority = 2
|
||||
else
|
||||
priority = 0
|
||||
else
|
||||
reset_message(1)
|
||||
. = TRUE
|
||||
|
||||
var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
|
||||
if(new_message)
|
||||
message = new_message
|
||||
screen = RCS_MESSAUTH
|
||||
switch(href_list["priority"])
|
||||
if("1") priority = 1
|
||||
if("2") priority = 2
|
||||
else priority = 0
|
||||
else
|
||||
if("writeAnnouncement")
|
||||
var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
|
||||
if(new_message)
|
||||
message = new_message
|
||||
else
|
||||
reset_message(1)
|
||||
. = TRUE
|
||||
|
||||
if("sendAnnouncement")
|
||||
if(!announcementConsole)
|
||||
return FALSE
|
||||
announcement.Announce(message, msg_sanitized = 1)
|
||||
reset_message(1)
|
||||
. = TRUE
|
||||
|
||||
if(href_list["writeAnnouncement"])
|
||||
var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
|
||||
if(new_message)
|
||||
message = new_message
|
||||
else
|
||||
reset_message(1)
|
||||
if("department")
|
||||
if(!message)
|
||||
return FALSE
|
||||
var/log_msg = message
|
||||
var/pass = 0
|
||||
screen = RCS_SENTFAIL
|
||||
for(var/obj/machinery/message_server/MS in machines)
|
||||
if(!MS.active)
|
||||
continue
|
||||
MS.send_rc_message(ckey(params["department"]), department, log_msg, msgStamped, msgVerified, priority)
|
||||
pass = 1
|
||||
if(pass)
|
||||
screen = RCS_SENTPASS
|
||||
message_log += list(list("Message sent to [recipient]", "[message]"))
|
||||
else
|
||||
audible_message(text("[bicon(src)] *The Requests Console beeps: 'NOTICE: No server detected!'"),,4)
|
||||
. = TRUE
|
||||
|
||||
if(href_list["sendAnnouncement"])
|
||||
if(!announcementConsole) return
|
||||
announcement.Announce(message, msg_sanitized = 1)
|
||||
reset_message(1)
|
||||
//Handle printing
|
||||
if("print")
|
||||
var/msg = message_log[text2num(params["print"])];
|
||||
if(msg)
|
||||
msg = "<b>[msg[1]]:</b><br>[msg[2]]"
|
||||
msg = replacetext(msg, "<BR>", "\n")
|
||||
msg = strip_html_properly(msg)
|
||||
var/obj/item/weapon/paper/R = new(src.loc)
|
||||
R.name = "[department] Message"
|
||||
R.info = "<H3>[department] Requests Console</H3><div>[msg]</div>"
|
||||
. = TRUE
|
||||
|
||||
if(href_list["department"] && message)
|
||||
var/log_msg = message
|
||||
var/pass = 0
|
||||
screen = RCS_SENTFAIL
|
||||
for (var/obj/machinery/message_server/MS in machines)
|
||||
if(!MS.active) continue
|
||||
MS.send_rc_message(ckey(href_list["department"]),department,log_msg,msgStamped,msgVerified,priority)
|
||||
pass = 1
|
||||
if(pass)
|
||||
screen = RCS_SENTPASS
|
||||
message_log += "<B>Message sent to [recipient]</B><BR>[message]"
|
||||
else
|
||||
audible_message(text("[bicon(src)] *The Requests Console beeps: 'NOTICE: No server detected!'"),,4)
|
||||
//Handle screen switching
|
||||
if("setScreen")
|
||||
var/tempScreen = text2num(params["setScreen"])
|
||||
if(tempScreen == RCS_ANNOUNCE && !announcementConsole)
|
||||
return
|
||||
if(tempScreen == RCS_VIEWMSGS)
|
||||
for (var/obj/machinery/requests_console/Console in allConsoles)
|
||||
if(Console.department == department)
|
||||
Console.newmessagepriority = 0
|
||||
Console.icon_state = "req_comp0"
|
||||
Console.set_light(1)
|
||||
if(tempScreen == RCS_MAINMENU)
|
||||
reset_message()
|
||||
screen = tempScreen
|
||||
. = TRUE
|
||||
|
||||
//Handle printing
|
||||
if (href_list["print"])
|
||||
var/msg = message_log[text2num(href_list["print"])];
|
||||
if(msg)
|
||||
msg = replacetext(msg, "<BR>", "\n")
|
||||
msg = strip_html_properly(msg)
|
||||
var/obj/item/weapon/paper/R = new(src.loc)
|
||||
R.name = "[department] Message"
|
||||
R.info = "<H3>[department] Requests Console</H3><div>[msg]</div>"
|
||||
|
||||
//Handle screen switching
|
||||
if(href_list["setScreen"])
|
||||
var/tempScreen = text2num(href_list["setScreen"])
|
||||
if(tempScreen == RCS_ANNOUNCE && !announcementConsole)
|
||||
return
|
||||
if(tempScreen == RCS_VIEWMSGS)
|
||||
for (var/obj/machinery/requests_console/Console in allConsoles)
|
||||
if(Console.department == department)
|
||||
Console.newmessagepriority = 0
|
||||
Console.icon_state = "req_comp0"
|
||||
Console.set_light(1)
|
||||
if(tempScreen == RCS_MAINMENU)
|
||||
reset_message()
|
||||
screen = tempScreen
|
||||
|
||||
//Handle silencing the console
|
||||
if(href_list["toggleSilent"])
|
||||
silent = !silent
|
||||
|
||||
updateUsrDialog()
|
||||
return
|
||||
//Handle silencing the console
|
||||
if("toggleSilent")
|
||||
silent = !silent
|
||||
. = TRUE
|
||||
|
||||
//err... hacking code, which has no reason for existing... but anyway... it was once supposed to unlock priority 3 messaging on that console (EXTREME priority...), but the code for that was removed.
|
||||
/obj/machinery/requests_console/attackby(var/obj/item/weapon/O as obj, var/mob/user as mob)
|
||||
@@ -238,7 +254,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
if(screen == RCS_MESSAUTH)
|
||||
var/obj/item/weapon/card/id/T = O
|
||||
msgVerified = text("<font color='green'><b>Verified by [T.registered_name] ([T.assignment])</b></font>")
|
||||
updateUsrDialog()
|
||||
SStgui.update_uis(src)
|
||||
if(screen == RCS_ANNOUNCE)
|
||||
var/obj/item/weapon/card/id/ID = O
|
||||
if(access_RC_announce in ID.GetAccess())
|
||||
@@ -247,13 +263,13 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
else
|
||||
reset_message()
|
||||
to_chat(user, "<span class='warning'>You are not authorized to send announcements.</span>")
|
||||
updateUsrDialog()
|
||||
SStgui.update_uis(src)
|
||||
if(istype(O, /obj/item/weapon/stamp))
|
||||
if(inoperable(MAINT)) return
|
||||
if(screen == RCS_MESSAUTH)
|
||||
var/obj/item/weapon/stamp/T = O
|
||||
msgStamped = text("<font color='blue'><b>Stamped with the [T.name]</b></font>")
|
||||
updateUsrDialog()
|
||||
SStgui.update_uis(src)
|
||||
return
|
||||
|
||||
/obj/machinery/requests_console/proc/reset_message(var/mainmenu = 0)
|
||||
|
||||
@@ -113,15 +113,15 @@ var/global/list/obj/machinery/message_server/message_servers = list()
|
||||
|
||||
/obj/machinery/message_server/proc/send_rc_message(var/recipient = "",var/sender = "",var/message = "",var/stamp = "", var/id_auth = "", var/priority = 1)
|
||||
rc_msgs += new/datum/data_rc_msg(recipient,sender,message,stamp,id_auth)
|
||||
var/authmsg = "[message]<br>"
|
||||
var/authmsg = "[message]\n"
|
||||
if (id_auth)
|
||||
authmsg += "[id_auth]<br>"
|
||||
authmsg += "([id_auth])\n"
|
||||
if (stamp)
|
||||
authmsg += "[stamp]<br>"
|
||||
authmsg += "([stamp])\n"
|
||||
for (var/obj/machinery/requests_console/Console in allConsoles)
|
||||
if (ckey(Console.department) == ckey(recipient))
|
||||
if(Console.inoperable())
|
||||
Console.message_log += "<B>Message lost due to console failure.</B><BR>Please contact [station_name()] system adminsitrator or AI for technical assistance.<BR>"
|
||||
Console.message_log += list(list("Message lost due to console failure.","Please contact [station_name()] system adminsitrator or AI for technical assistance."))
|
||||
continue
|
||||
if(Console.newmessagepriority < priority)
|
||||
Console.newmessagepriority = priority
|
||||
@@ -131,12 +131,12 @@ var/global/list/obj/machinery/message_server/message_servers = list()
|
||||
if(!Console.silent)
|
||||
playsound(Console, 'sound/machines/twobeep.ogg', 50, 1)
|
||||
Console.audible_message(text("[bicon(Console)] *The Requests Console beeps: 'PRIORITY Alert in [sender]'"),,5)
|
||||
Console.message_log += "<B><FONT color='red'>High Priority message from <A href='?src=\ref[Console];write=[sender]'>[sender]</A></FONT></B><BR>[authmsg]"
|
||||
Console.message_log += list(list("High Priority message from [sender]", "[authmsg]"))
|
||||
else
|
||||
if(!Console.silent)
|
||||
playsound(Console, 'sound/machines/twobeep.ogg', 50, 1)
|
||||
Console.audible_message(text("[bicon(Console)] *The Requests Console beeps: 'Message from [sender]'"),,4)
|
||||
Console.message_log += "<B>Message from <A href='?src=\ref[Console];write=[sender]'>[sender]</A></B><BR>[authmsg]"
|
||||
Console.message_log += list(list("Message from [sender]", "[authmsg]"))
|
||||
Console.set_light(2)
|
||||
|
||||
|
||||
|
||||
@@ -141,6 +141,26 @@
|
||||
*/
|
||||
/datum/proc/tgui_close(mob/user)
|
||||
|
||||
/**
|
||||
* verb
|
||||
*
|
||||
* Used by a client to fix broken TGUI windows caused by opening a UI window before assets load.
|
||||
* Probably not very performant and forcibly destroys a bunch of windows, so it has some warnings attached.
|
||||
* Conveniently, also allows devs to force a dev server reattach without relogging, since it yeets windows.
|
||||
*/
|
||||
/client/verb/tgui_fix_white()
|
||||
set desc = "Only use this if you have a broken TGUI window occupying your screen!"
|
||||
set name = "Fix TGUI"
|
||||
set category = "OOC"
|
||||
|
||||
if(alert(src, "Only use this verb if you have a white TGUI window stuck on your screen.", "Fix TGUI", "Continue", "Nevermind") != "Continue")
|
||||
return
|
||||
|
||||
SStgui.close_user_uis(mob)
|
||||
if(alert(src, "Did that fix the problem?", "Fix TGUI", "Yes", "No") == "No")
|
||||
SStgui.force_close_all_windows(mob)
|
||||
alert(src, "UIs should be fixed now. If not, please cry to your nearest coder.", "Fix TGUI")
|
||||
|
||||
/**
|
||||
* verb
|
||||
*
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
<!--
|
||||
Title: Request Console
|
||||
Used In File(s): \code\game\machinery\requests_console.dm
|
||||
|
||||
#define RCS_MAINMENU 0 // Main men
|
||||
#define RCS_RQASSIST 1 // Request supplies
|
||||
#define RCS_RQSUPPLY 2 // Request assistance
|
||||
#define RCS_SENDINFO 3 // Relay information
|
||||
#define RCS_SENTPASS 4 // Message sent successfully
|
||||
#define RCS_SENTFAIL 5 // Message sent unsuccessfully
|
||||
#define RCS_VIEWMSGS 6 // View messages
|
||||
#define RCS_MESSAUTH 7 // Authentication before sending
|
||||
#define RCS_ANNOUNCE 8 // Send announcementu
|
||||
|
||||
-->
|
||||
|
||||
{{if data.screen == 1}}
|
||||
<div class="item"><h3>Request assistance from another department.</h3></div>
|
||||
<table class="block">
|
||||
{{for data.assist_dept}}
|
||||
{{if value != data.department}}
|
||||
<tr>
|
||||
<td><div class="itemLabelWidest" align="right">{{:value}} -</div></td>
|
||||
<td><div class="item">{{:helper.link('Message', null, { 'write' : value , 'priority' : 1 })}}</div></td>
|
||||
<td><div class="item">{{:helper.link('High Priority', null, { 'write' : value , 'priority' : 2 })}}</div></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{empty}}
|
||||
<tr><td><div class="itemLabel">There are no available departments to request assistance from.</div></td></tr>
|
||||
{{/for}}
|
||||
</table><br>
|
||||
<div class="item">{{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}</div>
|
||||
{{else data.screen == 2}}
|
||||
<div class="item"><h3>Request supplies from another department.</h3></div>
|
||||
<table class="block">
|
||||
{{for data.supply_dept}}
|
||||
{{if value != data.department}}
|
||||
<tr>
|
||||
<td><div class="itemLabelWidest" align="right">{{:value}} - </div></td>
|
||||
<td><div class="item">{{:helper.link('Message', null, { 'write' : value , 'priority' : 1 })}}</div></td>
|
||||
<td><div class="item">{{:helper.link('High Priority', null, { 'write' : value , 'priority' : 2 })}}</div></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{empty}}
|
||||
<tr><td><div class="itemLabel">There are no available departments to request supplies from.</div></td></tr>
|
||||
{{/for}}
|
||||
</table><br>
|
||||
<div class="item">{{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}</div>
|
||||
{{else data.screen == 3}}
|
||||
<div class="item"><h3>Relay info to another department.</h3></div>
|
||||
<table class="block">
|
||||
{{for data.info_dept}}
|
||||
{{if value != data.department}}
|
||||
<tr>
|
||||
<td><div class="itemLabelWidest" align="right">{{:value}} -</div></td>
|
||||
<td width=70px><div class="item">{{:helper.link('Message', null, { 'write' : value , 'priority' : 1 })}}</div></td>
|
||||
<td width=90px><div class="item">{{:helper.link('High Priority', null, { 'write' : value , 'priority' : 2 })}}</div></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{empty}}
|
||||
<tr><td><div class="itemLabel">There are no available departments to relay information to.</div></td></tr>
|
||||
{{/for}}
|
||||
</table><br>
|
||||
<div class="item">{{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}</div>
|
||||
{{else data.screen == 4}}
|
||||
<div class="item"><b>Message sent successfully.</b></div>
|
||||
<div class="item">{{:helper.link('Continue', 'arrowthick-1-e', { 'setScreen' : 0 })}}</div>
|
||||
{{else data.screen == 5}}
|
||||
<div class="item"><b>An Error occured. Message not sent.</b></div>
|
||||
<div class="item">{{:helper.link('Continue', 'arrowthick-1-e', { 'setScreen' : 0 })}}</div>
|
||||
{{else data.screen == 6}}
|
||||
<div class="statusDisplay" style="overflow: auto;">
|
||||
{{for data.message_log}}
|
||||
<div class="item">{{:value}}</div>
|
||||
<div class="item">{{:helper.link('Print', null, { 'print' : index + 1 })}}</div>
|
||||
{{empty}}
|
||||
<div class="item">No messages have been received.</div>
|
||||
{{/for}}
|
||||
</div>
|
||||
<div class="item">{{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}</div>
|
||||
{{else data.screen == 7}}
|
||||
<div class="item"><h2>Message Authentication</h2></div><br>
|
||||
<div class="statusDisplay" style="overflow: auto;">
|
||||
<div class="item"><b>Message for {{:data.recipient}}:</b> {{:data.message}}</div>
|
||||
<div class="item"><b>Validated by:</b> {{:data.msgVerified}}</div>
|
||||
<div class="item"><b>Stamped by:</b> {{:data.msgStamped}}</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
{{:helper.link('Send Message', 'arrowthick-1-e', { 'department' : data.recipient })}}
|
||||
{{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}
|
||||
</div>
|
||||
{{else data.screen == 8}}
|
||||
<div class="item"><h2>Station wide announcement</h2></div>
|
||||
<div class="item"><b>Message:</b> {{:data.message}} {{:helper.link('Write Message', 'pencil', { 'writeAnnouncement' : 1 })}}</div>
|
||||
<br>
|
||||
{{if data.announceAuth}}
|
||||
<div class="item"><b>ID verified. Authentication accepted.</b></div>
|
||||
{{else}}
|
||||
<div class="item">Swipe your ID card to authenticate yourself.</div>
|
||||
{{/if}}
|
||||
<br>
|
||||
<div class="item">
|
||||
{{:helper.link('Announce', 'signal-diag', { 'sendAnnouncement' : 1 }, (data.announceAuth && data.message) ? null : 'disabled' )}}
|
||||
{{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}
|
||||
</div>
|
||||
{{else}}
|
||||
{{if data.newmessagepriority == 1}}
|
||||
<div class="item"><font color='red'>There are new messages</font></div>
|
||||
{{else data.newmessagepriority == 2}}
|
||||
<div class="item"><font color='red'><b>NEW PRIORITY MESSAGES</b></font></div>
|
||||
{{/if}}
|
||||
<div class="item">{{:helper.link('View Messages', data.newmessagepriority ? 'mail-closed' : 'mail-open', { 'setScreen' : 6 })}}</div>
|
||||
<br>
|
||||
<div class="item">{{:helper.link('Request Assistance', 'gear', { 'setScreen' : 1 })}}</div>
|
||||
<div class="item">{{:helper.link('Request Supplies', 'gear', { 'setScreen' : 2 })}}</div>
|
||||
<div class="item">{{:helper.link('Relay Anonymous Information', 'gear', { 'setScreen' : 3})}}</div>
|
||||
<br>
|
||||
{{if data.announcementConsole}}
|
||||
<div class="item">{{:helper.link('Send Station-wide Announcement', 'signal-diag', { 'setScreen' : 8})}}</div>
|
||||
<br>
|
||||
{{/if}}
|
||||
<div class="item">{{:helper.link(data.silent ? 'Speaker OFF' : 'Speaker ON', data.silent ? 'volume-off' : 'volume-on', { 'toggleSilent' : 1})}}</div>
|
||||
{{/if}}
|
||||
332
tgui/packages/tgui/interfaces/RequestConsole.js
Normal file
332
tgui/packages/tgui/interfaces/RequestConsole.js
Normal file
@@ -0,0 +1,332 @@
|
||||
import { decodeHtmlEntities } from 'common/string';
|
||||
import { Fragment } from 'inferno';
|
||||
import { useBackend } from "../backend";
|
||||
import { Box, Button, Flex, Icon, LabeledList, ProgressBar, Section, Tabs } from "../components";
|
||||
import { Window } from "../layouts";
|
||||
|
||||
const RCS_MAINMENU = 0; // Settings menu
|
||||
const RCS_RQASSIST = 1; // Request supplies
|
||||
const RCS_RQSUPPLY = 2; // Request assistance
|
||||
const RCS_SENDINFO = 3; // Relay information
|
||||
const RCS_SENTPASS = 4; // Message sent successfully
|
||||
const RCS_SENTFAIL = 5; // Message sent unsuccessfully
|
||||
const RCS_VIEWMSGS = 6; // View messages
|
||||
const RCS_MESSAUTH = 7; // Authentication before sending
|
||||
const RCS_ANNOUNCE = 8; // Send announcement
|
||||
|
||||
const RequestConsoleSettings = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
silent,
|
||||
} = data;
|
||||
return (
|
||||
<Section title="Settings">
|
||||
<Button
|
||||
selected={!silent}
|
||||
icon={silent ? "volume-mute" : "volume-up"}
|
||||
onClick={() => act("toggleSilent")}>
|
||||
Speaker {silent ? "OFF" : "ON"}
|
||||
</Button>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleSupplies = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
department,
|
||||
supply_dept,
|
||||
} = data;
|
||||
return (
|
||||
<Section title="Supplies">
|
||||
<RequestConsoleSendMenu dept_list={supply_dept} department={department} />
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleAssistance = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
department,
|
||||
assist_dept,
|
||||
} = data;
|
||||
return (
|
||||
<Section title="Request assistance from another department">
|
||||
<RequestConsoleSendMenu dept_list={assist_dept} department={department} />
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleRelay = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
department,
|
||||
info_dept,
|
||||
} = data;
|
||||
return (
|
||||
<Section title="Report Anonymous Information">
|
||||
<RequestConsoleSendMenu dept_list={info_dept} department={department} />
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleSendMenu = (props, context) => {
|
||||
const { act } = useBackend(context);
|
||||
const {
|
||||
dept_list,
|
||||
department,
|
||||
} = props;
|
||||
return (
|
||||
<LabeledList>
|
||||
{dept_list.sort().map(dept => dept !== department && (
|
||||
<LabeledList.Item label={dept} buttons={
|
||||
<Fragment>
|
||||
<Button
|
||||
icon="envelope-open-text"
|
||||
onClick={() => act("write", { write: dept, priority: 1 })}>
|
||||
Message
|
||||
</Button>
|
||||
<Button
|
||||
icon="exclamation-triangle"
|
||||
onClick={() => act("write", { write: dept, priority: 2 })}>
|
||||
High Priority
|
||||
</Button>
|
||||
</Fragment>
|
||||
} />
|
||||
) || null)}
|
||||
</LabeledList>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleSendPass = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
return (
|
||||
<Section>
|
||||
<Box fontSize={2} color="good">
|
||||
Message Sent Successfully
|
||||
</Box>
|
||||
<Box>
|
||||
<Button
|
||||
icon="arrow-right"
|
||||
onClick={() => act("setScreen", { setScreen: RCS_MAINMENU })}>
|
||||
Continue
|
||||
</Button>
|
||||
</Box>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleSendFail = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
return (
|
||||
<Section>
|
||||
<Box fontSize={1.5} bold color="bad">
|
||||
An error occured. Message Not Sent.
|
||||
</Box>
|
||||
<Box>
|
||||
<Button
|
||||
icon="arrow-right"
|
||||
onClick={() => act("setScreen", { setScreen: RCS_MAINMENU })}>
|
||||
Continue
|
||||
</Button>
|
||||
</Box>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleViewMessages = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
message_log,
|
||||
} = data;
|
||||
return (
|
||||
<Section title="Messages">
|
||||
{(message_log.length && message_log.map((msg, i) => (
|
||||
<LabeledList.Item label={decodeHtmlEntities(msg[0])} key={i}
|
||||
buttons={
|
||||
<Button
|
||||
icon="print"
|
||||
onClick={() => act("print", { print: i + 1 })}>
|
||||
Print
|
||||
</Button>
|
||||
}>
|
||||
{decodeHtmlEntities(msg[1])}
|
||||
</LabeledList.Item>
|
||||
))) || (
|
||||
<Box>
|
||||
No messages.
|
||||
</Box>
|
||||
)}
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleMessageAuth = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
message,
|
||||
recipient,
|
||||
priority,
|
||||
msgStamped,
|
||||
msgVerified,
|
||||
} = data;
|
||||
return (
|
||||
<Section title="Message Authentication">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label={"Message for " + recipient}>
|
||||
{message}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Priority">
|
||||
{priority === 2 ? "High Priority" : (priority === 1 ? "Normal Priority" : "Unknown")}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Validated By" color={msgVerified ? "good" : "bad"}>
|
||||
{decodeHtmlEntities(msgVerified) || "No Validation"}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Stamped By" color={msgStamped ? "good" : "bad"}>
|
||||
{decodeHtmlEntities(msgStamped) || "No Stamp"}
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
<Button
|
||||
mt={1}
|
||||
icon="share"
|
||||
onClick={() => act("department", { department: recipient })}>
|
||||
Send Message
|
||||
</Button>
|
||||
<Button
|
||||
icon="undo"
|
||||
onClick={() => act("setScreen", { setScreen: RCS_MAINMENU })}>
|
||||
Back
|
||||
</Button>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const RequestConsoleAnnounce = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
department,
|
||||
screen,
|
||||
message_log,
|
||||
newmessagepriority,
|
||||
silent,
|
||||
announcementConsole,
|
||||
assist_dept,
|
||||
supply_dept,
|
||||
info_dept,
|
||||
message,
|
||||
recipient,
|
||||
priority,
|
||||
msgStamped,
|
||||
msgVerified,
|
||||
announceAuth,
|
||||
} = data;
|
||||
return (
|
||||
<Section title="Send Station-Wide Announcement">
|
||||
{announceAuth && (
|
||||
<Fragment>
|
||||
<Box bold color="good" mb={1}>
|
||||
ID Verified. Authentication Accepted.
|
||||
</Box>
|
||||
<Section title="Message" mt={1} maxHeight="200px" scrollable buttons={
|
||||
<Button
|
||||
ml={1}
|
||||
icon="pen"
|
||||
onClick={() => act("writeAnnouncement")}>
|
||||
Edit
|
||||
</Button>
|
||||
}>
|
||||
{message || "No Message"}
|
||||
</Section>
|
||||
</Fragment>
|
||||
) || (
|
||||
<Box bold color="bad" mb={1}>
|
||||
Swipe your ID card to authenticate yourself.
|
||||
</Box>
|
||||
)}
|
||||
<Button
|
||||
disabled={!message || !announceAuth}
|
||||
icon="share"
|
||||
onClick={() => act("sendAnnouncement")}>
|
||||
Announce
|
||||
</Button>
|
||||
<Button
|
||||
icon="undo"
|
||||
onClick={() => act("setScreen", { setScreen: RCS_MAINMENU })}>
|
||||
Back
|
||||
</Button>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
let screenToTemplate = {};
|
||||
screenToTemplate[RCS_MAINMENU] = RequestConsoleSettings;
|
||||
screenToTemplate[RCS_RQASSIST] = RequestConsoleAssistance;
|
||||
screenToTemplate[RCS_RQSUPPLY] = RequestConsoleSupplies;
|
||||
screenToTemplate[RCS_SENDINFO] = RequestConsoleRelay;
|
||||
screenToTemplate[RCS_SENTPASS] = RequestConsoleSendPass;
|
||||
screenToTemplate[RCS_SENTFAIL] = RequestConsoleSendFail;
|
||||
screenToTemplate[RCS_VIEWMSGS] = RequestConsoleViewMessages;
|
||||
screenToTemplate[RCS_MESSAUTH] = RequestConsoleMessageAuth;
|
||||
screenToTemplate[RCS_ANNOUNCE] = RequestConsoleAnnounce;
|
||||
|
||||
export const RequestConsole = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
screen,
|
||||
newmessagepriority,
|
||||
announcementConsole,
|
||||
} = data;
|
||||
|
||||
let BodyElement = screenToTemplate[screen];
|
||||
|
||||
return (
|
||||
<Window width={520} height={410} resizable>
|
||||
<Window.Content scrollable>
|
||||
<Tabs>
|
||||
<Tabs.Tab
|
||||
selected={screen === RCS_VIEWMSGS}
|
||||
onClick={() => act("setScreen", { setScreen: RCS_VIEWMSGS })}
|
||||
icon="envelope-open-text">
|
||||
Messages
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
selected={screen === RCS_RQASSIST}
|
||||
onClick={() => act("setScreen", { setScreen: RCS_RQASSIST })}
|
||||
icon="share-square">
|
||||
Assistance
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
selected={screen === RCS_RQSUPPLY}
|
||||
onClick={() => act("setScreen", { setScreen: RCS_RQSUPPLY })}
|
||||
icon="share-square">
|
||||
Supplies
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
selected={screen === RCS_SENDINFO}
|
||||
onClick={() => act("setScreen", { setScreen: RCS_SENDINFO })}
|
||||
icon="share-square-o">
|
||||
Report
|
||||
</Tabs.Tab>
|
||||
{announcementConsole && (
|
||||
<Tabs.Tab
|
||||
selected={screen === RCS_ANNOUNCE}
|
||||
onClick={() => act("setScreen", { setScreen: RCS_ANNOUNCE })}
|
||||
icon="volume-up">
|
||||
Announce
|
||||
</Tabs.Tab>
|
||||
) || null}
|
||||
<Tabs.Tab
|
||||
selected={screen === RCS_MAINMENU}
|
||||
onClick={() => act("setScreen", { setScreen: RCS_MAINMENU })}
|
||||
icon="cog" />
|
||||
</Tabs>
|
||||
{newmessagepriority && (
|
||||
<Section
|
||||
title={newmessagepriority > 1 ? "NEW PRIORITY MESSAGES" : "There are new messages!"}
|
||||
color={newmessagepriority > 1 ? "bad" : "average"} bold={newmessagepriority > 1} />
|
||||
) || null}
|
||||
<BodyElement />
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user