[TGUI] Request Consoles (#14734)

* TGUI Request Consoles

* Mochi tewaks

* Else ill do this
This commit is contained in:
AffectedArc07
2020-10-26 19:25:26 +00:00
committed by GitHub
parent bfe2c9da00
commit 61328bdd76
5 changed files with 579 additions and 336 deletions
+155 -162
View File
@@ -27,6 +27,10 @@
#define COM_ROLES list("Blueshield","NT Representative","Head of Personnel's Desk","Captain's Desk","Bridge")
#define SCI_ROLES list("Robotics","Science","Research Director's Desk")
#define RQ_NONEW_MESSAGES 0
#define RQ_NORMALPRIORITY 1
#define RQ_HIGHPRIORITY 2
GLOBAL_LIST_EMPTY(req_console_assistance)
GLOBAL_LIST_EMPTY(req_console_supplies)
GLOBAL_LIST_EMPTY(req_console_information)
@@ -35,7 +39,7 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
/obj/machinery/requests_console
name = "Requests Console"
desc = "A console intended to send requests to different departments on the station."
anchored = 1
anchored = TRUE
icon = 'icons/obj/terminals.dmi'
icon_state = "req_comp0"
max_integrity = 300
@@ -43,19 +47,15 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
var/department = "Unknown" //The list of all departments on the station (Determined from this variable on each unit) Set this to the same thing if you want several consoles in one department
var/list/message_log = list() //List of all messages
var/departmentType = 0 //Bitflag. Zero is reply-only. Map currently uses raw numbers instead of defines.
var/newmessagepriority = 0
// 0 = no new message
// 1 = normal priority
// 2 = high priority
var/newmessagepriority = RQ_NONEW_MESSAGES
// RQ_NONEWMESSAGES = no new message
// RQ_NORMALPRIORITY = normal priority
// RQ_HIGHPRIORITY = high priority
var/screen = RCS_MAINMENU
var/silent = 0 // set to 1 for it not to beep all the time
// var/hackState = 0
// 0 = not hacked
// 1 = hacked
var/announcementConsole = 0
// 0 = This console cannot be used to send department announcements
// 1 = This console can send department announcementsf
var/open = 0 // 1 if open
var/silent = FALSE // set to TRUE for it not to beep all the time
var/announcementConsole = FALSE
// FALSE = This console cannot be used to send department announcements
// TRUE = This console can send department announcementsf
var/announceAuth = 0 //Will be set to 1 when you authenticate yourself for announcements
var/msgVerified = "" //Will contain the name of the person who varified it
var/msgStamped = "" //If a message is stamped, this will contain the stamp name
@@ -82,15 +82,15 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
else
icon_state = "req_comp[newmessagepriority]"
/obj/machinery/requests_console/New()
/obj/machinery/requests_console/Initialize(mapload)
Radio = new /obj/item/radio(src)
Radio.listening = 1
Radio.config(list("Engineering","Medical","Supply","Command","Science","Service","Security", "AI Private" = 0))
Radio.listening = TRUE
Radio.config(list("Engineering", "Medical", "Supply", "Command", "Science", "Service", "Security", "AI Private" = FALSE))
Radio.follow_target = src
..()
. = ..()
announcement.title = "[department] announcement"
announcement.newscast = 0
announcement.newscast = FALSE
name = "[department] Requests Console"
GLOB.allRequestConsoles += src
@@ -101,14 +101,15 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
if(departmentType & RC_INFO)
GLOB.req_console_information |= department
// NOT BOOLEAN. DO NOT CONVERT.
set_light(1)
/obj/machinery/requests_console/Destroy()
GLOB.allRequestConsoles -= src
var/lastDeptRC = 1
var/lastDeptRC = TRUE
for(var/obj/machinery/requests_console/Console in GLOB.allRequestConsoles)
if(Console.department == department)
lastDeptRC = 0
lastDeptRC = FALSE
break
if(lastDeptRC)
if(departmentType & RC_ASSIST)
@@ -124,22 +125,22 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
if(stat & NOPOWER)
return
ui_interact(user)
tgui_interact(user)
/obj/machinery/requests_console/attack_hand(user as mob)
if(..(user))
return
ui_interact(user)
/obj/machinery/requests_console/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
tgui_interact(user)
/obj/machinery/requests_console/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "request_console.tmpl", "[department] Request Console", 520, 410)
ui = new(user, src, ui_key, "RequestConsole", "[department] Request Console", 520, 410, master_ui, state)
ui.open()
ui.set_auto_update(1)
/obj/machinery/requests_console/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
var/data[0]
/obj/machinery/requests_console/tgui_data(mob/user)
var/list/data = list()
data["department"] = department
data["screen"] = screen
@@ -164,142 +165,130 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
return data
/obj/machinery/requests_console/Topic(href, href_list)
/obj/machinery/requests_console/tgui_act(action, list/params)
if(..())
return 1
usr.set_machine(src)
return
add_fingerprint(usr)
if(reject_bad_text(href_list["write"]))
recipient = href_list["write"] //write contains the string of the receiving department's name
. = 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
reset_message(1)
switch(action)
if("writeInput")
if(reject_bad_text(params["write"]))
recipient = params["write"] //write contains the string of the receiving department's name
if(href_list["writeAnnouncement"])
var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
if(new_message)
message = new_message
else
reset_message(1)
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 = RQ_NORMALPRIORITY
if("2")
priority = RQ_HIGHPRIORITY
else
priority = RQ_NONEW_MESSAGES
else
reset_message(TRUE)
if(href_list["sendAnnouncement"])
if(!announcementConsole) return
announcement.Announce(message, msg_sanitized = 1)
reset_message(1)
if("writeAnnouncement")
var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
if(new_message)
message = new_message
else
reset_message(TRUE)
if( href_list["department"] && message )
var/log_msg = message
var/pass = 0
screen = RCS_SENTFAIL
for(var/obj/machinery/message_server/MS in GLOB.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
if(recipient in ENGI_ROLES)
radiochannel = "Engineering"
if(recipient in SEC_ROLES)
radiochannel = "Security"
if(recipient in MISC_ROLES)
radiochannel = "Service"
if(recipient in MED_ROLES)
radiochannel = "Medical"
if(recipient in COM_ROLES)
radiochannel = "Command"
if(recipient in SCI_ROLES)
radiochannel = "Science"
if(recipient == "AI")
radiochannel = "AI Private"
if(recipient == "Cargo Bay")
radiochannel = "Supply"
message_log += "<B>Message sent to [recipient] at [station_time_timestamp()]</B><BR>[message]"
Radio.autosay("Alert; a new requests console message received for [recipient] from [department]", null, "[radiochannel]")
else
atom_say("No server detected!")
if("sendAnnouncement")
if(!announcementConsole)
return
announcement.Announce(message, msg_sanitized = TRUE)
reset_message(TRUE)
//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 GLOB.allRequestConsoles)
if(Console.department == department)
Console.newmessagepriority = 0
Console.icon_state = "req_comp0"
Console.set_light(1)
if(tempScreen == RCS_MAINMENU)
reset_message()
screen = tempScreen
if("department")
if(!message)
return
var/log_msg = message
var/pass = FALSE
screen = RCS_SENTFAIL
for(var/M in GLOB.message_servers)
var/obj/machinery/message_server/MS = M
if(!MS.active)
continue
MS.send_rc_message(ckey(params["department"]), department, log_msg, msgStamped, msgVerified, priority)
pass = TRUE
if(pass)
screen = RCS_SENTPASS
if(recipient in ENGI_ROLES)
radiochannel = "Engineering"
else if(recipient in SEC_ROLES)
radiochannel = "Security"
else if(recipient in MISC_ROLES)
radiochannel = "Service"
else if(recipient in MED_ROLES)
radiochannel = "Medical"
else if(recipient in COM_ROLES)
radiochannel = "Command"
else if(recipient in SCI_ROLES)
radiochannel = "Science"
else if(recipient == "AI")
radiochannel = "AI Private"
else if(recipient == "Cargo Bay")
radiochannel = "Supply"
message_log += "Message sent to [recipient] at [station_time_timestamp()] - [message]"
Radio.autosay("Alert; a new requests console message received for [recipient] from [department]", null, "[radiochannel]")
else
atom_say("No server detected!")
if(href_list["shipSelect"])
ship_tag_name = href_list["shipSelect"]
ship_tag_index = GLOB.TAGGERLOCATIONS.Find(ship_tag_name)
//Handle screen switching
if("setScreen")
// Ensures screen cant be set higher or lower than it should be
var/tempScreen = round(clamp(text2num(params["setScreen"]), 0, 10), 1)
if(tempScreen == RCS_ANNOUNCE && !announcementConsole)
return
if(tempScreen == RCS_VIEWMSGS)
for(var/obj/machinery/requests_console/Console in GLOB.allRequestConsoles)
if(Console.department == department)
Console.newmessagepriority = RQ_NONEW_MESSAGES
Console.icon_state = "req_comp0"
Console.set_light(1)
if(tempScreen == RCS_MAINMENU)
reset_message()
screen = tempScreen
//Handle Shipping Label Printing
if(href_list["printLabel"])
var/error_message = ""
if(!ship_tag_index)
error_message = "Please select a destination."
else if(!msgVerified)
error_message = "Please verify shipper ID."
else if(world.time < print_cooldown)
error_message = "Please allow the printer time to prepare the next shipping label."
if(error_message)
atom_say("[error_message]")
return
print_label(ship_tag_name, ship_tag_index)
shipping_log += "<B>Shipping Label printed for [ship_tag_name]</b><br>[msgVerified]"
reset_message(1)
if("shipSelect")
ship_tag_name = params["shipSelect"]
ship_tag_index = GLOB.TAGGERLOCATIONS.Find(ship_tag_name)
//Handle silencing the console
if(href_list["toggleSilent"])
silent = !silent
//Handle Shipping Label Printing
if("printLabel")
var/error_message
if(!ship_tag_index)
error_message = "Please select a destination."
else if(!msgVerified)
error_message = "Please verify shipper ID."
else if(world.time < print_cooldown)
error_message = "Please allow the printer time to prepare the next shipping label."
if(error_message)
atom_say("[error_message]")
return
print_label(ship_tag_name, ship_tag_index)
shipping_log += "Shipping Label printed for [ship_tag_name] - [msgVerified]"
reset_message(TRUE)
//Handle silencing the console
if("toggleSilent")
silent = !silent
SSnanoui.update_uis(src)
return
//err... hacking code, which has no reason for existing... but anyway... it was once supposed to unlock priority 3 messanging on that console (EXTREME priority...), but the code for that was removed.
/obj/machinery/requests_console/attackby(obj/item/I, mob/user)
/*
if(istype(O, /obj/item/crowbar))
if(open)
open = 0
icon_state="req_comp0"
else
open = 1
if(hackState == 0)
icon_state="req_comp_open"
else if(hackState == 1)
icon_state="req_comp_rewired"
if(istype(O, /obj/item/screwdriver))
if(open)
if(hackState == 0)
hackState = 1
icon_state="req_comp_rewired"
else if(hackState == 1)
hackState = 0
icon_state="req_comp_open"
else
to_chat(user, "You can't do much with that.")*/
if(istype(I, /obj/item/card/id))
if(inoperable(MAINT))
return
if(screen == RCS_MESSAUTH)
var/obj/item/card/id/T = I
msgVerified = text("<font color='green'><b>Verified by [T.registered_name] ([T.assignment])</b></font>")
updateUsrDialog()
msgVerified = "Verified by [T.registered_name] ([T.assignment])"
SStgui.update_uis(src)
if(screen == RCS_ANNOUNCE)
var/obj/item/card/id/ID = I
if(ACCESS_RC_ANNOUNCE in ID.GetAccess())
@@ -308,31 +297,31 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
else
reset_message()
to_chat(user, "<span class='warning'>You are not authorized to send announcements.</span>")
updateUsrDialog()
SStgui.update_uis(src)
if(screen == RCS_SHIPPING)
var/obj/item/card/id/T = I
msgVerified = text("<font color='green'><b>Sender verified as [T.registered_name] ([T.assignment])</b></font>")
updateUsrDialog()
msgVerified = "Sender verified as [T.registered_name] ([T.assignment])"
SStgui.update_uis(src)
if(istype(I, /obj/item/stamp))
if(inoperable(MAINT))
return
if(screen == RCS_MESSAUTH)
var/obj/item/stamp/T = I
msgStamped = text("<font color='blue'><b>Stamped with the [T.name]</b></font>")
updateUsrDialog()
msgStamped = "Stamped with the [T.name]"
SStgui.update_uis(src)
else
return ..()
/obj/machinery/requests_console/proc/reset_message(var/mainmenu = 0)
/obj/machinery/requests_console/proc/reset_message(mainmenu = FALSE)
message = ""
recipient = ""
priority = 0
priority = RQ_NONEW_MESSAGES
msgVerified = ""
msgStamped = ""
announceAuth = 0
announceAuth = FALSE
announcement.announcer = ""
ship_tag_name = ""
ship_tag_index = 0
ship_tag_index = FALSE
if(mainmenu)
screen = RCS_MAINMENU
@@ -340,23 +329,23 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
var/linkedSender
if(istype(source, /obj/machinery/requests_console))
var/obj/machinery/requests_console/sender = source
linkedSender = "<a href='?src=[UID()];write=[ckey(sender.department)]'[sender.department]</a>"
linkedSender = sender.department
else
capitalize(source)
linkedSender = source
capitalize(title)
if(src.newmessagepriority < priority)
src.newmessagepriority = priority
if(newmessagepriority < priority)
newmessagepriority = priority
update_icon()
if(!src.silent)
playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 1)
if(!silent)
playsound(loc, 'sound/machines/twobeep.ogg', 50, TRUE)
atom_say(title)
switch(priority)
if(2) // High
src.message_log += "<span class='bad'>High Priority</span><BR><b>From:</b> [linkedSender]<BR>[message]"
if(RQ_HIGHPRIORITY) // High
message_log += "High Priority - From: [linkedSender] - [message]"
else // Normal
src.message_log += "<b>From:</b> [linkedSender]<BR>[message]"
message_log += "From: [linkedSender] - [message]"
set_light(2)
/obj/machinery/requests_console/proc/print_label(tag_name, tag_index)
@@ -364,3 +353,7 @@ GLOBAL_LIST_EMPTY(allRequestConsoles)
sp.sortTag = tag_index
sp.update_desc()
print_cooldown = world.time + 600 //1 minute cooldown before you can print another label, but you can still configure the next one during this time
#undef RQ_NONEW_MESSAGES
#undef RQ_NORMALPRIORITY
#undef RQ_HIGHPRIORITY
+20 -19
View File
@@ -86,31 +86,32 @@ GLOBAL_LIST_EMPTY(message_servers)
/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]"
if(id_auth)
authmsg += "[id_auth]<br>"
authmsg += " - [id_auth]"
if(stamp)
authmsg += "[stamp]<br>"
for(var/obj/machinery/requests_console/Console in GLOB.allRequestConsoles)
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>"
authmsg += " - [stamp]"
for(var/C in GLOB.allRequestConsoles)
var/obj/machinery/requests_console/RC = C
if(ckey(RC.department) == ckey(recipient))
if(RC.inoperable())
RC.message_log += "Message lost due to console failure. Please contact [station_name()]'s system administrator or AI for technical assistance."
continue
if(Console.newmessagepriority < priority)
Console.newmessagepriority = priority
Console.icon_state = "req_comp[priority]"
if(RC.newmessagepriority < priority)
RC.newmessagepriority = priority
RC.icon_state = "req_comp[priority]"
switch(priority)
if(2)
if(!Console.silent)
playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1)
Console.atom_say("PRIORITY Alert in [sender]")
Console.message_log += "<B><FONT color='red'>High Priority message from <A href='?src=[Console.UID()];write=[sender]'>[sender]</A></FONT></B><BR>[authmsg]"
if(!RC.silent)
playsound(RC.loc, 'sound/machines/twobeep.ogg', 50, 1)
RC.atom_say("PRIORITY Alert in [sender]")
RC.message_log += "High Priority message from [sender]: [authmsg]"
else
if(!Console.silent)
playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1)
Console.atom_say("Message from [sender]")
Console.message_log += "<B>Message from <A href='?src=[Console.UID()];write=[sender]'>[sender]</A></B><BR>[authmsg]"
Console.set_light(2)
if(!RC.silent)
playsound(RC.loc, 'sound/machines/twobeep.ogg', 50, 1)
RC.atom_say("Message from [sender]")
RC.message_log += "Message [sender]: [authmsg]"
RC.set_light(2)
/obj/machinery/message_server/attack_hand(user as mob)
// to_chat(user, "<span class='notice'>There seem to be some parts missing from this server. They should arrive on the station in a few days, give or take a few CentComm delays.</span>")
-152
View File
@@ -1,152 +0,0 @@
<!--
Title: Request Console
Used In File(s): \code\game\machinery\requests_console.dm
#define RCS_MAINMENU 0 // Main men
#define RCS_RQSUPPLY 1 // Request supplies
#define RCS_RQASSIST 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', 'arrow-left', { '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', 'arrow-left', { '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', 'arrow-left', { 'setScreen' : 0 })}}</div>
{{else data.screen == 4}}
<div class="item"><b>Message sent successfully.</b></div>
<div class="item">{{:helper.link('Continue', 'arrow-right', { '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', 'arrow-right', { 'setScreen' : 0 })}}</div>
{{else data.screen == 6}}
<div class="statusDisplay" style="overflow: auto;">
{{for data.message_log}}
<div class="item">{{:value}}</div>
{{empty}}
<div class="item">No messages have been recieved.</div>
{{/for}}
</div>
<div class="item">{{:helper.link('Back', 'arrow-left', { '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', 'arrow-right', { 'department' : data.recipient })}}
{{:helper.link('Back', 'arrow-left', { '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', { 'sendAnnouncement' : 1 }, (data.announceAuth && data.message) ? null : 'disabled' )}}
{{:helper.link('Back', 'arrow-left', { 'setScreen' : 0 })}}
</div>
{{else data.screen == 9}}
<div class="item"><h3>Print a Shipping Label.</h3></div>
<div class="statusDisplay" style="overflow: auto;">
<div class="item"><b>Destination:</b> {{:data.shipDest}}</div>
<div class="item"><b>Validated by:</b> {{:data.msgVerified}}</div>
<div class="item">{{:helper.link('Print Label', null, { 'printLabel' : 1 })}}</div>
</div>
<table class="block">
{{for data.ship_dept}}
<tr>
<td><div class="itemLabelWidest" align="right">{{:value}} -</div></td>
<td><div class="item">{{:helper.link('Select', null, { 'shipSelect' : value })}}</div></td>
</tr>
{{empty}}
<tr><td><div class="itemLabel">There are no available shipping destinations.</div></td></tr>
{{/for}}
</table><br>
<div class="item">{{:helper.link('Back', 'arrow-left', { 'setScreen' : 0 })}}</div>
{{else data.screen == 10}}
<div class="statusDisplay" style="overflow: auto;">
{{for data.shipping_log}}
<div class="item">{{:value}}</div>
{{empty}}
<div class="item">No shipping labels have been printed.</div>
{{/for}}
</div>
<div class="item">{{:helper.link('Back', 'arrow-left', { '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 ? 'envelope' : 'envelope-o', { '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>
<div class="item">{{:helper.link('Print Shipping Label', 'gear', { 'setScreen' : 9})}}</div>
<div class="item">{{:helper.link('View Shipping Logs', 'gear', { 'setScreen' : 10})}}</div>
<br>
{{if data.announcementConsole}}
<div class="item">{{:helper.link('Send Station-wide Announcement', 'signal', { 'setScreen' : 8})}}</div>
<br>
{{/if}}
<div class="item">{{:helper.link(data.silent ? 'Speaker OFF' : 'Speaker ON', data.silent ? 'volume-off' : 'volume-up', { 'toggleSilent' : 1})}}</div>
{{/if}}
@@ -0,0 +1,401 @@
import { useBackend } from "../backend";
import { Button, LabeledList, Box, Section } from "../components";
import { Window } from "../layouts";
export const RequestConsole = (props, context) => {
const { act, data } = useBackend(context);
const {
screen,
} = data;
const pickPage = index => {
switch (index) {
case 0:
return <MainMenu />;
case 1:
return <DepartmentList purpose="ASSISTANCE" />;
case 2:
return <DepartmentList purpose="SUPPLIES" />;
case 3:
return <DepartmentList purpose="INFO" />;
case 4:
return <MessageResponse type="SUCCESS" />;
case 5:
return <MessageResponse type="FAIL" />;
case 6:
return <MessageLog type="MESSAGES" />;
case 7:
return <MessageAuth />;
case 8:
return <StationAnnouncement />;
case 9:
return <PrintShippingLabel />;
case 10:
return <MessageLog type="SHIPPING" />;
default:
return "WE SHOULDN'T BE HERE!";
}
};
return (
<Window>
<Window.Content scrollable>
{pickPage(screen)}
</Window.Content>
</Window>
);
};
const MainMenu = (props, context) => {
const { act, data } = useBackend(context);
const {
newmessagepriority,
announcementConsole,
silent,
} = data;
let messageInfo;
if (newmessagepriority === 1) {
messageInfo = (
<Box color="red">
There are new messages
</Box>
);
} else if (newmessagepriority === 2) {
messageInfo = (
<Box color="red" bold>
NEW PRIORITY MESSAGES
</Box>
);
}
return (
<Section title="Main Menu">
{messageInfo}
<Box mt={2}>
<Button
content="View Messages"
icon={newmessagepriority > 0 ? "envelope-open-text" : "envelope"}
onClick={
() => act('setScreen', { setScreen: 6 })
} />
</Box>
<Box mt={2}>
<Box>
<Button
content="Request Assistance"
icon="hand-paper"
onClick={
() => act('setScreen', { setScreen: 1 })
} />
</Box>
<Box>
<Button
content="Request Supplies"
icon="box"
onClick={
() => act('setScreen', { setScreen: 2 })
} />
</Box>
<Box>
<Button
content="Relay Anonymous Information"
icon="comment"
onClick={
() => act('setScreen', { setScreen: 3 })
} />
</Box>
</Box>
<Box mt={2}>
<Box>
<Button
content="Print Shipping Label"
icon="tag"
onClick={
() => act('setScreen', { setScreen: 9 })
} />
</Box>
<Box>
<Button
content="View Shipping Logs"
icon="clipboard-list"
onClick={
() => act('setScreen', { setScreen: 10 })
} />
</Box>
</Box>
{!!announcementConsole && (
<Box mt={2}>
<Button
content="Send Station-Wide Announcement"
icon="bullhorn"
onClick={
() => act('setScreen', { setScreen: 8 })
} />
</Box>
)}
<Box mt={2}>
<Button
content={silent ? "Speaker Off" : "Speaker On"}
selected={!silent}
icon={silent ? "volume-mute" : "volume-up"}
onClick={
() => act('toggleSilent')
} />
</Box>
</Section>
);
};
const DepartmentList = (props, context) => {
const { act, data } = useBackend(context);
const {
department,
} = data;
let list2iterate;
let sectionTitle;
switch (props.purpose) {
case "ASSISTANCE":
list2iterate = data.assist_dept;
sectionTitle = "Request assistance from another department";
break;
case "SUPPLIES":
list2iterate = data.supply_dept;
sectionTitle = "Request supplies from another department";
break;
case "INFO":
list2iterate = data.info_dept;
sectionTitle = "Relay information to another department";
break;
}
return (
<Section title={sectionTitle} buttons={
<Button
content="Back"
icon="arrow-left"
onClick={
() => act('setScreen', { setScreen: 0 })
} />
}>
<LabeledList>
{list2iterate.filter(d => (d !== department)).map(d => (
<LabeledList.Item key={d} label={d}>
<Button
content="Message"
icon="envelope"
onClick={
() => act('writeInput', { write: d, priority: 1 })
} />
<Button
content="High Priority"
icon="exclamation-circle"
onClick={
() => act('writeInput', { write: d, priority: 2 })
} />
</LabeledList.Item>
))}
</LabeledList>
</Section>
);
};
const MessageResponse = (props, context) => {
const { act, data } = useBackend(context);
let sectionTitle;
switch (props.type) {
case "SUCCESS":
sectionTitle = "Message sent successfully";
break;
case "FAIL":
sectionTitle = "Request supplies from another department";
break;
}
return (
<Section title={sectionTitle} buttons={
<Button
content="Back"
icon="arrow-left"
onClick={
() => act('setScreen', { setScreen: 0 })
} />
} />
);
};
const MessageLog = (props, context) => {
const { act, data } = useBackend(context);
let list2iterate;
let sectionTitle;
switch (props.type) {
case "MESSAGES":
list2iterate = data.message_log;
sectionTitle = "Message Log";
break;
case "SHIPPING":
list2iterate = data.shipping_log;
sectionTitle = "Shipping label print log";
break;
}
return (
<Section title={sectionTitle} buttons={
<Button
content="Back"
icon="arrow-left"
onClick={
() => act('setScreen', { setScreen: 0 })
} />
} >
{list2iterate.map(m => (
<Box key={m}>
{m}
</Box>
))}
</Section>
);
};
const MessageAuth = (props, context) => {
const { act, data } = useBackend(context);
const {
recipient,
message,
msgVerified,
msgStamped,
} = data;
return (
<Section title="Message Authentication" buttons={
<Button
content="Back"
icon="arrow-left"
onClick={
() => act('setScreen', { setScreen: 0 })
} />
} >
<LabeledList>
<LabeledList.Item label="Recipient">
{recipient}
</LabeledList.Item>
<LabeledList.Item label="Message">
{message}
</LabeledList.Item>
<LabeledList.Item label="Validated by" color="green">
{msgVerified}
</LabeledList.Item>
<LabeledList.Item label="Stamped by" color="blue">
{msgStamped}
</LabeledList.Item>
</LabeledList>
<Button
fluid
mt={1}
textAlign="center"
content="Send Message"
icon="envelope"
onClick={
() => act('department', { department: recipient })
} />
</Section>
);
};
const StationAnnouncement = (props, context) => {
const { act, data } = useBackend(context);
const {
message,
announceAuth,
} = data;
return (
<Section title="Station-Wide Announcement" buttons={
<Button
content="Back"
icon="arrow-left"
onClick={
() => act('setScreen', { setScreen: 0 })
} />
} >
<Button
content={message ? message : "Edit Message"}
icon="edit"
onClick={
() => act('writeAnnouncement')
} />
{announceAuth ? (
<Box mt={1} color="green">
ID verified. Authentication accepted.
</Box>
) : (
<Box mt={1}>
Swipe your ID card to authenticate yourself.
</Box>
)}
<Button
fluid
mt={1}
textAlign="center"
content="Send Announcement"
icon="bullhorn"
disabled={!(announceAuth && message)}
onClick={
() => act('sendAnnouncement')
} />
</Section>
);
};
const PrintShippingLabel = (props, context) => {
const { act, data } = useBackend(context);
const {
shipDest,
msgVerified,
ship_dept,
} = data;
return (
<Section title="Print Shipping Label" buttons={
<Button
content="Back"
icon="arrow-left"
onClick={
() => act('setScreen', { setScreen: 0 })
} />
} >
<LabeledList>
<LabeledList.Item label="Destination">
{shipDest}
</LabeledList.Item>
<LabeledList.Item label="Validated by">
{msgVerified}
</LabeledList.Item>
</LabeledList>
<Button
fluid
mt={1}
textAlign="center"
content="Print Label"
icon="print"
disabled={!(shipDest && msgVerified)}
onClick={
() => act('printLabel')
} />
<Section title="Destinations" mt={1}>
<LabeledList>
{ship_dept.map(d => (
<LabeledList.Item label={d} key={d}>
<Button
content={shipDest === d ? "Selected" : "Select"}
selected={shipDest === d}
onClick={
() => act('shipSelect', { shipSelect: d })
} />
</LabeledList.Item>
))}
</LabeledList>
</Section>
</Section>
);
};
File diff suppressed because one or more lines are too long